Skip to content

Commit

Permalink
Classic UI: Transplant of alwaysWeaponBar and weaponBarStyle from Gam…
Browse files Browse the repository at this point in the history
…e Options to H.U.D. (#248)
  • Loading branch information
NeonKnightOA authored Mar 21, 2024
1 parent 10ce380 commit 963550e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 38 deletions.
47 changes: 47 additions & 0 deletions code/q3_ui/ui_hud.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ typedef struct {
menuslider_s crosshairColorGreen;
menuslider_s crosshairColorBlue;

menuradiobutton_s alwaysWeaponBar;
menulist_s weaponBarStyle;

menuradiobutton_s drawFPS;

menubitmap_s back;
Expand All @@ -72,12 +75,27 @@ typedef struct {

static hudOptions_t hudOptions_s;

static const char *weaponBarStyle_names[] =
{
"Bottom Side (Default)",
"Bottom Side + Ammo Bar",
"Left Side + Ammo Count",
"Left Side + Ammo Bar",
"Left + Ammo Background",
"Bottom + Ammo Count + BGD",
"Bottom + Ammo Count + Bar",
"Bottom + Ammo Background",
NULL
};

static void HUDOptions_SetMenuItems( void ) {
hudOptions_s.crosshair.curvalue = (int)trap_Cvar_VariableValue( "cg_drawCrosshair" ) % NUM_CROSSHAIRS;
hudOptions_s.crosshairHealth.curvalue = trap_Cvar_VariableValue( "cg_crosshairHealth") != 0;
hudOptions_s.crosshairColorRed.curvalue = trap_Cvar_VariableValue( "cg_crosshairColorRed")*255.0f;
hudOptions_s.crosshairColorGreen.curvalue = trap_Cvar_VariableValue( "cg_crosshairColorGreen")*255.0f;
hudOptions_s.crosshairColorBlue.curvalue = trap_Cvar_VariableValue( "cg_crosshairColorBlue")*255.0f;
hudOptions_s.alwaysWeaponBar.curvalue = trap_Cvar_VariableValue( "cg_alwaysWeaponBar" ) != 0;
hudOptions_s.weaponBarStyle.curvalue = trap_Cvar_VariableValue( "cg_weaponBarStyle" ) != 0;
hudOptions_s.drawFPS.curvalue = trap_Cvar_VariableValue( "cg_drawfps") != 0;
}

Expand Down Expand Up @@ -122,6 +140,14 @@ static void HUDOptions_Event( void* ptr, int notification ) {
trap_Cvar_SetValue( "cg_crosshairColorBlue", ((float)hudOptions_s.crosshairColorBlue.curvalue)/255.f );
break;

case ID_ALWAYSWEAPONBAR:
trap_Cvar_SetValue( "cg_alwaysWeaponBar", hudOptions_s.alwaysWeaponBar.curvalue );
break;

case ID_WEAPONBARSTYLE:
trap_Cvar_SetValue( "cg_weaponBarStyle", hudOptions_s.weaponBarStyle.curvalue );
break;

case ID_DRAWFPS:
trap_Cvar_SetValue( "cg_drawFPS", hudOptions_s.drawFPS.curvalue );
break;
Expand Down Expand Up @@ -288,6 +314,25 @@ static void HUDOptions_MenuInit( void ) {
hudOptions_s.crosshairColorBlue.generic.flags |= QMF_INACTIVE;
}

y += BIGCHAR_HEIGHT+2;
hudOptions_s.alwaysWeaponBar.generic.type = MTYPE_RADIOBUTTON;
hudOptions_s.alwaysWeaponBar.generic.name = "Always Show Weapon Bar:";
hudOptions_s.alwaysWeaponBar.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
hudOptions_s.alwaysWeaponBar.generic.callback = HUDOptions_Event;
hudOptions_s.alwaysWeaponBar.generic.id = ID_ALWAYSWEAPONBAR;
hudOptions_s.alwaysWeaponBar.generic.x = HUDOPTIONS_X_POS;
hudOptions_s.alwaysWeaponBar.generic.y = y;

y += BIGCHAR_HEIGHT+2;
hudOptions_s.weaponBarStyle.generic.type = MTYPE_SPINCONTROL;
hudOptions_s.weaponBarStyle.generic.name = "Weapon Bar Style:";
hudOptions_s.weaponBarStyle.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
hudOptions_s.weaponBarStyle.generic.callback = HUDOptions_Event;
hudOptions_s.weaponBarStyle.generic.id = ID_WEAPONBARSTYLE;
hudOptions_s.weaponBarStyle.generic.x = HUDOPTIONS_X_POS;
hudOptions_s.weaponBarStyle.generic.y = y;
hudOptions_s.weaponBarStyle.itemnames = weaponBarStyle_names;

y += BIGCHAR_HEIGHT+2;
hudOptions_s.drawFPS.generic.type = MTYPE_RADIOBUTTON;
hudOptions_s.drawFPS.generic.name = "Draw FPS:";
Expand Down Expand Up @@ -317,6 +362,8 @@ static void HUDOptions_MenuInit( void ) {
Menu_AddItem( &hudOptions_s.menu, &hudOptions_s.crosshairColorRed );
Menu_AddItem( &hudOptions_s.menu, &hudOptions_s.crosshairColorGreen );
Menu_AddItem( &hudOptions_s.menu, &hudOptions_s.crosshairColorBlue );
Menu_AddItem( &hudOptions_s.menu, &hudOptions_s.alwaysWeaponBar );
Menu_AddItem( &hudOptions_s.menu, &hudOptions_s.weaponBarStyle );
Menu_AddItem( &hudOptions_s.menu, &hudOptions_s.drawFPS );

Menu_AddItem( &hudOptions_s.menu, &hudOptions_s.back );
Expand Down
38 changes: 0 additions & 38 deletions code/q3_ui/ui_preferences.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ typedef struct {
menubitmap_s framer;

menuradiobutton_s simpleitems;
menuradiobutton_s alwaysweaponbar;
menulist_s weaponBarStyle;
menuradiobutton_s brass;
menuradiobutton_s wallmarks;
menuradiobutton_s identifytarget;
Expand Down Expand Up @@ -116,23 +114,8 @@ static const char *obituaryOutput_names[] =
NULL
};

static const char *weaponBarStyle_names[] =
{
"Bottom Side (Default)",
"Bottom Side + Ammo Bar",
"Left Side + Ammo Count",
"Left Side + Ammo Bar",
"Left + Ammo Background",
"Bottom + Ammo Count + BGD",
"Bottom + Ammo Count + Bar",
"Bottom + Ammo Background",
NULL
};

static void Preferences_SetMenuItems( void ) {
s_preferences.simpleitems.curvalue = trap_Cvar_VariableValue( "cg_simpleItems" ) != 0;
s_preferences.alwaysweaponbar.curvalue = trap_Cvar_VariableValue( "cg_alwaysWeaponBar" ) != 0;
s_preferences.weaponBarStyle.curvalue = trap_Cvar_VariableValue( "cg_weaponBarStyle" ) != 0;
s_preferences.brass.curvalue = trap_Cvar_VariableValue( "cg_brassTime" ) != 0;
s_preferences.wallmarks.curvalue = trap_Cvar_VariableValue( "cg_marks" ) != 0;
s_preferences.identifytarget.curvalue = trap_Cvar_VariableValue( "cg_drawCrosshairNames" ) != 0;
Expand All @@ -156,14 +139,6 @@ static void Preferences_Event( void* ptr, int notification ) {
case ID_SIMPLEITEMS:
trap_Cvar_SetValue( "cg_simpleItems", s_preferences.simpleitems.curvalue );
break;

case ID_ALWAYSWEAPONBAR:
trap_Cvar_SetValue( "cg_alwaysWeaponBar", s_preferences.alwaysweaponbar.curvalue );
break;

case ID_WEAPONBARSTYLE:
trap_Cvar_SetValue( "cg_weaponBarStyle", s_preferences.weaponBarStyle.curvalue );
break;

case ID_HIGHQUALITYSKY:
trap_Cvar_SetValue( "r_fastsky", !s_preferences.highqualitysky.curvalue );
Expand Down Expand Up @@ -265,17 +240,6 @@ static void Preferences_MenuInit( void ) {

y = 96;
Preferences_Menu_AddBoolean(&s_preferences.simpleitems, &y, ID_SIMPLEITEMS, "2D (Simple) Items:");
Preferences_Menu_AddBoolean(&s_preferences.alwaysweaponbar, &y, ID_ALWAYSWEAPONBAR, "Always Show Weapon Bar:");

y += BIGCHAR_HEIGHT+2;
s_preferences.weaponBarStyle.generic.type = MTYPE_SPINCONTROL;
s_preferences.weaponBarStyle.generic.name = "Weapon Bar Style:";
s_preferences.weaponBarStyle.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.weaponBarStyle.generic.callback = Preferences_Event;
s_preferences.weaponBarStyle.generic.id = ID_WEAPONBARSTYLE;
s_preferences.weaponBarStyle.generic.x = PREFERENCES_X_POS;
s_preferences.weaponBarStyle.generic.y = y;
s_preferences.weaponBarStyle.itemnames = weaponBarStyle_names;

Preferences_Menu_AddBoolean(&s_preferences.wallmarks, &y, ID_WALLMARKS, "Marks on Walls:");
Preferences_Menu_AddBoolean(&s_preferences.brass, &y, ID_EJECTINGBRASS, "Ejecting Brass:");
Expand Down Expand Up @@ -333,8 +297,6 @@ static void Preferences_MenuInit( void ) {
Menu_AddItem( &s_preferences.menu, &s_preferences.framer );

Menu_AddItem( &s_preferences.menu, &s_preferences.simpleitems );
Menu_AddItem( &s_preferences.menu, &s_preferences.alwaysweaponbar );
Menu_AddItem( &s_preferences.menu, &s_preferences.weaponBarStyle );
Menu_AddItem( &s_preferences.menu, &s_preferences.wallmarks );
Menu_AddItem( &s_preferences.menu, &s_preferences.brass );
Menu_AddItem( &s_preferences.menu, &s_preferences.identifytarget );
Expand Down

0 comments on commit 963550e

Please sign in to comment.