From 5d31119a4987c2283a1c392f43048cd3dc59f674 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 6 Nov 2019 19:22:14 +0100 Subject: [PATCH] - fixed the Shadow Warrior menu, but it doesn't do much good. The game appears to be thoroughly broken. --- source/blood/src/blood.h | 1 + source/blood/src/gamemenu.cpp | 5 + source/blood/src/messages.cpp | 6 +- source/build/include/baselayer.h | 1 + source/common/console/c_bind.h | 8 +- source/common/inputstate.h | 32 +++++ source/common/searchpaths.cpp | 3 +- source/duke3d/src/duke3d.h | 1 + source/duke3d/src/game.cpp | 4 +- source/duke3d/src/menus.cpp | 6 + source/duke3d/src/menus.h | 1 + source/mact/include/control.h | 22 ---- source/mact/src/input.cpp | 8 +- source/rr/src/duke3d.h | 1 + source/rr/src/game.cpp | 1 + source/rr/src/menus.cpp | 6 + source/sw/src/anim.cpp | 7 +- source/sw/src/game.cpp | 13 +- source/sw/src/game.h | 3 +- source/sw/src/menus.cpp | 125 +++++++++----------- wadsrc/static/demolition/demolition.grpinfo | 9 ++ 21 files changed, 157 insertions(+), 106 deletions(-) diff --git a/source/blood/src/blood.h b/source/blood/src/blood.h index 9fe06ed31..bc4241c53 100644 --- a/source/blood/src/blood.h +++ b/source/blood/src/blood.h @@ -90,6 +90,7 @@ struct GameInterface : ::GameInterface bool validate_hud(int) override; void set_hud_layout(int size) override; void set_hud_scale(int size) override; + bool mouseInactiveConditional(bool condition) override; }; END_BLD_NS diff --git a/source/blood/src/gamemenu.cpp b/source/blood/src/gamemenu.cpp index ab145a120..0e1010313 100644 --- a/source/blood/src/gamemenu.cpp +++ b/source/blood/src/gamemenu.cpp @@ -2963,4 +2963,9 @@ bool CGameMenuItemPassword::Event(CGameMenuEvent &event) return CGameMenuItem::Event(event); } +bool GameInterface::mouseInactiveConditional(bool condition) +{ + return MOUSEINACTIVECONDITIONAL(condition); +} + END_BLD_NS diff --git a/source/blood/src/messages.cpp b/source/blood/src/messages.cpp index 9c2f633fe..f69cb5c96 100644 --- a/source/blood/src/messages.cpp +++ b/source/blood/src/messages.cpp @@ -56,7 +56,11 @@ void sub_5A928(void) void sub_5A944(int key) { auto binding = Bindings.GetBind(key); -#pragma message("todo: reset the bound button here") + if (binding) + { + auto index = buttonMap.FindButtonIndex(binding); + if (index >= 0) buttonMap.ClearButton(index); + } } void SetGodMode(bool god) diff --git a/source/build/include/baselayer.h b/source/build/include/baselayer.h index a3fc0ba80..76d58a4dc 100644 --- a/source/build/include/baselayer.h +++ b/source/build/include/baselayer.h @@ -173,6 +173,7 @@ struct GameInterface virtual bool validate_hud(int) = 0; virtual void set_hud_layout(int size) = 0; virtual void set_hud_scale(int size) = 0; + virtual bool mouseInactiveConditional(bool condition) { return condition; } }; extern GameInterface* gi; diff --git a/source/common/console/c_bind.h b/source/common/console/c_bind.h index ef9012b73..08e68de2f 100644 --- a/source/common/console/c_bind.h +++ b/source/common/console/c_bind.h @@ -72,8 +72,12 @@ public: const char *GetBind(unsigned int index) const { - if (index < NUM_KEYS) return Binds[index].GetChars(); - else return NULL; + if (index < NUM_KEYS) + { + auto c = Binds[index].GetChars(); + if (*c) return c; + } + return NULL; } }; diff --git a/source/common/inputstate.h b/source/common/inputstate.h index 683f4bc8c..f0b3bdc76 100644 --- a/source/common/inputstate.h +++ b/source/common/inputstate.h @@ -293,6 +293,38 @@ public: inline void MouseClearAllButtonss(void) { g_mouseBits = 0; } }; +typedef enum +{ + dir_North, + dir_NorthEast, + dir_East, + dir_SouthEast, + dir_South, + dir_SouthWest, + dir_West, + dir_NorthWest, + dir_None +} direction; + +struct UserInput +{ + int32_t button0; + int32_t button1; + direction dir; +}; + +// Shadow Warrior still uses these. :( +inline void CONTROL_GetUserInput(UserInput* inp) +{ + +} + +inline void CONTROL_ClearUserInput(UserInput* inp) +{ + +} + + extern InputState inputState; diff --git a/source/common/searchpaths.cpp b/source/common/searchpaths.cpp index 1a7741e99..9fd01954a 100644 --- a/source/common/searchpaths.cpp +++ b/source/common/searchpaths.cpp @@ -661,7 +661,8 @@ static TArray ParseGrpInfo(const char *fn, FileReader &fr, TMapmouseInactiveConditional(inputState.MouseGetButtons()&LEFT_MOUSE) || (JOYSTICK_GetGameControllerButtons()&(1<mouseInactiveConditional(buttonMap.ButtonDown(gamefunc_Fire)) || buttonMap.ButtonDown(gamefunc_Crouch) || (JOYSTICK_GetGameControllerButtons()&(1<mouseInactiveConditional((inputState.MouseGetButtons()&LEFT_MOUSE) && (inputState.MouseGetButtons()&WHEELUP_MOUSE)) #endif ; } @@ -295,7 +295,7 @@ int32_t I_SliderRight(void) return I_MenuRight() #if !defined EDUKE32_TOUCH_DEVICES - //|| MOUSEINACTIVECONDITIONAL((inputState.MouseGetButtons()&LEFT_MOUSE) && (inputState.MouseGetButtons()&WHEELDOWN_MOUSE)) + || gi->mouseInactiveConditional((inputState.MouseGetButtons()&LEFT_MOUSE) && (inputState.MouseGetButtons()&WHEELDOWN_MOUSE)) #endif ; } diff --git a/source/rr/src/duke3d.h b/source/rr/src/duke3d.h index 5d4405f7c..f5568d8cb 100644 --- a/source/rr/src/duke3d.h +++ b/source/rr/src/duke3d.h @@ -155,6 +155,7 @@ struct GameInterface : ::GameInterface bool validate_hud(int) override; void set_hud_layout(int size) override; void set_hud_scale(int size) override; + bool mouseInactiveConditional(bool condition) override; }; END_RR_NS diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index f94cc2bea..4e1466619 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -7756,6 +7756,7 @@ int GameInterface::app_main() FX_StopAllSounds(); S_ClearSoundLocks(); app_loop(); + return 0; } void app_loop() diff --git a/source/rr/src/menus.cpp b/source/rr/src/menus.cpp index dab13bd4e..6bdb89f71 100644 --- a/source/rr/src/menus.cpp +++ b/source/rr/src/menus.cpp @@ -7592,4 +7592,10 @@ void M_DisplayMenus(void) CAMERADIST = 65536; } } + +bool GameInterface::mouseInactiveConditional(bool condition) +{ + return MOUSEINACTIVECONDITIONAL(condition); +} + END_RR_NS diff --git a/source/sw/src/anim.cpp b/source/sw/src/anim.cpp index 7d22a3e5c..047732631 100644 --- a/source/sw/src/anim.cpp +++ b/source/sw/src/anim.cpp @@ -46,6 +46,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "animlib.h" #include "anim.h" +#include "input.h" #include "common_game.h" @@ -322,11 +323,13 @@ playanm(short anim_num) switch (ANIMnum) { case ANIM_INTRO: - if (inputState.keyBufferWaiting() || uinfo.button0 || uinfo.button1 || quitevent) + if (I_GeneralTrigger() || quitevent) + I_GeneralTriggerClear(); goto ENDOFANIMLOOP; break; case ANIM_SERP: - if (inputState.GetKeyStatus(KEYSC_ESC) || uinfo.button1 || quitevent) + if (I_EscapeTrigger() || quitevent) + I_EscapeTriggerClear(); goto ENDOFANIMLOOP; break; } diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 4e3f79980..6855fe556 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -61,6 +61,7 @@ Things required to make savegames work: #include "network.h" #include "pal.h" #include "fx_man.h" +#include "input.h" #include "mytypes.h" //#include "config.h" @@ -1696,8 +1697,9 @@ LogoLevel(void) ototalclock += synctics; } - if (totalclock > 5*120 || KeyPressed() || uinfo.button0 || uinfo.button1) + if (totalclock > 5*120 || I_GeneralTrigger()) { + I_GeneralTriggerClear(); break; } } @@ -2439,8 +2441,9 @@ BonusScreen(PLAYERp pp) CONTROL_GetUserInput(&uinfo); CONTROL_ClearUserInput(&uinfo); - if (inputState.GetKeyStatus(KEYSC_SPACE) || inputState.GetKeyStatus(KEYSC_ENTER) || uinfo.button0 || uinfo.button1) + if (I_GeneralTrigger()) { + I_GeneralTriggerClear(); if (State >= s_BonusRest && State < &s_BonusRest[SIZ(s_BonusRest)]) { State = s_BonusAnim[STD_RANDOM_RANGE(SIZ(s_BonusAnim))]; @@ -5017,6 +5020,12 @@ saveable_module saveable_build = /*extern*/ void GameInterface::set_hud_layout(int requested_size) { /* the relevant setting is gs.BorderNum */} /*extern*/ void GameInterface::set_hud_scale(int requested_size) { /* the relevant setting is gs.BorderNum */ } +bool GameInterface::mouseInactiveConditional(bool condition) +{ + return condition; +} + + ::GameInterface* CreateInterface() { return new GameInterface; diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 293277f5f..ed577269e 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -383,7 +383,7 @@ extern char MessageOutputString[256]; #define TRAVERSE_SPRITE_SECT(l, o, n) for ((o) = (l); (n) = nextspritesect[o], (o) != -1; (o) = (n)) #define TRAVERSE_SPRITE_STAT(l, o, n) for ((o) = (l); (n) = nextspritestat[o], (o) != -1; (o) = (n)) -#define TRAVERSE_CONNECT(i) for (i = connecthead; i != -1; i = connectpoint2[i]) +#define TRAVERSE_CONNECT(i) for (i = connecthead; i != -1 && i != connectpoint2[i]; i = connectpoint2[i]) #define NORM_ANGLE(ang) ((ang) & 2047) @@ -2380,6 +2380,7 @@ struct GameInterface : ::GameInterface bool validate_hud(int) override; void set_hud_layout(int size) override; void set_hud_scale(int size) override; + bool mouseInactiveConditional(bool condition) override; }; diff --git a/source/sw/src/menus.cpp b/source/sw/src/menus.cpp index 8dac286aa..a68e8b7b1 100644 --- a/source/sw/src/menus.cpp +++ b/source/sw/src/menus.cpp @@ -43,6 +43,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "sw_strs.h" #include "pal.h" #include "demo.h" +#include "input.h" #include "gamecontrol.h" #include "gamedefs.h" @@ -759,16 +760,32 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item) if (currentkey < 0) currentkey = 0; inputState.ClearKeyStatus(sc_PgUp); } - else if (inpt.button0) + else if (I_EscapeTrigger()) { currentmode = 1; inputState.ClearLastScanCode(); inputState.ClearKeysDown(); } - else if (inpt.dir == dir_North) currentkey = max(0,currentkey-1); - else if (inpt.dir == dir_South) currentkey = min(NUMGAMEFUNCTIONS-1,currentkey+1); - else if (inpt.dir == dir_East) currentcol = 1; - else if (inpt.dir == dir_West) currentcol = 0; + else if (I_MenuUp()) + { + I_MenuUpClear(); + currentkey = max(0, currentkey - 1); + } + else if (I_MenuDown()) + { + I_MenuDownClear(); + currentkey = min(NUMGAMEFUNCTIONS - 1, currentkey + 1); + } + else if (I_MenuRight()) + { + I_MenuRightClear(); + currentcol = 1; + } + else if (I_MenuLeft()) + { + I_MenuLeftClear(); + currentcol = 0; + } if (currentkey == gamefunc_Show_Console) currentcol = 0; @@ -873,12 +890,21 @@ static int MNU_SelectButtonFunction(const char *buttonname, int *currentfunc) if (*currentfunc < 0) *currentfunc = 0; inputState.ClearKeyStatus(sc_PgUp); } - else if (inpt.button0) + else if (I_GeneralTrigger()) { + I_GeneralTriggerClear(); returnval = 1; } - else if (inpt.dir == dir_North) *currentfunc = max(0, *currentfunc-1); - else if (inpt.dir == dir_South) *currentfunc = min(NUMGAMEFUNCTIONS-1, *currentfunc+1); + else if (I_MenuUp()) + { + I_MenuUpClear(); + *currentfunc = max(0, *currentfunc - 1); + } + else if (inpt.dir == dir_South) + { + I_MenuDownClear(); + *currentfunc = min(NUMGAMEFUNCTIONS - 1, *currentfunc + 1); + } CONTROL_ClearUserInput(&inpt); @@ -1622,20 +1648,24 @@ MNU_OrderCustom(UserCall call, MenuItem *item) ExitMenus(); } - if (order_input.dir == dir_North) + if (I_MenuUp()) { + I_MenuUpClear(); on_screen--; } - else if (order_input.dir == dir_South) + else if (I_MenuDown()) { + I_MenuDownClear(); on_screen++; } - else if (order_input.dir == dir_West) + else if (I_MenuLeft()) { + I_MenuLeftClear(); on_screen--; } - else if (order_input.dir == dir_East) + else if (I_MenuRight()) { + I_MenuRightClear(); on_screen++; } @@ -4427,91 +4457,46 @@ void MNU_DoMenu(CTLType type, PLAYERp pp) // should not get input if you are editing a save game slot if (totalclock < limitmove) limitmove = (int32_t) totalclock; - if (!MenuInputMode) - { - UserInput tst_input; - SWBOOL select_held = FALSE; - - - // Zero out the input structure - tst_input.button0 = tst_input.button1 = FALSE; - tst_input.dir = dir_None; - - if (!select_held) - { - CONTROL_GetUserInput(&tst_input); - mnu_input_buffered.dir = tst_input.dir; - } - - if (mnu_input_buffered.button0 || mnu_input_buffered.button1) - { - if (tst_input.button0 == mnu_input_buffered.button0 && - tst_input.button1 == mnu_input_buffered.button1) - { - select_held = TRUE; - } - else if (totalclock - limitmove > 7) - { - mnu_input.button0 = mnu_input_buffered.button0; - mnu_input.button1 = mnu_input_buffered.button1; - - mnu_input_buffered.button0 = tst_input.button0; - mnu_input_buffered.button1 = tst_input.button1; - } - } - else - { - select_held = FALSE; - mnu_input_buffered.button0 = tst_input.button0; - mnu_input_buffered.button1 = tst_input.button1; - } - - if (totalclock - limitmove > 7 && !select_held) - { - mnu_input.dir = mnu_input_buffered.dir; - - if (mnu_input.dir != dir_None) - if (!FX_SoundActive(handle2)) - handle2 = PlaySound(DIGI_STAR,&zero,&zero,&zero,v3df_dontpan); - - limitmove = (int32_t) totalclock; - mnu_input_buffered.dir = dir_None; - } - } - - if (mnu_input.dir == dir_North) + + if (I_MenuUp()) { + I_MenuUpClear(); MNU_PrevItem(); resetitem = TRUE; } - else if (mnu_input.dir == dir_South) + else if (I_MenuDown()) { + I_MenuDownClear(); MNU_NextItem(); resetitem = TRUE; } - else if (mnu_input.button0) + else if (I_GeneralTrigger()) { static int handle5=0; + I_GeneralTriggerClear(); if (!FX_SoundActive(handle5)) handle5 = PlaySound(DIGI_SWORDSWOOSH,&zero,&zero,&zero,v3df_dontpan); inputState.ClearKeysDown(); MNU_DoItem(); resetitem = TRUE; } - else if (mnu_input.dir == dir_West + else if (I_MenuLeft() && currentmenu->items[currentmenu->cursor].type == mt_slider) { + I_MenuLeftClear(); MNU_DoSlider(-1, ¤tmenu->items[currentmenu->cursor], FALSE); resetitem = TRUE; } - else if (mnu_input.dir == dir_East + else if (I_MenuRight() && currentmenu->items[currentmenu->cursor].type == mt_slider) { + I_MenuRightClear(); MNU_DoSlider(1, ¤tmenu->items[currentmenu->cursor], FALSE); resetitem = TRUE; } - else if (mnu_input.button1) + else if (I_ReturnTrigger()) { + I_ReturnTriggerClear(); static int handle3=0; if (!FX_SoundActive(handle3)) handle3 = PlaySound(DIGI_SWORDSWOOSH,&zero,&zero,&zero,v3df_dontpan); diff --git a/wadsrc/static/demolition/demolition.grpinfo b/wadsrc/static/demolition/demolition.grpinfo index 0595433d9..b1561d67b 100644 --- a/wadsrc/static/demolition/demolition.grpinfo +++ b/wadsrc/static/demolition/demolition.grpinfo @@ -363,3 +363,12 @@ grpinfo gamefilter "Blood.Cryptic" } +grpinfo +{ + name "Shadow Warrior" + flags GAMEFLAG_SW + crc 0x7545319F + size 47536148 + defname "sw.def" + gamefilter "ShadowWarrior.ShadowWarrior" +}