1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 
19 */
20 
21 #include "ui_local.h"
22 
23 /*
24 =============================================================================
25 
26 GAME MENU
27 
28 =============================================================================
29 */
30 
31 #define ID_LOADGAME	101
32 #define ID_START	102
33 
34 typedef struct m_game_s {
35 	menuFrameWork_t	menu;
36 	menuSpinControl_t	skill;
37 	menuAction_t load;
38 	menuAction_t start;
39 	menuStatic_t	banner;
40 } m_game_t;
41 
42 static m_game_t		m_game;
43 
44 static const char *difficulty_names[] = {
45 	"easy",
46 	"medium",
47 	"hard",
48 	"hard+",
49 	NULL
50 };
51 
StartGame(void)52 static void StartGame( void ) {
53 	cvar.SetInteger( "skill", m_game.skill.curvalue );
54 	cvar.SetInteger( "deathmatch", 0 );
55 	cvar.SetInteger( "coop", 0 );
56 	cvar.SetInteger( "gamerules", 0 );		//PGM
57 
58 	cmd.ExecuteText( EXEC_APPEND, "map base1\n" );
59 
60 	// disable updates and start the cinematic going
61 	UI_ForceMenuOff();
62 
63 }
64 
GameMenu_Callback(int id,int msg,int param)65 static int GameMenu_Callback( int id, int msg, int param ) {
66 	switch( msg ) {
67 	case QM_ACTIVATE:
68 		switch( id ) {
69 		case ID_LOADGAME:
70 			M_Menu_LoadGame_f ();
71 			break;
72 		case ID_START:
73 			StartGame();
74 			break;
75 		}
76 		return QMS_IN;
77 	case QM_DESTROY:
78 		break;
79 	default:
80 		break;
81 	}
82 
83 	return QMS_NOTHANDLED;
84 
85 }
86 
GameMenu_Init(void)87 static void GameMenu_Init( void ) {
88 	int y;
89 
90 	memset( &m_game, 0, sizeof( m_game ) );
91 
92 	m_game.menu.callback = GameMenu_Callback;
93 
94 	y = 120;
95 	m_game.skill.generic.type	= MTYPE_SPINCONTROL;
96 	m_game.skill.generic.name	= "skill";
97 	m_game.skill.generic.x		= uis.glconfig.vidWidth / 2;
98 	m_game.skill.generic.y		= y;
99 	m_game.skill.itemnames		= difficulty_names;
100 	y += 8;
101 
102 	m_game.load.generic.type	= MTYPE_ACTION;
103 	m_game.load.generic.id		= ID_LOADGAME;
104 	m_game.load.generic.name	= "load game";
105 	m_game.load.generic.x		= uis.glconfig.vidWidth / 2 + LCOLUMN_OFFSET;
106 	m_game.load.generic.y		= y;
107 	m_game.load.generic.uiFlags	= UI_RIGHT;
108 	y += 8;
109 
110 	m_game.start.generic.type	= MTYPE_ACTION;
111 	m_game.start.generic.flags	= QMF_HASFOCUS;
112 	m_game.start.generic.id		= ID_START;
113 	m_game.start.generic.name	= "start game";
114 	m_game.start.generic.x		= uis.glconfig.vidWidth / 2 + LCOLUMN_OFFSET;
115 	m_game.start.generic.y		= y;
116 	m_game.start.generic.uiFlags	= UI_RIGHT;
117 	y += 8;
118 
119 	UI_SetupDefaultBanner( &m_game.banner, "Single player" );
120 
121 	Menu_AddItem( &m_game.menu, (void *)&m_game.skill );
122 	Menu_AddItem( &m_game.menu, (void *)&m_game.load );
123 	Menu_AddItem( &m_game.menu, (void *)&m_game.start );
124 	Menu_AddItem( &m_game.menu, (void *)&m_game.banner );
125 }
126 
127 
128 
M_Menu_Game_f(void)129 void M_Menu_Game_f( void ) {
130 	GameMenu_Init();
131 	UI_PushMenu( &m_game.menu );
132 }
133