From 702f91b6b55c5b9444fede7afdc3204587503cac Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 2 Dec 2019 21:05:19 +0100 Subject: [PATCH] - disconnected Shadow Warrior's menu so it can be replaced. Unlike the other games this was a lot more invasive --- source/sw/src/common_game.h | 4 - source/sw/src/console.cpp | 1 + source/sw/src/demo.cpp | 4 - source/sw/src/draw.cpp | 11 +- source/sw/src/game.cpp | 390 +----------- source/sw/src/menus.cpp | 1163 +++++++++++++++++------------------ source/sw/src/menus.h | 22 +- source/sw/src/network.cpp | 1 - source/sw/src/network.h | 1 + source/sw/src/panel.cpp | 4 +- source/sw/src/player.cpp | 17 +- source/sw/src/sounds.cpp | 7 +- 12 files changed, 635 insertions(+), 990 deletions(-) diff --git a/source/sw/src/common_game.h b/source/sw/src/common_game.h index c7c0248b0..6b4b207b3 100644 --- a/source/sw/src/common_game.h +++ b/source/sw/src/common_game.h @@ -65,10 +65,6 @@ BEGIN_SW_NS #define SETUPPROGRAMNAME ("Shadow Warrior Setup") #define SETUPPROGRAMVERSION ("1.2") -#define GAMENAME "Shadow Warrior" -#define GAMELAUNCHER ("SW.EXE") -#define GAMETOTYPE ("SW") - #define MENUFOOTER "Esc Exits  Move ΔΩ Selects\0" #define COMMITLAUNCHER ("COMMIT.EXE") diff --git a/source/sw/src/console.cpp b/source/sw/src/console.cpp index e9228f835..313651cea 100644 --- a/source/sw/src/console.cpp +++ b/source/sw/src/console.cpp @@ -66,6 +66,7 @@ BEGIN_SW_NS SWBOOL SpriteInfo = FALSE; extern SWBOOL QuitFlag; +extern SWBOOL MultiPlayQuitFlag; // FUNCTION PROTOTYPES /////////////////////////////////////////////////////////////////////// void CON_ProcessOptions(void); diff --git a/source/sw/src/demo.cpp b/source/sw/src/demo.cpp index cc4e5e02e..648671680 100644 --- a/source/sw/src/demo.cpp +++ b/source/sw/src/demo.cpp @@ -452,8 +452,6 @@ DemoPlayBack(void) domovethings(); - MNU_CheckForMenus(); - // fast forward and slow mo if (DemoEdit) { @@ -621,8 +619,6 @@ ScenePlayBack(void) //movethings(); domovethings(); - - MNU_CheckForMenus(); } // demo is over diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index a67b84492..d43e47155 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -56,6 +56,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "interp.h" #include "sector.h" #include "config.h" +#include "menu/menu.h" BEGIN_SW_NS @@ -1039,7 +1040,7 @@ post_analyzesprites(void) void ResizeView(PLAYERp pp) { - if (MenuInputMode || InputMode || HelpInputMode || ConPanel || ConInputMode || PauseKeySet) + if (M_Active() || PauseKeySet) return; if (dimensionmode == 2 || dimensionmode == 5 || dimensionmode == 6) @@ -1083,7 +1084,6 @@ ResizeView(PLAYERp pp) } // !JIM! 08/06 -extern SWBOOL UsingMenus; #if 0 void @@ -1417,6 +1417,7 @@ void PrintLocationInfo(PLAYERp pp) SWBOOL DebugSecret = FALSE; void SecretInfo(PLAYERp pp) { + if (!hud_stats) return; #define Y_STEP 7 #define AVERAGEFRAMES 16 int x = windowxy1.x+2; @@ -2485,10 +2486,8 @@ drawscreen(PLAYERp pp) DrawCompass(pp); UpdateMiniBar(pp); - if (UsingMenus) - MNU_DrawMenu(); - else - SecretInfo(pp); + if (!M_Active()) + SecretInfo(pp); videoNextPage(); diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 69f0a192c..e29909bb9 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -95,6 +95,7 @@ Things required to make savegames work: #include "printf.h" #include "m_argv.h" #include "debugbreak.h" +#include "menu/menu.h" //#include "crc32.h" @@ -106,6 +107,8 @@ signed char MNU_InputString(char*, short); SWBOOL IsCommand(const char* str); SWBOOL MNU_StartNetGame(void); +extern SWBOOL MultiPlayQuitFlag; + #if DEBUG #define BETA 0 @@ -1819,7 +1822,7 @@ TitleLevel(void) //MNU_CheckForMenusAnyKey(); } - //if (UsingMenus) + //if (M_Active()) // MNU_DrawMenu(); //drawscreen as fast as you can @@ -1941,7 +1944,8 @@ void MenuLevel(void) if (FinishAnim) { inputState.ClearKeyStatus(sc_Escape); - ControlPanelType = ct_ordermenu; + M_StartControlPanel(false); + M_SetMenu(NAME_CreditsMenu); FinishAnim = 0; } } @@ -1960,7 +1964,6 @@ void MenuLevel(void) if (totalclock >= ototalclock + synctics) { ototalclock += synctics; - MNU_CheckForMenusAnyKey(); if (CommEnabled) getpackets(); } @@ -1998,10 +2001,9 @@ void MenuLevel(void) } // force the use of menus at all time - if (!UsingMenus && !ConPanel) + if (!M_Active() && !ConPanel) { inputState.SetKeyStatus(sc_Escape); - MNU_CheckForMenusAnyKey(); } // must lock the clock for drawing so animations will happen @@ -2010,9 +2012,6 @@ void MenuLevel(void) //drawscreen as fast as you can DrawMenuLevelScreen(); - if (UsingMenus) - MNU_DrawMenu(); - videoNextPage(); } @@ -2020,8 +2019,7 @@ void MenuLevel(void) //LoadGameOutsideMoveLoop = FALSE; inputState.ClearKeyStatus(sc_Escape); inputState.ClearKeysDown(); - //ExitMenus(); - UsingMenus = FALSE; + M_ClearMenus(); InMenuLevel = FALSE; videoClearViewableArea(0L); videoNextPage(); @@ -2270,7 +2268,7 @@ void BonusScreen(PLAYERp pp) rotatesprite(0, 0, RS_SCALE, 0, 5120, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1); rotatesprite(158<<16, 86<<16, RS_SCALE, 0, State->Pic, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1); videoNextPage(); - FadeIn(0,0); + //FadeIn(0,0); } BonusDone = FALSE; @@ -2375,7 +2373,7 @@ void BonusScreen(PLAYERp pp) void EndGameSequence(void) { SWBOOL anim_ok = TRUE; - FadeOut(0, 5); + //FadeOut(0, 5); if ((adult_lockout || Global_PLock) && FinishAnim == ANIM_SUMO) anim_ok = FALSE; @@ -2442,7 +2440,7 @@ void StatScreen(PLAYERp mpp) // No stats in bot games //if (BotMode) return; - ResetPalette(mpp); + //ResetPalette(mpp); COVER_SetReverb(0); // Reset reverb StopSound(); @@ -2628,7 +2626,7 @@ void Control() InitGame(); MONO_PRINT("InitGame done"); - MNU_InitMenus(); + //MNU_InitMenus(); InGame = TRUE; GameIntro(); @@ -2744,9 +2742,6 @@ void MoveLoop(void) // demosync_record(); #endif } - - if (!InputMode && !PauseKeySet) - MNU_CheckForMenus(); } @@ -3179,150 +3174,7 @@ void ManualPlayerDelete(PLAYERp cur_pp) } } -#if DEBUG -void SinglePlayInput(PLAYERp pp) -{ - int pnum = myconnectindex; - uint8_t* kp; - if (buttonMap.ButtonDown(gamefunc_See_Co_Op_View) && !UsingMenus && !ConPanel && dimensionmode == 3) - { - short oldscreenpeek = screenpeek; - - buttonMap.ClearButton(gamefunc_See_Co_Op_View); - - screenpeek = connectpoint2[screenpeek]; - - if (screenpeek < 0) - screenpeek = connecthead; - - if (dimensionmode == 2 || dimensionmode == 5 || dimensionmode == 6) - setup2dscreen(); - - if (dimensionmode != 2) - { - PLAYERp tp; - - tp = Player + screenpeek; - PlayerUpdatePanelInfo(tp); - setpalettefade(0,0,0,0); - memcpy(pp->temp_pal, palette_data, sizeof(palette_data)); - DoPlayerDivePalette(tp); - DoPlayerNightVisionPalette(tp); -// printf("SingPlayInput set_pal: tp->PlayerSprite = %d\n",tp->PlayerSprite); - } - } - - -} - -void DebugKeys(PLAYERp pp) -{ - short w, h; - - if (!(inputState.GetKeyStatus(KEYSC_ALT) || inputState.GetKeyStatus(KEYSC_RALT))) - return; - - if (InputMode) - return; - - if (CommEnabled) - return; - - // - // visiblity adjust - // - - if (inputState.GetKeyStatus(KEYSC_L) > 0) - { - if (inputState.GetKeyStatus(KEYSC_LSHIFT) | inputState.GetKeyStatus(KEYSC_RSHIFT)) // SHIFT - { - g_visibility = g_visibility - (g_visibility >> 3); - - if (g_visibility < 128) - g_visibility = 16348; - - //if (g_visibility > 16384) - // g_visibility = 128; - } - else - { - inputState.GetKeyStatus(KEYSC_L) = 0; - - g_visibility = g_visibility - (g_visibility >> 3); - - if (g_visibility > 16384) - g_visibility = 128; - } - } - - // - // parallax changes - // - - if (inputState.GetKeyStatus(KEYSC_X)) - { - if (inputState.GetKeyStatus(KEYSC_LSHIFT)) - { - inputState.GetKeyStatus(KEYSC_LSHIFT) = FALSE; - inputState.GetKeyStatus(KEYSC_X) = 0; - - parallaxyoffs_override += 10; - - if (parallaxyoffs_override > 100) - parallaxyoffs_override = 0; - } - else - { - inputState.GetKeyStatus(KEYSC_X) = 0; - parallaxtype++; - if (parallaxtype > 2) - parallaxtype = 0; - } - } -} - -#endif - -void ConKey(void) -{ -#if DEBUG - // Console Input Panel - if (!ConPanel && dimensionmode == 3) - { - //if (inputState.GetKeyStatus(KEYSC_TILDE) && inputState.GetKeyStatus(KEYSC_LSHIFT)) - if (inputState.GetKeyStatus(KEYSC_TILDE)) - { - inputState.GetKeyStatus(KEYSC_TILDE) = FALSE; - //inputState.GetKeyStatus(KEYSC_LSHIFT) = FALSE; - inputState.keyFlushChars(); - ConPanel = TRUE; - InputMode = TRUE; - ConInputMode = TRUE; - if (!CommEnabled) - GamePaused = TRUE; - memset(MessageInputString, '\0', sizeof(MessageInputString)); - } - } - else if (ConPanel) - { - //if (inputState.GetKeyStatus(KEYSC_TILDE) && inputState.GetKeyStatus(KEYSC_LSHIFT)) - if (inputState.GetKeyStatus(KEYSC_TILDE)) - { - inputState.GetKeyStatus(KEYSC_TILDE) = FALSE; - //inputState.GetKeyStatus(KEYSC_LSHIFT) = FALSE; - inputState.keyFlushChars(); - ConPanel = FALSE; - ConInputMode = FALSE; - InputMode = FALSE; - if (!CommEnabled) - GamePaused = FALSE; - memset(MessageInputString, '\0', sizeof(MessageInputString)); - SetFragBar(Player + myconnectindex); - } - } -#endif -} char WangBangMacro[10][64]; @@ -3398,47 +3250,10 @@ FunctionKeys(PLAYERp pp) return; } - - if (numplayers <= 1) - { - // F2 save menu - if (inputState.GetKeyStatus(KEYSC_F2)) - { - inputState.ClearKeyStatus(KEYSC_F2); - if (!TEST(pp->Flags, PF_DEAD)) - { - inputState.SetKeyStatus(sc_Escape); - ControlPanelType = ct_savemenu; - } - } - - // F3 load menu - if (inputState.GetKeyStatus(KEYSC_F3)) - { - inputState.ClearKeyStatus(KEYSC_F3); - if (!TEST(pp->Flags, PF_DEAD)) - { - inputState.SetKeyStatus(sc_Escape); - ControlPanelType = ct_loadmenu; - } - } - - } - - - // F4 sound menu - if (inputState.GetKeyStatus(KEYSC_F4)) - { - inputState.ClearKeyStatus(KEYSC_F4); - inputState.SetKeyStatus(sc_Escape); - ControlPanelType = ct_soundmenu; - } - - // F7 VIEW control - if (inputState.GetKeyStatus(KEYSC_F7)) + if (buttonMap.ButtonDown(gamefunc_Third_Person_View)) { - inputState.ClearKeyStatus(KEYSC_F7); + buttonMap.ClearButton(gamefunc_Third_Person_View); if (inputState.GetKeyStatus(KEYSC_LSHIFT) || inputState.GetKeyStatus(KEYSC_RSHIFT)) { @@ -3459,33 +3274,6 @@ FunctionKeys(PLAYERp pp) } } - // F8 toggle messages - if (inputState.GetKeyStatus(KEYSC_F8)) - { - inputState.ClearKeyStatus(KEYSC_F8); - - hud_messages = !hud_messages; - - if (hud_messages) - PutStringInfoLine(pp, "Messages ON"); - else - PutStringInfoLine(pp, "Messages OFF"); - } - - // F10 quit menu - if (inputState.GetKeyStatus(KEYSC_F10)) - { - inputState.ClearKeyStatus(KEYSC_F10); - inputState.SetKeyStatus(sc_Escape); - ControlPanelType = ct_quitmenu; - } - - // F11 gamma correction - if (inputState.GetKeyStatus(KEYSC_F11) > 0) - { - inputState.ClearKeyStatus(KEYSC_F11); - // Do this entirely in the video backend. - } } @@ -3494,7 +3282,7 @@ void PauseKey(PLAYERp pp) extern SWBOOL GamePaused,CheatInputMode; extern SWBOOL enabled; - if (inputState.GetKeyStatus(sc_Pause) && !CommEnabled && !InputMode && !UsingMenus && !CheatInputMode && !ConPanel) + if (inputState.GetKeyStatus(sc_Pause) && !CommEnabled && !InputMode && !M_Active() && !CheatInputMode && !ConPanel) { inputState.ClearKeyStatus(sc_Pause); @@ -3566,6 +3354,7 @@ void GetMessageInput(PLAYERp pp) } } } +#if 0 // the message input needs to be moved out of the game code! else if (MessageInputMode && !ConInputMode) { if (gs.BorderNum > BORDER_BAR+1) @@ -3687,141 +3476,7 @@ SEND_MESSAGE: break; } } -} - -void GetConInput(PLAYERp pp) -{ - int pnum = myconnectindex; - short w,h; - static SWBOOL cur_show; - - if (MessageInputMode || HelpInputMode) - return; - - ConKey(); - - // Console input commands - if (ConInputMode && !MessageInputMode) - { - // get input - switch (MNU_InputSmallString(MessageInputString, 250)) - { - case -1: // Cancel Input (pressed ESC) or Err - InputMode = FALSE; - inputState.ClearKeysDown(); - inputState.keyFlushChars(); - memset(MessageInputString, '\0', sizeof(MessageInputString)); - break; - case FALSE: // Input finished (RETURN) - if (MessageInputString[0] == '\0') - { - InputMode = FALSE; - inputState.ClearKeysDown(); - inputState.keyFlushChars(); - buttonMap.ClearButton(gamefunc_Inventory); - memset(MessageInputString, '\0', sizeof(MessageInputString)); - } - else - { - InputMode = FALSE; - inputState.ClearKeysDown(); - inputState.keyFlushChars(); - buttonMap.ClearButton(gamefunc_Inventory); - CON_ConMessage("%s", MessageInputString); - CON_ProcessUserCommand(); // Check to see if it's a cheat or command - - conbot += 6; - conbotgoal = conbot; - //addconquote(MessageInputString); - // Clear it out after every entry - memset(MessageInputString, '\0', sizeof(MessageInputString)); - } - break; - case TRUE: // Got input - break; - } - } -} - - -void GetHelpInput(PLAYERp pp) -{ - extern SWBOOL GamePaused; - - if (inputState.GetKeyStatus(KEYSC_ALT) || inputState.GetKeyStatus(KEYSC_RALT)) - return; - - if (inputState.GetKeyStatus(KEYSC_LSHIFT) || inputState.GetKeyStatus(KEYSC_RSHIFT)) - return; - - if (MessageInputMode || ConInputMode) - return; - - // F1 help menu - if (!HelpInputMode) - { - if (inputState.GetKeyStatus(KEYSC_F1)) - { - inputState.ClearKeyStatus(KEYSC_F11); - HelpPage = 0; - HelpInputMode = TRUE; - PanelUpdateMode = FALSE; - InputMode = TRUE; - if (!CommEnabled) - GamePaused = TRUE; - } - } - else if (HelpInputMode) - { - if (inputState.GetKeyStatus(KEYSC_ESC)) - { - inputState.ClearKeyStatus(sc_Escape); - inputState.ClearKeysDown(); - PanelUpdateMode = TRUE; - HelpInputMode = FALSE; - InputMode = FALSE; - if (!CommEnabled) - GamePaused = FALSE; - SetRedrawScreen(pp); - } - - if (inputState.GetKeyStatus(KEYSC_SPACE) || inputState.GetKeyStatus(KEYSC_ENTER) || inputState.GetKeyStatus(KEYSC_PGDN) || inputState.GetKeyStatus(KEYSC_DOWN) || inputState.GetKeyStatus(KEYSC_RIGHT) || inputState.GetKeyStatus(sc_kpad_3) || inputState.GetKeyStatus(sc_kpad_2) || inputState.GetKeyStatus(sc_kpad_6)) - { - inputState.ClearKeyStatus(KEYSC_SPACE); - inputState.ClearKeyStatus(KEYSC_ENTER); - inputState.ClearKeyStatus(KEYSC_PGDN); - inputState.ClearKeyStatus(KEYSC_DOWN); - inputState.ClearKeyStatus(KEYSC_RIGHT); - inputState.ClearKeyStatus(sc_kpad_3); - inputState.ClearKeyStatus(sc_kpad_2); - inputState.ClearKeyStatus(sc_kpad_6); - - HelpPage++; - if (HelpPage >= (int)SIZ(HelpPagePic)) - // CTW MODIFICATION - // "Oops! I did it again..." - // HelpPage = SIZ(HelpPagePic) - 1; - HelpPage = 0; - // CTW MODIFICATION END - } - - if (inputState.GetKeyStatus(KEYSC_PGUP) || inputState.GetKeyStatus(KEYSC_UP) || inputState.GetKeyStatus(KEYSC_LEFT) || inputState.GetKeyStatus(sc_kpad_9) || inputState.GetKeyStatus(sc_kpad_8) || inputState.GetKeyStatus(sc_kpad_4)) - { - inputState.ClearKeyStatus(KEYSC_PGUP); - inputState.ClearKeyStatus(KEYSC_UP); - inputState.ClearKeyStatus(KEYSC_LEFT); - inputState.ClearKeyStatus(sc_kpad_8); - inputState.ClearKeyStatus(sc_kpad_9); - inputState.ClearKeyStatus(sc_kpad_4); - - HelpPage--; - if (HelpPage < 0) - // CTW MODIFICATION - // "Played with the logic, got lost in the game..." - HelpPage = SIZ(HelpPagePic) - 1; - // CTW MODIFICATION END - } - } +#endif } short MirrorDelay; @@ -3920,11 +3575,9 @@ void getinput(SW_PACKET *loc) if (PauseKeySet) return; - if (!MenuInputMode && !UsingMenus) + if (!M_Active()) { GetMessageInput(pp); - GetConInput(pp); - GetHelpInput(pp); } // MAP KEY @@ -3968,8 +3621,8 @@ void getinput(SW_PACKET *loc) if (ScrollMode2D && pp == Player + myconnectindex && !Prediction) MoveScrollMode2D(Player + myconnectindex); - // !JIM! Added UsingMenus so that you don't move at all while using menus - if (MenuInputMode || UsingMenus || ScrollMode2D || InputMode) + // !JIM! Added M_Active() so that you don't move at all while using menus + if (M_Active() || ScrollMode2D || InputMode) return; SET_LOC_KEY(loc->bits, SK_SPACE_BAR, ((!!inputState.GetKeyStatus(KEYSC_SPACE)) | buttonMap.ButtonDown(gamefunc_Open))); @@ -4097,12 +3750,15 @@ void getinput(SW_PACKET *loc) if (!CommEnabled) { + // What a mess...:? +#if 0 if (MenuButtonAutoAim) { MenuButtonAutoAim = FALSE; if ((!!TEST(pp->Flags, PF_AUTO_AIM)) != !!cl_autoaim) SET_LOC_KEY(loc->bits, SK_AUTO_AIM, TRUE); } +#endif } else if (inputState.GetKeyStatus(sc_Pause)) { diff --git a/source/sw/src/menus.cpp b/source/sw/src/menus.cpp index 78491f935..de61a05ca 100644 --- a/source/sw/src/menus.cpp +++ b/source/sw/src/menus.cpp @@ -54,23 +54,594 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "music.h" #include "text.h" #include "version.h" +#include "network.h" #include "colormap.h" #include "config.h" BEGIN_SW_NS -signed char MNU_InputString(char*, short); //#define PLOCK_VERSION TRUE +extern SWBOOL ExitLevel, NewGame; + short TimeLimitTable[9] = {0,3,5,10,15,20,30,45,60}; +SWBOOL +MNU_StartNetGame(void) +{ + extern SWBOOL ExitLevel, ShortGameMode, DemoInitOnce, FirstTimeIntoGame; + extern short Level, Skill; + // CTW REMOVED + //extern int gTenActivated; + // CTW REMOVED END + int pnum; + + // always assumed that a demo is playing + + ready2send = 0; + // Skill can go negative here + Skill = gs.NetMonsters - 1; + Level = gs.NetLevel + 1; + DemoPlaying = FALSE; + ExitLevel = TRUE; + NewGame = TRUE; + // restart demo for multi-play mode + DemoInitOnce = FALSE; + + // TENSW: return if a joiner + if (/* CTW REMOVED gTenActivated && */ !AutoNet && FirstTimeIntoGame) + return TRUE; + + // need to set gNet vars for self + // everone else gets a packet to set them + gNet.AutoAim = cl_autoaim; + gNet.SpawnMarkers = gs.NetSpawnMarkers; + gNet.HurtTeammate = gs.NetHurtTeammate; + gNet.Nuke = gs.NetNuke; + gNet.KillLimit = gs.NetKillLimit * 10; + gNet.TimeLimit = TimeLimitTable[gs.NetTimeLimit] * 60 * 120; + + if (ShortGameMode) + { + gNet.KillLimit /= 10; + gNet.TimeLimit /= 2; + } + + gNet.TimeLimitClock = gNet.TimeLimit; + gNet.TeamPlay = gs.NetTeamPlay; + gNet.MultiGameType = gs.NetGameType + 1; + + if (gNet.MultiGameType == MULTI_GAME_COMMBAT_NO_RESPAWN) + { + gNet.MultiGameType = MULTI_GAME_COMMBAT; + gNet.NoRespawn = TRUE; + } + else + { + gNet.NoRespawn = FALSE; + } + + if (CommEnabled) + { + PACKET_NEW_GAME p; + + p.PacketType = PACKET_TYPE_NEW_GAME; + p.Level = Level; + p.Skill = Skill; + p.GameType = gs.NetGameType; + p.AutoAim = cl_autoaim; + p.HurtTeammate = gs.NetHurtTeammate; + p.TeamPlay = gs.NetTeamPlay; + p.SpawnMarkers = gs.NetSpawnMarkers; + p.KillLimit = gs.NetKillLimit; + p.TimeLimit = gs.NetTimeLimit; + p.Nuke = gs.NetNuke; + + netbroadcastpacket((uint8_t*)(&p), sizeof(p)); // TENSW + } + + + return TRUE; +} + + +//////////////////////////////////////////////// +// Measure the pixel width of a graphic string +//////////////////////////////////////////////// +static char lg_xlat_num[] = { 0,1,2,3,4,5,6,7,8,9 }; +#define FONT_LARGE_ALPHA 3706 +#define FONT_LARGE_DIGIT 3732 +#define MenuDrawFlags (ROTATE_SPRITE_SCREEN_CLIP) +#define MZ 65536 +#define MENU_SHADE_DEFAULT 0 +#define MENU_SHADE_INACTIVE 20 + +void MNU_MeasureStringLarge(const char *string, short *w, short *h) +{ + short ndx, width, height; + char c; + short pic; + + width = 0; + height = *h; + + for (ndx = 0; (c = string[ndx]) != 0; ndx++) + { + if (isalpha(c)) + { + c = toupper(c); + pic = FONT_LARGE_ALPHA + (c - 'A'); + } + else if (isdigit(c)) + { + pic = FONT_LARGE_DIGIT + lg_xlat_num[(c - '0')]; + } + else if (c == ' ') + { + width += 10; // Special case for space char + continue; + } + else + { + continue; + } + + width += tilesiz[pic].x+1; + if (height < tilesiz[pic].y) + height = tilesiz[pic].y; + } + + *w = width; + *h = height; +} + +//////////////////////////////////////////////// +// Draw a string using a graphic font +//////////////////////////////////////////////// +void MNU_DrawStringLarge(short x, short y, const char *string, int shade) +{ + int ndx, offset; + char c; + short pic; + + offset = x; + + for (ndx = 0; (c = string[ndx]) != 0; ndx++) + { + if (isalpha(c)) + { + c = toupper(c); + pic = FONT_LARGE_ALPHA + (c - 'A'); + } + else if (isdigit(c)) + { + pic = FONT_LARGE_DIGIT + lg_xlat_num[(c - '0')]; + } + else if (c == ' ') + { + offset += 10; + continue; + } + else + { + continue; + } + + rotatesprite(offset << 16, y << 16, MZ, 0, pic, shade, 0, MenuDrawFlags|ROTATE_SPRITE_CORNER, 0, 0, xdim - 1, ydim - 1); + offset += tilesiz[pic].x + 1; + } + +} + + +//////////////////////////////////////////////// +// Measure the pixel width of a graphic string +//////////////////////////////////////////////// +void MNU_MeasureString(const char *string, short *w, short *h) +{ + short ndx, width, height; + char c; + short ac; + + if (string[0] == '^') + { + MNU_MeasureStringLarge(&string[1], w, h); + return; + } + + width = 0; + height = *h; + + for (ndx = 0; (c = string[ndx]) != 0; ndx++) + { + ac = c - '!' + STARTALPHANUM; + if ((ac < STARTALPHANUM || ac > ENDALPHANUM) && c != asc_Space) + break; + + if (c > asc_Space && c < 127) + { + width += tilesiz[ac].x; + if (height < tilesiz[ac].y) + height = tilesiz[ac].y; + } + else if (c == asc_Space) + width += 4; // Special case for space char + } + + *w = width; + *h = height; +} + +//////////////////////////////////////////////// +// Draw a string using a graphic font +// +// MenuTextShade and MenuDrawFlags +//////////////////////////////////////////////// +void MNU_DrawString(short x, short y, const char *string, short shade, short pal) +{ + int ndx, offset; + char c; + short ac; + + if (string[0] == '^') + { + MNU_DrawStringLarge(x,y, &string[1]); + return; + } + + offset = x; + + for (ndx = 0; (c = string[ndx]) != 0; ndx++) + { + ac = c - '!' + STARTALPHANUM; + if ((ac < STARTALPHANUM || ac > ENDALPHANUM) && c != asc_Space) + break; + + if (c > asc_Space && c < 127) + { + rotatesprite(offset<<16,y<<16,MZ,0,ac, shade, pal, MenuDrawFlags, 0, 0, xdim - 1, ydim - 1); + offset += tilesiz[ac].x; + } + else if (c == asc_Space) + offset += 4; // Special case for space char + } + +} + +//////////////////////////////////////////////// +// Measure the pixel width of a small font string +//////////////////////////////////////////////// +void MNU_MeasureSmallString(const char *string, short *w, short *h) +{ + short ndx, width, height; + char c; + short ac; + + width = 0; + height = *h; + + for (ndx = 0; (c = string[ndx]) != 0; ndx++) + { + ac = (c - '!') + 2930; + if ((ac < 2930 || ac > 3023) && c != asc_Space) + break; + + if (c > asc_Space && c < 127) + { + width += tilesiz[ac].x; + if (height < tilesiz[ac].y) + height = tilesiz[ac].y; + } + else if (c == asc_Space) + width += 4; // Special case for space char + } + + *w = width; + *h = height; +} + +//////////////////////////////////////////////// +// Draw a string using a small graphic font +//////////////////////////////////////////////// +void MNU_DrawSmallString(short x, short y, const char *string, short shade, short pal) +{ + int ndx; + char c; + short ac,offset; + + + offset = x; + + for (ndx = 0; (c = string[ndx]) != 0; ndx++) + { + ac = c - '!' + 2930; + if ((ac < 2930 || ac > 3023) && c != asc_Space) + break; + + if (c > asc_Space && c < 127) + { + rotatesprite(offset<<16,y<<16,MZ,0,ac, shade, pal, MenuDrawFlags, 0, 0, xdim - 1, ydim - 1); + + offset += tilesiz[ac].x; + + } + else if (c == asc_Space) + { + offset += 4; // Special case for space char + } + } + +} + + +////////////////////////////////////////////////////////////////////////////// +#define FADE_DAMAGE_FACTOR 3 // 100 health / 32 shade cycles = 3.125 + +// Fades from 100% to 62.5% somewhat quickly, +// then from 62.5% to 37.5% slowly, +// then from 37.5% to 0% quickly. +// This seems to capture the pain caused by enemy shots, plus the extreme +// fade caused by being blinded or intense pain. +// Perhaps the next step would be to apply a gentle smoothing to the +// intersections of these lines. +static int faderamp[32] = +{ + // y=64-4x + 252,240,224,208,192,176, + + // y=44.8-(16/20)x + 160,156,152,152,148, + 144,140,136,136,132, + 128,124,120,120,116, + 112,108,104,104,100, + + // y=128-4x + 96,80,64,48,32,16 +}; + + +typedef struct RGB_color_typ +{ + unsigned char red; + unsigned char green; + unsigned char blue; +} RGB_color, * RGB_color_ptr; + +unsigned char ppalette[MAX_SW_PLAYERS_REG][768]; +unsigned char palette_data[256][3]; // Global palette array + +////////////////////////////////////////// +// Set the amount of redness for damage +// the player just took +////////////////////////////////////////// +void SetFadeAmt(PLAYERp pp, short damage, unsigned char startcolor) +{ + int palreg, usereg = 0, tmpreg1 = 0, tmpreg2 = 0; + short fadedamage = 0; + RGB_color color; + + //CON_ConMessage("SetAmt: fadeamt = %d, startcolor = %d, pp = %d",pp->FadeAmt,startcolor,pp->StartColor); + + if (abs(pp->FadeAmt) > 0 && startcolor == pp->StartColor) + return; + + // Don't ever over ride flash bomb + if (pp->StartColor == 1 && abs(pp->FadeAmt) > 0) + return; + + // Reset the palette + if (pp == Player + screenpeek) + { + videoFadePalette(0, 0, 0, 0); + if (pp->FadeAmt <= 0) + GetPaletteFromVESA(&ppalette[screenpeek][0]); + } + + if (damage < -150 && damage > -1000) fadedamage = 150; + else if (damage < -1000) // Underwater + fadedamage = abs(damage + 1000); + else + fadedamage = abs(damage); + + if (damage >= -5 && damage < 0) + fadedamage += 10; + + // Don't let red to TOO red + if (startcolor == COLOR_PAIN && fadedamage > 100) fadedamage = 100; + + pp->FadeAmt = fadedamage / FADE_DAMAGE_FACTOR; + + if (pp->FadeAmt <= 0) + { + pp->FadeAmt = 0; + return; + } + + // It's a health item, just do a preset flash amount + if (damage > 0) + pp->FadeAmt = 3; + + pp->StartColor = startcolor; + + pp->FadeTics = 0; + + // Set player's palette to current game palette + GetPaletteFromVESA(pp->temp_pal); + + color.red = palette_data[pp->StartColor][0]; + color.green = palette_data[pp->StartColor][1]; + color.blue = palette_data[pp->StartColor][2]; + + for (palreg = 0; palreg < 768; palreg++) + { + tmpreg1 = (int)(pp->temp_pal[palreg]) + ((2 * pp->FadeAmt) + 4); + tmpreg2 = (int)(pp->temp_pal[palreg]) - ((2 * pp->FadeAmt) + 4); + if (tmpreg1 > 255) + tmpreg1 = 255; + if (tmpreg2 < 0) + tmpreg2 = 0; + + if (usereg == 0) + { + if (pp->temp_pal[palreg] < color.red) + { + if ((pp->temp_pal[palreg] = tmpreg1) > color.red) + pp->temp_pal[palreg] = color.red; + } + else if (pp->temp_pal[palreg] > color.red) + if ((pp->temp_pal[palreg] = tmpreg2) < color.red) + pp->temp_pal[palreg] = color.red; + } + else if (usereg == 1) + { + if (pp->temp_pal[palreg] < color.green) + { + if ((pp->temp_pal[palreg] = tmpreg1) > color.green) + pp->temp_pal[palreg] = color.green; + } + else if (pp->temp_pal[palreg] > color.green) + if ((pp->temp_pal[palreg] = tmpreg2) < color.green) + pp->temp_pal[palreg] = color.green; + } + else if (usereg == 2) + { + if (pp->temp_pal[palreg] < color.blue) + { + if ((pp->temp_pal[palreg] = tmpreg1) > color.blue) + pp->temp_pal[palreg] = color.blue; + } + else if (pp->temp_pal[palreg] > color.blue) + if ((pp->temp_pal[palreg] = tmpreg2) < color.blue) + pp->temp_pal[palreg] = color.blue; + } + + if (++usereg > 2) + usereg = 0; + } + + // Do initial palette set + if (pp == Player + screenpeek) + { + if (videoGetRenderMode() < REND_POLYMOST) set_pal(pp->temp_pal); + else videoFadePalette(color.red, color.green, color.blue, faderamp[min(31, max(0, 32 - abs(pp->FadeAmt)))]); + if (damage < -1000) + pp->FadeAmt = 1000; // Don't call DoPaletteFlash for underwater stuff + } +} + +////////////////////////////////////////// +// Do the screen reddness based on damage +////////////////////////////////////////// +#define MAXFADETICS 5 +void DoPaletteFlash(PLAYERp pp) +{ + int i, palreg, tmpreg1 = 0, tmpreg2 = 0; + unsigned char* pal_ptr = &ppalette[screenpeek][0]; + + + if (pp->FadeAmt <= 1) + { + pp->FadeAmt = 0; + pp->StartColor = 0; + if (pp == Player + screenpeek) + { + videoFadePalette(0, 0, 0, 0); + memcpy(pp->temp_pal, palette_data, sizeof(palette_data)); + DoPlayerDivePalette(pp); // Check Dive again + DoPlayerNightVisionPalette(pp); // Check Night Vision again + } + + return; + } + + + pp->FadeTics += synctics; // Add this frame's tic amount to + // counter + + if (pp->FadeTics >= MAXFADETICS) + { + while (pp->FadeTics >= MAXFADETICS) + { + pp->FadeTics -= MAXFADETICS; + + pp->FadeAmt--; // Decrement FadeAmt till it gets to + // 0 again. + } + } + else + return; // Return if they were not > + // MAXFADETICS + + if (pp->FadeAmt > 32) + return; + + if (pp->FadeAmt <= 1) + { + pp->FadeAmt = 0; + pp->StartColor = 0; + if (pp == Player + screenpeek) + { + videoFadePalette(0, 0, 0, 0); + memcpy(pp->temp_pal, palette_data, sizeof(palette_data)); + DoPlayerDivePalette(pp); // Check Dive again + DoPlayerNightVisionPalette(pp); // Check Night Vision again + } + return; + } + else + { + //CON_Message("gamavalues = %d, %d, %d",pp->temp_pal[pp->StartColor],pp->temp_pal[pp->StartColor+1],pp->temp_pal[pp->StartColor+2]); + for (palreg = 0; palreg < 768; palreg++) + { + tmpreg1 = (int)(pp->temp_pal[palreg]) + 2; + tmpreg2 = (int)(pp->temp_pal[palreg]) - 2; + if (tmpreg1 > 255) + tmpreg1 = 255; + if (tmpreg2 < 0) + tmpreg2 = 0; + + if (pp->temp_pal[palreg] < pal_ptr[palreg]) + { + if ((pp->temp_pal[palreg] = tmpreg1) > pal_ptr[palreg]) + pp->temp_pal[palreg] = pal_ptr[palreg]; + } + else if (pp->temp_pal[palreg] > pal_ptr[palreg]) + if ((pp->temp_pal[palreg] = tmpreg2) < pal_ptr[palreg]) + pp->temp_pal[palreg] = pal_ptr[palreg]; + + } + + // Only hard set the palette if this is currently the player's view + if (pp == Player + screenpeek) + { + if (videoGetRenderMode() < REND_POLYMOST) set_pal(pp->temp_pal); + else + { + videoFadePalette( + palette_data[pp->StartColor][0], + palette_data[pp->StartColor][1], + palette_data[pp->StartColor][2], + faderamp[min(31, max(0, 32 - abs(pp->FadeAmt)))] + ); + } + } + + } + +} + + + +# if 0 + +signed char MNU_InputString(char*, short); + SWBOOL SavePrompt = FALSE; extern SWBOOL InMenuLevel, LoadGameOutsideMoveLoop, LoadGameFromDemo; extern uint8_t RedBookSong[40]; -extern SWBOOL ExitLevel, NewGame; extern short Level, Skill; extern SWBOOL MusicInitialized, FxInitialized; SWBOOL MNU_CheckUserMap(MenuItem *item); @@ -1581,87 +2152,6 @@ void ResetMenuInput(void) InputMode = FALSE; } -SWBOOL -MNU_StartNetGame(void) -{ - extern SWBOOL ExitLevel, ShortGameMode, DemoInitOnce, FirstTimeIntoGame; - extern short Level, Skill; - // CTW REMOVED - //extern int gTenActivated; - // CTW REMOVED END - int pnum; - - // always assumed that a demo is playing - - ready2send = 0; - // Skill can go negative here - Skill = gs.NetMonsters-1; - Level = gs.NetLevel + 1; - if (!AutoNet) - ExitMenus(); - DemoPlaying = FALSE; - ExitLevel = TRUE; - NewGame = TRUE; - // restart demo for multi-play mode - DemoInitOnce = FALSE; - ResetMenuInput(); - - // TENSW: return if a joiner - if (/* CTW REMOVED gTenActivated && */ !AutoNet && FirstTimeIntoGame) - return TRUE; - - // need to set gNet vars for self - // everone else gets a packet to set them - gNet.AutoAim = cl_autoaim; - gNet.SpawnMarkers = gs.NetSpawnMarkers; - gNet.HurtTeammate = gs.NetHurtTeammate; - gNet.Nuke = gs.NetNuke; - gNet.KillLimit = gs.NetKillLimit*10; - gNet.TimeLimit = TimeLimitTable[gs.NetTimeLimit]*60*120; - - if (ShortGameMode) - { - gNet.KillLimit /= 10; - gNet.TimeLimit /= 2; - } - - gNet.TimeLimitClock = gNet.TimeLimit; - gNet.TeamPlay = gs.NetTeamPlay; - gNet.MultiGameType = gs.NetGameType+1; - - if (gNet.MultiGameType == MULTI_GAME_COMMBAT_NO_RESPAWN) - { - gNet.MultiGameType = MULTI_GAME_COMMBAT; - gNet.NoRespawn = TRUE; - } - else - { - gNet.NoRespawn = FALSE; - } - - if (CommEnabled) - { - PACKET_NEW_GAME p; - - p.PacketType = PACKET_TYPE_NEW_GAME; - p.Level = Level; - p.Skill = Skill; - p.GameType = gs.NetGameType; - p.AutoAim = cl_autoaim; - p.HurtTeammate = gs.NetHurtTeammate; - p.TeamPlay = gs.NetTeamPlay; - p.SpawnMarkers = gs.NetSpawnMarkers; - p.KillLimit = gs.NetKillLimit; - p.TimeLimit = gs.NetTimeLimit; - p.Nuke = gs.NetNuke; - - netbroadcastpacket((uint8_t*)(&p), sizeof(p)); // TENSW - } - - - return TRUE; -} - SWBOOL MNU_EpisodeCustom(void) @@ -1821,258 +2311,6 @@ MNU_InitMenus(void) main_i[4].hotkey = (SW_SHAREWARE) ? KEYSC_H : KEYSC_C; } -//////////////////////////////////////////////// -// Measure the pixel width of a graphic string -//////////////////////////////////////////////// -static char lg_xlat_num[] = {0,1,2,3,4,5,6,7,8,9}; -#define FONT_LARGE_ALPHA 3706 -#define FONT_LARGE_DIGIT 3732 - -void MNU_MeasureStringLarge(const char *string, short *w, short *h) -{ - short ndx, width, height; - char c; - short pic; - - width = 0; - height = *h; - - for (ndx = 0; (c = string[ndx]) != 0; ndx++) - { - if (isalpha(c)) - { - c = toupper(c); - pic = FONT_LARGE_ALPHA + (c - 'A'); - } - else if (isdigit(c)) - { - pic = FONT_LARGE_DIGIT + lg_xlat_num[(c - '0')]; - } - else if (c == ' ') - { - width += 10; // Special case for space char - continue; - } - else - { - continue; - } - - width += tilesiz[pic].x+1; - if (height < tilesiz[pic].y) - height = tilesiz[pic].y; - } - - *w = width; - *h = height; -} - -//////////////////////////////////////////////// -// Draw a string using a graphic font -//////////////////////////////////////////////// -void MNU_DrawStringLarge(short x, short y, const char *string) -{ - int ndx, offset; - char c; - short pic; - - offset = x; - - for (ndx = 0; (c = string[ndx]) != 0; ndx++) - { - if (isalpha(c)) - { - c = toupper(c); - pic = FONT_LARGE_ALPHA + (c - 'A'); - } - else if (isdigit(c)) - { - pic = FONT_LARGE_DIGIT + lg_xlat_num[(c - '0')]; - } - else if (c == ' ') - { - offset += 10; - continue; - } - else - { - continue; - } - - rotatesprite(offset << 16, y << 16, MZ, 0, pic, MenuTextShade, 0, MenuDrawFlags|ROTATE_SPRITE_CORNER, 0, 0, xdim - 1, ydim - 1); - offset += tilesiz[pic].x + 1; - } - -} - - -//////////////////////////////////////////////// -// Measure the pixel width of a graphic string -//////////////////////////////////////////////// -void MNU_MeasureString(const char *string, short *w, short *h) -{ - short ndx, width, height; - char c; - short ac; - - if (string[0] == '^') - { - MNU_MeasureStringLarge(&string[1], w, h); - return; - } - - width = 0; - height = *h; - - for (ndx = 0; (c = string[ndx]) != 0; ndx++) - { - ac = c - '!' + STARTALPHANUM; - if ((ac < STARTALPHANUM || ac > ENDALPHANUM) && c != asc_Space) - break; - - if (c > asc_Space && c < 127) - { - width += tilesiz[ac].x; - if (height < tilesiz[ac].y) - height = tilesiz[ac].y; - } - else if (c == asc_Space) - width += 4; // Special case for space char - } - - *w = width; - *h = height; -} - -//////////////////////////////////////////////// -// Draw a string using a graphic font -// -// MenuTextShade and MenuDrawFlags -//////////////////////////////////////////////// -void MNU_DrawString(short x, short y, const char *string, short shade, short pal) -{ - int ndx, offset; - char c; - short ac; - - if (string[0] == '^') - { - MNU_DrawStringLarge(x,y, &string[1]); - return; - } - - offset = x; - - for (ndx = 0; (c = string[ndx]) != 0; ndx++) - { - ac = c - '!' + STARTALPHANUM; - if ((ac < STARTALPHANUM || ac > ENDALPHANUM) && c != asc_Space) - break; - - if (c > asc_Space && c < 127) - { - rotatesprite(offset<<16,y<<16,MZ,0,ac, shade, pal, MenuDrawFlags, 0, 0, xdim - 1, ydim - 1); - offset += tilesiz[ac].x; - } - else if (c == asc_Space) - offset += 4; // Special case for space char - } - -} -/* Original code -void -MNU_DrawString(short x, short y, char *string) -{ - int ndx, offset; - char c; - - if (string[0] == '^') - { - MNU_DrawStringLarge(x,y, &string[1]); - return; - } - - offset = x; - - for (ndx = 0; (c = string[ndx]) != 0; ndx++) - { - if (c > asc_Space && c < 127) - { - rotatesprite(offset << 16, y << 16, MZ, 0, xlatfont[c], MenuTextShade, 0, MenuDrawFlags, 0, 0, xdim - 1, ydim - 1); - offset += tilesiz[xlatfont[c]].x; - } else - if (c == asc_Space) - offset += 4; // Special case for space char - } - -} -*/ - -//////////////////////////////////////////////// -// Measure the pixel width of a small font string -//////////////////////////////////////////////// -void MNU_MeasureSmallString(const char *string, short *w, short *h) -{ - short ndx, width, height; - char c; - short ac; - - width = 0; - height = *h; - - for (ndx = 0; (c = string[ndx]) != 0; ndx++) - { - ac = (c - '!') + 2930; - if ((ac < 2930 || ac > 3023) && c != asc_Space) - break; - - if (c > asc_Space && c < 127) - { - width += tilesiz[ac].x; - if (height < tilesiz[ac].y) - height = tilesiz[ac].y; - } - else if (c == asc_Space) - width += 4; // Special case for space char - } - - *w = width; - *h = height; -} - -//////////////////////////////////////////////// -// Draw a string using a small graphic font -//////////////////////////////////////////////// -void MNU_DrawSmallString(short x, short y, const char *string, short shade, short pal) -{ - int ndx; - char c; - short ac,offset; - - - offset = x; - - for (ndx = 0; (c = string[ndx]) != 0; ndx++) - { - ac = c - '!' + 2930; - if ((ac < 2930 || ac > 3023) && c != asc_Space) - break; - - if (c > asc_Space && c < 127) - { - rotatesprite(offset<<16,y<<16,MZ,0,ac, shade, pal, MenuDrawFlags, 0, 0, xdim - 1, ydim - 1); - - offset += tilesiz[ac].x; - - } - else if (c == asc_Space) - { - offset += 4; // Special case for space char - } - } - -} - //////////////////////////////////////////////// // Get an input string from user using small font //////////////////////////////////////////////// @@ -4084,19 +4322,12 @@ static int MNU_ControlAxisNum(int offset) // Miscellaneous Routines /////////////////////////////////////////////////////////////////////////////////////////////////// -typedef struct RGB_color_typ -{ - unsigned char red; - unsigned char green; - unsigned char blue; -} RGB_color, *RGB_color_ptr; #define PALETTE_MASK 0x3c6 #define PALETTE_READ 0x3c7 #define PALETTE_WRITE 0x3c8 #define PALETTE_DATA 0x3c9 -unsigned char palette_data[256][3]; // Global palette array // V E R T I C A L R E T R A C E V A R I A B L E S ////////////////////////////////////////// @@ -4292,253 +4523,6 @@ void FadeOut(unsigned char targetcolor, unsigned int clicks) } } -////////////////////////////////////////////////////////////////////////////// -#define FADE_DAMAGE_FACTOR 3 // 100 health / 32 shade cycles = 3.125 - -// Fades from 100% to 62.5% somewhat quickly, -// then from 62.5% to 37.5% slowly, -// then from 37.5% to 0% quickly. -// This seems to capture the pain caused by enemy shots, plus the extreme -// fade caused by being blinded or intense pain. -// Perhaps the next step would be to apply a gentle smoothing to the -// intersections of these lines. -static int faderamp[32] = -{ - // y=64-4x - 252,240,224,208,192,176, - - // y=44.8-(16/20)x - 160,156,152,152,148, - 144,140,136,136,132, - 128,124,120,120,116, - 112,108,104,104,100, - - // y=128-4x - 96,80,64,48,32,16 -}; - -unsigned char ppalette[MAX_SW_PLAYERS_REG][768]; - -////////////////////////////////////////// -// Set the amount of redness for damage -// the player just took -////////////////////////////////////////// -void SetFadeAmt(PLAYERp pp, short damage, unsigned char startcolor) -{ - int palreg, usereg = 0, tmpreg1 = 0, tmpreg2 = 0; - short fadedamage=0; - RGB_color color; - - //CON_ConMessage("SetAmt: fadeamt = %d, startcolor = %d, pp = %d",pp->FadeAmt,startcolor,pp->StartColor); - - if (abs(pp->FadeAmt) > 0 && startcolor == pp->StartColor) - return; - - // Don't ever over ride flash bomb - if (pp->StartColor == 1 && abs(pp->FadeAmt) > 0) - return; - - // Reset the palette - if (pp == Player + screenpeek) - { - videoFadePalette(0,0,0,0); - if (pp->FadeAmt <= 0) - GetPaletteFromVESA(&ppalette[screenpeek][0]); - } - - if (damage < -150 && damage > -1000) fadedamage = 150; - else if (damage < -1000) // Underwater - fadedamage = abs(damage+1000); - else - fadedamage = abs(damage); - - if (damage >= -5 && damage < 0) - fadedamage += 10; - - // Don't let red to TOO red - if (startcolor == COLOR_PAIN && fadedamage > 100) fadedamage = 100; - - pp->FadeAmt = fadedamage / FADE_DAMAGE_FACTOR; - - if (pp->FadeAmt <= 0) - { - pp->FadeAmt = 0; - return; - } - - // It's a health item, just do a preset flash amount - if (damage > 0) - pp->FadeAmt = 3; - - pp->StartColor = startcolor; - - pp->FadeTics = 0; - - // Set player's palette to current game palette - GetPaletteFromVESA(pp->temp_pal); - - color.red = palette_data[pp->StartColor][0]; - color.green = palette_data[pp->StartColor][1]; - color.blue = palette_data[pp->StartColor][2]; - - for (palreg = 0; palreg < 768; palreg++) - { - tmpreg1 = (int)(pp->temp_pal[palreg]) + ((2 * pp->FadeAmt) + 4); - tmpreg2 = (int)(pp->temp_pal[palreg]) - ((2 * pp->FadeAmt) + 4); - if (tmpreg1 > 255) - tmpreg1 = 255; - if (tmpreg2 < 0) - tmpreg2 = 0; - - if (usereg == 0) - { - if (pp->temp_pal[palreg] < color.red) - { - if ((pp->temp_pal[palreg] = tmpreg1) > color.red) - pp->temp_pal[palreg] = color.red; - } - else if (pp->temp_pal[palreg] > color.red) - if ((pp->temp_pal[palreg] = tmpreg2) < color.red) - pp->temp_pal[palreg] = color.red; - } - else if (usereg == 1) - { - if (pp->temp_pal[palreg] < color.green) - { - if ((pp->temp_pal[palreg] = tmpreg1) > color.green) - pp->temp_pal[palreg] = color.green; - } - else if (pp->temp_pal[palreg] > color.green) - if ((pp->temp_pal[palreg] = tmpreg2) < color.green) - pp->temp_pal[palreg] = color.green; - } - else if (usereg == 2) - { - if (pp->temp_pal[palreg] < color.blue) - { - if ((pp->temp_pal[palreg] = tmpreg1) > color.blue) - pp->temp_pal[palreg] = color.blue; - } - else if (pp->temp_pal[palreg] > color.blue) - if ((pp->temp_pal[palreg] = tmpreg2) < color.blue) - pp->temp_pal[palreg] = color.blue; - } - - if (++usereg > 2) - usereg = 0; - } - - // Do initial palette set - if (pp == Player + screenpeek) - { - if (videoGetRenderMode() < REND_POLYMOST) set_pal(pp->temp_pal); - else videoFadePalette(color.red, color.green, color.blue, faderamp[min(31,max(0,32-abs(pp->FadeAmt)))]); - if (damage < -1000) - pp->FadeAmt = 1000; // Don't call DoPaletteFlash for underwater stuff - } -} - -////////////////////////////////////////// -// Do the screen reddness based on damage -////////////////////////////////////////// -#define MAXFADETICS 5 -void DoPaletteFlash(PLAYERp pp) -{ - int i, palreg, tmpreg1 = 0, tmpreg2 = 0; - unsigned char *pal_ptr = &ppalette[screenpeek][0]; - - - if (pp->FadeAmt <= 1) - { - pp->FadeAmt = 0; - pp->StartColor = 0; - if (pp == Player + screenpeek) - { - videoFadePalette(0,0,0,0); - memcpy(pp->temp_pal, palette_data, sizeof(palette_data)); - DoPlayerDivePalette(pp); // Check Dive again - DoPlayerNightVisionPalette(pp); // Check Night Vision again - } - - return; - } - - - pp->FadeTics += synctics; // Add this frame's tic amount to - // counter - - if (pp->FadeTics >= MAXFADETICS) - { - while (pp->FadeTics >= MAXFADETICS) - { - pp->FadeTics -= MAXFADETICS; - - pp->FadeAmt--; // Decrement FadeAmt till it gets to - // 0 again. - } - } - else - return; // Return if they were not > - // MAXFADETICS - - if (pp->FadeAmt > 32) - return; - - if (pp->FadeAmt <= 1) - { - pp->FadeAmt = 0; - pp->StartColor = 0; - if (pp == Player + screenpeek) - { - videoFadePalette(0,0,0,0); - memcpy(pp->temp_pal, palette_data, sizeof(palette_data)); - DoPlayerDivePalette(pp); // Check Dive again - DoPlayerNightVisionPalette(pp); // Check Night Vision again - } - return; - } - else - { - //CON_Message("gamavalues = %d, %d, %d",pp->temp_pal[pp->StartColor],pp->temp_pal[pp->StartColor+1],pp->temp_pal[pp->StartColor+2]); - for (palreg = 0; palreg < 768; palreg++) - { - tmpreg1 = (int)(pp->temp_pal[palreg]) + 2; - tmpreg2 = (int)(pp->temp_pal[palreg]) - 2; - if (tmpreg1 > 255) - tmpreg1 = 255; - if (tmpreg2 < 0) - tmpreg2 = 0; - - if (pp->temp_pal[palreg] < pal_ptr[palreg]) - { - if ((pp->temp_pal[palreg] = tmpreg1) > pal_ptr[palreg]) - pp->temp_pal[palreg] = pal_ptr[palreg]; - } - else if (pp->temp_pal[palreg] > pal_ptr[palreg]) - if ((pp->temp_pal[palreg] = tmpreg2) < pal_ptr[palreg]) - pp->temp_pal[palreg] = pal_ptr[palreg]; - - } - - // Only hard set the palette if this is currently the player's view - if (pp == Player + screenpeek) - { - if (videoGetRenderMode() < REND_POLYMOST) set_pal(pp->temp_pal); - else - { - videoFadePalette( - palette_data[pp->StartColor][0], - palette_data[pp->StartColor][1], - palette_data[pp->StartColor][2], - faderamp[min(31,max(0,32-abs(pp->FadeAmt)))] - ); - } - } - - } - -} - void ResetPalette(PLAYERp pp) { videoFadePalette(0,0,0,0); @@ -4550,6 +4534,7 @@ void ResetPalette(PLAYERp pp) pp->FadeTics = 0; } +#endif // vim:ts=4:sw=4:enc=utf-8: FSavegameInfo GameInterface::GetSaveSig() diff --git a/source/sw/src/menus.h b/source/sw/src/menus.h index 21c7a3ee5..e6ac403f4 100644 --- a/source/sw/src/menus.h +++ b/source/sw/src/menus.h @@ -32,8 +32,15 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms BEGIN_SW_NS -#define MENU_SHADE_DEFAULT 0 -#define MENU_SHADE_INACTIVE 20 +void MNU_MeasureString(const char* string, short* w, short* h); +void MNU_DrawString(short x, short y, const char* string, short shade, short pal); +void MNU_MeasureSmallString(const char* string, short* w, short* h); +void MNU_DrawSmallString(short x, short y, const char* string, short shade, short pal); +void MNU_MeasureStringLarge(const char* string, short* w, short* h); +void MNU_DrawStringLarge(short x, short y, const char* string, int shade = 0); + + +#if 0 typedef enum { @@ -56,12 +63,6 @@ void MNU_DrawMenu(void); // This is used in drawscreen to refresh menus in // multiplay situations. void MNU_CheckForMenus(void); void MNU_CheckForMenusAnyKey(void); -void MNU_MeasureString(const char *string, short *w, short *h); -void MNU_DrawString(short x, short y, const char *string, short shade, short pal); -void MNU_MeasureSmallString(const char *string,short *w,short *h); -void MNU_DrawSmallString(short x,short y,const char *string,short shade,short pal); -void MNU_MeasureStringLarge(const char *string, short *w, short *h); -void MNU_DrawStringLarge(short x, short y, const char *string); // Functions from my other engine //void Get_Palette (unsigned char *pal); @@ -75,7 +76,6 @@ void ExitMenus(void); void ResetMenuInput(void); extern SWBOOL BorderAdjust; -extern SWBOOL MultiPlayQuitFlag; // Make memcpy an intrinsic function for an easy frame rate boost //#pragma intrinsic( memcpy ); @@ -93,8 +93,6 @@ extern SWBOOL MultiPlayQuitFlag; #define M_CX2 319 #define M_CY2 199 -#define MZ 65536 - #define asc_Esc 27 #define asc_Enter 13 #define asc_Space 32 @@ -335,6 +333,8 @@ typedef struct int x,y; } VMODE; +#endif + END_SW_NS #endif diff --git a/source/sw/src/network.cpp b/source/sw/src/network.cpp index 905e45115..d4c5db866 100644 --- a/source/sw/src/network.cpp +++ b/source/sw/src/network.cpp @@ -1497,7 +1497,6 @@ getpackets(void) NewGame = TRUE; // restart demo for multi-play mode DemoInitOnce = FALSE; - ResetMenuInput(); // send a dummy packet to see when it arrives //tempbuf[0] = PACKET_TYPE_DUMMY; diff --git a/source/sw/src/network.h b/source/sw/src/network.h index 8e9f175df..141eb4fbb 100644 --- a/source/sw/src/network.h +++ b/source/sw/src/network.h @@ -1,3 +1,4 @@ +#pragma once //------------------------------------------------------------------------- /* Copyright (C) 1997, 2005 - 3D Realms Entertainment diff --git a/source/sw/src/panel.cpp b/source/sw/src/panel.cpp index 21b0defb9..2c39ceade 100644 --- a/source/sw/src/panel.cpp +++ b/source/sw/src/panel.cpp @@ -44,6 +44,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "weapon.h" #include "fx_man.h" +#include "menu/menu.h" BEGIN_SW_NS @@ -67,7 +68,6 @@ int InitFistAttack(PLAYERp pp); //#define UK_VERSION TRUE #define PANF_UZI_XFLIP (BIT(21)) -extern SWBOOL UsingMenus; #define XDIM 320 #define YDIM 200 @@ -775,7 +775,7 @@ void PlayerUpdatePanelInfo(PLAYERp pp) if (Prediction) return; - if (UsingMenus) + if (M_Active()) return; PlayerUpdateHealth(pp, 0); diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index cb18476c2..5f1cb8962 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -65,6 +65,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "vis.h" #include "track.h" #include "interp.h" +#include "menu/menu.h" BEGIN_SW_NS @@ -2414,7 +2415,7 @@ MoveScrollMode2D(PLAYERp pp) mfsvel = mfvel = 0; - if (MenuInputMode || UsingMenus) + if (M_Active()) return; // Recenter view if told @@ -2476,7 +2477,7 @@ MoveScrollMode2D(PLAYERp pp) } } - if (!UsingMenus && !HelpInputMode && !ConPanel) + if (!M_Active() && !HelpInputMode && !ConPanel) { if (buttonMap.ButtonDown(gamefunc_Move_Forward)) { @@ -2520,8 +2521,17 @@ MoveScrollMode2D(PLAYERp pp) void DoPlayerMenuKeys(PLAYERp pp) { + if (!CommEnabled) { + // Go back to the source to set this - the old code here was catastrophically bad. + // this needs to be fixed properly - as it is this can never be compatible with demo playback. + if (cl_autoaim) + SET(Player[myconnectindex].Flags, PF_AUTO_AIM); + else + RESET(Player[myconnectindex].Flags, PF_AUTO_AIM); + +#if 0 if (TEST_SYNC_KEY((pp), SK_AUTO_AIM)) { if (FLAG_KEY_PRESSED(pp, SK_AUTO_AIM)) @@ -2532,6 +2542,7 @@ DoPlayerMenuKeys(PLAYERp pp) } else FLAG_KEY_RESET(pp, SK_AUTO_AIM); +#endif } } @@ -7660,7 +7671,7 @@ void ChopsCheck(PLAYERp pp) extern SWBOOL HelpInputMode; extern int ChopTics; - if (!UsingMenus && !HelpInputMode && !TEST(pp->Flags, PF_DEAD) && !pp->sop_riding && numplayers <= 1) + if (!M_Active() && !HelpInputMode && !TEST(pp->Flags, PF_DEAD) && !pp->sop_riding && numplayers <= 1) { if ((pp->input.bits|pp->input.vel|pp->input.svel|pp->input.angvel|pp->input.aimvel) || TEST(pp->Flags, PF_CLIMBING|PF_FALLING|PF_DIVING)) diff --git a/source/sw/src/sounds.cpp b/source/sw/src/sounds.cpp index 14a71dfbf..9bb92f3d1 100644 --- a/source/sw/src/sounds.cpp +++ b/source/sw/src/sounds.cpp @@ -50,6 +50,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "rts.h" #include "menus.h" #include "config.h" +#include "menu/menu.h" #ifdef _WIN32 #include "sdlayer.h" @@ -797,7 +798,7 @@ int PlaySound(int num, int *x, int *y, int *z, Voc3D_Flags flags) // Don't play game sounds when in menus - //if (UsingMenus && (*x!=0 || *y!=0 || *z!=0)) return(-1); + //if (M_Active() && (*x!=0 || *y!=0 || *z!=0)) return(-1); // Weed out parental lock sounds if PLock is active if (adult_lockout || Global_PLock) @@ -864,7 +865,7 @@ int PlaySound(int num, int *x, int *y, int *z, Voc3D_Flags flags) // Assign voc to voc pointer vp = &voc[num]; - if (UsingMenus && *x==0 && *y==0 && *z==0) // Menus sound outdo everything + if (M_Active() && *x==0 && *y==0 && *z==0) // Menus sound outdo everything priority = 100; else priority = vp->priority; @@ -1637,7 +1638,7 @@ DoUpdateSounds3D(void) int i; static SWBOOL MoveSkip8 = 0; - if (UsingMenus) return; + if (M_Active()) return; // This function is already only call 10x per sec, this widdles it down even more! MoveSkip8 = (MoveSkip8 + 1) & 15;