Introduce F1 menu to reconfigure key bindings at runtime
This commit is contained in:
parent
af145c3a01
commit
dd73db2e9d
17 changed files with 1837 additions and 136 deletions
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "sharedstate.h"
|
||||
#include "graphics.h"
|
||||
#include "settingsmenu.h"
|
||||
#include "debugwriter.h"
|
||||
|
||||
#include <string.h>
|
||||
|
@ -37,7 +38,7 @@ bool EventThread::keyStates[] = { false };
|
|||
|
||||
EventThread::JoyState EventThread::joyState =
|
||||
{
|
||||
0, 0, { false }
|
||||
{ 0 }, { false }
|
||||
};
|
||||
|
||||
EventThread::MouseState EventThread::mouseState =
|
||||
|
@ -108,6 +109,8 @@ void EventThread::process(RGSSThreadData &rtData)
|
|||
|
||||
bool resetting = false;
|
||||
|
||||
SettingsMenu *sMenu = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (!SDL_WaitEvent(&event))
|
||||
|
@ -116,6 +119,19 @@ void EventThread::process(RGSSThreadData &rtData)
|
|||
break;
|
||||
}
|
||||
|
||||
if (sMenu && sMenu->onEvent(event))
|
||||
{
|
||||
if (sMenu->destroyReq())
|
||||
{
|
||||
delete sMenu;
|
||||
sMenu = 0;
|
||||
|
||||
updateCursorState(cursorInWindow && windowFocused);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_WINDOWEVENT :
|
||||
|
@ -129,14 +145,14 @@ void EventThread::process(RGSSThreadData &rtData)
|
|||
case SDL_WINDOWEVENT_ENTER :
|
||||
cursorInWindow = true;
|
||||
mouseState.inWindow = true;
|
||||
updateCursorState(cursorInWindow && windowFocused);
|
||||
updateCursorState(cursorInWindow && windowFocused && !sMenu);
|
||||
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_LEAVE :
|
||||
cursorInWindow = false;
|
||||
mouseState.inWindow = false;
|
||||
updateCursorState(cursorInWindow && windowFocused);
|
||||
updateCursorState(cursorInWindow && windowFocused && !sMenu);
|
||||
|
||||
break;
|
||||
|
||||
|
@ -147,13 +163,13 @@ void EventThread::process(RGSSThreadData &rtData)
|
|||
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED :
|
||||
windowFocused = true;
|
||||
updateCursorState(cursorInWindow && windowFocused);
|
||||
updateCursorState(cursorInWindow && windowFocused && !sMenu);
|
||||
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST :
|
||||
windowFocused = false;
|
||||
updateCursorState(cursorInWindow && windowFocused);
|
||||
updateCursorState(cursorInWindow && windowFocused && !sMenu);
|
||||
resetInputStates();
|
||||
|
||||
break;
|
||||
|
@ -181,6 +197,17 @@ void EventThread::process(RGSSThreadData &rtData)
|
|||
break;
|
||||
}
|
||||
|
||||
if (event.key.keysym.scancode == SDL_SCANCODE_F1)
|
||||
{
|
||||
if (!sMenu)
|
||||
{
|
||||
sMenu = new SettingsMenu(rtData);
|
||||
updateCursorState(false);
|
||||
}
|
||||
|
||||
sMenu->raise();
|
||||
}
|
||||
|
||||
if (event.key.keysym.scancode == SDL_SCANCODE_F2)
|
||||
{
|
||||
if (!fps.displaying)
|
||||
|
@ -248,11 +275,7 @@ void EventThread::process(RGSSThreadData &rtData)
|
|||
break;
|
||||
|
||||
case SDL_JOYAXISMOTION :
|
||||
if (event.jaxis.axis == 0)
|
||||
joyState.xAxis = event.jaxis.value;
|
||||
else
|
||||
joyState.yAxis = event.jaxis.value;
|
||||
|
||||
joyState.axis[event.jaxis.axis] = event.jaxis.value;
|
||||
break;
|
||||
|
||||
case SDL_JOYDEVICEADDED :
|
||||
|
@ -333,6 +356,8 @@ void EventThread::process(RGSSThreadData &rtData)
|
|||
|
||||
if (SDL_JoystickGetAttached(js))
|
||||
SDL_JoystickClose(js);
|
||||
|
||||
delete sMenu;
|
||||
}
|
||||
|
||||
void EventThread::cleanup()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue