/* =========================================================================== Copyright (C) 1999-2005 Id Software, Inc. Copyright (C) 2002-2021 Q3Rally Team (Per Thormann - q3rally@gmail.com) This file is part of q3rally source code. q3rally source code is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. q3rally source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with q3rally; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ // /* ======================================================================= SETUP MENU ======================================================================= */ #include "ui_local.h" #define SETUP_MENU_VERTICAL_SPACING 34 #define ID_CUSTOMIZEPLAYER 10 #define ID_CUSTOMIZECONTROLS 11 #define ID_SYSTEMCONFIG 12 #define ID_GAME 13 #define ID_CDKEY 14 #define ID_LOAD 15 #define ID_SAVE 16 #define ID_DEFAULTS 17 #define ID_BACK 18 // STONELANCE #define ID_Q3ROPTIONS 19 // END typedef struct { menuframework_s menu; menutext_s banner; menutext_s setupplayer; menutext_s setupcontrols; menutext_s setupsystem; menutext_s game; menutext_s cdkey; menutext_s q3rOptions; menutext_s defaults; menutext_s back; } setupMenuInfo_t; static setupMenuInfo_t setupMenuInfo; /* ================= Setup_ResetDefaults_Action ================= */ static void Setup_ResetDefaults_Action( qboolean result ) { if( !result ) { return; } trap_Cmd_ExecuteText( EXEC_APPEND, "exec default.cfg\n"); trap_Cmd_ExecuteText( EXEC_APPEND, "cvar_restart\n"); trap_Cmd_ExecuteText( EXEC_APPEND, "vid_restart\n" ); } /* ================= Setup_ResetDefaults_Draw ================= */ static void Setup_ResetDefaults_Draw( void ) { UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 0, "WARNING: This will reset *ALL*", UI_CENTER|UI_SMALLFONT, color_yellow ); UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 1, "options to their default values.", UI_CENTER|UI_SMALLFONT, color_yellow ); } /* =============== UI_SetupMenu_Event =============== */ static void UI_SetupMenu_Event( void *ptr, int event ) { if( event != QM_ACTIVATED ) { return; } switch( ((menucommon_s*)ptr)->id ) { /* case ID_CUSTOMIZEPLAYER: UI_PlayerSettingsMenu(); break; case ID_CUSTOMIZECONTROLS: UI_ControlsMenu(); break; case ID_SYSTEMCONFIG: UI_GraphicsOptionsMenu(); break; case ID_GAME: UI_PreferencesMenu(); break; case ID_CDKEY: UI_CDKeyMenu(); break; // case ID_LOAD: // UI_LoadConfigMenu(); // break; // case ID_SAVE: // UI_SaveConfigMenu(); // break; case ID_DEFAULTS: UI_ConfirmMenu( "SET TO DEFAULTS?", Setup_ResetDefaults_Draw, Setup_ResetDefaults_Action ); break; case ID_BACK: UI_PopMenu(); break; */ default: setupMenuInfo.menu.transitionMenu = ((menucommon_s*)ptr)->id; uis.transitionOut = uis.realtime; break; // END } } // STONELANCE /* ================= UI_SetupMenu_ChangeMenu ================= */ void UI_SetupMenu_ChangeMenu( int menuID ){ switch(menuID){ case ID_CUSTOMIZEPLAYER: UI_PlayerSettingsMenu(); break; case ID_CUSTOMIZECONTROLS: UI_ControlsMenu(); break; case ID_SYSTEMCONFIG: UI_GraphicsOptionsMenu(); break; case ID_GAME: UI_PreferencesMenu(); break; case ID_CDKEY: UI_CDKeyMenu(); break; case ID_Q3ROPTIONS: UI_Q3ROptionsMenu(); break; case ID_DEFAULTS: UI_ConfirmMenu( "SET TO DEFAULTS?", Setup_ResetDefaults_Draw, Setup_ResetDefaults_Action ); break; case ID_BACK: // uis.transitionIn = uis.realtime; UI_PopMenu(); break; } } /* ================= UI_SetupMenu_RunTransition ================= */ void UI_SetupMenu_RunTransition(float frac){ uis.text_color[0] = text_color_normal[0]; uis.text_color[1] = text_color_normal[1]; uis.text_color[2] = text_color_normal[2]; uis.text_color[3] = text_color_normal[3] * frac; setupMenuInfo.banner.color = uis.text_color; setupMenuInfo.cdkey.color = uis.text_color; setupMenuInfo.defaults.color = uis.text_color; setupMenuInfo.game.color = uis.text_color; setupMenuInfo.q3rOptions.color = uis.text_color; setupMenuInfo.setupcontrols.color = uis.text_color; setupMenuInfo.setupplayer.color = uis.text_color; setupMenuInfo.setupsystem.color = uis.text_color; } /* =============== UI_SetupMenu_Init =============== */ static void UI_SetupMenu_Init( void ) { int y; UI_SetupMenu_Cache(); memset( &setupMenuInfo, 0, sizeof(setupMenuInfo) ); setupMenuInfo.menu.wrapAround = qtrue; setupMenuInfo.menu.fullscreen = qtrue; setupMenuInfo.menu.transition = UI_SetupMenu_RunTransition; setupMenuInfo.menu.changeMenu = UI_SetupMenu_ChangeMenu; setupMenuInfo.banner.generic.type = MTYPE_BTEXT; setupMenuInfo.banner.generic.x = 320; setupMenuInfo.banner.generic.y = 16; setupMenuInfo.banner.string = "SETUP"; setupMenuInfo.banner.color = color_white; setupMenuInfo.banner.style = UI_CENTER; y = 134; setupMenuInfo.setupplayer.generic.type = MTYPE_PTEXT; setupMenuInfo.setupplayer.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; setupMenuInfo.setupplayer.generic.x = 320; setupMenuInfo.setupplayer.generic.y = y; setupMenuInfo.setupplayer.generic.id = ID_CUSTOMIZEPLAYER; setupMenuInfo.setupplayer.generic.callback = UI_SetupMenu_Event; setupMenuInfo.setupplayer.string = "PLAYER"; setupMenuInfo.setupplayer.color = text_color_normal; setupMenuInfo.setupplayer.style = UI_CENTER; y += SETUP_MENU_VERTICAL_SPACING; setupMenuInfo.setupcontrols.generic.type = MTYPE_PTEXT; setupMenuInfo.setupcontrols.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; setupMenuInfo.setupcontrols.generic.x = 320; setupMenuInfo.setupcontrols.generic.y = y; setupMenuInfo.setupcontrols.generic.id = ID_CUSTOMIZECONTROLS; setupMenuInfo.setupcontrols.generic.callback = UI_SetupMenu_Event; setupMenuInfo.setupcontrols.string = "CONTROLS"; setupMenuInfo.setupcontrols.color = text_color_normal; setupMenuInfo.setupcontrols.style = UI_CENTER; y += SETUP_MENU_VERTICAL_SPACING; setupMenuInfo.setupsystem.generic.type = MTYPE_PTEXT; setupMenuInfo.setupsystem.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; setupMenuInfo.setupsystem.generic.x = 320; setupMenuInfo.setupsystem.generic.y = y; setupMenuInfo.setupsystem.generic.id = ID_SYSTEMCONFIG; setupMenuInfo.setupsystem.generic.callback = UI_SetupMenu_Event; setupMenuInfo.setupsystem.string = "SYSTEM"; setupMenuInfo.setupsystem.color = text_color_normal; setupMenuInfo.setupsystem.style = UI_CENTER; y += SETUP_MENU_VERTICAL_SPACING; setupMenuInfo.game.generic.type = MTYPE_PTEXT; setupMenuInfo.game.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; setupMenuInfo.game.generic.x = 320; setupMenuInfo.game.generic.y = y; setupMenuInfo.game.generic.id = ID_GAME; setupMenuInfo.game.generic.callback = UI_SetupMenu_Event; setupMenuInfo.game.string = "GAME OPTIONS"; setupMenuInfo.game.color = text_color_normal; setupMenuInfo.game.style = UI_CENTER; y += SETUP_MENU_VERTICAL_SPACING; setupMenuInfo.q3rOptions.generic.type = MTYPE_PTEXT; setupMenuInfo.q3rOptions.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; setupMenuInfo.q3rOptions.generic.x = 320; setupMenuInfo.q3rOptions.generic.y = y; setupMenuInfo.q3rOptions.generic.id = ID_Q3ROPTIONS; setupMenuInfo.q3rOptions.generic.callback = UI_SetupMenu_Event; setupMenuInfo.q3rOptions.string = "Q3R OPTIONS"; setupMenuInfo.q3rOptions.color = text_color_normal; setupMenuInfo.q3rOptions.style = UI_CENTER; if( !trap_Cvar_VariableValue( "cl_paused" ) ) { #if 0 y += SETUP_MENU_VERTICAL_SPACING; setupMenuInfo.load.generic.type = MTYPE_PTEXT; setupMenuInfo.load.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; setupMenuInfo.load.generic.x = 320; setupMenuInfo.load.generic.y = y; setupMenuInfo.load.generic.id = ID_LOAD; setupMenuInfo.load.generic.callback = UI_SetupMenu_Event; setupMenuInfo.load.string = "LOAD"; setupMenuInfo.load.color = color_red; setupMenuInfo.load.style = UI_CENTER; y += SETUP_MENU_VERTICAL_SPACING; setupMenuInfo.save.generic.type = MTYPE_PTEXT; setupMenuInfo.save.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; setupMenuInfo.save.generic.x = 320; setupMenuInfo.save.generic.y = y; setupMenuInfo.save.generic.id = ID_SAVE; setupMenuInfo.save.generic.callback = UI_SetupMenu_Event; setupMenuInfo.save.string = "SAVE"; setupMenuInfo.save.color = color_red; setupMenuInfo.save.style = UI_CENTER; #endif y += SETUP_MENU_VERTICAL_SPACING; setupMenuInfo.defaults.generic.type = MTYPE_PTEXT; setupMenuInfo.defaults.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; setupMenuInfo.defaults.generic.x = 320; setupMenuInfo.defaults.generic.y = y; setupMenuInfo.defaults.generic.id = ID_DEFAULTS; setupMenuInfo.defaults.generic.callback = UI_SetupMenu_Event; setupMenuInfo.defaults.string = "DEFAULT"; setupMenuInfo.defaults.color = text_color_normal; setupMenuInfo.defaults.style = UI_CENTER; } setupMenuInfo.back.generic.type = MTYPE_PTEXT; setupMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; setupMenuInfo.back.generic.x = 20; setupMenuInfo.back.generic.y = 480 - 50; setupMenuInfo.back.generic.id = ID_BACK; setupMenuInfo.back.generic.callback = UI_SetupMenu_Event; setupMenuInfo.back.string = "< BACK"; setupMenuInfo.back.color = text_color_normal; setupMenuInfo.back.style = UI_LEFT | UI_SMALLFONT; Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.banner ); Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupplayer ); Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupcontrols ); Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupsystem ); Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.game ); Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.q3rOptions ); if( !trap_Cvar_VariableValue( "cl_paused" ) ) { Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.defaults ); } Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.back ); uis.transitionIn = uis.realtime; } /* ================= UI_SetupMenu_Cache ================= */ void UI_SetupMenu_Cache( void ) { // BAGPUSS /* trap_R_RegisterShaderNoMip( ART_BACK0 ); trap_R_RegisterShaderNoMip( ART_BACK1 ); trap_R_RegisterShaderNoMip( ART_FRAMEL ); trap_R_RegisterShaderNoMip( ART_FRAMER ); */ // END } /* =============== UI_SetupMenu =============== */ void UI_SetupMenu( void ) { UI_SetupMenu_Init(); UI_PushMenu( &setupMenuInfo.menu ); }