Add an option to color crosshair according to player health + shield

Shield is taken into account and is added to health for the calculation,
as the vast majority of damage types are fully blocked by a shield.

3 modes are available:

- Off (default)
- On (Green): Goes through a red-yellow-green-cyan gradient,
  closer to vanilla.
- On (White): Goes through a red-yellow-white-green gradient,
  closer to games like Xonotic.

When set to either of the On modes, the crosshair color setting
is ignored but the crosshair alpha setting is still used.
This commit is contained in:
Hugo Locurcio committed 2024-01-27 19:21:05 +01:00
1 parent 474a6df3d4
commit 02d7efb87f
6 files changed
+86 -1

No files matched your search

+32
View File
@@ -1040,6 +1040,30 @@ static MenuItemHandlerResult menuhandlerCrosshairSize(s32 operation, struct menu
return 0;
}
static MenuItemHandlerResult menuhandlerCrosshairHealth(s32 operation, struct menuitem *item, union handlerdata *data)
{
static const char *opts[] = {
"Off",
"On (Green)",
"On (White)"
};
switch (operation) {
case MENUOP_GETOPTIONCOUNT:
data->dropdown.value = ARRAYCOUNT(opts);
break;
case MENUOP_GETOPTIONTEXT:
return (intptr_t)opts[data->dropdown.value];
case MENUOP_SET:
g_PlayerExtCfg[g_ExtMenuPlayer].crosshairhealth = data->dropdown.value;
break;
case MENUOP_GETSELECTEDINDEX:
data->dropdown.value = g_PlayerExtCfg[g_ExtMenuPlayer].crosshairhealth;
}
return 0;
}
struct menuitem g_ExtendedGameCrosshairColourMenuItems[] = {
{
MENUITEMTYPE_SLIDER,
@@ -1158,6 +1182,14 @@ struct menuitem g_ExtendedGameMenuItems[] = {
0,
(void*)&g_ExtendedGameCrosshairColourMenuDialog,
},
{
MENUITEMTYPE_DROPDOWN,
0,
MENUITEMFLAG_LITERAL_TEXT,
(uintptr_t)"Crosshair Colour by Health",
0,
menuhandlerCrosshairHealth,
},
{
MENUITEMTYPE_SEPARATOR,
0,