Löve Frames - A GUI Library

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Nikolai Resokav
Party member
Posts: 140
Joined: Wed Apr 28, 2010 12:51 am
Location: United States

Re: Löve Frames - A GUI Library

Post by Nikolai Resokav »

AntonioModer wrote:BUG:
LOVE 0.8.0
Löve Frames v0.9.3.2

Code: Select all

The button item 1 was clicked!
Info was selected.
Error: libraries/loveframes/objects/frame.lua:382: attempt to index field '?' (a
 nil value)
stack traceback:
        libraries/loveframes/objects/frame.lua:382: in function 'MakeTop'
        libraries/loveframes/objects/frame.lua:224: in function 'mousepressed'
        libraries/loveframes/objects/frame.lua:234: in function 'mousepressed'
        libraries/loveframes/objects/base.lua:83: in function 'mousepressed'
        libraries/loveframes/init.lua:107: in function 'mousepressed'
        main.lua:331: in function 'mousepressed'
        [string "boot.lua"]:164: in function '?'
        [string "boot.lua"]:396: in function <[string "boot.lua"]:373>
        [C]: in function 'xpcall'
When i clicked left mouse on "frame1" (is children of "frame0").
BUG in function 'MakeTop', in variable 'key'.
If key = 0 then error.
My debug (in a hurry):

Code: Select all

--[[---------------------------------------------------------
	- func: MakeTop()
	- desc: makes the object the top object in the drawing
			order
--]]---------------------------------------------------------
function frame:MakeTop()
	
	local x, y            = love.mouse.getPosition()
	local key             = 0
	local base            = loveframes.base
	local basechildren    = base.children
	local numbasechildren = #basechildren
	
	if numbasechildren == 1 then
		return
	end
	
	if basechildren[numbasechildren] == self then
		return
	end
	
	-- make this the top object
	for k, v in ipairs(basechildren) do
		if v == self then
			table.remove(basechildren, k)
			table.insert(basechildren, self)
			key = k
			break
		end
	end
	
	-- MY DEBUG --
	if key == 0 and numbasechildren > 0 then
		key = 1;
	end
	
	basechildren[key]:mousepressed(x, y, "l")			-- BUG WITH "key" !!!
	
end
Sources: another person (other than me) it is difficult to understand them
This seems to be occurring from running MakeTop() on parent frames. I'll have a fix that prevents this bug from occurring in the next update. Thanks for finding this.
adrix89 wrote: Quick question on license.

The project is CC-BY-SA so does that mean it is contagious to my project?
If I make a game but not modify the library does that mean I have to license my game SA?
What is the authors interpretation of the license on this?
The license only applies to Love Frames. Just leave a copy of the license in the directory you installed Love Frames and you'll be good to go.
User avatar
SuperZazu
Citizen
Posts: 56
Joined: Sun Jun 10, 2012 2:06 pm
Location: France
Contact:

Re: Löve Frames - A GUI Library

Post by SuperZazu »

Really sorry about my problem, seems everything work fine now (I must've change something --' )
Sorry, thank you anyway!
User avatar
Nikolai Resokav
Party member
Posts: 140
Joined: Wed Apr 28, 2010 12:51 am
Location: United States

Re: Löve Frames - A GUI Library

Post by Nikolai Resokav »

SuperZazu wrote:Really sorry about my problem, seems everything work fine now (I must've change something --' )
Sorry, thank you anyway!
No worries! I'm glad everything is working for you now.
Divran
Prole
Posts: 12
Joined: Tue Mar 23, 2010 10:30 am

Re: Löve Frames - A GUI Library

Post by Divran »

Hello

I checked your util file, and I have some suggestions to make it better

First off, this code is messy

Code: Select all

			local parts = loveframes.util.SplitString(v, "([.])")
			local extension = parts[#parts]
			local name = restore(parts)
EDIT: Not exactly sure what the point of the restore function is, but it looks like it's just a strange way of writing "table.concat( t, "." )"
If it is, then it's completely pointless, since then you can just do "local name = v" instead.


You can do it much more easily by using patterns like so: EDIT: if "name" is supposed to include the full file path, simply replace "[^/]" with "."

Code: Select all

local name, extension = string.match( str, "([^/]+)%.(.+)$" )
And also, here, take this explode function. It was made by me and TomyLobo for Garry's Mod, since Garry used to use a very, very slow explode function (similar to the one you're currently using).

Code: Select all

local string_sub = string.sub
local function totable( str )
	local tbl = {}
	
	for i = 1, #str do
		tbl[i] = string_sub( str, i, i )
	end
	
	return tbl
end

local string_gsub = string.gsub
local string_gmatch = string.gmatch
-- Made by TomyLobo and Divran
function string.Explode(str, separator, withpattern)
	if (separator == "") then return totable( str ) end
	 
	local ret = {}
	local index,lastPosition = 1,1
	 
	-- Escape all magic characters in separator
	if not withpattern then separator = string_gsub( separator, "[%-%^%$%(%)%%%.%[%]%*%+%?]", "%%%1" ) end
	 
	-- Find the parts
	for startPosition,endPosition in string_gmatch( str, "()" .. separator.."()" ) do
		ret[index] = string_sub( str, lastPosition, startPosition-1)
		index = index + 1
		 
		-- Keep track of the position
		lastPosition = endPosition
	end
	 
	-- Add last part by using the position we stored
	ret[index] = string_sub( str, lastPosition)
	return ret
