ECS for GUI

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

ECS for GUI

Post by bobbyjones »

So guys I have been thinking about GUIs recently. I have seen tutorials for Unity's GUI system from 4.6+ and it reminds me of an ECS. In reality it is probably done with classes and not entities but considering lua is better fit for ECS rather than OOP maybe an ECS based GUI would be a good thing? One benefit of an ECS based GUI would be that the output of a hypothetical GUI editor would be pretty easy to read and make. But what are yall opinions on a ECS based GUI?
User avatar
bakpakin
Party member
Posts: 114
Joined: Sun Mar 15, 2015 9:29 am
Location: Boston

Re: ECS for GUI

Post by bakpakin »

IMHO, ECS would be better that an OO design for this problem

People often start learning programming nowadays with languages like Java and Python, which preach Object Oriented Programming as The Best Thing Ever and the Only Way To Do Things (Java especially). As people begin to code more, they often realize that OO is only one approach to problems, and often not the best. While it is the best way to do things in Java and C#, language features like closures, literal data structures, and a unified data structure (the table) make ECS and data driven programming in general great for Lua.

For GUI, I think ECS is a good idea, but to be more general, I think any data-driven design would be good for in-game GUI. It's easier to write shorter code, and as you said, easier to save to disk and read from disk. Most importantly, come time to make your actual buttons and text, you won't have to thing about how it works, you just have to send a Lua table to your engine.

In fact, you could probably throw the whole notion of ECS out the window if you're willing to give up some generality, and just make a GUI engine that takes a data structure of nested tables and renders it in the game.

I don't know if it is still in development, but karai17 had a project like this here. It's is very general in scope, but if you look at the examples you will see what I mean. It is the complete opposite of doing GUI the way LoveFrames does, and more like HTML and CSS.

My two cents.
((_((_CRAYOLA_((_((_> GitHub <_((_((_CRAYOLA_((_(()
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: ECS for GUI

Post by Nixola »

You know, I've never understood exactly what ECS is; does anyone have a link to a good something that explains the concept and maybe shows a possible implementation? (Not necessarily Lua-related)
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
bakpakin
Party member
Posts: 114
Joined: Sun Mar 15, 2015 9:29 am
Location: Boston

Re: ECS for GUI

Post by bakpakin »

((_((_CRAYOLA_((_((_> GitHub <_((_((_CRAYOLA_((_(()
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: ECS for GUI

Post by Nixola »

Thanks! I'll be sure to check that out whenever I find some time to sit down and code! ^^
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: ECS for GUI

Post by bobbyjones »

viewtopic.php?f=5&t=80896 knife's system module is an entity component system. Basically you define a system(a function) that requests some components (entries in an entity (table)) basically your player would end up a table of data rather than a class.

Also I am aware of DOMy but I don't like the way they are doing things. I would personally prefer no functions that end user would need basically. Just a table of data. Now of course the practicality is questionable but for a basic GUI like the one in Unity 4.6+ should be able to be done with just a table of data.
User avatar
bakpakin
Party member
Posts: 114
Joined: Sun Mar 15, 2015 9:29 am
Location: Boston

Re: ECS for GUI

Post by bakpakin »

Also, a shameless self promotion, I have a pretty mature entity-component-system library, tiny-ecs, here.
((_((_CRAYOLA_((_((_> GitHub <_((_((_CRAYOLA_((_(()
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 253 guests