diff --git a/Aquaria/Avatar.cpp b/Aquaria/Avatar.cpp index 6a3990f..ea5856e 100644 --- a/Aquaria/Avatar.cpp +++ b/Aquaria/Avatar.cpp @@ -1426,7 +1426,7 @@ void Avatar::openSingingInterface() //core->setMousePosition(Vector(400,300)); } - core->setMouseConstraintCircle(singingInterfaceRadius); + core->setMouseConstraintCircle(core->center, singingInterfaceRadius); stopRoll(); singing = true; currentSongIdx = SONG_NONE; diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 7a86a10..44197f6 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -8060,6 +8060,18 @@ luaFunc(getMouseWheelChange) luaReturnNum(core->mouse.scrollWheelChange); } +luaFunc(setMouseConstraintCircle) +{ + core->setMouseConstraintCircle(Vector(lua_tonumber(L, 1), lua_tonumber(L, 2)), lua_tonumber(L, 3)); + luaReturnNil(); +} + +luaFunc(setMouseConstraint) +{ + core->setMouseConstraint(getBool(L, 1)); + luaReturnNil(); +} + luaFunc(fade) { dsq->overlay->color.interpolateTo(Vector(lua_tonumber(L, 3), lua_tonumber(L, 4), lua_tonumber(L, 5)), lua_tonumber(L, 6)); @@ -9114,6 +9126,8 @@ static const struct { luaRegister(getMousePos), luaRegister(getMouseWorldPos), luaRegister(getMouseWheelChange), + luaRegister(setMouseConstraintCircle), + luaRegister(setMouseConstraint), luaRegister(resetContinuity), diff --git a/BBGE/Core.cpp b/BBGE/Core.cpp index ac0f4dd..459ceb3 100644 --- a/BBGE/Core.cpp +++ b/BBGE/Core.cpp @@ -3296,10 +3296,12 @@ void Core::setMouseConstraint(bool on) mouseConstraint = on; } -void Core::setMouseConstraintCircle(float circle) +void Core::setMouseConstraintCircle(const Vector& pos, float circle) { mouseConstraint = true; mouseCircle = circle; + mouseConstraintCenter = pos; + mouseConstraintCenter.z = 0; } /* @@ -3333,7 +3335,7 @@ bool Core::doMouseConstraint() { //- core->getVirtualOffX() //- virtualOffX - Vector h = Vector(core->center.x , core->center.y); + Vector h = mouseConstraintCenter; Vector d = mouse.position - h; if (!d.isLength2DIn(mouseCircle)) { diff --git a/BBGE/Core.h b/BBGE/Core.h index da4e73e..55d2233 100644 --- a/BBGE/Core.h +++ b/BBGE/Core.h @@ -1037,7 +1037,7 @@ public: void removeRenderObject(RenderObject *r, RemoveRenderObjectFlag flag = DESTROY_RENDER_OBJECT); void setMouseConstraint(bool on); - void setMouseConstraintCircle(float mouseCircle); + void setMouseConstraintCircle(const Vector& pos, float mouseCircle); void setReentryInputGrab(int on); @@ -1350,6 +1350,7 @@ protected: std::string appName; bool mouseConstraint; float mouseCircle; + Vector mouseConstraintCenter; bool doMouseConstraint();