From 963550e2a173b90c43387c95e09215954d8b5325 Mon Sep 17 00:00:00 2001 From: NeonKnightOA Date: Thu, 21 Mar 2024 10:25:25 -0300 Subject: [PATCH] Classic UI: Transplant of alwaysWeaponBar and weaponBarStyle from Game Options to H.U.D. (#248) --- code/q3_ui/ui_hud.c | 47 +++++++++++++++++++++++++++++++++++++ code/q3_ui/ui_preferences.c | 38 ------------------------------ 2 files changed, 47 insertions(+), 38 deletions(-) diff --git a/code/q3_ui/ui_hud.c b/code/q3_ui/ui_hud.c index 7b82f136..6c1796cb 100644 --- a/code/q3_ui/ui_hud.c +++ b/code/q3_ui/ui_hud.c @@ -63,6 +63,9 @@ typedef struct { menuslider_s crosshairColorGreen; menuslider_s crosshairColorBlue; + menuradiobutton_s alwaysWeaponBar; + menulist_s weaponBarStyle; + menuradiobutton_s drawFPS; menubitmap_s back; @@ -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; } @@ -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; @@ -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:"; @@ -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 ); diff --git a/code/q3_ui/ui_preferences.c b/code/q3_ui/ui_preferences.c index 3aefc062..ff8fe519 100644 --- a/code/q3_ui/ui_preferences.c +++ b/code/q3_ui/ui_preferences.c @@ -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; @@ -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; @@ -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 ); @@ -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:"); @@ -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 );