end
The look and feel of your gui is very nice! Great job

If you want more help optimizing your code, just ask. I have many tips and tricks
User avatar
Nikolai Resokav
Party member
Posts: 140
Joined: Wed Apr 28, 2010 12:51 am
Location: United States

Re: Löve Frames - A GUI Library

Post by Nikolai Resokav »

Divran wrote:Hello

I checked your util file, and I have some suggestions to make it better

First off, this code is messy
I am aware of how messy and unoptimized certain parts of my library are but you must understand that they were written with great haste and nearly a year ago, so there are obviously going to be a lot of improvements that need to be made. That said, I won't be updating that code for a while since it currently works fine and I have other things that require my attention at the moment. I do appreciate your input though, as well you interest in my library. Also, if you have suggestions for improvements or optimizations, please post them on the issue tracker as this will help me keep track of them.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Löve Frames - A GUI Library

Post by kikito »

Nikolai Resokav wrote:Also, if you have suggestions for improvements or optimizations, please post them on the issue tracker as this will help me keep track of them.
Nikolai doesn't mention this, but I'm very grateful when people take the time to create pull requests for my libraries, especially for small changes, like code cleanups and typos. Github's interface makes merging them extremely easy.
When I write def I mean function.
Divran
Prole
Posts: 12
Joined: Tue Mar 23, 2010 10:30 am

Re: Löve Frames - A GUI Library

Post by Divran »

Nikolai Resokav wrote:
Divran wrote:Hello

I checked your util file, and I have some suggestions to make it better

First off, this code is messy
I am aware of how messy and unoptimized certain parts of my library are but you must understand that they were written with great haste and nearly a year ago, so there are obviously going to be a lot of improvements that need to be made. That said, I won't be updating that code for a while since it currently works fine and I have other things that require my attention at the moment. I do appreciate your input though, as well you interest in my library. Also, if you have suggestions for improvements or optimizations, please post them on the issue tracker as this will help me keep track of them.
Aw, ok.

I've been planning on making my own gui in Lua for quite some time, and I'm only just getting started with it now. I thought love2d would be the perfect place to do it. I looked at your project for inspiration, and I found your way of debugging was quite nice with the yellow outlines (so I'm using it for mine as well, with some modifications). I haven't taken any code from your project, though.
Although I might look at it again sometime in the future if I get stuck with something you've already solved, if that's ok with you.
kikito wrote:
Nikolai Resokav wrote:Also, if you have suggestions for improvements or optimizations, please post them on the issue tracker as this will help me keep track of them.
Nikolai doesn't mention this, but I'm very grateful when people take the time to create pull requests for my libraries, especially for small changes, like code cleanups and typos. Github's interface makes merging them extremely easy.
Which of the libraries are yours? I thought Löve Frames was Nikolai's?
User avatar
Nikolai Resokav
Party member
Posts: 140
Joined: Wed Apr 28, 2010 12:51 am
Location: United States

Re: Löve Frames - A GUI Library

Post by Nikolai Resokav »

Divran wrote: I've been planning on making my own gui in Lua for quite some time, and I'm only just getting started with it now. I thought love2d would be the perfect place to do it. I looked at your project for inspiration, and I found your way of debugging was quite nice with the yellow outlines (so I'm using it for mine as well, with some modifications). I haven't taken any code from your project, though.
Although I might look at it again sometime in the future if I get stuck with something you've already solved, if that's ok with you.
You are free to use any code that you find in Love Frames with your project and modify it in any way you want. All I ask is that you give credit where credit is due.
Divran wrote: Which of the libraries are yours? I thought Löve Frames was Nikolai's?
Love Frames is my library but it uses a library made by kikito called middleclass for object-orientation.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Löve Frames - A GUI Library

Post by kikito »

Divran wrote: Which of the libraries are yours? I thought Löve Frames was Nikolai's?
I didn't want to imply that Löve Frames was mine. I have made a significant amount of libs, but LF is not one of them; it's Nikolai's.

What I meant was that, in general, it's easier for a change to be accepted if it comes in the form of a pull request on github, instead of a forum post - at least for small changes.

On github, when someone sends me a pull request, I can see the changes it'll make graphically and very easily, and merging them (if the pull request is well made) takes only one button press. For small changes, like optimisations, typos, etc, this is ideal, since I don't even have to open the console to accept them. As a bonus point, you appear as contributor of that change, which is nice.
When I write def I mean function.
Divran
Prole
Posts: 12
Joined: Tue Mar 23, 2010 10:30 am

Re: Löve Frames - A GUI Library

Post by Divran »

Ah alright. I made my own object oriented system using some simple metatables.

EDIT: And about the small fix to Löve Frame's util file... I didn't test any of the changes I made, and doing a git pull request on something that breaks everything wouldn't be very good, now would it :P
Nikolai Resokav wrote:You are free to use any code that you find in Love Frames with your project and modify it in any way you want. All I ask is that you give credit where credit is due.
Thanks. And of course.

I added this to my debug file:

Code: Select all

-- Credits to Nikolai Resokav, creator of Löve Frames for Löve2D - http://nikolairesokav.com/projects/loveframes/
-- for the idea of using these fancy outlines for debugging
-- I used his debug code as a base, and modified it
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests