Page 23 of 41

Re: Löve Frames - A GUI Library

Posted: Sun Aug 17, 2014 2:37 am
by paserra
Hello,
I'm new in this forum and I'll be glad to say thank you to all of you for your passion and your coding efforts.
I've started to code in LUA from one week and to use Löve from 3 days and I consider this programming language powerful and funny and the Löve implementation genial.
Thank you also for the amazig library Löve Frames.
I've uploaded for you the source I've developed Today: the creation of a custom panel component (panelExt) without the modification of the original code, with a customizable draw routine. This is just prototye and you can use it as a model for extending the other components.
Please help me to do some optimizations and to correct the code (I have a lot of things to learn about Lua and Löve).
Regards.
Pier Andrea.

Re: Löve Frames - A GUI Library

Posted: Sun Aug 17, 2014 2:57 am
by paserra
Ops,
I've found just now a very simple and elegant solution already implemented in the Löve Frames Library (I do not have to reinvent the wheel)!

Code: Select all

local myPanel = loveframes.Create("panel")
myPanel.Draw = function(object)
    love.graphics.setColor(255, 0, 0, 255)
    love.graphics.rectangle("fill", object.x, object.y, object.width, object.height)
end
So Clever!!!
Please do not consider my previous contribution!
Thank you Kenny Shields, you did a great work!
Kindest Regards,
Pier Andrea.

Re: Löve Frames - A GUI Library

Posted: Wed Aug 27, 2014 5:51 pm
by Cryogenical
I've been trying to make a simple little learning program to get a feel for this as I have two ambitious projects using this.
The progress bar seems to only update once to 1/10, then when I click the button again it doesn't do anything.

Code: Select all

function love.load()
    local value = 0
    local parentframe = loveframes.Create("frame")
    parentframe:SetName("Playlist"):SetPos(0,0):SetSize(300,600)

    local progressbar = loveframes.Create("progressbar", parentframe)
        progressbar:SetPos(5,30):SetWidth(290):SetLerpRate(10):SetMinMax(0,10):SetLerp(true)
    
    local button2 = loveframes.Create("button", parentframe)
    button2:SetSize(40,40):Center():SetText("Play")
    button2.OnClick = function(object, x, y)
        button2:SetText(progressbar:GetMax())
        if not progressbar:GetCompleted() then
        progressbar:SetValue(value + 1)
        end
    end
end
EDIT: Also, how do I remove something from a frame, say, a button?

Re: Löve Frames - A GUI Library

Posted: Wed Aug 27, 2014 7:49 pm
by DaedalusYoung
You set value to 0, then in your OnClick function, you set progressbar to value + 1. You do not appear to change the value of value, so that will always be 0, and value + 1 then of course will always be 1, no matter how many times you call it.

I don't know the particulars of the library, but my suggestion would be to completely get rid of value and just use something like GetValue (if that is an existing function) on progressbar to determine the new value.

Re: Löve Frames - A GUI Library

Posted: Thu Aug 28, 2014 7:44 pm
by Cryogenical
How do I get a slider to constantly update?

Code: Select all

local volumeslider = loveframes.Create("slider", parentframe)
    volumeslider:SetPos(275,175):SetSlideType("vertical"):SetHeight(250):SetButtonSize(20,10):SetMinMax(0,10):SetDecimals(10)
    volumeslider:SetScrollDecrease(1):SetScrollIncrease(1)
    local increase = volumeslider:GetScrollIncrease()
    local decrease = volumeslider:GetScrollDecrease()
    volumeslider.OnValueChanged = function(object)
        if increase then
            TEsound.volume("tag", 2)
        end
        if decrease then
            TEsound.volume("tag", .1)
        end
I have a slider to change the volume of a song, and I want it to increase/decrease based on, well, if it was moved up or down.
I've been trying to get it to have "notches", where you have 10 volume settings based on 10%, 20%, etc. I thought it would be related to the SetDecimal function, but it doesn't seem to do much. I'm probably just using it wrong.
I just tried to SetValue(0), so it started on the bottom. When I moved the slider up to "increase", the volume still lowered.

The volume only changes once, no matter which way I throw the slider around.

these docs are hard to understand
also I feel like everthing is missing functions

Re: Löve Frames - A GUI Library

Posted: Sat Sep 06, 2014 4:04 pm
by Nikolai Resokav
Cryogenical wrote:How do I get a slider to constantly update?

Code: Select all

