- Duke: fixed long standing problem that pressing Escape or walking backwards does not switch off the camera view.

This commit is contained in:
Christoph Oelckers 2022-11-19 18:26:17 +01:00
parent dee33ba4dd
commit c6b3cf3e0a
10 changed files with 43 additions and 24 deletions

View file

@ -72,6 +72,12 @@ public:
return Buttons[x].bWentUp;
}
void ButtonSet(int x) const
{
Buttons[x].bDown = Buttons[x].bWentDown = true;
Buttons[x].bWentUp = false;
}
void ClearButton(int x)
{
Buttons[x].Reset();

View file

@ -44,8 +44,6 @@
#include "gamestate.h"
#include "i_interface.h"
bool G_Responder(event_t* ev);
int eventhead;
int eventtail;
event_t events[MAXEVENTS];
@ -86,12 +84,16 @@ void D_ProcessEvents (void)
if (ev->type == EV_DeviceChange)
UpdateJoystickMenu(I_UpdateDeviceList());
if (gamestate != GS_INTRO) // GS_INTRO blocks the UI.
// allow the game to intercept Escape before dispatching it.
if (ev->type != EV_KeyDown || ev->data1 != KEY_ESCAPE || !sysCallbacks.WantEscape())
{
if (C_Responder(ev))
continue; // console ate the event
if (M_Responder(ev))
continue; // menu ate the event
if (gamestate != GS_INTRO) // GS_INTRO blocks the UI.
{
if (C_Responder(ev))
continue; // console ate the event
if (M_Responder(ev))
continue; // menu ate the event
}
}
if (sysCallbacks.G_Responder(ev) && ev->type == EV_KeyDown) keywasdown.Set(ev->data1);

View file

@ -46,6 +46,7 @@ struct SystemCallbacks
void (*LanguageChanged)(const char*);
bool (*OkForLocalization)(FTextureID, const char*);
FConfigFile* (*GetConfig)();
bool (*WantEscape)();
};
extern SystemCallbacks sysCallbacks;

View file

@ -69,6 +69,12 @@ bool G_Responder (event_t *ev)
switch (ev->type)
{
case EV_KeyDown:
if (ev->data1 == KEY_ESCAPE && gi->WantEscape())
{
// special case: This is hardcoded to the 'Escape' button. Only used by Duke's cameras.
ActionsToSend |= SB_ESCAPE;
return true;
}
if (C_DoKey (ev, &Bindings, &DoubleBindings))
return true;
break;

View file

@ -543,6 +543,11 @@ static void System_SetTransition(int type)
nextwipe = type;
}
bool WantEscape()
{
return gi->WantEscape();
}
void I_StartupJoysticks();
@ -591,7 +596,8 @@ int GameMain()
OnMenuOpen,
nullptr,
nullptr,
[]() ->FConfigFile* { return GameConfig; }
[]() ->FConfigFile* { return GameConfig; },
WantEscape,
};
try

View file

@ -126,6 +126,7 @@ struct GameInterface
virtual bool IsQAVInterpTypeValid(const FString& type) { return false; }
virtual void AddQAVInterpProps(const int res_id, const FString& interptype, const bool loopable, const TMap<int, TArray<int>>&& ignoredata) { }
virtual void RemoveQAVInterpProps(const int res_id) { }
virtual bool WantEscape() { return false; }
virtual FString statFPS()
{

View file

@ -351,11 +351,6 @@ CCMD(holsterweapon)
ActionsToSend |= SB_HOLSTER;
}
CCMD(backoff)
{
ActionsToSend |= SB_ESCAPE;
}
CCMD(pause)
{
sendPause = true;
@ -487,5 +482,6 @@ void ApplyGlobalInput(InputPacket& input, ControlInfo* hidInput, bool const crou
if (buttonMap.ButtonDown(gamefunc_Look_Right))
input.actions |= SB_LOOK_RIGHT;
}

View file

@ -158,6 +158,11 @@ void GameInterface::ToggleShowWeapon()
FTA(QUOTE_WEAPON_MODE_OFF - cl_showweapon, &ps[screenpeek]);
}
bool GameInterface::WantEscape()
{
return ps[myconnectindex].newOwner != nullptr;
}
int registerosdcommands(void)
{

View file

@ -62,6 +62,7 @@ struct GameInterface : public ::GameInterface
bool GetGeoEffect(GeoEffect* eff, sectortype* viewsector) override;
void AddExcludedEpisode(const FString& episode) override;
int GetCurrentSkill() override;
bool WantEscape() override;
};

View file

@ -1508,7 +1508,12 @@ void checksectors_d(int snum)
if (p->newOwner != nullptr)
{
if (abs(PlayerInputSideVel(snum)) > 1.5 || abs(PlayerInputForwardVel(snum)) > 1.5)
if (abs(PlayerInputSideVel(snum)) > 0.75 || abs(PlayerInputForwardVel(snum)) > 0.75)
{
clearcameras(p);
return;
}
else if (PlayerInput(snum, SB_ESCAPE))
{
clearcameras(p);
return;
@ -1520,16 +1525,6 @@ void checksectors_d(int snum)
else if (!p->toggle_key_flag)
{
if (PlayerInput(snum, SB_ESCAPE))
{
if (p->newOwner != nullptr)
{
clearcameras(p);
}
return;
}
near.hitActor = nullptr;
p->toggle_key_flag = 1;
hitscanwall = nullptr;