ECS for GUI
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
ECS for GUI
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?
Re: ECS for GUI
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.
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_((_(()
Re: ECS for GUI
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
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: ECS for GUI
Read up:
https://en.wikipedia.org/wiki/Entity_component_system
http://entity-systems.wikidot.com/
http://vasir.net/blog/game-development/ ... javascript
Here's a more in depth list on StackOverflow:
http://stackoverflow.com/questions/1901 ... ine-design
https://en.wikipedia.org/wiki/Entity_component_system
http://entity-systems.wikidot.com/
http://vasir.net/blog/game-development/ ... javascript
Here's a more in depth list on StackOverflow:
http://stackoverflow.com/questions/1901 ... ine-design
((_((_CRAYOLA_((_((_> GitHub <_((_((_CRAYOLA_((_(()
Re: ECS for GUI
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
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: ECS for GUI
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.
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.
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests