| 1 |
// |
| 2 |
// Copyright(C) 1993-1996 Id Software, Inc. |
| 3 |
// Copyright(C) 1993-2008 Raven Software |
| 4 |
// Copyright(C) 2005-2014 Simon Howard |
| 5 |
// |
| 6 |
// This program is free software; you can redistribute it and/or |
| 7 |
// modify it under the terms of the GNU General Public License |
| 8 |
// as published by the Free Software Foundation; either version 2 |
| 9 |
// of the License, or (at your option) any later version. |
| 10 |
// |
| 11 |
// This program is distributed in the hope that it will be useful, |
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
// GNU General Public License for more details. |
| 15 |
// |
| 16 |
|
| 17 |
// MN_menu.c |
| 18 |
|
| 19 |
#include "doomstat.h" |
| 20 |
#include "w_wad.h" |
| 21 |
#include "v_video.h" |
| 22 |
#include "m_menu.h" |
| 23 |
#include "g_game.h" |
| 24 |
#include "dsda/settings.h" |
| 25 |
#include "heretic/dstrings.h" |
| 26 |
#include "heretic/mn_menu.h" |
| 27 |
|
| 28 |
#define ITEM_HEIGHT 20 |
| 29 |
#define SELECTOR_XOFFSET (-28) |
| 30 |
#define SELECTOR_YOFFSET (-4) |
| 31 |
#define SFX_VOL_INDEX 1 |
| 32 |
#define MUS_VOL_INDEX 3 |
| 33 |
|
| 34 |
extern int g_menu_save_page_size; |
| 35 |
|
| 36 |
static int FontABaseLump; |
| 37 |
static int FontAYellowBaseLump; |
| 38 |
static int FontBBaseLump; |
| 39 |
static int SkullBaseLump; |
| 40 |
static int MenuTime; |
| 41 |
|
| 42 |
dboolean mn_SuicideConsole; |
| 43 |
|
| 44 |
static int MN_SafeFontALump(int offset) |
| 45 |
{ |
| 46 |
if (offset > 58) |
| 47 |
return FontABaseLump; |
| 48 |
|
| 49 |
return FontABaseLump + offset; |
| 50 |
} |
| 51 |
|
| 52 |
static void MN_InitFonts(void) |
| 53 |
{ |
| 54 |
FontABaseLump = W_GetNumForName("FONTA_S") + 1; |
| 55 |
if (hexen) FontAYellowBaseLump = W_GetNumForName("FONTAY_S") + 1; |
| 56 |
FontBBaseLump = W_GetNumForName("FONTB_S") + 1; |
| 57 |
} |
| 58 |
|
| 59 |
extern menu_t MainDef; |
| 60 |
extern menu_t EpiDef; |
| 61 |
extern menu_t SkillDef; |
| 62 |
extern menu_t OptionsDef; |
| 63 |
extern menu_t SoundDef; |
| 64 |
extern menu_t LoadDef; |
| 65 |
extern menu_t SaveDef; |
| 66 |
extern menuitem_t SoundMenu[]; |
| 67 |
|
| 68 |
///////////////////////////// |
| 69 |
// |
| 70 |
// Raven Prototypes |
| 71 |
// |
| 72 |
///////////////////////////// |
| 73 |
|
| 74 |
void MN_GameFiles(int choice); |
| 75 |
void MN_Info(int choice); |
| 76 |
void MN_Info2(int choice); |
| 77 |
void MN_Info3(int choice); |
| 78 |
void MN_Info4(int choice); |
| 79 |
void MN_FinishInfo(int choice); |
| 80 |
|
| 81 |
void MN_DrawInfoAd(void); |
| 82 |
void MN_DrawInfoHelp1(void); |
| 83 |
void MN_DrawInfoHelp2(void); |
| 84 |
void MN_DrawInfoCredits(void); |
| 85 |
|
| 86 |
void MN_DrawAd(void); |
| 87 |
void MN_DrawCredits(void); |
| 88 |
void MN_DrawHelp1(void); |
| 89 |
void MN_DrawHelp2(void); |
| 90 |
|
| 91 |
extern void M_ChangeMenu(menu_t *menu, menuactive_t mnact); |
| 92 |
extern dboolean inhelpscreens; |
| 93 |
extern menu_t ExtHelpDef; |
| 94 |
extern void M_NewGame(int choice); |
| 95 |
extern void M_Options(int choice); |
| 96 |
extern void M_QuitDOOM(int choice); |
| 97 |
extern void M_LoadGame(int choice); |
| 98 |
extern void M_SaveGame(int choice); |
| 99 |
|
| 100 |
|
| 101 |
///////////////////////////// |
| 102 |
// |
| 103 |
// Raven Info Screens |
| 104 |
// |
| 105 |
///////////////////////////// |
| 106 |
|
| 107 |
enum { infoempty1, info1_end } info_e1; |
| 108 |
enum { infoempty2, info2_end } info_e2; |
| 109 |
enum { infoempty3, info3_end } info_e3; |
| 110 |
enum { infoempty4, info4_end } info_e4; |
| 111 |
|
| 112 |
menuitem_t InfoMenu1[] = { {1,"",MN_Info2,0} }; |
| 113 |
menuitem_t InfoMenu2[] = { {1,"",MN_Info3,0} }; |
| 114 |
menuitem_t InfoMenu3[] = { {1,"",MN_Info4,0} }; |
| 115 |
menuitem_t InfoMenu4[] = { {1,"",MN_FinishInfo,0} }; |
| 116 |
|
| 117 |
menu_t InfoDef1 = |
| 118 |
{ |
| 119 |
info1_end, |
| 120 |
&MainDef, |
| 121 |
InfoMenu1, |
| 122 |
MN_DrawInfoAd, |
| 123 |
330,175, |
| 124 |
0 |
| 125 |
}; |
| 126 |
|
| 127 |
menu_t InfoDef2 = |
| 128 |
{ |
| 129 |
info2_end, |
| 130 |
&InfoDef1, |
| 131 |
InfoMenu2, |
| 132 |
MN_DrawInfoHelp1, |
| 133 |
330,175, |
| 134 |
0 |
| 135 |
}; |
| 136 |
|
| 137 |
menu_t InfoDef3 = |
| 138 |
{ |
| 139 |
info3_end, |
| 140 |
&InfoDef2, |
| 141 |
InfoMenu3, |
| 142 |
MN_DrawInfoHelp2, |
| 143 |
330,175, |
| 144 |
0 |
| 145 |
}; |
| 146 |
|
| 147 |
menu_t InfoDef4 = |
| 148 |
{ |
| 149 |
info4_end, |
| 150 |
&InfoDef3, |
| 151 |
InfoMenu4, |
| 152 |
MN_DrawInfoCredits, |
| 153 |
330,175, |
| 154 |
0 |
| 155 |
}; |
| 156 |
|
| 157 |
void MN_Info (int choice) { M_SetupNextMenu(&InfoDef1); } |
| 158 |
void MN_Info2 (int choice) { M_SetupNextMenu(&InfoDef2); } |
| 159 |
void MN_Info3 (int choice) { M_SetupNextMenu(&InfoDef3); } |
| 160 |
void MN_Info4 (int choice) { M_SetupNextMenu(&InfoDef4); } |
| 161 |
void MN_FinishInfo (int choice) { M_SetupNextMenu(&MainDef); } |
| 162 |
|
| 163 |
void MN_DrawInfoAd(void) |
| 164 |
{ |
| 165 |
inhelpscreens = true; |
| 166 |
MN_DrawAd(); |
| 167 |
} |
| 168 |
|
| 169 |
void MN_DrawInfoHelp1(void) |
| 170 |
{ |
| 171 |
inhelpscreens = true; |
| 172 |
MN_DrawHelp1(); |
| 173 |
} |
| 174 |
|
| 175 |
void MN_DrawInfoHelp2(void) |
| 176 |
{ |
| 177 |
inhelpscreens = true; |
| 178 |
MN_DrawHelp2(); |
| 179 |
} |
| 180 |
|
| 181 |
void MN_DrawInfoCredits(void) |
| 182 |
{ |
| 183 |
inhelpscreens = true; |
| 184 |
MN_DrawCredits(); |
| 185 |
} |
| 186 |
|
| 187 |
void MN_DrawAd (void) |
| 188 |
{ |
| 189 |
const char* ravenlump; |
| 190 |
ravenlump = (heretic && (gamemode == shareware)) ? "ORDER" : "CREDIT"; |
| 191 |
M_ChangeMenu(NULL, mnact_full); |
| 192 |
V_DrawRawScreen(ravenlump); |
| 193 |
return; |
| 194 |
} |
| 195 |
|
| 196 |
void MN_DrawHelp1 (void) |
| 197 |
{ |
| 198 |
M_ChangeMenu(NULL, mnact_full); |
| 199 |
V_DrawRawScreen("HELP1"); |
| 200 |
return; |
| 201 |
} |
| 202 |
|
| 203 |
void MN_DrawHelp2 (void) |
| 204 |
{ |
| 205 |
M_ChangeMenu(NULL, mnact_full); |
| 206 |
V_DrawRawScreen("HELP2"); |
| 207 |
return; |
| 208 |
} |
| 209 |
|
| 210 |
void MN_DrawCredits (void) |
| 211 |
{ |
| 212 |
M_ChangeMenu(NULL, mnact_full); |
| 213 |
V_DrawRawScreen("CREDIT"); |
| 214 |
return; |
| 215 |
} |
| 216 |
|
| 217 |
///////////////////////////// |
| 218 |
// |
| 219 |
// RavenMainMenu (Heretic and Hexen use this) |
| 220 |
// |
| 221 |
///////////////////////////// |
| 222 |
|
| 223 |
enum |
| 224 |
{ |
| 225 |
rnewgame = 0, |
| 226 |
roptions, |
| 227 |
rgamefiles, |
| 228 |
rinfo, |
| 229 |
rquitdoom, |
| 230 |
rmain_end |
| 231 |
} rmain_e; |
| 232 |
|
| 233 |
menuitem_t RavenMainMenu[]= |
| 234 |
{ |
| 235 |
{1,"M_NGAME", M_NewGame, 'n', "NEW GAME"}, |
| 236 |
{1,"M_OPTION",M_Options, 'o', "OPTIONS"}, |
| 237 |
{1,"M_GFILES", MN_GameFiles,'g', "GAME FILES"}, |
| 238 |
{1,"M_INFO",MN_Info,'i', "INFO"}, |
| 239 |
{1,"M_QUITG", M_QuitDOOM,'q', "QUIT GAME"} |
| 240 |
}; |
| 241 |
|
| 242 |
|
| 243 |
///////////////////////////// |
| 244 |
// |
| 245 |
// Raven GameFiles Menu |
| 246 |
// |
| 247 |
///////////////////////////// |
| 248 |
|
| 249 |
enum |
| 250 |
{ |
| 251 |
rloadgame, |
| 252 |
rsavegame, |
| 253 |
rsaveload_end |
| 254 |
} saveload_e; |
| 255 |
|
| 256 |
menuitem_t SaveLoadMenu[]= |
| 257 |
{ |
| 258 |
{1,"M_LOADG", M_LoadGame,'l', "LOAD GAME"}, |
| 259 |
{1,"M_SAVEG", M_SaveGame,'s', "SAVE GAME"}, |
| 260 |
}; |
| 261 |
|
| 262 |
menu_t SaveLoadDef = |
| 263 |
{ |
| 264 |
rsaveload_end, // number of menu items |
| 265 |
&MainDef, // previous menu screen |
| 266 |
SaveLoadMenu, // table that defines menu items |
| 267 |
NULL, // drawing routine |
| 268 |
97,64, // initial cursor position |
| 269 |
0 // last menu item the user was on |
| 270 |
}; |
| 271 |
|
| 272 |
void MN_GameFiles(int choice) |
| 273 |
{ |
| 274 |
M_SetupNextMenu(&SaveLoadDef); |
| 275 |
} |
| 276 |
|
| 277 |
|
| 278 |
///////////////////////////// |
| 279 |
// |
| 280 |
// Raven MN_Init |
| 281 |
// |
| 282 |
///////////////////////////// |
| 283 |
|
| 284 |
void MN_Init(void) |
| 285 |
{ |
| 286 |
MN_InitFonts(); |
| 287 |
|
| 288 |
if (heretic) |
| 289 |
{ |
| 290 |
SkullBaseLump = W_GetNumForName("M_SKL00"); |
| 291 |
} |
| 292 |
else |
| 293 |
{ |
| 294 |
SkullBaseLump = W_CheckNumForName2("FBULA0", ns_sprites); |
| 295 |
} |
| 296 |
|
| 297 |
// override doom menu parameters |
| 298 |
|
| 299 |
MainDef.x = 110; |
| 300 |
MainDef.y = 56; |
| 301 |
|
| 302 |
OptionsDef.x = 88; |
| 303 |
OptionsDef.y = 16; |
| 304 |
|
| 305 |
SoundDef.x = OptionsDef.x; |
| 306 |
SoundDef.y = OptionsDef.y; |
| 307 |
|
| 308 |
LoadDef.x = 70; |
| 309 |
LoadDef.y = 30; |
| 310 |
LoadDef.numitems = g_menu_save_page_size; |
| 311 |
|
| 312 |
SaveDef.x = 70; |
| 313 |
SaveDef.y = 30; |
| 314 |
SaveDef.numitems = g_menu_save_page_size; |
| 315 |
|
| 316 |
if (heretic) |
| 317 |
{ |
| 318 |
EpiDef.x = 80; |
| 319 |
EpiDef.y = 50; |
| 320 |
|
| 321 |
SkillDef.x = 38; |
| 322 |
SkillDef.y = 30; |
| 323 |
|
| 324 |
if (gamemode == retail) |
| 325 |
{ |
| 326 |
EpiDef.y -= ITEM_HEIGHT; |
| 327 |
} |
| 328 |
} |
| 329 |
else |
| 330 |
{ |
| 331 |
EpiDef.x = 66; |
| 332 |
EpiDef.y = 66; |
| 333 |
|
| 334 |
SkillDef.x = 120; |
| 335 |
SkillDef.y = 44; |
| 336 |
} |
| 337 |
|
| 338 |
SoundMenu[0].alttext = "SFX VOLUME"; |
| 339 |
SoundMenu[2].alttext = "MUSIC VOLUME"; |
| 340 |
|
| 341 |
// Use exclusive Raven MainMenu. |
| 342 |
MainDef.menuitems = RavenMainMenu; |
| 343 |
MainDef.numitems = rmain_end; |
| 344 |
SaveDef.prevMenu = &SaveLoadDef; |
| 345 |
LoadDef.prevMenu = &SaveLoadDef; |
| 346 |
|
| 347 |
// remove "ORDER" screen if not shareware |
| 348 |
if (gamemode != shareware) |
| 349 |
{ |
| 350 |
InfoDef1.routine = MN_DrawInfoHelp1; |
| 351 |
InfoMenu1[0].routine = MN_Info3; |
| 352 |
InfoDef2.prevMenu = &MainDef; |
| 353 |
} |
| 354 |
} |
| 355 |
|
| 356 |
void MN_UpdateClass(int choice) |
| 357 |
{ |
| 358 |
PlayerClass[consoleplayer] = choice + 1; |
| 359 |
|
| 360 |
switch (PlayerClass[consoleplayer]) |
| 361 |
{ |
| 362 |
case PCLASS_FIGHTER: |
| 363 |
SkillDef.x = 120; |
| 364 |
SkillDef.menuitems[0].alttext = hexen_skill_fighter[0]; |
| 365 |
SkillDef.menuitems[1].alttext = hexen_skill_fighter[1]; |
| 366 |
SkillDef.menuitems[2].alttext = hexen_skill_fighter[2]; |
| 367 |
SkillDef.menuitems[3].alttext = hexen_skill_fighter[3]; |
| 368 |
SkillDef.menuitems[4].alttext = hexen_skill_fighter[4]; |
| 369 |
break; |
| 370 |
case PCLASS_CLERIC: |
| 371 |
SkillDef.x = 116; |
| 372 |
SkillDef.menuitems[0].alttext = hexen_skill_cleric[0]; |
| 373 |
SkillDef.menuitems[1].alttext = hexen_skill_cleric[1]; |
| 374 |
SkillDef.menuitems[2].alttext = hexen_skill_cleric[2]; |
| 375 |
SkillDef.menuitems[3].alttext = hexen_skill_cleric[3]; |
| 376 |
SkillDef.menuitems[4].alttext = hexen_skill_cleric[4]; |
| 377 |
break; |
| 378 |
case PCLASS_MAGE: |
| 379 |
SkillDef.x = 112; |
| 380 |
SkillDef.menuitems[0].alttext = hexen_skill_mage[0]; |
| 381 |
SkillDef.menuitems[1].alttext = hexen_skill_mage[1]; |
| 382 |
SkillDef.menuitems[2].alttext = hexen_skill_mage[2]; |
| 383 |
SkillDef.menuitems[3].alttext = hexen_skill_mage[3]; |
| 384 |
SkillDef.menuitems[4].alttext = hexen_skill_mage[4]; |
| 385 |
break; |
| 386 |
default: |
| 387 |
break; |
| 388 |
} |
| 389 |
} |
| 390 |
|
| 391 |
void MN_Ticker(void) |
| 392 |
{ |
| 393 |
if (!menuactive) |
| 394 |
{ |
| 395 |
return; |
| 396 |
} |
| 397 |
MenuTime++; |
| 398 |
} |
| 399 |
|
| 400 |
extern menu_t* currentMenu; |
| 401 |
extern short itemOn; |
| 402 |
|
| 403 |
void MN_DrawMessage(const char* messageString) |
| 404 |
{ |
| 405 |
char *msg; |
| 406 |
char *p; |
| 407 |
int y; |
| 408 |
|
| 409 |
msg = Z_Strdup(messageString); |
| 410 |
p = msg; |
| 411 |
y = 100 - MN_TextAHeight(msg) / 2; |
| 412 |
|
| 413 |
while (*p) |
| 414 |
{ |
| 415 |
char *text; |
| 416 |
char c; |
| 417 |
|
| 418 |
text = p; |
| 419 |
while ((c = *p) && *p != '\n') |
| 420 |
p++; |
| 421 |
*p = 0; |
| 422 |
|
| 423 |
MN_DrTextA(text, 160 - MN_TextAWidth(text) / 2, y); |
| 424 |
y += R_NumPatchHeight(FontABaseLump); |
| 425 |
|
| 426 |
if ((*p = c)) |
| 427 |
p++; |
| 428 |
} |
| 429 |
Z_Free(msg); |
| 430 |
} |
| 431 |
|
| 432 |
void MN_Drawer(void) |
| 433 |
{ |
| 434 |
int i; |
| 435 |
int x; |
| 436 |
int y; |
| 437 |
int max; |
| 438 |
const char* selName; |
| 439 |
|
| 440 |
x = currentMenu->x; |
| 441 |
y = currentMenu->y; |
| 442 |
max = currentMenu->numitems; |
| 443 |
|
| 444 |
for (i = 0; i < max; i++) |
| 445 |
{ |
| 446 |
const char *text = currentMenu->menuitems[i].alttext; |
| 447 |
if (text) |
| 448 |
MN_DrTextB(text, x, y); |
| 449 |
y += ITEM_HEIGHT; |
| 450 |
} |
| 451 |
|
| 452 |
// Don't draw selector on INFO screens for Heretic / Hexen |
| 453 |
if (currentMenu == &InfoDef1 || currentMenu == &InfoDef2 || |
| 454 |
currentMenu == &InfoDef3 || currentMenu == &InfoDef4 || |
| 455 |
currentMenu == &ExtHelpDef) |
| 456 |
return; |
| 457 |
|
| 458 |
if (max) |
| 459 |
{ |
| 460 |
y = currentMenu->y + (itemOn * ITEM_HEIGHT) + SELECTOR_YOFFSET; |
| 461 |
selName = (MenuTime & 16 ? "M_SLCTR1" : "M_SLCTR2"); |
| 462 |
V_DrawNamePatch(x + SELECTOR_XOFFSET, y, 0, selName, CR_DEFAULT, VPT_STRETCH); |
| 463 |
} |
| 464 |
// MenuItem_t *item; |
| 465 |
// const char *message; |
| 466 |
// const char *selName; |
| 467 |
// |
| 468 |
// if (MenuActive == false) |
| 469 |
// { |
| 470 |
// if (askforquit) |
| 471 |
// { |
| 472 |
// message = QuitEndMsg[typeofask - 1]; |
| 473 |
// |
| 474 |
// MN_DrTextA(message, 160 - MN_TextAWidth(message) / 2, 80); |
| 475 |
// if (typeofask == 3) |
| 476 |
// { |
| 477 |
// MN_DrTextA(SlotText[quicksave - 1], 160 - |
| 478 |
// MN_TextAWidth(SlotText[quicksave - 1]) / 2, 90); |
| 479 |
// MN_DrTextA("?", 160 + |
| 480 |
// MN_TextAWidth(SlotText[quicksave - 1]) / 2, 90); |
| 481 |
// } |
| 482 |
// if (typeofask == 4) |
| 483 |
// { |
| 484 |
// MN_DrTextA(SlotText[quickload - 1], 160 - |
| 485 |
// MN_TextAWidth(SlotText[quickload - 1]) / 2, 90); |
| 486 |
// MN_DrTextA("?", 160 + |
| 487 |
// MN_TextAWidth(SlotText[quickload - 1]) / 2, 90); |
| 488 |
// } |
| 489 |
// } |
| 490 |
// return; |
| 491 |
// } |
| 492 |
// else |
| 493 |
// { |
| 494 |
// if (InfoType) |
| 495 |
// { |
| 496 |
// MN_DrawInfo(); |
| 497 |
// return; |
| 498 |
// } |
| 499 |
// if (screenblocks < 10) |
| 500 |
// { |
| 501 |
// BorderNeedRefresh = true; |
| 502 |
// } |
| 503 |
// if (CurrentMenu->drawFunc != NULL) |
| 504 |
// { |
| 505 |
// CurrentMenu->drawFunc(); |
| 506 |
// } |
| 507 |
// x = CurrentMenu->x; |
| 508 |
// y = CurrentMenu->y; |
| 509 |
// item = CurrentMenu->items; |
| 510 |
// for (i = 0; i < CurrentMenu->itemCount; i++) |
| 511 |
// { |
| 512 |
// if (item->type != ITT_EMPTY && item->text) |
| 513 |
// { |
| 514 |
// MN_DrTextB(item->text, x, y); |
| 515 |
// } |
| 516 |
// |
| 517 |
// y += ITEM_HEIGHT; |
| 518 |
// item++; |
| 519 |
// } |
| 520 |
// |
| 521 |
// y = CurrentMenu->y + (CurrentItPos * ITEM_HEIGHT) + SELECTOR_YOFFSET; |
| 522 |
// selName = (MenuTime & 16 ? "M_SLCTR1" : "M_SLCTR2"); |
| 523 |
// V_DrawPatch(x + SELECTOR_XOFFSET, y, |
| 524 |
// W_LumpByName(selName)); |
| 525 |
// } |
| 526 |
} |
| 527 |
|
| 528 |
static void Hexen_MN_DrawMainMenu(void); |
| 529 |
|
| 530 |
void MN_DrawMainMenu(void) |
| 531 |
{ |
| 532 |
int frame; |
| 533 |
|
| 534 |
if (hexen) return Hexen_MN_DrawMainMenu(); |
| 535 |
|
| 536 |
frame = (MenuTime / 3) % 18; |
| 537 |
V_DrawNamePatch(88, 0, 0, "M_HTIC", CR_DEFAULT, VPT_STRETCH); |
| 538 |
V_DrawNumPatch(40, 10, 0, SkullBaseLump + (17 - frame), CR_DEFAULT, VPT_STRETCH); |
| 539 |
V_DrawNumPatch(232, 10, 0, SkullBaseLump + frame, CR_DEFAULT, VPT_STRETCH); |
| 540 |
} |
| 541 |
|
| 542 |
static void Hexen_MN_DrawMainMenu(void) |
| 543 |
{ |
| 544 |
int frame; |
| 545 |
|
| 546 |
frame = (MenuTime / 5) % 7; |
| 547 |
V_DrawNamePatch(88, 0, 0, "M_HTIC", CR_DEFAULT, VPT_STRETCH); |
| 548 |
V_DrawNumPatch(37, 80, 0, SkullBaseLump + (frame + 2) % 7, CR_DEFAULT, VPT_STRETCH); |
| 549 |
V_DrawNumPatch(278, 80, 0, SkullBaseLump + frame, CR_DEFAULT, VPT_STRETCH); |
| 550 |
} |
| 551 |
|
| 552 |
// Class menu is in the episode slot for hexen |
| 553 |
void MN_DrawEpisode(void) |
| 554 |
{ |
| 555 |
pclass_t class; |
| 556 |
static const char *boxLumpName[3] = { |
| 557 |
"m_fbox", |
| 558 |
"m_cbox", |
| 559 |
"m_mbox" |
| 560 |
}; |
| 561 |
static const char *walkLumpName[3] = { |
| 562 |
"m_fwalk1", |
| 563 |
"m_cwalk1", |
| 564 |
"m_mwalk1" |
| 565 |
}; |
| 566 |
|
| 567 |
if (heretic) return; |
| 568 |
|
| 569 |
MN_DrTextB("CHOOSE CLASS:", 34, 24); |
| 570 |
class = (pclass_t) itemOn; |
| 571 |
V_DrawNamePatch(174, 8, 0, boxLumpName[class], CR_DEFAULT, VPT_STRETCH); |
| 572 |
V_DrawNumPatch(174 + 24, 8 + 12, 0, W_GetNumForName(walkLumpName[class]) + ((MenuTime >> 3) & 3), |
| 573 |
CR_DEFAULT, VPT_STRETCH); |
| 574 |
} |
| 575 |
|
| 576 |
void MN_DrawSkillMenu(void) |
| 577 |
{ |
| 578 |
if (heretic) return; |
| 579 |
|
| 580 |
MN_DrTextB("CHOOSE SKILL LEVEL:", 74, 16); |
| 581 |
} |
| 582 |
|
| 583 |
void MN_DrawOptions(void) |
| 584 |
{ |
| 585 |
} |
| 586 |
|
| 587 |
void MN_DrawSound(void) |
| 588 |
{ |
| 589 |
char num[4]; |
| 590 |
|
| 591 |
MN_DrawSlider(SoundDef.x - 8, SoundDef.y + ITEM_HEIGHT * SFX_VOL_INDEX, 16, 16, snd_SfxVolume); |
| 592 |
snprintf(num, sizeof(num), "%3d", snd_SfxVolume); |
| 593 |
MN_DrTextA(num, SoundDef.x + 130, SoundDef.y + ITEM_HEIGHT * SFX_VOL_INDEX + 3); |
| 594 |
|
| 595 |
MN_DrawSlider(SoundDef.x - 8, SoundDef.y + ITEM_HEIGHT * MUS_VOL_INDEX, 16, 16, snd_MusicVolume); |
| 596 |
snprintf(num, sizeof(num), "%3d", snd_MusicVolume); |
| 597 |
MN_DrTextA(num, SoundDef.x + 130, SoundDef.y + ITEM_HEIGHT * MUS_VOL_INDEX + 3); |
| 598 |
} |
| 599 |
|
| 600 |
extern char savegamestrings[10][SAVESTRINGSIZE]; |
| 601 |
|
| 602 |
static void MN_DrawFileSlots(int x, int y) |
| 603 |
{ |
| 604 |
int i; |
| 605 |
extern const char *saves_pages[]; |
| 606 |
|
| 607 |
for (i = 0; i < g_menu_save_page_size; i++) |
| 608 |
{ |
| 609 |
V_DrawNamePatch(x, y, 0, "M_FSLOT", CR_DEFAULT, VPT_STRETCH); |
| 610 |
MN_DrTextA(savegamestrings[i], x + 5, y + 5); |
| 611 |
y += ITEM_HEIGHT; |
| 612 |
} |
| 613 |
|
| 614 |
M_DrawTabs(saves_pages, 5, 135); |
| 615 |
} |
| 616 |
|
| 617 |
void MN_DrawLoad(void) |
| 618 |
{ |
| 619 |
const char *title; |
| 620 |
|
| 621 |
title = "LOAD GAME"; |
| 622 |
|
| 623 |
MN_DrTextB(title, 160 - MN_TextBWidth(title) / 2, 10); |
| 624 |
MN_DrawFileSlots(LoadDef.x, LoadDef.y); |
| 625 |
|
| 626 |
if (delete_verify) |
| 627 |
M_DrawDelVerify(); |
| 628 |
} |
| 629 |
|
| 630 |
extern int saveStringEnter; |
| 631 |
extern int saveSlot; |
| 632 |
|
| 633 |
void MN_DrawSave(void) |
| 634 |
{ |
| 635 |
const char *title; |
| 636 |
|
| 637 |
title = "SAVE GAME"; |
| 638 |
|
| 639 |
MN_DrTextB(title, 160 - MN_TextBWidth(title) / 2, 10); |
| 640 |
MN_DrawFileSlots(SaveDef.x, SaveDef.y); |
| 641 |
|
| 642 |
if (saveStringEnter) |
| 643 |
{ |
| 644 |
int i; |
| 645 |
|
| 646 |
i = MN_TextAWidth(savegamestrings[saveSlot]); |
| 647 |
MN_DrTextA("[", SaveDef.x + 5 + i, SaveDef.y + 5 + saveSlot * ITEM_HEIGHT); // [ is _ in font A |
| 648 |
} |
| 649 |
|
| 650 |
if (delete_verify) |
| 651 |
M_DrawDelVerify(); |
| 652 |
} |
| 653 |
|
| 654 |
void MN_DrawPause(void) |
| 655 |
{ |
| 656 |
const char *title; |
| 657 |
|
| 658 |
title = "PAUSE"; |
| 659 |
MN_DrTextB(title, 160 - MN_TextBWidth(title) / 2, 10); |
| 660 |
} |
| 661 |
|
| 662 |
void MN_DrTextA(const char *text, int x, int y) |
| 663 |
{ |
| 664 |
char c; |
| 665 |
int lump; |
| 666 |
|
| 667 |
while ((c = *text++) != 0) |
| 668 |
{ |
| 669 |
c = toupper(c); |
| 670 |
if (c < 33) |
| 671 |
{ |
| 672 |
x += 5; |
| 673 |
} |
| 674 |
else |
| 675 |
{ |
| 676 |
lump = MN_SafeFontALump(c - 33); |
| 677 |
V_DrawNumPatch(x, y, 0, lump, CR_DEFAULT, VPT_STRETCH); |
| 678 |
x += R_NumPatchWidth(lump) - 1; |
| 679 |
} |
| 680 |
} |
| 681 |
} |
| 682 |
|
| 683 |
int MN_TextAHeight(const char *text) |
| 684 |
{ |
| 685 |
int i, line_height, total_height; |
| 686 |
|
| 687 |
line_height = R_NumPatchHeight(FontABaseLump); |
| 688 |
total_height = line_height; |
| 689 |
|
| 690 |
for (i = 0; text[i]; i++) |
| 691 |
if (text[i] == '\n') |
| 692 |
total_height += line_height; |
| 693 |
return total_height; |
| 694 |
} |
| 695 |
|
| 696 |
int MN_TextAWidth(const char *text) |
| 697 |
{ |
| 698 |
char c; |
| 699 |
int width; |
| 700 |
int lump; |
| 701 |
|
| 702 |
width = 0; |
| 703 |
while ((c = *text++) != 0) |
| 704 |
{ |
| 705 |
c = toupper(c); |
| 706 |
if (c < 33) |
| 707 |
{ |
| 708 |
width += 5; |
| 709 |
} |
| 710 |
else |
| 711 |
{ |
| 712 |
lump = MN_SafeFontALump(c - 33); |
| 713 |
width += R_NumPatchWidth(lump) - 1; |
| 714 |
} |
| 715 |
} |
| 716 |
return (width); |
| 717 |
} |
| 718 |
|
| 719 |
void MN_DrTextB(const char *text, int x, int y) |
| 720 |
{ |
| 721 |
char c; |
| 722 |
int lump; |
| 723 |
|
| 724 |
while ((c = *text++) != 0) |
| 725 |
{ |
| 726 |
c = toupper(c); |
| 727 |
if (c < 33) |
| 728 |
{ |
| 729 |
x += 8; |
| 730 |
} |
| 731 |
else |
| 732 |
{ |
| 733 |
lump = FontBBaseLump + c - 33; |
| 734 |
V_DrawNumPatch(x, y, 0, lump, CR_DEFAULT, VPT_STRETCH); |
| 735 |
x += R_NumPatchWidth(lump) - 1; |
| 736 |
} |
| 737 |
} |
| 738 |
} |
| 739 |
|
| 740 |
int MN_TextBWidth(const char *text) |
| 741 |
{ |
| 742 |
char c; |
| 743 |
int width; |
| 744 |
int lump; |
| 745 |
|
| 746 |
width = 0; |
| 747 |
while ((c = *text++) != 0) |
| 748 |
{ |
| 749 |
c = toupper(c); |
| 750 |
if (c < 33) |
| 751 |
{ |
| 752 |
width += 5; |
| 753 |
} |
| 754 |
else |
| 755 |
{ |
| 756 |
lump = FontBBaseLump + c - 33; |
| 757 |
width += R_NumPatchWidth(lump) - 1; |
| 758 |
} |
| 759 |
} |
| 760 |
return (width); |
| 761 |
} |
| 762 |
|
| 763 |
void MN_DrawTitle(int y, const char *text, int cm) |
| 764 |
{ |
| 765 |
MN_DrTextB(text, 160 - (MN_TextBWidth(text) / 2), y); |
| 766 |
} |
| 767 |
|
| 768 |
#define SLIDER_LIMIT 200 |
| 769 |
#define SLIDER_WIDTH (SLIDER_LIMIT - 64) |
| 770 |
#define SLIDER_PATCH_COUNT (SLIDER_WIDTH / 8) |
| 771 |
|
| 772 |
void MN_DrawSlider(int x, int y, int width, int range, int slot) |
| 773 |
{ |
| 774 |
int xx; |
| 775 |
int i; |
| 776 |
int slot_offset; |
| 777 |
short slider_img = 0; |
| 778 |
|
| 779 |
width -= 4; |
| 780 |
|
| 781 |
xx = x - 12; |
| 782 |
V_DrawNamePatch(xx, y, 0, "M_SLDLT", CR_DEFAULT, VPT_STRETCH); |
| 783 |
xx += 32; |
| 784 |
for (i=0;i<width;i++) |
| 785 |
{ |
| 786 |
const char* name; |
| 787 |
name = (slider_img & 1 ? "M_SLDMD1" : "M_SLDMD2"); |
| 788 |
slider_img ^= 1; |
| 789 |
V_DrawNamePatch(xx, y, 0, name, CR_DEFAULT, VPT_STRETCH); |
| 790 |
|
| 791 |
xx += 8; |
| 792 |
} |
| 793 |
V_DrawNamePatch(xx, y, 0, "M_SLDRT", CR_DEFAULT, VPT_STRETCH); |
| 794 |
|
| 795 |
if (slot >= range) |
| 796 |
{ |
| 797 |
slot = range - 1; |
| 798 |
} |
| 799 |
|
| 800 |
width += 1; |
| 801 |
|
| 802 |
slot_offset = 8 * slot * width / range; |
| 803 |
slot_offset -= range / width; |
| 804 |
V_DrawNamePatch(x + 20 + slot_offset, y + 7, 0, "M_SLDKB", CR_DEFAULT, VPT_STRETCH); |
| 805 |
} |
| 806 |
|
| 807 |
// hexen |
| 808 |
|
| 809 |
void MN_DrTextAYellow(const char *text, int x, int y) |
| 810 |
{ |
| 811 |
char c; |
| 812 |
int lump; |
| 813 |
|
| 814 |
while ((c = *text++) != 0) |
| 815 |
{ |
| 816 |
c = toupper(c); |
| 817 |
if (c < 33) |
| 818 |
{ |
| 819 |
x += 5; |
| 820 |
} |
| 821 |
else |
| 822 |
{ |
| 823 |
lump = FontAYellowBaseLump + c - 33; |
| 824 |
V_DrawNumPatch(x, y, 0, lump, CR_DEFAULT, VPT_STRETCH); |
| 825 |
x += R_NumPatchWidth(lump) - 1; |
| 826 |
} |
| 827 |
} |
| 828 |
} |