Pause menu

Open-source port of PoP that runs natively on Windows, Linux, etc.
Falcury
Calif
Calif
Posts: 565
Joined: June 25th, 2009, 10:01 pm

Pause menu

Post by Falcury »

Maybe it would be nice if you could summon a settings window through a pause menu, something like this:
screenshot_paused_menu.png
screenshot_paused_menu.png (6.5 KiB) Viewed 6001 times
Falcury
Calif
Calif
Posts: 565
Joined: June 25th, 2009, 10:01 pm

Re: Settings window

Post by Falcury »

More half-baked design experimentation. I got some inspiration from The Witcher 3's in-game menu, which I think is pretty good.
screenshot_settings_menu.png
screenshot_settings_menu.png (7.69 KiB) Viewed 5981 times
Falcury
Calif
Calif
Posts: 565
Joined: June 25th, 2009, 10:01 pm

Re: Settings window

Post by Falcury »

Here is a demo of the experimental in-game menu system I've been working on for SDLPoP.
My goal is to create an in-game menu that works within the constraints of a 320 by 200 resolution, and is intuitively used with mouse, keyboard and controller.
In terms of functionality, the idea is that it becomes similar to what Norbert originally had in mind for a settings window, but directly overlayed on the main window, instead of a separate window.

Note that it's still rough around the edges.

To bring up the menu, pause the game.
Escape also exits the pause menu (the original behaviour to advance the game by only one frame is disabled for now).

To navigate the menu, use either the mouse (point and click), the arrow keys and enter, or a controller (D-pad for navigation, A to select).
For controllers, I've remapped 'back' to 'escape', so you can use that button to pause the game and bring up the menu.
Use the left/right arrow keys to turn settings on or off.

Just for fun, I added some sounds as well.

Toggles that I've tested to work:
  • Enable sound
  • Enable controller rumble
  • Horizontal joystick movement only
  • Copy protection level
  • Enable quicksave
  • Use 4:3 aspect ratio
  • Use integer scaling
  • Enable fading
  • Enable flashing
  • Enable lighting
Things that do not work / are not implemented:
  • Saving to .ini file
  • Toggle music
  • Slider interactivity (e.g. for changing the joystick threshold)
  • Scrolling (in the list of settings)
  • Enabling/disabling all bug fixes at once
  • Selecting/loading custom levelsets on the fly
  • Loading replays by selecting them from a list
  • Manual save game 'slots' (right now, the save game / load game pause menu options temporarily map to quicksave/quickload)
  • Option to disable the menu system and revert to original pause behavior.
  • Blitting on the GPU (so, CPU usage might be a bit high at the moment...)
GitHub branch:
https://github.com/Falcury/SDLPoP/tree/menu2

(I am probably not going to go further with the menubar idea, by the way.)
Attachments
SDLPoP_menu.zip
(4.78 MiB) Downloaded 102 times
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: Settings window

Post by Norbert »

Falcury wrote: November 30th, 2017, 5:58 pmHere is a demo of the experimental in-game menu system I've been working on for SDLPoP.
Hey, not bad.

(I commented out the SDL_RenderSetIntegerScale() calls because my system has SDL 2.0.4, and I didn't want to manually install SDL 2.0.5.)
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Settings window

Post by David »

Falcury wrote: November 30th, 2017, 5:58 pm
  • Use 4:3 aspect ratio
  • Use integer scaling
I like how these instantly take effect.
Falcury wrote: November 30th, 2017, 5:58 pm Escape also exits the pause menu (the original behaviour to advance the game by only one frame is disabled for now).
Actually, any key exits the menu, except the arrows and enter.

The way you handle the mouse coordinates: https://github.com/Falcury/SDLPoP/blob/ ... enu.c#L435
I did something similar for the editor here: https://github.com/NagyD/SDLPoP/blob/ed ... 09.c#L3189
However, my code probably won't work if either
You use some functions that I didn't even know about.

By the way, the selection rectangle is somewhat hard to see.
Or maybe just my screen is not adjusted correctly.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: Settings window

Post by Norbert »

David wrote: December 3rd, 2017, 11:43 pmHowever, my code probably won't work if either
If either what? :)
Falcury
Calif
Calif
Posts: 565
Joined: June 25th, 2009, 10:01 pm

Re: Settings window

Post by Falcury »

