README now has more information on GUECS but still needs more tips, tricks, and demos.

main
Zed A. Shaw 4 days ago
parent 589373bf22
commit 576de347b9
  1. 48
      README.md

@ -186,7 +186,7 @@ working on a layout in different ways to learn it.
### LEL Examples ### LEL Examples
Coming Soon...
### LEL Tricks ### LEL Tricks
@ -196,7 +196,38 @@ working on a layout in different ways to learn it.
## Using GUECS ## Using GUECS
Coming soon.. > __WARNING__: LEL can function on its own but GUECS is _very_ is currently only working with SFML.
> I also need to refine how the `guecs::Clickable` component works as its more complex than it needs
> to be. This will probably change in the future.
The GUECS system is mostly defined in these four files:
`guecs.hpp`
: This defines the base `guecs::UI` class which is a simple mostly template class that handles everything. Most of the template functions are used to perform the ECS style operations like `set<TYPE>(id, VALUE)` to set a specific component `TYPE` to a `VALUE` at the given cell `id` from LEL.
`guecs.cpp`
: Implementation for `guecs::UI` that aren't template based. Main functions here are
`guecs::UI::init()` and `guecs::UI::render()` which do the majority of the heavy lifting. If you're
looking to retarget GUECS to your game engine or graphics system then this is where to start.
`sfml/components.hpp`
: This is where the SFML based components live. This is where you find `Rectangle`, `Textual`,
`Label`, and `Clickable` among other things. If you're looking to retarget, then this is what you
have to write for your system.
`sfml/components.cpp`
: The implementations for the components, which is mostly just `init`, `update`, and `render` methods.
### GUECS Design Theme
The overall design theme for the `guecs::UI` is this:
1. Since there's not too many components it's easier to simply `init()` them in the correct order in one method. You usually only call `init()` once when that UI starts up, and then change or re-initialize individual components as needed during operation.
2. The `render()` method is the same, choosing to render each component in the correct order manually rather than trying to troll through everything and figure it out on the fly. This works well since usually you want to render `Background`, then `Rectangle`, then `Label` in order. If you find that's not the right ordering then this is where you go to fix it.
3. Adding a new component involves creating the class/struct in `sfml/components.hpp` and then adding it to `UI::init()` and `UI::render()`.
4. Mouse interactions are handled by `UI::mouse()` and mostly just figure out what cell was clicked on then run any `Clickable` configured for that cell. It will also return `true` if something hit so you can do more processing after calling it.
5. If you want to have immediate mode functionality then you'd mostly just make a component that has that and add it to `init()` and `render()`.
## Making Your Own ## Making Your Own
@ -216,6 +247,19 @@ encourage you to create your own rather than use mine. The key things to realiz
Give it a shot and soon I'll have a guide on how to do it. Give it a shot and soon I'll have a guide on how to do it.
### Fun Features
1. Look at `guecs::Sound` (in `sfml/components.hpp`) to see how you can add sound feedback to your UI.
2. Look at `guecs::Effect` (in `sfml/components.hpp`) to see how to apply shaders to your UI. Keep in mind that I don't know a damn thing about shaders.
## RPN Calculator Demo
For a mostly complete example look at `demos/calc.cpp` for a simple RPN calculator. Also check the
following projects where I'm using it:
* https://git.learnjsthehardway.com/learn-code-the-hard-way/raycaster
* https://git.learnjsthehardway.com/learn-code-the-hard-way/turings-tarpit
## Contact Me ## Contact Me
You can email me at help@learncodethehardway.com and I also stream my development of this (and other You can email me at help@learncodethehardway.com and I also stream my development of this (and other

Loading…
Cancel
Save