Skip to content

Commit

Permalink
flixel 5.9.0 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Geokureli committed Jul 10, 2024
1 parent d0afed7 commit 9849f37
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 8 additions & 0 deletions flixel/addons/ui/FlxUICursor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,11 @@ class FlxUICursor extends FlxUISprite
{
#if FLX_MOUSE
// REALLY force it to this location
#if (flixel < version("5.9.0"))
FlxG.mouse.setGlobalScreenPositionUnsafe(pt.x, pt.y);
#else
FlxG.mouse.setRawPositionUnsafe(pt.x, pt.y);
#end

if (_newMouse != null)
{
Expand Down Expand Up @@ -1084,7 +1088,11 @@ class FlxUICursor extends FlxUISprite
if (_newMouse != null)
{
_newMouse.updateGlobalScreenPosition = true; // resume low-level-mouse updating now that I'm done overriding it
#if (flixel < version("5.9.0"))
_newMouse.setGlobalScreenPositionUnsafe(Std.int(FlxG.game.mouseX), Std.int(FlxG.game.mouseY));
#else
_newMouse.setRawPositionUnsafe(Std.int(FlxG.game.mouseX), Std.int(FlxG.game.mouseY));
#end
}
#end
}
Expand Down
18 changes: 14 additions & 4 deletions flixel/addons/ui/FlxUIMouse.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,27 @@ class FlxUIMouse extends FlxMouse
* Called by the internal game loop to update the mouse pointer's position in the game world.
* Also updates the just pressed/just released flags.
*/
private override function update():Void
override function update():Void
{
var oldScreenX:Int = _globalScreenX;
var oldScreenY:Int = _globalScreenY;

#if (flixel < version("5.9.0"))
final oldScreenX = _globalScreenX;
final oldScreenY = _globalScreenY;
#else
final oldRawX = _rawX;
final oldRawY = _rawY;
#end

super.update();

if (!updateGlobalScreenPosition)
{
#if (flixel < version("5.9.0"))
_globalScreenX = oldScreenX;
_globalScreenY = oldScreenY;
updatePositions();
#else
setRawPositionUnsafe(oldRawX, oldRawY);
#end
}
}
}
Expand Down

0 comments on commit 9849f37

Please sign in to comment.