Skip to content

Commit

Permalink
Remove unused legacy code & defines (#3059)
Browse files Browse the repository at this point in the history
* Remove legacy code & defines
- Removed `FLX_POST_PROCESS` define &  related code
- Removed references to `openfl_next`, `lime_legacy` &  `next` defines
- Removed Lime & OpenFL version checks that are always true/false due to the current minimum versions

* Removed `legacy` define being set in include.xml

* Re-added `#if !flash` check in `initRenderMethod`

I mistakenly removed the entire code due to it including `lime_legacy`.

* Brought back `undump()` & `canBeDumped` as `refreshBitmap()` & `canBeRefreshed` respectively (old ones are now deprecated)
- Also brought back `onAssetsReload()` & `getBitmapFromSystem()`

* Added missing line breaks

* remove old import

* Remove another deprecated define

* Restored mistakenly-removed define check

* Rename `refreshBitmap()` to `refresh()`

---------

Co-authored-by: George FunBook <[email protected]>
  • Loading branch information
Starmapo and Geokureli authored Jan 30, 2025
1 parent 39e1fcf commit 27a756b
Show file tree
Hide file tree
Showing 18 changed files with 58 additions and 671 deletions.
1 change: 0 additions & 1 deletion checkstyle.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"FLX_NATIVE_CURSOR",
"FLX_SOUND_TRAY",
"FLX_POINTER_INPUT",
"FLX_POST_PROCESS",
"FLX_RECORD"
],
"defineCombinations": [
Expand Down
2 changes: 0 additions & 2 deletions flixel/FlxCamera.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1676,9 +1676,7 @@ class FlxCamera extends FlxBasic

final targetGraphics = (graphics == null) ? canvas.graphics : graphics;

#if (openfl > "8.7.0")
targetGraphics.overrideBlendMode(null);
#end
targetGraphics.beginFill(Color, FxAlpha);
// i'm drawing rect with these parameters to avoid light lines at the top and left of the camera,
// which could appear while cameras fading
Expand Down
83 changes: 1 addition & 82 deletions flixel/FlxG.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package flixel;

import flixel.effects.postprocess.PostProcess;
import flixel.math.FlxMath;
import flixel.math.FlxRandom;
import flixel.math.FlxRect;
Expand Down Expand Up @@ -50,12 +49,6 @@ import flixel.input.FlxAccelerometer;
#if FLX_POINTER_INPUT
import flixel.input.FlxSwipe;
#end
#if FLX_POST_PROCESS
import flixel.util.FlxDestroyUtil;
import openfl.display.OpenGLView;

using flixel.util.FlxArrayUtil;
#end

#if html5
import flixel.system.frontEnds.HTML5FrontEnd;
Expand Down Expand Up @@ -515,62 +508,6 @@ class FlxG
return child;
}

public static function addPostProcess(postProcess:PostProcess):PostProcess
{
#if FLX_POST_PROCESS
if (OpenGLView.isSupported)
{
var postProcesses = game.postProcesses;

// chaining
var length = postProcesses.length;
if (length > 0)
{
postProcesses[length - 1].to = postProcess;
}

game.postProcessLayer.addChild(postProcess);
postProcesses.push(postProcess);
}
else
{
FlxG.log.error("Shaders are not supported on this platform.");
}
#end

return postProcess;
}

public static function removePostProcess(postProcess:PostProcess):Void
{
#if FLX_POST_PROCESS
var postProcesses = game.postProcesses;
if (postProcesses.remove(postProcess))
{
chainPostProcesses();
postProcess.to = null;

FlxDestroyUtil.removeChild(game.postProcessLayer, postProcess);
}
#end
}

#if FLX_POST_PROCESS
static function chainPostProcesses():Void
{
var postProcesses = game.postProcesses;

if (postProcesses.length > 0)
{
for (i in 0...postProcesses.length - 1)
{
postProcesses[i].to = postProcesses[i + 1];
}
postProcesses.last().to = null;
}
}
#end

/**
* Opens a web page, by default a new tab or window. If the URL does not
* already start with `"http://"` or `"https://"`, it gets added automatically.
Expand Down Expand Up @@ -647,31 +584,13 @@ class FlxG

static function initRenderMethod():Void
{
renderMethod = BLITTING;

#if (!lime_legacy && !flash)
#if (lime >= "7.0.0")
#if !flash
renderMethod = switch (stage.window.context.type)
{
case OPENGL, OPENGLES, WEBGL: DRAW_TILES;
default: BLITTING;
}
#else
if (!Lib.application.config.windows[0].hardware)
{
renderMethod = BLITTING;
}
else
{
renderMethod = switch (stage.window.renderer.type)
{
case OPENGL, CONSOLE: DRAW_TILES;
case CANVAS, FLASH, CAIRO: BLITTING;
default: BLITTING;
}
}
#end
#else
#if web
renderMethod = BLITTING;
#else
Expand Down
68 changes: 1 addition & 67 deletions flixel/FlxGame.hx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ import openfl.filters.BitmapFilter;
#if desktop
import openfl.events.FocusEvent;
#end
#if FLX_POST_PROCESS
import flixel.effects.postprocess.PostProcess;
import openfl.display.OpenGLView;
#end
#if FLX_DEBUG
import flixel.system.debug.FlxDebugger;
#end
Expand Down Expand Up @@ -149,14 +145,6 @@ class FlxGame extends Sprite
*/
var _filters:Array<BitmapFilter>;

#if (desktop && lime_legacy)
/**
* Ugly workaround to ensure consistent behaviour between flash and cpp
* (the focus event should not fire when the game starts up!)
*/
var _onFocusFiredOnce:Bool = false;
#end

#if FLX_FOCUS_LOST_SCREEN
/**
* The "focus lost" screen.
Expand Down Expand Up @@ -230,18 +218,6 @@ class FlxGame extends Sprite
var _recordingRequested:Bool = false;
#end

#if FLX_POST_PROCESS
/**
* `Sprite` for postprocessing effects
*/
var postProcessLayer:Sprite = new Sprite();

/**
* Post process effects active on the `postProcessLayer`.
*/
var postProcesses:Array<PostProcess> = [];
#end

/**
* Instantiate a new game object.
*
Expand Down Expand Up @@ -330,11 +306,6 @@ class FlxGame extends Sprite

addChild(_inputContainer);

#if FLX_POST_PROCESS
if (OpenGLView.isSupported)
addChild(postProcessLayer);
#end

// Creating the debugger overlay
#if FLX_DEBUG
debugger = new FlxDebugger(FlxG.stage.stageWidth, FlxG.stage.stageHeight);
Expand All @@ -356,10 +327,7 @@ class FlxGame extends Sprite
#end

// Focus gained/lost monitoring
#if (desktop && openfl <= "4.0.0")
stage.addEventListener(FocusEvent.FOCUS_OUT, onFocusLost);
stage.addEventListener(FocusEvent.FOCUS_IN, onFocus);
#elseif (sys && openfl >= "9.3.0")
#if (sys && openfl >= "9.3.0")
stage.nativeWindow.addEventListener(Event.DEACTIVATE, onFocusLost);
stage.nativeWindow.addEventListener(Event.ACTIVATE, onFocus);
#else
Expand Down Expand Up @@ -394,15 +362,6 @@ class FlxGame extends Sprite
return; // Don't run this function twice (bug in standalone flash player)
#end

#if (desktop && lime_legacy)
// make sure the on focus event doesn't fire on startup
if (!_onFocusFiredOnce)
{
_onFocusFiredOnce = true;
return;
}
#end

#if mobile
// just check if device orientation has been changed
onResize(_);
Expand Down Expand Up @@ -433,11 +392,6 @@ class FlxGame extends Sprite

function onFocusLost(event:Event):Void
{
#if next
if (event != null && event.target != FlxG.stage)
return;
#end

#if flash
if (_lostFocus)
return; // Don't run this function twice (bug in standalone flash player)
Expand Down Expand Up @@ -472,11 +426,6 @@ class FlxGame extends Sprite
var width:Int = FlxG.stage.stageWidth;
var height:Int = FlxG.stage.stageHeight;

#if !flash
if (FlxG.renderTile)
FlxG.bitmap.onContext();
#end

resizeGame(width, height);
}

Expand All @@ -502,11 +451,6 @@ class FlxGame extends Sprite
if (soundTray != null)
soundTray.screenCenter();
#end

#if FLX_POST_PROCESS
for (postProcess in postProcesses)
postProcess.rebuild();
#end
}

/**
Expand Down Expand Up @@ -741,11 +685,6 @@ class FlxGame extends Sprite

updateInput();

#if FLX_POST_PROCESS
if (postProcesses[0] != null)
postProcesses[0].update(FlxG.elapsed);
#end

#if FLX_SOUND_SYSTEM
FlxG.sound.update(FlxG.elapsed);
#end
Expand Down Expand Up @@ -867,11 +806,6 @@ class FlxGame extends Sprite
if (FlxG.renderTile)
FlxDrawBaseItem.drawCalls = 0;

#if FLX_POST_PROCESS
if (postProcesses[0] != null)
postProcesses[0].capture();
#end

FlxG.cameras.lock();

if (FlxG.plugins.drawOnTop)
Expand Down
Loading

0 comments on commit 27a756b

Please sign in to comment.