1 /*
2 Copyright (C) 2003-2006 Andrey Nazarov
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
27 INGAME MENU
28
29 =======================================================================
30 */
31
32 #define INGAME_ITEMS 5
33
34 static const char *names[] = {
35 "Options",
36 "Multiplayer",
37 "Demos",
38 "Disconnect",
39 "Quit",
40 NULL
41 };
42
43 typedef struct ingameMenu_s {
44 menuFrameWork_t menu;
45 menuAction_t actions[INGAME_ITEMS];
46 } ingameMenu_t;
47
48 static ingameMenu_t m_ingame;
49
IngameMenu_QuitAction(qboolean yes)50 static void IngameMenu_QuitAction( qboolean yes ) {
51 if( yes ) {
52 cmd.ExecuteText( EXEC_APPEND, "quit\n" );
53 } else {
54 UI_PopMenu();
55 }
56 }
57
58
IngameMenu_Callback(int id,int msg,int param)59 static int IngameMenu_Callback( int id, int msg, int param ) {
60 switch( msg ) {
61 case QM_ACTIVATE:
62 switch( id ) {
63 case 0:
64 M_Menu_Options_f();
65 break;
66 case 1:
67 M_Menu_Multiplayer_f();
68 break;
69 case 2:
70 M_Menu_Demos_f();
71 break;
72 case 3:
73 cmd.ExecuteText( EXEC_APPEND, "disconnect\n" );
74 UI_PopMenu();
75 return QMS_SILENT;
76 case 4:
77 M_Menu_Confirm_f( "Quit game? y/n", IngameMenu_QuitAction );
78 break;
79 }
80 return QMS_IN;
81 default:
82 break;
83 }
84
85 return QMS_NOTHANDLED;
86 }
87
IngameMenu_Draw(menuFrameWork_t * self)88 static void IngameMenu_Draw( menuFrameWork_t *self ) {
89 int y1, y2;
90 color_t color;
91
92 y1 = ( uis.glconfig.vidHeight - 16 * INGAME_ITEMS ) / 2 - 16;
93 y2 = ( uis.glconfig.vidHeight + 16 * INGAME_ITEMS ) / 2 + 16;
94
95 color[0] = 0;
96 color[1] = 0;
97 color[2] = 255;
98 color[3] = 32;
99
100 ref.DrawFillEx( 0, y1, uis.glconfig.vidWidth, y2 - y1, color );
101
102 Menu_Draw( self );
103 }
104
105
106
IngameMenu_Init(void)107 static void IngameMenu_Init( void ) {
108 int i;
109 int x, y;
110
111 x = uis.glconfig.vidWidth / 2;
112 y = ( uis.glconfig.vidHeight - 16 * INGAME_ITEMS ) / 2;
113
114 memset( &m_ingame, 0, sizeof( m_ingame ) );
115
116 m_ingame.menu.callback = IngameMenu_Callback;
117 m_ingame.menu.draw = IngameMenu_Draw;
118 m_ingame.menu.transparent = qtrue;
119
120 for( i=0 ; i<INGAME_ITEMS ; i++ ) {
121 m_ingame.actions[i].generic.type = MTYPE_ACTION;
122 m_ingame.actions[i].generic.id = i;
123 m_ingame.actions[i].generic.name = names[i];
124 m_ingame.actions[i].generic.x = x;
125 m_ingame.actions[i].generic.y = y;
126 m_ingame.actions[i].generic.uiFlags = UI_CENTER|UI_DROPSHADOW;
127 y += 16;
128
129 Menu_AddItem( &m_ingame.menu, (void *)&m_ingame.actions[i] );
130 }
131
132 m_ingame.actions[0].generic.flags = QMF_HASFOCUS;
133
134 }
135
136
M_Menu_Ingame_f(void)137 void M_Menu_Ingame_f( void ) {
138 IngameMenu_Init();
139 UI_PushMenu( &m_ingame.menu );
140 }
141
142