From 2516f250b46d8f1c803ab9adebc23f87d38fa90b Mon Sep 17 00:00:00 2001 From: fgsfds Date: Fri, 11 Oct 2019 01:33:17 +0300 Subject: [PATCH] add level select to 2 player menu --- src/game.c | 2 +- src/menu.c | 49 +++++++++++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/game.c b/src/game.c index 012d842..2e85b78 100644 --- a/src/game.c +++ b/src/game.c @@ -72,7 +72,7 @@ extern map_block_t blk; byte cheat = 0; -byte _2pl = 0, g_dm = 0, g_st = GS_TITLE, g_exit = 0, g_map = 1, _warp = 0, g_music[8] = "MENU", g_loaded = 0; +byte _2pl = 0, g_dm = 0, g_st = GS_TITLE, g_exit = 0, g_map = 1, _warp = 1, g_music[8] = "MENU", g_loaded = 0; byte _net = 0; int g_sttm = 1092; dword g_time; diff --git a/src/menu.c b/src/menu.c index b4c38c2..d55ee2d 100644 --- a/src/menu.c +++ b/src/menu.c @@ -38,6 +38,7 @@ #include "memcard.h" #define QSND_NUM 14 +#define LASTMAP 19 enum { HIT100, ARMOR, JUMP, WPNS, IMMORTAL, SPEED, OPEN, EXIT @@ -58,13 +59,16 @@ static byte * panimp = panim; #define PCOLORN 10 int p1color = 0, p2color = 5; +static char _warp_mapname[9] = "MAP01"; + enum { MENU, MSG }; enum { CANCEL, NEWGAME, LOADGAME, OPTIONS, ENDGAME, ENDGM, PLR1, PLR2, COOP, DM, VOLUME, GAMMA, PLCOLOR, PLCEND, MUSIC, - SVOLM, SVOLP, MVOLM, MVOLP, GAMMAM, GAMMAP, PL1CM, PL1CP, PL2CM, PL2CP + SVOLM, SVOLP, MVOLM, MVOLP, GAMMAM, GAMMAP, PL1CM, PL1CP, PL2CM, PL2CP, + MAPSELM, MAPSELP, }; #ifndef DEMO @@ -78,7 +82,7 @@ static char * main_txt[] = { }, * ngplr_txt[] = { "ONE PLAYER", "TWO PLAYERS" }, * ngdm_txt[] = { - "COOPERATIVE", "DEATHMATCH" + "MAP:", "COOPERATIVE", "DEATHMATCH" }, * vol_txt[] = { "SOUND", "MUSIC" }, * plcolor_txt[] = { @@ -92,7 +96,7 @@ static byte main_typ[] = { }, ngplr_typ[] = { PLR1, PLR2 }, ngdm_typ[] = { - COOP, DM + MAPSELM, COOP, DM }, opt_typ[] = { ENDGAME, VOLUME, GAMMA, MUSIC }, endgm_typ[] = { @@ -112,7 +116,7 @@ static menu_t main_mnu = { }, ngplr_mnu = { MENU, 2, 0, 90, "NEW GAME", ngplr_txt, ngplr_typ }, ngdm_mnu = { - MENU, 2, 0, 90, "GAME TYPE", ngdm_txt, ngdm_typ + MENU, 3, 0, 90, "GAME TYPE", ngdm_txt, ngdm_typ }, vol_mnu = { MENU, 2, 0, 40, "VOLUME", vol_txt, vol_typ }, plcolor_mnu = { @@ -291,7 +295,7 @@ void GM_command(int c) { case PLCEND: _2pl = ngplr_mnu.cur; g_dm = ngdm_mnu.cur; - g_map = (_warp) ? _warp : 1; + g_map = (_2pl && _warp > 1) ? _warp : 1; g_loaded = 0; PL_reset(); if (_2pl) { @@ -366,6 +370,22 @@ void GM_command(int c) { p2color = 0; break; + case MAPSELM: + if (_warp > 1) + --_warp; + else + _warp = LASTMAP; + sprintf(_warp_mapname, "MAP%02d", _warp); + break; + + case MAPSELP: + if (_warp < LASTMAP) + _warp++; + else + _warp = 1; + sprintf(_warp_mapname, "MAP%02d", _warp); + break; + case SVOLM: S_volume(snd_vol - 8); break; @@ -530,20 +550,6 @@ int GM_act(void) { GM_command(mnu->t[1]); break; - case K_P1_L2: - if (!mnu) - break; - Z_sound(msnd4, 128); - if (_warp) --_warp; else _warp = 19; - break; - - case K_P1_R2: - if (!mnu) - break; - Z_sound(msnd4, 128); - if (_warp < 19) ++_warp; - break; - /* case SDLK_F1: // case 0x3B: if (shot_vga) { @@ -596,6 +602,7 @@ void GM_init(void) { int GM_draw(void) { int i, j, k, y; + char mapname[8]; ++gm_tm; V_setrect(0, SCRW, 0, SCRH); // V_setrect(0,320,0,200); @@ -611,10 +618,12 @@ int GM_draw(void) { Z_gotoxy(mnu->x, y - 10); Z_printbf(mnu->ttl); for (i = 0; i < mnu->n; ++i) { - Z_gotoxy(mnu->x + ((mnu->t[i] >= SVOLM) ? ((mnu->t[i] >= PL1CM) ? 50 : 152) : 0), y + i * 16 + 20); + Z_gotoxy(mnu->x + ((mnu->t[i] >= SVOLM) ? ((mnu->t[i] >= PL1CM) ? (mnu->t[i] >= MAPSELM ? 0 : 50) : 152) : 0), y + i * 16 + 20); Z_printbf(mnu->m[i]); if (mnu->t[i] == MUSIC) { Z_printbf(" '%.8s'", g_music); + } else if (mnu->t[i] >= MAPSELM) { + Z_printbf(" %.8s", _warp_mapname); } else if (mnu->t[i] >= PL1CM) { V_manspr(mnu->x + ((mnu->t[i] == PL1CM) ? 15 : 35), y + i * 16 + 20 + 14, PL_getspr(*panimp, 0), -- 2.11.4.GIT