Add MKXP.show_settings

This commit is contained in:
Inori 2019-09-17 01:42:50 -04:00 committed by Inori
parent e0236dff6f
commit 4e7e7b740a
4 changed files with 33 additions and 0 deletions

View file

@ -145,6 +145,7 @@ To smooth over cross-platform compatibility, functionality that you won't find i
* `user_language` returns the user's current locale (e.g. `en_US`).
* `game_title` returns the game's title as set in its ini.
* `power_state` returns a hash with the system power state information. Its members are `:discharging` (Boolean), `:percent` (int/nil), and `:seconds` (int/nil)
* `show_settings` displays the keybinding menu.
### Discord

View file

@ -106,6 +106,7 @@ RB_METHOD(mkxpPlatform);
RB_METHOD(mkxpUserLanguage);
RB_METHOD(mkxpGameTitle);
RB_METHOD(mkxpPowerState);
RB_METHOD(mkxpSettingsMenu);
RB_METHOD(mriRgssMain);
RB_METHOD(mriRgssStop);
@ -177,6 +178,7 @@ static void mriBindingInit()
VALUE mod = rb_define_module("MKXP");
_rb_define_module_function(mod, "data_directory", mkxpDataDirectory);
_rb_define_module_function(mod, "set_window_title", mkxpSetTitle);
_rb_define_module_function(mod, "show_settings", mkxpSettingsMenu);
_rb_define_module_function(mod, "puts", mkxpPuts);
_rb_define_module_function(mod, "raw_key_states", mkxpRawKeyStates);
_rb_define_module_function(mod, "mouse_in_window", mkxpMouseInWindow);
@ -333,6 +335,15 @@ RB_METHOD(mkxpPowerState)
return hash;
}
RB_METHOD(mkxpSettingsMenu)
{
RB_UNUSED_PARAM;
shState->eThread().requestSettingsMenu();
return Qnil;
}
static VALUE rgssMainCb(VALUE block)
{
rb_funcall2(block, rb_intern("call"), 0, 0);

View file

@ -89,6 +89,8 @@ enum
REQUEST_SETCURSORVISIBLE,
REQUEST_TEXTMODE,
REQUEST_SETTINGS,
UPDATE_FPS,
UPDATE_SCREEN_RECT,
@ -469,6 +471,16 @@ void EventThread::process(RGSSThreadData &rtData)
showCursor = event.user.code;
updateCursorState(cursorInWindow, gameScreen);
break;
case REQUEST_SETTINGS :
if (!sMenu)
{
sMenu = new SettingsMenu(rtData);
updateCursorState(false, gameScreen);
}
sMenu->raise();
break;
case UPDATE_FPS :
if (rtData.config.printFPS)
@ -674,6 +686,13 @@ void EventThread::requestTextInputMode(bool mode)
SDL_PushEvent(&event);
}
void EventThread::requestSettingsMenu()
{
SDL_Event event;
event.type = usrIdStart + REQUEST_SETTINGS;
SDL_PushEvent(&event);
}
void EventThread::showMessageBox(const char *body, int flags)
{
msgBoxDone.clear();

View file

@ -94,6 +94,8 @@ public:
void requestShowCursor(bool mode);
void requestTextInputMode(bool mode);
void requestSettingsMenu();
void requestTerminate();