- fixed keybinding and mouse cursor display.

- fixed some merge issues in Shadow Warrior.
This commit is contained in:
Christoph Oelckers 2019-12-05 21:39:02 +01:00
parent 223c6d628e
commit db425a1228
8 changed files with 24 additions and 24 deletions

View file

@ -145,7 +145,7 @@ void joyScanDevices(void);
void mouseInit(void);
void mouseUninit(void);
void mouseGrabInput(bool grab);
void mouseLockToWindow(char a);
void mouseLockToWindow(bool a);
void mouseMoveToCenter(void);
void joyReadButtons(int32_t *pResult);

View file

@ -33,10 +33,14 @@
#include "i_time.h"
#include "c_dispatch.h"
#include "d_gui.h"
#include "menu.h"
#include "utf8.h"
#include "imgui.h"
#include "imgui_impl_sdl.h"
#include "imgui_impl_opengl3.h"
#ifndef NETCODE_DISABLE
#include "enet.h"
#endif
@ -960,18 +964,9 @@ void mouseGrabInput(bool grab)
g_mouseGrabbed = grab;
inputState.MouseSetPos(0, 0);
}
void mouseLockToWindow(char a)
{
if (!(a & 2))
{
mouseGrabInput(a);
g_mouseLockedToWindow = g_mouseGrabbed;
}
// Fixme
SDL_ShowCursor(GUICapture ? SDL_ENABLE : SDL_DISABLE);
SDL_ShowCursor(!grab ? SDL_ENABLE : SDL_DISABLE);
if (grab) GUICapture &= ~1;
else GUICapture |= 1;
}
//
@ -1891,7 +1886,7 @@ int32_t handleevents_pollsdl(void)
{
code = ev.text.text[j];
// Fixme: Send an EV_GUI_Event instead and properly deal with Unicode.
if (GUICapture & 1)
if ((GUICapture & 1) && menuactive != MENU_WaitKey)
{
event_t ev = { EV_GUI_Event, EV_GUI_Char, int16_t(j), !!(SDL_GetModState() & KMOD_ALT) };
D_PostEvent(&ev);
@ -1903,7 +1898,7 @@ int32_t handleevents_pollsdl(void)
case SDL_KEYDOWN:
case SDL_KEYUP:
{
if (GUICapture & 1)
if ((GUICapture & 1) && menuactive != MENU_WaitKey)
{
event_t event = {};
event.type = EV_GUI_Event;

View file

@ -55,6 +55,7 @@
#include "inputstate.h"
#include "i_time.h"
#include "gamecvars.h"
#include "baselayer.h"
#define LEFTMARGIN 8
@ -1317,13 +1318,14 @@ void C_ToggleConsole ()
HistPos = NULL;
TabbedLast = false;
TabbedList = false;
GUICapture |= 1;
mouseGrabInput(false);
}
else //if (gamestate != GS_FULLCONSOLE && gamestate != GS_STARTUP)
{
ConsoleState = c_rising;
C_FlushDisplay ();
GUICapture &= ~1;
mouseGrabInput(true);
}
}

View file

@ -51,6 +51,7 @@
#include "fx_man.h"
#include "pragmas.h"
#include "build.h"
#include "baselayer.h"
void RegisterDukeMenus();
void RegisterRedneckMenus();
@ -372,7 +373,7 @@ void M_StartControlPanel (bool makeSound)
}
C_HideConsole (); // [RH] Make sure console goes bye bye.
GUICapture |= 1;
mouseGrabInput(false);
menuactive = MENU_On;
// Pause sound effects before we play the menu switch sound.
// That way, it won't be paused.
@ -814,6 +815,7 @@ void M_Ticker (void)
if (DMenu::MenuTime & 3) return;
if (DMenu::CurrentMenu != NULL && menuactive != MENU_Off)
{
D_ProcessEvents(); // The main loop is blocked when the menu is open and cannot dispatch the events.
if (transition.previous) transition.previous->Ticker();
DMenu::CurrentMenu->Ticker();
@ -898,7 +900,7 @@ void M_ClearMenus ()
}
DMenu::CurrentMenu = nullptr;
menuactive = MENU_Off;
GUICapture &= ~1;
mouseGrabInput(true);
gi->MenuClosed();
}

View file

@ -370,6 +370,7 @@ public:
pKey = keyptr;
SetMenuMessage(1);
menuactive = MENU_WaitKey; // There should be a better way to disable GUI capture...
mouseGrabInput(true);
}
bool TranslateKeyboardEvents() override
@ -396,9 +397,11 @@ public:
{
*pKey = ev->data1;
menuactive = MENU_On;
mouseGrabInput(false);
SetMenuMessage(0);
auto p = mParentMenu;
Close();
mParentMenu->MenuEvent((ev->data1 == KEY_ESCAPE)? MKEY_Abort : MKEY_Input, 0);
p->MenuEvent((ev->data1 == KEY_ESCAPE)? MKEY_Abort : MKEY_Input, 0);
return true;
}
return false;

View file

@ -2591,7 +2591,7 @@ DrawCompass(PLAYERp pp)
start_ang = NORM_CANG(start_ang - 4);
flags = ROTATE_SPRITE_SCREEN_CLIP | ROTATE_SPRITE_CORNER;
if (RedrawCompass && !UsingMenus)
if (RedrawCompass && !M_Active())
{
RedrawCompass = FALSE;
SET(flags, ROTATE_SPRITE_ALL_PAGES);

View file

@ -104,7 +104,6 @@ typedef enum
ct_quitmenu, ct_ordermenu, ct_episodemenu, ct_max
} CTLType;
extern SWBOOL UsingMenus;
extern int SENSITIVITY;
extern CTLType ControlPanelType;
extern int16_t MenuTextShade;

View file

@ -7597,8 +7597,7 @@ pDisplaySprites(PLAYERp pp)
}
#if 1
extern SWBOOL UsingMenus;
if (TEST(psp->flags, PANF_KILL_AFTER_SHOW) && !TEST(psp->flags, PANF_NOT_ALL_PAGES) && !UsingMenus)
if (TEST(psp->flags, PANF_KILL_AFTER_SHOW) && !TEST(psp->flags, PANF_NOT_ALL_PAGES) && !M_Active())
{
psp->numpages = 0;
SET(flags, ROTATE_SPRITE_ALL_PAGES);