Skip to content

Commit

Permalink
UI: Add advanced hit sound option to menu
Browse files Browse the repository at this point in the history
  • Loading branch information
kai-li-wop committed Jan 8, 2023
1 parent fb6fa7e commit 48aa98b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion code/ui/ui_preferences.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ PREFERENCES MENU
#define ID_SYNCEVERYFRAME 37
#define ID_FORCEMODEL 38
#define ID_GLOWMODEL 39
#define ID_HITSOUND 40

#define ID_CONNOTIFY 50
#define ID_CHATHEIGHT 51
Expand Down Expand Up @@ -132,6 +133,7 @@ typedef struct {
menuradiobutton_s synceveryframe;
menuradiobutton_s forcemodel;
menulist_s glowmodel;
menuradiobutton_s hitsound;

menulist_s connotify;
menulist_s chatheight;
Expand Down Expand Up @@ -188,6 +190,7 @@ static menucommon_s *g_game_options[] = {
(menucommon_s *)&s_preferences.synceveryframe,
(menucommon_s *)&s_preferences.forcemodel,
(menucommon_s *)&s_preferences.glowmodel,
(menucommon_s *)&s_preferences.hitsound,
NULL
};

Expand Down Expand Up @@ -269,12 +272,12 @@ static void UI_Preferences_SetMenuItems(void) {
s_preferences.ingamevideo.curvalue = trap_Cvar_VariableValue("r_inGameVideo") != 0;
s_preferences.synceveryframe.curvalue = trap_Cvar_VariableValue("r_finish") != 0;
s_preferences.forcemodel.curvalue = (trap_Cvar_VariableValue("cg_forcemodel") != 0);

if (!Q_stricmp(UI_Cvar_VariableString("cg_glowModel"), "")) {
s_preferences.glowmodel.curvalue = 0;
} else {
s_preferences.glowmodel.curvalue = (trap_Cvar_VariableValue("cg_glowModel") + 1);
}
s_preferences.hitsound.curvalue = (trap_Cvar_VariableValue("cg_advHitSound") != 0);

notify = UI_GetCvarInt("con_notifytime");
if (notify < 0) {
Expand Down Expand Up @@ -519,6 +522,10 @@ static void UI_Preferences_Event(void *ptr, int notification) {
UI_Preferences_UpdateMenuItems();
break;

case ID_HITSOUND:
trap_Cvar_SetValue("cg_advHitSound", s_preferences.hitsound.curvalue);
break;

case ID_CONNOTIFY:
switch (s_preferences.connotify.curvalue) {
case 0:
Expand Down Expand Up @@ -1020,6 +1027,18 @@ static void UI_Preferences_MenuInit(void) {
"Enable to force all players to be displayed with glowing player models in the desired skin color. "
"Default is none. NOTE: In team gametypes, the glowing color is always set to red or blue.";

y += (BIGCHAR_HEIGHT + 2);
s_preferences.hitsound.generic.type = MTYPE_RADIOBUTTON;
s_preferences.hitsound.generic.name = "Advanced Hit Sound:";
s_preferences.hitsound.generic.flags = QMF_SMALLFONT | QMF_HIDDEN;
s_preferences.hitsound.generic.callback = UI_Preferences_Event;
s_preferences.hitsound.generic.id = ID_HITSOUND;
s_preferences.hitsound.generic.x = XPOSITION;
s_preferences.hitsound.generic.y = y;
s_preferences.hitsound.generic.toolTip =
"Enable to play an alternate set of hit sounds indicating your opponent's shield points "
"from high to low. Default is off.";

// chat options
y = YPOSITION;
s_preferences.connotify.generic.type = MTYPE_SPINCONTROL;
Expand Down Expand Up @@ -1266,6 +1285,7 @@ static void UI_Preferences_MenuInit(void) {
Menu_AddItem(&s_preferences.menu, &s_preferences.synceveryframe);
Menu_AddItem(&s_preferences.menu, &s_preferences.forcemodel);
Menu_AddItem(&s_preferences.menu, &s_preferences.glowmodel);
Menu_AddItem(&s_preferences.menu, &s_preferences.hitsound);

Menu_AddItem(&s_preferences.menu, &s_preferences.connotify);
Menu_AddItem(&s_preferences.menu, &s_preferences.chatheight);
Expand Down

0 comments on commit 48aa98b

Please sign in to comment.