Added:
* Scrolling
* Enabling/disabling bug fixes (for now, you can enable them all at once, then turn off all the ones you don't like)
* Added some of the customization options (just numbers that can be increased/decreased, sliders don't really seem to be appropriate there)
David wrote: December 3rd, 2017, 11:43 pm Actually, any key exits the menu, except the arrows and enter.
Yeah... this is probably not good behaviour, because it may be unexpected to suddenly have the menu close because you hit a random key.
For now, I changed it so that only keys with the Ctrl modifier (e.g., Ctrl+R) get through.
And I added backspace as an alternative way to leave the menu, and the spacebar as an alternative way to select a menu item.
David wrote: December 3rd, 2017, 11:43 pm By the way, the selection rectangle is somewhat hard to see.
Or maybe just my screen is not adjusted correctly.
OK, I made it brighter, and added a white bar to the left of the rectangle to make it extra visible.
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Settings window

Post by David »

Falcury wrote: December 6th, 2017, 2:21 pm
David wrote: December 3rd, 2017, 11:43 pm Actually, any key exits the menu, except the arrows and enter.
Yeah... this is probably not good behaviour, because it may be unexpected to suddenly have the menu close because you hit a random key.
For now, I changed it so that only keys with the Ctrl modifier (e.g., Ctrl+R) get through.
And I added backspace as an alternative way to leave the menu, and the spacebar as an alternative way to select a menu item.
Thanks.
It's funny you chose backspace, since that is the key that I sometimes accidentally tried to use for this purpose...
Probably because I recently tried RetroArch, where backspace is for going back a menu. (And Esc quits the whole thing without warning.)
Falcury wrote: December 6th, 2017, 2:21 pm
David wrote: December 3rd, 2017, 11:43 pm By the way, the selection rectangle is somewhat hard to see.
Or maybe just my screen is not adjusted correctly.
OK, I made it brighter, and added a white bar to the left of the rectangle to make it extra visible.
Thanks!
Norbert wrote: December 4th, 2017, 8:12 pm
David wrote: December 3rd, 2017, 11:43 pmHowever, my code probably won't work if either
If either what? :)
Oops, it seems I forgot to finish that sentence...
What I wanted to say: If either integer scaling or 4:3 aspect ratio is enabled, then my mouse-coordinate-remapping code probably won't work correctly.
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Settings window

Post by David »

Norbert wrote: November 30th, 2017, 10:12 pm (I commented out the SDL_RenderSetIntegerScale() calls because my system has SDL 2.0.4, and I didn't want to manually install SDL 2.0.5.)
I added version checks for that: https://github.com/NagyD/SDLPoP/issues/ ... -351948623
(Although this is not yet on the settings window branch.)
Falcury
Calif
Calif
Posts: 565
Joined: June 25th, 2009, 10:01 pm

Re: Settings window

Post by Falcury »

Made some more progress.
It's not perfect yet. But I think I could address issues and get it into a state where it is 'production-ready' in a foreseeable amount of time.
Question is, do we think it would be feasible for the pause menu / settings menu to eventually make it to the main branch? (And, do we even want this feature to exist?)
Personally, I think it might be extremely useful to have. But I might be biased in favor of my own work.

Changes:
* Added a setting that allows you to revert to the original pausing behavior (i.e., pressing escape only pauses the game). Added an alternative way to bring up the menu: press Ctrl+M.
* Can now switch all bug fixes on/off while still remembering what the previous setting was for individual fixes. (Note: I created a new struct type 'fixes_options_type', for keeping the code simple.)
* Added settings for Shift+L behavior in non-cheat mode.
* Added settings for drawn_tile_top_level_edge, drawn_tile_left_level_edge and level_edge_hit_tile.
* Fixed some mouse/keyboard interaction problems (still some bugs remain...).
* Fixed image blending for the arrowhead images not working with the 32-bit RGBA surface (added draw_image_with_blending()).
* Minor fixes for text descriptions.
* Prevent recursion of draw_overlays() (when update_screen() is being called from within draw_overlays()).
* Removed the fixes/enhancement prompt option at startup, because it is no longer necessary. (Instead, the option for disabling/enabling fixes is provided in the pause menu)
* Removed old unused menubar-related code. (Random thought: maybe, the menubar thing could be revived for ecalot's editor. I remember being 'annoyed' that the editor had so many keybindings that I would have to learn before I was able to use it.)

New TODO items:
* Add a way to reset all settings to their defaults.
* Maybe add a way to disable all customizations in the "Mods" section at once (i.e. revert back to the original values).
* How should changing level-specific values in the "Mods" section work?
* Maybe generate a configuration file SDLPoP.cfg (or similar) for saved settings, and use SDLPoP.ini only for changing the defaults? (Would be easier to manage than writing back changed settings to the ini file; and, reverting to the defaults after messing up some settings would also be easy (basically, just reload from the ini file))
* I (temporarily?) added a crude interactive drawing mode for easier debugging of drawing bugs. See the variable debug_drawing_mode in seg009.c. All it does is manually updating the screen after each drawing operation (similar actually to how the screen used to be updated in the past). This is useful for debugging because you can see the final image appearing part by part. (need to decide to either remove this again, or keep/improve...)
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: Settings window

Post by Norbert »

Here's a direct link to the relevant branch of Falcury's fork:
https://github.com/Falcury/SDLPoP/tree/menu2
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: Settings window

Post by Norbert »

Falcury wrote: January 13th, 2018, 1:58 amPersonally, I think it might be extremely useful to have. But I might be biased in favor of my own work.
This paragraph is just me being playful, all in the spirit of good fun, challenging your reasoning and actions a bit. I would like to differentiate between a) the usefulness of allowing easy access to settings, and b) the effort you've put into providing this access. One could say that the intrinsic usefulness does not depend on how much of the functionality has been coded. In a situation where you had coded nothing, it would not be less or more "extremely useful to have". You are (thus) not biased in favor of your own work. You like my idea of allowing easy access to settings, that I demonstrated in my fork, that I linked to in the first post of this thread. As far as I can tell, summoning settings through a pause menu instead of a separate window adds nothing; instead prevents users from observing certain real-time changes.

More seriously though, what you've put together is quite nice. Keep up the good work. ;) The aesthetics of your menu are nice, although I personally prefer dark text on light backgrounds, which is also easier on the eyes (sources). Some small suggestions:
- When pressing up at the very top of a menu (and down at the bottom), maybe not play the sound effect.
- Maybe mouse-clicking the game could also bring up the menu.
- Maybe add a menu option to turn on cheats. And if cheats are enabled, either via the menu or via the command-line, maybe add a "CHEATS" menu that itself, among other options, contains a "LOAD LEVEL" sub-menu. I'd personally suggest adding the "ENABLE CHEATS" option in the main (top) menu - for easy access/findability - and replacing it with the "CHEATS" menu when chosen.
- For me, on Linux Mint, "LOAD GAME" has no effect, possibly because "SAVE GAME" isn't working. Saving and loading with F6 and F9 respectively still works.
Falcury
Calif
Calif
Posts: 565
Joined: June 25th, 2009, 10:01 pm

Re: Settings window

Post by Falcury »

Thank you for your feedback, Norbert!
Just to reassure you (perhaps unnecessarily), I'm completely OK with sharp/negative feedback, so please don't hold back for my sake! ;) I try my best to follow Elon Musk's advice on this:
https://www.youtube.com/watch?v=TsoUr62ehdE
Norbert wrote: January 13th, 2018, 6:57 am More seriously though, what you've put together is quite nice. Keep up the good work. ;)
Thanks!