local volumeslider = loveframes.Create("slider", parentframe)
    volumeslider:SetPos(275,175):SetSlideType("vertical"):SetHeight(250):SetButtonSize(20,10):SetMinMax(0,10):SetDecimals(10)
    volumeslider:SetScrollDecrease(1):SetScrollIncrease(1)
    local increase = volumeslider:GetScrollIncrease()
    local decrease = volumeslider:GetScrollDecrease()
    volumeslider.OnValueChanged = function(object)
        if increase then
            TEsound.volume("tag", 2)
        end
        if decrease then
            TEsound.volume("tag", .1)
        end
I have a slider to change the volume of a song, and I want it to increase/decrease based on, well, if it was moved up or down.
I've been trying to get it to have "notches", where you have 10 volume settings based on 10%, 20%, etc. I thought it would be related to the SetDecimal function, but it doesn't seem to do much. I'm probably just using it wrong.
I just tried to SetValue(0), so it started on the bottom. When I moved the slider up to "increase", the volume still lowered.

The volume only changes once, no matter which way I throw the slider around.
Something like this should work for what you are trying to do:

Code: Select all

    local volumeslider = loveframes.Create("slider")
    volumeslider:SetPos(275, 175)
    volumeslider:SetHeight(250)
    volumeslider:SetButtonSize(20, 10)
    volumeslider:SetMinMax(0, 10)
    volumeslider:SetDecimals(0)
    volumeslider:SetScrollDecrease(1)
    volumeslider:SetScrollIncrease(1)
    volumeslider:SetSlideType("vertical")
    volumeslider.OnValueChanged = function(object)
        TEsound.volume("tag", object:GetValue())
    end
Cryogenical wrote: these docs are hard to understand
also I feel like everthing is missing functions
Love Frames is in alpha, so incomplete documentation and functionality should be expected.

Re: Löve Frames - A GUI Library

Posted: Mon Sep 08, 2014 5:47 pm
by Cryogenical
It's still working incorrectly. The slider starts at the bottom (which means you could only increase the volume in theory!) and the increasing isn't working either, but when I increase the value and try to bring it down, when the button reaches the bottom the sound is muted until the slider is raised again.

I think the problem is the slider's value, but I could be mistaken.

EDIT: Just tried using a numberchoice, and it worked. Also, found out that I can't set the volume higher than the source's starting value (100%).

Code: Select all

local volume = 1
    local volumechoice = loveframes.Create("multichoice", parentframe)
    volumechoice:SetPos(50, 75):SetChoice(5)
        for i=1, 5 do 
        volumechoice:AddChoice(i)
        end
    volumechoice.OnChoiceSelected = function(object, choice)
            if choice == 1 then volume = .1 end
            TEsound.volume("tag", volume)
            if choice == 2 then volume = .2 end
            TEsound.volume("tag", volume)
            if choice == 3 then volume = .3 end
            TEsound.volume("tag", volume)
            if choice == 4 then volume = .4 end
            TEsound.volume("tag", volume)
            if choice == 5 then volume = 1 end
            TEsound.volume("tag", volume)
        end
I feel like there's a much easier way to utilize the if block, maybe a list or something? This right here is my weak point ;-;

Re: Löve Frames - A GUI Library

Posted: Mon Sep 08, 2014 6:09 pm
by DaedalusYoung
Cryogenical wrote:

Code: Select all

    volumechoice.OnChoiceSelected = function(object, choice)
            if choice == 1 then volume = .1 end
            TEsound.volume("tag", volume)
            if choice == 2 then volume = .2 end
            TEsound.volume("tag", volume)
            if choice == 3 then volume = .3 end
            TEsound.volume("tag", volume)
            if choice == 4 then volume = .4 end
            TEsound.volume("tag", volume)
            if choice == 5 then volume = 1 end
            TEsound.volume("tag", volume)
        end
I feel like there's a much easier way to utilize the if block, maybe a list or something? This right here is my weak point ;-;

Code: Select all

volume = choice / 10
if volume == 0.5 then volume = 1 end
TEsound.volume("tag", volume)

Re: Löve Frames - A GUI Library

Posted: Mon Sep 08, 2014 7:43 pm
by Cryogenical
your genius
That worked well, thank you very much man; I need to go practice this shit though

Re: Löve Frames - A GUI Library

Posted: Sun Sep 14, 2014 3:47 pm
by megalukes
I'm here just to thank you for this library. I was going to start programming an editor for my game from sketch but Löve Frames saved my a lot of time. I'm still impressed about how easy it is to make cool stuff with it. Are there any new features you intend to implement in the future?

Thank you again! :awesome: