From d25551e2666397dfb9321bef064d5c0f96198622 Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Sat, 8 Apr 2017 18:41:56 +0200 Subject: [PATCH] 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. --- binding-mri/binding-mri.cpp | 9 +++++++++ src/input.cpp | 6 ------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index c28cdaa..f0a4bb4 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -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); diff --git a/src/input.cpp b/src/input.cpp index d7978bd..22dab5d 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -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; }