Skip to content

Commit

Permalink
Merge pull request elizagamedev#27 from rkevin-arch/add-force-quit
Browse files Browse the repository at this point in the history
Add force quit feature
  • Loading branch information
Speak2Erase authored Mar 21, 2021
2 parents 7bb1b19 + 24baf2d commit 62650b6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions binding-mri/binding-mri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ RB_METHOD(mkxpDataDirectory);
RB_METHOD(mkxpPuts);
RB_METHOD(mkxpRawKeyStates);
RB_METHOD(mkxpMouseInWindow);
RB_METHOD(mkxpAllowForceQuit);

RB_METHOD(mriRgssMain);
RB_METHOD(mriRgssStop);
Expand Down Expand Up @@ -150,6 +151,7 @@ static void mriBindingInit()
_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);
_rb_define_module_function(mod, "allow_force_quit", mkxpAllowForceQuit);

/* Load global constants */
rb_gv_set("MKXP", Qtrue);
Expand Down Expand Up @@ -256,6 +258,12 @@ RB_METHOD(mkxpMouseInWindow)
return rb_bool_new(EventThread::mouseState.inWindow);
}

RB_METHOD(mkxpAllowForceQuit) {
RB_UNUSED_PARAM;
shState->rtData().allowForceQuit.set();
return Qnil;
}

static VALUE rgssMainCb(VALUE block)
{
rb_funcall2(block, rb_intern("call"), 0, 0);
Expand Down
6 changes: 6 additions & 0 deletions src/eventthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@ void EventThread::process(RGSSThreadData &rtData)
break;
}

if (event.key.keysym.scancode == SDL_SCANCODE_F3 && rtData.allowForceQuit) {
// ModShot addition: force quit the game, no prompting or saving
terminate = true;
break;
}

if (event.key.keysym.scancode == SDL_SCANCODE_F12)
{
if (!rtData.config.debugMode)
Expand Down
3 changes: 3 additions & 0 deletions src/eventthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ struct RGSSThreadData
/* True if accepting text input */
AtomicFlag acceptingTextInput;

/* True if allow force quit */
AtomicFlag allowForceQuit;

EventThread *ethread;
UnidirMessage<Vec2i> windowSizeMsg;
UnidirMessage<BDescVec> bindingUpdateMsg;
Expand Down

0 comments on commit 62650b6

Please sign in to comment.