From 11e9b8f4cef30441f47f09281f3d1a3dedb104d0 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sat, 31 May 2014 12:26:41 +0000 Subject: [PATCH] Ball-busting new menus. Still WIP. Mouse/touch/pointer support is yet to come. #SOON. Exposure to scripting is a LONG way off. Months. The spec and data structure needs time for comment and revision. The eventual scripting access will be Lua-only. git-svn-id: https://svn.eduke32.com/eduke32@4496 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/demo.c | 3 +- polymer/eduke32/source/game.c | 30 +- polymer/eduke32/source/game.h | 8 +- polymer/eduke32/source/gamevars.c | 1 + polymer/eduke32/source/global.h | 1 - polymer/eduke32/source/input.c | 98 +- polymer/eduke32/source/input.h | 14 +- polymer/eduke32/source/menus.c | 9256 +++++++++++++---------------- polymer/eduke32/source/menus.h | 340 +- polymer/eduke32/source/net.c | 28 +- polymer/eduke32/source/sounds.h | 2 +- 11 files changed, 4668 insertions(+), 5113 deletions(-) diff --git a/polymer/eduke32/source/demo.c b/polymer/eduke32/source/demo.c index b9db5888c..fca99128c 100644 --- a/polymer/eduke32/source/demo.c +++ b/polymer/eduke32/source/demo.c @@ -935,7 +935,7 @@ nextdemo_nomenu: if (ud.recstat != 2) M_DisplayMenus(); - if ((g_netServer || ud.multimode > 1) && !M_IsTextInput(g_currentMenu)) + if ((g_netServer || ud.multimode > 1) && !M_IsTextInput(m_currentMenu)) { ControlInfo noshareinfo; CONTROL_GetInput(&noshareinfo); @@ -945,7 +945,6 @@ nextdemo_nomenu: CONTROL_ClearButton(gamefunc_SendMessage); g_player[myconnectindex].ps->gm = MODE_TYPE; typebuf[0] = 0; - inputloc = 0; } } } diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index d850cee35..8dcc98c41 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -1240,15 +1240,10 @@ int32_t G_GameTextLen(int32_t x,const char *t) return x; } -int32_t mpgametext(int32_t y,const char *t,int32_t s,int32_t dabits) -{ - return G_PrintGameText(4,STARTALPHANUM, 5,y,t,s,0,dabits,0, 0, xdim-1, ydim-1, 65536); -} - // minitext_yofs: in hud_scale-independent, (<<16)-scaled, 0-200-normalized y coords, // (sb&ROTATESPRITE_MAX) only. static int32_t minitext_yofs = 0; -static int32_t minitext_lowercase = 0; +int32_t minitext_lowercase = 0; int32_t minitext_(int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t sb) { vec2_t dim; @@ -1288,6 +1283,15 @@ int32_t minitext_(int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t return x; } +void shadowminitext(int32_t x,int32_t y,const char *t,int32_t p,int32_t sb) +{ + int32_t f = 0; + + if (!minitext_lowercase) + f |= TEXT_UPPERCASE; + + G_ScreenTextShadow(1, 1, MINIFONT, x, y, 65536, 0, 0, t, 0, p, sb, 0, 4, 8, 1, 0, f, 0, 0, xdim-1, ydim-1); +} void creditsminitext(int32_t x,int32_t y,const char *t,int32_t p,int32_t sb) { int32_t f = TEXT_XCENTER; @@ -8847,7 +8851,6 @@ void G_HandleLocalKeys(void) CONTROL_ClearButton(gamefunc_SendMessage); g_player[myconnectindex].ps->gm |= MODE_TYPE; typebuf[0] = 0; - inputloc = 0; } if (KB_UnBoundKeyPressed(sc_F1)/* || (ud.show_help && I_AdvanceTrigger())*/) @@ -8975,13 +8978,7 @@ FAKE_F3: g_screenCapture = 0; if (g_lastSaveSlot >= 0) - { - /* inputloc = Bstrlen(&ud.savegame[g_lastSaveSlot][0]); - g_currentMenu = MENU_SAVETYPING+g_lastSaveSlot; - probey = g_lastSaveSlot; */ - G_SavePlayerMaybeMulti(g_lastSaveSlot); - } } if (KB_UnBoundKeyPressed(sc_F7)) @@ -9046,7 +9043,7 @@ FAKE_F3: if (KB_UnBoundKeyPressed(sc_F10)) { KB_ClearKeyDown(sc_F10); - M_ChangeMenu(MENU_QUIT); + M_ChangeMenu(MENU_QUIT_INGAME); FX_StopAllSounds(); S_ClearSoundLocks(); g_player[myconnectindex].ps->gm |= MODE_MENU; @@ -11064,7 +11061,6 @@ static int32_t G_EndOfLevel(void) G_DoOrderScreen(); g_player[myconnectindex].ps->gm = MODE_MENU; M_ChangeMenu(MENU_MAIN); - probey = 0; return 2; } else @@ -11820,6 +11816,8 @@ int32_t app_main(int32_t argc, const char **argv) } // loadtmb(); + M_Init(); + if (ud.warp_on > 1 && (!g_netServer && ud.multimode < 2)) { clearview(0L); @@ -11841,6 +11839,8 @@ int32_t app_main(int32_t argc, const char **argv) MAIN_LOOP_RESTART: + M_ChangeMenu(MENU_MAIN); + if (g_networkMode != NET_DEDICATED_SERVER) { G_GetCrosshairColor(); diff --git a/polymer/eduke32/source/game.h b/polymer/eduke32/source/game.h index 594fdbabd..1c0101a11 100644 --- a/polymer/eduke32/source/game.h +++ b/polymer/eduke32/source/game.h @@ -261,7 +261,6 @@ extern const char *defaultrtsfilename[GAMECOUNT]; extern const char *G_DefaultRtsFile(void); extern char g_modDir[BMAX_PATH]; -extern char inputloc; #ifdef LEGACY_ROR extern char ror_protectedsectors[MAXSECTORS]; #endif @@ -320,9 +319,12 @@ int32_t G_GameTextLen(int32_t x,const char *t); int32_t G_PrintGameText(int32_t hack,int32_t tile,int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t o,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z); int32_t GetTime(void); int32_t kopen4loadfrommod(const char *filename,char searchfirst); +extern int32_t minitext_lowercase; int32_t minitext_(int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t sb); +void shadowminitext(int32_t x,int32_t y,const char *t,int32_t p,int32_t sb); void creditsminitext(int32_t x,int32_t y,const char *t,int32_t p,int32_t sb); int32_t mpgametext(int32_t y,const char *t,int32_t s,int32_t dabits); + int32_t startwin_run(void); #ifdef YAX_ENABLE @@ -421,11 +423,11 @@ extern char forcegl; #define gametextscaled(x,y,t,s,dabits) G_PrintGameText(1,STARTALPHANUM, x,y,t,s,0,dabits,0, 0, xdim-1, ydim-1, 65536) #define gametextpal(x,y,t,s,p) G_PrintGameText(0,STARTALPHANUM, x,y,t,s,p,26,0, 0, xdim-1, ydim-1, 65536) #define gametextpalbits(x,y,t,s,p,dabits) G_PrintGameText(0,STARTALPHANUM, x,y,t,s,p,dabits,0, 0, xdim-1, ydim-1, 65536) +#define mpgametext(y, t, s, dabits) G_PrintGameText(4,STARTALPHANUM, 5,y,t,s,0,dabits,0, 0, xdim-1, ydim-1, 65536); + #define A_CheckSpriteFlags(iActor, iType) (((g_tile[sprite[iActor].picnum].flags^actor[iActor].flags) & iType) != 0) // (unsigned)iPicnum check: AMC TC Rusty Nails, bayonet MG alt. fire, iPicnum == -1 (via aplWeaponShoots) #define A_CheckSpriteTileFlags(iPicnum, iType) (((unsigned)iPicnum < MAXTILES) && (g_tile[iPicnum].flags & iType) != 0) -#define G_EnterText(x, y, t, dalen, c) _EnterText(0,x,y,t,dalen,c) -#define Net_EnterText(x, y, t, dalen, c) _EnterText(1,x,y,t,dalen,c) #define S_StopSound(num) S_StopEnvSound(num, -1) extern int32_t G_StartRTS(int32_t i, int localp); diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index 0385eebfe..7dfcc0bb1 100644 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "gamedef.h" #include "osd.h" #include "savegame.h" +#include "menus.h" #define _gamevars_c_ diff --git a/polymer/eduke32/source/global.h b/polymer/eduke32/source/global.h index c6fd2910a..8f7a3a850 100644 --- a/polymer/eduke32/source/global.h +++ b/polymer/eduke32/source/global.h @@ -89,7 +89,6 @@ G_EXTERN int32_t animategoal[MAXANIMATES],animatevel[MAXANIMATES],g_animateCount G_EXTERN int32_t cloudtotalclock; G_EXTERN int32_t fricxv,fricyv; G_EXTERN int32_t g_currentFrameRate; -G_EXTERN int32_t g_currentMenu; G_EXTERN int32_t g_damageCameras,g_freezerSelfDamage; G_EXTERN int32_t g_doQuickSave; G_EXTERN uint16_t g_earthquakeTime; diff --git a/polymer/eduke32/source/input.c b/polymer/eduke32/source/input.c index c4a32819d..03f149770 100644 --- a/polymer/eduke32/source/input.c +++ b/polymer/eduke32/source/input.c @@ -179,7 +179,6 @@ int32_t I_EscapeTriggerClear(void) } - int32_t I_PanelUp(void) { return ( @@ -248,15 +247,56 @@ int32_t I_PanelDownClear(void) +int32_t I_SliderLeft(void) +{ + return ( + KB_KeyPressed(sc_LeftArrow) || + KB_KeyPressed(sc_kpad_4) || + ((MOUSE_GetButtons()&LEFT_MOUSE) && (MOUSE_GetButtons()&WHEELUP_MOUSE)) || + BUTTON(gamefunc_Turn_Left) || + BUTTON(gamefunc_Strafe_Left) || + (JOYSTICK_GetHat(0)&HAT_LEFT) + ); +} +int32_t I_SliderLeftClear(void) +{ + KB_ClearKeyDown(sc_LeftArrow); + KB_ClearKeyDown(sc_kpad_4); + CONTROL_ClearButton(gamefunc_Turn_Left); + CONTROL_ClearButton(gamefunc_Strafe_Left); + JOYSTICK_ClearHat(0); + return ( + MOUSE_ClearButton(WHEELUP_MOUSE) + ); +} +int32_t I_SliderRight(void) +{ + return ( + KB_KeyPressed(sc_RightArrow) || + KB_KeyPressed(sc_kpad_6) || + ((MOUSE_GetButtons()&LEFT_MOUSE) && (MOUSE_GetButtons()&WHEELDOWN_MOUSE)) || + BUTTON(gamefunc_Turn_Right) || + BUTTON(gamefunc_Strafe_Right) || + (JOYSTICK_GetHat(0)&HAT_RIGHT) + ); +} +int32_t I_SliderRightClear(void) +{ + KB_ClearKeyDown(sc_RightArrow); + KB_ClearKeyDown(sc_kpad_6); + CONTROL_ClearButton(gamefunc_Turn_Right); + CONTROL_ClearButton(gamefunc_Strafe_Right); + JOYSTICK_ClearHat(0); + return ( + MOUSE_ClearButton(WHEELDOWN_MOUSE) + ); +} -char inputloc = 0; - -int32_t _EnterText(int32_t small,int32_t x,int32_t y,char *t,int32_t dalen,int32_t c) +int32_t I_EnterText(char *t, int32_t maxlength, int32_t flags) { char ch; - int32_t i; - const int32_t startx = x; + int32_t inputloc = Bstrlen(typebuf); while ((ch = KB_GetCh()) != 0) { @@ -273,16 +313,16 @@ int32_t _EnterText(int32_t small,int32_t x,int32_t y,char *t,int32_t dalen,int32 if (ch == asc_Enter) { I_AdvanceTriggerClear(); - return (1); + return 1; } else if (ch == asc_Escape) { I_ReturnTriggerClear(); - return (-1); + return -1; } - else if (ch >= 32 && inputloc < dalen && ch < 127) + else if (ch >= 32 && inputloc < maxlength && ch < 127) { - if (c != 997 || (ch >= '0' && ch <= '9')) + if (!(flags & INPUT_NUMERIC) || (ch >= '0' && ch <= '9')) { // JBF 20040508: so we can have numeric only if we want *(t+inputloc) = ch; @@ -293,39 +333,13 @@ int32_t _EnterText(int32_t small,int32_t x,int32_t y,char *t,int32_t dalen,int32 } } - if (c == 999) return(0); - if (c == 998) + // All gamefuncs (and *only* _gamefuncs_) in I_ReturnTriggerClear() should be replicated here. + CONTROL_ClearButton(gamefunc_Crouch); + if (I_ReturnTrigger()) { - char b[91],ii; - for (ii=0; iigm&MODE_TYPE) - x = mpgametext(y,b,c,2+8+16); - else x = gametext(x,y,b,c,2+8+16); - } - else - { - if (g_player[myconnectindex].ps->gm&MODE_TYPE) - x = mpgametext(y,t,c,2+8+16); - else x = gametext(x,y,t,c,2+8+16); - } - c = 4-(sintable[(totalclock<<4)&2047]>>11); - - i = G_GameTextLen(USERQUOTE_LEFTOFFSET,OSD_StripColors(tempbuf,t)); - while (i > (ud.config.ScreenWidth - USERQUOTE_RIGHTOFFSET)) - { - i -= (ud.config.ScreenWidth - USERQUOTE_RIGHTOFFSET); - if (small&1) - y += textsc(6); - y += 8; + I_ReturnTriggerClear(); + return -1; } - if (startx == 160) // gametext center - x = startx + ((x - startx)>>1); - - if (small&1) - rotatesprite_fs(textsc(x)<<16,(y<<16),32768,0,SPINNINGNUKEICON+((totalclock>>3)%7),c,0,(8|16)); - else rotatesprite_fs((x+8)<<16,(y+4)<<16,32768,0,SPINNINGNUKEICON+((totalclock>>3)%7),c,0,2+8); - return (0); + return 0; } diff --git a/polymer/eduke32/source/input.h b/polymer/eduke32/source/input.h index 7d0c4d5ad..b9846f881 100644 --- a/polymer/eduke32/source/input.h +++ b/polymer/eduke32/source/input.h @@ -54,7 +54,17 @@ extern int32_t I_PanelUpClear(void); extern int32_t I_PanelDown(void); extern int32_t I_PanelDownClear(void); -extern char inputloc; -extern int32_t _EnterText(int32_t small,int32_t x,int32_t y,char *t,int32_t dalen,int32_t c); +extern int32_t I_SliderLeft(void); +extern int32_t I_SliderLeftClear(void); + +extern int32_t I_SliderRight(void); +extern int32_t I_SliderRightClear(void); + + +enum EnterTextFlags_t { + INPUT_NUMERIC = 0x00000001, +}; + +extern int32_t I_EnterText(char *t, int32_t maxlength, int32_t flags); #endif diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index c669f9753..0e90f738c 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -20,8 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ //------------------------------------------------------------------------- -// FIXME: this file is the single worst fucking mess in all of EDuke32 - #include "duke3d.h" #include "net.h" #include "player.h" @@ -42,50 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -extern char inputloc; int32_t g_skillSoundVoice = -1; -int32_t probey=0; // the row number on which the menu cursor is positioned -static int32_t lastsavehead=0,last_menu_pos=0,last_menu,sh,onbar,buttonstat; -static int32_t last_main,last_main_ingame,last_episode,last_options,last_load = 0; - -// ugly hack to get around inadequacies of calling CONTROL_GetInput() in M_Probe() and still have gamefuncs function throughout menus -// A previous solution was to add CONTROL_GetInput(&minfo); in M_DisplayMenus but that hurt mouse aiming -#define AdvanceTrigger 0x01 -#define ReturnTrigger 0x02 -#define EscapeTrigger 0x04 -#define ProbeTriggers(x) (menutriggers&x) -#define ProbeTriggersClear(x) (menutriggers&=~x) -static int32_t menutriggers=0; - -static char menunamecnt; - -static fnlist_t fnlist; -static CACHE1D_FIND_REC *finddirshigh=NULL, *findfileshigh=NULL; -static int32_t currentlist=0; - -static void set_findhighs(void) -{ - finddirshigh = fnlist.finddirs; - findfileshigh = fnlist.findfiles; - currentlist = 0; - if (findfileshigh) - currentlist = 1; -} - - -static int32_t function, whichkey; -static int32_t changesmade, newvidmode, curvidmode, newfullscreen; -static int32_t vidsets[16] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 }; -static int32_t curvidset, newvidset = 0; -static int32_t soundbits, soundvoices, soundrate; -#define NUMDOUBLEMBTNS 3 // # of mouse buttons that can be double-clicked (mouse1 - mouse3) -#define NUMSINGLEMBTNS 4 // # of mouse buttons that can only be single-clicked (the rest) -#define NUMMOUSEFUNCTIONS (NUMDOUBLEMBTNS*2+NUMSINGLEMBTNS) -// NOTE: NUMMOUSEFUNCTIONS must equal MAXMOUSEBUTTONS!!! -static const char *mousebuttonnames[NUMMOUSEFUNCTIONS==MAXMOUSEBUTTONS ? MAXMOUSEBUTTONS : -1] = -{ "Mouse1", "Mouse2", "Mouse3", "Mouse4", "Wheel Up", - "Wheel Down", "Mouse5", "Mouse6", "Mouse7", "Mouse8" -}; extern int32_t voting; @@ -94,258 +49,7 @@ extern int32_t voting; #define mgametext(x,y,t,s,dabits) G_PrintGameText(2,STARTALPHANUM, x,y,t,s,0,dabits,0, 0, xdim-1, ydim-1, 65536) #define mgametextpal(x,y,t,s,p) G_PrintGameText(2,STARTALPHANUM, x,y,t,s,p,26,0, 0, xdim-1, ydim-1, 65536) -void M_ChangeMenu(int32_t cm) -{ - if (G_HaveEvent(EVENT_CHANGEMENU)) - cm = VM_OnEvent(EVENT_CHANGEMENU, g_player[myconnectindex].ps->i, myconnectindex, -1, cm); - if (cm >= 0) - { - g_currentMenu = cm; - - switch (g_currentMenu) - { - case MENU_MAIN: - probey = last_main; - break; - case MENU_MAIN_INGAME: - probey = last_main_ingame; - break; - case MENU_EPISODE: - probey = last_episode; - break; - case MENU_OPTIONS: - probey = last_options; - break; - case MENU_SKILL: - probey = 1; - break; - default: - if (cm >= MENU_LOAD && cm < MENU_STORY) - probey = last_load; - else if ((cm >= MENU_LOADVERIFY && cm <= MENU_LOADVERIFY10)) - return; - else probey = 0; - break; - } - - lastsavehead = -1; - } -} - -static void M_LinearPanels(int32_t firstMenu, int32_t lastMenu) -{ - int32_t changedMenu = g_currentMenu; - - if (I_PanelUp()) - { - I_PanelUpClear(); - - S_PlaySound(KICK_HIT); - changedMenu--; - if (changedMenu < firstMenu) changedMenu = lastMenu; - M_ChangeMenu(changedMenu); - } - else if (I_PanelDown()) - { - I_PanelDownClear(); - - S_PlaySound(KICK_HIT); - changedMenu++; - if (changedMenu > lastMenu) changedMenu = firstMenu; - M_ChangeMenu(changedMenu); - } -} - -#define LMB (buttonstat&LEFT_MOUSE) -#define RMB (buttonstat&RIGHT_MOUSE) -#define WHEELUP (buttonstat&WHEELUP_MOUSE) -#define WHEELDOWN (buttonstat&WHEELDOWN_MOUSE) - -static ControlInfo minfo; - -static int16_t mi, mii; - -static int32_t probe_(int32_t type,int32_t x,int32_t y,int32_t i,int32_t n) -{ - int16_t centre; - - CONTROL_GetInput(&minfo); - mi += (minfo.dpitch+minfo.dz); - mii += minfo.dyaw; - - menutriggers = 0; - - if (x == (320>>1)) - centre = 320>>2; - else centre = 0; - - if (!buttonstat || buttonstat == WHEELUP_MOUSE || buttonstat == WHEELDOWN_MOUSE) - { - if (KB_KeyPressed(sc_UpArrow) || KB_KeyPressed(sc_kpad_8) || mi < -8192 || WHEELUP || BUTTON(gamefunc_Move_Forward) || (JOYSTICK_GetHat(0)&HAT_UP)) - { - mi = mii = 0; - KB_ClearKeyDown(sc_UpArrow); - KB_ClearKeyDown(sc_kpad_8); - MOUSE_ClearButton(WHEELUP_MOUSE); - CONTROL_ClearButton(gamefunc_Move_Forward); - JOYSTICK_ClearHat(0); - - S_PlaySound(KICK_HIT); - - probey--; - if (probey < 0) - probey = n-1; - } - if (KB_KeyPressed(sc_PgUp)) - { - // n is >= NUMGAMEFUNCTIONS from mouse/keyboard setup - int32_t step = (n >= NUMGAMEFUNCTIONS) ? 13/2 : n/2; - - KB_ClearKeyDown(sc_PgUp); - - S_PlaySound(KICK_HIT); - -// if (probey == 0) probey = n-1; else - probey = max(0, probey-step); - } - if (KB_KeyPressed(sc_Home)) - { - // does not get in the way of special HOME handling in user map list - KB_ClearKeyDown(sc_Home); - - S_PlaySound(KICK_HIT); - - probey = 0; - } - - if (KB_KeyPressed(sc_DownArrow) || KB_KeyPressed(sc_kpad_2) || mi > 8192 || WHEELDOWN || BUTTON(gamefunc_Move_Backward) || (JOYSTICK_GetHat(0)&HAT_DOWN)) - { - mi = mii = 0; - KB_ClearKeyDown(sc_DownArrow); - KB_ClearKeyDown(sc_kpad_2); - KB_ClearKeyDown(sc_PgDn); - MOUSE_ClearButton(WHEELDOWN_MOUSE); - CONTROL_ClearButton(gamefunc_Move_Backward); - JOYSTICK_ClearHat(0); - - S_PlaySound(KICK_HIT); - - probey++; - if (probey >= n) - probey = 0; - } - if (KB_KeyPressed(sc_PgDn)) - { - int32_t step = (n >= NUMGAMEFUNCTIONS) ? 13/2 : n/2; - - KB_ClearKeyDown(sc_PgDn); - - S_PlaySound(KICK_HIT); - -// if (probey == n-1) probey = 0; else - probey = min(n-1, probey+step); - } - if (KB_KeyPressed(sc_End)) - { - // does not get in the way of special END handling in user map list - KB_ClearKeyDown(sc_End); - - S_PlaySound(KICK_HIT); - - probey = n-1; - } - } - - // XXX: check for probey < 0 needed here? (we have M_Probe(..., 0) calls) - - if (probey >= n) // not sure if still necessary - probey = 0; - - if (x || y) - { - if (centre) - { - // rotatesprite_fs(((320>>1)+(centre)+54)<<16,(y+(probey*i)-4)<<16,65536L,0,SPINNINGNUKEICON+6-((6+(totalclock>>3))%7),sh,0,10); - // rotatesprite_fs(((320>>1)-(centre)-54)<<16,(y+(probey*i)-4)<<16,65536L,0,SPINNINGNUKEICON+((totalclock>>3)%7),sh,0,10); - - rotatesprite_fs(((320>>1)+(centre>>1)+70)<<16,(y+(probey*i)-4)<<16,65536L>>type,0,SPINNINGNUKEICON+6-((6+(totalclock>>3))%7),sh,0,10); - rotatesprite_fs(((320>>1)-(centre>>1)-70)<<16,(y+(probey*i)-4)<<16,65536L>>type,0,SPINNINGNUKEICON+((totalclock>>3)%7),sh,0,10); - } - else - rotatesprite_fs((x<<16)-((tilesizx[BIGFNTCURSOR]-4)<<(16-type)),(y+(probey*i)-(4>>type))<<16,65536L>>type,0,SPINNINGNUKEICON+(((totalclock>>3))%7),sh,0,10); - } - - if (I_AdvanceTrigger() && !onbar) - { - if (g_currentMenu != MENU_SKILL) - S_PlaySound(PISTOL_BODYHIT); - - menutriggers |= AdvanceTrigger; - - I_AdvanceTriggerClear(); - - return(probey); - } - else if (I_ReturnTrigger()) - { - S_PlaySound(EXITMENUSOUND); - - menutriggers |= ReturnTrigger; - - I_ReturnTriggerClear(); - - onbar = 0; - return(-1); - } - else - { - if (onbar == 0) - return(-probey-2); - - if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || (LMB && (WHEELUP || mii < -256)) || BUTTON(gamefunc_Turn_Left) || - BUTTON(gamefunc_Strafe_Left) || (JOYSTICK_GetHat(0)&HAT_LEFT)) - return(probey); - else if (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || (LMB && (WHEELDOWN || mii > 256)) || BUTTON(gamefunc_Turn_Right) || - BUTTON(gamefunc_Strafe_Right) || (JOYSTICK_GetHat(0)&HAT_RIGHT)) - return(probey); - - return(-probey-2); - } -} -static inline int32_t M_Probe(int32_t x,int32_t y,int32_t i,int32_t n) -{ - return probe_(0,x,y,i,n); -} - -static inline int32_t probesm(int32_t x,int32_t y,int32_t i,int32_t n) -{ - return probe_(1,x,y,i,n); -} - -// see menutriggers for why this is a sorry hack -// calling CONTROL_GetFunctionInput(); from input.c also would not work -// and probe_() must remain static -static int32_t Menu_EnterText(int32_t x,int32_t y,char *t,int32_t dalen,int32_t c) -{ - int32_t probeysave = probey; - int32_t probeoutputx = M_Probe(0,0,0,1); - probey = probeysave; - - if (ProbeTriggers(AdvanceTrigger) || I_AdvanceTrigger()) - { - I_AdvanceTriggerClear(); - return (1); - } - - if (probeoutputx == -1) - { - I_ReturnTriggerClear(); - return (-1); - } - - return G_EnterText(x, y, t, dalen, c); -} int32_t menutext_(int32_t x,int32_t y,int32_t s,int32_t p,char *t,int32_t bits) { @@ -360,193 +64,11 @@ int32_t menutext_(int32_t x,int32_t y,int32_t s,int32_t p,char *t,int32_t bits) return dim.x; } - -// This function depends on the 'onbar' variable which should be set to the -// 'probey' indices where there's a slider bar. -static void sliderbar(int32_t type, int32_t x,int32_t y,int32_t *p,int32_t dainc,int32_t damodify,int32_t s, int32_t pa, int32_t min, int32_t max) -{ - int32_t xloc; - char rev; - - if (dainc < 0) - { - dainc = -dainc; - rev = 1; - } - else rev = 0; - y-=2; - - if (damodify) - { - if (*p >= min && *p <= max && (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || (LMB && (WHEELUP || mii < -256)) || - BUTTON(gamefunc_Turn_Left) || BUTTON(gamefunc_Strafe_Left) || (JOYSTICK_GetHat(0)&HAT_LEFT))) // && onbar) ) - { - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_kpad_4); - MOUSE_ClearButton(WHEELUP_MOUSE); - CONTROL_ClearButton(gamefunc_Turn_Left); - CONTROL_ClearButton(gamefunc_Strafe_Left); - JOYSTICK_ClearHat(0); - mii = 0; - if (!rev) - *p -= dainc; - else *p += dainc; - if (*p < min) - *p = min; - if (*p > max) - *p = max; - S_PlaySound(KICK_HIT); - } - if (*p <= max && *p >= min && (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || (LMB && (WHEELDOWN || mii > 256)) || - BUTTON(gamefunc_Turn_Right) || BUTTON(gamefunc_Strafe_Right) || (JOYSTICK_GetHat(0)&HAT_RIGHT))) //&& onbar) ) - { - KB_ClearKeyDown(sc_RightArrow); - KB_ClearKeyDown(sc_kpad_6); - MOUSE_ClearButton(WHEELDOWN_MOUSE); - CONTROL_ClearButton(gamefunc_Turn_Right); - CONTROL_ClearButton(gamefunc_Strafe_Right); - JOYSTICK_ClearHat(0); - mii = 0; - if (!rev) - *p += dainc; - else *p -= dainc; - if (*p > max) - *p = max; - if (*p < min) - *p = min; - S_PlaySound(KICK_HIT); - } - } - - xloc = *p; - rotatesprite_fs((x<<16)+(22<<(16-type)),(y<<16)-(3<<(16-type)),65536L>>type,0,SLIDEBAR,s,pa,10); - if (rev == 0) - rotatesprite_fs((x<<16)+((scale(64,xloc-min,max-min)+1)<<(16-type)),(y<<16)+(1<<(16-type)),65536L>>type,0,SLIDEBAR+1,s,pa,10); - else - rotatesprite_fs((x<<16)+((65-scale(64,xloc-min,max-min))<<(16-type)),(y<<16)+(1<<(16-type)),65536L>>type,0,SLIDEBAR+1,s,pa,10); -} - -#define bar(x,y,p,dainc,damodify,s,pa) sliderbar(0,x,y,p,dainc,damodify,s,pa,0,63); -#define barsm(x,y,p,dainc,damodify,s,pa) sliderbar(1,x,y,p,dainc,damodify,s,pa,0,63); - -static void modval(int32_t min, int32_t max,int32_t *p,int32_t dainc,int32_t damodify) -{ - char rev; - - if (dainc < 0) - { - dainc = -dainc; - rev = 1; - } - else rev = 0; - - if (damodify) - { - if (rev == 0) - { - if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || (LMB && minfo.dyaw < -256) || BUTTON(gamefunc_Turn_Left) || - BUTTON(gamefunc_Strafe_Left) || (JOYSTICK_GetHat(0)&HAT_LEFT)) // && onbar) ) - { - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_kpad_4); - CONTROL_ClearButton(gamefunc_Turn_Left); - CONTROL_ClearButton(gamefunc_Strafe_Left); - JOYSTICK_ClearHat(0); - - *p -= dainc; - if (*p < min) - { - *p = max; - if (damodify == 2) - *p = min; - } - S_PlaySound(PISTOL_BODYHIT); - } - if (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || (LMB && minfo.dyaw > 256) || BUTTON(gamefunc_Turn_Right) || - BUTTON(gamefunc_Strafe_Right) || (JOYSTICK_GetHat(0)&HAT_RIGHT)) //&& onbar) ) - { - KB_ClearKeyDown(sc_RightArrow); - KB_ClearKeyDown(sc_kpad_6); - CONTROL_ClearButton(gamefunc_Turn_Right); - CONTROL_ClearButton(gamefunc_Strafe_Right); - JOYSTICK_ClearHat(0); - - *p += dainc; - if (*p > max) - { - *p = min; - if (damodify == 2) - *p = max; - } - S_PlaySound(PISTOL_BODYHIT); - } - } - else - { - if (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || (LMB && minfo.dyaw > 256) || BUTTON(gamefunc_Turn_Right) || - BUTTON(gamefunc_Strafe_Right) || (JOYSTICK_GetHat(0)&HAT_RIGHT)) //&& onbar )) - { - KB_ClearKeyDown(sc_RightArrow); - KB_ClearKeyDown(sc_kpad_6); - CONTROL_ClearButton(gamefunc_Turn_Right); - CONTROL_ClearButton(gamefunc_Strafe_Right); - JOYSTICK_ClearHat(0); - - *p -= dainc; - if (*p < min) - { - *p = max; - if (damodify == 2) - *p = min; - } - S_PlaySound(PISTOL_BODYHIT); - } - if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || (LMB && minfo.dyaw < -256) || BUTTON(gamefunc_Turn_Left) || - BUTTON(gamefunc_Strafe_Left) || (JOYSTICK_GetHat(0)&HAT_LEFT)) // && onbar) ) - { - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_kpad_4); - CONTROL_ClearButton(gamefunc_Turn_Left); - CONTROL_ClearButton(gamefunc_Strafe_Left); - JOYSTICK_ClearHat(0); - - *p += dainc; - if (*p > max) - { - *p = min; - if (damodify == 2) - *p = max; - } - S_PlaySound(PISTOL_BODYHIT); - } - } - } -} - -#define NUKEICON_CENTER_PROBEX (NAM ? 184 : 180) - -#define UNSELMENUSHADE 10 -#define DISABLEDMENUSHADE 20 -#define UNSELMINISHADE 16 -#define MENUHIGHLIGHTCOND(cond) ((cond)?(sintable[(totalclock<<5)&2047]>>12):UNSELMENUSHADE) -#define MINIHIGHLIGHTCOND(cond) ((cond) ? 0 : UNSELMINISHADE) -#define MENUHIGHLIGHT(x) MENUHIGHLIGHTCOND(probey==(x)) -#define MINIHIGHLIGHT(x) MINIHIGHLIGHTCOND(probey==(x)) -// #define MENUHIGHLIGHT(x) probey==x?-(sintable[(totalclock<<4)&2047]>>12):probey-x>=0?(probey-x)<<2:-((probey-x)<<2) - -//#define MWIN(X) rotatesprite( 320<<15,200<<15,X,0,MENUSCREEN,-16,0,10+64,0,0,xdim-1,ydim-1) -//#define MWINXY(X,OX,OY) rotatesprite( ( 320+(OX) )<<15, ( 200+(OY) )<<15,X,0,MENUSCREEN,-16,0,10+64,0,0,xdim-1,ydim-1) - -//extern int32_t G_LoadSaveHeader(char spot,struct savehead_ *saveh); - #pragma pack(push,1) static savehead_t savehead; //static struct savehead_ savehead; #pragma pack(pop) -//static int32_t volnum,levnum,plrskl,numplr; -//static char brdfn[BMAX_PATH]; - static void M_DrawBackground(void) { rotatesprite_fs(160<<16,200<<15,65536L,0,MENUSCREEN,16,0,10+64); @@ -559,299 +81,1852 @@ static void M_DrawTopBar(const char *caption) menutext(160,24,0,0,caption); } -static void M_DisplaySaveGameList(void) -{ - int32_t x, c = 160; - - c += 64; - for (x = 0; x <= 108; x += 12) - rotatesprite_fs((c+91-64)<<16,(x+56)<<16,65536L,0,TEXTBOX,24,0,10); - - rotatesprite_fs(22<<16,97<<16,65536L,0,WINDOWBORDER2,24,0,10); - rotatesprite_fs(180<<16,97<<16,65536L,1024,WINDOWBORDER2,24,0,10); - rotatesprite_fs(99<<16,50<<16,65536L,512,WINDOWBORDER1,24,0,10); - rotatesprite_fs(103<<16,144<<16,65536L,1024+512,WINDOWBORDER1,24,0,10); - - for (x=0; x prev_color) - (*color)++; - else (*color)--; - i=0; + MEL_EPISODE[i] = &ME_EPISODE[i]; + ME_EPISODE[i] = ME_EPISODE_TEMPLATE; + ME_EPISODE[i].name = EpisodeNames[i]; + + MEOSN_NetEpisodes[i] = EpisodeNames[i]; + + k = i; } - } -} -static void Menus_LoadSave_DisplayCommon1(void) -{ - if (lastsavehead != probey) - G_LoadSaveHeaderNew(probey, &savehead); - lastsavehead = probey; - - rotatesprite_fs(101<<16,97<<16,65536L>>1,512,TILE_LOADSHOT,-32,0,4+10+64); - - if (g_oldverSavegame[probey]) - { - menutext(53,70,0,0,"Version"); - menutext(48,90,0,0,"Mismatch"); - - Bsprintf(tempbuf,"Saved: %d.%d.%d %d-bit", savehead.majorver, savehead.minorver, - savehead.bytever, 8*savehead.ptrsize); - mgametext(31,104,tempbuf,0,2+8+16); - Bsprintf(tempbuf,"Our: %d.%d.%d %d-bit", SV_MAJOR_VER, SV_MINOR_VER, BYTEVERSION, - (int32_t)(8*sizeof(intptr_t))); - mgametext(31+16,QUOTE_SAVE_BAD_VERSION,tempbuf,0,2+8+16); - } -} - -void Menu_Main(void) -{ - int32_t margin = MENU_MARGIN_CENTER; - int32_t x; - - enum - { - M_MAIN_EPISODE, - M_MAIN_OPTIONS, - M_MAIN_LOAD, - M_MAIN_STORY, - M_MAIN_CREDITS, - M_MAIN_QUIT - }; - - - rotatesprite_fs(margin<<16,28<<16,65536L,0,INGAMEDUKETHREEDEE,0,0,10); - - if (PLUTOPAK) // JBF 20030804 - rotatesprite_fs((margin+100)<<16,36<<16,65536L,0,PLUTOPAKSPRITE+2,(sintable[(totalclock<<4)&2047]>>11),0,2+8); - - menutext(margin,67,MENUHIGHLIGHT(0),0,"New Game"); - - // menutext(c,67+16,0,1,"Network Game"); - - menutext(margin,67+16/*+16*/,MENUHIGHLIGHT(1),0,"Options"); - menutext(margin,67+16+16/*+16*/,MENUHIGHLIGHT(2),0,"Load Game"); - - if (!VOLUMEALL) - menutext(margin,67+16+16+16/*+16*/,MENUHIGHLIGHT(3),0,"How To Order"); - else - menutext(margin,67+16+16+16/*+16*/,MENUHIGHLIGHT(3),0,"Help"); - - menutext(margin,67+16+16+16+16/*+16*/,MENUHIGHLIGHT(4),0,"Credits"); - menutext(margin,67+16+16+16+16+16/*+16*/,MENUHIGHLIGHT(5),0,"Quit"); - - x = M_Probe(margin,67,16,6); - - if (x >= 0) - { - if ((g_netServer || ud.multimode > 1) && x == 0 && ud.recstat != 2) + // prepare levels + for (j = 0; j < MAXLEVELS; ++j) { - last_main = 0; - M_ChangeMenu(MENU_NETSETUP); + MEOSN_NetLevels[i][j] = MapInfo[MAXLEVELS*i+j].name; + if (MapInfo[i*MAXLEVELS+j].filename != NULL) + MEOS_NETOPTIONS_LEVEL[i].numOptions = j+1; + } + MEOS_NETOPTIONS_LEVEL[i].optionNames = MEOSN_NetLevels[i]; + } + ++k; + MG_EPISODE.numEntries = g_numVolumes; // k; + MEOS_NETOPTIONS_EPISODE.numOptions = g_numVolumes + 1; // k+1; + MEOSN_NetEpisodes[g_numVolumes] = MenuUserMap; + MP_TOP_EPISODE.pos.y = (48-(g_numVolumes*2))<<16; + + // prepare skills + k = -1; + for (i = 0; i < g_numSkills && SkillNames[i][0]; ++i) + { + MEL_SKILL[i] = &ME_SKILL[i]; + ME_SKILL[i] = ME_SKILL_TEMPLATE; + ME_SKILL[i].name = SkillNames[i]; + + MEOSN_NetSkills[i] = SkillNames[i]; + + k = i; + } + ++k; + MG_SKILL.numEntries = g_numSkills; // k; + MEOS_NETOPTIONS_MONSTERS.numOptions = g_numSkills + 1; // k+1; + MEOSN_NetSkills[g_numSkills] = MenuSkillNone; + MP_TOP_SKILL.pos.y = (58 + (4-g_numSkills)*6)<<16; + MG_SKILL.currentEntry = 1; + + // prepare multiplayer gametypes + k = -1; + for (i = 0; i < MAXGAMETYPES; ++i) + if (GametypeNames[i][0]) + { + MEOSN_NetGametypes[i] = GametypeNames[i]; + k = i; + } + ++k; + MEOS_NETOPTIONS_GAMETYPE.numOptions = k; + + // prepare savegames + for (i = 0; i < MAXSAVEGAMES; ++i) + { + MEL_LOAD[i] = &ME_LOAD[i]; + MEL_SAVE[i] = &ME_SAVE[i]; + ME_LOAD[i] = ME_LOAD_TEMPLATE; + ME_SAVE[i] = ME_SAVE_TEMPLATE; + ME_SAVE[i].entry = &MEO_SAVE[i]; + MEO_SAVE[i] = MEO_SAVE_TEMPLATE; + + ME_LOAD[i].name = ud.savegame[i]; + MEO_SAVE[i].variable = ud.savegame[i]; + } + + // prepare text chat macros + for (i = 0; i < MAXRIDECULE; ++i) + { + MEL_MACROS[i] = &ME_MACROS[i]; + ME_MACROS[i] = ME_MACROS_TEMPLATE; + ME_MACROS[i].entry = &MEO_MACROS[i]; + MEO_MACROS[i] = MEO_MACROS_TEMPLATE; + + MEO_MACROS[i].variable = ud.ridecule[i]; + } + + // prepare input + for (i = 0; i < NUMGAMEFUNCTIONS; ++i) + { + MEL_KEYBOARDSETUPFUNCS[i] = &ME_KEYBOARDSETUPFUNCS[i]; + ME_KEYBOARDSETUPFUNCS[i] = ME_KEYBOARDSETUPFUNCS_TEMPLATE; + ME_KEYBOARDSETUPFUNCS[i].name = MenuGameFuncs[i]; + ME_KEYBOARDSETUPFUNCS[i].entry = &MEO_KEYBOARDSETUPFUNCS[i]; + MEO_KEYBOARDSETUPFUNCS[i] = MEO_KEYBOARDSETUPFUNCS_TEMPLATE; + MEO_KEYBOARDSETUPFUNCS[i].column[0] = &ud.config.KeyboardKeys[i][0]; + MEO_KEYBOARDSETUPFUNCS[i].column[1] = &ud.config.KeyboardKeys[i][1]; + } + for (i = 0; i < MENUMOUSEFUNCTIONS; ++i) + { + MEL_MOUSESETUPBTNS[i] = &ME_MOUSESETUPBTNS[i]; + ME_MOUSESETUPBTNS[i] = ME_MOUSEJOYSETUPBTNS_TEMPLATE; + ME_MOUSESETUPBTNS[i].name = MenuMouseNames[i]; + ME_MOUSESETUPBTNS[i].entry = &MEO_MOUSESETUPBTNS[i]; + MEO_MOUSESETUPBTNS[i] = MEO_MOUSEJOYSETUPBTNS_TEMPLATE; + MEO_MOUSESETUPBTNS[i].data = &ud.config.MouseFunctions[MenuMouseDataIndex[i][0]][MenuMouseDataIndex[i][1]]; + } + for (i = 0; i < 2*joynumbuttons + 2*joynumhats; ++i) + { + if (i < 2*joynumbuttons) + { + if (i & 1) + Bsnprintf(MenuJoystickNames[i], MAXJOYBUTTONSTRINGLENGTH, "Double %s", getjoyname(1, i>>1)); + else + Bstrncpy(MenuJoystickNames[i], getjoyname(1, i>>1), MAXJOYBUTTONSTRINGLENGTH); } else { - last_main = x; - switch (x) + Bsnprintf(MenuJoystickNames[i], MAXJOYBUTTONSTRINGLENGTH, (i & 1) ? "Double Hat %d %s" : "Hat %d %s", ((i - 2*joynumbuttons)>>3), MenuJoystickHatDirections[((i - 2*joynumbuttons)>>1) % 4]); + } + + MEL_JOYSTICKBTNS[i] = &ME_JOYSTICKBTNS[i]; + ME_JOYSTICKBTNS[i] = ME_MOUSEJOYSETUPBTNS_TEMPLATE; + ME_JOYSTICKBTNS[i].name = MenuJoystickNames[i]; + ME_JOYSTICKBTNS[i].entry = &MEO_JOYSTICKBTNS[i]; + MEO_JOYSTICKBTNS[i] = MEO_MOUSEJOYSETUPBTNS_TEMPLATE; + MEO_JOYSTICKBTNS[i].data = &ud.config.JoystickFunctions[i>>1][i&1]; + } + MG_JOYSTICKBTNS.numEntries = 2*joynumbuttons + 2*joynumhats; + for (i = 0; i < joynumaxes; ++i) + { + ME_JOYSTICKAXES[i] = ME_JOYSTICKAXES_TEMPLATE; + Bstrncpy(MenuJoystickAxes[i], getjoyname(0, i), MAXJOYBUTTONSTRINGLENGTH); + ME_JOYSTICKAXES[i].name = MenuJoystickAxes[i]; + MEL_JOYSTICKAXES[i] = &ME_JOYSTICKAXES[i]; + } + MG_JOYSTICKAXES.numEntries = joynumaxes; + + // prepare video setup + for (i = 0; i < validmodecnt; ++i) + { + int32_t *const r = &MEOS_VIDEOSETUP_RESOLUTION.numOptions; + + for (j = 0; j < *r; ++j) + { + if (validmode[i].xdim == resolution[j].xdim && validmode[i].ydim == resolution[j].ydim) { - case M_MAIN_EPISODE: - M_ChangeMenu(MENU_EPISODE); - break; - //case 1: break;//M_ChangeMenu(MENU_NETWORK);break; // JBF 20031128: I'm taking over the TEN menu option - case M_MAIN_OPTIONS: - M_ChangeMenu(MENU_OPTIONS); - break; // JBF 20031205: was 200 - case M_MAIN_LOAD: - M_ChangeMenu(MENU_LOAD); - break; - case M_MAIN_STORY: - KB_FlushKeyboardQueue(); - M_ChangeMenu(MENU_STORY); - break; - case M_MAIN_CREDITS: - M_ChangeMenu(MENU_CREDITS); - break; - case M_MAIN_QUIT: - M_ChangeMenu(MENU_QUIT); + resolution[j].flags |= validmode[i].fs ? RES_FS : RES_WIN; + if (validmode[i].bpp > resolution[j].bppmax) + resolution[j].bppmax = validmode[i].bpp; break; } } - } - if (KB_KeyPressed(sc_Q)) M_ChangeMenu(MENU_QUIT); - - if (x == -1 && (g_player[myconnectindex].ps->gm &MODE_GAME || ud.recstat == 2)) - { - g_player[myconnectindex].ps->gm &= ~MODE_MENU; - if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) + if (j == *r) // no match found { - ready2send = 1; - totalclock = ototalclock; + resolution[j].xdim = validmode[i].xdim; + resolution[j].ydim = validmode[i].ydim; + resolution[j].bppmax = validmode[i].bpp; + resolution[j].flags = validmode[i].fs ? RES_FS : RES_WIN; + Bsnprintf(resolution[j].name, MAXRESOLUTIONSTRINGLENGTH, "%d x %d", resolution[j].xdim, resolution[j].ydim); + MEOSN_VIDEOSETUP_RESOLUTION[j] = resolution[j].name; + ++*r; } } -} -int32_t M_IsTextInput(int32_t cm) -{ - switch (cm) + // prepare shareware + if (VOLUMEONE) { - case MENU_SELECTMAP: - case MENU_KEYBOARDASSIGN: - case MENU_SAVETYPING: - case MENU_SAVETYPING2: - case MENU_SAVETYPING3: - case MENU_SAVETYPING4: - case MENU_SAVETYPING5: - case MENU_SAVETYPING6: - case MENU_SAVETYPING7: - case MENU_SAVETYPING8: - case MENU_SAVETYPING9: - case MENU_SAVETYPING10: - case MENU_QUIT: - case MENU_QUITTOTITLE: - case MENU_QUIT2: - case MENU_NETWAITVOTES: - case MENU_ADULTPASSWORD: - case MENU_PLAYERNAME: - case MENU_MACROSTYPING: - return 1; - break; - default: - return 0; - break; - } + // change main menu + MenuGroup_ChangeEntryList(MG_MAIN, MEL_MAIN_SHAREWARE); + MenuGroup_ChangeEntryList(MG_MAIN_INGAME, MEL_MAIN_INGAME_SHAREWARE); - return 0; -} + // remove User Map + MenuMenu_ChangeGroupList(M_EPISODE, MGL_EPISODE_SHAREWARE); -static inline int32_t M_UpdateScreenOK(int32_t cm) -{ - switch (cm) - { - case MENU_LOAD: - case MENU_SAVE: - case MENU_SAVE_: - case MENU_SAVETYPING: - case MENU_SAVETYPING2: - case MENU_SAVETYPING3: - case MENU_SAVETYPING4: - case MENU_SAVETYPING5: - case MENU_SAVETYPING6: - case MENU_SAVETYPING7: - case MENU_SAVETYPING8: - case MENU_SAVETYPING9: - case MENU_SAVETYPING10: - case MENU_LOADVERIFY: - case MENU_LOADVERIFY2: - case MENU_LOADVERIFY3: - case MENU_LOADVERIFY4: - case MENU_LOADVERIFY5: - case MENU_LOADVERIFY6: - case MENU_LOADVERIFY7: - case MENU_LOADVERIFY8: - case MENU_LOADVERIFY9: - case MENU_LOADVERIFY10: - case MENU_SAVEVERIFY: - case MENU_SAVEVERIFY2: - case MENU_SAVEVERIFY3: - case MENU_SAVEVERIFY4: - case MENU_SAVEVERIFY5: - case MENU_SAVEVERIFY6: - case MENU_SAVEVERIFY7: - case MENU_SAVEVERIFY8: - case MENU_SAVEVERIFY9: - case MENU_SAVEVERIFY10: - return 0; - break; - default: - return 1; - break; - } - - return 1; -} - -void M_DisplayMenus(void) -{ - CACHE1D_FIND_REC *dir; - int32_t margin, x,i; - int32_t l,m; - const char *p = NULL; - - Net_GetPackets(); - - { - if (buttonstat != 0 && !onbar) + // blue out episodes beyond the first + for (i = 1; i < MAXVOLUMES; ++i) { - x = MOUSE_GetButtons()<<3; - if (x) buttonstat = x<<3; - else buttonstat = 0; + if (MEL_EPISODE[i]) + { + ME_EPISODE[i].font = &MF_RedfontBlue; + ME_EPISODE[i].entry = &MEO_EPISODE_SHAREWARE; + } + } + MEOS_NETOPTIONS_EPISODE.numOptions = 1; + ME_NETOPTIONS_EPISODE.disabled = 1; + } + + // prepare pre-Atomic + if (!VOLUMEALL || !PLUTOPAK) + { + // prepare credits + M_CREDITS.title = M_CREDITS2.title = M_CREDITS3.title = MenuCredits; + } +} + +static void M_RunMenu(Menu_t *cm); + + + +/* +At present, no true difference is planned between M_PreMenu() and M_PreMenuDraw(). +They are separate for purposes of organization. +*/ + +static void M_PreMenu(MenuID_t cm) +{ + int32_t i; + DukePlayer_t *ps = g_player[myconnectindex].ps; + + switch (cm) + { + case MENU_MAIN_INGAME: + ME_MAIN_SAVEGAME.disabled = (ud.recstat == 2); + ME_MAIN_QUITTOTITLE.disabled = (g_netServer || numplayers > 1); + case MENU_MAIN: + if ((g_netServer || ud.multimode > 1) && ud.recstat != 2) + { + ME_MAIN_NEWGAME.entry = &MEO_MAIN_NEWGAME_NETWORK; + ME_MAIN_NEWGAME_INGAME.entry = &MEO_MAIN_NEWGAME_NETWORK; } else - buttonstat = MOUSE_GetButtons(); + { + ME_MAIN_NEWGAME.entry = &MEO_MAIN_NEWGAME; + ME_MAIN_NEWGAME_INGAME.entry = &MEO_MAIN_NEWGAME_INGAME; + } + break; + + case MENU_GAMESETUP: + MEO_GAMESETUP_DEMOREC.options = (ps->gm&MODE_GAME) ? &MEOS_DemoRec : &MEOS_OffOn; + ME_GAMESETUP_DEMOREC.disabled = ((ps->gm&MODE_GAME) && ud.m_recstat != 1); + break; + +#ifdef USE_OPENGL + case MENU_RENDERERSETUP: + if (getrendermode() == REND_CLASSIC) + MenuMenu_ChangeGroupList(M_RENDERERSETUP, MGL_RENDERERSETUP); +#ifdef POLYMER + else if (getrendermode() == REND_POLYMER) + MenuMenu_ChangeGroupList(M_RENDERERSETUP, MGL_RENDERERSETUP_GL_POLYMER); +#endif + else + MenuMenu_ChangeGroupList(M_RENDERERSETUP, MGL_RENDERERSETUP_GL); + + if (getrendermode() != REND_CLASSIC) + for (i = (int32_t) ARRAY_SIZE(MEOSV_RENDERERSETUP_ANISOTROPY) - 1; i >= 0; --i) + { + if (MEOSV_RENDERERSETUP_ANISOTROPY[i] <= glinfo.maxanisotropy) + { + MEOS_RENDERERSETUP_ANISOTROPY.numOptions = i + 1; + break; + } + } + + ME_RENDERERSETUP_TEXQUALITY.disabled = !usehightile; + ME_RENDERERSETUP_PRECACHE.disabled = !usehightile; + ME_RENDERERSETUP_TEXCACHE.disabled = !(glusetexcompr && usehightile); + ME_RENDERERSETUP_DETAILTEX.disabled = !usehightile; + break; +#endif + + case MENU_VIDEOSETUP: +#ifdef USE_OPENGL + if (getrendermode() == REND_CLASSIC) + MenuMenu_ChangeGroupList(M_VIDEOSETUP, MGL_VIDEOSETUP); + else + MenuMenu_ChangeGroupList(M_VIDEOSETUP, MGL_VIDEOSETUP_GL); +#endif + ME_VIDEOSETUP_APPLY.disabled = ((xdim == resolution[newresolution].xdim && ydim == resolution[newresolution].ydim && getrendermode() == newrendermode && fullscreen == newfullscreen) || (newfullscreen ? !(resolution[newresolution].flags & RES_FS) : !(resolution[newresolution].flags & RES_WIN)) || (newrendermode != REND_CLASSIC && resolution[newresolution].bppmax <= 8)); + break; + + case MENU_SOUND: + ME_SOUND.disabled = (ud.config.FXDevice < 0); + ME_SOUND_MUSIC.disabled = (ud.config.MusicDevice < 0); + ME_SOUND_VOLUME_MASTER.disabled = (!ud.config.SoundToggle || ud.config.FXDevice < 0) && (!ud.config.MusicToggle || ud.config.MusicDevice < 0); + ME_SOUND_VOLUME_EFFECTS.disabled = (!ud.config.SoundToggle || ud.config.FXDevice < 0); + ME_SOUND_VOLUME_MUSIC.disabled = (!ud.config.MusicToggle || ud.config.MusicDevice < 0); + ME_SOUND_SAMPLINGRATE.disabled = (!ud.config.SoundToggle || ud.config.FXDevice < 0) && (!ud.config.MusicToggle || ud.config.MusicDevice < 0); + ME_SOUND_SAMPLESIZE.disabled = (!ud.config.SoundToggle || ud.config.FXDevice < 0) && (!ud.config.MusicToggle || ud.config.MusicDevice < 0); + ME_SOUND_NUMVOICES.disabled = (!ud.config.SoundToggle || ud.config.FXDevice < 0); + ME_SOUND_RESTART.disabled = (soundrate == ud.config.MixRate && soundvoices == ud.config.NumVoices && soundbits == ud.config.NumBits); + ME_SOUND_DUKETALK.disabled = (!ud.config.SoundToggle || ud.config.FXDevice < 0); + ME_SOUND_DUKEMATCHPLAYER.disabled = (!ud.config.SoundToggle || ud.config.FXDevice < 0); + ME_SOUND_AMBIENT.disabled = (!ud.config.SoundToggle || ud.config.FXDevice < 0); + ME_SOUND_REVERSESTEREO.disabled = (!ud.config.SoundToggle || ud.config.FXDevice < 0); + break; + + case MENU_MOUSESETUP: + ME_MOUSESETUP_MOUSEAIMING.disabled = ud.mouseaiming; + break; + + case MENU_NETOPTIONS: + if (MEO_NETOPTIONS_EPISODE.currentOption == MEOS_NETOPTIONS_EPISODE.numOptions-1) + MEL_NETOPTIONS[2] = &ME_NETOPTIONS_USERMAP; + else + { + MEL_NETOPTIONS[2] = &ME_NETOPTIONS_LEVEL; + MEO_NETOPTIONS_LEVEL.options = &MEOS_NETOPTIONS_LEVEL[MEO_NETOPTIONS_EPISODE.currentOption]; + } + MEL_NETOPTIONS[4] = (GametypeFlags[ud.m_coop] & GAMETYPE_MARKEROPTION) ? &ME_NETOPTIONS_MARKERS : &ME_NETOPTIONS_MARKERS_DISABLED; + MEL_NETOPTIONS[5] = (GametypeFlags[ud.m_coop] & (GAMETYPE_PLAYERSFRIENDLY|GAMETYPE_TDM)) ? &ME_NETOPTIONS_FRFIRE : &ME_NETOPTIONS_MAPEXITS; + break; + + case MENU_OPTIONS: + ME_OPTIONS_PLAYERSETUP.disabled = ud.recstat == 1; + ME_OPTIONS_JOYSTICKSETUP.disabled = CONTROL_JoyPresent == 0; + break; + + case MENU_LOAD: + for (i = 0; i < MAXSAVEGAMES; ++i) + { + ME_LOAD[i].entry = (ud.savegame[i][0] && !g_oldverSavegame[i]) ? &MEO_LOAD_VALID : &MEO_LOAD; + ME_LOAD[i].font = g_oldverSavegame[i] ? &MF_MinifontDarkGray : &MF_MinifontRed; + } + break; + + case MENU_SAVE: + for (i = 0; i < MAXSAVEGAMES; ++i) + MEO_SAVE[i].font = (g_oldverSavegame[i] && MEO_SAVE[i].editfield == NULL) ? &MF_MinifontDarkGray : &MF_MinifontRed; + break; + + case MENU_LOADVERIFY: + case MENU_SAVEVERIFY: + case MENU_ADULTPASSWORD: + M_RunMenu(m_previousMenu); + break; + + default: + break; } +} - if ((g_player[myconnectindex].ps->gm&MODE_MENU) == 0) +static void M_PreMenuDraw(MenuID_t cm, MenuGroup_t *group, MenuEntry_t *entry) +{ + int32_t i, j, l = 0, m; + + switch (cm) { - walock[TILE_LOADSHOT] = 1; - return; - } - if (G_HaveEvent(EVENT_DISPLAYMENU)) - VM_OnEvent(EVENT_DISPLAYMENU, g_player[screenpeek].ps->i, screenpeek, -1, 0); + case MENU_MAIN_INGAME: + l += 4; + case MENU_MAIN: + rotatesprite_fs(MENU_MARGIN_CENTER<<16,(28+l)<<16,65536L,0,INGAMEDUKETHREEDEE,0,0,10); + if (PLUTOPAK) // JBF 20030804 + rotatesprite_fs((MENU_MARGIN_CENTER+100)<<16,36<<16,65536L,0,PLUTOPAKSPRITE+2,(sintable[(totalclock<<4)&2047]>>11),0,2+8); + break; - g_player[myconnectindex].ps->gm &= (0xff-MODE_TYPE); - g_player[myconnectindex].ps->fta = 0; + case MENU_PLAYER: + rotatesprite_fs((260)<<16,(24+(tilesizy[APLAYER]>>1))<<16,49152L,0,1441-((((4-(totalclock>>4)))&3)*5),0,entry == &ME_PLAYER_TEAM ? G_GetTeamPalette(ud.team) : ud.color,10); + break; -// x = 0; + case MENU_MACROS: + mgametext(160,144,"Activate in-game with Shift-F#",0,2+8+16); + break; - sh = 4-(sintable[(totalclock<<4)&2047]>>11); + case MENU_COLCORR: + case MENU_COLCORR_INGAME: + rotatesprite(40<<16,24<<16,24576,0,BONUSSCREEN,0,0,2+8+16,0,scale(ydim,35,200),xdim-1,scale(ydim,80,200)-1); + rotatesprite(160<<16,27<<16,24576,0,3290,0,0,2+8+16,0,scale(ydim,35,200),xdim-1,scale(ydim,80,200)-1); + break; - // black translucent background - if ((g_player[myconnectindex].ps->gm&MODE_GAME) || ud.recstat==2) - if (g_currentMenu != MENU_COLCORR && g_currentMenu != MENU_COLCORR_INGAME) // not in 'color correction' menu - fade_screen_black(1); + case MENU_NETSETUP: + case MENU_NETHOST: + minitext(90,90, "Game Type" ,2,26); + minitext(90,90+8, "Episode" ,2,26); + minitext(90,90+8+8, "Level" ,2,26); + minitext(90,90+8+8+8, "Monsters" ,2,26); + if (ud.m_coop == 0) + minitext(90,90+8+8+8+8, "Markers" ,2,26); + else if (ud.m_coop == 1) + minitext(90,90+8+8+8+8, "Friendly Fire",2,26); + minitext(90,90+8+8+8+8+8, "User Map" ,2,26); - if (M_UpdateScreenOK(g_currentMenu)) - G_UpdateScreenArea(); + minitext(90+60,90,GametypeNames[ud.m_coop],0,26); - if (KB_KeyPressed(sc_Q) && !M_IsTextInput(g_currentMenu) && g_currentMenu >= 0) - { - last_menu = g_currentMenu; - last_menu_pos = probey; - M_ChangeMenu(MENU_QUIT2); - } + minitext(90+60,90+8, EpisodeNames[ud.m_volume_number],0,26); + minitext(90+60,90+8+8, MapInfo[MAXLEVELS*ud.m_volume_number+ud.m_level_number].name,0,26); + if (ud.m_monsters_off == 0 || ud.m_player_skill > 0) + minitext(90+60,90+8+8+8, SkillNames[ud.m_player_skill],0,26); + else minitext(90+60,90+8+8+8, "None",0,28); + if (ud.m_coop == 0) + { + if (ud.m_marker) minitext(90+60,90+8+8+8+8,"On",0,26); + else minitext(90+60,90+8+8+8+8,"Off",0,26); + } + else if (ud.m_coop == 1) + { + if (ud.m_ffire) minitext(90+60,90+8+8+8+8,"On",0,26); + else minitext(90+60,90+8+8+8+8,"Off",0,26); + } + break; + + case MENU_KEYBOARDKEYS: + if (group == &MG_KEYBOARDSETUPFUNCS) + { + mgametext(160,144+9+3,"Up/Down = Select Action",0,2+8+16); + mgametext(160,144+9+9+3,"Left/Right = Select List",0,2+8+16); + mgametext(160,144+9+9+9+3,"Enter = Modify Delete = Clear",0,2+8+16); + } + break; + + case MENU_MOUSESETUP: + if (entry == &ME_MOUSESETUP_MOUSEAIMING) + { + if (entry->disabled) + { + mgametext(160,140+9+9+9,"Set mouse aim type to toggle on/off",0,2+8+16); + mgametext(160,140+9+9+9+9,"in the Player Setup menu to enable",0,2+8+16); + } + } + break; + + case MENU_MOUSEBTNS: + if (group == &MG_MOUSESETUPBTNS) + { + mgametext(160,160+9,"Up/Down = Select Button",0,2+8+16); + mgametext(160,160+9+9,"Enter = Modify",0,2+8+16); + } + break; + + case MENU_MOUSEADVANCED: + if (group == &MG_MOUSEADVANCED_DAXES) + { + mgametext(160,144+9+9,"Digital axes are not for mouse look",0,2+8+16); + mgametext(160,144+9+9+9,"or for aiming up and down",0,2+8+16); + } + break; + + case MENU_JOYSTICKBTNS: + if (group == &MG_JOYSTICKBTNS) + { + mgametext(160,149,"Up/Down = Select Button",0,2+8+16); + mgametext(160,149+9,"Enter = Modify",0,2+8+16); + } + break; + + case MENU_RESETPLAYER: + mgametext(160,90,"Load last game:",0,2+8+16); + + Bsprintf(tempbuf,"\"%s\"",ud.savegame[g_lastSaveSlot]); + mgametext(160,99,tempbuf,0,2+8+16); + + mgametext(160,99+9,"(Y/N)",0,2+8+16); + break; + + case MENU_LOAD: + M_DrawBackground(); + + for (i = 0; i <= 108; i += 12) + rotatesprite_fs((160+64+91-64)<<16,(i+56)<<16,65536L,0,TEXTBOX,24,0,10); + + rotatesprite_fs(22<<16,97<<16,65536L,0,WINDOWBORDER2,24,0,10); + rotatesprite_fs(180<<16,97<<16,65536L,1024,WINDOWBORDER2,24,0,10); + rotatesprite_fs(99<<16,50<<16,65536L,512,WINDOWBORDER1,24,0,10); + rotatesprite_fs(103<<16,144<<16,65536L,1024+512,WINDOWBORDER1,24,0,10); + + if (ud.savegame[group->currentEntry][0]) + { + rotatesprite_fs(101<<16,97<<16,65536>>1,512,TILE_LOADSHOT,-32,0,4+10+64); + + if (g_oldverSavegame[group->currentEntry]) + { + menutext(53,70,0,0,"Version"); + menutext(48,90,0,0,"Mismatch"); + + Bsprintf(tempbuf,"Saved: %d.%d.%d %d-bit", savehead.majorver, savehead.minorver, + savehead.bytever, 8*savehead.ptrsize); + mgametext(31,104,tempbuf,0,2+8+16); + Bsprintf(tempbuf,"Our: %d.%d.%d %d-bit", SV_MAJOR_VER, SV_MINOR_VER, BYTEVERSION, + (int32_t)(8*sizeof(intptr_t))); + mgametext(31+16,QUOTE_SAVE_BAD_VERSION,tempbuf,0,2+8+16); + } + + Bsprintf(tempbuf,"Players: %-2d ", savehead.numplayers); + mgametext(160,156,tempbuf,0,2+8+16); + Bsprintf(tempbuf,"Episode: %-2d / Level: %-2d / Skill: %-2d", + 1+savehead.volnum, 1+savehead.levnum, savehead.skill); + mgametext(160,168,tempbuf,0,2+8+16); + if (savehead.volnum == 0 && savehead.levnum == 7) + mgametext(160,180,savehead.boardfn,0,2+8+16); + } + else + menutext(69,70,0,0,"Empty"); + break; + + case MENU_SAVE: + M_DrawBackground(); + + for (i = 0; i <= 108; i += 12) + rotatesprite_fs((160+64+91-64)<<16,(i+56)<<16,65536L,0,TEXTBOX,24,0,10); + + rotatesprite_fs(22<<16,97<<16,65536L,0,WINDOWBORDER2,24,0,10); + rotatesprite_fs(180<<16,97<<16,65536L,1024,WINDOWBORDER2,24,0,10); + rotatesprite_fs(99<<16,50<<16,65536L,512,WINDOWBORDER1,24,0,10); + rotatesprite_fs(103<<16,144<<16,65536L,1024+512,WINDOWBORDER1,24,0,10); + + if (ud.savegame[group->currentEntry][0]) + { + j = 0; + for (i = 0; i < 10; ++i) + if (((MenuString_t*)group->entrylist[i]->entry)->editfield) + j |= 1; + + rotatesprite_fs(101<<16,97<<16,65536L>>1,512,j?TILE_SAVESHOT:TILE_LOADSHOT,-32,0,4+10+64); + + if (g_oldverSavegame[group->currentEntry]) + { + menutext(53,70,0,0,"Version"); + menutext(48,90,0,0,"Mismatch"); + + Bsprintf(tempbuf,"Saved: %d.%d.%d %d-bit", savehead.majorver, savehead.minorver, + savehead.bytever, 8*savehead.ptrsize); + mgametext(31,104,tempbuf,0,2+8+16); + Bsprintf(tempbuf,"Our: %d.%d.%d %d-bit", SV_MAJOR_VER, SV_MINOR_VER, BYTEVERSION, + (int32_t)(8*sizeof(intptr_t))); + mgametext(31+16,QUOTE_SAVE_BAD_VERSION,tempbuf,0,2+8+16); + } + } + else + menutext(69,70,0,0,"Empty"); + + Bsprintf(tempbuf,"Players: %-2d ",ud.multimode); + mgametext(160,156,tempbuf,0,2+8+16); + Bsprintf(tempbuf,"Episode: %-2d / Level: %-2d / Skill: %-2d",1+ud.volume_number,1+ud.level_number,ud.player_skill); + mgametext(160,168,tempbuf,0,2+8+16); + if (ud.volume_number == 0 && ud.level_number == 7) + mgametext(160,180,currentboardfilename,0,2+8+16); + break; + + case MENU_LOADVERIFY: + mgametext(160,90,"Load game:",0,2+8+16); + Bsprintf(tempbuf,"\"%s\"",ud.savegame[MG_LOAD.currentEntry]); + mgametext(160,99,tempbuf,0,2+8+16); + mgametext(160,99+9,"(Y/N)",0,2+8+16); + break; + + case MENU_SAVEVERIFY: + mgametext(160,90,"Overwrite previous saved game?",0,2+8+16); + mgametext(160,90+9,"(Y/N)",0,2+8+16); + break; + + case MENU_NEWVERIFY: + mgametext(160,90,"Abort this game?",0,2+8+16); + mgametext(160,90+9,"(Y/N)",0,2+8+16); + break; + + case MENU_QUIT: + case MENU_QUIT_INGAME: + mgametext(MENU_MARGIN_CENTER,90,"Are you sure you want to quit?",0,2+8+16); + mgametext(MENU_MARGIN_CENTER,99,"(Y/N)",0,2+8+16); + break; + + case MENU_QUITTOTITLE: + mgametext(MENU_MARGIN_CENTER,90,"Quit to Title?",0,2+8+16); + mgametext(MENU_MARGIN_CENTER,99,"(Y/N)",0,2+8+16); + break; + + case MENU_NETWAITMASTER: + G_DrawFrags(); + mgametext(160,50,"Waiting for master",0,2+8+16); + mgametext(160,59,"to select level",0,2+8+16); + break; + + case MENU_NETWAITVOTES: + G_DrawFrags(); + mgametext(160,90,"Waiting for votes",0,2); + break; + + case MENU_ORDERING: + case MENU_ORDERING2: + case MENU_ORDERING3: + case MENU_ORDERING4: + rotatesprite_fs(0,0,65536L,0,ORDERING+g_currentMenu-MENU_ORDERING,0,0,10+16+64); + break; + + case MENU_STORY: + rotatesprite_fs(0,0,65536L,0,TEXTSTORY,0,0,10+16+64); + break; + + case MENU_F1HELP: + rotatesprite_fs(0,0,65536L,0,F1HELP,0,0,10+16+64); + break; - switch (g_currentMenu) - { case MENU_BUYDUKE: - x = M_Probe(326,190,0,1); mgametext(160,41-8,"You are playing the shareware",0,2+8+16); mgametext(160,50-8,"version of Duke Nukem 3D. While",0,2+8+16); mgametext(160,59-8,"this version is really cool, you",0,2+8+16); @@ -866,624 +1941,870 @@ void M_DisplayMenus(void) mgametext(160,122+8,"Steam or the Google Play Store",0,2+8+16); mgametext(160,131+8,"to upgrade to the full registered",0,2+8+16); mgametext(160,139+8,"version of Duke Nukem 3D.",0,2+8+16); + mgametext(160,148+16,"Press any key...",0,2+8+16); - - if (x >= -1) M_ChangeMenu(MENU_EPISODE); break; - case MENU_NETWORK: - M_DrawTopBar("Network Game"); - - x = M_Probe(160,100-18,18,3); - - if (x == -1) M_ChangeMenu(MENU_MAIN); - else if (x == 2) M_ChangeMenu(MENU_NETHOST); - else if (x == 1) M_ChangeMenu(MENU_NETJOIN); - else if (x == 0) M_ChangeMenu(MENU_PLAYER); - - menutext(160,100-18,MENUHIGHLIGHT(0),0,"Player Setup"); - menutext(160,100,MENUHIGHLIGHT(1),0,"Join Game"); - menutext(160,100+18,MENUHIGHLIGHT(2),0,"Host Game"); - break; - - case MENU_PLAYER: - case MENU_PLAYERNAME: - M_DrawTopBar("Player Setup"); - margin = MENU_MARGIN_REGULAR; + case MENU_CREDITS: + case MENU_CREDITS2: + case MENU_CREDITS3: + if (!VOLUMEALL || !PLUTOPAK) { - int32_t io, ii, yy = 37, d=margin+140, enabled; - const char *opts[] = + // pre-Atomic credits where there are not tiles devoted to them + + M_DrawBackground(); + + switch (g_currentMenu) { - "Name", - "-", - "Color", - "-", - "Team", - "-", - "-", - "Auto aim", - "Mouse aim", - "-", - "-", - "Switch weapons on pickup", - "Switch weapons when empty", - "-", - "-", - "Multiplayer macros", - NULL + case MENU_CREDITS: + m = 20; + l = 33; + + shadowminitext(m, l, "Original Concept", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Todd Replogle and Allen H. Blum III", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "Produced & Directed By", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Greg Malone", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "Executive Producer", 12, 10+16+128); l += 7; + shadowminitext(m, l, "George Broussard", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "BUILD Engine", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Ken Silverman", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "Game Programming", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Todd Replogle", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "3D Engine/Tools/Net", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Ken Silverman", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "Network Layer/Setup Program", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Mark Dochtermann", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "Map Design", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Allen H. Blum III", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Richard Gray", 12, 10+16+128); l += 7; + + m = 180; + l = 33; + + shadowminitext(m, l, "3D Modeling", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Chuck Jones", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Sapphire Corporation", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "Artwork", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Dirk Jones, Stephen Hornback", 12, 10+16+128); l += 7; + shadowminitext(m, l, "James Storey, David Demaret", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Douglas R. Wood", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "Sound Engine", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Jim Dose", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "Sound & Music Development", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Robert Prince", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Lee Jackson", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "Voice Talent", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Lani Minella - Voice Producer", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Jon St. John as \"Duke Nukem\"", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "Graphic Design", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Packaging, Manual, Ads", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Robert M. Atkins", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Michael Hadwin", 12, 10+16+128); l += 7; + break; + + case MENU_CREDITS2: + m = 20; + l = 33; + + shadowminitext(m, l, "Special Thanks To", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Steven Blackburn, Tom Hall", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Scott Miller, Joe Siegler", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Terry Nagy, Colleen Compton", 12, 10+16+128); l += 7; + shadowminitext(m, l, "HASH, Inc., FormGen, Inc.", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "The 3D Realms Beta Testers", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "Nathan Anderson, Wayne Benner", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Glenn Brensinger, Rob Brown", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Erik Harris, Ken Heckbert", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Terry Herrin, Greg Hively", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Hank Leukart, Eric Baker", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Jeff Rausch, Kelly Rogers", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Mike Duncan, Doug Howell", 12, 10+16+128); l += 7; + shadowminitext(m, l, "Bill Blair", 12, 10+16+128); l += 7; + + m = 160; + l = 33; + + shadowminitext(m, l, "Company Product Support", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "The following companies were cool", 12, 10+16+128); l += 7; + shadowminitext(m, l, "enough to give us lots of stuff", 12, 10+16+128); l += 7; + shadowminitext(m, l, "during the making of Duke Nukem 3D.", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "Altec Lansing Multimedia", 12, 10+16+128); l += 7; + shadowminitext(m, l, "for tons of speakers and the", 12, 10+16+128); l += 7; + shadowminitext(m, l, "THX-licensed sound system.", 12, 10+16+128); l += 7; + shadowminitext(m, l, "For info call 1-800-548-0620", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "Creative Labs, Inc.", 12, 10+16+128); l += 7; + l += 3; + shadowminitext(m, l, "Thanks for the hardware, guys.", 12, 10+16+128); l += 7; + break; + + case MENU_CREDITS3: + m = MENU_MARGIN_CENTER; + mgametext(m,50, "Duke Nukem is a trademark of",0,2+8+16); + mgametext(m,50+9, "3D Realms Entertainment",0,2+8+16); + + mgametext(m,50+9+9+9, "Duke Nukem",0,2+8+16); + mgametext(m,50+9+9+9+9,"(C) 1996 3D Realms Entertainment",0,2+8+16); + + if (VOLUMEONE) + { + mgametext(m,106, "Please read LICENSE.DOC for shareware",0,2+8+16); + mgametext(m,106+9, "distribution grants and restrictions.",0,2+8+16); + } + + mgametext(m,VOLUMEONE?134:115, "Made in Dallas, Texas USA",0,2+8+16); + break; + } + } + else + rotatesprite_fs(160<<16,200<<15,65536L,0,2504+g_currentMenu-MENU_CREDITS,0,0,10+64); + break; + case MENU_CREDITS4: // JBF 20031220 + M_DrawBackground(); + + l = 7; + + mgametext(160,38-l,"Management, Design and Production",0,2+8+16); + creditsminitext(160, 38+10-l, "Richard \"TerminX\" Gobeille", 8, 10+16+128); + +#ifndef POLYMER + mgametext(160,58-l,"Rendering and Support Programming",0,2+8+16); +#else + mgametext(160,58-l,"Polymer Rendering System by",0,2+8+16); +#endif + creditsminitext(160, 58+10-l, "Pierre-Loup \"Plagman\" Griffais", 8, 10+16+128); + + mgametext(160,78-l,"Engine and Game Programming",0,2+8+16); + creditsminitext(160, 78+10-l, "Philipp \"Helixhorned\" Kutin", 8, 10+16+128); + creditsminitext(160, 78+7+10-l, "Evan \"Hendricks266\" Ramos", 8, 10+16+128); + + mgametext(160,98+7-l,"Based on \"JFDuke3D\" by",0,2+8+16); + creditsminitext(160, 98+7+10-l, "Jonathon \"JonoF\" Fowler", 8, 10+16+128); + + mgametext(160,118+7-l,"Original \"EDuke\" Concept",0,2+8+16); + creditsminitext(160, 118+7+10-l, "Matt \"Matteus\" Saettler", 8, 10+16+128); + + mgametext(160,138+7-l,"BUILD Engine by",0,2+8+16); + creditsminitext(160, 138+7+10-l, "Ken \"Awesoken\" Silverman", 8, 10+16+128); + +#ifdef __ANDROID__ + mgametext(160, 158+7-l, "Android version by", 0, 2+8+16); + creditsminitext(160, 158+7+10-l, "Emile Belanger/Beloko Games", 8, 10+16+128); +#endif + + creditsminitext(160, 138+10+10+10+10+4-l, "Visit www.eduke32.com for news and updates", 8, 10+16+128); + break; + + case MENU_CREDITS5: + M_DrawBackground(); + + l = 7; + + mgametext(160,38-l,"License and Other Contributors",0,2+8+16); + { + const char *header[] = + { + "This program is distributed under the terms of the", + "GNU General Public License version 2 as published by the", + "Free Software Foundation. See GNU.TXT for details.", + " ", + "Thanks to the following people for their contributions:", + " ", + }; + const char *body[] = + { + "Adam Fazakerley", // netcode NAT traversal + "Alan Ondra", // testing + "Bioman", // GTK work, APT repository and package upkeep + "Brandon Bergren", // "Bdragon" - tiles.cfg + "Charlie Honig", // "CONAN" - showview command + "Dan Gaskill", // "DeeperThought" - testing + "David Koenig", // "Bargle" - Merged a couple of things from duke3d_w32 + "Ed Coolidge", // Mapster32 improvements + "Ferry Landzaat", // ? (listed on the wiki page) + "Hunter_rus", // tons of stuff + "James Bentler", // Mapster32 improvements + "Jasper Foreman", // netcode contributions + "Javier Martinez", // "Malone3D" - EDuke 2.1.1 components + "Jeff Hart", // website graphics + "Jonathan Smith", // "Mblackwell" - testing + "Jose del Castillo", // "Renegado" - EDuke 2.1.1 components + "Lachlan McDonald", // official EDuke32 icon + "LSDNinja", // OS X help and testing + "Marcus Herbert", // "rhoenie" - OS X compatibility work + "Matthew Palmer", // "Usurper" - testing and eduke32.com domain + "Ozkan Sezer", // SDL/GTK version checking improvements + "Peter Green", // "Plugwash" - dynamic remapping, custom gametypes + "Peter Veenstra", // "Qbix" - port to 64-bit + "Randy Heit", // random snippets of ZDoom here and there + "Robin Green", // CON array support + "Ryan Gordon", // "icculus" - icculus.org Duke3D port sound code + "Stephen Anthony", // early 64-bit porting work + "Thijs Leenders", // Android icon work + "tueidj", // Wii port + " ", + }; + const char *footer[] = + { + " ", + "BUILD engine technology available under BUILDLIC.", }; - rotatesprite_fs((260)<<16,(24+(tilesizy[APLAYER]>>1))<<16,49152L,0,1441-((((4-(totalclock>>4)))&3)*5),0,probey == 2 ? G_GetTeamPalette(ud.team) : ud.color,10); + const int32_t header_numlines = sizeof(header)/sizeof(char *); + const int32_t body_numlines = sizeof(body)/sizeof(char *); + const int32_t footer_numlines = sizeof(footer)/sizeof(char *); - for (ii=io=0; opts[ii]; ii++) - { - if (opts[ii][0] == '-' && !opts[ii][1]) - { - if (io <= probey) yy += 4; - continue; - } - if (io < probey) yy += 8; - io++; - } - - - if (g_currentMenu == MENU_PLAYER) - { - x = probesm(margin,yy+5,0,io); - - if (x == -1) - { - M_ChangeMenu(MENU_OPTIONS); - probey = 3; - break; - } - - for (ii=io=0; opts[ii]; ii++) - { - if (opts[ii][0] == '-' && !opts[ii][1]) - continue; - enabled = 1; - switch (io) - { - case 0: - if (x == io) - { - strcpy(buf, szPlayerName); - inputloc = strlen(buf); - M_ChangeMenu(MENU_PLAYERNAME); - - I_AdvanceTriggerClear(); - } - break; - - case 1: - i = ud.color; - if (x == io) - { - ud.color++; - if (ud.color > 23) - ud.color = 0; - G_CheckPlayerColor((int32_t *)&ud.color,-1); - } - modval(0,23,(int32_t *)&ud.color,1,probey==1); - G_CheckPlayerColor((int32_t *)&ud.color,i); - if (ud.color != i) - G_UpdatePlayerFromMenu(); - break; - - case 2: - i = ud.team; - if (x == io) - { - ud.team++; - if (ud.team == 4) - ud.team = 0; - } - modval(0,3,(int32_t *)&ud.team,1,probey==2); - if (ud.team != i) - G_UpdatePlayerFromMenu(); - break; - - case 3: - i = ud.config.AutoAim; - if (x == io) - ud.config.AutoAim = (ud.config.AutoAim == 2) ? 0 : ud.config.AutoAim+1; - modval(0,2,(int32_t *)&ud.config.AutoAim,1,probey==3); - if (ud.config.AutoAim != i) - G_UpdatePlayerFromMenu(); - break; - - case 4: - i = ud.mouseaiming; - if (x == io) - ud.mouseaiming = !ud.mouseaiming; - modval(0,1,(int32_t *)&ud.mouseaiming,1,probey==4); - if (ud.mouseaiming != i) - G_UpdatePlayerFromMenu(); - break; - - case 5: - i = 0; - if (ud.weaponswitch & 1) - { - i = 1; - if (ud.weaponswitch & 4) - i = 2; - } - l = i; - if (x == io) - i = (i == 2) ? 0 : i+1; - modval(0,2,(int32_t *)&i,1,probey==5); - if (i != l) - { - if (i > 0) - { - ud.weaponswitch |= 1; - if (i == 2) - ud.weaponswitch |= 4; - else - ud.weaponswitch &= ~4; - } - else - ud.weaponswitch &= ~(1|4); - - G_UpdatePlayerFromMenu(); - } - break; - case 6: - i = 0; - if (ud.weaponswitch & 2) - i = 1; - if (x == io) - i = 1-i; - modval(0,1,(int32_t *)&i,1,probey==6); - if ((ud.weaponswitch & 2 && !i) || (!(ud.weaponswitch & 2) && i)) - { - ud.weaponswitch ^= 2; - G_UpdatePlayerFromMenu(); - } - break; - case 7: - if (x == io) - { - M_ChangeMenu(MENU_MACROS); - } - break; - - default: - break; - } - io++; - } - } - else - { - // because OSD_StripColors needs a valid target and tempbuf is used in _EnterText() - char dummybuf[64]; - x = Menu_EnterText(d-50,37,buf,30,0); - - while (Bstrlen(OSD_StripColors(dummybuf,buf)) > 10) - { - buf[Bstrlen(buf)-1] = '\0'; - inputloc--; - } - - if (x) - { - if (x == 1) - { - if (buf[0] && Bstrcmp(szPlayerName,buf)) - { - Bstrcpy(szPlayerName,buf); - Net_SendClientInfo(); - } - // send name update - } - I_AdvanceTriggerClear(); - - M_ChangeMenu(MENU_PLAYER); - } - } - - yy = 37; - { - for (ii=io=0; opts[ii]; ii++) - { - if (opts[ii][0] == '-' && !opts[ii][1]) - { - yy += 4; - continue; - } - enabled = 1; - switch (io) - { - case 0: - if (g_currentMenu == MENU_PLAYER) - { - mgametext(d-50,yy,szPlayerName,MENUHIGHLIGHT(io),2+8+16); - } - break; - - case 1: - { - const char *s[] = - { "Auto","","","","","","","","","Blue","Red","Green","Gray","Dark gray","Dark green","Brown", - "Dark blue","","","","","Bright red","","Yellow","","" - }; - mgametext(d-50,yy,s[ud.color],MENUHIGHLIGHT(io),2+8+16); - } - break; - - case 2: - { - const char *s[] = { "Blue", "Red", "Green", "Gray" }; - mgametext(d-50,yy,s[ud.team],MENUHIGHLIGHT(io),2+8+16); - } - break; - - case 3: - { - const char *s[] = { "Off", "All weapons", "Bullets only" }; - mgametext(d-50,yy,s[ud.config.AutoAim],MENUHIGHLIGHT(io),2+8+16); - } - break; - - case 4: - mgametext(d-50,yy,ud.mouseaiming?"Hold button":"Toggle on/off",MENUHIGHLIGHT(io),2+8+16); - break; - - case 5: - { - const char *s[] = { "Off", "All weapons", "Fav priority" }; - i = 0; - if (ud.weaponswitch & 1) - { - i = 1; - if (ud.weaponswitch & 4) - i = 2; - } - mgametext(d+45,yy,s[i],MENUHIGHLIGHT(io),2+8+16); - } - break; - - case 6: - mgametext(d+45,yy,ud.weaponswitch&2?"On":"Off",MENUHIGHLIGHT(io),2+8+16); - break; - - default: - break; - } - mgametextpal(margin,yy, opts[ii], enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 10); - io++; - yy += 8; - } - } - - break; - } - case MENU_MACROS: - case MENU_MACROSTYPING: - M_DrawTopBar("Multiplayer Macros"); - - if (g_currentMenu == MENU_MACROS) - { - x = probesm(24,45,8,10); - if (x == -1) - { - M_ChangeMenu(MENU_PLAYER); - probey = 7; - } - else if (x >= 0 && x < MAXRIDECULE) - { - strcpy(buf, ud.ridecule[x]); - inputloc = strlen(buf); - last_menu_pos = probey; - M_ChangeMenu(MENU_MACROSTYPING); - I_AdvanceTriggerClear(); - } - } - else - { - probey = last_menu_pos; - x = Menu_EnterText(26,40+(last_menu_pos<<3),buf,34,0); - if (x) - { - if (x == 1) - { - Bstrcpy(ud.ridecule[last_menu_pos],buf); - } - I_AdvanceTriggerClear(); - M_ChangeMenu(MENU_MACROS); - probey = last_menu_pos; - } - } - for (i=0; i 0) - minitext(90+60,60+8+8+8, SkillNames[ud.m_player_skill],0,26); - else minitext(90+60,60+8+8+8, "None",0,28); - if (ud.m_coop == 0) - { - if (ud.m_marker) minitext(90+60,60+8+8+8+8,"On",0,26); - else minitext(90+60,60+8+8+8+8,"Off",0,26); - } - else if (ud.m_coop == 1) - { - if (ud.m_ffire) minitext(90+60,60+8+8+8+8,"On",0,26); - else minitext(90+60,60+8+8+8+8,"Off",0,26); - } - - menutext(40,50+80,0,0,"Launch Game"); + default: break; + } +} - case MENU_NETOPTIONS: + + +static void M_PreMenuInput(MenuGroup_t *group, MenuEntry_t *entry) +{ + switch (g_currentMenu) { - int32_t c = (320>>1) - 120; - M_DrawTopBar("Net Game Options"); - x = M_Probe(c,57-8,16,8); - - switch (x) + case MENU_KEYBOARDKEYS: + if (group == &MG_KEYBOARDSETUPFUNCS) + { + if (KB_KeyPressed(sc_Delete)) + { + MenuCustom2Col_t *column = (MenuCustom2Col_t*)entry->entry; + char key[2]; + key[0] = ud.config.KeyboardKeys[group->currentEntry][0]; + key[1] = ud.config.KeyboardKeys[group->currentEntry][1]; + *column->column[group->currentColumn] = 0xff; + CONFIG_MapKey(group->currentEntry, ud.config.KeyboardKeys[group->currentEntry][0], key[0], ud.config.KeyboardKeys[group->currentEntry][1], key[1]); + S_PlaySound(KICK_HIT); + KB_ClearKeyDown(sc_Delete); + } + } + break; + + default: + break; + } +} + +static void M_PreMenuOptionListDraw(/*MenuGroup_t *group,*/ MenuEntry_t *entry) +{ + switch (g_currentMenu) + { + case MENU_MOUSEBTNS: + case MENU_MOUSEADVANCED: + case MENU_JOYSTICKBTNS: + case MENU_JOYSTICKAXIS: + mgametext(320>>1,31,"Select a function to assign",0,2+8+16); + + Bsprintf(tempbuf, "to %s", entry->name); + + mgametext(320>>1,31+9,tempbuf,0,2+8+16); + + mgametext(320>>1,161,"Press \"Escape\" To Cancel",0,2+8+16); + break; + } +} + +static int32_t M_PreMenuCustom2ColScreen(MenuGroup_t *group, MenuEntry_t *entry) +{ + if (g_currentMenu == MENU_KEYBOARDKEYS) + { + MenuCustom2Col_t *column = (MenuCustom2Col_t*)entry->entry; + + int32_t sc = KB_GetLastScanCode(); + if (sc != sc_None) + { + char key[2]; + key[0] = ud.config.KeyboardKeys[group->currentEntry][0]; + key[1] = ud.config.KeyboardKeys[group->currentEntry][1]; + + S_PlaySound(PISTOL_BODYHIT); + + *column->column[group->currentColumn] = KB_GetLastScanCode(); + + CONFIG_MapKey(group->currentEntry, ud.config.KeyboardKeys[group->currentEntry][0], key[0], ud.config.KeyboardKeys[group->currentEntry][1], key[1]); + + KB_ClearKeyDown(sc); + + return 1; + } + } + + return 0; +} + +static void M_PreMenuCustom2ColScreenDraw(MenuGroup_t *group, MenuEntry_t *entry) +{ + if (g_currentMenu == MENU_KEYBOARDKEYS) + { + mgametext(320>>1,90,"Press the key to assign as",0,2+8+16); + Bsprintf(tempbuf,"%s for \"%s\"", group->currentColumn?"secondary":"primary", entry->name); + mgametext(320>>1,90+9,tempbuf,0,2+8+16); + mgametext(320>>1,90+9+9+9,"Press \"Escape\" To Cancel",0,2+8+16); + } +} + +static void M_MenuEntryFocus(MenuGroup_t *group/*, MenuEntry_t *entry*/) +{ + switch (g_currentMenu) + { + case MENU_LOAD: + case MENU_SAVE: + G_LoadSaveHeaderNew(group->currentEntry, &savehead); + break; + + default: + break; + } +} + +/* +Functions where a "newValue" or similar is passed are run *before* the linked variable is actually changed. +That way you can compare the new and old values and potentially block the change. +*/ +static void M_MenuEntryLinkActivate(MenuGroup_t *group, MenuEntry_t *entry) +{ + switch (g_currentMenu) + { + case MENU_EPISODE: + if (group == &MG_EPISODE) + { + ud.m_volume_number = group->currentEntry; + ud.m_level_number = 0; + } + break; + + case MENU_SKILL: + { + int32_t skillsound = 0; + + switch (group->currentEntry) { - case -1: - M_ChangeMenu(MENU_NETHOST); - break; case 0: - ud.m_coop++; - if (ud.m_coop == 3) ud.m_coop = 0; + skillsound = JIBBED_ACTOR6; break; case 1: - if (!VOLUMEONE) - { - ud.m_volume_number++; - if (ud.m_volume_number == g_numVolumes) ud.m_volume_number = 0; - if (ud.m_volume_number == 0 && ud.m_level_number > 6) - ud.m_level_number = 0; - if (ud.m_level_number > 10) ud.m_level_number = 0; - } + skillsound = BONUS_SPEECH1; break; case 2: - ud.m_level_number++; - if (!VOLUMEONE) + skillsound = DUKE_GETWEAPON2; + break; + case 3: + skillsound = JIBBED_ACTOR5; + break; + } + + g_skillSoundVoice = S_PlaySound(skillsound); + + ud.m_player_skill = group->currentEntry+1; + if (group->currentEntry == 3) ud.m_respawn_monsters = 1; + else ud.m_respawn_monsters = 0; + + ud.m_monsters_off = ud.monsters_off = 0; + + ud.m_respawn_items = 0; + ud.m_respawn_inventory = 0; + + ud.multimode = 1; + + if (ud.m_volume_number == 3 && (G_GetLogoFlags() & LOGO_NOE4CUTSCENE)==0) + { + flushperms(); + setview(0,0,xdim-1,ydim-1); + clearview(0L); + nextpage(); + } + + G_NewGame_EnterLevel(); + break; + } + + case MENU_JOYSTICKAXES: + M_JOYSTICKAXIS.title = getjoyname(0, group->currentEntry); + MEO_JOYSTICKAXIS_ANALOG.data = &ud.config.JoystickAnalogueAxes[group->currentEntry]; + MEO_JOYSTICKAXIS_SCALE.variable = &ud.config.JoystickAnalogueScale[group->currentEntry]; + MEO_JOYSTICKAXIS_DEAD.variable = &ud.config.JoystickAnalogueDead[group->currentEntry]; + MEO_JOYSTICKAXIS_SATU.variable = &ud.config.JoystickAnalogueSaturate[group->currentEntry]; + MEO_JOYSTICKAXIS_DIGITALNEGATIVE.data = &ud.config.JoystickDigitalFunctions[group->currentEntry][0]; + MEO_JOYSTICKAXIS_DIGITALPOSITIVE.data = &ud.config.JoystickDigitalFunctions[group->currentEntry][1]; + break; + + default: + break; + } + + if (entry == &ME_VIDEOSETUP_APPLY) + { + int32_t pxdim, pydim, pfs, pbpp, prend; + int32_t nxdim, nydim, nfs, nbpp, nrend; + + pxdim = xdim; + pydim = ydim; + pbpp = bpp; + pfs = fullscreen; + prend = getrendermode(); + nxdim = resolution[newresolution].xdim; + nydim = resolution[newresolution].ydim; + nfs = newfullscreen; + + nbpp = (newrendermode == REND_CLASSIC) ? 8 : resolution[newresolution].bppmax; + nrend = newrendermode; + + if (setgamemode(nfs, nxdim, nydim, nbpp) < 0) + { + if (setgamemode(pfs, pxdim, pydim, pbpp) < 0) { - if (ud.m_volume_number == 0 && ud.m_level_number > 6) - ud.m_level_number = 0; + setrendermode(prend); + G_GameExit("Failed restoring old video mode."); + } + else onvideomodechange(pbpp > 8); + } + else onvideomodechange(nbpp > 8); + + g_restorePalette = -1; + G_UpdateScreenArea(); + setrendermode(nrend); + + ud.config.ScreenMode = fullscreen; + ud.config.ScreenWidth = xdim; + ud.config.ScreenHeight = ydim; + ud.config.ScreenBPP = bpp; + } + else if (entry == &ME_SOUND_RESTART) + { + ud.config.MixRate = soundrate; + ud.config.NumVoices = soundvoices; + ud.config.NumBits = soundbits; + + S_SoundShutdown(); + S_MusicShutdown(); + + S_MusicStartup(); + S_SoundStartup(); + + FX_StopAllSounds(); + S_ClearSoundLocks(); + + if (ud.config.MusicToggle == 1) + { + if (ud.recstat != 2 && g_player[myconnectindex].ps->gm&MODE_GAME) + { + if (MapInfo[g_musicIndex].musicfn != NULL) + S_PlayMusic(&MapInfo[g_musicIndex].musicfn[0],g_musicIndex); + } + else S_PlayMusic(&EnvMusicFilename[0][0],MAXVOLUMES*MAXLEVELS); + } + } + else if (entry == &ME_COLCORR_RESET) + { + vid_gamma = DEFAULT_GAMMA; + vid_contrast = DEFAULT_CONTRAST; + vid_brightness = DEFAULT_BRIGHTNESS; + ud.brightness = 0; + setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); + } + else if (entry == &ME_KEYBOARDSETUP_RESET) + CONFIG_SetDefaultKeys((const char (*)[MAXGAMEFUNCLEN])keydefaults); + else if (entry == &ME_KEYBOARDSETUP_RESETCLASSIC) + CONFIG_SetDefaultKeys(oldkeydefaults); + else if (entry == &ME_NETHOST_LAUNCH) + { + // master does whatever it wants + if (g_netServer) + { + Net_FillNewGame(&pendingnewgame, 1); + Net_StartNewGame(); + Net_SendNewGame(1, NULL); + } + else if (voting == -1) + { + Net_SendMapVoteInitiate(); + M_ChangeMenu(MENU_NETWAITVOTES); + } + } +} + +static int32_t M_MenuEntryOptionModify(MenuGroup_t* group, MenuEntry_t *entry, int32_t newOption) +{ + int32_t x; + DukePlayer_t *ps = g_player[myconnectindex].ps; + + if (entry == &ME_GAMESETUP_DEMOREC) + { + if ((ps->gm&MODE_GAME)) + G_CloseDemoWrite(); + } + else if (entry == &ME_GAMESETUP_DM_SHOWPLAYERWEAPONS) + ud.showweapons = newOption; + else if (entry == &ME_GAMESETUP_CONSOLETEXT) + OSD_SetTextMode(newOption); + else if (entry == &ME_GAMESETUP_UPDATES) + ud.config.LastUpdateCheck = 0; + else if (entry == &ME_PLAYER_WEAPSWITCH_PICKUP) + { + ud.weaponswitch &= ~(1|4); + switch (newOption) + { + case 2: + ud.weaponswitch |= 4; + case 1: + ud.weaponswitch |= 1; + break; + default: + break; + } + } + else if (entry == &ME_PLAYER_WEAPSWITCH_EMPTY) + ud.weaponswitch = (ud.weaponswitch&~2) | (newOption ? 2 : 0); +#ifdef USE_OPENGL + else if (entry == &ME_VIDEOSETUP_TEXFILTER) + { + gltexfiltermode = newOption; + gltexapplyprops(); + } + else if (entry == &ME_RENDERERSETUP_ASPECTRATIO) + { + glwidescreen = newOption & 1; + r_usenewaspect = newOption & 2; + } +#ifdef POLYMER + else if (entry == &ME_RENDERERSETUP_ASPECTRATIO_POLYMER) + { + pr_customaspect = MEOSV_RENDERERSETUP_ASPECTRATIO_POLYMER[newOption]; + } +#endif + else if (entry == &ME_RENDERERSETUP_ANISOTROPY) + { + glanisotropy = newOption; + gltexapplyprops(); + } + else if (entry == &ME_RENDERERSETUP_VSYNC) + setvsync(newOption); + else if (entry == &ME_RENDERERSETUP_TEXQUALITY) + { + r_downsize = newOption; + texcache_invalidate(); + resetvideomode(); + if (setgamemode(fullscreen,xdim,ydim,bpp)) + OSD_Printf("restartvid: Reset failed...\n"); + r_downsizevar = r_downsize; + } +#endif + else if (entry == &ME_SOUND) + { + if (newOption == 0) + { + FX_StopAllSounds(); + S_ClearSoundLocks(); + } + } + else if (entry == &ME_SOUND_MUSIC) + { + ud.config.MusicToggle = newOption; + + if (newOption == 0) + S_PauseMusic(1); + else + { + if (ud.recstat != 2 && g_player[myconnectindex].ps->gm&MODE_GAME) + { + if (MapInfo[g_musicIndex].musicfn != NULL) + S_PlayMusic(&MapInfo[g_musicIndex].musicfn[0], g_musicIndex); + } + else S_PlayMusic(&EnvMusicFilename[0][0], MAXVOLUMES*MAXLEVELS); + + S_PauseMusic(0); + } + } + else if (entry == &ME_SOUND_DUKETALK) + ud.config.VoiceToggle = (ud.config.VoiceToggle&~1) | newOption; + else if (entry == &ME_SOUND_DUKEMATCHPLAYER) + ud.config.VoiceToggle = (ud.config.VoiceToggle&~4) | (newOption ? 4 : 0); + else if (entry == &ME_MOUSESETUP_SMOOTH) + CONTROL_SmoothMouse = ud.config.SmoothInput; + else if (entry == &ME_JOYSTICKAXIS_ANALOG) + CONTROL_MapAnalogAxis(MG_JOYSTICKAXES.currentEntry, newOption, controldevice_joystick); + else if (entry == &ME_NETOPTIONS_EPISODE) + { + if (newOption < MAXVOLUMES) + ud.m_volume_number = newOption; + } + else if (entry == &ME_NETOPTIONS_MONSTERS) + { + ud.m_monsters_off = (newOption == MAXSKILLS); + if (newOption < MAXSKILLS) + ud.m_player_skill = newOption; + } + else if (entry == &ME_ADULTMODE) + { + if (newOption) + { + for (x=0; x= 0) + wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra; +#endif } else { - if (ud.m_volume_number == 0 && ud.m_level_number > 5) - ud.m_level_number = 0; + M_ChangeMenu(MENU_ADULTPASSWORD); + return 1; } - if (ud.m_level_number > 10) ud.m_level_number = 0; - break; - case 3: - if (ud.m_monsters_off == 1 && ud.m_player_skill > 0) - ud.m_monsters_off = 0; - - if (ud.m_monsters_off == 0) - { - ud.m_player_skill++; - if (ud.m_player_skill > 3) - { - ud.m_player_skill = 0; - ud.m_monsters_off = 1; - } - } - else ud.m_monsters_off = 0; - - break; - - case 4: - if (ud.m_coop == 0) - ud.m_marker = !ud.m_marker; - break; - - case 5: - if (ud.m_coop == 1) - ud.m_ffire = !ud.m_ffire; - break; - - case 6: - // pick the user map - break; - - case 7: - M_ChangeMenu(MENU_NETHOST); - break; } - - c += 40; - - // if(ud.m_coop==1) mgametext(c+70,57-7-9,"Cooperative Play",0,2+8+16); - // else if(ud.m_coop==2) mgametext(c+70,57-7-9,"DukeMatch (No Spawn)",0,2+8+16); - // else mgametext(c+70,57-7-9,"DukeMatch (Spawn)",0,2+8+16); - mgametext(c+70,57-7-9,GametypeNames[ud.m_coop],0,26); - - mgametext(c+70,57+16-7-9,EpisodeNames[ud.m_volume_number],0,2+8+16); - - mgametext(c+70,57+16+16-7-9,&MapInfo[MAXLEVELS*ud.m_volume_number+ud.m_level_number].name[0],0,2+8+16); - - if (ud.m_monsters_off == 0 || ud.m_player_skill > 0) - mgametext(c+70,57+16+16+16-7-9,SkillNames[ud.m_player_skill],0,2+8+16); - else mgametext(c+70,57+16+16+16-7-9,"None",0,2+8+16); - - if (ud.m_coop == 0) - { - if (ud.m_marker) - mgametext(c+70,57+16+16+16+16-7-9,"On",0,2+8+16); - else mgametext(c+70,57+16+16+16+16-7-9,"Off",0,2+8+16); - } - - if (ud.m_coop == 1) - { - if (ud.m_ffire) - mgametext(c+70,57+16+16+16+16+16-7-9,"On",0,2+8+16); - else mgametext(c+70,57+16+16+16+16+16-7-9,"Off",0,2+8+16); - } - - c -= 44; - - menutext(c,57-9,MENUHIGHLIGHT(0),0,"Game Type"); - - sprintf(tempbuf,"Episode %d",ud.m_volume_number+1); - menutext(c,57+16-9,MENUHIGHLIGHT(1),0,tempbuf); - - sprintf(tempbuf,"Level %d",ud.m_level_number+1); - menutext(c,57+16+16-9,MENUHIGHLIGHT(2),0,tempbuf); - - menutext(c,57+16+16+16-9,MENUHIGHLIGHT(3),0,"Monsters"); - - if (ud.m_coop == 0) - menutext(c,57+16+16+16+16-9,MENUHIGHLIGHT(4),0,"Markers"); - else - menutext(c,57+16+16+16+16-9,MENUHIGHLIGHT(4),1,"Markers"); - - if (ud.m_coop == 1) - menutext(c,57+16+16+16+16+16-9,MENUHIGHLIGHT(5),0,"Fr. Fire"); - else menutext(c,57+16+16+16+16+16-9,MENUHIGHLIGHT(5),1,"Fr. Fire"); - - if (VOLUMEALL) - { - menutext(c,57+16+16+16+16+16+16-9,MENUHIGHLIGHT(6),boardfilename[0] == 0,"User Map"); - if (boardfilename[0] != 0) - mgametext(c+70+44,57+16+16+16+16+16,boardfilename,0,2+8+16); - } - else - { - menutext(c,57+16+16+16+16+16+16-9,MENUHIGHLIGHT(6),1,"User Map"); - } - - menutext(c,57+16+16+16+16+16+16+16-9,MENUHIGHLIGHT(7),0,"Accept"); } + + if (g_currentMenu == MENU_PLAYER && entry != &ME_PLAYER_MACROS) + G_UpdatePlayerFromMenu(); + + switch (g_currentMenu) + { + case MENU_MOUSEBTNS: + case MENU_MOUSEADVANCED: + case MENU_JOYSTICKBTNS: + case MENU_JOYSTICKAXIS: + if (group == &MG_MOUSESETUPBTNS) + { + CONTROL_MapButton(newOption, MenuMouseDataIndex[group->currentEntry][0], MenuMouseDataIndex[group->currentEntry][1], controldevice_mouse); + CONTROL_FreeMouseBind(MenuMouseDataIndex[group->currentEntry][0]); + } + else if (group == &MG_MOUSEADVANCED_DAXES) + { + CONTROL_MapDigitalAxis(group->currentEntry>>1, newOption, group->currentEntry&1, controldevice_mouse); + } + else if (group == &MG_JOYSTICKBTNS) + { + CONTROL_MapButton(newOption, group->currentEntry>>1, group->currentEntry&1, controldevice_joystick); + } + else if (group == &MG_JOYSTICKAXIS_DIGITAL) + { + CONTROL_MapDigitalAxis(group->currentEntry>>1, newOption, group->currentEntry&1, controldevice_joystick); + } + break; + } + + return 0; +} + +static void M_MenuCustom2ColScreen(MenuGroup_t *group/*, MenuEntry_t *entry*/) +{ + if (group == &MG_KEYBOARDSETUPFUNCS) + { + KB_FlushKeyboardQueue(); + KB_ClearLastScanCode(); + } +} + +static int32_t M_MenuEntryRangeInt32Modify(MenuEntry_t *entry, int32_t newValue) +{ + if (entry == &ME_GAMESETUP_SCREENSIZE) + G_SetViewportShrink(newValue - vpsize); + else if (entry == &ME_GAMESETUP_SBARSIZE) + G_SetStatusBarScale(newValue); + else if (entry == &ME_SOUND_VOLUME_MASTER) + { + FX_SetVolume(newValue); + S_MusicVolume(MASTER_VOLUME(ud.config.MusicVolume)); + } + else if (entry == &ME_SOUND_VOLUME_MUSIC) + S_MusicVolume(MASTER_VOLUME(newValue)); + else if (entry == &ME_MOUSEADVANCED_SCALEX) + CONTROL_SetAnalogAxisScale(0, newValue, controldevice_mouse); + else if (entry == &ME_MOUSEADVANCED_SCALEY) + CONTROL_SetAnalogAxisScale(1, newValue, controldevice_mouse); + else if (entry == &ME_JOYSTICKAXIS_SCALE) + CONTROL_SetAnalogAxisScale(MG_JOYSTICKAXES.currentEntry, newValue, controldevice_joystick); + else if (entry == &ME_JOYSTICKAXIS_DEAD) + setjoydeadzone(MG_JOYSTICKAXES.currentEntry, newValue, *MEO_JOYSTICKAXIS_SATU.variable); + else if (entry == &ME_JOYSTICKAXIS_SATU) + setjoydeadzone(MG_JOYSTICKAXES.currentEntry, *MEO_JOYSTICKAXIS_DEAD.variable, newValue); + + return 0; +} + +static int32_t M_MenuEntryRangeFloatModify(MenuEntry_t *entry, float newValue) +{ + if (entry == &ME_RENDERERSETUP_AMBIENT) + r_ambientlightrecip = 1.f/newValue; + + return 0; +} + +static int32_t M_MenuEntryRangeDoubleModify(MenuEntry_t *entry/*, double newValue*/) +{ + if (entry == &ME_COLCORR_GAMMA) + { + ud.brightness = GAMMA_CALC<<2; + setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); + } + else if (entry == &ME_COLCORR_CONTRAST || entry == &ME_COLCORR_BRIGHTNESS) + setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); + + return 0; +} + +static uint32_t save_xxh = 0; + +static void M_MenuEntryStringActivate(MenuGroup_t *group/*, MenuEntry_t *entry*/) +{ + switch (g_currentMenu) + { + case MENU_SAVE: + if (!save_xxh) + save_xxh = XXH32((uint8_t *)&ud.savegame[group->currentEntry][0], 19, 0xDEADBEEF); + if (ud.savegame[group->currentEntry][0]) + M_ChangeMenu(MENU_SAVEVERIFY); break; - case MENU_NETJOIN: - case MENU_NETJOINSERVER: // editing server - case MENU_NETJOINPORT: // editing port - M_DrawTopBar("Join Network Game"); + default: + break; + } +} - if (g_currentMenu == MENU_NETJOIN) +static void M_MenuEntryStringSubmit(/*MenuGroup_t *group, MenuEntry_t *entry, char *input*/) +{ + switch (g_currentMenu) + { + case MENU_SAVE: + // dirty hack... char 127 in last position indicates an auto-filled name + if (ud.savegame[MG_SAVE.currentEntry][0] == 0 || (ud.savegame[MG_SAVE.currentEntry][20] == 127 && + save_xxh == XXH32((uint8_t *)&ud.savegame[MG_SAVE.currentEntry][0], 19, 0xDEADBEEF))) { - x = M_Probe(46,50,20,3); - - if (x == -1) - { - M_ChangeMenu(MENU_NETWORK); - probey = 1; - } - else if (x == 0) - { - strcpy(buf, "localhost"); - inputloc = strlen(buf); - M_ChangeMenu(MENU_NETJOINSERVER); - } - else if (x == 1) - { - strcpy(buf, "19014"); - inputloc = strlen(buf); - M_ChangeMenu(MENU_NETJOINPORT); - } - else if (x == 2) - {} - I_AdvanceTriggerClear(); - } - else if (g_currentMenu == MENU_NETJOINSERVER) - { - x = Menu_EnterText(40+100,50-9,buf,31,0); - if (x) - { - if (x == 1) - { - //strcpy(szPlayerName,buf); - } - - I_AdvanceTriggerClear(); - - M_ChangeMenu(MENU_NETJOIN); - } - } - else if (g_currentMenu == MENU_NETJOINPORT) - { - x = Menu_EnterText(40+100,50+20-9,buf,5,997); - if (x) - { - if (x == 1) - { - //strcpy(szPlayerName,buf); - } - - I_AdvanceTriggerClear(); - - M_ChangeMenu(MENU_NETJOIN); - } + Bstrncpy(&ud.savegame[MG_SAVE.currentEntry][0], MapInfo[ud.volume_number * MAXLEVELS + ud.level_number].name, 19); + ud.savegame[MG_SAVE.currentEntry][20] = 127; } - menutext(40,50,0,0,"Server"); - if (g_currentMenu != MENU_NETJOINSERVER) mgametext(40+100,50-9,"server",0,2+8+16); + G_SavePlayerMaybeMulti(MG_SAVE.currentEntry); - menutext(40,50+20,0,0,"Port"); - if (g_currentMenu != MENU_NETJOINPORT) + g_lastSaveSlot = MG_SAVE.currentEntry; + g_player[myconnectindex].ps->gm = MODE_GAME; + + if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) { - sprintf(tempbuf,"%d",19014); - mgametext(40+100,50+20-9,tempbuf,0,2+8+16); + ready2send = 1; + totalclock = ototalclock; } - - menutext(160,50+20+20,0,0,"Connect"); - - - // ADDRESS - // PORT - // CONNECT + save_xxh = 0; break; + default: + break; + } +} + +static void M_MenuEntryStringCancel(/*MenuGroup_t *group, MenuEntry_t *entry*/) +{ + switch (g_currentMenu) + { + case MENU_SAVE: + save_xxh = 0; + ReadSaveGameHeaders(); + break; + + default: + break; + } +} + +/* +This is polled when the menu code is populating the screen but for some reason doesn't have the data. +*/ +static int32_t M_MenuEntryOptionSource(MenuEntry_t *entry, int32_t currentValue) +{ + if (entry == &ME_GAMESETUP_CONSOLETEXT) + return OSD_GetTextMode(); + else if (entry == &ME_PLAYER_WEAPSWITCH_PICKUP) + return (ud.weaponswitch & 1) ? ((ud.weaponswitch & 4) ? 2 : 1) : 0; + else if (entry == &ME_PLAYER_WEAPSWITCH_EMPTY) + return (ud.weaponswitch & 2) ? 1 : 0; +#ifdef USE_OPENGL + else if (entry == &ME_RENDERERSETUP_ASPECTRATIO) + return r_usenewaspect ? 2 : glwidescreen; +#ifdef POLYMER + else if (entry == &ME_RENDERERSETUP_ASPECTRATIO_POLYMER) + return clamp(currentValue, 0, ARRAY_SIZE(MEOSV_RENDERERSETUP_ASPECTRATIO_POLYMER)-1); +#endif +#endif + else if (entry == &ME_SOUND_DUKETALK) + return ud.config.VoiceToggle & 1; + else if (entry == &ME_SOUND_DUKEMATCHPLAYER) + return (ud.config.VoiceToggle & 4) ? 1 : 0; + else if (entry == &ME_NETOPTIONS_EPISODE) + return (currentValue < MAXVOLUMES ? ud.m_volume_number : MAXVOLUMES); + else if (entry == &ME_NETOPTIONS_MONSTERS) + return (ud.m_monsters_off ? MAXSKILLS : ud.m_player_skill); + + return currentValue; +} + +static void M_MenuVerify(int32_t input) +{ + switch (g_currentMenu) + { case MENU_RESETPLAYER: - case MENU_RESETPLAYER2: + if (input) + { + KB_FlushKeyboardQueue(); + KB_ClearKeysDown(); + FX_StopAllSounds(); + S_ClearSoundLocks(); - mgametext(160,90,"Load last game:",0,2+8+16); - - Bsprintf(tempbuf,"\"%s\"",ud.savegame[g_lastSaveSlot]); - mgametext(160,99,tempbuf,0,2+8+16); - - mgametext(160,99+9,"(Y/N)",0,2+8+16); - - x = M_Probe(NUKEICON_CENTER_PROBEX,124+9,0,0); - - if (x == -1 || KB_KeyPressed(sc_N)) + G_LoadPlayerMaybeMulti(g_lastSaveSlot); + } + else { if (sprite[g_player[myconnectindex].ps->i].extra <= 0) { @@ -1491,8 +2812,6 @@ void M_DisplayMenus(void) return; } - KB_ClearKeyDown(sc_N); - g_player[myconnectindex].ps->gm &= ~MODE_MENU; if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) { @@ -1500,163 +2819,12 @@ void M_DisplayMenus(void) totalclock = ototalclock; } } - - if (ProbeTriggers(AdvanceTrigger) || I_AdvanceTrigger() || KB_KeyPressed(sc_Y)) - { - I_AdvanceTriggerClear(); - ProbeTriggersClear(AdvanceTrigger); - KB_ClearKeyDown(sc_Y); - - KB_FlushKeyboardQueue(); - KB_ClearKeysDown(); - FX_StopAllSounds(); - S_ClearSoundLocks(); - - G_LoadPlayerMaybeMulti(g_lastSaveSlot); - } - - break; - - case MENU_ADULTMODE: - case MENU_ADULTPASSWORD: - - margin = 60; - M_DrawTopBar("Adult Mode"); - - menutext(margin,50+16,MENUHIGHLIGHT(0),0,"Adult Mode"); - menutext(margin,50+16+16,MENUHIGHLIGHT(1),0,"Enter Password"); - - menutext(margin+160+40,50+16,MENUHIGHLIGHT(0),0,ud.lockout?"Off":"On"); - - if (g_currentMenu == MENU_ADULTPASSWORD) - { - mgametext(160,50+16+16+16+16-12,"Enter Password",0,2+8+16); - x = Menu_EnterText((320>>1),50+16+16+16+16,buf,19, 998); - - if (x) - { - if (ud.pwlockout[0] == 0 || ud.lockout == 0) - strcpy(&ud.pwlockout[0],buf); - else if (strcmp(buf,&ud.pwlockout[0]) == 0) - { - ud.lockout = 0; - buf[0] = 0; -#if 0 - for (x=0; x= 0) - wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra; -#endif - } - M_ChangeMenu(MENU_ADULTMODE); - I_AdvanceTriggerClear(); - } - } - else - { - x = M_Probe(60,50+16,16,2); - if (x == -1) - { - M_ChangeMenu(MENU_GAMESETUP); - probey = 0; - break; - } - - if (x == 0) - { - if (ud.lockout == 1) - { - if (ud.pwlockout[0] == 0) - { - ud.lockout = 0; -#if 0 - for (x=0; x= 0) - wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra; -#endif - } - else - { - buf[0] = 0; - M_ChangeMenu(MENU_ADULTPASSWORD); - inputloc = 0; - KB_FlushKeyboardQueue(); - } - } - else - { - ud.lockout = 1; - - for (x=0; x>1,512,TILE_LOADSHOT,-32,0,4+10+64); - - M_DisplaySaveGameList(); - - Bsprintf(tempbuf,"Players: %-2d ",savehead.numplayers); - mgametext(160,156,tempbuf,0,2+8+16); - - Bsprintf(tempbuf,"Episode: %-2d / Level: %-2d / Skill: %-2d", - 1+savehead.volnum, 1+savehead.levnum, savehead.skill); - mgametext(160,168,tempbuf,0,2+8+16); - - if (savehead.volnum == 0 && savehead.levnum == 7) - mgametext(160,180,savehead.boardfn,0,2+8+16); - - mgametext(160,90,"Load game:",0,2+8+16); - Bsprintf(tempbuf,"\"%s\"",ud.savegame[g_currentMenu-MENU_LOADVERIFY]); - mgametext(160,99,tempbuf,0,2+8+16); - mgametext(160,99+9,"(Y/N)",0,2+8+16); - - x = M_Probe(NUKEICON_CENTER_PROBEX,124+9,0,0); - - if (ProbeTriggers(AdvanceTrigger) || I_AdvanceTrigger() || KB_KeyPressed(sc_Y)) + if (input) { - I_AdvanceTriggerClear(); - ProbeTriggersClear(AdvanceTrigger); - KB_ClearKeyDown(sc_Y); - - g_lastSaveSlot = g_currentMenu-MENU_LOADVERIFY; + g_lastSaveSlot = MG_LOAD.currentEntry; KB_FlushKeyboardQueue(); KB_ClearKeysDown(); @@ -1667,13 +2835,9 @@ void M_DisplayMenus(void) } G_LoadPlayerMaybeMulti(g_lastSaveSlot); - - break; } - - if (x == -1 || KB_KeyPressed(sc_N)) + else { - KB_ClearKeyDown(sc_N); if (g_player[myconnectindex].ps->gm&MODE_GAME) { g_player[myconnectindex].ps->gm &= ~MODE_MENU; @@ -1683,570 +2847,1070 @@ void M_DisplayMenus(void) totalclock = ototalclock; } } - else - { - M_ChangeMenu(MENU_LOAD); - probey = last_load; - } } - - break; - - case MENU_NEWVERIFY: - - x = M_Probe(NUKEICON_CENTER_PROBEX,124,0,0); - - if (ProbeTriggers(AdvanceTrigger) || I_AdvanceTrigger() || KB_KeyPressed(sc_Y)) - { - I_AdvanceTriggerClear(); - ProbeTriggersClear(AdvanceTrigger); - KB_ClearKeyDown(sc_Y); - KB_FlushKeyboardQueue(); - M_ChangeMenu(MENU_EPISODE); - } - if (x == -1 || KB_KeyPressed(sc_N)) - { - KB_ClearKeyDown(sc_N); - if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - g_player[myconnectindex].ps->gm &= ~MODE_MENU; - break; - } - mgametext(160,90,"Abort this game?",0,2+8+16); - mgametext(160,90+9,"(Y/N)",0,2+8+16); - break; case MENU_SAVEVERIFY: - case MENU_SAVEVERIFY2: - case MENU_SAVEVERIFY3: - case MENU_SAVEVERIFY4: - case MENU_SAVEVERIFY5: - case MENU_SAVEVERIFY6: - case MENU_SAVEVERIFY7: - case MENU_SAVEVERIFY8: - case MENU_SAVEVERIFY9: - case MENU_SAVEVERIFY10: - - M_DrawBackground(); - M_DrawTopBar("Save Game"); - - rotatesprite_fs(101<<16,97<<16,65536L>>1,512,TILE_LOADSHOT,-32,0,4+10+64); - Bsprintf(tempbuf,"Players: %-2d ",ud.multimode); - mgametext(160,156,tempbuf,0,2+8+16); - - Bsprintf(tempbuf,"Episode: %-2d / Level: %-2d / Skill: %-2d",1+ud.volume_number,1+ud.level_number,ud.player_skill); - mgametext(160,168,tempbuf,0,2+8+16); - - if (ud.volume_number == 0 && ud.level_number == 7) - mgametext(160,180,boardfilename,0,2+8+16); - - M_DisplaySaveGameList(); - - mgametext(160,90,"Overwrite previous saved game?",0,2+8+16); - mgametext(160,90+9,"(Y/N)",0,2+8+16); - - x = M_Probe(NUKEICON_CENTER_PROBEX,124,0,0); - - if (ProbeTriggers(AdvanceTrigger) || I_AdvanceTrigger() || KB_KeyPressed(sc_Y)) + if (!input) { - I_AdvanceTriggerClear(); - ProbeTriggersClear(AdvanceTrigger); - KB_ClearKeyDown(sc_Y); + save_xxh = 0; + ReadSaveGameHeaders(); - inputloc = strlen(&ud.savegame[g_currentMenu-MENU_SAVEVERIFY][0]); - - M_ChangeMenu(g_currentMenu-MENU_SAVEVERIFY+MENU_SAVETYPING); - - KB_FlushKeyboardQueue(); - break; + ((MenuString_t*)MG_SAVE.entrylist[MG_SAVE.currentEntry]->entry)->editfield = NULL; } - if (x == -1 || KB_KeyPressed(sc_N)) - { - KB_ClearKeyDown(sc_N); - M_ChangeMenu(MENU_SAVE_); - } - break; - case MENU_CREDITS: - case MENU_CREDITS2: - case MENU_CREDITS3: - case MENU_CREDITS4: - case MENU_CREDITS5: - case MENU_CREDITS6: - case MENU_CREDITS7: - case MENU_CREDITS8: - case MENU_CREDITS9: - case MENU_CREDITS10: - margin = MENU_MARGIN_CENTER; - if (!VOLUMEALL || !PLUTOPAK) + case MENU_NEWVERIFY: + if (!input) { - //M_DrawBackground(); - switch (g_currentMenu) + if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) { - case MENU_CREDITS9: - case MENU_CREDITS10: - M_DrawTopBar("About EDuke32"); - break; - default: - M_DrawTopBar("Credits"); - break; + ready2send = 1; + totalclock = ototalclock; } - - l = 9; + g_player[myconnectindex].ps->gm &= ~MODE_MENU; } + break; + + case MENU_QUIT: + case MENU_QUIT_INGAME: + if (input) + G_GameQuit(); else + g_quitDeadline = 0; + break; + + case MENU_QUITTOTITLE: + if (input) { - l = 4; - } - - M_LinearPanels(MENU_CREDITS, MENU_CREDITS+l); - - x = M_Probe(0,0,0,1); - - if (x == -1) - { - M_ChangeMenu(MENU_MAIN); - break; - } - - if (!VOLUMEALL || !PLUTOPAK) - { - switch (g_currentMenu) - { - case MENU_CREDITS: - mgametext(margin,40, "Original Concept",0,2+8+16); - mgametext(margin,40+9, "Todd Replogle",0,2+8+16); - mgametext(margin,40+9+9, "Allen H. Blum III",0,2+8+16); - - mgametext(margin,40+9+9+9+9, "Produced & Directed By",0,2+8+16); - mgametext(margin,40+9+9+9+9+9, "Greg Malone",0,2+8+16); - - mgametext(margin,40+9+9+9+9+9+9+9, "Executive Producer",0,2+8+16); - mgametext(margin,40+9+9+9+9+9+9+9+9, "George Broussard",0,2+8+16); - - mgametext(margin,40+9+9+9+9+9+9+9+9+9+9, "BUILD Engine",0,2+8+16); - mgametext(margin,40+9+9+9+9+9+9+9+9+9+9+9,"Ken Silverman",0,2+8+16); - break; - case MENU_CREDITS2: - mgametext(margin,40, "Game Programming",0,2+8+16); - mgametext(margin,40+9, "Todd Replogle",0,2+8+16); - - mgametext(margin,40+9+9+9, "3D Engine/Tools/Net",0,2+8+16); - mgametext(margin,40+9+9+9+9, "Ken Silverman",0,2+8+16); - - mgametext(margin,40+9+9+9+9+9+9, "Network Layer/Setup Program",0,2+8+16); - mgametext(margin,40+9+9+9+9+9+9+9, "Mark Dochtermann",0,2+8+16); - break; - case MENU_CREDITS3: - mgametext(margin,40, "Map Design",0,2+8+16); - mgametext(margin,40+9, "Allen H. Blum III",0,2+8+16); - mgametext(margin,40+9+9, "Richard Gray",0,2+8+16); - - mgametext(margin,40+9+9+9+9, "3D Modeling",0,2+8+16); - mgametext(margin,40+9+9+9+9+9, "Chuck Jones",0,2+8+16); - mgametext(margin,40+9+9+9+9+9+9, "Sapphire Corporation",0,2+8+16); - - mgametext(margin,40+9+9+9+9+9+9+9+9, "Artwork",0,2+8+16); - mgametext(margin,40+9+9+9+9+9+9+9+9+9, "Dirk Jones, Stephen Hornback",0,2+8+16); - mgametext(margin,40+9+9+9+9+9+9+9+9+9+9, "James Storey, David Demaret",0,2+8+16); - mgametext(margin,40+9+9+9+9+9+9+9+9+9+9+9,"Douglas R. Wood",0,2+8+16); - break; - case MENU_CREDITS4: - mgametext(margin,40, "Sound Engine",0,2+8+16); - mgametext(margin,40+9, "Jim Dose",0,2+8+16); - - mgametext(margin,40+9+9+9, "Sound & Music Development",0,2+8+16); - mgametext(margin,40+9+9+9+9, "Robert Prince",0,2+8+16); - mgametext(margin,40+9+9+9+9+9, "Lee Jackson",0,2+8+16); - - mgametext(margin,40+9+9+9+9+9+9+9, "Voice Talent",0,2+8+16); - mgametext(margin,40+9+9+9+9+9+9+9+9, "Lani Minella - Voice Producer",0,2+8+16); - mgametext(margin,40+9+9+9+9+9+9+9+9+9, "Jon St. John as \"Duke Nukem\"",0,2+8+16); - break; - case MENU_CREDITS5: - mgametext(margin,60, "Graphic Design",0,2+8+16); - mgametext(margin,60+9, "Packaging, Manual, Ads",0,2+8+16); - mgametext(margin,60+9+9, "Robert M. Atkins",0,2+8+16); - mgametext(margin,60+9+9+9, "Michael Hadwin",0,2+8+16); - - mgametext(margin,60+9+9+9+9+9, "Special Thanks To",0,2+8+16); - mgametext(margin,60+9+9+9+9+9+9, "Steven Blackburn, Tom Hall",0,2+8+16); - mgametext(margin,60+9+9+9+9+9+9+9, "Scott Miller, Joe Siegler",0,2+8+16); - mgametext(margin,60+9+9+9+9+9+9+9+9, "Terry Nagy, Colleen Compton",0,2+8+16); - mgametext(margin,60+9+9+9+9+9+9+9+9+9, "HASH, Inc., FormGen, Inc.",0,2+8+16); - break; - case MENU_CREDITS6: - mgametext(margin,49, "The 3D Realms Beta Testers",0,2+8+16); - - mgametext(margin,49+9+9, "Nathan Anderson, Wayne Benner",0,2+8+16); - mgametext(margin,49+9+9+9, "Glenn Brensinger, Rob Brown",0,2+8+16); - mgametext(margin,49+9+9+9+9, "Erik Harris, Ken Heckbert",0,2+8+16); - mgametext(margin,49+9+9+9+9+9, "Terry Herrin, Greg Hively",0,2+8+16); - mgametext(margin,49+9+9+9+9+9+9, "Hank Leukart, Eric Baker",0,2+8+16); - mgametext(margin,49+9+9+9+9+9+9+9, "Jeff Rausch, Kelly Rogers",0,2+8+16); - mgametext(margin,49+9+9+9+9+9+9+9+9, "Mike Duncan, Doug Howell",0,2+8+16); - mgametext(margin,49+9+9+9+9+9+9+9+9+9, "Bill Blair",0,2+8+16); - break; - case MENU_CREDITS7: - mgametext(margin,32, "Company Product Support",0,2+8+16); - - mgametext(margin,32+9+9, "The following companies were cool",0,2+8+16); - mgametext(margin,32+9+9+9, "enough to give us lots of stuff",0,2+8+16); - mgametext(margin,32+9+9+9+9, "during the making of Duke Nukem 3D.",0,2+8+16); - - mgametext(margin,32+9+9+9+9+9+9, "Altec Lansing Multimedia",0,2+8+16); - mgametext(margin,32+9+9+9+9+9+9+9, "for tons of speakers and the",0,2+8+16); - mgametext(margin,32+9+9+9+9+9+9+9+9, "THX-licensed sound system.",0,2+8+16); - mgametext(margin,32+9+9+9+9+9+9+9+9+9, "For info call 1-800-548-0620",0,2+8+16); - - mgametext(margin,32+9+9+9+9+9+9+9+9+9+9+9,"Creative Labs, Inc.",0,2+8+16); - - mgametext(margin,32+9+9+9+9+9+9+9+9+9+9+9+9+9,"Thanks for the hardware, guys.",0,2+8+16); - break; - case MENU_CREDITS8: - mgametext(margin,50, "Duke Nukem is a trademark of",0,2+8+16); - mgametext(margin,50+9, "3D Realms Entertainment",0,2+8+16); - - mgametext(margin,50+9+9+9, "Duke Nukem",0,2+8+16); - mgametext(margin,50+9+9+9+9, "(C) 1996 3D Realms Entertainment",0,2+8+16); - - if (VOLUMEONE) - { - mgametext(margin,106, "Please read LICENSE.DOC for shareware",0,2+8+16); - mgametext(margin,106+9, "distribution grants and restrictions.",0,2+8+16); - } - - mgametext(margin,VOLUMEONE?134:115, "Made in Dallas, Texas USA",0,2+8+16); - break; - case MENU_CREDITS9: - l = 10; - goto cheat_for_port_credits; - case MENU_CREDITS10: - l = 10; - goto cheat_for_port_credits2; - } - break; - } - - // Plutonium pak menus - switch (g_currentMenu) - { - case MENU_CREDITS: - case MENU_CREDITS2: - case MENU_CREDITS3: - rotatesprite_fs(160<<16,200<<15,65536L,0,2504+g_currentMenu-MENU_CREDITS,0,0,10+64); - break; - case MENU_CREDITS4: // JBF 20031220 - M_DrawBackground(); - M_DrawTopBar("About EDuke32"); - -cheat_for_port_credits: - if (g_scriptVersion != 14) l = (-2); - mgametext(160,38-l,"Management, Design and Production",0,2+8+16); - p = "Richard \"TerminX\" Gobeille"; - creditsminitext(160, 38+10-l, p, 8, 10+16+128); - -#ifdef __ANDROID__ - mgametext(160,58-l,"Rendering and Support Programming",0,2+8+16); -#else - mgametext(160,58-l,"Polymer Rendering System by",0,2+8+16); -#endif - p = "Pierre-Loup \"Plagman\" Griffais"; - creditsminitext(160, 58+10-l, p, 8, 10+16+128); - - mgametext(160,78-l,"Engine and Game Programming",0,2+8+16); - p = "Philipp \"Helixhorned\" Kutin"; - creditsminitext(160, 78+10-l, p, 8, 10+16+128); - - mgametext(160,98-l,"Based on \"JFDuke3D\" by",0,2+8+16); - p = "Jonathon \"JonoF\" Fowler"; - creditsminitext(160, 98+10-l, p, 8, 10+16+128); - - mgametext(160,118-l,"Original \"EDuke\" concept",0,2+8+16); - p = "Matt \"Matteus\" Saettler"; - creditsminitext(160, 118+10-l, p, 8, 10+16+128); - - mgametext(160,138-l,"BUILD Engine by",0,2+8+16); - p = "Ken \"Awesoken\" Silverman"; - creditsminitext(160, 138+10-l, p, 8, 10+16+128); - -#ifdef __ANDROID__ - mgametext(160, 158-l, "Android version by", 0, 2+8+16); - p = "Emile Belanger/Beloko Games"; - creditsminitext(160, 158+10-l, p, 8, 10+16+128); -#endif - - p = "Visit www.eduke32.com for news and updates"; - creditsminitext(160, 138+10+10+10+10+4-l, p, 8, 10+16+128); - break; - - case MENU_CREDITS5: - M_DrawBackground(); - M_DrawTopBar("About EDuke32"); - -cheat_for_port_credits2: - if (g_scriptVersion != 14) l = (-2); - mgametext(160,38-l,"License and Other Contributors",0,2+8+16); - { - const char *header[] = - { - "This program is distributed under the terms of the", - "GNU General Public License version 2 as published by the", - "Free Software Foundation. See GNU.TXT for details.", - " ", - "Thanks to the following people for their contributions:", - " ", - }; - const char *body[] = - { - "Adam Fazakerley", // netcode NAT traversal - "Alan Ondra", // testing - "Bioman", // GTK work, APT repository and package upkeep - "Brandon Bergren", // "Bdragon" - tiles.cfg - "Charlie Honig", // "CONAN" - showview command - "Dan Gaskill", // "DeeperThought" - testing - "David Koenig", // "Bargle" - Merged a couple of things from duke3d_w32 - "Ed Coolidge", // Mapster32 improvements - "Evan Ramos", // "Hendricks266" - misc stuff - "Ferry Landzaat", // ? (listed on the wiki page) - "Hunter_rus", // tons of stuff - "James Bentler", // Mapster32 improvements - "Jasper Foreman", // netcode contributions - "Javier Martinez", // "Malone3D" - EDuke 2.1.1 components - "Jeff Hart", // website graphics - "Jonathan Smith", // "Mblackwell" - testing - "Jose del Castillo", // "Renegado" - EDuke 2.1.1 components - "Lachlan McDonald", // official EDuke32 icon - "LSDNinja", // OS X help and testing - "Marcus Herbert", // "rhoenie" - OS X compatibility work - "Matthew Palmer", // "Usurper" - testing and eduke32.com domain - "Ozkan Sezer", // SDL/GTK version checking improvements - "Peter Green", // "Plugwash" - dynamic remapping, custom gametypes - "Peter Veenstra", // "Qbix" - port to 64-bit - "Randy Heit", // random snippets of ZDoom here and there - "Robin Green", // CON array support - "Ryan Gordon", // "icculus" - icculus.org Duke3D port sound code - "Stephen Anthony", // early 64-bit porting work - "Thijs Leenders", // Android icon work - "tueidj", // Wii port - " ", - }; - const char *footer[] = - { - " ", - "BUILD engine technology available under BUILDLIC.", - }; - - const int32_t header_numlines = sizeof(header)/sizeof(char *); - const int32_t body_numlines = sizeof(body)/sizeof(char *); - const int32_t footer_numlines = sizeof(footer)/sizeof(char *); - - i = 0; - for (m=0; mgm = MODE_DEMO; + if (ud.recstat == 1) + G_CloseDemoWrite(); + E_MapArt_Clear(); } break; - case MENU_MAIN: - Menu_Main(); + case MENU_NETWAITVOTES: + if (!input) + Net_SendMapVoteCancel(0); break; - case MENU_MAIN_INGAME: - margin = MENU_MARGIN_CENTER; - rotatesprite_fs(margin<<16,32<<16,65536L,0,INGAMEDUKETHREEDEE,0,0,10); - if (PLUTOPAK) // JBF 20030804 - rotatesprite_fs((margin+100)<<16,36<<16,65536L,0,PLUTOPAKSPRITE+2,(sintable[(totalclock<<4)&2047]>>11),0,2+8); - x = M_Probe(margin,67,16,7); - switch (x) + default: + break; + } +} + +static void M_MenuPasswordSubmit(char *input) +{ + switch (g_currentMenu) + { + case MENU_ADULTPASSWORD: + if (ud.pwlockout[0] == 0 || ud.lockout == 0) + Bstrcpy(&ud.pwlockout[0], input); + else if (Bstrcmp(input, &ud.pwlockout[0]) == 0) + { + ud.lockout = 0; +#if 0 + for (x=0; x= 0) + wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra; +#endif + } + M_ChangeMenu(MENU_ADULTMODE); + break; + + default: + break; + } +} + +static void M_MenuFileSelectInit(MenuFileSelect_t *object) +{ + if (object->destination[0] == 0) Bstrcpy(object->destination, "./"); + Bcorrectfilename(object->destination, 1); + + fnlist_getnames(&object->fnlist, object->destination, object->pattern, 0, 0); + object->finddirshigh = object->fnlist.finddirs; + object->findfileshigh = object->fnlist.findfiles; + object->currentlist = 0; + if (object->findfileshigh) + object->currentlist = 1; + + KB_FlushKeyboardQueue(); +} + +static void M_MenuFileSelect(int32_t input) +{ + switch (g_currentMenu) + { + case MENU_NETUSERMAP: + if ((g_netServer || ud.multimode > 1)) + Net_SendUserMapName(); + case MENU_USERMAP: + if (input) + { + ud.m_volume_number = 0; + ud.m_level_number = 7; + M_ChangeMenu(MENU_SKILL); + } + break; + + default: + break; + } +} + + + + + +static Menu_t* M_FindMenuBinarySearch(MenuID_t query, size_t searchstart, size_t searchend) +{ + const size_t thissearch = (searchstart + searchend) / 2; + const MenuID_t difference = query - Menus[thissearch].menuID; + + if (difference == 0) + return &Menus[thissearch]; + else if (searchstart == searchend) + return NULL; + else if (difference > 0) + { + if (thissearch == searchend) + return NULL; + searchstart = thissearch + 1; + } + else if (difference < 0) + { + if (thissearch == searchstart) + return NULL; + searchend = thissearch - 1; + } + + return M_FindMenuBinarySearch(query, searchstart, searchend); +} + +static Menu_t* M_FindMenu(MenuID_t query) +{ + if ((unsigned) query > (unsigned) Menus[numMenus-1].menuID) + return NULL; + + return M_FindMenuBinarySearch(query, 0, numMenus-1); +} + +void M_ChangeMenu(MenuID_t cm) +{ + Menu_t *search; + int32_t i; + + if (G_HaveEvent(EVENT_CHANGEMENU)) + cm = VM_OnEvent(EVENT_CHANGEMENU, g_player[myconnectindex].ps->i, myconnectindex, -1, cm); + + if (cm == MENU_PREVIOUS) + { + m_currentMenu = m_previousMenu; + g_currentMenu = g_previousMenu; + } + else if (cm == MENU_CLOSE) + { + if (g_player[myconnectindex].ps->gm & MODE_GAME) { - case 0: - if ((!g_netServer && ud.multimode < 2) || ud.recstat == 2) - M_ChangeMenu(MENU_NEWVERIFY); - else - { - M_ChangeMenu(MENU_NETSETUP); - last_main_ingame = 0; - } - break; - case 1: - if (ud.recstat != 2) - { - last_main_ingame = 1; - M_ChangeMenu(MENU_SAVE); - setview(0,0,xdim-1,ydim-1); - } - break; - case 2: - last_main_ingame = 2; - M_ChangeMenu(MENU_LOAD); - break; - case 3: - last_main_ingame = 3; - M_ChangeMenu(MENU_OPTIONS); // JBF 20031205: was 200 - break; - case 4: - last_main_ingame = 4; - KB_FlushKeyboardQueue(); - M_ChangeMenu(MENU_STORY); - break; - case 5: - if (numplayers < 2 && !g_netServer) - { - last_main_ingame = 5; - M_ChangeMenu(MENU_QUITTOTITLE); - } - break; - case 6: - last_main_ingame = 6; - M_ChangeMenu(MENU_QUIT); - break; - case -1: g_player[myconnectindex].ps->gm &= ~MODE_MENU; if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) { ready2send = 1; totalclock = ototalclock; } + } + } + else if (cm >= 0) + { + if ((g_player[myconnectindex].ps->gm&MODE_GAME) && cm == MENU_MAIN) + cm = MENU_MAIN_INGAME; + + search = M_FindMenu(cm); + + if (search == NULL) + return; + + m_previousMenu = m_currentMenu; + m_currentMenu = search; + g_currentMenu = cm; + } + else + return; + + switch (g_currentMenu) + { + case MENU_SAVE: + if (g_player[myconnectindex].ps->gm&MODE_GAME) + { + g_screenCapture = 1; + G_DrawRooms(myconnectindex,65536); + g_screenCapture = 0; + } + break; + + case MENU_VIDEOSETUP: + newresolution = 0; + for (i = 0; i < MAXVALIDMODES; ++i) + { + if (resolution[i].xdim == xdim && resolution[i].ydim == ydim) + { + newresolution = i; + break; + } + } + newrendermode = getrendermode(); + newfullscreen = fullscreen; + break; + + case MENU_SOUND: + case MENU_SOUND_INGAME: + soundrate = ud.config.MixRate; + soundvoices = ud.config.NumVoices; + soundbits = ud.config.NumBits; + break; + + default: + break; + } + + if (m_currentMenu->type == Password) + { + typebuf[0] = 0; + ((MenuPassword_t*)m_currentMenu->object)->input = typebuf; + } + else if (m_currentMenu->type == FileSelect) + M_MenuFileSelectInit((MenuFileSelect_t*)m_currentMenu->object); + else if (m_currentMenu->type == Menu) + { + MenuMenu_t *menu = (MenuMenu_t*)m_currentMenu->object; + MenuGroup_t* currgroup = menu->grouplist[menu->currentGroup]; + // MenuEntry_t* currentry = currgroup->entrylist[currgroup->currentEntry]; + + M_MenuEntryFocus(currgroup/*, currentry*/); + } +} + + + + + + + + + + +void G_CheckPlayerColor(int32_t *color, int32_t prev_color) +{ + size_t i; + + for (i = 0; i < ARRAY_SIZE(MEOSV_PLAYER_COLOR); ++i) + if (*color == MEOSV_PLAYER_COLOR[i]) + return; + + *color = prev_color; +} + + +int32_t M_DetermineMenuSpecialState(MenuEntry_t *entry) +{ + if (entry == NULL) + return 0; + + if (entry->type == String) + { + if (((MenuString_t*)entry->entry)->editfield) + return 1; + } + else if (entry->type == Option) + { + if (((MenuOption_t*)entry->entry)->options->currentEntry >= 0) + return 2; + } + else if (entry->type == Custom2Col) + { + if (((MenuCustom2Col_t*)entry->entry)->screenOpen) + return 2; + } + + return 0; +} + +int32_t M_IsTextInput(Menu_t *cm) +{ + switch (m_currentMenu->type) + { + case Verify: + case Password: + case FileSelect: + case Message: + return 1; + break; + case Panel: + return 0; + break; + case Menu: + { + MenuMenu_t *menu = (MenuMenu_t*)cm->object; + MenuGroup_t *group = menu->grouplist[menu->currentGroup]; + MenuEntry_t *entry = group->entrylist[group->currentEntry]; + return M_DetermineMenuSpecialState(entry); + } + break; + } + + return 0; +} + +static inline int32_t M_BlackTranslucentBackgroundOK(MenuID_t cm) +{ + switch (cm) + { + case MENU_COLCORR: + case MENU_COLCORR_INGAME: + return 0; + break; + default: + return 1; + break; + } + + return 1; +} + +static inline int32_t M_UpdateScreenOK(MenuID_t cm) +{ + switch (cm) + { + case MENU_LOAD: + case MENU_SAVE: + case MENU_LOADVERIFY: + case MENU_SAVEVERIFY: + return 0; + break; + default: + return 1; + break; + } + + return 1; +} + + +/* + Code below this point is entirely general, + so if you want to change or add a menu, + chances are you should scroll up. +*/ + +static void M_ShadePal(MenuTextType_t *font, uint8_t status, int32_t *s, int32_t *p) +{ + *s = (status & (1<<0)) ? (sintable[(totalclock<<5)&2047]>>12) : font->shade_deselected; + *p = (status & (1<<1)) ? font->pal_disabled : font->pal; +} + +static vec2_t M_MenuText(int32_t x, int32_t y, MenuTextType_t *font, const char *t, uint8_t status) +{ + int32_t s, p, ybetween = font->ybetween; + int32_t f = font->textflags; + if (status & (1<<2)) + f |= TEXT_XCENTER; + if (status & (1<<3)) + f |= TEXT_XRIGHT; + if (status & (1<<4)) + { + f |= TEXT_YCENTER | TEXT_YOFFSETZERO; + ybetween = font->yline; // <^ the battle against 'Q' + } + if (status & (1<<5)) + f |= TEXT_LITERALESCAPE; + + M_ShadePal(font, status, &s, &p); + + return G_ScreenText(font->tilenum, x, y, 65536, 0, 0, t, s, p, 2|8|16|ROTATESPRITE_FULL16, 0, font->xspace, font->yline, font->xbetween, ybetween, f, 0, 0, xdim-1, ydim-1); +} + +#if 0 +static vec2_t M_MenuTextSize(int32_t x, int32_t y, MenuTextType_t *font, const char *t, uint8_t status) +{ + int32_t f = font->textflags; + if (status & (1<<5)) + f |= TEXT_LITERALESCAPE; + + return G_ScreenTextSize(font->tilenum, x, y, 65536, 0, t, 2|8|16|ROTATESPRITE_FULL16, font->xspace, font->yline, font->xbetween, font->ybetween, f, 0, 0, xdim-1, ydim-1); +} +#endif + +static int32_t M_FindOptionBinarySearch(MenuOption_t *object, const int32_t query, size_t searchstart, size_t searchend) +{ + const size_t thissearch = (searchstart + searchend) / 2; + const int32_t difference = ((object->options->optionValues == NULL && query < 0) ? object->options->numOptions-1 : query) - ((object->options->optionValues == NULL) ? (int32_t) thissearch : object->options->optionValues[thissearch]); + + if (difference == 0) + return thissearch; + else if (searchstart == searchend) + return -1; + else if (difference > 0) + { + if (thissearch == searchend) + return -1; + searchstart = thissearch + 1; + } + else if (difference < 0) + { + if (thissearch == searchstart) + return -1; + searchend = thissearch - 1; + } + + return M_FindOptionBinarySearch(object, query, searchstart, searchend); +} + +static int32_t M_RunMenu_MenuMenu(MenuMenu_t *menu, MenuEntry_t *currentry, int32_t state) +{ + const int32_t cursorShade = 4-(sintable[(totalclock<<4)&2047]>>11); + int32_t g, rely = INT32_MIN, srcy = INT32_MIN, totalextent = 0; + + menu->ytop = INT32_MAX; + menu->bottomcutoff = INT32_MIN; + + // find min/max + for (g = 0; g < menu->numGroups; ++g) + { + MenuGroup_t *group = menu->grouplist[g]; + + if (group == NULL || group->numEntries == 0) + continue; + + if (group->position->pos.y < menu->ytop) + menu->ytop = group->position->pos.y; + + if (group->position->bottomcutoff > menu->bottomcutoff) + menu->bottomcutoff = group->position->bottomcutoff; + } + + // iterate through menu + for (g = 0; g < menu->numGroups; ++g) + { + MenuGroup_t *group = menu->grouplist[g]; + int32_t e, y; + + if (group == NULL || group->numEntries == 0) + continue; + + y = group->position->pos.y; + + if (y == srcy) + y = rely + group->position->groupspacing; + else + srcy = y; + + for (e = 0; e < group->numEntries; ++e) + { + MenuEntry_t *entry = group->entrylist[e]; + uint8_t status = 0; + int32_t height, x; + // vec2_t textsize; + int32_t dodraw = 1; + + if (entry == NULL) + continue; + + x = group->position->pos.x; + + status |= (g == menu->currentGroup && e == group->currentEntry)<<0; + status |= (entry->disabled)<<1; + status |= (group->position->width == 0)<<2; + + dodraw &= menu->ytop <= y - menu->scrollPos && y - menu->scrollPos + entry->font->yline <= menu->bottomcutoff; + + if (dodraw) + /*textsize =*/ M_MenuText(x, y - menu->scrollPos, entry->font, entry->name, status); + + height = entry->font->yline; // max(textsize.y, entry->font->yline); // bluefont Q ruins this + + status |= (group->position->width < 0)<<3 | (1<<4); + + if (dodraw && (status & (1<<0)) && state != 1) + { + if (status & (1<<2)) + { + rotatesprite_fs((160<<16) + group->position->cursorPosition, y + (height>>1) - menu->scrollPos, group->position->cursorScale, 0, SPINNINGNUKEICON+6-((6+(totalclock>>3))%7), cursorShade, 0, 10); + rotatesprite_fs((160<<16) - group->position->cursorPosition, y + (height>>1) - menu->scrollPos, group->position->cursorScale, 0, SPINNINGNUKEICON+((totalclock>>3)%7), cursorShade, 0, 10); + } + else + rotatesprite_fs(x - group->position->cursorPosition, + y + (height>>1) - menu->scrollPos, group->position->cursorScale, 0, SPINNINGNUKEICON+(((totalclock>>3))%7), cursorShade, 0, 10); + } + + x += klabs(group->position->width); + + if (dodraw) + switch (entry->type) + { + case Dummy: + break; + case Link: + break; + case Option: + { + MenuOption_t *object = (MenuOption_t*)entry->entry; + int32_t currentOption = M_FindOptionBinarySearch(object, object->data == NULL ? M_MenuEntryOptionSource(entry, object->currentOption) : *object->data, 0, object->options->numOptions); + + if (currentOption >= 0) + object->currentOption = currentOption; + + M_MenuText(x, y + (height>>1) - menu->scrollPos, object->font, currentOption < 0 ? MenuCustom : object->options->optionNames[currentOption], status); + break; + } + case Custom2Col: + { + MenuCustom2Col_t *object = (MenuCustom2Col_t*)entry->entry; + M_MenuText(x - ((status & (1<<3)) ? object->columnWidth : 0), y + (height>>1) - menu->scrollPos, object->font, object->key[*object->column[0]], status & ~((group->currentColumn != 0)<<0)); + M_MenuText(x + ((status & (1<<3)) ? 0 : object->columnWidth), y + (height>>1) - menu->scrollPos, object->font, object->key[*object->column[1]], status & ~((group->currentColumn != 1)<<0)); + break; + } + case RangeInt32: + { + MenuRangeInt32_t *object = (MenuRangeInt32_t*)entry->entry; + + int32_t s, p; + const int32_t z = scale(65536, height, tilesizy[SLIDEBAR]<<16); + M_ShadePal(object->font, status, &s, &p); + + if (status & (1<<3)) + x -= scale(tilesizx[SLIDEBAR]<<16, height, tilesizy[SLIDEBAR]<<16); + + rotatesprite_fs(x, y - menu->scrollPos, z, 0, SLIDEBAR, s, entry->disabled ? 1 : 0, 2|8|16|ROTATESPRITE_FULL16); + + rotatesprite_fs( + x + (1<<16) + scale(scale((tilesizx[SLIDEBAR]-2-tilesizx[SLIDEBAR+1])<<16, height, tilesizy[SLIDEBAR]<<16), *object->variable - object->min, object->max - object->min), + y + scale((tilesizy[SLIDEBAR]-tilesizy[SLIDEBAR+1])<<15, height, tilesizy[SLIDEBAR]<<16) - menu->scrollPos, + z, 0, SLIDEBAR+1, s, entry->disabled ? 1 : 0, 2|8|16|ROTATESPRITE_FULL16); + + if (object->displaytype > 0) + { + status |= (1<<3); + + if (object->onehundredpercent == 0) + object->onehundredpercent = object->max; + + switch (object->displaytype) + { + case 1: + Bsprintf(tempbuf, "%d", *object->variable); + break; + case 2: + { + int32_t v; + ftol(((float) *object->variable * 100.) / (float) object->onehundredpercent + 0.5, &v); + Bsprintf(tempbuf, "%d%%", v); + break; + } + case 3: + Bsprintf(tempbuf, "%.2f", (double) *object->variable / (double) object->onehundredpercent); + break; + } + + M_MenuText(x - (4<<16), y + (height>>1) - menu->scrollPos, object->font, tempbuf, status); + } + break; + } + case RangeFloat: + { + MenuRangeFloat_t *object = (MenuRangeFloat_t*)entry->entry; + + int32_t s, p; + const int32_t z = scale(65536, height, tilesizy[SLIDEBAR]<<16); + M_ShadePal(object->font, status, &s, &p); + + if (status & (1<<3)) + x -= scale(tilesizx[SLIDEBAR]<<16, height, tilesizy[SLIDEBAR]<<16); + + rotatesprite_fs(x, y - menu->scrollPos, z, 0, SLIDEBAR, s, p, 2|8|16|ROTATESPRITE_FULL16); + + rotatesprite_fs( + x + (1<<16) + ((float) scale((tilesizx[SLIDEBAR]-2-tilesizx[SLIDEBAR+1])<<16, height, tilesizy[SLIDEBAR]<<16) * (*object->variable - object->min) / (object->max - object->min)), + y + scale((tilesizy[SLIDEBAR]-tilesizy[SLIDEBAR+1])<<15, height, tilesizy[SLIDEBAR]<<16) - menu->scrollPos, + z, 0, SLIDEBAR+1, s, p, 2|8|16|ROTATESPRITE_FULL16); + + if (object->displaytype > 0) + { + status |= (1<<3); + + if (object->onehundredpercent == 0) + object->onehundredpercent = 1.; + + switch (object->displaytype) + { + case 1: + Bsprintf(tempbuf, "%.2f", *object->variable); + break; + case 2: + { + int32_t v; + ftol((*object->variable * 100.) / object->onehundredpercent + 0.5, &v); + Bsprintf(tempbuf, "%d%%", v); + break; + } + case 3: + Bsprintf(tempbuf, "%.2f", *object->variable / object->onehundredpercent); + break; + } + + M_MenuText(x - (4<<16), y + (height>>1) - menu->scrollPos, object->font, tempbuf, status); + } + break; + } + case RangeDouble: + { + MenuRangeDouble_t *object = (MenuRangeDouble_t*)entry->entry; + + int32_t s, p; + const int32_t z = scale(65536, height, tilesizy[SLIDEBAR]<<16); + M_ShadePal(object->font, status, &s, &p); + + if (status & (1<<3)) + x -= scale(tilesizx[SLIDEBAR]<<16, height, tilesizy[SLIDEBAR]<<16); + + rotatesprite_fs(x, y - menu->scrollPos, z, 0, SLIDEBAR, s, p, 2|8|16|ROTATESPRITE_FULL16); + + rotatesprite_fs( + x + (1<<16) + ((double) scale((tilesizx[SLIDEBAR]-2-tilesizx[SLIDEBAR+1])<<16, height, tilesizy[SLIDEBAR]<<16) * (*object->variable - object->min) / (object->max - object->min)), + y + scale((tilesizy[SLIDEBAR]-tilesizy[SLIDEBAR+1])<<15, height, tilesizy[SLIDEBAR]<<16) - menu->scrollPos, + z, 0, SLIDEBAR+1, s, p, 2|8|16|ROTATESPRITE_FULL16); + + if (object->displaytype > 0) + { + status |= (1<<3); + + if (object->onehundredpercent == 0) + object->onehundredpercent = 1.; + + switch (object->displaytype) + { + case 1: + Bsprintf(tempbuf, "%.2f", *object->variable); + break; + case 2: + { + int32_t v; + dtol((*object->variable * 100.) / object->onehundredpercent + 0.5, &v); + Bsprintf(tempbuf, "%d%%", v); + break; + } + case 3: + Bsprintf(tempbuf, "%.2f", *object->variable / object->onehundredpercent); + break; + } + + M_MenuText(x - (4<<16), y + (height>>1) - menu->scrollPos, object->font, tempbuf, status); + } + break; + } + case String: + { + MenuString_t *object = (MenuString_t*)entry->entry; + + if (entry == currentry && object->editfield != NULL) + { + const vec2_t dim = M_MenuText(x, y + (height>>1), object->font, object->editfield, status | (1<<5)); + const int32_t h = max(dim.y, entry->font->yline); + + rotatesprite_fs(x + dim.x + (1<<16) + scale(tilesizx[SPINNINGNUKEICON]<<15, h, tilesizy[SPINNINGNUKEICON]<<16), y + (height>>1) - menu->scrollPos, scale(65536, h, tilesizy[SPINNINGNUKEICON]<<16), 0, SPINNINGNUKEICON+(((totalclock>>3))%7), cursorShade, 0, 10); + } + else + M_MenuText(x, y + (height>>1) - menu->scrollPos, object->font, object->variable, status); + break; + } + } + + // prepare for the next line + entry->ytop = y; + + y += height; + entry->ybottom = y; + totalextent = y; + + y += group->position->entryspacing; + rely = y; + } + } + + menu->totalHeight = totalextent - menu->ytop; + + // draw indicators if applicable + if (totalextent > menu->bottomcutoff) + { + if (menu->scrollPos > 0) + rotatesprite((320 - tilesizx[SELECTDIR])<<16, menu->ytop, 65536, 0, SELECTDIR, 0, 0, 26, 0, 0, xdim-1, scale(ydim, menu->ytop + (tilesizy[SELECTDIR]<<15), 200<<16) - 1); + + if (menu->ytop + menu->totalHeight - menu->scrollPos > menu->bottomcutoff) + rotatesprite((320 - tilesizx[SELECTDIR])<<16, menu->bottomcutoff - (tilesizy[SELECTDIR]<<16), 65536, 0, SELECTDIR, 0, 0, 26, 0, scale(ydim, menu->bottomcutoff - (tilesizy[SELECTDIR]<<15), 200<<16), xdim-1, ydim-1); + } + + return menu->totalHeight; +} + +static void M_RunMenu_MenuOptionList(MenuOption_t *object) +{ + const int32_t cursorShade = 4-(sintable[(totalclock<<4)&2047]>>11); + int32_t e, y = object->options->list->pos.y; + + for (e = 0; e < object->options->numOptions; ++e) + { + uint8_t status = 0; + int32_t height, x; + // vec2_t textsize; + int32_t dodraw = 1; + + x = object->options->list->pos.x; + + status |= (e == object->options->currentEntry)<<0; + status |= (object->options->list->width == 0)<<2; + + dodraw &= object->options->list->pos.y <= y - object->options->scrollPos && y - object->options->scrollPos + object->font->yline <= object->options->list->bottomcutoff; + + if (dodraw) + /*textsize =*/ M_MenuText(x, y - object->options->scrollPos, object->font, object->options->optionNames[e], status); + + height = object->font->yline; // max(textsize.y, object->font->yline); + + status |= (object->options->list->width < 0)<<3 | (1<<4); + + if (dodraw && (status & (1<<0))) + { + if (status & (1<<2)) + { + rotatesprite_fs((160<<16) + object->options->list->cursorPosition, y + (height>>1) - object->options->scrollPos, object->options->list->cursorScale, 0, SPINNINGNUKEICON+6-((6+(totalclock>>3))%7), cursorShade, 0, 10); + rotatesprite_fs((160<<16) - object->options->list->cursorPosition, y + (height>>1) - object->options->scrollPos, object->options->list->cursorScale, 0, SPINNINGNUKEICON+((totalclock>>3)%7), cursorShade, 0, 10); + } + else + rotatesprite_fs(x - object->options->list->cursorPosition, + y + (height>>1) - object->options->scrollPos, object->options->list->cursorScale, 0, SPINNINGNUKEICON+(((totalclock>>3))%7), cursorShade, 0, 10); + } + + // prepare for the next line + y += height; + y += object->options->list->entryspacing; + } + + y -= object->options->list->entryspacing; + + // draw indicators if applicable + if (y > object->options->list->bottomcutoff) + { + if (object->options->scrollPos > 0) + rotatesprite((320 - tilesizx[SELECTDIR])<<16, object->options->list->pos.y, 65536, 0, SELECTDIR, 0, 0, 26, 0, 0, xdim-1, scale(ydim, object->options->list->pos.y + (tilesizy[SELECTDIR]<<15), 200<<16) - 1); + + if (y - object->options->scrollPos > object->options->list->bottomcutoff) + rotatesprite((320 - tilesizx[SELECTDIR])<<16, object->options->list->bottomcutoff - (tilesizy[SELECTDIR]<<16), 65536, 0, SELECTDIR, 0, 0, 26, 0, scale(ydim, object->options->list->bottomcutoff - (tilesizy[SELECTDIR]<<15), 200<<16), xdim-1, ydim-1); + } +} + +static void M_RunMenu(Menu_t *cm) +{ + const int32_t cursorShade = 4-(sintable[(totalclock<<4)&2047]>>11); + + switch (cm->type) + { + case Verify: + { + MenuVerify_t *object = (MenuVerify_t*)cm->object; + + M_PreMenu(cm->menuID); + + rotatesprite_fs(object->cursorpos.x, object->cursorpos.y, 65536, 0, SPINNINGNUKEICON+(((totalclock>>3))%7), cursorShade, 0, 10); + + M_PreMenuDraw(cm->menuID, NULL, NULL); break; } - if (KB_KeyPressed(sc_Q)) - M_ChangeMenu(MENU_QUIT); - - menutext(margin,67 ,MENUHIGHLIGHT(0),0,"New Game"); - menutext(margin,67+16 ,MENUHIGHLIGHT(1),0,"Save Game"); - menutext(margin,67+16+16 ,MENUHIGHLIGHT(2),0,"Load Game"); - - menutext(margin,67+16+16+16 ,MENUHIGHLIGHT(3),0,"Options"); - if (!VOLUMEALL) + case Message: { - menutext(margin,67+16+16+16+16 ,MENUHIGHLIGHT(4),0,"How To Order"); - } - else - { - menutext(margin,67+16+16+16+16 ,MENUHIGHLIGHT(4),0,"Help"); - } - if (g_netServer || numplayers > 1) - menutext(margin,67+16+16+16+16+16 ,MENUHIGHLIGHT(5),1,"Quit To Title"); - else menutext(margin,67+16+16+16+16+16 ,MENUHIGHLIGHT(5),0,"Quit To Title"); - menutext(margin,67+16+16+16+16+16+16,MENUHIGHLIGHT(6),0,"Quit Game"); - break; + MenuMessage_t *object = (MenuMessage_t*)cm->object; - case MENU_EPISODE: - M_DrawTopBar("Select An Episode"); - x = M_Probe(160,VOLUMEONE?60:60-(g_numVolumes*2),20,VOLUMEONE?3:g_numVolumes+1); - if (x >= 0) - { - if (VOLUMEONE) - { - if (x > 0) - M_ChangeMenu(MENU_BUYDUKE); - else - { - ud.m_volume_number = x; - ud.m_level_number = 0; - last_episode = x; - M_ChangeMenu(MENU_SKILL); - } - } + rotatesprite_fs(object->cursorpos.x, object->cursorpos.y, 65536, 0, SPINNINGNUKEICON+(((totalclock>>3))%7), cursorShade, 0, 10); - if (!VOLUMEONE) - { - if (x == g_numVolumes /*&& boardfilename[0]*/) - { - //ud.m_volume_number = 0; - //ud.m_level_number = 7; - currentlist = 1; - last_episode = x; - M_ChangeMenu(MENU_USERMAP); - } - else - { - ud.m_volume_number = x; - ud.m_level_number = 0; - last_episode = x; - M_ChangeMenu(MENU_SKILL); - } - } - } - else if (x == -1) - { - if (g_player[myconnectindex].ps->gm&MODE_GAME) M_ChangeMenu(MENU_MAIN_INGAME); - else M_ChangeMenu(MENU_MAIN); + M_PreMenu(cm->menuID); + M_PreMenuDraw(cm->menuID, NULL, NULL); + break; } - margin = 80; - if (VOLUMEONE) + case Password: { - menutext(160,60,MENUHIGHLIGHT(0),0,EpisodeNames[0]); - menutext(160,60+20,MENUHIGHLIGHT(1),1,EpisodeNames[1]); - menutext(160,60+20+20,MENUHIGHLIGHT(2),1,EpisodeNames[2]); - if (PLUTOPAK) - menutext(160,60+20+20,MENUHIGHLIGHT(3),1,EpisodeNames[3]); + MenuPassword_t *object = (MenuPassword_t*)cm->object; + size_t x; + + M_PreMenu(cm->menuID); + + mgametext(160,50+16+16+16+16-12,"Enter Password",0,2|8|16); + + for (x=0; x < Bstrlen(object->input); ++x) + tempbuf[x] = '*'; + tempbuf[x] = 0; + + x = gametext(160,50+16+16+16+16,tempbuf,998,2|8|16); + + x = 160 + ((x - 160)>>1); + + rotatesprite_fs((x+8)<<16,(50+16+16+16+16+4)<<16,32768,0,SPINNINGNUKEICON+((totalclock>>3)%7),cursorShade,0,2|8); + + M_PreMenuDraw(cm->menuID, NULL, NULL); + break; } - else + + case FileSelect: { - for (i=0; iobject; - menutext(160,60-(g_numVolumes*2)+(20*i),MENUHIGHLIGHT(i),0,"User Map"); - } - break; + int32_t i, width = 160 - (40-4); - case MENU_USERMAP: - if (boardfilename[0] == 0) strcpy(boardfilename, "./"); - Bcorrectfilename(boardfilename,1); - - fnlist_getnames(&fnlist, boardfilename, "*.map", 0, 0); - set_findhighs(); - - M_ChangeMenu(MENU_SELECTMAP); - KB_FlushKeyboardQueue(); - case MENU_SELECTMAP: - M_DrawTopBar("Select A User Map"); - - { - int32_t width = 160 - (40-4); + M_PreMenu(cm->menuID); // black translucent background underneath file lists rotatesprite(0<<16, 0<<16, 65536<<5, 0, /*tile*/ 0, numshades, 0, 10+16+1+32, xdim/2-scale(width,(ydim*4)/3,320),scale(12+32-2,ydim,200), xdim/2+scale(width,(ydim*4)/3,320)-1,scale(12+32+112+4,ydim,200)-1); + + // path + minitext(38,45,object->destination,16,26); + + mgametext(40+4,32,"Directories",0,2+8+16); + + if (object->finddirshigh) + { + int32_t len; + + object->dir = object->finddirshigh; + for (i=0; i<5; i++) if (!object->dir->prev) break; + else object->dir=object->dir->prev; + for (i=5; i>-8 && object->dir; i--, object->dir=object->dir->next) + { + uint8_t status = 0; + + len = Bstrlen(object->dir->name); + Bstrncpy(tempbuf,object->dir->name,len); + if (len > USERMAPENTRYLENGTH) + { + len = USERMAPENTRYLENGTH-3; + tempbuf[len] = 0; + while (len < USERMAPENTRYLENGTH) + tempbuf[len++] = '.'; + } + tempbuf[len] = 0; + + status |= (object->dir == object->finddirshigh && object->currentlist == 0)<<0; + + M_MenuText(40<<16, (1+12+32+8*(6-i))<<16, object->dirfont, tempbuf, status); + } + } + + mgametext(180+4,32,"Files",0,2+8+16); + + if (object->findfileshigh) + { + int32_t len; + + object->dir = object->findfileshigh; + for (i=0; i<6; i++) if (!object->dir->prev) break; + else object->dir=object->dir->prev; + for (i=6; i>-8 && object->dir; i--, object->dir=object->dir->next) + { + uint8_t status = 0; + + len = Bstrlen(object->dir->name); + Bstrncpy(tempbuf,object->dir->name,len); + if (len > USERMAPENTRYLENGTH) + { + len = USERMAPENTRYLENGTH-3; + tempbuf[len] = 0; + while (len < USERMAPENTRYLENGTH) + tempbuf[len++] = '.'; + } + tempbuf[len] = 0; + + status |= (object->dir == object->findfileshigh && object->currentlist == 1)<<0; + + M_MenuText(180<<16, (1+12+32+8*(6-i))<<16, object->filefont, tempbuf, status); + + // object->dir->source==CACHE1D_SOURCE_ZIP ? 8 : 2 + } + } + + rotatesprite_fs(((object->currentlist == 0 ? 45 : 185)<<16)-(21<<15),(32+4+1-2)<<16,32768,0,SPINNINGNUKEICON+(((totalclock>>3))%7),cursorShade,0,10); + + M_PreMenuDraw(cm->menuID, NULL, NULL); + + if (object->title != NoTitle) + M_DrawTopBar(object->title); + break; } - // path - minitext(38,45,boardfilename,16,26); - + case Panel: { + MenuPanel_t *object = (MenuPanel_t*)cm->object; + M_PreMenu(cm->menuID); + M_PreMenuDraw(cm->menuID, NULL, NULL); + if (object->title != NoTitle) + M_DrawTopBar(object->title); + break; + } + + case Menu: + { + int32_t state; + + MenuMenu_t *menu = (MenuMenu_t*)cm->object; + MenuGroup_t *currgroup = menu->grouplist[menu->currentGroup]; + MenuEntry_t *currentry = currgroup->entrylist[currgroup->currentEntry]; + + state = M_DetermineMenuSpecialState(currentry); + + if (state != 2) + { + M_PreMenu(cm->menuID); + M_PreMenuDraw(cm->menuID, currgroup, currentry); + + M_RunMenu_MenuMenu(menu, currentry, state); + } + else + { + if (currentry->type == Option) + { + M_PreMenuOptionListDraw(/*currgroup,*/ currentry); + + M_RunMenu_MenuOptionList((MenuOption_t*)currentry->entry); + } + else if (currentry->type == Custom2Col) + { + M_PreMenuCustom2ColScreenDraw(currgroup, currentry); + } + } + + if (menu->title != NoTitle) + M_DrawTopBar(menu->title); + break; + } + } +} + +static void M_RunMenuInput(Menu_t *cm) +{ + switch (cm->type) + { + case Panel: + { + MenuPanel_t *panel = (MenuPanel_t*)cm->object; + + if (I_ReturnTrigger()) + { + I_ReturnTriggerClear(); + + S_PlaySound(EXITMENUSOUND); + + M_ChangeMenu(cm->parentID); + } + else if (I_PanelUp()) + { + I_PanelUpClear(); + + S_PlaySound(KICK_HIT); + M_ChangeMenu(panel->previousID); + } + else if (I_PanelDown()) + { + I_PanelDownClear(); + + S_PlaySound(KICK_HIT); + M_ChangeMenu(panel->nextID); + } + } + + case Password: + { + MenuPassword_t *object = (MenuPassword_t*)cm->object; + int32_t hitstate = I_EnterText(object->input, object->maxlength, 0); + + if (hitstate == 1) + { + S_PlaySound(PISTOL_BODYHIT); + + M_MenuPasswordSubmit(object->input); + + object->input = NULL; + } + else if (hitstate == -1) + { + S_PlaySound(EXITMENUSOUND); + + object->input = NULL; + + M_ChangeMenu(cm->parentID); + } + break; + } + + case FileSelect: + { + MenuFileSelect_t *object = (MenuFileSelect_t*)cm->object; + // JBF 20040208: seek to first name matching pressed character - CACHE1D_FIND_REC *seeker = currentlist ? fnlist.findfiles : fnlist.finddirs; - if ((KB_KeyPressed(sc_Home)|KB_KeyPressed(sc_End)) > 0) + CACHE1D_FIND_REC *seeker = object->currentlist ? object->fnlist.findfiles : object->fnlist.finddirs; + + if (I_ReturnTrigger()) + { + I_ReturnTriggerClear(); + + S_PlaySound(EXITMENUSOUND); + + fnlist_clearnames(&object->fnlist); + + object->destination[0] = 0; + + M_MenuFileSelect(0); + + M_ChangeMenu(cm->parentID); + } + else if (I_AdvanceTrigger()) + { + I_AdvanceTriggerClear(); + + S_PlaySound(PISTOL_BODYHIT); + + if (object->currentlist == 0) + { + if (!object->finddirshigh) break; + Bstrcat(object->destination, object->finddirshigh->name); + Bstrcat(object->destination, "/"); + Bcorrectfilename(object->destination, 1); + + fnlist_clearnames(&object->fnlist); + + M_MenuFileSelectInit(object); + } + else + { + if (!object->findfileshigh) break; + Bstrcat(object->destination, object->findfileshigh->name); + + fnlist_clearnames(&object->fnlist); + + M_MenuFileSelect(1); + } + } + else if ((KB_KeyPressed(sc_Home)|KB_KeyPressed(sc_End)) > 0) { while (seeker && (KB_KeyPressed(sc_End)?seeker->next:seeker->prev)) seeker = KB_KeyPressed(sc_End)?seeker->next:seeker->prev; if (seeker) { - if (currentlist) findfileshigh = seeker; - else finddirshigh = seeker; + if (object->currentlist) object->findfileshigh = seeker; + else object->finddirshigh = seeker; // clear keys, don't play the kick sound a dozen times! KB_ClearKeyDown(sc_End); KB_ClearKeyDown(sc_Home); @@ -2255,8 +3919,8 @@ cheat_for_port_credits2: } else if ((KB_KeyPressed(sc_PgUp)|KB_KeyPressed(sc_PgDn)) > 0) { - seeker = currentlist?findfileshigh:finddirshigh; - i = 6; + int32_t i = 6; + seeker = object->currentlist?object->findfileshigh:object->finddirshigh; while (i>0) { if (seeker && (KB_KeyPressed(sc_PgDn)?seeker->next:seeker->prev)) @@ -2265,14 +3929,70 @@ cheat_for_port_credits2: } if (seeker) { - if (currentlist) findfileshigh = seeker; - else finddirshigh = seeker; + if (object->currentlist) object->findfileshigh = seeker; + else object->finddirshigh = seeker; // clear keys, don't play the kick sound a dozen times! KB_ClearKeyDown(sc_PgDn); KB_ClearKeyDown(sc_PgUp); S_PlaySound(KICK_HIT); } } + else if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || + KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || + KB_KeyPressed(sc_Tab) || (MOUSE_GetButtons()&MIDDLE_MOUSE)) + { + KB_ClearKeyDown(sc_LeftArrow); + KB_ClearKeyDown(sc_kpad_4); + KB_ClearKeyDown(sc_RightArrow); + KB_ClearKeyDown(sc_kpad_6); + KB_ClearKeyDown(sc_Tab); + MOUSE_ClearButton(MIDDLE_MOUSE); + object->currentlist = !object->currentlist; + S_PlaySound(KICK_HIT); + } + else if (KB_KeyPressed(sc_UpArrow) || KB_KeyPressed(sc_kpad_8) || (MOUSE_GetButtons()&WHEELUP_MOUSE) || BUTTON(gamefunc_Move_Forward) || (JOYSTICK_GetHat(0)&HAT_UP)) + { + KB_ClearKeyDown(sc_UpArrow); + KB_ClearKeyDown(sc_kpad_8); + MOUSE_ClearButton(WHEELUP_MOUSE); + CONTROL_ClearButton(gamefunc_Move_Forward); + JOYSTICK_ClearHat(0); + + S_PlaySound(KICK_HIT); + + if (object->currentlist == 0) + { + if (object->finddirshigh) + if (object->finddirshigh->prev) object->finddirshigh = object->finddirshigh->prev; + } + else + { + if (object->findfileshigh) + if (object->findfileshigh->prev) object->findfileshigh = object->findfileshigh->prev; + } + } + else if (KB_KeyPressed(sc_DownArrow) || KB_KeyPressed(sc_kpad_2) || (MOUSE_GetButtons()&WHEELDOWN_MOUSE) || BUTTON(gamefunc_Move_Backward) || (JOYSTICK_GetHat(0)&HAT_DOWN)) + { + KB_ClearKeyDown(sc_DownArrow); + KB_ClearKeyDown(sc_kpad_2); + KB_ClearKeyDown(sc_PgDn); + MOUSE_ClearButton(WHEELDOWN_MOUSE); + CONTROL_ClearButton(gamefunc_Move_Backward); + JOYSTICK_ClearHat(0); + + S_PlaySound(KICK_HIT); + + if (object->currentlist == 0) + { + if (object->finddirshigh) + if (object->finddirshigh->next) object->finddirshigh = object->finddirshigh->next; + } + else + { + if (object->findfileshigh) + if (object->findfileshigh->next) object->findfileshigh = object->findfileshigh->next; + } + } else { char ch2, ch; @@ -2289,3060 +4009,640 @@ cheat_for_port_credits2: } if (seeker) { - if (currentlist) findfileshigh = seeker; - else finddirshigh = seeker; + if (object->currentlist) object->findfileshigh = seeker; + else object->finddirshigh = seeker; S_PlaySound(KICK_HIT); } } } - } - mgametext(40+4,32,"Directories",0,2+8+16); - if (finddirshigh) - { - int32_t len; - - dir = finddirshigh; - for (i=0; i<5; i++) if (!dir->prev) break; - else dir=dir->prev; - for (i=5; i>-8 && dir; i--, dir=dir->next) - { - len = Bstrlen(dir->name); - Bstrncpy(tempbuf,dir->name,len); - if (len > USERMAPENTRYLENGTH) - { - len = USERMAPENTRYLENGTH-3; - tempbuf[len] = 0; - while (len < USERMAPENTRYLENGTH) - tempbuf[len++] = '.'; - } - tempbuf[len] = 0; - minitextshade(40,1+12+32+8*(6-i),tempbuf,MINIHIGHLIGHTCOND(dir == finddirshigh && currentlist == 0),0,26); - } - } - - mgametext(180+4,32,"Map Files",0,2+8+16); - - if (findfileshigh) - { - int32_t len; - - dir = findfileshigh; - for (i=0; i<6; i++) if (!dir->prev) break; - else dir=dir->prev; - for (i=6; i>-8 && dir; i--, dir=dir->next) - { - len = Bstrlen(dir->name); - Bstrncpy(tempbuf,dir->name,len); - if (len > USERMAPENTRYLENGTH) - { - len = USERMAPENTRYLENGTH-3; - tempbuf[len] = 0; - while (len < USERMAPENTRYLENGTH) - tempbuf[len++] = '.'; - } - tempbuf[len] = 0; - minitextshade(180,1+12+32+8*(6-i),tempbuf,MINIHIGHLIGHTCOND(dir == findfileshigh && currentlist == 1), - dir->source==CACHE1D_SOURCE_ZIP ? 8 : 2, - 26); - } - } - - if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || (LMB && minfo.dyaw < -256) || - KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || (LMB && minfo.dyaw > 256) || - KB_KeyPressed(sc_Tab)) - { - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_kpad_4); - KB_ClearKeyDown(sc_RightArrow); - KB_ClearKeyDown(sc_kpad_6); - KB_ClearKeyDown(sc_Tab); - currentlist = 1-currentlist; - S_PlaySound(KICK_HIT); - } - - onbar = 0; - probey = 2; - if (currentlist == 0) x = probesm(45,32+4+1,0,3); - else x = probesm(185,32+4+1,0,3); - - if (probey == 1) - { - if (currentlist == 0) - { - if (finddirshigh) - if (finddirshigh->prev) finddirshigh = finddirshigh->prev; - } - else - { - if (findfileshigh) - if (findfileshigh->prev) findfileshigh = findfileshigh->prev; - } - } - else if (probey == 0) - { - if (currentlist == 0) - { - if (finddirshigh) - if (finddirshigh->next) finddirshigh = finddirshigh->next; - } - else - { - if (findfileshigh) - if (findfileshigh->next) findfileshigh = findfileshigh->next; - } - } - - if (x == -1) - { - fnlist_clearnames(&fnlist); - - boardfilename[0] = 0; - if ((g_netServer || ud.multimode > 1)) - { - Net_SendUserMapName(); - M_ChangeMenu(MENU_NETSETUP); - probey = last_menu_pos; - } - else M_ChangeMenu(MENU_EPISODE); - } - else if (x >= 0) - { - if (currentlist == 0) - { - if (!finddirshigh) break; - strcat(boardfilename, finddirshigh->name); - strcat(boardfilename, "/"); - Bcorrectfilename(boardfilename, 1); - M_ChangeMenu(MENU_USERMAP); - KB_FlushKeyboardQueue(); - } - else - { - if (!findfileshigh) break; - strcat(boardfilename, findfileshigh->name); - ud.m_volume_number = 0; - ud.m_level_number = 7; - if ((g_netServer || ud.multimode > 1)) - { - Net_SendUserMapName(); - M_ChangeMenu(MENU_NETSETUP); - probey = last_menu_pos; - } - else M_ChangeMenu(MENU_SKILL); - } - - fnlist_clearnames(&fnlist); - } - break; - - case MENU_SKILL: - { - // 4 skills (orig) --> 70 - const int32_t ybase = 70 + (4-g_numSkills)*6; - - margin = MENU_MARGIN_CENTER; - M_DrawTopBar("Select Skill"); - x = M_Probe(margin,ybase,19,g_numSkills); - if (x >= 0) - { - int32_t skillsound = 0; - - switch (x) - { - case 0: - skillsound = JIBBED_ACTOR6; - break; - case 1: - skillsound = BONUS_SPEECH1; - break; - case 2: - skillsound = DUKE_GETWEAPON2; - break; - case 3: - skillsound = JIBBED_ACTOR5; - break; - } - - g_skillSoundVoice = S_PlaySound(skillsound); - - ud.m_player_skill = x+1; - if (x == 3) ud.m_respawn_monsters = 1; - else ud.m_respawn_monsters = 0; - - ud.m_monsters_off = ud.monsters_off = 0; - - ud.m_respawn_items = 0; - ud.m_respawn_inventory = 0; - - ud.multimode = 1; - - if (ud.m_volume_number == 3 && (G_GetLogoFlags() & LOGO_NOE4CUTSCENE)==0) - { - flushperms(); - setview(0,0,xdim-1,ydim-1); - clearview(0L); - nextpage(); - } - - G_NewGame_EnterLevel(); - } - else if (x == -1) - { - M_ChangeMenu(MENU_EPISODE); - KB_FlushKeyboardQueue(); - } - - for (i=0; i= 2) - break; - - if (opts[ii][0] == '-' && !opts[ii][1]) - { - if (io <= probey) yy += 4; - continue; - } - if (io < probey) yy += 8; - io++; - } - - onbar = (probey==1||probey==5); - x = probesm(margin,yy+5,0,io); - - if (x == -1) - { - M_ChangeMenu(MENU_VIDEOSETUP); - probey = 6; - break; - } - - yy = 37; - for (ii=io=0; opts[ii]; ii++) - { - if (getrendermode() == REND_CLASSIC && io >= 2) - break; - - if (opts[ii][0] == '-' && !opts[ii][1]) - { - yy += 4; - continue; - } - - enabled = 1; - switch (io) - { - case 0: - if (getrendermode() <= REND_POLYMOST) - { -#ifdef USE_OPENGL - int32_t tmp = r_usenewaspect ? 2 : glwidescreen; - - if (x==io) - { - tmp = tmp+1; - if (tmp > 2) - tmp = 0; - } - modval(0,2,&tmp,1,probey==io); - - r_usenewaspect = (tmp==2); - - // with r_usenewaspect, glwidescreen has no effect... - glwidescreen = (tmp < 2) ? tmp : 0; - mgametextpal(d,yy, r_usenewaspect ? "Auto" : - (glwidescreen ? "Old wide" : "Old reg."), - MENUHIGHLIGHT(io), 0); -#else - if (x==io) - r_usenewaspect = !r_usenewaspect; - modval(0,1,&r_usenewaspect,1,probey==io); - mgametextpal(d,yy, r_usenewaspect ? "Auto" : "Old reg.", - MENUHIGHLIGHT(io), 0); -#endif - } -#ifdef POLYMER - else - { - double ratios[] = { 0.0, 1.33, 1.66, 1.78, 1.85, 2.35 }; - - int32_t j = ARRAY_SIZE(ratios); - - for (i = 0; i= j) - i = 0; - } - if (i == j) - Bsprintf(tempbuf,"Custom"); - else - { - if (i == 0) Bsprintf(tempbuf,"Auto"); - else Bsprintf(tempbuf,"%.2f:1",ratios[i]); - - if (ratios[i] != pr_customaspect) - pr_customaspect = ratios[i]; - } - mgametextpal(d,yy,tempbuf, MENUHIGHLIGHT(io), 0); - - } -#endif - break; - case 1: - { - int32_t i = (int32_t)(r_ambientlight*1024.f); - int32_t j = i; - - sliderbar(1,d+8,yy+7, &i,128,x==io,MENUHIGHLIGHT(io),0,128,4096); - Bsprintf(tempbuf,"%.2f",r_ambientlight); - mgametextpal(d-35,yy, tempbuf, MENUHIGHLIGHT(io), 0); - if (i != j) - { - r_ambientlight = (float)i/1024.f; - r_ambientlightrecip = 1.f/r_ambientlight; - } - break; - } -#ifdef USE_OPENGL - case 2: - { - int32_t dummy = glanisotropy; - modval(0,(int32_t)glinfo.maxanisotropy+1,(int32_t *)&dummy,1,probey==io); - if (dummy > glanisotropy) glanisotropy *= 2; - else if (dummy < glanisotropy) glanisotropy /= 2; - if (x==io) - glanisotropy *= 2; - if (glanisotropy > glinfo.maxanisotropy) glanisotropy = 1; - else if (glanisotropy < 1) glanisotropy = (int32_t)glinfo.maxanisotropy; - gltexapplyprops(); - if (glanisotropy == 1) strcpy(tempbuf,"None"); - else Bsprintf(tempbuf,"%dx",glanisotropy); - mgametextpal(d,yy, tempbuf, MENUHIGHLIGHT(io), 0); - break; - } - case 3: - { - int32_t ovsync = vsync; - if (x==io) vsync++; - if (vsync == 2) vsync = -1; - modval(-1,1,(int32_t *)&vsync,1,probey==io); - mgametextpal(d,yy, vsync < 0 ? "Adaptive" : vsync ? "Yes" : "No", MENUHIGHLIGHT(io), 0); - if (vsync != ovsync) - setvsync(vsync); - break; - } - case 4: - if (x==io) usehightile = 1-usehightile; - modval(0,1,(int32_t *)&usehightile,1,probey==io); - mgametextpal(d,yy, usehightile ? "Yes" : "No", MENUHIGHLIGHT(io), 0); - break; - case 5: - { - i = r_downsize; - enabled = usehightile; - sliderbar(1,d+8,yy+7, &r_downsize,-1,enabled && x==io,MENUHIGHLIGHT(io),!enabled,0,2); - if (r_downsize != i) - { - texcache_invalidate(); - resetvideomode(); - if (setgamemode(fullscreen,xdim,ydim,bpp)) - OSD_Printf("restartvid: Reset failed...\n"); - r_downsizevar = r_downsize; - return; - } - break; - } - case 6: - enabled = usehightile; - if (enabled && x==io) ud.config.useprecache = !ud.config.useprecache; - if (enabled) modval(0,1,(int32_t *)&ud.config.useprecache,1,probey==io); - mgametextpal(d,yy, ud.config.useprecache ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0); - break; - case 7: - { - const char *s[] = { "Off", "On", "Compress" }; - enabled = (glusetexcompr && usehightile); - if (enabled && x==io) - { - glusetexcache++; - if (glusetexcache > 2) - glusetexcache = 0; - } - if (enabled) modval(0,2,(int32_t *)&glusetexcache,1,probey==io); - mgametextpal(d,yy, s[glusetexcache], enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0); - } - break; - case 8: - enabled = usehightile; - if (enabled && x==io) r_detailmapping = !r_detailmapping; - if (enabled) modval(0,1,(int32_t *)&r_detailmapping,1,probey==io); - mgametextpal(d,yy, r_detailmapping ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0); - break; - case 9: - if (x==io) usemodels = 1-usemodels; - modval(0,1,(int32_t *)&usemodels,1,probey==io); - mgametextpal(d,yy, usemodels ? "Yes" : "No", MENUHIGHLIGHT(io), 0); - break; -#endif - default: - break; - } - mgametextpal(margin,yy, opts[ii], enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 10); - io++; - yy += 8; - } - } - break; - case MENU_COLCORR: - case MENU_COLCORR_INGAME: - M_DrawTopBar("Color Correction"); - - margin = MENU_MARGIN_REGULAR; - - x = 4; - - onbar = (probey != 3); - x = M_Probe(margin,probey==3?106:98,16,x); - - if (x == -1) - { - if (g_player[myconnectindex].ps->gm &MODE_GAME && g_currentMenu == MENU_COLCORR_INGAME) - { - g_player[myconnectindex].ps->gm &= ~MODE_MENU; - if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - } - else - { - M_ChangeMenu(MENU_VIDEOSETUP); - probey = 4; - } + M_PreMenuInput(NULL, NULL); break; } - menutext(margin,98,MENUHIGHLIGHT(0),0,"Gamma"); - menutext(margin,98+16,MENUHIGHLIGHT(1),0,"Contrast"); - menutext(margin,98+16+16,MENUHIGHLIGHT(2),0,"Brightness"); - menutext(margin,98+16+16+16+8,MENUHIGHLIGHT(3),0,"Reset To Defaults"); - - Bsprintf(tempbuf,"%s%.2f",vid_gamma>=0?" ":"",vid_gamma); - mgametext(margin+177-56,98-8,tempbuf,MENUHIGHLIGHT(0),2+8+16); - Bsprintf(tempbuf,"%s%.2f",vid_contrast>=0?" ":"",vid_contrast); - mgametext(margin+177-56,98+16-8,tempbuf,MENUHIGHLIGHT(1),2+8+16); - Bsprintf(tempbuf,"%s%.2f",vid_brightness>=0?" ":"",vid_brightness); - mgametext(margin+177-56,98+16+16-8,tempbuf,MENUHIGHLIGHT(2),2+8+16); - - rotatesprite(40<<16,24<<16,24576,0,BONUSSCREEN,0,0,2+8+16,0,scale(ydim,35,200),xdim-1,scale(ydim,80,200)-1); - rotatesprite(160<<16,27<<16,24576,0,3290,0,0,2+8+16,0,scale(ydim,35,200),xdim-1,scale(ydim,80,200)-1); - - { - extern int32_t gammabrightness; - - int32_t b = (int32_t)(vid_gamma*40960.f); - sliderbar(0,margin+177,98,&b,4096,x==0,MENUHIGHLIGHT(0),0,8192,163840); - - if (b != (double)(vid_gamma*40960.f)) + case Message: + if (I_ReturnTrigger()) { - vid_gamma = (double)b/40960.f; - ud.brightness = GAMMA_CALC; - ud.brightness <<= 2; - setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); - } + I_ReturnTriggerClear(); - b = (int32_t)(vid_contrast*40960.f); - sliderbar(0,margin+177,98+16,&b,2048,x==1,gammabrightness?MENUHIGHLIGHT(1):DISABLEDMENUSHADE,0,4096,110592); - - if (b != (vid_contrast*40960.f)) - { - vid_contrast = (double)b/40960.f; - setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); - } - - b = (int32_t)(vid_brightness*40960.f); - sliderbar(0,margin+177,98+16+16,&b,2048,x==2,gammabrightness?MENUHIGHLIGHT(2):DISABLEDMENUSHADE,0,-32768,32768); - - if (b != (vid_brightness*40960.f)) - { - vid_brightness = (double)b/40960.f; - setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); - } - - if (x == 3) - { - vid_gamma = DEFAULT_GAMMA; - vid_contrast = DEFAULT_CONTRAST; - vid_brightness = DEFAULT_BRIGHTNESS; - ud.brightness = 0; - setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); - } - } - - break; - - case MENU_SETUP: - - M_DrawTopBar("Game Setup"); - - margin = MENU_MARGIN_REGULAR; - - { - int32_t io, ii, yy, d=margin+160+40, enabled; - const char *opts[] = - { - "Show setup window at start", - "Show crosshair", - "Crosshair size", - "-", - "Screen size", - "Status bar size", - "Stats and chat text size", - "Show level stats", - "-", - "Allow walk with autorun", - "-", - "Shadows", - "Screen tilting", - "-", - "Show framerate", - "Demo recording", - "-", - "More...", - NULL - }; - - yy = 37; - for (ii=io=0; opts[ii]; ii++) - { - if (opts[ii][0] == '-' && !opts[ii][1]) - { - if (io <= probey) yy += 4; - continue; - } - if (io < probey) yy += 8; - io++; - } - - onbar = (probey >= 2 && probey <= 5); - x = probesm(margin,yy+5,0,io); - - if (x == -1) - { - M_ChangeMenu(MENU_OPTIONS); - break; - } - - yy = 37; - for (ii=io=0; opts[ii]; ii++) - { - if (opts[ii][0] == '-' && !opts[ii][1]) - { - yy += 4; - continue; - } - enabled = 1; - switch (io) - { - case 0: - if (x==io) ud.config.ForceSetup = 1-ud.config.ForceSetup; - modval(0,1,(int32_t *)&ud.config.ForceSetup,1,probey==io); - mgametextpal(d,yy, ud.config.ForceSetup ? "Yes" : "No", MENUHIGHLIGHT(io), 0); - break; - case 1: - if (x==io) ud.crosshair = !ud.crosshair; - modval(0,1,(int32_t *)&ud.crosshair,1,probey==io); - { - mgametextpal(d,yy,ud.crosshair?"Yes":"No", MENUHIGHLIGHT(io), 0); - break; - } - case 2: - { - int32_t chs = ud.crosshairscale; - sliderbar(1,d+8,yy+7, &chs,5,x==io,MENUHIGHLIGHT(io),0,25,100); - ud.crosshairscale = clamp(chs, 10, 100); - } - break; - case 3: - { - int32_t vpsize = ud.screen_size + 4*(ud.screen_size>=8 && ud.statusbarmode==0); - const int32_t ovpsize = vpsize; - - sliderbar(1,d+8,yy+7, &vpsize,-4,x==io,MENUHIGHLIGHT(io),0,0,68); - - if (vpsize-ovpsize) - G_SetViewportShrink(vpsize-ovpsize); - } - break; - case 4: - { - int32_t sbs = ud.statusbarscale; - const int32_t osbs = sbs; - sliderbar(1,d+8,yy+7, &sbs,4,x==io,MENUHIGHLIGHT(io),0,36,100); - if (x == io && sbs != osbs) - G_SetStatusBarScale(sbs); - } - break; - case 5: - { - sliderbar(1,d+8,yy+7, &ud.textscale,50,enabled && x==io,MENUHIGHLIGHT(io),0,100,400); - } - break; - case 6: - if (x==io) ud.levelstats = !ud.levelstats; - modval(0,1,(int32_t *)&ud.levelstats,1,probey==io); - mgametextpal(d,yy, ud.levelstats ? "Yes" : "No", MENUHIGHLIGHT(io), 0); - break; - case 7: - if (x==io) ud.runkey_mode = !ud.runkey_mode; - modval(0,1,(int32_t *)&ud.runkey_mode,1,probey==io); - mgametextpal(d,yy, ud.runkey_mode ? "No" : "Yes", MENUHIGHLIGHT(io), 0); - break; - case 8: - if (x==io) ud.shadows = 1-ud.shadows; - modval(0,1,(int32_t *)&ud.shadows,1,probey==io); - mgametextpal(d,yy, ud.shadows ? "On" : "Off", MENUHIGHLIGHT(io), 0); - break; - case 9: - if (x==io) ud.screen_tilting = !ud.screen_tilting; -#ifdef USE_OPENGL - if (!ud.screen_tilting) setrollangle(0); -#endif - modval(0,1,(int32_t *)&ud.screen_tilting,1,probey==io); - mgametextpal(d,yy, ud.screen_tilting ? "On" : "Off", MENUHIGHLIGHT(io), 0); - break; // original had a 'full' option - case 10: - if (x==io) ud.tickrate = 1-ud.tickrate; - modval(0,1,(int32_t *)&ud.tickrate,1,probey==io); - mgametextpal(d,yy, ud.tickrate ? "Yes" : "No", MENUHIGHLIGHT(io), 0); - break; - case 11: - { - DukePlayer_t *ps = g_player[myconnectindex].ps; - - if (x==io) - { - enabled = !((ps->gm&MODE_GAME) && ud.m_recstat != 1); - - if ((ps->gm&MODE_GAME)) G_CloseDemoWrite(); - else ud.m_recstat = !ud.m_recstat; - } - - if ((ps->gm&MODE_GAME) && ud.m_recstat != 1) - enabled = 0; - - mgametextpal(d, yy, ud.m_recstat ? ((enabled && ps->gm&MODE_GAME)?"Running":"On"):"Off", - enabled ? MENUHIGHLIGHT(io) : DISABLEDMENUSHADE, !enabled); - break; - } - case 12: - if (x==io) M_ChangeMenu(MENU_GAMESETUP); - break; - default: - break; - } - mgametextpal(margin,yy, opts[ii], enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 10); - io++; - yy += 8; - } - } - break; - - case MENU_GAMESETUP: - - M_DrawTopBar("Game Setup"); - - margin = MENU_MARGIN_REGULAR; - - { - int32_t io, ii, yy, d=margin+160+40, enabled; - const char *opts[] = - { - "Parental lock", - "-", - "Show inv & pickup messages", - "Display current weapon", - "Upgraded status bar", - "Camera view in demos", - "-", - "DM: Ignore map votes", - "DM: Use private messages", - "DM: Show player names", - "DM: Show player weapons", - "DM: Show player obituaries", - "-", - "Console text style", - "-", -#ifdef _WIN32 - "Check for updates at start", -#else - "-", - "-", -#endif - "-", - "Previous page", - NULL - }; - - yy = 37; - for (ii=io=0; opts[ii]; ii++) - { - if (opts[ii][0] == '-' && !opts[ii][1]) - { - if (io <= probey) yy += 4; - continue; - } - if (io < probey) yy += 8; - io++; - } - - x = probesm(margin,yy+5,0,io); - - if (x == -1) - { - M_ChangeMenu(MENU_SETUP); - probey = 12; - break; - } - - yy = 37; - for (ii=io=0; opts[ii]; ii++) - { - if (opts[ii][0] == '-' && !opts[ii][1]) - { - yy += 4; - continue; - } - enabled = 1; - switch (io) - { - case 0: - if (!NAM) - { - if (x==io) M_ChangeMenu(MENU_ADULTMODE); - } - else enabled = 0; - break; - case 1: - if (x==io) - ud.fta_on = 1-ud.fta_on; - modval(0,1,(int32_t *)&ud.fta_on,1,probey==io); - mgametextpal(d,yy, ud.fta_on ? "Yes" : "No", MENUHIGHLIGHT(io), 0); - break; - case 2: - if (x==io) - { - ud.drawweapon = (ud.drawweapon == 2) ? 0 : ud.drawweapon+1; - } - modval(0,2,(int32_t *)&ud.drawweapon,1,probey==io); - { - const char *s[] = { "Off", "On", "Icon only" }; - mgametextpal(d,yy, s[ud.drawweapon], MENUHIGHLIGHT(io), 0); - break; - } - case 3: - if (x==io) ud.althud = !ud.althud; - modval(0,1,(int32_t *)&ud.althud,1,probey==io); - mgametextpal(d,yy, ud.althud ? "Yes" : "No", MENUHIGHLIGHT(io), 0); - break; - case 4: - if (x==io) ud.democams = 1-ud.democams; - modval(0,1,(int32_t *)&ud.democams,1,probey==io); - mgametextpal(d,yy, ud.democams ? "On" : "Off", MENUHIGHLIGHT(io), 0); - break; - case 5: - if (x==io) - { - ud.autovote = (ud.autovote == 2) ? 0 : ud.autovote+1; - } - modval(0,2,(int32_t *)&ud.autovote,1,probey==io); - { - const char *s[] = { "Off", "Vote No", "Vote Yes" }; - mgametextpal(d,yy, s[ud.autovote], MENUHIGHLIGHT(io), 0); - break; - } - case 6: - if (x==io) ud.automsg = 1-ud.automsg; - modval(0,1,(int32_t *)&ud.automsg,1,probey==io); - mgametextpal(d,yy, ud.automsg ? "Off" : "On", MENUHIGHLIGHT(io), 0); - break; - case 7: - if (x==io) ud.idplayers = 1-ud.idplayers; - modval(0,1,(int32_t *)&ud.idplayers,1,probey==io); - mgametextpal(d,yy, ud.idplayers ? "Yes" : "No", MENUHIGHLIGHT(io), 0); - break; - case 8: - if (x==io) ud.showweapons = 1-ud.showweapons; - modval(0,1,(int32_t *)&ud.showweapons,1,probey==io); - ud.config.ShowOpponentWeapons = ud.showweapons; - mgametextpal(d,yy, ud.config.ShowOpponentWeapons ? "Yes" : "No", MENUHIGHLIGHT(io), 0); - break; - case 9: - if (x==io) ud.obituaries = 1-ud.obituaries; - modval(0,1,(int32_t *)&ud.obituaries,1,probey==io); - mgametextpal(d,yy, ud.obituaries ? "Yes" : "No", MENUHIGHLIGHT(io), 0); - break; - case 10: - { - int32_t osdmode = OSD_GetTextMode(); - if (x==io) osdmode = !osdmode; - modval(0,1,(int32_t *)&osdmode,1,probey==io); - mgametextpal(d,yy, osdmode? "Basic" : "Sprites", MENUHIGHLIGHT(io), 0); - if (OSD_GetTextMode() != osdmode) - OSD_SetTextMode(osdmode); - break; - } -#ifdef _WIN32 - case 11: - i = ud.config.CheckForUpdates; - if (x==io) ud.config.CheckForUpdates = 1-ud.config.CheckForUpdates; - modval(0,1,(int32_t *)&ud.config.CheckForUpdates,1,probey==io); - if (ud.config.CheckForUpdates != i) - ud.config.LastUpdateCheck = 0; - mgametextpal(d,yy, ud.config.CheckForUpdates ? "Yes" : "No", MENUHIGHLIGHT(io), 0); - break; - case 12: -#else - case 11: -#endif - if (x==io) M_ChangeMenu(MENU_SETUP); - break; - default: - break; - } - mgametextpal(margin,yy, opts[ii], enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 10); - io++; - yy += 8; - } - } - break; - - // JBF 20031205: Second level options menu selection - case MENU_OPTIONS: - M_DrawTopBar("Options"); - - margin = 50; - - onbar = 0; - x = M_Probe(160,margin,18,7); - - last_options = probey; - - switch (x) - { - case -1: - if (g_player[myconnectindex].ps->gm&MODE_GAME) M_ChangeMenu(MENU_MAIN_INGAME); - else M_ChangeMenu(MENU_MAIN); - break; - - case 0: - M_ChangeMenu(MENU_SETUP); - break; - - case 1: - changesmade = 0; - M_ChangeMenu(MENU_SOUND); - break; - - case 2: - { - int32_t dax = xdim, day = ydim, daz; - curvidmode = newvidmode = checkvideomode(&dax,&day,bpp,fullscreen,0); - if (newvidmode == 0x7fffffffl) newvidmode = validmodecnt; - newfullscreen = fullscreen; - changesmade = 0; - - dax = 0; - for (day = 0; day < validmodecnt; day++) - { - if (dax == ARRAY_SIZE(vidsets)) break; - for (daz = 0; daz < dax; daz++) - if ((validmode[day].bpp|((validmode[day].fs&1)<<16)) == (vidsets[daz]&0x1ffffl)) break; - if (vidsets[daz] != -1) continue; - if (validmode[day].bpp == 8) - { - vidsets[dax++] = 8|((validmode[day].fs&1)<<16); -// 8-bit Polymost can diaf -// vidsets[dax++] = 0x20000|8|((validmode[day].fs&1)<<16); - } - else - vidsets[dax++] = 0x20000|validmode[day].bpp|((validmode[day].fs&1)<<16); - } - for (dax = 0; dax < (int32_t)ARRAY_SIZE(vidsets) && vidsets[dax] != -1; dax++) - if (vidsets[dax] == (((getrendermode() >= REND_POLYMOST)<<17)|(fullscreen<<16)|bpp)) break; - if (dax < (int32_t)ARRAY_SIZE(vidsets)) newvidset = dax; - curvidset = newvidset; - - M_ChangeMenu(MENU_VIDEOSETUP); - } - break; - case 3: - if (ud.recstat != 1) - M_ChangeMenu(MENU_PLAYER); - break; - case 4: - currentlist = 0; - case 5: - case 6: - if (x==6 && !CONTROL_JoyPresent) break; - M_ChangeMenu(MENU_KEYBOARDSETUP+x-4); - break; - } - - menutext(160,margin, MENUHIGHLIGHT(0),0,"Game Setup"); - menutext(160,margin+18, MENUHIGHLIGHT(1),0,"Sound Setup"); - menutext(160,margin+18+18, MENUHIGHLIGHT(2),0,"Video Setup"); - menutext(160,margin+18+18+18, MENUHIGHLIGHT(3),ud.recstat == 1,"Player Setup"); - menutext(160,margin+18+18+18+18, MENUHIGHLIGHT(4),0,"Keyboard Setup"); - menutext(160,margin+18+18+18+18+18, MENUHIGHLIGHT(5),0,"Mouse Setup"); - menutext(160,margin+18+18+18+18+18+18,MENUHIGHLIGHT(6),CONTROL_JoyPresent==0,"Joystick Setup"); - break; - - // JBF 20031206: Video settings menu - case MENU_VIDEOSETUP: - M_DrawTopBar("Video Setup"); - - margin = MENU_MARGIN_REGULAR; - -#ifdef USE_OPENGL - x = (7/*+(getrendermode() >= REND_POLYMOST)*/); -#else - x = 7; -#endif -// onbar = (getrendermode() == REND_CLASSIC && probey == 6); // (probey == 4); - if (probey == 0 || probey == 1 || probey == 2) - x = M_Probe(margin,50,16,x); - else if (probey == 3) - x = M_Probe(margin,50+16+16+22,0,x); - else - x = M_Probe(margin,50+62-16-16-16,16,x); - - if ((probey >= 0 && probey <= 2) && (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_RightArrow))) - { - S_PlaySound(PISTOL_BODYHIT); - x=probey; - } - - switch (x) - { - case -1: - M_ChangeMenu(MENU_OPTIONS); - probey = 2; - break; - - case 0: - do - { - if (KB_KeyPressed(sc_LeftArrow)) - { - newvidmode--; - if (newvidmode < 0) newvidmode = validmodecnt-1; - } - else - { - newvidmode++; - if (newvidmode >= validmodecnt) newvidmode = 0; - } - } - while ((validmode[newvidmode].fs&1) != ((vidsets[newvidset]>>16)&1) || validmode[newvidmode].bpp != (vidsets[newvidset] & 0x0ffff)); - //OSD_Printf("New mode is %dx%dx%d-%d %d\n",validmode[newvidmode].xdim,validmode[newvidmode].ydim,validmode[newvidmode].bpp,validmode[newvidmode].fs,newvidmode); - if ((curvidmode == 0x7fffffffl && newvidmode == validmodecnt) || curvidmode == newvidmode) - changesmade &= ~1; - else - changesmade |= 1; - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_RightArrow); - break; - - case 1: - { - int32_t lastvidset, lastvidmode, safevidmode = -1; - lastvidset = newvidset; - lastvidmode = newvidmode; - // find the next vidset compatible with the current fullscreen setting - while (vidsets[0] != -1) - { - newvidset++; - if (newvidset == ARRAY_SIZE(vidsets) || vidsets[newvidset] == -1) - { - newvidset = -1; - continue; - } - if (((vidsets[newvidset]>>16)&1) != newfullscreen) continue; - break; - } - - if ((vidsets[newvidset] & 0x0ffff) != (vidsets[lastvidset] & 0x0ffff)) - { - // adjust the video mode to something legal for the new vidset - do - { - newvidmode++; - if (newvidmode == lastvidmode) break; // end of cycle - if (newvidmode >= validmodecnt) - { - if (safevidmode != -1) - break; - newvidmode = 0; - } - if (validmode[newvidmode].bpp == (vidsets[newvidset]&0x0ffff) && - validmode[newvidmode].fs == newfullscreen && - validmode[newvidmode].xdim <= validmode[lastvidmode].xdim && - (safevidmode==-1?1:(validmode[newvidmode].xdim>=validmode[safevidmode].xdim)) && - validmode[newvidmode].ydim <= validmode[lastvidmode].ydim && - (safevidmode==-1?1:(validmode[newvidmode].ydim>=validmode[safevidmode].ydim)) - ) - safevidmode = newvidmode; - } - while (1); - if (safevidmode == -1) - { - //OSD_Printf("No best fit!\n"); - newvidmode = lastvidmode; - newvidset = lastvidset; - } - else - { - //OSD_Printf("Best fit is %dx%dx%d-%d %d\n",validmode[safevidmode].xdim,validmode[safevidmode].ydim,validmode[safevidmode].bpp,validmode[safevidmode].fs,safevidmode); - newvidmode = safevidmode; - } - } - if (newvidset != curvidset) changesmade |= 4; - else changesmade &= ~4; - if (newvidmode != curvidmode) changesmade |= 1; - else changesmade &= ~1; - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_RightArrow); - } - break; - - case 2: - newfullscreen = !newfullscreen; - { - int32_t lastvidset, lastvidmode, safevidmode = -1, safevidset = -1; - lastvidset = newvidset; - lastvidmode = newvidmode; - // find the next vidset compatible with the current fullscreen setting - while (vidsets[0] != -1) - { - newvidset++; - if (newvidset == lastvidset) break; - if (newvidset == ARRAY_SIZE(vidsets) || vidsets[newvidset] == -1) - { - newvidset = -1; - continue; - } - if (((vidsets[newvidset]>>16)&1) != newfullscreen) continue; - if ((vidsets[newvidset] & 0x2ffff) != (vidsets[lastvidset] & 0x2ffff)) - { - if ((vidsets[newvidset] & 0x20000) == (vidsets[lastvidset] & 0x20000)) safevidset = newvidset; - continue; - } - break; - } - if (newvidset == lastvidset) - { - if (safevidset == -1) - { - newfullscreen = !newfullscreen; - break; - } - else - { - newvidset = safevidset; - } - } - - // adjust the video mode to something legal for the new vidset - do - { - newvidmode++; - if (newvidmode == lastvidmode) break; // end of cycle - if (newvidmode >= validmodecnt) newvidmode = 0; - if (validmode[newvidmode].bpp == (vidsets[newvidset]&0x0ffff) && - validmode[newvidmode].fs == newfullscreen && - validmode[newvidmode].xdim <= validmode[lastvidmode].xdim && - (safevidmode==-1?1:(validmode[newvidmode].xdim>=validmode[safevidmode].xdim)) && - validmode[newvidmode].ydim <= validmode[lastvidmode].ydim && - (safevidmode==-1?1:(validmode[newvidmode].ydim>=validmode[safevidmode].ydim)) - ) - safevidmode = newvidmode; - } - while (1); - if (safevidmode == -1) - { - //OSD_Printf("No best fit!\n"); - newvidmode = lastvidmode; - newvidset = lastvidset; - newfullscreen = !newfullscreen; - } - else - { - //OSD_Printf("Best fit is %dx%dx%d-%d %d\n",validmode[safevidmode].xdim,validmode[safevidmode].ydo,,validmode[safevidmode].bpp,validmode[safevidmode].fs,safevidmode); - newvidmode = safevidmode; - } - if (newvidset != curvidset) changesmade |= 4; - else changesmade &= ~4; - if (newvidmode != curvidmode) changesmade |= 1; - else changesmade &= ~1; - } - if (newfullscreen == fullscreen) changesmade &= ~2; - else changesmade |= 2; - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_RightArrow); - break; - - case 3: - if (!changesmade) break; - { - int32_t pxdim, pydim, pfs, pbpp, prend; - int32_t nxdim, nydim, nfs, nbpp, nrend; - - pxdim = xdim; - pydim = ydim; - pbpp = bpp; - pfs = fullscreen; - prend = getrendermode(); - nxdim = (newvidmode==validmodecnt)?xdim:validmode[newvidmode].xdim; - nydim = (newvidmode==validmodecnt)?ydim:validmode[newvidmode].ydim; - nfs = newfullscreen; - nbpp = (newvidmode==validmodecnt)?bpp:validmode[newvidmode].bpp; - nrend = (vidsets[newvidset] & 0x20000) ? (nbpp==8?2: -#ifdef USE_OPENGL - glrendmode -#else - 0 -#endif - ) : 0; - - if (setgamemode(nfs, nxdim, nydim, nbpp) < 0) - { - if (setgamemode(pfs, pxdim, pydim, pbpp) < 0) - { - setrendermode(prend); - G_GameExit("Failed restoring old video mode."); - } - else onvideomodechange(pbpp > 8); - } - else onvideomodechange(nbpp > 8); - - g_restorePalette = -1; - G_UpdateScreenArea(); - setrendermode(nrend); - - curvidmode = newvidmode; - curvidset = newvidset; - changesmade = 0; - - ud.config.ScreenMode = fullscreen; - ud.config.ScreenWidth = xdim; - ud.config.ScreenHeight = ydim; - ud.config.ScreenBPP = bpp; - } - break; - - case 4: - M_ChangeMenu(MENU_COLCORR); - break; - - case 5: - if (getrendermode() == REND_CLASSIC) - { - ud.detail = 1-ud.detail; - break; - } -#ifdef USE_OPENGL - gltexfiltermode++; - if (gltexfiltermode > 5) - gltexfiltermode = 0; - gltexapplyprops(); - break; -#endif - case 6: -// if (getrendermode() == REND_CLASSIC) break; - M_ChangeMenu(MENU_RENDERERSETUP); - break; - } - - menutext(margin,50,MENUHIGHLIGHT(0),0,"Resolution"); - Bsprintf(tempbuf,"%d x %d", - (newvidmode==validmodecnt)?xdim:validmode[newvidmode].xdim, - (newvidmode==validmodecnt)?ydim:validmode[newvidmode].ydim); - mgametext(margin+168,50-8,tempbuf,MENUHIGHLIGHT(0),2+8+16); - - menutext(margin,50+16,MENUHIGHLIGHT(1),0,"Renderer"); - if (vidsets[newvidset]&0x20000) - Bsprintf(tempbuf,"%d-bit OpenGL", vidsets[newvidset]&0x0ffff); - else - Bsprintf(tempbuf,"Software"); - mgametext(margin+168,50+16-8,tempbuf,MENUHIGHLIGHT(1),2+8+16); - - menutext(margin,50+16+16,MENUHIGHLIGHT(2),0,"Fullscreen"); - menutext(margin+168,50+16+16,MENUHIGHLIGHT(2),0,newfullscreen?"Yes":"No"); - - menutext(margin+16,50+16+16+22,MENUHIGHLIGHT(3),changesmade==0,"Apply Changes"); - - menutext(margin,50+62+16,MENUHIGHLIGHT(4),0,"Color Correction"); - /* { - short ss = ud.brightness; - bar(c+171,50+62+16,&ss,8,x==4,MENUHIGHLIGHT(4),PHX(-6)); - if (x==4) - { - ud.brightness = ss; - setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0); - } - } - */ - if (getrendermode() == REND_CLASSIC) - { - menutext(margin,50+62+16+16,MENUHIGHLIGHT(5),0,"Pixel Doubling"); - menutext(margin+168,50+62+16+16,MENUHIGHLIGHT(5),0,ud.detail?"Off":"On"); - modval(0,1,(int32_t *)&ud.detail,1,probey==5); - } -#ifdef USE_OPENGL - else - { - int32_t filter = gltexfiltermode; - menutext(margin,50+62+16+16,MENUHIGHLIGHT(5),0,"Texture Filter"); - switch (gltexfiltermode) - { - case 0: - strcpy(tempbuf,"Nearest"); - break; - case 1: - strcpy(tempbuf,"Linear"); - break; - case 2: - strcpy(tempbuf,"Near_MM_Near"); - break; - case 3: - strcpy(tempbuf,"Bilinear"); - break; - case 4: - strcpy(tempbuf,"Near_MM_Lin"); - break; - case 5: - strcpy(tempbuf,"Trilinear"); - break; - default: - strcpy(tempbuf,"Other"); - break; - } - modval(0,5,(int32_t *)&gltexfiltermode,1,probey==5); - if (gltexfiltermode != filter) - gltexapplyprops(); - mgametextpal(margin+168,50+62+16+16-8,tempbuf,MENUHIGHLIGHT(5),getrendermode() == REND_CLASSIC); - } -#endif - menutext(margin,50+62+16+16+16,MENUHIGHLIGHT(6),0 /*bpp==8*/,"Renderer Setup"); - break; - - case MENU_KEYBOARDSETUP: - M_DrawTopBar("Keyboard Setup"); - - margin = MENU_MARGIN_REGULAR; - - onbar = 0; - - if (probey == NUMGAMEFUNCTIONS) - x = probesm(60,145,0,NUMGAMEFUNCTIONS+2); - else if (probey == NUMGAMEFUNCTIONS+1) - x = probesm(60,152,0,NUMGAMEFUNCTIONS+2); - else x = probesm(0,0,0,NUMGAMEFUNCTIONS+2); - - if (x==-1) - { - M_ChangeMenu(MENU_OPTIONS); - probey = 4; - } - else if (x == NUMGAMEFUNCTIONS) - { - CONFIG_SetDefaultKeys((const char (*)[MAXGAMEFUNCLEN])keydefaults); - break; - } - else if (x == NUMGAMEFUNCTIONS+1) - { - CONFIG_SetDefaultKeys(oldkeydefaults); - break; - } - else if (x>=0) - { - function = probey; - whichkey = currentlist; - M_ChangeMenu(MENU_KEYBOARDASSIGN); - KB_FlushKeyboardQueue(); - KB_ClearLastScanCode(); - break; - } - - // the top of our list - m = clamp(probey-6, 0, NUMGAMEFUNCTIONS-13); - - if (probey == gamefunc_Show_Console) currentlist = 0; - else if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || - KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || - KB_KeyPressed(sc_Tab)) - { - currentlist ^= 1; - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_RightArrow); - KB_ClearKeyDown(sc_kpad_4); - KB_ClearKeyDown(sc_kpad_6); - KB_ClearKeyDown(sc_Tab); - S_PlaySound(KICK_HIT); - } - else if (KB_KeyPressed(sc_Delete)) - { - char key[2]; - key[0] = ud.config.KeyboardKeys[probey][0]; - key[1] = ud.config.KeyboardKeys[probey][1]; - ud.config.KeyboardKeys[probey][currentlist] = 0xff; - CONFIG_MapKey(probey, ud.config.KeyboardKeys[probey][0], key[0], ud.config.KeyboardKeys[probey][1], key[1]); - S_PlaySound(KICK_HIT); - KB_ClearKeyDown(sc_Delete); - } - - for (l=min(13,NUMGAMEFUNCTIONS)-1; l >= 0 ; l--) - { - p = CONFIG_FunctionNumToName(m+l); - if (!p) continue; - - strcpy(tempbuf, p); - for (i=0; tempbuf[i]; i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - // game function name redefined --> pal 8 text - minitextshade(70,34+l*8,tempbuf,MINIHIGHLIGHT(m+l), - Bstrcmp(keydefaults[3*(m+l)],oldkeydefaults[3*(m+l)]) ? 8 : 1, 10+16); - - //strcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[m+l][0])); - strcpy(tempbuf, (char *)getkeyname(ud.config.KeyboardKeys[m+l][0])); - if (!tempbuf[0]) strcpy(tempbuf, " -"); - minitextshade(70+100,34+l*8,tempbuf, - MINIHIGHLIGHTCOND(m+l == probey && !currentlist),2,10+16); - - //strcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[m+l][1])); - strcpy(tempbuf, (char *)getkeyname(ud.config.KeyboardKeys[m+l][1])); - if (!tempbuf[0]) strcpy(tempbuf, " -"); - minitextshade(70+120+34,34+l*8,tempbuf, - MINIHIGHLIGHTCOND(m+l == probey && currentlist),2,10+16); - } - - mgametextpal(160,140, "Reset Keys To Defaults",MENUHIGHLIGHT(NUMGAMEFUNCTIONS),10); - mgametextpal(160,140+7,"Set Classic Key Layout",MENUHIGHLIGHT(NUMGAMEFUNCTIONS+1),10); - mgametext(160,144+9+3,"Up/Down = Select Action",0,2+8+16); - mgametext(160,144+9+9+3,"Left/Right = Select List",0,2+8+16); - mgametext(160,144+9+9+9+3,"Enter = Modify Delete = Clear",0,2+8+16); - - break; - - case MENU_KEYBOARDASSIGN: - { - int32_t sc; - M_DrawTopBar("Keyboard Setup"); - - mgametext(320>>1,90,"Press the key to assign as",0,2+8+16); - Bsprintf(tempbuf,"%s for \"%s\"", whichkey?"secondary":"primary", CONFIG_FunctionNumToName(function)); - mgametext(320>>1,90+9,tempbuf,0,2+8+16); - mgametext(320>>1,90+9+9+9,"Press \"Escape\" To Cancel",0,2+8+16); - - sc = KB_GetLastScanCode(); - if (sc != sc_None || RMB) - { - if (sc == sc_Escape || RMB) - { S_PlaySound(EXITMENUSOUND); - } - else - { - char key[2]; - key[0] = ud.config.KeyboardKeys[function][0]; - key[1] = ud.config.KeyboardKeys[function][1]; - S_PlaySound(PISTOL_BODYHIT); - - ud.config.KeyboardKeys[function][whichkey] = KB_GetLastScanCode(); - - CONFIG_MapKey(function, ud.config.KeyboardKeys[function][0], key[0], ud.config.KeyboardKeys[function][1], key[1]); + M_ChangeMenu(cm->parentID); } - M_ChangeMenu(MENU_KEYBOARDSETUP); - - currentlist = whichkey; - probey = function; - - KB_ClearKeyDown(sc); - } - - break; - } - case MENU_MOUSESETUP: - M_DrawTopBar("Mouse Setup"); - - margin = 60-4; - - onbar = (probey == NUMMOUSEFUNCTIONS); - if (probey < NUMMOUSEFUNCTIONS) - x = probesm(73,38,8,NUMMOUSEFUNCTIONS+2+2+1); - else - x = probesm(40,123-(NUMMOUSEFUNCTIONS)*9,9,NUMMOUSEFUNCTIONS+2+2+1); - - if (x==-1) - { - M_ChangeMenu(MENU_OPTIONS); - probey = 5; - break; - } - else if (x == NUMMOUSEFUNCTIONS) - { - // sensitivity - } - else if (x == NUMMOUSEFUNCTIONS+1) - { - // mouse aiming toggle - if (!ud.mouseaiming) g_myAimMode = 1-g_myAimMode; - } - else if (x == NUMMOUSEFUNCTIONS+2) - { - // invert mouse aim - ud.mouseflip = 1-ud.mouseflip; - } - else if (x == NUMMOUSEFUNCTIONS+2+1) - { - //input smoothing - ud.config.SmoothInput = !ud.config.SmoothInput; - CONTROL_SmoothMouse = ud.config.SmoothInput; - } - else if (x == NUMMOUSEFUNCTIONS+2+2) - { - //advanced - M_ChangeMenu(MENU_MOUSEADVANCED); - break; - } - else if (x >= 0) - { - //set an option - M_ChangeMenu(MENU_MOUSEASSIGN); - function = 0; - whichkey = x; - if (x < NUMDOUBLEMBTNS*2) - probey = ud.config.MouseFunctions[x>>1][x&1]; - else - probey = ud.config.MouseFunctions[x-NUMDOUBLEMBTNS][0]; - if (probey < 0) probey = NUMGAMEFUNCTIONS-1; - break; - } - - for (l=0; l < NUMMOUSEFUNCTIONS; l++) - { - tempbuf[0] = 0; - if (l < NUMDOUBLEMBTNS*2) + if (I_CheckAllInput()) { - if (l&1) + I_ClearAllInput(); + + S_PlaySound(EXITMENUSOUND); + + M_ChangeMenu(((MenuMessage_t*)cm->object)->linkID); + } + + M_PreMenuInput(NULL, NULL); + break; + + case Verify: + if (I_ReturnTrigger() || KB_KeyPressed(sc_N)) + { + I_ReturnTriggerClear(); + KB_ClearKeyDown(sc_N); + + M_MenuVerify(0); + + M_ChangeMenu(cm->parentID); + } + + if (I_AdvanceTrigger() || KB_KeyPressed(sc_Y)) + { + I_AdvanceTriggerClear(); + KB_ClearKeyDown(sc_Y); + + M_MenuVerify(1); + + M_ChangeMenu(((MenuVerify_t*)cm->object)->linkID); + } + + M_PreMenuInput(NULL, NULL); + break; + + case Menu: + { + int32_t state, movement = 0; + + MenuMenu_t *menu = (MenuMenu_t*)cm->object; + MenuGroup_t *currgroup = menu->grouplist[menu->currentGroup]; + MenuEntry_t *currentry = currgroup->entrylist[currgroup->currentEntry]; + + state = M_DetermineMenuSpecialState(currentry); + + if (state == 0) + { + if (currentry != NULL) + switch (currentry->type) { - Bstrcpy(tempbuf, "Double "); - m = ud.config.MouseFunctions[l>>1][1]; - } - else - m = ud.config.MouseFunctions[l>>1][0]; - Bstrcat(tempbuf, mousebuttonnames[l>>1]); - } - else - { - Bstrcpy(tempbuf, mousebuttonnames[l-NUMDOUBLEMBTNS]); - m = ud.config.MouseFunctions[l-NUMDOUBLEMBTNS][0]; - } - - minitextshade(margin+20,34+l*8,tempbuf,MINIHIGHLIGHT(l),1,10+16); - - if (m == -1) - minitextshade(margin+100+20,34+l*8," -None-",MINIHIGHLIGHT(l),2,10+16); - else - { - strcpy(tempbuf, CONFIG_FunctionNumToName(m)); - for (i=0; tempbuf[i]; i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(margin+100+20,34+l*8,tempbuf,MINIHIGHLIGHT(l),2,10+16); - } - } - - mgametextpal(40,118,"Base mouse sensitivity",MENUHIGHLIGHT(NUMMOUSEFUNCTIONS),10); - mgametextpal(40,118+9,"Use mouse aiming",!ud.mouseaiming?MENUHIGHLIGHT(NUMMOUSEFUNCTIONS+1):DISABLEDMENUSHADE,10); - mgametextpal(40,118+9+9,"Invert mouse",MENUHIGHLIGHT(NUMMOUSEFUNCTIONS+2),10); - mgametextpal(40,118+9+9+9,"Smooth mouse movement",MENUHIGHLIGHT(NUMMOUSEFUNCTIONS+2+1),10); - mgametextpal(40,118+9+9+9+9,"Advanced mouse setup",MENUHIGHLIGHT(NUMMOUSEFUNCTIONS+2+2),10); - - { - int32_t sense = (int32_t)(CONTROL_MouseSensitivity * 4.0f); - sense = clamp(sense, 0, 63); - barsm(248,126,&sense,2,x==NUMMOUSEFUNCTIONS,MENUHIGHLIGHT(NUMMOUSEFUNCTIONS),0); - CONTROL_MouseSensitivity = sense / 4.0f; - } - - if (!ud.mouseaiming) modval(0,1,(int32_t *)&g_myAimMode,1,probey == NUMMOUSEFUNCTIONS+1); - else if (probey == NUMMOUSEFUNCTIONS+1) - { - mgametext(160,140+9+9+9,"Set mouse aim type to toggle on/off",0,2+8+16); - mgametext(160,140+9+9+9+9,"in the Player Setup menu to enable",0,2+8+16); - } - - modval(0,1,(int32_t *)&ud.mouseflip,1,probey == NUMMOUSEFUNCTIONS+2); - modval(0,1,(int32_t *)&ud.config.SmoothInput,1,probey == NUMMOUSEFUNCTIONS+2+1); - if (probey == NUMMOUSEFUNCTIONS+2+1) - { -// mgametext(160,160+9,"This option incurs a movement delay",0,2+8+16); - CONTROL_SmoothMouse = ud.config.SmoothInput; - } - - mgametextpal(240,118+9, g_myAimMode && !ud.mouseaiming ? "Yes" : "No", - !ud.mouseaiming?MENUHIGHLIGHT(NUMMOUSEFUNCTIONS+1):DISABLEDMENUSHADE, 0); - mgametextpal(240,118+9+9, !ud.mouseflip ? "Yes" : "No", MENUHIGHLIGHT(NUMMOUSEFUNCTIONS+2), 0); - mgametextpal(240,118+9+9+9, ud.config.SmoothInput ? "Yes" : "No", MENUHIGHLIGHT(NUMMOUSEFUNCTIONS+2+1), 0); - - if (probey < NUMMOUSEFUNCTIONS) - { - mgametext(160,160+9,"Up/Down = Select Button",0,2+8+16); - mgametext(160,160+9+9,"Enter = Modify",0,2+8+16); - } - break; - - case MENU_MOUSEASSIGN: - if (function == 0) M_DrawTopBar("Mouse Setup"); - else if (function == 1) M_DrawTopBar("Digital Axes Setup"); - else if (function == 2) M_DrawTopBar("Joystick Buttons"); - else if (function == 3) M_DrawTopBar("Joystick Axes"); - - x = M_Probe(0,0,0,NUMGAMEFUNCTIONS); - - if (x==-1) - { - if (function == 0) - { - // mouse button - M_ChangeMenu(MENU_MOUSESETUP); - probey = whichkey; - } - else if (function == 1) - { - // mouse digital axis - M_ChangeMenu(MENU_MOUSEADVANCED); - probey = 3+(whichkey^2); - } - else if (function == 2) - { - // joystick button/hat - M_ChangeMenu(MENU_JOYSTICKBTNS); - probey = whichkey; - } - else if (function == 3) - { - // joystick digital axis - M_ChangeMenu((whichkey>>2)+MENU_JOYSTICKAXES); - probey = 1+((whichkey>>1)&1)*4+(whichkey&1); - } - break; - } - else if (x >= 0) - { - if (x == NUMGAMEFUNCTIONS-1) x = -1; - - if (function == 0) - { - if (whichkey < NUMDOUBLEMBTNS*2) - { - ud.config.MouseFunctions[whichkey>>1][whichkey&1] = x; - CONTROL_MapButton(x, whichkey>>1, whichkey&1, controldevice_mouse); - CONTROL_FreeMouseBind(whichkey>>1); - } - else - { - ud.config.MouseFunctions[whichkey-NUMDOUBLEMBTNS][0] = x; - CONTROL_MapButton(x, whichkey-NUMDOUBLEMBTNS, 0, controldevice_mouse); - CONTROL_FreeMouseBind(whichkey-NUMDOUBLEMBTNS); - - } - M_ChangeMenu(MENU_MOUSESETUP); - probey = whichkey; - } - else if (function == 1) - { - ud.config.MouseDigitalFunctions[whichkey>>1][whichkey&1] = x; - CONTROL_MapDigitalAxis(whichkey>>1, x, whichkey&1, controldevice_mouse); - M_ChangeMenu(MENU_MOUSEADVANCED); - probey = 3+(whichkey^2); - } - else if (function == 2) - { - if (whichkey < 2*joynumbuttons) - { - ud.config.JoystickFunctions[whichkey>>1][whichkey&1] = x; - CONTROL_MapButton(x, whichkey>>1, whichkey&1, controldevice_joystick); - } - else - { - ud.config.JoystickFunctions[joynumbuttons + (whichkey-2*joynumbuttons)][0] = x; - CONTROL_MapButton(x, joynumbuttons + (whichkey-2*joynumbuttons), 0, controldevice_joystick); - } - M_ChangeMenu(MENU_JOYSTICKBTNS); - probey = whichkey; - } - else if (function == 3) - { - ud.config.JoystickDigitalFunctions[whichkey>>1][whichkey&1] = x; - CONTROL_MapDigitalAxis(whichkey>>1, x, whichkey&1, controldevice_joystick); - M_ChangeMenu((whichkey>>2)+MENU_JOYSTICKAXES); - probey = 1+((whichkey>>1)&1)*4+(whichkey&1); - } - break; - } - - mgametext(320>>1,31,"Select a function to assign",0,2+8+16); - - if (function == 0) - { - if (whichkey < NUMDOUBLEMBTNS*2) - Bsprintf(tempbuf,"to %s%s", (whichkey&1)?"double-clicked ":"", mousebuttonnames[whichkey>>1]); - else - Bstrcpy(tempbuf, mousebuttonnames[whichkey-NUMDOUBLEMBTNS]); - } - else if (function == 1) - { - Bstrcpy(tempbuf,"to digital "); - switch (whichkey) - { - case 0: - Bstrcat(tempbuf, "Left"); - break; - case 1: - Bstrcat(tempbuf, "Right"); - break; - case 2: - Bstrcat(tempbuf, "Up"); - break; - case 3: - Bstrcat(tempbuf, "Down"); - break; - } - } - else if (function == 2) - { - static const char *directions[] = - { - "Up", "Right", "Down", "Left" - }; - if (whichkey < 2*joynumbuttons) - Bsprintf(tempbuf,"to %s%s", (whichkey&1)?"double-clicked ":"", getjoyname(1,whichkey>>1)); - else - Bsprintf(tempbuf,"to hat %s", directions[whichkey-2*joynumbuttons]); - } - else if (function == 3) - { - Bsprintf(tempbuf,"to digital %s %s",getjoyname(0,whichkey>>1),(whichkey&1)?"positive":"negative"); - } - - mgametext(320>>1,31+9,tempbuf,0,2+8+16); - - m = clamp(probey-6, 0, NUMGAMEFUNCTIONS-13); - - for (l=0; l < min(13,NUMGAMEFUNCTIONS); l++) - { - if (l+m == NUMGAMEFUNCTIONS-1) - strcpy(tempbuf, " -None-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(m+l)); - - for (i=0; tempbuf[i]; i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(100,51+l*8,tempbuf,MINIHIGHLIGHT(m+l), - Bstrcmp(keydefaults[3*(m+l)],oldkeydefaults[3*(m+l)]) ? 8 : 1, 10+16); - } - - mgametext(320>>1,161,"Press \"Escape\" To Cancel",0,2+8+16); - - break; - - case MENU_MOUSEADVANCED: - M_DrawTopBar("Advanced Mouse"); - - margin = MENU_MARGIN_REGULAR; - - onbar = (probey == 0 || probey == 1 || probey == 2); - if (probey < 3) - x = M_Probe(margin,46,16,7); - else if (probey < 7) - { - m=50; - x = probesm(margin+10,97+16-(9+9+9),9,7); - } - else - { - x = M_Probe(margin,146+16-(16+16+16+16+16+16),16,7); - } - - switch (x) - { - case -1: - M_ChangeMenu(MENU_MOUSESETUP); - probey = NUMMOUSEFUNCTIONS+2+2; - break; - - case 0: - // x-axis scale - case 1: - // y-axis scale - case 2: - // mouse filter - break; - - case 3: - // digital up - case 4: - // digital down - case 5: - // digital left - case 6: - // digital right - function = 1; - whichkey = (x-3)^2; // flip the actual axis number - M_ChangeMenu(MENU_MOUSEASSIGN); - probey = ud.config.MouseDigitalFunctions[whichkey>>1][whichkey&1]; - if (probey < 0) probey = NUMGAMEFUNCTIONS-1; - break; - } - - switch (probey) - { - case 3: - case 4: - case 5: - case 6: - mgametext(160,144+9+9,"Digital axes are not for mouse look",0,2+8+16); - mgametext(160,144+9+9+9,"or for aiming up and down",0,2+8+16); - break; - } - - menutext(margin,46,MENUHIGHLIGHT(0),0,"X-Axis Scale"); - l = (ud.config.MouseAnalogueScale[0]+262144) >> 13; - bar(margin+160+40,46,&l,1,x==0,MENUHIGHLIGHT(0),0); - l = (l<<13)-262144; - if (l != ud.config.MouseAnalogueScale[0]) - { - CONTROL_SetAnalogAxisScale(0, l, controldevice_mouse); - ud.config.MouseAnalogueScale[0] = l; - } - Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0); - mgametext(margin+160-16,46-8,tempbuf,MENUHIGHLIGHT(0),2+8+16); - - menutext(margin,46+16,MENUHIGHLIGHT(1),0,"Y-Axis Scale"); - l = (ud.config.MouseAnalogueScale[1]+262144) >> 13; - bar(margin+160+40,46+16,&l,1,x==1,MENUHIGHLIGHT(1),0); - l = (l<<13)-262144; - if (l != ud.config.MouseAnalogueScale[1]) - { - CONTROL_SetAnalogAxisScale(1, l, controldevice_mouse); - ud.config.MouseAnalogueScale[1] = l; - } - Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0); - mgametext(margin+160-16,46+16-8,tempbuf,MENUHIGHLIGHT(1),2+8+16); - - menutext(margin,46+16+16,MENUHIGHLIGHT(2),0,"Dead Zone"); - l = ud.config.MouseDeadZone>>1; - bar(margin+160+40,46+16+16,&l,2,x==2,MENUHIGHLIGHT(2),0); - ud.config.MouseDeadZone = l<<1; - M_DrawTopBar("Digital Axes Setup"); - - if (ud.config.MouseDeadZone == 0) - Bsprintf(tempbuf," Off"); - else if (ud.config.MouseDeadZone < 48) - Bsprintf(tempbuf," Low"); - else if (ud.config.MouseDeadZone < 96) - Bsprintf(tempbuf," Med"); - else if (ud.config.MouseDeadZone < 128) - Bsprintf(tempbuf,"High"); - - mgametext(margin+160-16,46+16+16-8,tempbuf,MENUHIGHLIGHT(2),2+8+16); - - - mgametextpal(margin+10,92+16,"Up:",MENUHIGHLIGHT(3),10); - if (ud.config.MouseDigitalFunctions[1][0] < 0) - strcpy(tempbuf, " -None-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(ud.config.MouseDigitalFunctions[1][0])); - - for (i=0; tempbuf[i]; i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(margin+10+60,93+16,tempbuf,MINIHIGHLIGHT(3),0,10+16); - - mgametextpal(margin+10,92+16+9,"Down:",MENUHIGHLIGHT(4),10); - if (ud.config.MouseDigitalFunctions[1][1] < 0) - strcpy(tempbuf, " -None-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(ud.config.MouseDigitalFunctions[1][1])); - - for (i=0; tempbuf[i]; i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(margin+10+60,93+16+9,tempbuf,MINIHIGHLIGHT(4),0,10+16); - - mgametextpal(margin+10,92+16+9+9,"Left:",MENUHIGHLIGHT(5),10); - if (ud.config.MouseDigitalFunctions[0][0] < 0) - strcpy(tempbuf, " -None-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(ud.config.MouseDigitalFunctions[0][0])); - - for (i=0; tempbuf[i]; i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(margin+10+60,93+16+9+9,tempbuf,MINIHIGHLIGHT(5),0,10+16); - - mgametextpal(margin+10,92+16+9+9+9,"Right:",MENUHIGHLIGHT(6),10); - if (ud.config.MouseDigitalFunctions[0][1] < 0) - strcpy(tempbuf, " -None-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(ud.config.MouseDigitalFunctions[0][1])); - - for (i=0; tempbuf[i]; i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(margin+10+60,93+16+9+9+9,tempbuf,MINIHIGHLIGHT(6),0,10+16); - - break; - - case MENU_JOYSTICKSETUP: - M_DrawTopBar("Joystick Setup"); - - x = M_Probe(160,100-18,18,3); - - switch (x) - { - case -1: - M_ChangeMenu(MENU_OPTIONS); - probey = 6; - break; - case 0: - case 1: - M_ChangeMenu(MENU_JOYSTICKBTNS+x); - break; - case 2: - M_ChangeMenu(MENU_JOYSTICKDEAD); - break; - } - - menutext(160,100-18,MENUHIGHLIGHT(0),0,"Edit Buttons"); - menutext(160,100 ,MENUHIGHLIGHT(1),0,"Edit Axes"); - menutext(160,100+18,MENUHIGHLIGHT(2),0,"Dead Zones"); - - break; - - case MENU_JOYSTICKBTNS: - M_DrawTopBar("Joystick Buttons"); - - margin = 2*joynumbuttons + 4*(joynumhats>0); - - x = M_Probe(0,0,0,margin); - - if (x == -1) - { - M_ChangeMenu(MENU_JOYSTICKSETUP); - probey = 0; - break; - } - else if (x >= 0) - { - function = 2; - whichkey = x; - M_ChangeMenu(MENU_MOUSEASSIGN); - if (x < 2*joynumbuttons) - { - probey = ud.config.JoystickFunctions[x>>1][x&1]; - } - else - { - probey = ud.config.JoystickFunctions[joynumbuttons + (x-2*joynumbuttons)][0]; - } - if (probey < 0) probey = NUMGAMEFUNCTIONS-1; - break; - } - - // the top of our list - if (margin < 13) m = 0; - else - { - m = probey - 6; - if (m < 0) m = 0; - else if (m + 13 >= margin) m = margin-13; - } - - for (l=0; l>1)); - x = ud.config.JoystickFunctions[(l+m)>>1][(l+m)&1]; - } - else - { - static const char *directions[] = - { - "Up", "Right", "Down", "Left" - }; - Bsprintf(tempbuf, "Hat %s", directions[(l+m)-2*joynumbuttons]); - x = ud.config.JoystickFunctions[joynumbuttons + ((l+m)-2*joynumbuttons)][0]; - } - minitextshade(80-4,33+l*8,tempbuf,MINIHIGHLIGHT(m+l),1,10+16); - - if (x == -1) - minitextshade(176,33+l*8," -None-",MINIHIGHLIGHT(m+l),2,10+16); - else - { - strcpy(tempbuf, CONFIG_FunctionNumToName(x)); - for (i=0; tempbuf[i]; i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(176,33+l*8,tempbuf,MINIHIGHLIGHT(m+l),2,10+16); - } - } - - mgametext(160,149,"Up/Down = Select Button",0,2+8+16); - mgametext(160,149+9,"Enter = Modify",0,2+8+16); - break; - - case MENU_JOYSTICKAXES: - case MENU_JOYSTICKAXES2: - case MENU_JOYSTICKAXES3: - case MENU_JOYSTICKAXES4: - case MENU_JOYSTICKAXES5: - case MENU_JOYSTICKAXES6: - case MENU_JOYSTICKAXES7: - case MENU_JOYSTICKAXES8: - { - int32_t thispage, twothispage; - - M_DrawTopBar("Joystick Axes"); - - thispage = (g_currentMenu < MENU_JOYSTICKAXES3) ? (g_currentMenu-MENU_JOYSTICKAXES) : (g_currentMenu-MENU_JOYSTICKAXES3)+2; - twothispage = (thispage*2+1 < joynumaxes); - - onbar = 0; - switch (probey) - { - case 0: - case 4: - onbar = 1; - x = M_Probe(88,61+(probey==4)*64,0,1+(4< 2) - { - if (thispage == ((joynumaxes+1)/2)-1) M_ChangeMenu(MENU_JOYSTICKAXES); - else - { - if (g_currentMenu == MENU_JOYSTICKAXES2) M_ChangeMenu(MENU_JOYSTICKAXES3); - else M_ChangeMenu(g_currentMenu+1); - } - } - break; - - case 4: // bar - if (!twothispage && joynumaxes > 2) - M_ChangeMenu(MENU_JOYSTICKAXES); - case 0: - break; - - case 1: // digitals - case 2: - case 5: - case 6: - function = 3; - whichkey = ((thispage*2+(x==5||x==6)) << 1) + (x==2||x==6); - M_ChangeMenu(MENU_MOUSEASSIGN); - probey = ud.config.JoystickDigitalFunctions[whichkey>>1][whichkey&1]; - if (probey < 0) probey = NUMGAMEFUNCTIONS-1; - break; - - case 3: // analogues - case 7: - l = ud.config.JoystickAnalogueAxes[thispage*2+(x==7)]; - if (l == analog_turning) l = analog_strafing; - else if (l == analog_strafing) l = analog_lookingupanddown; - else if (l == analog_lookingupanddown) l = analog_moving; - else if (l == analog_moving) l = -1; - else l = analog_turning; - ud.config.JoystickAnalogueAxes[thispage*2+(x==7)] = l; - CONTROL_MapAnalogAxis(thispage*2+(x==7),l,controldevice_joystick); - { - mouseyaxismode = -1; - } - break; - default: - break; - } - - if (getjoyname(0,thispage*2) != NULL) - { - Bstrcpy(tempbuf,(char *)getjoyname(0,thispage*2)); - menutext(42,48,MENUHIGHLIGHTCOND(0 <= probey && probey <= 3),0,tempbuf); - } - - if (twothispage) - { - if (getjoyname(0,thispage*2+1) != NULL) - { - Bstrcpy(tempbuf,(char *)getjoyname(0,thispage*2+1)); - menutext(42,48+64,MENUHIGHLIGHTCOND(4 <= probey && probey <= 7),0,tempbuf); - } - } - - mgametext(76,54,"Scale",MENUHIGHLIGHT(0),2+8+16); - l = (ud.config.JoystickAnalogueScale[thispage*2]+262144) >> 13; - bar(140+56,54+8,&l,1,x==0,MENUHIGHLIGHT(0),0); - l = (l<<13)-262144; - if (l != ud.config.JoystickAnalogueScale[thispage*2]) - { - CONTROL_SetAnalogAxisScale(thispage*2, l, controldevice_joystick); - ud.config.JoystickAnalogueScale[thispage*2] = l; - } - Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0); - mgametext(140,54,tempbuf,MENUHIGHLIGHT(0),2+8+16); - - mgametext(76,54+15,"Digital",MENUHIGHLIGHTCOND(probey == 1 || probey == 2),2+8+16); - if (ud.config.JoystickDigitalFunctions[thispage*2][0] < 0) - strcpy(tempbuf, " -None-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(ud.config.JoystickDigitalFunctions[thispage*2][0])); - - for (i=0; tempbuf[i]; i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(140+12,54+15,tempbuf,MINIHIGHLIGHT(1),0,10+16); - - if (ud.config.JoystickDigitalFunctions[thispage*2][1] < 0) - strcpy(tempbuf, " -None-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(ud.config.JoystickDigitalFunctions[thispage*2][1])); - - for (i=0; tempbuf[i]; i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(140+12+72,54+15,tempbuf,MINIHIGHLIGHT(2),0,10+16); - - mgametext(76,54+15+15,"Analog",MENUHIGHLIGHT(3),2+8+16); - if (CONFIG_AnalogNumToName(ud.config.JoystickAnalogueAxes[thispage*2])) - { - p = CONFIG_AnalogNumToName(ud.config.JoystickAnalogueAxes[thispage*2]); - if (p) - { - mgametext(140+12,54+15+15, strchr(p,'_')+1, MENUHIGHLIGHT(3), 2+8+16); - } - } - - if (twothispage) - { - mgametext(76,54+64,"Scale",MENUHIGHLIGHT(4),2+8+16); - l = (ud.config.JoystickAnalogueScale[thispage*2+1]+262144) >> 13; - bar(140+56,54+8+64,&l,1,x==4,MENUHIGHLIGHT(4),0); - l = (l<<13)-262144; - if (l != ud.config.JoystickAnalogueScale[thispage*2+1]) - { - CONTROL_SetAnalogAxisScale(thispage*2+1, l, controldevice_joystick); - ud.config.JoystickAnalogueScale[thispage*2+1] = l; - } - Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0); - mgametext(140,54+64,tempbuf,MENUHIGHLIGHT(4),2+8+16); - - mgametext(76,54+64+15,"Digital",MENUHIGHLIGHTCOND(probey == 5 || probey == 6),2+8+16); - if (ud.config.JoystickDigitalFunctions[thispage*2+1][0] < 0) - strcpy(tempbuf, " -None-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(ud.config.JoystickDigitalFunctions[thispage*2+1][0])); - - for (i=0; tempbuf[i]; i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(140+12,54+15+64,tempbuf,MINIHIGHLIGHT(5),0,10+16); - - if (ud.config.JoystickDigitalFunctions[thispage*2+1][1] < 0) - strcpy(tempbuf, " -None-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(ud.config.JoystickDigitalFunctions[thispage*2+1][1])); - - for (i=0; tempbuf[i]; i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(140+12+72,54+15+64,tempbuf,MINIHIGHLIGHT(6),0,10+16); - - mgametext(76,54+64+15+15,"Analog",MENUHIGHLIGHT(7),2+8+16); - if (CONFIG_AnalogNumToName(ud.config.JoystickAnalogueAxes[thispage*2+1])) - { - p = CONFIG_AnalogNumToName(ud.config.JoystickAnalogueAxes[thispage*2+1]); - if (p) - { - mgametext(140+12,54+64+15+15, strchr(p,'_')+1, MENUHIGHLIGHT(7), 2+8+16); - } - } - } - - if (joynumaxes > 2) - { - menutext(320>>1,twothispage?174:124,twothispage?MENUHIGHLIGHT(8):MENUHIGHLIGHT(4),(joynumaxes<=2),"Next..."); - Bsprintf(tempbuf,"Page %d of %d",thispage+1,(joynumaxes+1)/2); - mgametext(320-100,174,tempbuf,0,2+8+16); - } - break; - } - - case MENU_JOYSTICKDEAD: - case MENU_JOYSTICKDEAD2: - case MENU_JOYSTICKDEAD3: - case MENU_JOYSTICKDEAD4: - { - // Pray this is enough pages for now :-| - int32_t first,last; - M_DrawTopBar("Joy Dead Zones"); - - first = 4*(g_currentMenu-MENU_JOYSTICKDEAD); - last = min(4*(g_currentMenu-MENU_JOYSTICKDEAD)+4,joynumaxes); - - onbar = probey==2*(last-first) ? 0 : 1; - x = M_Probe(320,48,15,2*(last-first)+(joynumaxes>4)); - - if (x==-1) - { - M_ChangeMenu(MENU_JOYSTICKSETUP); - probey = 2; - break; - } - else if (x==2*(last-first) && joynumaxes>4) - { - M_ChangeMenu((g_currentMenu-MENU_JOYSTICKDEAD) == (joynumaxes/4) ? MENU_JOYSTICKDEAD : (g_currentMenu+1)); - probey = 0; - break; - } - - for (m = first; m < last; m++) - { - int32_t odx,dx,ody,dy; - Bstrcpy(tempbuf,(char *)getjoyname(0,m)); - menutext(32,48+30*(m-first),MENUHIGHLIGHTCOND( probey == (m-first)*2 || probey == (m-first)*2+1),0,tempbuf); - - mgametext(128,48+30*(m-first)-8,"Dead",MENUHIGHLIGHT((m-first)*2),2+8+16); - mgametext(128,48+30*(m-first)-8+15,"Satu",MENUHIGHLIGHT((m-first)*2+1),2+8+16); - - dx = odx = min(64,64l*ud.config.JoystickAnalogueDead[m]/10000l); - dy = ody = min(64,64l*ud.config.JoystickAnalogueSaturate[m]/10000l); - - bar(MENU_JOYSTICKAXES3,48+30*(m-first),&dx,4,x==((m-first)*2),MENUHIGHLIGHT((m-first)*2),0); - bar(MENU_JOYSTICKAXES3,48+30*(m-first)+15,&dy,4,x==((m-first)*2+1),MENUHIGHLIGHT((m-first)*2+1),0); - - Bsprintf(tempbuf,"%3d%%",100*dx/64); - mgametext(MENU_JOYSTICKAXES3-49,48+30*(m-first)-8,tempbuf,MENUHIGHLIGHT((m-first)*2),2+8+16); - Bsprintf(tempbuf,"%3d%%",100*dy/64); - mgametext(MENU_JOYSTICKAXES3-49,48+30*(m-first)-8+15,tempbuf,MENUHIGHLIGHT((m-first)*2+1),2+8+16); - - if (dx != odx) ud.config.JoystickAnalogueDead[m] = 10000l*dx/64l; - if (dy != ody) ud.config.JoystickAnalogueSaturate[m] = 10000l*dy/64l; - if (dx != odx || dy != ody) - setjoydeadzone(m,ud.config.JoystickAnalogueDead[m],ud.config.JoystickAnalogueSaturate[m]); - } - //mgametext(160,158,"Dead = Dead Zone, Sat. = Saturation",0,2+8+16); - if (joynumaxes>4) - { - menutext(32,48+30*(last-first),MENUHIGHLIGHT(2*(last-first)),0,"Next..."); - Bsprintf(tempbuf,"Page %d of %d", 1+(g_currentMenu-MENU_JOYSTICKDEAD), (joynumaxes+3)/4); - mgametext(320-100,158,tempbuf,0,2+8+16); - } - break; - } - - case MENU_SOUND: - case MENU_SOUND_INGAME: - - margin = MENU_MARGIN_REGULAR; - M_DrawTopBar("Sound Setup"); - - if (!(changesmade & 8)) - { - soundrate = ud.config.MixRate; - soundvoices = ud.config.NumVoices; - soundbits = ud.config.NumBits; - } - - { - int32_t io, ii, yy, d=margin+160+40, enabled, j; - const char *opts[] = - { - "Sound", - "Master volume", - "Effects volume", - "Music volume", - "-", - "Playback sampling rate", - "Sample size", - "Number of voices", - "-", - "Restart sound system", - "-", - "Duke talk", - "Dukematch player sounds", - "Ambient sounds", - "Reverse stereo channels", - NULL - }; - - yy = 37; - for (ii=io=0; opts[ii]; ii++) - { - if (opts[ii][0] == '-' && !opts[ii][1]) - { - if (io <= probey) yy += 4; - continue; - } - if (io < probey) yy += 8; - io++; - } - - onbar = (probey >=1 && probey <= 4); - x = probesm(margin,yy+5,0,io); - - if (x == -1) - { - ud.config.MixRate = soundrate; - ud.config.NumVoices = soundvoices; - ud.config.NumBits = soundbits; - - if (g_player[myconnectindex].ps->gm &MODE_GAME && g_currentMenu == MENU_SOUND_INGAME) - { - g_player[myconnectindex].ps->gm &= ~MODE_MENU; - if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - } - - else M_ChangeMenu(MENU_OPTIONS); - probey = 1; - } - - yy = 37; - for (ii=io=0; opts[ii]; ii++) - { - if (opts[ii][0] == '-' && !opts[ii][1]) - { - yy += 4; - continue; - } - enabled = 1; - - switch (io) - { - case 0: - if (ud.config.FXDevice >= 0) - { - i = ud.config.SoundToggle; - modval(0,1,(int32_t *)&ud.config.SoundToggle,1,probey==io); - if (x==io) - ud.config.SoundToggle = 1-ud.config.SoundToggle; - if (i != ud.config.SoundToggle) + case Dummy: + break; + case Link: + if (currentry->disabled) + break; + if (I_AdvanceTrigger()) { - if (ud.config.SoundToggle == 0) - { - FX_StopAllSounds(); - S_ClearSoundLocks(); - } + I_AdvanceTriggerClear(); + + M_MenuEntryLinkActivate(currgroup, currentry); + + if (g_currentMenu != MENU_SKILL) + S_PlaySound(PISTOL_BODYHIT); + + M_ChangeMenu(((MenuLink_t*)currentry->entry)->linkID); } - - } - - if (ud.config.MusicDevice >= 0) + break; + case Option: { - i = ud.config.MusicToggle; - ud.config.MusicToggle = ud.config.SoundToggle; + MenuOption_t *object = (MenuOption_t*)currentry->entry; + int32_t modification = -1; - if (i != ud.config.MusicToggle) + if (currentry->disabled) + break; + + if (I_AdvanceTrigger()) { - if (ud.config.MusicToggle == 0) S_PauseMusic(1); + I_AdvanceTriggerClear(); + + S_PlaySound(PISTOL_BODYHIT); + + if (object->options->features & 2) + { + modification = object->currentOption + 1; + if (modification >= object->options->numOptions) + modification = 0; + } else { - if (ud.recstat != 2 && g_player[myconnectindex].ps->gm&MODE_GAME) - { - if (MapInfo[g_musicIndex].musicfn != NULL) - S_PlayMusic(&MapInfo[g_musicIndex].musicfn[0], g_musicIndex); - } - else S_PlayMusic(&EnvMusicFilename[0][0], MAXVOLUMES*MAXLEVELS); + object->options->currentEntry = object->currentOption; + } + } + else if (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6)) + { + modification = object->currentOption + 1; + if (modification >= object->options->numOptions) + modification = 0; - S_PauseMusic(0); + KB_ClearKeyDown(sc_RightArrow); + KB_ClearKeyDown(sc_kpad_6); + S_PlaySound(PISTOL_BODYHIT); + } + else if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4)) + { + modification = object->currentOption - 1; + if (modification < 0) + modification = object->options->numOptions - 1; + + KB_ClearKeyDown(sc_LeftArrow); + KB_ClearKeyDown(sc_kpad_4); + S_PlaySound(PISTOL_BODYHIT); + } + + if (modification >= 0) + { + int32_t temp = (object->options->optionValues == NULL) ? modification : object->options->optionValues[modification]; + if (!M_MenuEntryOptionModify(currgroup, currentry, temp)) + { + object->currentOption = modification; + if ((int32_t*)object->data != NULL) + *((int32_t*)object->data) = temp; } } } - - mgametextpal(d,yy, ud.config.SoundToggle ? "On" : "Off", MENUHIGHLIGHT(io), 0); - break; - case 1: - { - enabled = (ud.config.SoundToggle && ud.config.FXDevice >= 0); - l = ud.config.MasterVolume; - sliderbar(1, d+8, yy+7, &ud.config.MasterVolume, 15, probey==io, enabled ? MENUHIGHLIGHT(io) : UNSELMENUSHADE, !enabled, 0, 255); - if (l != ud.config.MasterVolume) + break; + case Custom2Col: + if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || + KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || + KB_KeyPressed(sc_Tab) || (MOUSE_GetButtons()&MIDDLE_MOUSE)) { - FX_SetVolume(ud.config.MasterVolume); - S_MusicVolume(MASTER_VOLUME(ud.config.MusicVolume)); + currgroup->currentColumn = !currgroup->currentColumn; + KB_ClearKeyDown(sc_LeftArrow); + KB_ClearKeyDown(sc_RightArrow); + KB_ClearKeyDown(sc_kpad_4); + KB_ClearKeyDown(sc_kpad_6); + KB_ClearKeyDown(sc_Tab); + MOUSE_ClearButton(MIDDLE_MOUSE); + S_PlaySound(KICK_HIT); } - } - break; - case 2: - { - enabled = (ud.config.SoundToggle && ud.config.FXDevice >= 0); - sliderbar(1,d+8,yy+7, &ud.config.FXVolume,15,probey==io,enabled?MENUHIGHLIGHT(io):UNSELMENUSHADE,!enabled,1,255); - } - break; - - case 3: - { - enabled = (ud.config.MusicToggle && ud.config.MusicDevice >= 0); - l = ud.config.MusicVolume; - sliderbar(1,d+8,yy+7, &ud.config.MusicVolume,15,probey==io,enabled?MENUHIGHLIGHT(io):UNSELMENUSHADE,!enabled,0,255); - if (l != ud.config.MusicVolume) - S_MusicVolume(MASTER_VOLUME(ud.config.MusicVolume)); - } - break; - case 4: - { - int32_t rates[] = { 22050, 24000, 32000, 44100, 48000 }; - int32_t j = ARRAY_SIZE(rates); - - for (i = 0; idisabled) break; - modval(0,j-1,(int32_t *)&i,1,enabled && probey==io); - if (x == io) - { - i++; - if (i >= j) - i = 0; - } - if (i == j) - Bsprintf(tempbuf,"Other"); - else - { - Bsprintf(tempbuf,"%d Hz",rates[i]); - if (rates[i] != ud.config.MixRate) + if (I_AdvanceTrigger()) { - ud.config.MixRate = rates[i]; - changesmade |= 8; + I_AdvanceTriggerClear(); + + S_PlaySound(PISTOL_BODYHIT); + + M_MenuCustom2ColScreen(currgroup/*, currentry*/); + + ((MenuCustom2Col_t*)currentry->entry)->screenOpen = 1; } - } - mgametextpal(d,yy,tempbuf, MENUHIGHLIGHT(io), 0); - } - break; - case 5: - i = ud.config.NumBits; - if (x==io) + break; + case RangeInt32: { - if (ud.config.NumBits == 8) - ud.config.NumBits = 16; - else if (ud.config.NumBits == 16) - ud.config.NumBits = 8; - } - modval(8,16,(int32_t *)&ud.config.NumBits,8,probey==io); - if (ud.config.NumBits != i) - changesmade |= 8; - Bsprintf(tempbuf,"%d-bit",ud.config.NumBits); - mgametextpal(d,yy, tempbuf, MENUHIGHLIGHT(io), 0); - break; - case 6: - i = ud.config.NumVoices; - if (x==io) - { - ud.config.NumVoices++; - if (ud.config.NumVoices > 256) - ud.config.NumVoices = 4; - } - modval(4,256,(int32_t *)&ud.config.NumVoices,4,probey==io); - if (ud.config.NumVoices != i) - changesmade |= 8; - Bsprintf(tempbuf,"%d",ud.config.NumVoices); - mgametextpal(d,yy, tempbuf, MENUHIGHLIGHT(io), 0); - break; - case 7: - enabled = (changesmade&8); - if (!enabled) break; - if (x == io) - { - S_SoundShutdown(); - S_MusicShutdown(); + MenuRangeInt32_t *object = (MenuRangeInt32_t*)currentry->entry; + const double interval = (double) (object->max - object->min) / (object->steps - 1); + int32_t step; + int32_t modification = 0; - S_MusicStartup(); - S_SoundStartup(); + if (currentry->disabled) + break; - FX_StopAllSounds(); - S_ClearSoundLocks(); + dtol((double) (*object->variable - object->min) / interval + 0.5, &step); - if (ud.config.MusicToggle == 1) + if (I_SliderLeft()) { - if (ud.recstat != 2 && g_player[myconnectindex].ps->gm&MODE_GAME) - { - if (MapInfo[g_musicIndex].musicfn != NULL) - S_PlayMusic(&MapInfo[g_musicIndex].musicfn[0],g_musicIndex); - } - else S_PlayMusic(&EnvMusicFilename[0][0],MAXVOLUMES*MAXLEVELS); + I_SliderLeftClear(); + + modification = -1; + S_PlaySound(KICK_HIT); } - changesmade &= ~8; + else if (I_SliderRight()) + { + I_SliderRightClear(); + + modification = 1; + S_PlaySound(KICK_HIT); + } + + if (modification != 0) + { + int32_t temp; + + step += modification; + + if (step < 0) + step = 0; + else if (step >= object->steps) + step = object->steps - 1; + + dtol(interval * step + object->min + 0.5, &temp); + + if (!M_MenuEntryRangeInt32Modify(currentry, temp)) + *object->variable = temp; + } + + break; } - break; - case 8: - enabled = (ud.config.SoundToggle && ud.config.FXDevice >= 0); - i = j = (ud.config.VoiceToggle&1); - modval(0,1,(int32_t *)&i,1,enabled && probey==io); - if (x == io || j != i) - ud.config.VoiceToggle ^= 1; - mgametextpal(d,yy, ud.config.VoiceToggle&1? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, enabled?0:1); - break; - case 9: - enabled = (ud.config.SoundToggle && ud.config.FXDevice >= 0); - i = j = (ud.config.VoiceToggle&4); - modval(0,1,(int32_t *)&i,1,enabled && probey==io); - if (x == io || j != i) - ud.config.VoiceToggle ^= 4; - mgametextpal(d,yy, ud.config.VoiceToggle&4? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, enabled?0:1); - break; - case 10: - enabled = (ud.config.SoundToggle && ud.config.FXDevice >= 0); - modval(0,1,(int32_t *)&ud.config.AmbienceToggle,1,enabled && probey==io); - if (enabled && x == io) - ud.config.AmbienceToggle = 1-ud.config.AmbienceToggle; - mgametextpal(d,yy, ud.config.AmbienceToggle? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, enabled?0:1); - break; - case 11: - enabled = (ud.config.SoundToggle && ud.config.FXDevice >= 0); - modval(0,1,(int32_t *)&ud.config.ReverseStereo,1,enabled && probey==io); - if (enabled && x == io) - ud.config.ReverseStereo = 1-ud.config.ReverseStereo; - mgametextpal(d,yy, ud.config.ReverseStereo? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, enabled?0:1); - break; - - default: - break; - } - mgametextpal(margin,yy, opts[ii], enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, enabled?10:1); - io++; - yy += 8; - - } - } - break; - - case MENU_SAVE: - M_ChangeMenu(MENU_SAVE_); - g_screenCapture = 1; - G_DrawRooms(myconnectindex,65536); - g_screenCapture = 0; - break; - - case MENU_SAVETYPING: - case MENU_SAVETYPING2: - case MENU_SAVETYPING3: - case MENU_SAVETYPING4: - case MENU_SAVETYPING5: - case MENU_SAVETYPING6: - case MENU_SAVETYPING7: - case MENU_SAVETYPING8: - case MENU_SAVETYPING9: - case MENU_SAVETYPING10: - case MENU_SAVE_: - case MENU_LOAD: - - margin = MENU_MARGIN_CENTER; - M_DrawBackground(); - - M_DrawTopBar(g_currentMenu == MENU_LOAD ? "Load Game" : "Save Game"); - - if (g_currentMenu >= MENU_SAVETYPING && g_currentMenu <= MENU_SAVETYPING10) - { - static uint32_t xxh = 0; - - if (!xxh) xxh = XXH32((uint8_t *)&ud.savegame[g_currentMenu-MENU_SAVETYPING][0], 19, 0xDEADBEEF); - - Bsprintf(tempbuf,"Players: %-2d ",ud.multimode); - mgametext(160,156,tempbuf,0,2+8+16); - Bsprintf(tempbuf,"Episode: %-2d / Level: %-2d / Skill: %-2d",1+ud.volume_number,1+ud.level_number,ud.player_skill); - mgametext(160,168,tempbuf,0,2+8+16); - if (ud.volume_number == 0 && ud.level_number == 7) - mgametext(160,180,currentboardfilename,0,2+8+16); - - x = Menu_EnterText((320>>1),184,&ud.savegame[g_currentMenu-MENU_SAVETYPING][0],20, 999); - - if (x == -1) - { - xxh = 0; - ReadSaveGameHeaders(); - M_ChangeMenu(MENU_SAVE_); - goto DISPLAYNAMES; - } - - if (x == 1) - { - // dirty hack... char 127 in last position indicates an auto-filled name - if (ud.savegame[g_currentMenu-MENU_SAVETYPING][0] == 0 || (ud.savegame[g_currentMenu-MENU_SAVETYPING][20] == 127 && - xxh == XXH32((uint8_t *)&ud.savegame[g_currentMenu-MENU_SAVETYPING][0], 19, 0xDEADBEEF))) - { - Bstrncpy(&ud.savegame[g_currentMenu-MENU_SAVETYPING][0], MapInfo[ud.volume_number * MAXLEVELS + ud.level_number].name, 19); - ud.savegame[g_currentMenu-MENU_SAVETYPING][20] = 127; - } - - G_SavePlayerMaybeMulti(g_currentMenu-MENU_SAVETYPING); - - g_lastSaveSlot = g_currentMenu-MENU_SAVETYPING; - g_player[myconnectindex].ps->gm = MODE_GAME; - - if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - xxh = 0; - } - - rotatesprite_fs(101<<16,97<<16,65536>>1,512,TILE_SAVESHOT,-32,0,2+4+8+64); - M_DisplaySaveGameList(); - rotatesprite_fs((margin+67+strlen(&ud.savegame[g_currentMenu-MENU_SAVETYPING][0])*4)<<16,(50+12*probey)<<16,32768L-10240,0,SPINNINGNUKEICON+(((totalclock)>>3)%7),0,0,10); - break; - } - - last_load = probey; - - x = M_Probe(margin+68,54,12,10); - - if (g_currentMenu == MENU_LOAD) - { - // load game - if (ud.savegame[probey][0]) - { - Menus_LoadSave_DisplayCommon1(); - - Bsprintf(tempbuf,"Players: %-2d ", savehead.numplayers); - mgametext(160,156,tempbuf,0,2+8+16); - Bsprintf(tempbuf,"Episode: %-2d / Level: %-2d / Skill: %-2d", - 1+savehead.volnum, 1+savehead.levnum, savehead.skill); - mgametext(160,168,tempbuf,0,2+8+16); - if (savehead.volnum == 0 && savehead.levnum == 7) - mgametext(160,180,savehead.boardfn,0,2+8+16); - } - else - { - menutext(69,70,0,0,"Empty"); - } - } - else - { - // save game - if (ud.savegame[probey][0]) - { - Menus_LoadSave_DisplayCommon1(); - } - else menutext(69,70,0,0,"Empty"); - - Bsprintf(tempbuf,"Players: %-2d ",ud.multimode); - mgametext(160,156,tempbuf,0,2+8+16); - Bsprintf(tempbuf,"Episode: %-2d / Level: %-2d / Skill: %-2d",1+ud.volume_number,1+ud.level_number,ud.player_skill); - mgametext(160,168,tempbuf,0,2+8+16); - if (ud.volume_number == 0 && ud.level_number == 7) - mgametext(160,180,currentboardfilename,0,2+8+16); - } - - switch (x) - { - case -1: - if (g_currentMenu == MENU_LOAD) - { - if ((g_player[myconnectindex].ps->gm&MODE_GAME) != MODE_GAME) - { - M_ChangeMenu(MENU_MAIN); - break; - } - else - g_player[myconnectindex].ps->gm &= ~MODE_MENU; - } - else - g_player[myconnectindex].ps->gm = MODE_GAME; - - if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - - break; - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - if (g_currentMenu == MENU_LOAD) - { - if (ud.savegame[x][0] && !g_oldverSavegame[x]) - M_ChangeMenu(MENU_LOADVERIFY+x); - } - else - { - if (ud.savegame[x][0] != 0) - M_ChangeMenu(MENU_SAVEVERIFY+x); - else - { - KB_FlushKeyboardQueue(); - M_ChangeMenu(MENU_SAVETYPING+x); - ud.savegame[x][0] = 0; - inputloc = 0; - } - } - break; - } - -DISPLAYNAMES: - M_DisplaySaveGameList(); - break; - - case MENU_STORY: - case MENU_F1HELP: - if (VOLUMEALL) goto VOLUME_ALL_40x; - case MENU_ORDERING: - case MENU_ORDERING2: - - margin = MENU_MARGIN_CENTER; - - M_LinearPanels(MENU_STORY, MENU_ORDERING2); - - x = M_Probe(0,0,0,1); - - if (x == -1) - { - if (g_player[myconnectindex].ps->gm&MODE_GAME) - M_ChangeMenu(MENU_MAIN_INGAME); - else M_ChangeMenu(MENU_MAIN); - return; - } - - flushperms(); - rotatesprite_fs(0,0,65536L,0,ORDERING+g_currentMenu-MENU_STORY,0,0,10+16+64); - - break; -VOLUME_ALL_40x: - - margin = MENU_MARGIN_CENTER; - - M_LinearPanels(MENU_STORY, MENU_F1HELP); - - x = M_Probe(0,0,0,1); - - if (x == -1) - { - if (g_player[myconnectindex].ps->gm&MODE_GAME) - { - switch (g_currentMenu) - { - case MENU_STORY: - case MENU_F1HELP: - g_player[myconnectindex].ps->gm = MODE_GAME; - if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) + case RangeFloat: { - ready2send = 1; - totalclock = ototalclock; + MenuRangeFloat_t *object = (MenuRangeFloat_t*)currentry->entry; + const float interval = (object->max - object->min) / (object->steps - 1); + int32_t step; + int32_t modification = 0; + + if (currentry->disabled) + break; + + ftol((*object->variable - object->min) / interval + 0.5, &step); + + if (I_SliderLeft()) + { + I_SliderLeftClear(); + + modification = -1; + S_PlaySound(KICK_HIT); + } + else if (I_SliderRight()) + { + I_SliderRightClear(); + + modification = 1; + S_PlaySound(KICK_HIT); + } + + if (modification != 0) + { + float temp; + + step += modification; + + if (step < 0) + step = 0; + else if (step >= object->steps) + step = object->steps - 1; + + temp = interval * step + object->min; + + if (!M_MenuEntryRangeFloatModify(currentry, temp)) + *object->variable = temp; + } + + break; + } + case RangeDouble: + { + MenuRangeDouble_t *object = (MenuRangeDouble_t*)currentry->entry; + const double interval = (object->max - object->min) / (object->steps - 1); + int32_t step; + int32_t modification = 0; + + if (currentry->disabled) + break; + + dtol((*object->variable - object->min) / interval + 0.5, &step); + + if (I_SliderLeft()) + { + I_SliderLeftClear(); + + modification = -1; + S_PlaySound(KICK_HIT); + } + else if (I_SliderRight()) + { + I_SliderRightClear(); + + modification = 1; + S_PlaySound(KICK_HIT); + } + + if (modification != 0) + { + double temp; + + step += modification; + + if (step < 0) + step = 0; + else if (step >= object->steps) + step = object->steps - 1; + + temp = interval * step + object->min; + + if (!M_MenuEntryRangeDoubleModify(currentry/*, temp*/)) + *object->variable = temp; + } + + break; + } + + case String: + { + MenuString_t *object = (MenuString_t*)currentry->entry; + + if (I_AdvanceTrigger()) + { + I_AdvanceTriggerClear(); + + S_PlaySound(PISTOL_BODYHIT); + + Bstrncpy(typebuf, object->variable, TYPEBUFSIZE); + object->editfield = typebuf; + + // this limitation is an arbitrary implementation detail + if (object->maxlength > TYPEBUFSIZE) + object->maxlength = TYPEBUFSIZE; + + M_MenuEntryStringActivate(currgroup/*, currentry*/); + } + + break; + } + } + + if (I_ReturnTrigger() || I_EscapeTrigger()) + { + I_ReturnTriggerClear(); + I_EscapeTriggerClear(); + + S_PlaySound(EXITMENUSOUND); + + M_ChangeMenu(cm->parentID); + } + else if (KB_KeyPressed(sc_Home)) + { + movement = 1; + + KB_ClearKeyDown(sc_Home); + + S_PlaySound(KICK_HIT); + + menu->currentGroup = 0; + menu->grouplist[menu->currentGroup]->currentEntry = 0; + + currgroup = menu->grouplist[menu->currentGroup]; + currentry = currgroup->entrylist[currgroup->currentEntry]; + + M_MenuEntryFocus(currgroup/*, currentry*/); + } + else if (KB_KeyPressed(sc_End)) + { + movement = 1; + + KB_ClearKeyDown(sc_End); + + S_PlaySound(KICK_HIT); + + menu->currentGroup = menu->numGroups-1; + menu->grouplist[menu->currentGroup]->currentEntry = menu->grouplist[menu->currentGroup]->numEntries-1; + + currgroup = menu->grouplist[menu->currentGroup]; + currentry = currgroup->entrylist[currgroup->currentEntry]; + + M_MenuEntryFocus(currgroup/*, currentry*/); + } + else if (KB_KeyPressed(sc_UpArrow) || KB_KeyPressed(sc_kpad_8) || (MOUSE_GetButtons()&WHEELUP_MOUSE) || BUTTON(gamefunc_Move_Forward) || (JOYSTICK_GetHat(0)&HAT_UP)) + { + movement = 1; + + KB_ClearKeyDown(sc_UpArrow); + KB_ClearKeyDown(sc_kpad_8); + MOUSE_ClearButton(WHEELUP_MOUSE); + CONTROL_ClearButton(gamefunc_Move_Forward); + JOYSTICK_ClearHat(0); + + S_PlaySound(KICK_HIT); + + --currgroup->currentEntry; + if (currgroup->currentEntry < 0) + { + currgroup->currentEntry = 0; + --menu->currentGroup; + + if (menu->currentGroup < 0) + menu->currentGroup = menu->numGroups-1; + + currgroup = menu->grouplist[menu->currentGroup]; + currgroup->currentEntry = currgroup->numEntries-1; + } + currentry = currgroup->entrylist[currgroup->currentEntry]; + + M_MenuEntryFocus(currgroup/*, currentry*/); + } + else if (KB_KeyPressed(sc_DownArrow) || KB_KeyPressed(sc_kpad_2) || (MOUSE_GetButtons()&WHEELDOWN_MOUSE) || BUTTON(gamefunc_Move_Backward) || (JOYSTICK_GetHat(0)&HAT_DOWN)) + { + movement = 1; + + KB_ClearKeyDown(sc_DownArrow); + KB_ClearKeyDown(sc_kpad_2); + KB_ClearKeyDown(sc_PgDn); + MOUSE_ClearButton(WHEELDOWN_MOUSE); + CONTROL_ClearButton(gamefunc_Move_Backward); + JOYSTICK_ClearHat(0); + + S_PlaySound(KICK_HIT); + + ++currgroup->currentEntry; + if (currgroup->currentEntry >= currgroup->numEntries) + { + currgroup->currentEntry = currgroup->numEntries-1; + ++menu->currentGroup; + + if (menu->currentGroup >= menu->numGroups) + menu->currentGroup = 0; + + currgroup = menu->grouplist[menu->currentGroup]; + currgroup->currentEntry = 0; + } + currentry = currgroup->entrylist[currgroup->currentEntry]; + + M_MenuEntryFocus(currgroup/*, currentry*/); + } + + if (movement) + { + if (currentry->ybottom - menu->scrollPos > menu->bottomcutoff) + menu->scrollPos = currentry->ybottom - menu->bottomcutoff; + else if (currentry->ytop - menu->scrollPos < menu->ytop) + menu->scrollPos = currentry->ytop - menu->ytop; + } + + if (currentry != NULL && !currentry->disabled) + M_PreMenuInput(currgroup, currentry); + } + else if (state == 1) + { + if (currentry->type == String) + { + MenuString_t *object = (MenuString_t*)currentry->entry; + + int32_t hitstate = I_EnterText(object->editfield, object->maxlength, object->flags); + + if (hitstate == 1) + { + S_PlaySound(PISTOL_BODYHIT); + + M_MenuEntryStringSubmit(/*currgroup, currentry, object->editfield*/); + + Bstrncpy(object->variable, object->editfield, object->maxlength); + + object->editfield = NULL; + } + else if (hitstate == -1) + { + S_PlaySound(EXITMENUSOUND); + + M_MenuEntryStringCancel(/*currgroup, currentry*/); + + object->editfield = NULL; } - break; - default: - M_ChangeMenu(MENU_MAIN_INGAME); - break; } } - else M_ChangeMenu(MENU_MAIN); - return; - } + else if (state == 2) + { + if (currentry->type == Option) + { + MenuOption_t *object = (MenuOption_t*)currentry->entry; + int32_t movement = 0; + + if (I_ReturnTrigger()) + { + I_ReturnTriggerClear(); + + S_PlaySound(EXITMENUSOUND); + + object->options->currentEntry = -1; + } + else if (I_AdvanceTrigger()) + { + int32_t temp = (object->options->optionValues == NULL) ? object->options->currentEntry : object->options->optionValues[object->options->currentEntry]; + + I_AdvanceTriggerClear(); + + S_PlaySound(PISTOL_BODYHIT); + + if (!M_MenuEntryOptionModify(currgroup, currentry, temp)) + { + object->currentOption = object->options->currentEntry; + if ((int32_t*)object->data != NULL) + *((int32_t*)object->data) = temp; + } + + object->options->currentEntry = -1; + } + else if (KB_KeyPressed(sc_Home)) + { + movement = 1; + + KB_ClearKeyDown(sc_Home); + + S_PlaySound(KICK_HIT); + + object->options->currentEntry = 0; + } + else if (KB_KeyPressed(sc_End)) + { + movement = 1; + + KB_ClearKeyDown(sc_End); + + S_PlaySound(KICK_HIT); + + object->options->currentEntry = object->options->numOptions-1; + } + else if (KB_KeyPressed(sc_UpArrow) || KB_KeyPressed(sc_kpad_8) || (MOUSE_GetButtons()&WHEELUP_MOUSE) || BUTTON(gamefunc_Move_Forward) || (JOYSTICK_GetHat(0)&HAT_UP)) + { + movement = 1; + + KB_ClearKeyDown(sc_UpArrow); + KB_ClearKeyDown(sc_kpad_8); + MOUSE_ClearButton(WHEELUP_MOUSE); + CONTROL_ClearButton(gamefunc_Move_Forward); + JOYSTICK_ClearHat(0); + + S_PlaySound(KICK_HIT); + + --object->options->currentEntry; + + if (object->options->currentEntry < 0) + object->options->currentEntry = object->options->numOptions-1; + } + else if (KB_KeyPressed(sc_DownArrow) || KB_KeyPressed(sc_kpad_2) || (MOUSE_GetButtons()&WHEELDOWN_MOUSE) || BUTTON(gamefunc_Move_Backward) || (JOYSTICK_GetHat(0)&HAT_DOWN)) + { + movement = 1; + + KB_ClearKeyDown(sc_DownArrow); + KB_ClearKeyDown(sc_kpad_2); + KB_ClearKeyDown(sc_PgDn); + MOUSE_ClearButton(WHEELDOWN_MOUSE); + CONTROL_ClearButton(gamefunc_Move_Backward); + JOYSTICK_ClearHat(0); + + S_PlaySound(KICK_HIT); + + ++object->options->currentEntry; + + if (object->options->currentEntry >= object->options->numOptions) + object->options->currentEntry = 0; + } + + if (movement) + { + int32_t listytop = object->options->list->pos.y; + // assumes height == font->yline! + int32_t ytop = listytop + object->options->currentEntry * (object->font->yline + object->options->list->entryspacing); + int32_t ybottom = ytop + object->font->yline; + + if (ybottom - object->options->scrollPos > object->options->list->bottomcutoff) + object->options->scrollPos = ybottom - object->options->list->bottomcutoff; + else if (ytop - object->options->scrollPos < listytop) + object->options->scrollPos = ytop - listytop; + } + } + else if (currentry->type == Custom2Col) + { + if (I_EscapeTrigger()) + { + I_EscapeTriggerClear(); + + S_PlaySound(EXITMENUSOUND); + + ((MenuCustom2Col_t*)currentry->entry)->screenOpen = 0; + } + else if (M_PreMenuCustom2ColScreen(currgroup, currentry)) + ((MenuCustom2Col_t*)currentry->entry)->screenOpen = 0; + } + } - flushperms(); - switch (g_currentMenu) - { - case MENU_STORY: - rotatesprite_fs(0,0,65536L,0,TEXTSTORY,0,0,10+16+64); - break; - case MENU_F1HELP: - rotatesprite_fs(0,0,65536L,0,F1HELP,0,0,10+16+64); break; } + } +} - break; +// This function MUST NOT RECURSE. That is why M_RunMenu is separate. +void M_DisplayMenus(void) +{ + Net_GetPackets(); - case MENU_QUIT: - case MENU_QUIT2: - margin = MENU_MARGIN_CENTER; - - mgametext(margin,90,"Are you sure you want to quit?",0,2+8+16); - mgametext(margin,99,"(Y/N)",0,2+8+16); - - x = M_Probe(NUKEICON_CENTER_PROBEX,124,0,1); - - if (ProbeTriggers(AdvanceTrigger) || I_AdvanceTrigger() || KB_KeyPressed(sc_Y)) - { - I_AdvanceTriggerClear(); - ProbeTriggersClear(AdvanceTrigger); - KB_ClearKeyDown(sc_Y); - KB_FlushKeyboardQueue(); - - G_GameQuit(); - } - if (x == -1 || KB_KeyPressed(sc_N)) - { - KB_ClearKeyDown(sc_N); - g_quitDeadline = 0; - if (g_player[myconnectindex].ps->gm &MODE_DEMO && ud.recstat == 2) - g_player[myconnectindex].ps->gm = MODE_DEMO; - else - { - if (g_currentMenu == MENU_QUIT2) - { - M_ChangeMenu(last_menu); - probey = last_menu_pos; - } - else if (!(g_player[myconnectindex].ps->gm &MODE_GAME || ud.recstat == 2)) - M_ChangeMenu(MENU_MAIN); - else g_player[myconnectindex].ps->gm &= ~MODE_MENU; - if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - } - } - - break; - case MENU_QUITTOTITLE: - margin = MENU_MARGIN_CENTER; - mgametext(margin,90,"Quit to Title?",0,2+8+16); - mgametext(margin,99,"(Y/N)",0,2+8+16); - - x = M_Probe(NUKEICON_CENTER_PROBEX,124,0,0); - - if (ProbeTriggers(AdvanceTrigger) || I_AdvanceTrigger() || KB_KeyPressed(sc_Y)) - { - I_AdvanceTriggerClear(); - ProbeTriggersClear(AdvanceTrigger); - KB_ClearKeyDown(sc_Y); - - KB_FlushKeyboardQueue(); - g_player[myconnectindex].ps->gm = MODE_DEMO; - if (ud.recstat == 1) - G_CloseDemoWrite(); - E_MapArt_Clear(); - M_ChangeMenu(MENU_MAIN); - } - - if (x == -1 || KB_KeyPressed(sc_N)) - { - g_player[myconnectindex].ps->gm &= ~MODE_MENU; - if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - } - - break; - - case MENU_NETWAITMASTER: - G_DrawFrags(); - M_DrawTopBar(&g_player[myconnectindex].user_name[0]); - - Bsprintf(tempbuf,"Waiting for master"); - mgametext(160,50,tempbuf,0,2+8+16); - mgametext(160,59,"to select level",0,2+8+16); - - if (I_EscapeTrigger()) - { - I_EscapeTriggerClear(); - S_PlaySound(EXITMENUSOUND); - M_ChangeMenu(MENU_MAIN); - } - break; - - case MENU_PRENETSETUP: - if (menunamecnt == 0) - { - // getfilenames("SUBD"); - fnlist_getnames(&fnlist, ".", "*.MAP", 0, 0); - set_findhighs(); - - if (menunamecnt == 0) - M_ChangeMenu(MENU_NETSETUP); - } - - case MENU_NETWAITVOTES: + if ((g_player[myconnectindex].ps->gm&MODE_MENU) == 0) { - x = M_Probe(NUKEICON_CENTER_PROBEX,124,0,0); - - if (voting != myconnectindex) - { - g_player[myconnectindex].ps->gm &= ~MODE_MENU; - } - else if (x == -1) - { - Net_SendMapVoteCancel(0); - M_ChangeMenu(MENU_MAIN); - } - else - { - mgametext(160,90,"Waiting for votes",0,2); - } - - break; + walock[TILE_LOADSHOT] = 1; + return; } - case MENU_NETSETUP: - margin = (320>>1) - 120; - if ((g_player[myconnectindex].ps->gm&MODE_GAME) != MODE_GAME) - G_DrawFrags(); - M_DrawTopBar(&g_player[myconnectindex].user_name[0]); + if (G_HaveEvent(EVENT_DISPLAYMENU)) + VM_OnEvent(EVENT_DISPLAYMENU, g_player[screenpeek].ps->i, screenpeek, -1, 0); - x = M_Probe(margin,57-8,16,8); + g_player[myconnectindex].ps->gm &= (0xff-MODE_TYPE); + g_player[myconnectindex].ps->fta = 0; - modval(0,g_numGametypes-1,(int32_t *)&ud.m_coop,1,probey==0); - if (!VOLUMEONE) - modval(0,g_numVolumes-1,(int32_t *)&ud.m_volume_number,1,probey==1); + if (((g_player[myconnectindex].ps->gm&MODE_GAME) || ud.recstat==2) && M_BlackTranslucentBackgroundOK(g_currentMenu)) + fade_screen_black(1); - i = ud.m_level_number; + if (M_UpdateScreenOK(g_currentMenu)) + G_UpdateScreenArea(); - modval(0,ud.m_volume_number == 0?6+(boardfilename[0]!=0):MAXLEVELS-1,(int32_t *)&ud.m_level_number,1,probey==2); - - if ((GametypeFlags[ud.m_coop] & GAMETYPE_MARKEROPTION)) - modval(0,1,(int32_t *)&ud.m_marker,1,probey==4); - if ((GametypeFlags[ud.m_coop] & (GAMETYPE_PLAYERSFRIENDLY|GAMETYPE_TDM))) - modval(0,1,(int32_t *)&ud.m_ffire,1,probey==5); - else modval(0,1,(int32_t *)&ud.m_noexits,1,probey==5); - - if (probey == 1) - if (ud.m_volume_number == 0 && ud.m_level_number > 6+(boardfilename[0]!=0)) - ud.m_level_number = 0; - - while (MapInfo[(ud.m_volume_number*MAXLEVELS)+ud.m_level_number].name == NULL) - { - if (ud.m_level_number < i || i == 0) - ud.m_level_number--; - else ud.m_level_number++; - - if (ud.m_level_number > MAXLEVELS-1 || ud.m_level_number < 0) - { - ud.m_level_number = 0; - break; - } - } - - switch (x) - { - case -1: - ud.m_recstat = 0; - if (g_player[myconnectindex].ps->gm&MODE_GAME) M_ChangeMenu(MENU_MAIN_INGAME); - else M_ChangeMenu(MENU_MAIN); - break; - case 0: - ud.m_coop++; - if (ud.m_coop == g_numGametypes) ud.m_coop = 0; - break; - case 1: - if (!VOLUMEONE) - { - ud.m_volume_number++; - if (ud.m_volume_number == g_numVolumes) ud.m_volume_number = 0; - if (ud.m_volume_number == 0 && ud.m_level_number > 6+(boardfilename[0]!=0)) - ud.m_level_number = 0; - if (ud.m_level_number > MAXLEVELS-1) ud.m_level_number = 0; - } - break; - case 2: - ud.m_level_number++; - if (!VOLUMEONE) - { - if (ud.m_volume_number == 0 && ud.m_level_number > 6+(boardfilename[0]!=0)) - ud.m_level_number = 0; - } - else - { - if (ud.m_volume_number == 0 && ud.m_level_number > 5) - ud.m_level_number = 0; - } - if (ud.m_level_number > MAXLEVELS-1) ud.m_level_number = 0; - break; - case 3: - if (ud.m_monsters_off == 1 && ud.m_player_skill > 0) - ud.m_monsters_off = 0; - - if (ud.m_monsters_off == 0) - { - ud.m_player_skill++; - if (ud.m_player_skill > 3) - { - ud.m_player_skill = 0; - ud.m_monsters_off = 1; - } - } - else ud.m_monsters_off = 0; - - break; - - case 4: - if ((GametypeFlags[ud.m_coop] & GAMETYPE_MARKEROPTION)) - ud.m_marker = !ud.m_marker; - break; - - case 5: - if ((GametypeFlags[ud.m_coop] & (GAMETYPE_PLAYERSFRIENDLY|GAMETYPE_TDM))) - ud.m_ffire = !ud.m_ffire; - else ud.m_noexits = !ud.m_noexits; - break; - - case 6: - if (VOLUMEALL) - { - currentlist = 1; - last_menu_pos = probey; - M_ChangeMenu(MENU_USERMAP); - } - break; - case 7: - // master does whatever it wants - if (g_netServer) - { - Net_FillNewGame(&pendingnewgame, 1); - Net_StartNewGame(); - Net_SendNewGame(1, NULL); - break; - } - if (voting == -1) - { - Net_SendMapVoteInitiate(); - M_ChangeMenu(MENU_NETWAITVOTES); - } - break; - } - - margin += 40; - - //if(ud.m_coop==1) mgametext(c+70,57-7-9,"Cooperative Play",0,2+8+16); - //else if(ud.m_coop==2) mgametext(c+70,57-7-9,"DukeMatch (No Spawn)",0,2+8+16); - //else mgametext(c+70,57-7-9,"DukeMatch (Spawn)",0,2+8+16); - mgametext(margin+70,57-7-9,GametypeNames[ud.m_coop],MENUHIGHLIGHT(0),2+8+16); - if (VOLUMEONE) - { - mgametext(margin+70,57+16-7-9,EpisodeNames[ud.m_volume_number],MENUHIGHLIGHT(1),2+8+16); - } - else - { - mgametext(margin+70,57+16-7-9,EpisodeNames[ud.m_volume_number],MENUHIGHLIGHT(1),2+8+16); - } - - mgametext(margin+70,57+16+16-7-9,&MapInfo[MAXLEVELS*ud.m_volume_number+ud.m_level_number].name[0],MENUHIGHLIGHT(2),2+8+16); - - mgametext(margin+70,57+16+16+16-7-9,ud.m_monsters_off == 0 || ud.m_player_skill > 0?SkillNames[ud.m_player_skill]:"None",MENUHIGHLIGHT(3),2+8+16); - - if (GametypeFlags[ud.m_coop] & GAMETYPE_MARKEROPTION) - mgametext(margin+70,57+16+16+16+16-7-9,ud.m_marker?"On":"Off",MENUHIGHLIGHT(4),2+8+16); - - if (GametypeFlags[ud.m_coop] & (GAMETYPE_PLAYERSFRIENDLY|GAMETYPE_TDM)) - mgametext(margin+70,57+16+16+16+16+16-7-9,ud.m_ffire?"On":"Off",MENUHIGHLIGHT(5),2+8+16); - else mgametext(margin+70,57+16+16+16+16+16-7-9,ud.m_noexits?"Off":"On",MENUHIGHLIGHT(5),2+8+16); - - margin -= 44; - - menutext(margin,57-9,MENUHIGHLIGHT(0),0,"Game Type"); - - if (VOLUMEONE) - { - Bsprintf(tempbuf,"Episode %d",ud.m_volume_number+1); - menutext(margin,57+16-9,MENUHIGHLIGHT(1),1,tempbuf); - } - else - { - Bsprintf(tempbuf,"Episode %d",ud.m_volume_number+1); - menutext(margin,57+16-9,MENUHIGHLIGHT(1),0,tempbuf); - } - - Bsprintf(tempbuf,"Level %d",ud.m_level_number+1); - menutext(margin,57+16+16-9,MENUHIGHLIGHT(2),0,tempbuf); - - menutext(margin,57+16+16+16-9,MENUHIGHLIGHT(3),0,"Monsters"); - - if (GametypeFlags[ud.m_coop] & GAMETYPE_MARKEROPTION) - menutext(margin,57+16+16+16+16-9,MENUHIGHLIGHT(4),0,"Markers"); - else - menutext(margin,57+16+16+16+16-9,MENUHIGHLIGHT(4),1,"Markers"); - - if (GametypeFlags[ud.m_coop] & (GAMETYPE_PLAYERSFRIENDLY|GAMETYPE_TDM)) - menutext(margin,57+16+16+16+16+16-9,MENUHIGHLIGHT(5),0,"Fr. Fire"); - else menutext(margin,57+16+16+16+16+16-9,MENUHIGHLIGHT(5),0,"Map Exits"); - - if (VOLUMEALL) - { - menutext(margin,57+16+16+16+16+16+16-9,MENUHIGHLIGHT(6),0,"User Map"); - if (boardfilename[0] != 0) - mgametext(margin+70+44,57+16+16+16+16+16,boardfilename,MENUHIGHLIGHT(6),2+8+16); - } - else - { - menutext(margin,57+16+16+16+16+16+16-9,MENUHIGHLIGHT(6),1,"User Map"); - } - - menutext(margin,57+16+16+16+16+16+16+16-9,MENUHIGHLIGHT(7),voting!=-1,"Start Game"); - - break; + if (!M_IsTextInput(m_currentMenu) && KB_KeyPressed(sc_Q)) + { + g_previousMenu = g_currentMenu; + M_ChangeMenu(MENU_QUIT); } + + + M_RunMenu(m_currentMenu); + M_RunMenuInput(m_currentMenu); + + if (G_HaveEvent(EVENT_DISPLAYMENUREST)) VM_OnEvent(EVENT_DISPLAYMENUREST, g_player[screenpeek].ps->i, screenpeek, -1, 0); - if (I_EscapeTrigger()) - I_EscapeTriggerClear(); - if ((g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) { G_UpdateScreenArea(); diff --git a/polymer/eduke32/source/menus.h b/polymer/eduke32/source/menus.h index 14d8b7aab..8b4437cf7 100644 --- a/polymer/eduke32/source/menus.h +++ b/polymer/eduke32/source/menus.h @@ -23,20 +23,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __menus_h__ #define __menus_h__ -#include "savegame.h" - -#define MENU_MARGIN_REGULAR 40 -#define MENU_MARGIN_CENTER 160 +#include "compat.h" enum MenuIndex_t { + MENU_NULL = INT32_MIN, // sentinel for "do nothing" + MENU_CLOSE = -2, // sentinel for "close the menu"/"no menu" + MENU_PREVIOUS = -1, // sentinel for "go to previous menu" MENU_MAIN = 0, MENU_MAIN_INGAME = 50, MENU_EPISODE = 100, MENU_USERMAP = 101, - MENU_SELECTMAP = 102, MENU_SKILL = 110, - MENU_SETUP = 200, - MENU_GAMESETUP = 201, + MENU_GAMESETUP = 200, MENU_OPTIONS = 202, MENU_VIDEOSETUP = 203, MENU_KEYBOARDSETUP = 204, @@ -44,46 +42,26 @@ enum MenuIndex_t { MENU_JOYSTICKSETUP = 206, MENU_JOYSTICKBTNS = 207, MENU_JOYSTICKAXES = 208, - MENU_JOYSTICKAXES2 = 209, - MENU_KEYBOARDASSIGN = 210, - MENU_MOUSEASSIGN = 211, + MENU_KEYBOARDKEYS = 209, + MENU_MOUSEBTNS = 210, MENU_MOUSEADVANCED = 212, - MENU_JOYSTICKDEAD = 213, - MENU_JOYSTICKDEAD2 = 214, - MENU_JOYSTICKDEAD3 = 215, - MENU_JOYSTICKDEAD4 = 216, - MENU_JOYSTICKAXES3 = 217, - MENU_JOYSTICKAXES4 = 218, - MENU_JOYSTICKAXES5 = 219, - MENU_JOYSTICKAXES6 = 220, - MENU_JOYSTICKAXES7 = 221, - MENU_JOYSTICKAXES8 = 222, + MENU_JOYSTICKAXIS = 213, MENU_RENDERERSETUP = 230, MENU_COLCORR = 231, MENU_COLCORR_INGAME = 232, MENU_LOAD = 300, MENU_SAVE = 350, - MENU_SAVE_ = 351, - MENU_SAVETYPING = 360, - MENU_SAVETYPING2 = 361, - MENU_SAVETYPING3 = 362, - MENU_SAVETYPING4 = 363, - MENU_SAVETYPING5 = 364, - MENU_SAVETYPING6 = 365, - MENU_SAVETYPING7 = 366, - MENU_SAVETYPING8 = 367, - MENU_SAVETYPING9 = 368, - MENU_SAVETYPING10 = 369, MENU_STORY = 400, MENU_F1HELP = 401, MENU_ORDERING = 402, MENU_ORDERING2 = 403, + MENU_ORDERING3 = 404, + MENU_ORDERING4 = 405, MENU_QUIT = 500, MENU_QUITTOTITLE = 501, - MENU_QUIT2 = 502, + MENU_QUIT_INGAME = 502, MENU_NETSETUP = 600, MENU_NETWAITMASTER = 601, - MENU_PRENETSETUP = 602, MENU_NETWAITVOTES = 603, MENU_SOUND = 700, MENU_SOUND_INGAME = 701, @@ -92,58 +70,290 @@ enum MenuIndex_t { MENU_CREDITS3 = 992, MENU_CREDITS4 = 993, MENU_CREDITS5 = 994, - MENU_CREDITS6 = 995, - MENU_CREDITS7 = 996, - MENU_CREDITS8 = 997, - MENU_CREDITS9 = 998, - MENU_CREDITS10 = 999, MENU_LOADVERIFY = 1000, - MENU_LOADVERIFY2 = 1001, - MENU_LOADVERIFY3 = 1002, - MENU_LOADVERIFY4 = 1003, - MENU_LOADVERIFY5 = 1004, - MENU_LOADVERIFY6 = 1005, - MENU_LOADVERIFY7 = 1006, - MENU_LOADVERIFY8 = 1007, - MENU_LOADVERIFY9 = 1008, - MENU_LOADVERIFY10 = 1009, MENU_NEWVERIFY = 1500, MENU_SAVEVERIFY = 2000, - MENU_SAVEVERIFY2 = 2001, - MENU_SAVEVERIFY3 = 2002, - MENU_SAVEVERIFY4 = 2003, - MENU_SAVEVERIFY5 = 2004, - MENU_SAVEVERIFY6 = 2005, - MENU_SAVEVERIFY7 = 2006, - MENU_SAVEVERIFY8 = 2007, - MENU_SAVEVERIFY9 = 2008, - MENU_SAVEVERIFY10 = 2009, MENU_ADULTMODE = 10000, MENU_ADULTPASSWORD = 10001, MENU_RESETPLAYER = 15000, - MENU_RESETPLAYER2 = 15001, MENU_BUYDUKE = 20000, MENU_NETWORK = 20001, MENU_PLAYER = 20002, - MENU_PLAYERNAME = 20003, MENU_MACROS = 20004, - MENU_MACROSTYPING = 20005, MENU_NETHOST = 20010, MENU_NETOPTIONS = 20011, + MENU_NETUSERMAP = 20012, MENU_NETJOIN = 20020, - MENU_NETJOINSERVER = 20021, - MENU_NETJOINPORT = 20022, - }; -extern char inputloc; + + + +typedef int32_t MenuID_t; + + + +// a subset of screentext parameters, restricted because menus require accessibility +typedef struct MenuTextType_t +{ + int32_t tilenum; + int32_t shade_deselected; // selected entries are mandated to glow + int32_t pal, pal_disabled; + int32_t xspace, yline; + int32_t xbetween, ybetween; + int32_t textflags; +} MenuTextType_t; + + + +typedef enum MenuEntryType_t +{ + Dummy, + Link, + Option, + Custom2Col, + RangeInt32, + RangeFloat, + RangeDouble, + String, +} MenuEntryType_t; + + + +typedef struct MenuPos_t +{ + vec2_t pos; + + int32_t groupspacing; + int32_t entryspacing; + int32_t width; // 0: center, >0: width of the label column (left-aligned options), <0: -width of everything (right-aligned) + int32_t bottomcutoff; + + int32_t cursorPosition, cursorScale; +} MenuPos_t; + +typedef struct MenuLink_t +{ + // traits + MenuID_t linkID; +} MenuLink_t; +typedef struct MenuOptionSet_t +{ + uint8_t features; // bit 1 = disable left/right arrows, bit 2 = disable list + + // traits + char **optionNames; + int32_t *optionValues; // If NULL, the identity of currentOption is assumed. + int32_t numOptions; + + // specifically for a pop-up list + MenuPos_t *list; + int32_t currentEntry; + int32_t scrollPos; +} MenuOptionSet_t; +typedef struct MenuOption_t +{ + // appearance + MenuTextType_t *font; + + // traits + MenuOptionSet_t *options; // so that common sets such as Yes/No, On/Off can be reused + + // effect + int32_t *data; + + // state + int32_t currentOption; +} MenuOption_t; +typedef struct MenuCustom2Col_t +{ + // appearance + MenuTextType_t *font; + int32_t columnWidth; + + char **key; + size_t numvalid; + + uint8_t *column[2]; + + // state + int8_t screenOpen; +} MenuCustom2Col_t; +typedef struct MenuRangeInt32_t +{ + // appearance + MenuTextType_t *font; + uint8_t displaytype; // 0 = none, 1 = integer, 2 = percent, 3 = normalized decimal + + // traits + int32_t min; + int32_t max; + int32_t steps; + int32_t onehundredpercent; // 0 implies max + + // effect + int32_t* variable; +} MenuRangeInt32_t; +typedef struct MenuRangeFloat_t +{ + // appearance + MenuTextType_t *font; + uint8_t displaytype; // 0 = none, 1 = decimal, 2 = percent, 3 = normalized decimal + + // traits + float min; + float max; + int32_t steps; + float onehundredpercent; // 0 implies 1.0 + + // effect + float* variable; +} MenuRangeFloat_t; +typedef struct MenuRangeDouble_t +{ + // appearance + MenuTextType_t *font; + uint8_t displaytype; // 0 = none, 1 = decimal, 2 = percent + + // traits + double min; + double max; + int32_t steps; + double onehundredpercent; // 0 implies 1.0 + + // effect + double* variable; +} MenuRangeDouble_t; +typedef struct MenuString_t +{ + // appearance + MenuTextType_t *font; + + // effect + char* variable; + int32_t maxlength; + + int32_t flags; + + // state + char* editfield; +} MenuString_t; + + +typedef struct MenuEntry_t +{ + // appearance + MenuTextType_t *font; + + // traits + const char *name; + + MenuEntryType_t type; + void *entry; + + // state + int32_t disabled; + + int32_t ytop, ybottom; +} MenuEntry_t; + + +typedef struct MenuGroup_t +{ + MenuEntry_t **entrylist; + int32_t numEntries; + + MenuPos_t *position; + + int32_t currentEntry; + int32_t currentColumn; // a little hackish but not too bad +} MenuGroup_t; + + +typedef enum MenuType_t +{ + Menu, + Panel, + Verify, + Message, + Password, + FileSelect, +} MenuType_t; + +typedef struct MenuMenu_t +{ + MenuGroup_t **grouplist; + int32_t numGroups; + + const char *title; + + // state + int32_t currentGroup; + int32_t ytop, bottomcutoff, totalHeight, scrollPos; +} MenuMenu_t; +typedef struct MenuPanel_t +{ + const char *title; + + MenuID_t previousID; + MenuID_t nextID; +} MenuPanel_t; +typedef struct MenuVerify_t +{ + vec2_t cursorpos; + + MenuID_t linkID; +} MenuVerify_t; +typedef struct MenuMessage_t +{ + vec2_t cursorpos; + + MenuID_t linkID; +} MenuMessage_t; +typedef struct MenuPassword_t +{ + // traits + int32_t maxlength; + + // state + char *input; +} MenuPassword_t; +typedef struct MenuFileSelect_t +{ + const char *title; + + // appearance + MenuTextType_t *dirfont; + MenuTextType_t *filefont; + + // traits + const char *pattern; + char *destination; + + // state + fnlist_t fnlist; + CACHE1D_FIND_REC *finddirshigh, *findfileshigh, *dir; + int32_t currentEntry, currentlist; +} MenuFileSelect_t; + +typedef struct Menu_t +{ + MenuID_t menuID; + MenuID_t parentID; + MenuType_t type; + void *object; +} Menu_t; + +extern MenuID_t g_currentMenu; +extern Menu_t *m_currentMenu; + extern int32_t g_lastSaveSlot; extern int32_t g_quitDeadline; -extern int32_t probey; extern int32_t voting; int32_t menutext_(int32_t x,int32_t y,int32_t s,int32_t p,char *t,int32_t bits); void M_ChangeMenu(int32_t cm); -int32_t M_IsTextInput(int32_t cm); +int32_t M_IsTextInput(Menu_t *cm); void G_CheckPlayerColor(int32_t *color,int32_t prev_color); +void M_Init(void); void M_DisplayMenus(void); #endif diff --git a/polymer/eduke32/source/net.c b/polymer/eduke32/source/net.c index f4265d576..eb16cd91b 100644 --- a/polymer/eduke32/source/net.c +++ b/polymer/eduke32/source/net.c @@ -1709,7 +1709,7 @@ void Net_ReceiveClientUpdate(ENetEvent *event) void Net_SendMessage(void) { - int16_t hitstate, i, j, l; + int32_t hitstate, i, j, l; if (g_player[myconnectindex].ps->gm&MODE_SENDTOWHOM) { @@ -1832,11 +1832,31 @@ void Net_SendMessage(void) } else { - if (ud.screen_size > 1) j = 200-45; - else j = 200-8; + hitstate = I_EnterText(typebuf, 120, 0); + + if (ud.screen_size > 1) j = (200-45)<<16; + else j = (200-8)<<16; if (xdim >= 640 && ydim >= 480) j = scale(j,ydim,200); - hitstate = Net_EnterText(320>>1,j,typebuf,120,1); + + i = textsc(5<<16); + + { + const vec2_t dim = G_ScreenTextSize(STARTALPHANUM, i, 0, textsc(65536), 0, typebuf, 8|16|ROTATESPRITE_FULL16, 5<<16, 7<<16, 0, 0, TEXT_LITERALESCAPE, 0, 0, xdim-1, ydim-1); + + l = i + dim.x + scale(textsc((tilesizx[SPINNINGNUKEICON]+2)<<13), ydim, 200); + } + + if (l >= (xdim<<16)) + i -= (l - (xdim<<16)); + + { + const vec2_t dim = G_ScreenText(STARTALPHANUM, i, j, textsc(65536), 0, 0, typebuf, 1, 0, 8|16|ROTATESPRITE_FULL16, 0, 5<<16, 7<<16, 0, 0, TEXT_YCENTER|TEXT_LITERALESCAPE, 0, 0, xdim-1, ydim-1); + + i += dim.x + scale(textsc((tilesizx[SPINNINGNUKEICON]+1)<<12), ydim, 200); + } + + rotatesprite_fs(i, j, textsc(32768), 0, SPINNINGNUKEICON+((totalclock>>3)%7), 4-(sintable[(totalclock<<4)&2047]>>11), 0, 0); if (hitstate == 1) { diff --git a/polymer/eduke32/source/sounds.h b/polymer/eduke32/source/sounds.h index b07c93938..296c369ae 100644 --- a/polymer/eduke32/source/sounds.h +++ b/polymer/eduke32/source/sounds.h @@ -37,7 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define LOUDESTVOLUME 150 #define MUSIC_ID -65536 -#define FX_VOLUME(x) scale(x, 255, ud.config.FXVolume) +#define FX_VOLUME(x) (ud.config.FXVolume > 0 ? scale(x, 255, ud.config.FXVolume) : 0) #define MASTER_VOLUME(x) scale(ud.config.MasterVolume, x, 255) struct audioenumdev