I agree with your point about dark text on light backgrounds being easier on the eyes (I also prefer this, especially for code editing). There are several reasons why I still went with the dark color scheme. Most importantly, Prince of Persia itself already includes white text on a dark background for its UI (e.g., the dialog box on the potions level, and the texts at the bottom of the screen) so I wanted something that sticks as closely as possible to the original look and feel. My second reason is that most other games I know seem to do it this way too. In particular I was inspired by The Witcher 3, and I thought I'd try something similar to that.

I removed the sound effect when pressing up at the very top of a menu (and down at the bottom).

Good idea to add a cheats menu. Then we can use cheats while using a controller. Still working on how that should look, but I already added a pause menu item 'CHEATS' that only appears when cheats are enabled. I also added a toggle for cheats in the settings menu. (Hm, maybe that option should also only appear if you first used the command-line option?)

Yeah, the "LOAD GAME" and "SAVE GAME" menu items seem to be broken. Will have to fix that. I can also add mouse-clicking bringing up the menu.

Progress (commit,commit):
  • Don't play sound effect when pressing up at the very top of a menu (and down at the bottom).
  • Enabling cheats from the Gameplay settings.
  • Settings are now saved to a file SDLPoP.cfg. Basically, your changed settings will be remembered from that file, as long as you don't touch SDLPoP.ini (If you edit SDLPoP.ini, the ini settings will again override the previously used settings). Not sure if this is the best long term solution, but I quite like not having to forcefully rewrite the ini file every time you change a setting... And this way there is no need for a "save settings" prompt, because settings jsut get saved automatically when you close the menu, with not really any risk of the file being locked for editing, etc.
  • MODS menu: Added a setting for toggling whether or not to use modified 'custom gameplay' options. So you can quickly revert back to the default if you accidentally changed a customization setting.
  • MODS menu: Display ticks as seconds instead of ticks.
  • The 'Start fullscreen' setting now toggles fullscreen immediately, as well as setting fullscreen at startup.
  • The joystick threshold setting now increments/decrements with steps of 1000.
  • Refactor: accessing 'custom' and 'fixes' options through a pointer, so that we can switch to another configuration by simply changing that pointer.
  • Refactor: pulled out process_rw_write() and process_rw_read() from replay.c, so that they could be used in menu.c as well for (un)serializing to/from a configuration file 'SDLPoP.cfg'.
