Input: Remove ugly [-20,-20] mouse position hack

This was supposed to disappear shortly after To the Moon's release,
but it unfortunately survived a bit longer :)

The status of the mouse cursor being inside / outside the game window
is now properly exposed (in MRI) via MKXP.mouse_in_window.
This commit is contained in:
Jonas Kulla 2017-04-08 18:41:56 +02:00 committed by Marty Plummer
parent 2f273bade8
commit d25551e266
2 changed files with 9 additions and 6 deletions

View File

@ -80,6 +80,7 @@ RB_METHOD(mriP);
RB_METHOD(mkxpDataDirectory);
RB_METHOD(mkxpPuts);
RB_METHOD(mkxpRawKeyStates);
RB_METHOD(mkxpMouseInWindow);
RB_METHOD(mriRgssMain);
RB_METHOD(mriRgssStop);
@ -144,6 +145,7 @@ static void mriBindingInit()
_rb_define_module_function(mod, "data_directory", mkxpDataDirectory);
_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_gv_set("MKXP", Qtrue);
}
@ -222,6 +224,13 @@ RB_METHOD(mkxpRawKeyStates)
return str;
}
RB_METHOD(mkxpMouseInWindow)
{
RB_UNUSED_PARAM;
return rb_bool_new(EventThread::mouseState.inWindow);
}
static VALUE rgssMainCb(VALUE block)
{
rb_funcall2(block, rb_intern("call"), 0, 0);

View File

@ -665,9 +665,6 @@ int Input::mouseX()
{
RGSSThreadData &rtData = shState->rtData();
if (!EventThread::mouseState.inWindow)
return -20;
return (EventThread::mouseState.x - rtData.screenOffset.x) * rtData.sizeResoRatio.x;
}
@ -675,9 +672,6 @@ int Input::mouseY()
{
RGSSThreadData &rtData = shState->rtData();
if (!EventThread::mouseState.inWindow)
return -20;
return (EventThread::mouseState.y - rtData.screenOffset.y) * rtData.sizeResoRatio.y;
}