- more mouse fixes. Most of the menu is now mouse controllable again.

The exceptions are the text screens which do not react to the mouse and the confirmation screen which treats a mouse click as a cancel event.
This commit is contained in:
Christoph Oelckers 2019-12-06 00:06:41 +01:00
parent 3d10d006a7
commit a0fe7f4048
2 changed files with 14 additions and 2 deletions

View file

@ -1712,6 +1712,8 @@ int32_t handleevents_sdlcommon(SDL_Event *ev)
event_t evt;
evt.type = EV_GUI_Event;
evt.subtype = uint8_t((ev->button.state == SDL_PRESSED) ? EV_GUI_LButtonDown : EV_GUI_LButtonUp);
evt.data1 = ev->motion.x;
evt.data2 = ev->motion.y;
SDL_Keymod kmod = SDL_GetModState();
evt.data3 = ((kmod & KMOD_SHIFT) ? GKM_SHIFT : 0) |

View file

@ -63,6 +63,7 @@ extern bool rotatesprite_2doverride;
bool help_disabled, credits_disabled;
int g_currentMenu; // accessible by CON scripts - contains the current menu's script ID if defined or INT_MAX if none given.
int DrawBackground;
TArray<DMenu*> toDelete;
//
// Todo: Move these elsewhere
@ -227,7 +228,7 @@ void DMenu::Close ()
else
{
Destroy();
delete this;
toDelete.Push(this);
if (DMenu::CurrentMenu == NULL)
{
M_ClearMenus();
@ -620,7 +621,7 @@ bool M_SetMenu(FName menu, int param, FName caller)
//
//=============================================================================
bool M_Responder (event_t *ev)
bool M_DoResponder (event_t *ev)
{
int ch = 0;
bool keyup = false;
@ -803,6 +804,15 @@ bool M_Responder (event_t *ev)
return false;
}
bool M_Responder(event_t* ev)
{
// delayed deletion, so that self-deleting menus don't crash if they are getting accesses after being closed.
auto res = M_DoResponder(ev);
for (auto p : toDelete) delete p;
toDelete.Clear();
return res;
}
//=============================================================================
//
//