New TODO items:
  • Add the fuzzy pixels option as a menu setting as well.
  • Maybe add a "CAPTURE" menu item to the pause menu? Then, there should probably be options to make a screenshot, level screenshot, or record a replay. Maybe allow starting a replay either from the current position, or only as soon as the room changes.
  • Should the menu be accessible while watching a replay? And if yes, should certain items be disabled?
  • Same for the title screen/opening cutscene/demo level?
  • Should there be a setting to enable the debug timer, without needing debug cheats enabled? May be useful for speedrunning.
  • There should probably be a controller button mapped to bringing up the menu?
  • When using a controller, support holding down a direction for navigating the menu faster (similar to keyboard keys being repeated if held down).
  • Bit much for now, but something to think about for later: maybe display a list of mods, and allow switching to another levelset on the fly.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: Settings window

Post by Norbert »

You're on a roll.
Falcury wrote: January 22nd, 2018, 2:39 pmI also added a toggle for cheats in the settings menu. (Hm, maybe that option should also only appear if you first used the command-line option?)
I think it's useful to always include the toggle to enable cheats, for instance for players who don't know cheats exist.
Maybe change "Enable cheats" to "Enable cheats and CHEATS menu", to make it as exact and informative as possible.
In menu.c, the #if SDL_VERSION_ATLEAST(2,0,5) ... #endif could be added to SDL_RenderSetIntegerScale(renderer_, SDL_FALSE);.
Falcury wrote: January 22nd, 2018, 2:39 pm[*]Should the menu be accessible while watching a replay? And if yes, should certain items be disabled?
[*]Same for the title screen/opening cutscene/demo level?
Both would be nice to have, if you're up for adding it...
Falcury wrote: January 22nd, 2018, 2:39 pm[*]There should probably be a controller button mapped to bringing up the menu?
Definitely. Probably keep B free for possible future gameplay action(s). For now, both Start and Back could bring up the menu, given that "Quit Game" and "Restart Level" are accessible from the menu.
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Settings window

Post by David »

I think I found a bug in the menu:
Click on the screen when the menu is not visible. Then maybe move the mouse. Then press Esc.
If now there is a menu item under the cursor, it will be activated immediately.

Another thing: When the menu is open, the CPU usage goes up to 60%.
It's similar to what I mentioned here: https://github.com/NagyD/SDLPoP/pull/146

An even worse bug: If I scroll with the mouse wheel when the menu is not open, then the game crashes!
The same happens if the menu is open but I'm not within a sub-menu of settings.

Falcury wrote: January 22nd, 2018, 2:39 pm Settings are now saved to a file SDLPoP.cfg. Basically, your changed settings will be remembered from that file,
I see it's a binary file.
Falcury wrote: January 22nd, 2018, 2:39 pm as long as you don't touch SDLPoP.ini (If you edit SDLPoP.ini, the ini settings will again override the previously used settings).
Specifically, SDLPoP compares the modification time of the two files: https://github.com/Falcury/SDLPoP/blob/ ... nu.c#L1349
Falcury wrote: January 22nd, 2018, 2:39 pm Yeah, the "LOAD GAME" and "SAVE GAME" menu items seem to be broken.
I see these would activate F6 and F9 but somehow that has no effect: https://github.com/Falcury/SDLPoP/blob/ ... enu.c#L649
Post Reply