- fixed the Shadow Warrior menu, but it doesn't do much good. The game appears to be thoroughly broken.

This commit is contained in:
Christoph Oelckers 2019-11-06 19:22:14 +01:00
parent 6ee807f225
commit 5d31119a49
21 changed files with 157 additions and 106 deletions

View file

@ -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

View file

@ -2963,4 +2963,9 @@ bool CGameMenuItemPassword::Event(CGameMenuEvent &event)
return CGameMenuItem::Event(event);
}
bool GameInterface::mouseInactiveConditional(bool condition)
{
return MOUSEINACTIVECONDITIONAL(condition);
}
END_BLD_NS

View file

@ -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)

View file

@ -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;

View file

@ -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;
}
};

View file

@ -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;

View file

@ -661,7 +661,8 @@ static TArray<GrpInfo> ParseGrpInfo(const char *fn, FileReader &fr, TMap<FString
FlagMap.Insert("GAMEFLAG_RR", GAMEFLAG_RR);
FlagMap.Insert("GAMEFLAG_RRRA", GAMEFLAG_RRRA);
FlagMap.Insert("GAMEFLAG_BLOOD", GAMEFLAG_BLOOD);
FlagMap.Insert("GAMEFLAG_SW", GAMEFLAG_SW);
FScanner sc;
auto mem = fr.Read();
sc.OpenMem(fn, (const char *)mem.Data(), mem.Size());

View file

@ -151,6 +151,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_DUKE_NS

View file

@ -4806,7 +4806,8 @@ FAKE_F3:
}
}
if (inputState.UnboundKeyPressed(sc_F4))
if (inputState.GetKeyStatus(sc_F4))
if (inputState.UnboundKeyPressed(sc_F4))
{
inputState.ClearKeyStatus(sc_F4);
@ -6349,6 +6350,7 @@ int GameInterface::app_main()
VM_OnEvent(EVENT_INITCOMPLETE);
app_loop();
return 0;
}
void app_loop()

View file

@ -7135,4 +7135,10 @@ void M_DisplayMenus(void)
CAMERADIST = 65536;
}
}
bool GameInterface::mouseInactiveConditional(bool condition)
{
return MOUSEINACTIVECONDITIONAL(condition);
}
END_DUKE_NS

View file

@ -488,6 +488,7 @@ extern int32_t m_mousewake_watchpoint, m_menuchange_watchpoint;
# define MOUSEWATCHPOINTCONDITIONAL(condition) ((condition) || m_mousewake_watchpoint || m_menuchange_watchpoint == 3)
#endif
#define MAXMENUGAMEPLAYENTRIES 7
enum MenuGameplayEntryFlags

View file

@ -69,25 +69,6 @@ typedef enum
analog_maxtype
} analogcontrol;
typedef enum
{
dir_North,
dir_NorthEast,
dir_East,
dir_SouthEast,
dir_South,
dir_SouthWest,
dir_West,
dir_NorthWest,
dir_None
} direction;
typedef struct
{
int32_t button0;
int32_t button1;
direction dir;
} UserInput;
typedef struct
{
@ -205,9 +186,6 @@ void CONTROL_ClearGameControllerDigitalAxisNeg(int32_t axis);
////////// KEY/MOUSE BIND STUFF //////////
#define CONTROL_GetUserInput(...)
#define CONTROL_ClearUserInput(...)
////////////////////
extern bool CONTROL_SmoothMouse;

View file

@ -54,7 +54,7 @@ int32_t I_TextSubmit(void)
return
inputState.GetKeyStatus(sc_Enter)
|| inputState.GetKeyStatus(sc_kpad_Enter)
//|| MOUSEINACTIVECONDITIONAL(inputState.MouseGetButtons()&LEFT_MOUSE)
|| gi->mouseInactiveConditional(inputState.MouseGetButtons()&LEFT_MOUSE)
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_A));
}
@ -102,7 +102,7 @@ int32_t I_GeneralTrigger(void)
I_AdvanceTrigger()
|| I_ReturnTrigger()
|| buttonMap.ButtonDown(gamefunc_Open)
//|| MOUSEINACTIVECONDITIONAL(buttonMap.ButtonDown(gamefunc_Fire))
|| gi->mouseInactiveConditional(buttonMap.ButtonDown(gamefunc_Fire))
|| buttonMap.ButtonDown(gamefunc_Crouch)
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_START));
}
@ -278,7 +278,7 @@ int32_t I_SliderLeft(void)
return
I_MenuLeft()
#if !defined EDUKE32_TOUCH_DEVICES
//|| MOUSEINACTIVECONDITIONAL((inputState.MouseGetButtons()&LEFT_MOUSE) && (inputState.MouseGetButtons()&WHEELUP_MOUSE))
|| gi->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
;
}

View file

@ -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

View file

@ -7756,6 +7756,7 @@ int GameInterface::app_main()
FX_StopAllSounds();
S_ClearSoundLocks();
app_loop();
return 0;
}
void app_loop()

View file

@ -7592,4 +7592,10 @@ void M_DisplayMenus(void)
CAMERADIST = 65536;
}
}
bool GameInterface::mouseInactiveConditional(bool condition)
{
return MOUSEINACTIVECONDITIONAL(condition);
}
END_RR_NS

View file

@ -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;
}

View file

@ -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;

View file

@ -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;
};

View file

@ -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, &currentmenu->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, &currentmenu->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);

View file

@ -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"
}