Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various menu control improvements #1199

Merged
merged 3 commits into from
Apr 21, 2024
Merged

Various menu control improvements #1199

merged 3 commits into from
Apr 21, 2024

Conversation

JNechaevsky
Copy link
Collaborator

Small collection of various menu control improvements.

Following actions can be confirmed by Enter key:

  • Nightmare skill verifying (Doom only)
  • End game
  • Quit
  • Suicide confirmation (Hexen only) is possible but not included - probably it's too dangerous, just like savegames deleting - user have to confirm such actions strictly by Y key.

Heretic and Hexen:

  • Menus can be scrolled via mouse wheel.
  • Small addition - allow to quit by pressing F10 in any game states, so user won't need to open game menu and select "Quit Game", if the game wasn't started.

Extra:

  • Slightly reduced delay between LMB/RMB clicks, so user now can go through actions like "New Game > Episode > Skill level" by faster clicking.

Following actions:
- Nightmare skill verifying (Doom)
- End game
- Quit

Small addition for Heretic and Hexen: allow to quit by pressing F10 in any game states, so user won't need to open game menu and select "Quit Game".

Suicide confirmation (Hexen only) is possible but not included - probably it's too "dangeours", just like savegames deliting, user have to confirm such actions strictly by "Y" key.
So you can click faster to select / go back in menus.
}

// [crispy] scroll menus with mouse wheel
if (event->data1 & (1 << 4))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applies to both Heretic and Hexen, this means: use hardcoded mouse events, not related to mousebprevweapon and mousebnextweapon binds to avoid situations if mouse wheel actions will be re-binded.

@@ -1079,6 +1084,11 @@ static boolean InventoryMoveRight()

plr = &players[consoleplayer];
inventoryTics = 5 * 35;

if (MenuActive)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applies to both Heretic and Hexen, not sure if this is optimal, but we have to prevent inventory pop-up while using mouse wheel in active menu.

Copy link
Owner

@fabiangreffrath fabiangreffrath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, thanks!

@JNechaevsky JNechaevsky merged commit d4747e4 into master Apr 21, 2024
5 checks passed
@JNechaevsky JNechaevsky deleted the controls branch April 21, 2024 08:51
@JNechaevsky
Copy link
Collaborator Author

Thanks for accepting! 🤗

On a next step I would like to suggest indication of savegame file date ("modified" date, technically) in Save/Load menu. It's shamelessly inspired by Woof, but approach is different, I have a working code for Doom, Heretic and Hexen already.

Please note, that it will require just a small extension of existing DrawSaveLoadBottomLine function, but what's more interesting - constructing date in "%Y-%m-%d %X" doesn't seems to require shutting up pragmas, at least GCC on MSYS and Linux are happy. Probably worth to checkout Woof's code as well.

Results are pretty obivious, but will require adaptation of coloring style to Crispy + small vertical menu shifting:

image

image

image

However, before proceed I need to get your approval to remove extra line background, this one:
image

If one more extra line background will be used for file date, it probably will not look good, and not using any extra lines will allow to don't draw anything over status bar (pixel perfection!).

@fabiangreffrath
Copy link
Owner

Thanks for accepting! 🤗

Thanks for working on this!

but what's more interesting - constructing date in "%Y-%m-%d %X" doesn't seems to require shutting up pragmas, at least GCC on MSYS and Linux are happy. Probably worth to checkout Woof's code as well.

Sure, but "%Y-%m-%d" is not the native date format in my locale. We shut up the warning, because in some locales the date format is only two- digit, and then the date string is century ambiguous.

However, before proceed I need to get your approval to remove extra line background

Yes, of course, please proceed.

@JNechaevsky
Copy link
Collaborator Author

Sure, but "%Y-%m-%d" is not the native date format in my locale. We shut up the warning, because in some locales the date format is only two- digit, and then the date string is century ambiguous.

Aaaah, so idea is to set not just time, but also a date to user's locale, got it. My native format is DD.MM.YYYY, but somehow I got used to YYYY-MM-DD international ISO format. Sure, worth to follow Woof approach then.

@JNechaevsky
Copy link
Collaborator Author

First results. There is small problem with original 4:3 ratio I would like to solve - file date should not be drawing over status bar KIS stats, otherwise it will not be very nice, but this way menu is slightly higher than it should be.

image

image

image

Another idea is to make status bar KIS stats translucent while active Save/Load menu. This will also keep chat line visible:

image

image

Which way should I proceed?

@JNechaevsky
Copy link
Collaborator Author

Third idea is try to fit everything in one line, like on this mockup

image

This is tricky, but won't require vertical menu shifting at all, and we'll have to remove PGUP/PGDN strings, otherwise it won't fit nicely. But we can implement scrolling by arrow keys as well, they aren't used while string editing.

P.S. Hmm, MM/DD/YYYY is not my locale format, despite of I'm using following string to construct date and time: strftime(filedate, sizeof(filedate), "%x %X", localtime(&filestat.st_mtime));

@fabiangreffrath
Copy link
Owner

You'll have to call setlocale(LC_TIME, "") somewhere early in the init code (and thus unleash a plethora of bugs on Windows).
https://github.com/fabiangreffrath/woof/blob/877836530867a100f91834c05c362b48b7dc7c30/src/i_main.c#L56

@JNechaevsky
Copy link
Collaborator Author

Worked perfectly, GCC under MSYS doesn't have any complains 😊

+++ crispy-doom/src/i_main.c	Sun Apr 21 19:00:55 2024
@@ -18,14 +18,15 @@
 
 #include "config.h"
 #include "crispy.h"
 
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <locale.h>
 
 #include "SDL.h"
 
 #include "doomtype.h"
 #include "i_system.h"
 #include "m_argv.h"
 #include "m_misc.h"
@@ -47,14 +48,17 @@
     myargv = malloc(argc * sizeof(char *));
     assert(myargv != NULL);
 
     for (int i = 0; i < argc; i++)
     {
         myargv[i] = M_StringDuplicate(argv[i]);
     }
+
+    // [crispy] Print date and time in the Load/Save Game menus in the current locale
+    setlocale(LC_TIME, "");
 
     //!
     // Print the program version and exit.
     //
     if (M_ParmExists("-version") || M_ParmExists("--version")) {
         puts(PACKAGE_STRING);
         exit(0);

image

Please choose preferred alignment:

  • First one is okay, but will left some empty space below file slots, if no save is available under the cursor. Not very nice.
  • Second one is okay, but we'll need some kind of boolean, so KIS stats will know when to become translucent. drawKIStranslucent = (!crispy->widescreen && menuactive && (currentMenu == &SaveDef || currentMenu == &LoadDef));, handled via M_Ticker or even better, just once when menu is activated/deactivated. Translucency seems to be needed only for 4:3 ratio. But what about level name in opened automap? It will have same problem with drawing save date on top of it.
  • Third one is possibly "less diff" approach, but there may be potential problem with fitting of some bolder fonts, unless we'll make save file backgrounds slightly wider. Plus possibly most complicated in terms of careful strings alignment, despite of this is one line line, it should be drawn via multiple M_WriteText calls, like save date aligned to the LoadDef.x, > to the LoadDef.x+(SAVESTRINGSIZE-6)*8 and so on, and so on.

@fabiangreffrath
Copy link
Owner

To be honest, I wouldn't bother with translucency and just draw things over things. We only have so much space on screen, and the menu already covers various part of the game scene. 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants