Skip to content

Commit

Permalink
Flixel 5.9.0 compat (#277)
Browse files Browse the repository at this point in the history
* flixel 5.9.0 compat

* more upkeep

* fix more warnings
  • Loading branch information
Geokureli authored Jul 10, 2024
1 parent d0afed7 commit 6f141bc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
12 changes: 12 additions & 0 deletions flixel/addons/ui/FlxUICursor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,11 @@ class FlxUICursor extends FlxUISprite

// Ad hoc fix to avoid world coordinates on UI elements
if (scrollFactor.x == 0 && scrollFactor.y == 0)
#if (flixel < version("5.9.0"))
jumpToXY(FlxG.mouse.screenX, FlxG.mouse.screenY);
#else
jumpToXY(FlxG.mouse.viewX, FlxG.mouse.viewY);
#end
else
jumpToXY(FlxG.mouse.x, FlxG.mouse.y);
visible = oldVis;
Expand Down Expand Up @@ -962,7 +966,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 +1092,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
19 changes: 15 additions & 4 deletions flixel/addons/ui/FlxUIMouse.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,28 @@ 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;
#else
_rawX = oldRawX;
_rawY = oldRawY;
#end
updatePositions();
}
}
}
Expand Down

0 comments on commit 6f141bc

Please sign in to comment.