| 1 |
|
| 2 |
/* |
| 3 |
=========================================================================== |
| 4 |
Copyright (C) 2009 Poul Sander |
| 5 |
|
| 6 |
This file is part of the Open Arena source code. |
| 7 |
|
| 8 |
Open Arena source code is free software; you can redistribute it |
| 9 |
and/or modify it under the terms of the GNU General Public License as |
| 10 |
published by the Free Software Foundation; either version 2 of the License, |
| 11 |
or (at your option) any later version. |
| 12 |
|
| 13 |
Open Arena source code is distributed in the hope that it will be |
| 14 |
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
GNU General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with Open Arena source code; if not, write to the Free Software |
| 20 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 |
=========================================================================== |
| 22 |
*/ |
| 23 |
|
| 24 |
#include "ui_local.h" |
| 25 |
|
| 26 |
#define VOTEMENU_BACK0 "menu/art_blueish/back_0" |
| 27 |
#define VOTEMENU_BACK1 "menu/art_blueish/back_1" |
| 28 |
#define ART_FIGHT0 "menu/art_blueish/accept_0" |
| 29 |
#define ART_FIGHT1 "menu/art_blueish/accept_1" |
| 30 |
#define ART_BACKGROUND "menu/art_blueish/addbotframe" |
| 31 |
|
| 32 |
static char* votemenu_fraglmit_artlist[] = |
| 33 |
{ |
| 34 |
VOTEMENU_BACK0, |
| 35 |
VOTEMENU_BACK1, |
| 36 |
ART_FIGHT0, |
| 37 |
ART_FIGHT1, |
| 38 |
NULL |
| 39 |
}; |
| 40 |
|
| 41 |
#define ID_BACK 100 |
| 42 |
#define ID_GO 101 |
| 43 |
#define ID_50 102 |
| 44 |
#define ID_10 103 |
| 45 |
#define ID_15 104 |
| 46 |
#define ID_20 105 |
| 47 |
#define ID_30 106 |
| 48 |
#define ID_40 107 |
| 49 |
#define ID_INF 108 |
| 50 |
|
| 51 |
#define FRAGLIMIT_MENU_VERTICAL_SPACING 28 |
| 52 |
|
| 53 |
typedef struct |
| 54 |
{ |
| 55 |
menuframework_s menu; |
| 56 |
menutext_s banner; |
| 57 |
menubitmap_s back; |
| 58 |
menubitmap_s go; |
| 59 |
|
| 60 |
//Buttons: |
| 61 |
menutext_s bLimit50; |
| 62 |
menutext_s bLimit10; |
| 63 |
menutext_s bLimit15; |
| 64 |
menutext_s bLimit20; |
| 65 |
menutext_s bLimit30; |
| 66 |
menutext_s bLimit40; |
| 67 |
menutext_s bLimitInf; |
| 68 |
|
| 69 |
int min, max; //Values restricted by server |
| 70 |
int selection; |
| 71 |
} votemenu_t; |
| 72 |
|
| 73 |
static votemenu_t s_votemenu_fraglmit; |
| 74 |
|
| 75 |
void UI_VoteFraglimitMenuInternal( void ); |
| 76 |
|
| 77 |
/* |
| 78 |
================= |
| 79 |
VoteMenu_Fraglimit_Event |
| 80 |
================= |
| 81 |
*/ |
| 82 |
static void VoteMenu_Fraglimit_Event( void* ptr, int event ) |
| 83 |
{ |
| 84 |
switch (((menucommon_s*)ptr)->id) |
| 85 |
{ |
| 86 |
case ID_BACK: |
| 87 |
if (event != QM_ACTIVATED) |
| 88 |
break; |
| 89 |
|
| 90 |
UI_PopMenu(); |
| 91 |
break; |
| 92 |
case ID_GO: |
| 93 |
if( event != QM_ACTIVATED ) { |
| 94 |
return; |
| 95 |
} |
| 96 |
switch(s_votemenu_fraglmit.selection) { |
| 97 |
case ID_10: |
| 98 |
trap_Cmd_ExecuteText( EXEC_APPEND, "callvote fraglimit 10" ); |
| 99 |
UI_PopMenu(); |
| 100 |
UI_PopMenu(); |
| 101 |
break; |
| 102 |
case ID_15: |
| 103 |
trap_Cmd_ExecuteText( EXEC_APPEND, "callvote fraglimit 15" ); |
| 104 |
UI_PopMenu(); |
| 105 |
UI_PopMenu(); |
| 106 |
break; |
| 107 |
case ID_20: |
| 108 |
trap_Cmd_ExecuteText( EXEC_APPEND, "callvote fraglimit 20" ); |
| 109 |
UI_PopMenu(); |
| 110 |
UI_PopMenu(); |
| 111 |
break; |
| 112 |
case ID_30: |
| 113 |
trap_Cmd_ExecuteText( EXEC_APPEND, "callvote fraglimit 30" ); |
| 114 |
UI_PopMenu(); |
| 115 |
UI_PopMenu(); |
| 116 |
break; |
| 117 |
case ID_40: |
| 118 |
trap_Cmd_ExecuteText( EXEC_APPEND, "callvote fraglimit 40" ); |
| 119 |
UI_PopMenu(); |
| 120 |
UI_PopMenu(); |
| 121 |
break; |
| 122 |
case ID_50: |
| 123 |
trap_Cmd_ExecuteText( EXEC_APPEND, "callvote fraglimit 50" ); |
| 124 |
UI_PopMenu(); |
| 125 |
UI_PopMenu(); |
| 126 |
break; |
| 127 |
case ID_INF: |
| 128 |
trap_Cmd_ExecuteText( EXEC_APPEND, "callvote fraglimit 0" ); |
| 129 |
UI_PopMenu(); |
| 130 |
UI_PopMenu(); |
| 131 |
break; |
| 132 |
}; |
| 133 |
break; |
| 134 |
default: |
| 135 |
if( event != QM_ACTIVATED ) { |
| 136 |
return; |
| 137 |
} |
| 138 |
if(s_votemenu_fraglmit.selection != ((menucommon_s*)ptr)->id) { |
| 139 |
s_votemenu_fraglmit.selection = ((menucommon_s*)ptr)->id; |
| 140 |
UI_VoteFraglimitMenuInternal(); |
| 141 |
} |
| 142 |
break; |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
static void setMenutext(menutext_s *menu,int y,int id,int value,char *text) { |
| 147 |
menu->generic.type = MTYPE_PTEXT; |
| 148 |
menu->color = color_red; |
| 149 |
menu->generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; |
| 150 |
if((s_votemenu_fraglmit.min > value && value!=0) || |
| 151 |
(s_votemenu_fraglmit.max < value && s_votemenu_fraglmit.max!=0) || |
| 152 |
(s_votemenu_fraglmit.max != 0 && value==0)) |
| 153 |
menu->generic.flags |= QMF_INACTIVE|QMF_GRAYED; |
| 154 |
else |
| 155 |
if(s_votemenu_fraglmit.selection == id) |
| 156 |
menu->color = color_orange; |
| 157 |
menu->generic.x = 320; |
| 158 |
menu->generic.y = y; |
| 159 |
menu->generic.id = id; |
| 160 |
menu->generic.callback = VoteMenu_Fraglimit_Event; |
| 161 |
menu->string = text; |
| 162 |
menu->style = UI_CENTER|UI_SMALLFONT; |
| 163 |
} |
| 164 |
|
| 165 |
/* |
| 166 |
================= |
| 167 |
VoteMenu_Fraglimit_Cache |
| 168 |
================= |
| 169 |
*/ |
| 170 |
static void VoteMenu_Fraglimit_Cache( void ) |
| 171 |
{ |
| 172 |
int i; |
| 173 |
|
| 174 |
// touch all our pics |
| 175 |
for (i=0; ;i++) |
| 176 |
{ |
| 177 |
if (!votemenu_fraglmit_artlist[i]) |
| 178 |
break; |
| 179 |
trap_R_RegisterShaderNoMip(votemenu_fraglmit_artlist[i]); |
| 180 |
} |
| 181 |
} |
| 182 |
|
| 183 |
/* |
| 184 |
================= |
| 185 |
UI_VoteMenu_Fraglimit_Draw |
| 186 |
================= |
| 187 |
*/ |
| 188 |
static void UI_VoteMenu_Fraglimit_Draw( void ) { |
| 189 |
UI_DrawBannerString( 320, 16, "CALL VOTE - FRAGLIMIT", UI_CENTER, color_white ); |
| 190 |
UI_DrawNamedPic( 320-233, 240-166, 466, 332, ART_BACKGROUND ); |
| 191 |
|
| 192 |
// standard menu drawing |
| 193 |
Menu_Draw( &s_votemenu_fraglmit.menu ); |
| 194 |
} |
| 195 |
|
| 196 |
/* |
| 197 |
================= |
| 198 |
UI_VoteFraglimitMenuInternal |
| 199 |
*Used then forcing a redraw |
| 200 |
================= |
| 201 |
*/ |
| 202 |
void UI_VoteFraglimitMenuInternal( void ) |
| 203 |
{ |
| 204 |
int y; |
| 205 |
|
| 206 |
VoteMenu_Fraglimit_Cache(); |
| 207 |
|
| 208 |
s_votemenu_fraglmit.menu.wrapAround = qtrue; |
| 209 |
s_votemenu_fraglmit.menu.fullscreen = qfalse; |
| 210 |
s_votemenu_fraglmit.menu.draw = UI_VoteMenu_Fraglimit_Draw; |
| 211 |
|
| 212 |
s_votemenu_fraglmit.banner.generic.type = MTYPE_BTEXT; |
| 213 |
s_votemenu_fraglmit.banner.generic.x = 320; |
| 214 |
s_votemenu_fraglmit.banner.generic.y = 16; |
| 215 |
s_votemenu_fraglmit.banner.string = "CALL VOTE - FRAGLIMIT"; |
| 216 |
s_votemenu_fraglmit.banner.color = color_white; |
| 217 |
s_votemenu_fraglmit.banner.style = UI_CENTER; |
| 218 |
|
| 219 |
y = 98; |
| 220 |
setMenutext(&s_votemenu_fraglmit.bLimit10,y,ID_10,10,"10"); |
| 221 |
y+=FRAGLIMIT_MENU_VERTICAL_SPACING; |
| 222 |
setMenutext(&s_votemenu_fraglmit.bLimit15,y,ID_15,15,"15"); |
| 223 |
y+=FRAGLIMIT_MENU_VERTICAL_SPACING; |
| 224 |
setMenutext(&s_votemenu_fraglmit.bLimit20,y,ID_20,20,"20"); |
| 225 |
y+=FRAGLIMIT_MENU_VERTICAL_SPACING; |
| 226 |
setMenutext(&s_votemenu_fraglmit.bLimit30,y,ID_30,30,"30"); |
| 227 |
y+=FRAGLIMIT_MENU_VERTICAL_SPACING; |
| 228 |
setMenutext(&s_votemenu_fraglmit.bLimit40,y,ID_40,40,"40"); |
| 229 |
y+=FRAGLIMIT_MENU_VERTICAL_SPACING; |
| 230 |
setMenutext(&s_votemenu_fraglmit.bLimit50,y,ID_50,50,"50"); |
| 231 |
y+=FRAGLIMIT_MENU_VERTICAL_SPACING; |
| 232 |
setMenutext(&s_votemenu_fraglmit.bLimitInf,y,ID_INF,0,"No limit"); |
| 233 |
|
| 234 |
s_votemenu_fraglmit.back.generic.type = MTYPE_BITMAP; |
| 235 |
s_votemenu_fraglmit.back.generic.name = VOTEMENU_BACK0; |
| 236 |
s_votemenu_fraglmit.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 237 |
s_votemenu_fraglmit.back.generic.callback = VoteMenu_Fraglimit_Event; |
| 238 |
s_votemenu_fraglmit.back.generic.id = ID_BACK; |
| 239 |
s_votemenu_fraglmit.back.generic.x = 320-128; |
| 240 |
s_votemenu_fraglmit.back.generic.y = 256+128-64; |
| 241 |
s_votemenu_fraglmit.back.width = 128; |
| 242 |
s_votemenu_fraglmit.back.height = 64; |
| 243 |
s_votemenu_fraglmit.back.focuspic = VOTEMENU_BACK1; |
| 244 |
|
| 245 |
s_votemenu_fraglmit.go.generic.type = MTYPE_BITMAP; |
| 246 |
s_votemenu_fraglmit.go.generic.name = ART_FIGHT0; |
| 247 |
s_votemenu_fraglmit.go.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 248 |
s_votemenu_fraglmit.go.generic.callback = VoteMenu_Fraglimit_Event; |
| 249 |
s_votemenu_fraglmit.go.generic.id = ID_GO; |
| 250 |
s_votemenu_fraglmit.go.generic.x = 320; |
| 251 |
s_votemenu_fraglmit.go.generic.y = 256+128-64; |
| 252 |
s_votemenu_fraglmit.go.width = 128; |
| 253 |
s_votemenu_fraglmit.go.height = 64; |
| 254 |
s_votemenu_fraglmit.go.focuspic = ART_FIGHT1; |
| 255 |
} |
| 256 |
|
| 257 |
/* |
| 258 |
================= |
| 259 |
UI_VoteFraglimitMenu |
| 260 |
*Called from outside |
| 261 |
================= |
| 262 |
*/ |
| 263 |
void UI_VoteFraglimitMenu( void ) { |
| 264 |
char serverinfo[MAX_INFO_STRING]; |
| 265 |
// zero set all our globals |
| 266 |
memset( &s_votemenu_fraglmit, 0 ,sizeof(votemenu_t) ); |
| 267 |
trap_GetConfigString( CS_SERVERINFO, serverinfo, MAX_INFO_STRING ); |
| 268 |
s_votemenu_fraglmit.min = atoi(Info_ValueForKey(serverinfo,"g_voteMinFraglimit")); |
| 269 |
s_votemenu_fraglmit.max = atoi(Info_ValueForKey(serverinfo,"g_voteMaxFraglimit")); |
| 270 |
UI_VoteFraglimitMenuInternal(); |
| 271 |
|
| 272 |
Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.banner ); |
| 273 |
Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.back ); |
| 274 |
Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.go ); |
| 275 |
Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.bLimit10 ); |
| 276 |
Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.bLimit15 ); |
| 277 |
Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.bLimit20 ); |
| 278 |
Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.bLimit30 ); |
| 279 |
Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.bLimit40 ); |
| 280 |
Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.bLimit50 ); |
| 281 |
Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.bLimitInf ); |
| 282 |
|
| 283 |
UI_PushMenu( &s_votemenu_fraglmit.menu ); |
| 284 |
} |