From 79ced02d3678d155e8d732d63a1457e9a2542527 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 Dec 2019 00:01:04 +0100 Subject: [PATCH] - implemented the Shadow Warrior menu interface. --- source/common/menu/menu.cpp | 2 + source/common/menu/savegamemanager.cpp | 400 ------------------------- source/rr/src/menus.cpp | 19 -- source/sw/CMakeLists.txt | 1 + source/sw/src/d_menu.cpp | 279 +++++++++++++++++ source/sw/src/game.h | 11 + source/sw/src/menus.cpp | 76 ++--- source/sw/src/menus.h | 123 ++++---- source/sw/src/save.cpp | 122 ++------ source/sw/src/swcvar.cpp | 1 + source/sw/src/swcvar.h | 1 + 11 files changed, 419 insertions(+), 616 deletions(-) create mode 100644 source/sw/src/d_menu.cpp diff --git a/source/common/menu/menu.cpp b/source/common/menu/menu.cpp index 88413202a..0fb2937cb 100644 --- a/source/common/menu/menu.cpp +++ b/source/common/menu/menu.cpp @@ -55,6 +55,7 @@ void RegisterDukeMenus(); void RegisterRedneckMenus(); void RegisterBloodMenus(); +void RegisterSWMenus(); void RegisterLoadsaveMenus(); extern bool rotatesprite_2doverride; bool help_disabled, credits_disabled; @@ -913,6 +914,7 @@ void M_Init (void) RegisterDukeMenus(); RegisterRedneckMenus(); RegisterBloodMenus(); + RegisterSWMenus(); RegisterLoadsaveMenus(); timerSetCallback(M_Ticker); M_ParseMenuDefs(); diff --git a/source/common/menu/savegamemanager.cpp b/source/common/menu/savegamemanager.cpp index 75cedfbe8..d04b81cb0 100644 --- a/source/common/menu/savegamemanager.cpp +++ b/source/common/menu/savegamemanager.cpp @@ -705,403 +705,3 @@ CCMD(quickload) }); M_ActivateMenu(newmenu); } - -#if 0 - -// Duke -if ((buttonMap.ButtonDown(gamefunc_Quick_Load) || g_doQuickSave == 2) && (myplayer.gm & MODE_GAME)) -{ - buttonMap.ClearButton(gamefunc_Quick_Load); - - g_doQuickSave = 0; - - if (g_quickload == nullptr || !g_quickload->isValid()) - { - C_DoCommand("openloadmenu"); - } - else if (g_quickload->isValid()) - { - inputState.keyFlushChars(); - inputState.ClearKeysDown(); - if (G_LoadPlayerMaybeMulti(*g_quickload) != 0) - g_quickload->reset(); - } -} - -if ((buttonMap.ButtonDown(gamefunc_Quick_Save) || g_doQuickSave == 1) && (myplayer.gm & MODE_GAME)) -{ - buttonMap.ClearButton(gamefunc_Quick_Save); - - g_doQuickSave = 0; - - if (!g_lastusersave.isValid()) - { - C_DoCommand("opensavemenu"); - return; - } - inputState.keyFlushChars(); - - if (sprite[myplayer.i].extra <= 0) - { - P_DoQuote(QUOTE_SAVE_DEAD, &myplayer); - return; - } - - g_screenCapture = 1; - G_DrawRooms(myconnectindex, 65536); - g_screenCapture = 0; - - if (g_lastusersave.isValid()) - { - savebrief_t& sv = g_lastusersave; - - // dirty hack... char 127 in last position indicates an auto-filled name - if (sv.name[MAXSAVEGAMENAME] == 127) - { - strncpy(sv.name, g_mapInfo[ud.volume_number * MAXLEVELS + ud.level_number].name, MAXSAVEGAMENAME); - sv.name[MAXSAVEGAMENAME] = 127; - } - - g_quickload = &sv; - G_SavePlayerMaybeMulti(sv); - } - } - - -// handle CON_SAVE and CON_SAVENN -if (g_saveRequested) -{ - inputState.keyFlushChars(); - videoNextPage(); - - g_screenCapture = 1; - G_DrawRooms(myconnectindex, 65536); - g_screenCapture = 0; - - G_SavePlayerMaybeMulti(g_lastautosave, true); - g_quickload = &g_lastautosave; - - OSD_Printf("Saved: %s\n", g_lastautosave.path); - - g_saveRequested = false; -} - - -// RR - -if ((buttonMap.ButtonDown(gamefunc_Quick_Load) || g_doQuickSave == 2) && (!RRRA || ud.player_skill != 4) && (!RR || RRRA || ud.player_skill != 5) && (g_player[myconnectindex].ps->gm & MODE_GAME)) -{ - buttonMap.ClearButton(gamefunc_Quick_Load); - - g_doQuickSave = 0; - - if (g_quickload == nullptr || !g_quickload->isValid()) - { - C_DoCommand("openloadmenu"); - } - else if (g_quickload->isValid()) - { - inputState.keyFlushChars(); - inputState.ClearKeysDown(); - S_PauseSounds(true); - if (G_LoadPlayerMaybeMulti(*g_quickload) != 0) - g_quickload->reset(); - } -} - -if ((buttonMap.ButtonDown(gamefunc_Quick_Save) || g_doQuickSave == 1) && (!RRRA || ud.player_skill != 4) && (!RR || RRRA || ud.player_skill != 5) && (g_player[myconnectindex].ps->gm & MODE_GAME)) -{ - buttonMap.ClearButton(gamefunc_Quick_Save); - - g_doQuickSave = 0; - - if (!g_lastusersave.isValid()) - { - C_DoCommand("opensavemenu"); - return; - } - - inputState.keyFlushChars(); - - if (sprite[g_player[myconnectindex].ps->i].extra <= 0) - { - P_DoQuote(QUOTE_SAVE_DEAD, g_player[myconnectindex].ps); - return; - } - - g_screenCapture = 1; - G_DrawRooms(myconnectindex, 65536); - g_screenCapture = 0; - - if (g_lastusersave.isValid()) - { - savebrief_t& sv = g_lastusersave; - - // dirty hack... char 127 in last position indicates an auto-filled name - if (sv.name[MAXSAVEGAMENAME] == 127) - { - strncpy(sv.name, g_mapInfo[ud.volume_number * MAXLEVELS + ud.level_number].name, MAXSAVEGAMENAME); - sv.name[MAXSAVEGAMENAME] = 127; - } - - g_quickload = &sv; - G_SavePlayerMaybeMulti(sv); - } -} - -// sw - -SWBOOL DoQuickSave(short save_num) -{ - PauseAction(); - - if (SaveGame(save_num) != -1) - { - QuickLoadNum = save_num; - - LastSaveNum = -1; - - return FALSE; - } - - return TRUE; -} - -SWBOOL DoQuickLoad() -{ - inputState.ClearKeysDown(); - - PauseAction(); - - ReloadPrompt = FALSE; - if (LoadGame(QuickLoadNum) == -1) - { - return FALSE; - } - - ready2send = 1; - LastSaveNum = -1; - - return TRUE; -} - - -// F6 quick save -if (inputState.GetKeyStatus(KEYSC_F6)) -{ - inputState.ClearKeyStatus(KEYSC_F6); - if (!TEST(pp->Flags, PF_DEAD)) - { - if (QuickLoadNum < 0) - { - inputState.SetKeyStatus(sc_Escape); - ControlPanelType = ct_savemenu; - } - else - { - inputState.ClearAllInput(); - DoQuickSave(QuickLoadNum); - ResumeAction(); - } - } -} - -// F9 quick load -if (inputState.GetKeyStatus(KEYSC_F9)) -{ - inputState.ClearKeyStatus(KEYSC_F9); - - if (!TEST(pp->Flags, PF_DEAD)) - { - if (QuickLoadNum < 0) - { - inputState.SetKeyStatus(sc_Escape); - ControlPanelType = ct_loadmenu; - } - else - { - DoQuickLoad(); - ResumeAction(); - } - } -} - -//////////////////////////////////////////////// -// Load Game menu -// This function gets called whenever you -// press enter on one of the load game -// spots. -// I'm figuring it need to do the following: -// . Load the game if there is one by calling: MNU_LoadGameCustom. -//////////////////////////////////////////////// -SWBOOL MNU_GetLoadCustom(void) -{ - short load_num; - - load_num = currentmenu->cursor; - - // no saved game exists - don't do anything - if (SaveGameDescr[load_num][0] == '\0') - return FALSE; - - if (InMenuLevel || DemoMode || DemoPlaying) - { - LoadSaveMsg("Loading..."); - - if (LoadGame(load_num) == -1) - return FALSE; - - QuickLoadNum = load_num; - // the (Quick)Save menu should default to the last loaded game - SaveGameGroup.cursor = load_num; - - ExitMenus(); - ExitLevel = TRUE; - LoadGameOutsideMoveLoop = TRUE; - if (DemoMode || DemoPlaying) - LoadGameFromDemo = TRUE; - - return TRUE; - } - - LoadSaveMsg("Loading..."); - - PauseAction(); - - if (LoadGame(load_num) == -1) - { - ResumeAction(); - return FALSE; - } - - QuickLoadNum = load_num; - // the (Quick)Save menu should default to the last loaded game - SaveGameGroup.cursor = load_num; - - ready2send = 1; - LastSaveNum = -1; - ExitMenus(); - - if (DemoMode) - { - ExitLevel = TRUE; - DemoPlaying = FALSE; - } - - return TRUE; -} - -//////////////////////////////////////////////// -// Save Game menu -// This function gets called whenever you -// press enter on one of the save game -// spots. -// I'm figuring it need to do the following: -// . Call MNU_GetInput to allow string input of description. -// . Save the game if there is one by calling: MNU_SaveGameCustom. -//////////////////////////////////////////////// -SWBOOL MNU_GetSaveCustom(void) -{ - short save_num; - extern SWBOOL InMenuLevel, LoadGameOutsideMoveLoop; - - save_num = currentmenu->cursor; - - if (InMenuLevel) - return FALSE; - - if (MenuInputMode) - { - LoadSaveMsg("Saving..."); - - if (DoQuickSave(save_num) == FALSE) - { - LoadGameGroup.cursor = save_num; - } - - ResumeAction(); - ExitMenus(); - - // toggle edit mode - MenuInputMode = FALSE; - } - else - { - strcpy(BackupSaveGameDescr, SaveGameDescr[save_num]); - - // clear keyboard buffer - while (inputState.keyBufferWaiting()) - { - if (inputState.keyGetChar() == 0) - inputState.keyGetChar(); - } - - // toggle edit mode - MenuInputMode = TRUE; - } - - return TRUE; -} - - - -// Blood -static void DoQuickLoad(void) -{ - if (!gGameMenuMgr.m_bActive) - { - if (gQuickLoadSlot != -1) - { - QuickLoadGame(); - return; - } - if (gQuickLoadSlot == -1 && gQuickSaveSlot != -1) - { - gQuickLoadSlot = gQuickSaveSlot; - QuickLoadGame(); - return; - } - gGameMenuMgr.Push(&menuLoadGame, -1); - } -} - -static void DoQuickSave(void) -{ - if (gGameStarted && !gGameMenuMgr.m_bActive && gPlayer[myconnectindex].pXSprite->health != 0) - { - if (gQuickSaveSlot != -1) - { - QuickSaveGame(); - return; - } - gGameMenuMgr.Push(&menuSaveGame, -1); - } -} - -if (gDoQuickSave) -{ - inputState.keyFlushScans(); - switch (gDoQuickSave) - { - case 1: - DoQuickSave(); - break; - case 2: - DoQuickLoad(); - break; - } - gDoQuickSave = 0; - return; -} - - case sc_F6: - inputState.keyFlushScans(); - DoQuickSave(); - break; - case sc_F9: - inputState.keyFlushScans(); - DoQuickLoad(); - break; - - -#endif \ No newline at end of file diff --git a/source/rr/src/menus.cpp b/source/rr/src/menus.cpp index 0bbaf8fc6..238839e89 100644 --- a/source/rr/src/menus.cpp +++ b/source/rr/src/menus.cpp @@ -1390,25 +1390,6 @@ static void Menu_PreDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin) switch (cm) { - case MENU_MAIN_INGAME: - l += 4; - fallthrough__; - case MENU_MAIN: - if (RR) - { - if (RRRA) - rotatesprite_fs(origin.x + ((MENU_MARGIN_CENTER-5)<<16), origin.y + ((57+l)<<16), 16592L,0,THREEDEE,0,0,10); - else - rotatesprite_fs(origin.x + ((MENU_MARGIN_CENTER+5)<<16), origin.y + ((24+l)<<16), 23592L,0,INGAMEDUKETHREEDEE,0,0,10); - } - else - { - rotatesprite_fs(origin.x + (MENU_MARGIN_CENTER<<16), origin.y + ((28+l)<<16), 65536L,0,INGAMEDUKETHREEDEE,0,0,10); - if (PLUTOPAK) // JBF 20030804 - rotatesprite_fs(origin.x + ((MENU_MARGIN_CENTER+100)<<16), origin.y + (36<<16), 65536L,0,PLUTOPAKSPRITE+2,(sintable[((int32_t) totalclock<<4)&2047]>>11),0,2+8); - } - break; - case MENU_CDPLAYER: rotatesprite_fs(origin.x + (MENU_MARGIN_CENTER<<16), origin.y+(100<<16),32768L,0,CDPLAYER,16,0,10); break; diff --git a/source/sw/CMakeLists.txt b/source/sw/CMakeLists.txt index 197582dcd..30277199e 100644 --- a/source/sw/CMakeLists.txt +++ b/source/sw/CMakeLists.txt @@ -102,6 +102,7 @@ set( PCH_SOURCES src/zilla.cpp src/zombie.cpp src/swcvar.cpp + src/d_menu.cpp ) diff --git a/source/sw/src/d_menu.cpp b/source/sw/src/d_menu.cpp new file mode 100644 index 000000000..abd344ce1 --- /dev/null +++ b/source/sw/src/d_menu.cpp @@ -0,0 +1,279 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2016 EDuke32 developers and contributors +Copyright (C) 2019 Christoph Oelckers + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +//------------------------------------------------------------------------- + +#include "ns.h" // Must come before everything else! +#include "build.h" +#include "osd.h" + +#include "keys.h" +#include "names2.h" +#include "panel.h" +#include "game.h" +#include "tags.h" +#include "sector.h" +#include "sprite.h" +#include "weapon.h" +#include "player.h" +#include "jsector.h" +#include "control.h" +#include "menus.h" +#include "sw_strs.h" +#include "pal.h" +#include "demo.h" +#include "input.h" +#include "keydef.h" + +#include "gamecontrol.h" +#include "gamedefs.h" +#include "config.h" +#include "network.h" +#include "fx_man.h" +#include "music.h" +#include "text.h" +#include "version.h" +#include "network.h" + +#include "colormap.h" +#include "config.h" +#include "menu/menu.h" + +#include "../../glbackend/glbackend.h" + + +BEGIN_SW_NS + +int handle1; + +void Menu_Init(void) +{ + + +} + +//---------------------------------------------------------------------------- +// +// Implements the native looking menu used for the main menu +// and the episode/skill selection screens, i.e. the parts +// that need to look authentic +// +//---------------------------------------------------------------------------- + +class SWMainMenu : public DListMenu +{ + void PreDraw() override + { + rotatesprite(160, 15, 65536, 0, pic_shadow_warrior, + m_defshade, 0, ROTATE_SPRITE_SCREEN_CLIP, 0, 0, xdim - 1, ydim - 1); + } +}; + +static bool DidOrderSound; +static int zero = 0; +class SWOrderMenu : public DImageScrollerMenu +{ +public: + SWOrderMenu() + { + if (SW_SHAREWARE && !DidOrderSound) + { + DidOrderSound = true; + int choose_snd = STD_RANDOM_RANGE(1000); + if (choose_snd > 500) + PlaySound(DIGI_WANGORDER1, &zero, &zero, &zero, v3df_dontpan); + else + PlaySound(DIGI_WANGORDER2, &zero, &zero, &zero, v3df_dontpan); + } + } +}; + +//---------------------------------------------------------------------------- +// +// Menu related game interface functions +// +//---------------------------------------------------------------------------- + +void GameInterface::DrawNativeMenuText(int fontnum, int state, double xpos, double ypos, float fontscale, const char* text, int flags) +{ + short w, h; + switch (fontnum) + { + case NIT_BigFont: + MNU_MeasureStringLarge(text, &w, &h); + if (flags & LMF_Centered) xpos -= w/2; + MNU_DrawStringLarge(short(xpos), short(ypos), text, state == NIT_InactiveState? 20 : 0); + break; + + case NIT_SmallFont: + MNU_MeasureString(text, &w, &h); + if (flags & LMF_Centered) xpos -= w/2; + MNU_DrawString(short(xpos), short(ypos), text, state == NIT_InactiveState? 20 : 0, 16); + break; + + case NIT_TinyFont: + MNU_MeasureSmallString(text, &w, &h); + if (flags & LMF_Centered) xpos -= w/2; + MNU_DrawSmallString(short(xpos), short(ypos), text, state == NIT_InactiveState? 20 : 0, 16); + break; + } + if (state == NIT_SelectedState) + { + int x = int(xpos), y = int(ypos); + int scale = 65536; + short w,h; + + if (text) + { + scale /= 2; + x -= mulscale17(tilesiz[pic_yinyang].x,scale) + 2; + y += 4; + } + else + { + scale -= (1<<13); + x -= ((tilesiz[pic_yinyang].x) / 2) - 3; + y += 8; + } + + rotatesprite(x << 16, y << 16, + scale, 0, pic_yinyang, 2, 0, MenuDrawFlags, 0, 0, xdim - 1, ydim - 1); + } +} + + +void GameInterface::MenuOpened() +{ +} + +void GameInterface::MenuSound(EMenuSounds snd) +{ + switch (snd) + { + case CursorSound: + PlaySound(DIGI_STAR,&zero,&zero,&zero,v3df_dontpan); + break; + + case AdvanceSound: + PlaySound(DIGI_SWORDSWOOSH,&zero,&zero,&zero,v3df_dontpan); + break; + + case CloseSound: + PlaySound(DIGI_STARCLINK,&zero,&zero,&zero,v3df_dontpan); + break; + + default: + return; + } +} + +void GameInterface::MenuClosed() +{ + if (!LoadGameOutsideMoveLoop) + { + ResumeGame(); + SetRedrawScreen(&Player[myconnectindex]); + } +} + +extern SWBOOL InMenuLevel; +extern SWBOOL DemoMode; +extern SWBOOL ExitLevel, NewGame; + +bool GameInterface::CanSave() +{ + return (!CommEnabled && numplayers ==1 && !DemoMode && !InMenuLevel && !TEST(Player[myconnectindex].Flags, PF_DEAD)); +} + +void GameInterface::StartGame(FGameStartup& gs) +{ + PLAYERp pp = Player + screenpeek; + int handle = 0; + int zero = 0; + + // always assumed that a demo is playing + + ready2send = 0; + + if (gs.Episode >= 1) + Level = 5; + else + Level = 1; + + DemoPlaying = FALSE; + ExitLevel = TRUE; + NewGame = TRUE; + DemoMode = FALSE; + CameraTestMode = FALSE; + Skill = gs.Skill; + + //InitNewGame(); + + if (Skill == 0) + handle = PlaySound(DIGI_TAUNTAI3,&zero,&zero,&zero,v3df_none); + else if (Skill == 1) + handle = PlaySound(DIGI_NOFEAR,&zero,&zero,&zero,v3df_none); + else if (Skill == 2) + handle = PlaySound(DIGI_WHOWANTSWANG,&zero,&zero,&zero,v3df_none); + else if (Skill == 3) + handle = PlaySound(DIGI_NOPAIN,&zero,&zero,&zero,v3df_none); + + if (handle > FX_Ok) + while (FX_SoundActive(handle)) + handleevents(); +} + +FSavegameInfo GameInterface::GetSaveSig() +{ + return { SAVESIG_SW, MINSAVEVER_SW, SAVEVER_SW }; +} + +void GameInterface::DrawMenuCaption(const DVector2& origin, const char* text) +{ + short w, h; + // Draw the backdrop bar + rotatesprite(10 << 16, (5-3) << 16, 65536, 0, 2427, + 2, 0, MenuDrawFlags|ROTATE_SPRITE_CORNER, 0, 0, xdim - 1, ydim - 1); + MNU_MeasureStringLarge(text, &w, &h); + MNU_DrawString(TEXT_XCENTER(w), 5, text, 1, 16); +} + +void GameInterface::DrawCenteredTextScreen(const DVector2 &origin, const char *text, int position) +{ +} + + + +END_SW_NS + +//---------------------------------------------------------------------------- +// +// Class registration +// +//---------------------------------------------------------------------------- + + +static TMenuClassDescriptor _mm("ShadowWarrior.MainMenu"); +static TMenuClassDescriptor _so("ShadowWarrior.OrderMenu"); + +void RegisterSWMenus() +{ + menuClasses.Push(&_mm); + menuClasses.Push(&_so); +} diff --git a/source/sw/src/game.h b/source/sw/src/game.h index b4e07fe38..fd2de23cb 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -2381,7 +2381,18 @@ struct GameInterface : ::GameInterface bool validate_hud(int) override; void set_hud_layout(int size) override; void set_hud_scale(int size) override; + void DrawNativeMenuText(int fontnum, int state, double xpos, double ypos, float fontscale, const char* text, int flags) override; + void MenuOpened() override; + void MenuSound(EMenuSounds snd) override; + void MenuClosed() override; + bool CanSave() override; + void StartGame(FGameStartup& gs) override; FSavegameInfo GetSaveSig() override; + void DrawMenuCaption(const DVector2& origin, const char* text) override; + void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position) override; + bool LoadGame(FSaveGameNode* sv) override; + bool SaveGame(FSaveGameNode* sv) override; + }; diff --git a/source/sw/src/menus.cpp b/source/sw/src/menus.cpp index de61a05ca..075413c55 100644 --- a/source/sw/src/menus.cpp +++ b/source/sw/src/menus.cpp @@ -634,6 +634,36 @@ void DoPaletteFlash(PLAYERp pp) } +SWBOOL MNU_ShareWareMessage() +{ + const char* extra_text; + short w, h; + + if (SW_SHAREWARE) + { + extra_text = "Be sure to call 800-3DREALMS today"; + MNU_MeasureString(extra_text, &w, &h); + MNU_DrawString(TEXT_XCENTER(w), 110, extra_text, 1, 16); + extra_text = "and order the game."; + MNU_MeasureString(extra_text, &w, &h); + MNU_DrawString(TEXT_XCENTER(w), 120, extra_text, 1, 16); + extra_text = "You are only playing the first "; + MNU_MeasureString(extra_text, &w, &h); + MNU_DrawString(TEXT_XCENTER(w), 130, extra_text, 1, 16); + extra_text = "four levels, and are missing most"; + MNU_MeasureString(extra_text, &w, &h); + MNU_DrawString(TEXT_XCENTER(w), 140, extra_text, 1, 16); + extra_text = "of the game, weapons and monsters."; + MNU_MeasureString(extra_text, &w, &h); + MNU_DrawString(TEXT_XCENTER(w), 150, extra_text, 1, 16); + extra_text = "See the ordering information."; + MNU_MeasureString(extra_text, &w, &h); + MNU_DrawString(TEXT_XCENTER(w), 160, extra_text, 1, 16); + //SET(item->flags, mf_disabled); + } + return TRUE; +} + # if 0 @@ -2105,47 +2135,6 @@ ExitMenus(void) } SWBOOL -MNU_StartGame(void) -{ - PLAYERp pp = Player + screenpeek; - int handle = 0; - int zero = 0; - - // always assumed that a demo is playing - - ready2send = 0; - Skill = currentmenu->cursor; - - if (EpisodeMenuSelection >= 1) - Level = 5; - else - Level = 1; - - ExitMenus(); - DemoPlaying = FALSE; - ExitLevel = TRUE; - NewGame = TRUE; - DemoMode = FALSE; - CameraTestMode = FALSE; - - //InitNewGame(); - - if (Skill == 0) - handle = PlaySound(DIGI_TAUNTAI3,&zero,&zero,&zero,v3df_none); - else if (Skill == 1) - handle = PlaySound(DIGI_NOFEAR,&zero,&zero,&zero,v3df_none); - else if (Skill == 2) - handle = PlaySound(DIGI_WHOWANTSWANG,&zero,&zero,&zero,v3df_none); - else if (Skill == 3) - handle = PlaySound(DIGI_NOPAIN,&zero,&zero,&zero,v3df_none); - - if (handle > FX_Ok) - while (FX_SoundActive(handle)) - handleevents(); - - return TRUE; -} - void ResetMenuInput(void) { cust_callback = NULL; @@ -4537,10 +4526,5 @@ void ResetPalette(PLAYERp pp) #endif // vim:ts=4:sw=4:enc=utf-8: -FSavegameInfo GameInterface::GetSaveSig() -{ - return { SAVESIG_SW, MINSAVEVER_SW, SAVEVER_SW }; -} - END_SW_NS diff --git a/source/sw/src/menus.h b/source/sw/src/menus.h index e6ac403f4..d28c0c952 100644 --- a/source/sw/src/menus.h +++ b/source/sw/src/menus.h @@ -39,65 +39,6 @@ void MNU_DrawSmallString(short x, short y, const char* string, short shade, shor 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 -{ - ct_mainmenu, ct_savemenu, ct_loadmenu, ct_soundmenu, ct_optionmenu, ct_quickloadmenu, - ct_quitmenu, ct_ordermenu, ct_episodemenu, ct_max -} CTLType; - -extern SWBOOL UsingMenus; -extern int SENSITIVITY; -extern CTLType ControlPanelType; -extern int16_t MenuTextShade; -extern int16_t MenuTextPalette; - -// Prototypes -//void MNU_DoMenu( CTLType type, PLAYERp pp ); -void MNU_InitMenus(void); -//void (*CustomRefresh)(void); -//void MNU_Refresh( void ); -void MNU_DrawMenu(void); // This is used in drawscreen to refresh menus in -// multiplay situations. -void MNU_CheckForMenus(void); -void MNU_CheckForMenusAnyKey(void); - -// Functions from my other engine -//void Get_Palette (unsigned char *pal); -//void Set_Palette(unsigned char *buff); -//void Fade_Timer(int clicks); -void FadeIn(unsigned char targetcolor, unsigned int clicks); -void FadeOut(unsigned char targetcolor, unsigned int clicks); -void ResetPalette(PLAYERp pp); - -void ExitMenus(void); -void ResetMenuInput(void); - -extern SWBOOL BorderAdjust; - -// Make memcpy an intrinsic function for an easy frame rate boost -//#pragma intrinsic( memcpy ); - -// L O C A L V A R I A B L E S //////////////////////////////////////////////////////////////// - -// Default menu pic brightness -#define m_defshade 2 - -#define FLASHTIME 60 // One second per icon flash - -// Defines for permanentwritesprite clipping box -#define M_CX1 0 -#define M_CY1 0 -#define M_CX2 319 -#define M_CY2 199 - -#define asc_Esc 27 -#define asc_Enter 13 -#define asc_Space 32 - - #define pic_none 0 #define pic_radiobuttn1 2816 #define pic_radiobuttn2 2817 @@ -150,6 +91,69 @@ extern SWBOOL BorderAdjust; #define pic_savedescr 2924 #define pic_shadow_warrior 2366 +#define m_defshade 2 +#define MenuDrawFlags (ROTATE_SPRITE_SCREEN_CLIP) +extern SWBOOL LoadGameOutsideMoveLoop; + + +#if 0 + +typedef enum +{ + ct_mainmenu, ct_savemenu, ct_loadmenu, ct_soundmenu, ct_optionmenu, ct_quickloadmenu, + ct_quitmenu, ct_ordermenu, ct_episodemenu, ct_max +} CTLType; + +extern SWBOOL UsingMenus; +extern int SENSITIVITY; +extern CTLType ControlPanelType; +extern int16_t MenuTextShade; +extern int16_t MenuTextPalette; + +// Prototypes +//void MNU_DoMenu( CTLType type, PLAYERp pp ); +void MNU_InitMenus(void); +//void (*CustomRefresh)(void); +//void MNU_Refresh( void ); +void MNU_DrawMenu(void); // This is used in drawscreen to refresh menus in +// multiplay situations. +void MNU_CheckForMenus(void); +void MNU_CheckForMenusAnyKey(void); + +// Functions from my other engine +//void Get_Palette (unsigned char *pal); +//void Set_Palette(unsigned char *buff); +//void Fade_Timer(int clicks); +void FadeIn(unsigned char targetcolor, unsigned int clicks); +void FadeOut(unsigned char targetcolor, unsigned int clicks); +void ResetPalette(PLAYERp pp); + +void ExitMenus(void); +void ResetMenuInput(void); + +extern SWBOOL BorderAdjust; + +// Make memcpy an intrinsic function for an easy frame rate boost +//#pragma intrinsic( memcpy ); + +// L O C A L V A R I A B L E S //////////////////////////////////////////////////////////////// + +// Default menu pic brightness + +#define FLASHTIME 60 // One second per icon flash + +// Defines for permanentwritesprite clipping box +#define M_CX1 0 +#define M_CY1 0 +#define M_CX2 319 +#define M_CY2 199 + +#define asc_Esc 27 +#define asc_Enter 13 +#define asc_Space 32 + + + // This is the current values set with all slider bar functions #define SENSE_DEFAULT 10 // Default mouse sensitivity ** should be 5!!! #define FXVOL_DEFAULT 8 // Default sound fx volume @@ -226,7 +230,6 @@ enum typedef int MenuFlags; #define MenuSelectFlags (mf_pushed | mf_selected | mf_disabled) -#define MenuDrawFlags (ROTATE_SPRITE_SCREEN_CLIP) typedef enum { diff --git a/source/sw/src/save.cpp b/source/sw/src/save.cpp index 56f5c242e..791f670b6 100644 --- a/source/sw/src/save.cpp +++ b/source/sw/src/save.cpp @@ -221,7 +221,8 @@ int LoadSymCodeInfo(MFILE_READ fil, void **ptr) } -int SaveGame(short save_num) + +bool GameInterface::SaveGame(FSaveGameNode *sv) { MFILE_WRITE fil; int i,j; @@ -247,16 +248,13 @@ int SaveGame(short save_num) Saveable_Init(); - FStringf base("save%04d", save_num); - auto game_name = G_BuildSaveName(base); + auto game_name = G_BuildSaveName(sv->Filename); OpenSaveGameForWrite(game_name); - G_WriteSaveHeader(SaveGameDescr[save_num], LevelInfo[Level].LevelName, LevelInfo[Level].Description); + G_WriteSaveHeader(sv->SaveTitle, LevelInfo[Level].LevelName, LevelInfo[Level].Description); fil = WriteSavegameChunk("snapshot.sw"); MWRITE(&GameVersion,sizeof(GameVersion),1,fil); - MWRITE(SaveGameDescr[save_num],sizeof(SaveGameDescr[save_num]),1,fil); - MWRITE(&Level,sizeof(Level),1,fil); MWRITE(&Skill,sizeof(Skill),1,fil); @@ -693,78 +691,17 @@ int SaveGame(short save_num) //MWRITE(&Zombies, sizeof(Zombies), 1, fil); MCLOSE_WRITE(fil); + if (!saveisshot) + return FinishSavegameWrite(); - ////DSPRINTF(ds, "done saving"); - //MONO_PRINT(ds); - - if (saveisshot) - CON_Message("There was a problem saving. See \"Save Help\" section of release notes."); - - return saveisshot ? -1 : 0; -} - -int LoadGameFullHeader(short save_num, char *descr, short *level, short *skill) -{ -#if 0 // only used by the menu. Will go away soon. - MFILE_READ fil; - char game_name[256]; - short tile; - int ver; - - snprintf(game_name, 256, "%sgame%d.sav", M_GetSavegamesPath().GetChars(), save_num); - if ((fil = MOPEN_READ(game_name)) == MOPEN_READ_ERR) - return -1; - - MREAD(&ver,sizeof(ver),1,fil); - if (ver != GameVersion) - { - MCLOSE_READ(fil); - return -1; - } - - MREAD(descr, sizeof(SaveGameDescr[0]), 1,fil); - - MREAD(level,sizeof(*level),1,fil); - MREAD(skill,sizeof(*skill),1,fil); - - tile = ScreenLoadSaveSetup(Player + myconnectindex); - ScreenLoad(fil); - - MCLOSE_READ(fil); - - return tile; -#else - return 0; -#endif -} - -void LoadGameDescr(short save_num, char *descr) -{ -#if 0 - MFILE_READ fil; - char game_name[256]; - short tile; - int ver; - - snprintf(game_name, 256, "%sgame%d.sav", M_GetSavegamesPath().GetChars(), save_num); - if ((fil = MOPEN_READ(game_name)) == MOPEN_READ_ERR) - return; - - MREAD(&ver,sizeof(ver),1,fil); - if (ver != GameVersion) - { - MCLOSE_READ(fil); - return; - } - - MREAD(descr, sizeof(SaveGameDescr[0]),1,fil); - - MCLOSE_READ(fil); -#endif + return false; } -int LoadGame(short save_num) +extern SWBOOL LoadGameOutsideMoveLoop; +extern SWBOOL InMenuLevel; + +bool GameInterface::LoadGame(FSaveGameNode* sv) { MFILE_READ fil; int i,j,saveisshot=0; @@ -786,23 +723,23 @@ int LoadGame(short save_num) int StateStartNdx; int StateNdx; int StateEndNdx; - extern SWBOOL InMenuLevel; + + if (!InMenuLevel) PauseAction(); Saveable_Init(); - FStringf base("save%04d", save_num); - auto game_name = G_BuildSaveName(base); + auto game_name = G_BuildSaveName(sv->Filename); OpenSaveGameForRead(game_name); auto filr = ReadSavegameChunk("snapshot.sw"); - if (!filr.isOpen()) return -1; + if (!filr.isOpen()) return false; fil = &filr; MREAD(&i,sizeof(i),1,fil); if (i != GameVersion) { MCLOSE_READ(fil); - return -1; + return false; } // Don't terminate until you've made sure conditions are valid for loading. @@ -814,8 +751,6 @@ int LoadGame(short save_num) Terminate3DSounds(); - MREAD(SaveGameDescr[save_num], sizeof(SaveGameDescr[save_num]),1,fil); - MREAD(&Level,sizeof(Level),1,fil); MREAD(&Skill,sizeof(Skill),1,fil); @@ -855,7 +790,7 @@ int LoadGame(short save_num) saveisshot |= LoadSymCodeInfo(fil, (void **)&pp->DoPlayerAction); saveisshot |= LoadSymDataInfo(fil, (void **)&pp->sop_control); saveisshot |= LoadSymDataInfo(fil, (void **)&pp->sop_riding); - if (saveisshot) { MCLOSE_READ(fil); return -1; } + if (saveisshot) { MCLOSE_READ(fil); return false; } } @@ -887,12 +822,12 @@ int LoadGame(short save_num) saveisshot |= LoadSymDataInfo(fil, (void **)&psp->ActionState); saveisshot |= LoadSymDataInfo(fil, (void **)&psp->RestState); saveisshot |= LoadSymCodeInfo(fil, (void **)&psp->PanelSpriteFunc); - if (saveisshot) { MCLOSE_READ(fil); return -1; } + if (saveisshot) { MCLOSE_READ(fil); return false; } for (j = 0; j < (int)SIZ(psp->over); j++) { saveisshot |= LoadSymDataInfo(fil, (void **)&psp->over[j].State); - if (saveisshot) { MCLOSE_READ(fil); return -1; } + if (saveisshot) { MCLOSE_READ(fil); return false; } } } @@ -982,7 +917,7 @@ int LoadGame(short save_num) saveisshot |= LoadSymDataInfo(fil, (void **)&u->SpriteP); saveisshot |= LoadSymDataInfo(fil, (void **)&u->PlayerP); saveisshot |= LoadSymDataInfo(fil, (void **)&u->tgt_sp); - if (saveisshot) { MCLOSE_READ(fil); return -1; } + if (saveisshot) { MCLOSE_READ(fil); return false; } MREAD(&SpriteNum,sizeof(SpriteNum),1,fil); } @@ -998,7 +933,7 @@ int LoadGame(short save_num) saveisshot |= LoadSymCodeInfo(fil, (void **)&sop->Animator); saveisshot |= LoadSymDataInfo(fil, (void **)&sop->controller); saveisshot |= LoadSymDataInfo(fil, (void **)&sop->sp_child); - if (saveisshot) { MCLOSE_READ(fil); return -1; } + if (saveisshot) { MCLOSE_READ(fil); return false; } } MREAD(SineWaveFloor, sizeof(SineWaveFloor),1,fil); @@ -1071,7 +1006,7 @@ int LoadGame(short save_num) saveisshot |= LoadSymCodeInfo(fil, (void **)&a->callback); saveisshot |= LoadSymDataInfo(fil, (void **)&a->callbackdata); - if (saveisshot) { MCLOSE_READ(fil); return -1; } + if (saveisshot) { MCLOSE_READ(fil); return false; } } #else AnimCnt = 0; @@ -1091,7 +1026,7 @@ int LoadGame(short save_num) saveisshot |= LoadSymDataInfo(fil, (void **)&a->ptr); saveisshot |= LoadSymCodeInfo(fil, (void **)&a->callback); saveisshot |= LoadSymDataInfo(fil, (void **)&a->callbackdata); - if (saveisshot) { MCLOSE_READ(fil); return -1; } + if (saveisshot) { MCLOSE_READ(fil); return false; } } #endif #endif @@ -1120,7 +1055,7 @@ int LoadGame(short save_num) MREAD(bakipos,sizeof(bakipos),1,fil); for (i = numinterpolations - 1; i >= 0; i--) saveisshot |= LoadSymDataInfo(fil, (void **)&curipos[i]); - if (saveisshot) { MCLOSE_READ(fil); return -1; } + if (saveisshot) { MCLOSE_READ(fil); return false; } // short interpolations MREAD(&short_numinterpolations,sizeof(short_numinterpolations),1,fil); @@ -1129,7 +1064,7 @@ int LoadGame(short save_num) MREAD(short_bakipos,sizeof(short_bakipos),1,fil); for (i = short_numinterpolations - 1; i >= 0; i--) saveisshot |= LoadSymDataInfo(fil, (void **)&short_curipos[i]); - if (saveisshot) { MCLOSE_READ(fil); return -1; } + if (saveisshot) { MCLOSE_READ(fil); return false; } // parental lock for (i = 0; i < (int)SIZ(otlist); i++) @@ -1311,7 +1246,12 @@ int LoadGame(short save_num) DoPlayerDivePalette(Player+myconnectindex); DoPlayerNightVisionPalette(Player+myconnectindex); - return 0; + + ExitLevel = TRUE; + LoadGameOutsideMoveLoop = TRUE; + + if (!InMenuLevel) ready2send = 1; + return true; } void diff --git a/source/sw/src/swcvar.cpp b/source/sw/src/swcvar.cpp index 61dd2961d..b61f18162 100644 --- a/source/sw/src/swcvar.cpp +++ b/source/sw/src/swcvar.cpp @@ -1,3 +1,4 @@ #include "swcvar.h" CVAR(Bool, sw_ninjahack, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +CVAR(Bool, sw_usedarts, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); diff --git a/source/sw/src/swcvar.h b/source/sw/src/swcvar.h index 8302d574e..1ca530f7f 100644 --- a/source/sw/src/swcvar.h +++ b/source/sw/src/swcvar.h @@ -2,3 +2,4 @@ EXTERN_CVAR(Bool, sw_ninjahack) +EXTERN_CVAR(Bool, sw_usedarts)