Feature Request: Menu
It'd be nice if someone pressed something like ESC (or something else), it'd pop-up some kind of menu. We all know it; it asks us if we want to continue, change settings, exit, save, load, etc.
But it also stops everything else in the game -- depending on which game you're playing.
Proposition:
width := 600
height := 800
pauseWorld := true
menuEntity := engi.CreateMenu(width, height, pauseWorld)
And this Entity, would then contain a SpaceComponent of given size, and one could add some additional components (i.e. RenderComponent) to do the markup themselves. The pauseWorld part is why I'd love to see this implemented (by me or someone else).
Additional proposition (which you don't have to like):
pauseWorld := true
items := map[string]func() {
"Continue" : func() { /* do nothing */},
"Save" : func() { /* save the game */},
"Exit" : func() { /* exit the game */},
}
menuEntity := engi.CreateMenu(pauseWorld, items)
Then engi would just create a menu with these options, possibly with some styling options for the user.
Not sure how this fits in the whole ECS-paradigm, but it'd be a nice feature to have. And this issue would be a great place to discuss (or summarize discussions).
Awesome. We definitely need some sort of pause/menu feature. My only concern would be making the menu too specific and not flexible enough for general use. IMO we should view the pause menu as a group of Entitys which represent a UI + pause logic.
Regarding your second proposal, I don't quite understand why you wouldnt just use an interface?
type XYZ interface {
Continue()
Save()
Exit()
}
Also, perhaps implementing Save logic into the engine is going a bit too far. I'm happy for a discussion on this though.
So it should have some kind of PauseSystem, which some Entity would require?
w.r.t. the second proposal:
The idea was the map, not those specific entries of the map. It would create a menu with the strings as buttons (or w/e), and execute the function on select.
Yes. A PauseSystem would be good. We could make use of the Message-ing features, to summon the PauseSystem.
@EtienneBruines I think it would be best to allow each Entity to handle its own behaviours.
A PauseSystem with the Message-ing features would work.
Thinking about what might be the best idea on how to stop "everything" - since we still want the menu to work. We still need (most of) the systems: RenderSystem, AnimationSystem, and possibly some other systems as well. We could use the PriorityLevel for this; the downside is that it's only attached to RenderComponents, and not to everything existing.
What if we used some UnpauseComponent or something? One could add those components to stuff that shouldn't be affected by the system-wide pause.
The current World-loop, is this:
for _, system := range w.Systems() {
system.Pre()
for _, entity := range system.Entities() {
if entity.Exists {
system.Update(entity, dt)
}
}
system.Post()
}
And it needs to be modified in such a way, that it skips everything that doesn't have an UnpauseComponent - if the system is paused.
I'll make a PR so you can see it in action.
Is there anything else we want to implement from this Issue?
Would this be pluggable by a developer or would this be core engine feature like CameraSystem?
Well, the PauseSystem has been implemented, and is completely pluggable.
I'm not sure what else we want to implement, because the other stuff probably is up to the developer, and it wouldn't be anything useful if we did it. We are busy with building-blocks though, such as #59.
hey @EtienneBruines and @paked I do not know what happened to this issue.
I did not find this feature in any Golang game engine. And it is very difficult to create this alone.
- Don't you want the engine to do this?
I think you support this right now.
Can you add a little example?
@SeanTolstoyevski I think it was decided that we did as much as we could as a game engine, because every main menu is different.
There's an example here: https://github.com/EngoEngine/engo/tree/a8276ad380704822182b58ec79f3618c751a2d93/demos/adventure#a-pause-menu
Basically upon entering the main menu (can be a keypress, like ESC), you remove all Entitys from all System to prevent them from being rendered. That is, if you want to remove sight of the game. It's also become quite common to keep the game rendered in the background. If that is what you want, you'll need to figure out something to make it "pause aware", meaning that you don't move your character by pressing WASD while in the main menu -- nor should the time keep ticking.
But because every menu is different (some want buttons, some want text, some want animations), it's difficult to create a one-size-fits-all feature.
============
Even though I haven't been active on this project for years, I think I can go ahead and reopen this issue for further discussion (if you have any additional thoughts on the matter or ideas that the game engine could/should offer).
Hi, thank you very much for your attention and thinks. This community is active. It's beautiful.
It's hard to design a menu in general. Because it is necessary to establish an event-based system.
I think handling a main menu is out of scope for a game engine to handle. There's too many variances and possible combinations and some projects that might not even use one.
I think what we can do is show a good example of a menu in one of the demos (maybe improve the one in adventure) or it's own separate demo depending on how important it is.
Thoughts?
If you'd like an example of a main menu, including a start menu, you can check out my game hypnic. That scene is the main menu, and it even has an options menu with sliders to control things like volume and input. I'm actually participating in the Game-Off 2020 and I'm planning on attempting a pause menu type system for that as well.
That said, I don't think something like that would work as part of the systems in common. Common should be more general-purpose, so maybe a system for gui tools such as buttons that you can use in a menu, but the menu itself should be up to the end user