Skip to content

Commit

Permalink
Add a few more items to the Controls menu
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-drexler committed Aug 28, 2024
1 parent 99ef5e0 commit 85e89a3
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Quake/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -4568,6 +4568,9 @@ typedef struct
keydevicemask_t devicemask;
} menukeybind_t;

#define QUICKSAVE "echo Quicksaving...; wait; save quick"
#define QUICKLOAD "echo Quickloading...; wait; load quick"

This comment has been minimized.

Copy link
@4LT

4LT Aug 29, 2024

I think it would be more consistent to prefer constants over macros.
Then again, static const char * const is a mouthful

This comment has been minimized.

Copy link
@andrei-drexler

andrei-drexler Aug 29, 2024

Author Owner

I'm not sure constants would be more consistent in this case. With these macros, all elements are initialized with string literals (after preprocessing), whereas with constants that would no longer be the case, and the code would also be more verbose, as you mentioned.


static const menukeybind_t menubinds[] =
{
{"+forward", "Move forward", KDM_KEYBOARD_AND_MOUSE},
Expand Down Expand Up @@ -4602,6 +4605,14 @@ static const menukeybind_t menubinds[] =
{"impulse 8", "Thunderbolt", KDM_ANY},
{"impulse 225", "Laser Cannon", KDM_ANY},
{"impulse 226", "Mjolnir", KDM_ANY},
{"", "", KDM_ANY},
{QUICKSAVE, "Quick save" , KDM_ANY},
{QUICKLOAD, "Quick load" , KDM_ANY},
{"menu_load", "Load menu" , KDM_ANY},
{"menu_save", "Save menu" , KDM_ANY},
{"menu_maps", "Maps menu" , KDM_ANY},
{"menu_options", "Options menu" , KDM_ANY},
{"screenshot", "Screenshot", KDM_ANY},
};

This comment has been minimized.

Copy link
@vsonnier

vsonnier Aug 30, 2024

Hi @andrei-drexler, now that you have added the keybinds that are historically on the F-keys (I copied your commit :) you should also remove the F-key range from keys.c menubound otherwise you effectively won't be able to bind F-keys.
I made the modification on vk and so far it doesn't seem to bring any side-effects, but Ironwail management is more sophisticated so idk.

This comment has been minimized.

Copy link
@andrei-drexler

andrei-drexler Aug 30, 2024

Author Owner

Thanks, but I don't think that's the best approach. I haven't tried it, but I expect switching menus using the functions keys (e.g. pressing F4 to switch to Options while in the Save menu) to no longer work, or quickloading while in the menu. Some folks are bound to notice that.

As a side note, what's the rush in copying my WIP code before it's even released? You're going to force me to no longer push my changes and just do code drops when I release new versions.

This comment has been minimized.

Copy link
@vsonnier

vsonnier Aug 31, 2024

No rush indeed, I'm cherry-picking changes early because I have to adapt them to vkQuake in any case, while I have sometimes not much time to do so. Then, I prefer publishing them fast for testing at large.

If mistakes are made the fault is vk and vk alone, not the originator of course.


#define NUMCOMMANDS Q_COUNTOF(menubinds)
Expand Down Expand Up @@ -4647,17 +4658,19 @@ static qboolean M_Keys_Match (int index)

static void M_Keys_Populate (void)
{
int i, limit;
int i;

VEC_CLEAR (keysmenu.items);

limit = hipnotic ? NUMCOMMANDS : NUMCOMMANDS - 2;
for (i = 0; i < limit; i++)
for (i = 0; i < NUMCOMMANDS; i++)
{
// filter item by device type
if (!(keysmenu.devicemask & menubinds[i].devicemask))
continue;

if (!hipnotic && (strcmp (menubinds[i].command, "impulse 225") == 0 || strcmp (menubinds[i].command, "impulse 226") == 0))
continue;

// if we have two separators in a row, overwrite the old one
if (VEC_SIZE (keysmenu.items) > 0 && !menubinds[i].command[0] && !VEC_LAST(keysmenu.items).command[0])
VEC_LAST(keysmenu.items) = menubinds[i];
Expand Down

0 comments on commit 85e89a3

Please sign in to comment.