Löve Frames - A GUI Library
Re: Löve Frames - A GUI Library
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.
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.
- Attachments
-
- panelExt.love
- Simple example of 3 extended panels with customized draw routines.
- (134.08 KiB) Downloaded 446 times
Re: Löve Frames - A GUI Library
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)!
So Clever!!!
Please do not consider my previous contribution!
Thank you Kenny Shields, you did a great work!
Kindest Regards,
Pier Andrea.
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
Please do not consider my previous contribution!
Thank you Kenny Shields, you did a great work!
Kindest Regards,
Pier Andrea.
- Cryogenical
- Prole
- Posts: 49
- Joined: Mon Apr 28, 2014 5:23 pm
Re: Löve Frames - A GUI Library
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.
EDIT: Also, how do I remove something from a frame, say, a button?
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
- DaedalusYoung
- Party member
- Posts: 413
- Joined: Sun Jul 14, 2013 8:04 pm
Re: Löve Frames - A GUI Library
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.
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.
- Cryogenical
- Prole
- Posts: 49
- Joined: Mon Apr 28, 2014 5:23 pm
Re: Löve Frames - A GUI Library
How do I get a slider to constantly update?
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
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'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
- Nikolai Resokav
- Party member
- Posts: 140
- Joined: Wed Apr 28, 2010 12:51 am
- Location: United States
Re: Löve Frames - A GUI Library
Something like this should work for what you are trying to do:Cryogenical wrote:How do I get a slider to constantly update?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.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'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.
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
Love Frames is in alpha, so incomplete documentation and functionality should be expected.Cryogenical wrote: these docs are hard to understand
also I feel like everthing is missing functions
- Cryogenical
- Prole
- Posts: 49
- Joined: Mon Apr 28, 2014 5:23 pm
Re: Löve Frames - A GUI Library
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%).
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 ;-;
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
- DaedalusYoung
- Party member
- Posts: 413
- Joined: Sun Jul 14, 2013 8:04 pm
Re: Löve Frames - A GUI Library
Cryogenical wrote: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
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
Code: Select all
volume = choice / 10
if volume == 0.5 then volume = 1 end
TEsound.volume("tag", volume)
- Cryogenical
- Prole
- Posts: 49
- Joined: Mon Apr 28, 2014 5:23 pm
Re: Löve Frames - A GUI Library
your genius
That worked well, thank you very much man; I need to go practice this shit though
That worked well, thank you very much man; I need to go practice this shit though
Re: Löve Frames - A GUI Library
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!
Thank you again!
Who is online
Users browsing this forum: alexjgriffith and 2 guests