EGS v2 - Screenshots! Redesign! (Easy GUI System)

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Trappingnoobs
Citizen
Posts: 95
Joined: Tue Oct 12, 2010 8:52 pm

Re: Unnamed GUI library

Post by Trappingnoobs »

T-Bone wrote:Pics or it didn't happen :neko:
I gave a .love file.

Trigger one of the button's events, and watch the event log- The event will be triggered for both buttons. You can trigger an event by just hovering it or clicking it or whatever.

But you can tell the class system is working to some extent; they are keeping their local positions and stuff.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Unnamed GUI library

Post by Robin »

You know why that is? Because Event is still the same table:

Code: Select all

a = {b = {}}
c = {b = a.b}
c.b.blah = true
print(a.b.blah) -- prints true
So both functions get added to the same table.
Help us help you: attach a .love.
User avatar
Trappingnoobs
Citizen
Posts: 95
Joined: Tue Oct 12, 2010 8:52 pm

Re: Unnamed GUI library

Post by Trappingnoobs »

:o:

So making a variable point to a table actualy makes it point instead of cloning the table? THAT explains SO much... I've been hitting problems like this for months and months in so many different situations... I'll rebuild my class system for tables.

Thanks :D


So if I just did this

Code: Select all

function CloneTable(tab)
rT = {}
for _,v in pairs(tab) do
rT[_] = v
end
return rT
end
Would I need to make it recursive for tables inside the table?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Unnamed GUI library

Post by Robin »

Trappingnoobs wrote:Would I need to make it recursive for tables inside the table?
Depends.

Note that for classes, it would be better to make new tables in the constructor than to clone them.
Help us help you: attach a .love.
User avatar
Trappingnoobs
Citizen
Posts: 95
Joined: Tue Oct 12, 2010 8:52 pm

Re: Unnamed GUI library

Post by Trappingnoobs »

Robin wrote:
Trappingnoobs wrote:Would I need to make it recursive for tables inside the table?
Depends.

Note that for classes, it would be better to make new tables in the constructor than to clone them.
Yes but some are identical throughout classes, and, as you've probably seen, take up like 70 lines of space in every class, I'd rather inherit.


After some testing I needed to make it recursive, and it works (But there are large amounts of ugly hax involved T.t), so I'm just hoping it'll start inheriting events properly now too.

I came up with this. To be honest; it's got to the point I've forgotten what most of it's there for/what it does, but it works, so I hopefully won't need to ever again edit it.

Code: Select all

local function CloneTable(tab)
	local rT = {} --returnTable
	for key,val in pairs(tab) do
		if type(val) == "table" then
			rT[key] = CloneTable(val)
		else
			rT[key] = val
		end
	end
	return rT
end
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Unnamed GUI library

Post by Robin »

Trappingnoobs wrote:Yes but some are identical throughout classes, and, as you've probably seen, take up like 70 lines of space in every class, I'd rather inherit.
Dude. Subclassing.
Trappingnoobs wrote:I came up with this. To be honest; it's got to the point I've forgotten what most of it's there for/what it does, but it works, so I hopefully won't need to ever again edit it.
Be careful with that attitude. That never works.
Trappingnoobs wrote:

Code: Select all

local function CloneTable(tab)
Yes, that works, but there might be times were it will not. For example:

Code: Select all

a = {}
a.a = a
CloneTable(a) -- oops!
Help us help you: attach a .love.
User avatar
Trappingnoobs
Citizen
Posts: 95
Joined: Tue Oct 12, 2010 8:52 pm

Re: Unnamed GUI library

Post by Trappingnoobs »

Robin wrote:
Trappingnoobs wrote:Yes but some are identical throughout classes, and, as you've probably seen, take up like 70 lines of space in every class, I'd rather inherit.
Dude. Subclassing.
That's what I'm doing... Inheriting is the same as subclassing; everything from class A is put into class B if class B asks for it.
Robin wrote:
Trappingnoobs wrote:I came up with this. To be honest; it's got to the point I've forgotten what most of it's there for/what it does, but it works, so I hopefully won't need to ever again edit it.
Be careful with that attitude. That never works.
Yeah; it's failed me a lot. If necessary I'll just force myself to repeatedly read it over and over until I find out why x problem is occuring. Hopefully it won't get to that.
Robin wrote:
Trappingnoobs wrote:

Code: Select all

local function CloneTable(tab)
Yes, that works, but there might be times were it will not. For example:

Code: Select all

a = {}
a.a = a
CloneTable(a) -- oops!
Any way I can protect against that? Although, if somone did that, wouldn't they have purpousefully wanted something bad to happen?

Unless I just do

Code: Select all

if val ~= args then
clone logic
else
args.key = args
end
That'd work.. I think..

Edit:

Wait, they can't do that; anyway; the class doesn't exist until it's finished processing all the properties, so unless they did some wierd stuff and PURPOUSEFULLY did some stuff like, I don't know, making it the return value, I don't think it's possible.. I don't know; I'm probably wrong.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Unnamed GUI library

Post by T-Bone »

Trappingnoobs wrote:
T-Bone wrote:Pics or it didn't happen :neko:
I gave a .love file.
Pics are still a good idea. Also, you should probably update the first post as it clearly states that there is no .love file. In red letters.
User avatar
Trappingnoobs
Citizen
Posts: 95
Joined: Tue Oct 12, 2010 8:52 pm

Re: Unnamed GUI library

Post by Trappingnoobs »

T-Bone wrote:
Trappingnoobs wrote:
T-Bone wrote:Pics or it didn't happen :neko:
I gave a .love file.
Pics are still a good idea. Also, you should probably update the first post as it clearly states that there is no .love file. In red letters.
That's red? I thought it was brown. T.t

No, there isn't meant to be. I'm not officialy releasing it yet, I only put that one because of my epic fail that kinda messed everything up.

I'm working on frames which hold other GUI element right now. Then bubble selections, then sliders, then release. :D

I added some new events

"captionStartedShowing"
"captionStoppedShowing"

You might think "Why captionStoppedShowing- why not just use mouseExited"- It's because if you set "hasCaption" to false while it's showing, it'll unshow and call that event. It'll call when the mouse exits too.

EDIT:

About the pics; I'm going to have to set up an awesome setup otherwise it doesn't advertise how adjustable everything is. I need lots of different colors and borderwidths, so it might take a while to set up.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Unnamed GUI library

Post by Robin »

Trappingnoobs wrote:That's what I'm doing... Inheriting is the same as subclassing; everything from class A is put into class B if class B asks for it.[/quote
Not what I meant. You could make a class called Object which implements the event system. Then you let all the other classes subclass Object and voilà: one free event system.
Trappingnoobs wrote:Any way I can protect against that? Although, if somone did that, wouldn't they have purpousefully wanted something bad to happen?
No. There are a lot of legitimate reasons for doing things like that. It would be better to not need to copy anything, by calling the constructors of the superclasses.
Trappingnoobs wrote:I'm probably wrong.
Yes, you are.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests