diff --git a/checkstyle.json b/checkstyle.json index b603612dab..545ea16945 100644 --- a/checkstyle.json +++ b/checkstyle.json @@ -5,7 +5,6 @@ "FLX_NATIVE_CURSOR", "FLX_SOUND_TRAY", "FLX_POINTER_INPUT", - "FLX_POST_PROCESS", "FLX_RECORD" ], "defineCombinations": [ diff --git a/flixel/FlxG.hx b/flixel/FlxG.hx index df6734d83d..59231b9773 100644 --- a/flixel/FlxG.hx +++ b/flixel/FlxG.hx @@ -1,11 +1,5 @@ package flixel; -import openfl.Lib; -import openfl.display.DisplayObject; -import openfl.display.Stage; -import openfl.display.StageDisplayState; -import openfl.net.URLRequest; -import flixel.effects.postprocess.PostProcess; import flixel.math.FlxMath; import flixel.math.FlxRandom; import flixel.math.FlxRect; @@ -28,6 +22,11 @@ import flixel.system.scaleModes.RatioScaleMode; import flixel.util.FlxCollision; import flixel.util.FlxSave; import flixel.util.typeLimit.NextState; +import openfl.Lib; +import openfl.display.DisplayObject; +import openfl.display.Stage; +import openfl.display.StageDisplayState; +import openfl.net.URLRequest; #if FLX_TOUCH import flixel.input.touch.FlxTouchManager; #end @@ -49,12 +48,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; @@ -508,62 +501,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. @@ -640,31 +577,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 diff --git a/flixel/FlxGame.hx b/flixel/FlxGame.hx index 0e67d637f4..5e371e913e 100644 --- a/flixel/FlxGame.hx +++ b/flixel/FlxGame.hx @@ -14,10 +14,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 @@ -148,14 +144,6 @@ class FlxGame extends Sprite */ var _filters:Array; - #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. @@ -229,18 +217,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 = []; - #end - /** * Instantiate a new game object. * @@ -329,11 +305,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); @@ -355,13 +326,8 @@ 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); - #else stage.addEventListener(Event.DEACTIVATE, onFocusLost); stage.addEventListener(Event.ACTIVATE, onFocus); - #end // Instantiate the initial state resetGame(); @@ -390,15 +356,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(_); @@ -429,11 +386,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) @@ -468,11 +420,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); } @@ -498,11 +445,6 @@ class FlxGame extends Sprite if (soundTray != null) soundTray.screenCenter(); #end - - #if FLX_POST_PROCESS - for (postProcess in postProcesses) - postProcess.rebuild(); - #end } /** @@ -737,11 +679,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 @@ -857,11 +794,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) diff --git a/flixel/effects/postprocess/PostProcess.hx b/flixel/effects/postprocess/PostProcess.hx deleted file mode 100644 index cfff5800da..0000000000 --- a/flixel/effects/postprocess/PostProcess.hx +++ /dev/null @@ -1,260 +0,0 @@ -package flixel.effects.postprocess; - -import openfl.geom.Rectangle; -#if FLX_POST_PROCESS -import flixel.FlxG; -import openfl.Assets; -import openfl.display.OpenGLView; -import openfl.gl.GL; -import openfl.gl.GLFramebuffer; -import openfl.gl.GLRenderbuffer; -import openfl.gl.GLTexture; -import openfl.gl.GLBuffer; -import openfl.utils.Float32Array; - -private class Uniform -{ - public var id:Int; - public var value:Float; - - public function new(id, value) - { - this.id = id; - this.value = value; - } -} - -/** - * Fullscreen post processing class. - * Uses GLSL shaders to produce post processing effects. - */ -class PostProcess extends OpenGLView -{ - var screenWidth:Int; - var screenHeight:Int; - - /** - * Create a new PostProcess object - * - * @param fragmentShader A GLSL file in your assets path - */ - public function new(fragmentShader:String) - { - super(); - uniforms = new Map(); - - // create and bind the framebuffer - framebuffer = GL.createFramebuffer(); - rebuild(); - #if (ios || tvos) - defaultFramebuffer = new GLFramebuffer(GL.version, 1); // faked framebuffer - #else - var status = GL.checkFramebufferStatus(GL.FRAMEBUFFER); - - switch (status) - { - case GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT: - trace("FRAMEBUFFER_INCOMPLETE_ATTACHMENT"); - case GL.FRAMEBUFFER_UNSUPPORTED: - trace("GL_FRAMEBUFFER_UNSUPPORTED"); - case GL.FRAMEBUFFER_COMPLETE: - default: - trace("Check frame buffer: " + status); - } - #end - - buffer = GL.createBuffer(); - GL.bindBuffer(GL.ARRAY_BUFFER, buffer); - GL.bufferData(GL.ARRAY_BUFFER, new Float32Array(#if !openfl_next cast #end vertices), GL.STATIC_DRAW); - GL.bindBuffer(GL.ARRAY_BUFFER, null); - - postProcessShader = new Shader([ - {src: VERTEX_SHADER, fragment: false}, - {src: Assets.getText(fragmentShader), fragment: true} - ]); - - // default shader variables - imageUniform = postProcessShader.uniform("uImage0"); - timeUniform = postProcessShader.uniform("uTime"); - resolutionUniform = postProcessShader.uniform("uResolution"); - - vertexSlot = postProcessShader.attribute("aVertex"); - texCoordSlot = postProcessShader.attribute("aTexCoord"); - } - - /** - * Set a uniform value in the shader - * - * @param uniform The uniform name within the shader source - * @param value Value to set the uniform to - */ - public function setUniform(uniform:String, value:Float):Void - { - if (uniforms.exists(uniform)) - { - var uniform = uniforms.get(uniform); - uniform.value = value; - } - else - { - var id:Int = postProcessShader.uniform(uniform); - if (id != -1) - { - uniforms.set(uniform, new Uniform(id, value)); - } - else - { - throw 'Uniform with name "$uniform" could not be found.'; - } - } - } - - /** - * Allows multi pass rendering by passing the framebuffer to another post processing class. - * Renders to a `PostProcess` framebuffer instead of the screen, if set. - * Set to `null` to render to the screen. - */ - public var to(never, set):PostProcess; - - function set_to(value:PostProcess):PostProcess - { - renderTo = (value == null ? defaultFramebuffer : value.framebuffer); - return value; - } - - /** - * Rebuilds the renderbuffer to match screen dimensions. - */ - public function rebuild() - { - GL.bindFramebuffer(GL.FRAMEBUFFER, framebuffer); - - if (texture != null) - GL.deleteTexture(texture); - if (renderbuffer != null) - GL.deleteRenderbuffer(renderbuffer); - - this.screenWidth = FlxG.stage.stageWidth; - this.screenHeight = FlxG.stage.stageHeight; - createTexture(screenWidth, screenHeight); - createRenderbuffer(screenWidth, screenHeight); - - GL.bindFramebuffer(GL.FRAMEBUFFER, null); - } - - inline function createRenderbuffer(width:Int, height:Int) - { - // Bind the renderbuffer and create a depth buffer - renderbuffer = GL.createRenderbuffer(); - - GL.bindRenderbuffer(GL.RENDERBUFFER, renderbuffer); - GL.renderbufferStorage(GL.RENDERBUFFER, GL.DEPTH_COMPONENT16, width, height); - - // Specify renderbuffer as depth attachment - GL.framebufferRenderbuffer(GL.FRAMEBUFFER, GL.DEPTH_ATTACHMENT, GL.RENDERBUFFER, renderbuffer); - } - - inline function createTexture(width:Int, height:Int) - { - texture = GL.createTexture(); - - GL.bindTexture(GL.TEXTURE_2D, texture); - GL.texImage2D(GL.TEXTURE_2D, 0, GL.RGB, width, height, 0, GL.RGB, GL.UNSIGNED_BYTE, null); - - GL.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_WRAP_S, GL.CLAMP_TO_EDGE); - GL.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_WRAP_T, GL.CLAMP_TO_EDGE); - GL.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, GL.LINEAR); - GL.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MAG_FILTER, GL.LINEAR); - - // specify texture as color attachment - GL.framebufferTexture2D(GL.FRAMEBUFFER, GL.COLOR_ATTACHMENT0, GL.TEXTURE_2D, texture, 0); - } - - /** - * Capture what is subsequently rendered to this framebuffer. - */ - public function capture() - { - GL.bindFramebuffer(GL.FRAMEBUFFER, framebuffer); - GL.clear(GL.DEPTH_BUFFER_BIT | GL.COLOR_BUFFER_BIT); - } - - public function update(elapsed:Float) - { - time += elapsed; - } - - var framebuffer:GLFramebuffer; - var renderbuffer:GLRenderbuffer; - var texture:GLTexture; - - var postProcessShader:Shader; - var buffer:GLBuffer; - var renderTo:GLFramebuffer; - var defaultFramebuffer:GLFramebuffer = null; - - /* @Time accumulator passed to the shader */ - var time:Float = 0; - - var vertexSlot:Int; - var texCoordSlot:Int; - var imageUniform:Int; - var resolutionUniform:Int; - var timeUniform:Int; - var uniforms:Map; - - /* @Simple full screen vertex shader */ - static inline var VERTEX_SHADER:String = " -#ifdef GL_ES - precision mediump float; -#endif - -attribute vec2 aVertex; -attribute vec2 aTexCoord; -varying vec2 vTexCoord; - -void main() { - vTexCoord = aTexCoord; - gl_Position = vec4(aVertex, 0.0, 1.0); -}"; - - static var vertices(get, never):Array; - - static inline function get_vertices():Array - { - return [ - -1.0, -1.0, 0, 0, - 1.0, -1.0, 1, 0, - -1.0, 1.0, 0, 1, - 1.0, -1.0, 1, 0, - 1.0, 1.0, 1, 1, - -1.0, 1.0, 0, 1 - ]; - } -} -#else -class PostProcess -{ - public function new(shader:String) - { - FlxG.log.error("Post processing is only supported on the CPP and Neko targets of OpenFL legacy - for newer OpenFL versions, please use shader filters."); - } - - public function enable(?to:PostProcess) {} - - public function capture() {} - - public function rebuild() {} - - public function update(elapsed:Float) {} - - public function render(rect:Rectangle) {} - - public function setUniform(uniform:String, value:Float) {} - - public var to(never, set):PostProcess; - - public function set_to(value:PostProcess):PostProcess - return null; -} -#end diff --git a/flixel/effects/postprocess/Shader.hx b/flixel/effects/postprocess/Shader.hx deleted file mode 100644 index 304cde955a..0000000000 --- a/flixel/effects/postprocess/Shader.hx +++ /dev/null @@ -1,99 +0,0 @@ -package flixel.effects.postprocess; - -#if FLX_POST_PROCESS -import openfl.gl.GL; -import openfl.gl.GLProgram; -import openfl.gl.GLShader; - -/** - * GLSL Shader object - */ -class Shader -{ - var program:GLProgram; - - /** - * Creates a new Shader - * - * @param sources A list of GLSL shader sources to compile and link into a program - */ - public function new(sources:Array) - { - program = GL.createProgram(); - - for (source in sources) - { - var shader = compile(source.src, source.fragment ? GL.FRAGMENT_SHADER : GL.VERTEX_SHADER); - if (shader == null) - return; - GL.attachShader(program, shader); - GL.deleteShader(shader); - } - - GL.linkProgram(program); - - if (GL.getProgramParameter(program, GL.LINK_STATUS) == 0) - { - trace(GL.getProgramInfoLog(program)); - trace("VALIDATE_STATUS: " + GL.getProgramParameter(program, GL.VALIDATE_STATUS)); - trace("ERROR: " + GL.getError()); - return; - } - } - - /** - * Compiles the shader source into a GlShader object and prints any errors - * - * @param source The shader source code - * @param type The type of shader to compile (fragment, vertex) - */ - function compile(source:String, type:Int):GLShader - { - var shader = GL.createShader(type); - GL.shaderSource(shader, source); - GL.compileShader(shader); - - if (GL.getShaderParameter(shader, GL.COMPILE_STATUS) == 0) - { - trace(GL.getShaderInfoLog(shader)); - return null; - } - - return shader; - } - - /** - * Return the attribute location in this shader - * - * @param a The attribute name to find - */ - public inline function attribute(a:String):Int - { - return GL.getAttribLocation(program, a); - } - - /** - * Return the uniform location in this shader - * - * @param a The uniform name to find - */ - public inline function uniform(u:String):Int - { - return GL.getUniformLocation(program, u); - } - - /** - * Bind the program for rendering - */ - public inline function bind() - { - GL.useProgram(program); - } -} - -typedef ShaderSource = -{ - var src:String; - var fragment:Bool; -} -#end diff --git a/flixel/graphics/FlxGraphic.hx b/flixel/graphics/FlxGraphic.hx index b3140b93e2..850bad147d 100644 --- a/flixel/graphics/FlxGraphic.hx +++ b/flixel/graphics/FlxGraphic.hx @@ -303,11 +303,6 @@ class FlxGraphic implements IFlxDestroyable */ public var destroyOnNoUse(default, set):Bool = true; - /** - * Whether the `BitmapData` of this graphic object has been dumped or not. - */ - public var isDumped(default, null):Bool = false; - /** * Whether the `BitmapData` of this graphic object has been loaded or not. */ @@ -320,10 +315,12 @@ class FlxGraphic implements IFlxDestroyable public var isDestroyed(get, never):Bool; /** - * Whether the `BitmapData` of this graphic object can be dumped for decreased memory usage, - * but may cause some issues (when you need direct access to pixels of this graphic. - * If the graphic is dumped then you should call `undump()` and have total access to pixels. + * Whether the `BitmapData` of this graphic object can be refreshed. + * This is only the case for graphics with an `assetsKey` or `assetsClass`. */ + public var canBeRefreshed(get, never):Bool; + + @:deprecated("`canBeDumped` is deprecated, use `canBeRefreshed`") public var canBeDumped(get, never):Bool; /** @@ -407,58 +404,31 @@ class FlxGraphic implements IFlxDestroyable } /** - * Dumps bits of `BitmapData` to decrease memory usage, but you can't read/write pixels on it anymore - * (but you can call `onContext()` (or `undump()`) method which will restore it again). - */ - public function dump():Void - { - #if (lime_legacy && !flash) - if (FlxG.renderTile && canBeDumped) - { - bitmap.dumpBits(); - isDumped = true; - } - #end - } - - /** - * Undumps bits of the `BitmapData` - regenerates it and regenerate tilesheet data for this object + * Refreshes the `BitmapData` of this graphic. */ - public function undump():Void + public function refreshBitmap():Void { var newBitmap:BitmapData = getBitmapFromSystem(); if (newBitmap != null) bitmap = newBitmap; - isDumped = false; } - - /** - * Use this method to restore cached `BitmapData` (if it's possible). - * It's called automatically when the RESIZE event occurs. - */ - public function onContext():Void + + @:deprecated("`undump` is deprecated, use `refreshBitmap`") + public function undump():Void { - // no need to restore tilesheet if it hasn't been dumped - if (isDumped) - { - undump(); // restore everything - dump(); // and dump BitmapData again - } + refreshBitmap(); } - + /** * Asset reload callback for this graphic object. - * It regenerated its tilesheet and resets frame bitmaps. + * It regenerates its bitmap data. */ public function onAssetsReload():Void { - if (!canBeDumped) + if (!canBeRefreshed) return; - - var dumped:Bool = isDumped; - undump(); - if (dumped) - dump(); + + refreshBitmap(); } /** @@ -538,7 +508,7 @@ class FlxGraphic implements IFlxDestroyable /** * Gets the `BitmapData` for this graphic object from OpenFL. - * This method is used for undumping graphic. + * This method is used for refreshing bitmaps. */ function getBitmapFromSystem():BitmapData { @@ -547,13 +517,13 @@ class FlxGraphic implements IFlxDestroyable newBitmap = FlxAssets.getBitmapFromClass(assetsClass); else if (assetsKey != null) newBitmap = FlxAssets.getBitmapData(assetsKey); - + if (newBitmap != null) return FlxGraphic.getBitmap(newBitmap, unique); - + return null; } - + inline function get_isLoaded() { return bitmap != null && !bitmap.rect.isEmpty(); @@ -564,11 +534,16 @@ class FlxGraphic implements IFlxDestroyable return shader == null; } - inline function get_canBeDumped():Bool + inline function get_canBeRefreshed():Bool { return assetsClass != null || assetsKey != null; } + inline function get_canBeDumped():Bool + { + return canBeRefreshed; + } + public function incrementUseCount() { useCount++; diff --git a/flixel/graphics/tile/FlxDrawQuadsItem.hx b/flixel/graphics/tile/FlxDrawQuadsItem.hx index a203d9ebac..e6e09178fd 100644 --- a/flixel/graphics/tile/FlxDrawQuadsItem.hx +++ b/flixel/graphics/tile/FlxDrawQuadsItem.hx @@ -3,15 +3,15 @@ package flixel.graphics.tile; import flixel.FlxCamera; import flixel.graphics.frames.FlxFrame; import flixel.graphics.tile.FlxDrawBaseItem.FlxDrawItemType; -import flixel.system.FlxAssets.FlxShader; import flixel.math.FlxMatrix; -import openfl.geom.ColorTransform; -import openfl.display.ShaderParameter; +import flixel.system.FlxAssets.FlxShader; import openfl.Vector; +import openfl.display.ShaderParameter; +import openfl.geom.ColorTransform; class FlxDrawQuadsItem extends FlxDrawBaseItem { - static inline var VERTICES_PER_QUAD = #if (openfl >= "8.5.0") 4 #else 6 #end; + static inline var VERTICES_PER_QUAD = 4; public var shader:FlxShader; @@ -129,9 +129,7 @@ class FlxDrawQuadsItem extends FlxDrawBaseItem setParameterValue(shader.hasTransform, true); setParameterValue(shader.hasColorTransform, colored || hasColorOffsets); - #if (openfl > "8.7.0") camera.canvas.graphics.overrideBlendMode(blend); - #end camera.canvas.graphics.beginShaderFill(shader); camera.canvas.graphics.drawQuads(rects, null, transforms); super.render(camera); diff --git a/flixel/graphics/tile/FlxDrawTrianglesItem.hx b/flixel/graphics/tile/FlxDrawTrianglesItem.hx index 3bcd950e61..7ee7b3240c 100644 --- a/flixel/graphics/tile/FlxDrawTrianglesItem.hx +++ b/flixel/graphics/tile/FlxDrawTrianglesItem.hx @@ -13,7 +13,7 @@ import openfl.display.ShaderParameter; import openfl.display.TriangleCulling; import openfl.geom.ColorTransform; -typedef DrawData = #if (flash || openfl >= "4.0.0") openfl.Vector #else Array #end; +typedef DrawData = openfl.Vector; /** * @author Zaphod @@ -74,9 +74,7 @@ class FlxDrawTrianglesItem extends FlxDrawBaseItem setParameterValue(shader.hasTransform, true); setParameterValue(shader.hasColorTransform, colored || hasColorOffsets); - #if (openfl > "8.7.0") camera.canvas.graphics.overrideBlendMode(blend); - #end camera.canvas.graphics.beginShaderFill(shader); #else diff --git a/flixel/input/android/FlxAndroidKey.hx b/flixel/input/android/FlxAndroidKey.hx index 949951bb2c..efab92eda6 100644 --- a/flixel/input/android/FlxAndroidKey.hx +++ b/flixel/input/android/FlxAndroidKey.hx @@ -12,8 +12,8 @@ enum abstract FlxAndroidKey(Int) from Int to Int public static var toStringMap(default, null):Map = FlxMacroUtil.buildMap("flixel.input.android.FlxAndroidKey", true); var ANY = -2; var NONE = -1; - var MENU = #if (openfl >= "8.0.0") 0x4000010C #else 16777234 #end; - var BACK = #if (openfl >= "8.0.0") 0x4000010E #else 27 #end; + var MENU = 0x4000010C; + var BACK = 0x4000010E; @:from public static inline function fromString(s:String) diff --git a/flixel/sound/FlxSound.hx b/flixel/sound/FlxSound.hx index 5af46a02a2..18e575d700 100644 --- a/flixel/sound/FlxSound.hx +++ b/flixel/sound/FlxSound.hx @@ -14,12 +14,10 @@ import openfl.media.Sound; import openfl.media.SoundChannel; import openfl.media.SoundTransform; import openfl.net.URLRequest; +import openfl.utils.AssetType; #if flash11 import openfl.utils.ByteArray; #end -#if (openfl >= "8.0.0") -import openfl.utils.AssetType; -#end /** * This is the universal flixel sound object, used for streaming, music, and sound effects. diff --git a/flixel/system/FlxAssets.hx b/flixel/system/FlxAssets.hx index 7b3e75f341..28ccd7d88e 100644 --- a/flixel/system/FlxAssets.hx +++ b/flixel/system/FlxAssets.hx @@ -2,9 +2,6 @@ package flixel.system; import haxe.macro.Expr; #if !macro -import openfl.display.BitmapData; -import openfl.display.Graphics; -import openfl.media.Sound; import flixel.FlxG; import flixel.graphics.FlxGraphic; import flixel.graphics.atlas.AseAtlas; @@ -16,10 +13,13 @@ import flixel.graphics.frames.bmfont.BMFont; import flixel.util.typeLimit.OneOfFour; import flixel.util.typeLimit.OneOfThree; import flixel.util.typeLimit.OneOfTwo; -import haxe.io.Bytes; import haxe.Json; +import haxe.io.Bytes; import haxe.xml.Access; import openfl.Assets; +import openfl.display.BitmapData; +import openfl.display.Graphics; +import openfl.media.Sound; import openfl.utils.ByteArray; using StringTools; @@ -31,7 +31,7 @@ class GraphicLogo extends BitmapData {} class GraphicVirtualInput extends BitmapData {} @:file("assets/images/ui/virtual-input.txt") -class VirtualInputData extends #if (lime_legacy || nme) ByteArray #else ByteArrayData #end {} +class VirtualInputData extends #if nme ByteArray #else ByteArrayData #end {} typedef FlxTexturePackerJsonAsset = FlxJsonAsset; typedef FlxAsepriteJsonAsset = FlxJsonAsset; diff --git a/flixel/system/FlxBasePreloader.hx b/flixel/system/FlxBasePreloader.hx index e41ca98969..a5a0b7d005 100644 --- a/flixel/system/FlxBasePreloader.hx +++ b/flixel/system/FlxBasePreloader.hx @@ -1,6 +1,9 @@ package flixel.system; +import flixel.util.FlxColor; +import flixel.util.FlxStringUtil; import openfl.Lib; +import openfl.Vector; import openfl.display.Bitmap; import openfl.display.BitmapData; import openfl.display.GradientType; @@ -10,17 +13,14 @@ import openfl.display.Sprite; import openfl.display.StageAlign; import openfl.display.StageScaleMode; import openfl.events.Event; -import openfl.events.ProgressEvent; import openfl.events.MouseEvent; +import openfl.events.ProgressEvent; import openfl.geom.Matrix; import openfl.geom.Rectangle; import openfl.net.URLRequest; import openfl.text.TextField; import openfl.text.TextFormat; import openfl.text.TextFormatAlign; -import flixel.util.FlxColor; -import flixel.util.FlxStringUtil; -import openfl.Vector; class FlxBasePreloader extends DefaultPreloader { @@ -101,11 +101,6 @@ class FlxBasePreloader extends DefaultPreloader { super(); - #if (openfl <= "4.0.0") - removeChild(progress); - removeChild(outline); - #end - minDisplayTime = MinDisplayTime; if (AllowedURLs != null) allowedURLs = AllowedURLs; @@ -409,7 +404,6 @@ class FlxBasePreloader extends DefaultPreloader #end } -#if (openfl >= "8.0.0") // This is a slightly trimmed down version of the NMEPreloader present in older OpenFL versions private class DefaultPreloader extends Sprite { @@ -463,6 +457,3 @@ private class DefaultPreloader extends Sprite } } } -#else -private typedef DefaultPreloader = NMEPreloader; -#end diff --git a/flixel/system/debug/console/Console.hx b/flixel/system/debug/console/Console.hx index ec567331de..022ed56797 100644 --- a/flixel/system/debug/console/Console.hx +++ b/flixel/system/debug/console/Console.hx @@ -1,15 +1,15 @@ package flixel.system.debug.console; #if FLX_DEBUG -import openfl.text.TextField; -import openfl.text.TextFormat; import flixel.FlxG; import flixel.FlxObject; import flixel.system.debug.FlxDebugger.GraphicConsole; -import flixel.system.debug.completion.CompletionList; import flixel.system.debug.completion.CompletionHandler; +import flixel.system.debug.completion.CompletionList; import flixel.util.FlxStringUtil; -#if (!next && sys) +import openfl.text.TextField; +import openfl.text.TextFormat; +#if sys import openfl.events.MouseEvent; #end #if hscript @@ -58,7 +58,7 @@ class Console extends Window */ var input:TextField; - #if (!next && sys) + #if sys var inputMouseDown:Bool = false; var stageMouseDown:Bool = false; #end @@ -123,7 +123,7 @@ class Console extends Window #end #end - #if (!next && sys) // workaround for broken TextField focus on native + #if sys // workaround for broken TextField focus on native input.addEventListener(MouseEvent.MOUSE_DOWN, function(_) { inputMouseDown = true; @@ -135,7 +135,7 @@ class Console extends Window #end } - #if (!next && sys) + #if sys @:access(flixel.FlxGame.onFocus) override public function update() { diff --git a/flixel/system/frontEnds/BitmapFrontEnd.hx b/flixel/system/frontEnds/BitmapFrontEnd.hx index d9e1d16966..264dfe025e 100644 --- a/flixel/system/frontEnds/BitmapFrontEnd.hx +++ b/flixel/system/frontEnds/BitmapFrontEnd.hx @@ -1,6 +1,5 @@ package flixel.system.frontEnds; -import openfl.display.BitmapData; import flixel.graphics.FlxGraphic; import flixel.graphics.frames.FlxFrame; import flixel.math.FlxPoint; @@ -8,6 +7,7 @@ import flixel.math.FlxRect; import flixel.system.FlxAssets.FlxGraphicAsset; import flixel.util.FlxColor; import openfl.Assets; +import openfl.display.BitmapData; #if !flash import lime.graphics.opengl.GL; #end @@ -49,64 +49,13 @@ class BitmapFrontEnd for (key in _cache.keys()) { var obj = _cache.get(key); - if (obj != null && obj.canBeDumped) + if (obj != null && obj.canBeRefreshed) { obj.onAssetsReload(); } } } - /** - * New context handler. - * Regenerates tilesheets for all dumped graphics objects in the cache. - */ - public function onContext():Void - { - for (key in _cache.keys()) - { - var obj = _cache.get(key); - if (obj != null && obj.isDumped) - { - obj.onContext(); - } - } - } - - /** - * Dumps bits of all graphics in the cache. This frees some memory, but you can't read/write pixels on those graphics anymore. - * You can call undump() method for each FlxGraphic (or undumpCache()) object which will restore it again. - */ - public function dumpCache():Void - { - #if !web - for (key in _cache.keys()) - { - var obj = _cache.get(key); - if (obj != null && obj.canBeDumped) - { - obj.dump(); - } - } - #end - } - - /** - * Restores graphics of all dumped objects in the cache. - */ - public function undumpCache():Void - { - #if !web - for (key in _cache.keys()) - { - var obj = _cache.get(key); - if (obj != null && obj.isDumped) - { - obj.undump(); - } - } - #end - } - /** * Check the local bitmap cache to see if a bitmap with this key has been loaded already. * diff --git a/flixel/system/frontEnds/SoundFrontEnd.hx b/flixel/system/frontEnds/SoundFrontEnd.hx index 4abab4d04a..07f77af516 100644 --- a/flixel/system/frontEnds/SoundFrontEnd.hx +++ b/flixel/system/frontEnds/SoundFrontEnd.hx @@ -5,15 +5,13 @@ import flixel.FlxG; import flixel.group.FlxGroup; import flixel.input.keyboard.FlxKey; import flixel.math.FlxMath; -import flixel.system.FlxAssets; import flixel.sound.FlxSound; import flixel.sound.FlxSoundGroup; +import flixel.system.FlxAssets; import flixel.system.ui.FlxSoundTray; import openfl.Assets; import openfl.media.Sound; -#if (openfl >= "8.0.0") import openfl.utils.AssetType; -#end /** * Accessed via `FlxG.sound`. diff --git a/flixel/system/macros/FlxDefines.hx b/flixel/system/macros/FlxDefines.hx index baaa4529a0..3c031b1eb0 100644 --- a/flixel/system/macros/FlxDefines.hx +++ b/flixel/system/macros/FlxDefines.hx @@ -3,12 +3,12 @@ package flixel.system.macros; import haxe.macro.Compiler; import haxe.macro.Context; import haxe.macro.Expr.Position; +using StringTools; #if (flixel_addons >= "3.2.2") import flixel.addons.system.macros.FlxAddonDefines; #end -using StringTools; private enum UserDefines { @@ -59,7 +59,6 @@ private enum HelperDefines FLX_NATIVE_CURSOR; FLX_SOUND_TRAY; FLX_POINTER_INPUT; - FLX_POST_PROCESS; FLX_JOYSTICK_API; FLX_GAMEINPUT_API; FLX_ACCELEROMETER; @@ -187,12 +186,8 @@ class FlxDefines if (!defined(FLX_NO_SOUND_SYSTEM) && !defined(FLX_NO_SOUND_TRAY)) define(FLX_SOUND_TRAY); - #if (lime >= "8.0.0") if (defined(FLX_NO_SOUND_SYSTEM) || defined("flash")) define(FLX_NO_PITCH); - #else - define(FLX_NO_PITCH); - #end if (!defined(FLX_NO_PITCH)) define(FLX_PITCH); @@ -202,8 +197,6 @@ class FlxDefines if (!defined("flash") || defined("flash11_8")) define(FLX_GAMEINPUT_API); - else if (!defined("openfl_next") && (defined("cpp") || defined("neko"))) - define(FLX_JOYSTICK_API); #if nme define(FLX_JOYSTICK_API); @@ -212,11 +205,6 @@ class FlxDefines if (!defined(FLX_NO_TOUCH) || !defined(FLX_NO_MOUSE)) define(FLX_POINTER_INPUT); - #if (openfl < "4.0.0") - if (defined("cpp") || defined("neko")) - define(FLX_POST_PROCESS); - #end - if (defined("cpp") && defined("steamwrap")) define(FLX_STEAMWRAP); diff --git a/flixel/text/FlxText.hx b/flixel/text/FlxText.hx index d1f34a62e9..cf79873aeb 100644 --- a/flixel/text/FlxText.hx +++ b/flixel/text/FlxText.hx @@ -20,15 +20,12 @@ import openfl.text.TextField; import openfl.text.TextFieldAutoSize; import openfl.text.TextFormat; import openfl.text.TextFormatAlign; +import openfl.utils.AssetType; using flixel.util.FlxStringUtil; - #if flash import openfl.geom.Rectangle; #end -#if (openfl >= "8.0.0") -import openfl.utils.AssetType; -#end // TODO: think about filters and text diff --git a/flixel/util/FlxSpriteUtil.hx b/flixel/util/FlxSpriteUtil.hx index 189b13ad6f..0529dd71da 100644 --- a/flixel/util/FlxSpriteUtil.hx +++ b/flixel/util/FlxSpriteUtil.hx @@ -1,5 +1,15 @@ package flixel.util; +import flixel.FlxG; +import flixel.FlxObject; +import flixel.FlxSprite; +import flixel.effects.FlxFlicker; +import flixel.math.FlxMath; +import flixel.math.FlxPoint; +import flixel.math.FlxRect; +import flixel.system.FlxAssets; +import flixel.tweens.FlxEase; +import flixel.tweens.FlxTween; import openfl.display.BitmapData; import openfl.display.BitmapDataChannel; import openfl.display.BlendMode; @@ -12,16 +22,6 @@ import openfl.geom.ColorTransform; import openfl.geom.Matrix; import openfl.geom.Point; import openfl.geom.Rectangle; -import flixel.FlxG; -import flixel.FlxObject; -import flixel.FlxSprite; -import flixel.effects.FlxFlicker; -import flixel.math.FlxMath; -import flixel.math.FlxPoint; -import flixel.math.FlxRect; -import flixel.system.FlxAssets; -import flixel.tweens.FlxEase; -import flixel.tweens.FlxTween; // TODO: pad(): Pad the sprite out with empty pixels left/right/above/below it // TODO: rotateClockwise(): Takes the bitmapData from the given source FlxSprite and rotates it 90 degrees clockwise @@ -425,7 +425,6 @@ class FlxSpriteUtil return sprite; } - #if (flash || openfl >= "8.0.0") /** * This function draws a rounded rectangle on a FlxSprite. Same as drawRoundRect, * except it allows you to determine the radius of each corner individually. @@ -452,7 +451,6 @@ class FlxSpriteUtil endDraw(sprite, drawStyle); return sprite; } - #end /** * This function draws a circle on a FlxSprite at position X,Y with the specified color. diff --git a/include.xml b/include.xml index f742fbd22c..72db0b5230 100644 --- a/include.xml +++ b/include.xml @@ -17,8 +17,6 @@ - -