From c5740735233f94864dd56188185b4ca8ac42a115 Mon Sep 17 00:00:00 2001 From: Jaime Humberto Macias Bustamante Date: Mon, 4 Mar 2024 09:18:06 -0700 Subject: [PATCH 01/19] OpenFL version compatibility fix (reopen) (#250) * OpenFL version compatibility fix Uses var alias "__source" on 9.2.2 or "__audioSource" on latest, in case of using latest libraries. * Revert "OpenFL version compatibility fix" This reverts commit aa83aee5a5c5eb3f4e7645187f7223e438786439. * OpenFL Compatibility fix Uses (compiles) "__source" or "__audioSource" variable depending of the OpenFL version, in order to not break FlxSound. * Revert "OpenFL Compatibility fix" This reverts commit 18a9aeddf984da22422ee6f24efb9b61060456de. * OpenFL compatibility fix (get/set var) (suggestion by @NeeEoo) uses an auxiliary "__audioSource" variable for usage on latest OpenFL versions, in order to not break FlxSound class. --- source/openfl/media/SoundChannel.hx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/openfl/media/SoundChannel.hx b/source/openfl/media/SoundChannel.hx index f74d89b6..0838f391 100644 --- a/source/openfl/media/SoundChannel.hx +++ b/source/openfl/media/SoundChannel.hx @@ -64,6 +64,7 @@ import lime.media.AudioSource; @:noCompletion private var __soundTransform:SoundTransform; #if lime @:noCompletion private var __source:AudioSource; + @:noCompletion private var __audioSource(get, set):AudioSource; #end #if openfljs @@ -232,6 +233,14 @@ import lime.media.AudioSource; __dispose(); dispatchEvent(new Event(Event.SOUND_COMPLETE)); } + + function set___audioSource(value:AudioSource):AudioSource { + return __source = value; + } + + function get___audioSource():AudioSource { + return __source; + } } #else typedef SoundChannel = flash.media.SoundChannel; From a629d6988a030a58e469e83c8ea75650e78b1a50 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Mon, 11 Mar 2024 03:18:33 +0100 Subject: [PATCH 02/19] Cleanup --- source/funkin/backend/system/Conductor.hx | 5 ----- source/funkin/backend/system/macros/DefinesMacro.hx | 2 -- source/funkin/backend/system/macros/HashLinkFixer.hx | 9 --------- source/funkin/backend/system/macros/Macros.hx | 2 +- source/funkin/backend/system/macros/OptionsMacro.hx | 1 - source/funkin/backend/system/macros/Utils.hx | 1 - 6 files changed, 1 insertion(+), 19 deletions(-) diff --git a/source/funkin/backend/system/Conductor.hx b/source/funkin/backend/system/Conductor.hx index 70af30cb..8db60b36 100644 --- a/source/funkin/backend/system/Conductor.hx +++ b/source/funkin/backend/system/Conductor.hx @@ -5,11 +5,6 @@ import flixel.FlxState; import funkin.backend.system.interfaces.IBeatReceiver; import flixel.util.FlxSignal.FlxTypedSignal; -/** - * ... - * @author - */ - typedef BPMChangeEvent = { var stepTime:Float; diff --git a/source/funkin/backend/system/macros/DefinesMacro.hx b/source/funkin/backend/system/macros/DefinesMacro.hx index b7a8b96e..da257223 100644 --- a/source/funkin/backend/system/macros/DefinesMacro.hx +++ b/source/funkin/backend/system/macros/DefinesMacro.hx @@ -1,9 +1,7 @@ package funkin.backend.system.macros; #if macro -import sys.io.Process; import haxe.macro.Context; -import haxe.macro.Compiler; import haxe.macro.Expr; #end diff --git a/source/funkin/backend/system/macros/HashLinkFixer.hx b/source/funkin/backend/system/macros/HashLinkFixer.hx index f4edeaf8..046929e8 100644 --- a/source/funkin/backend/system/macros/HashLinkFixer.hx +++ b/source/funkin/backend/system/macros/HashLinkFixer.hx @@ -1,17 +1,8 @@ package funkin.backend.system.macros; #if macro -import haxe.macro.Type.ClassType; -import Type.ValueType; -import haxe.macro.Expr.Function; import haxe.macro.Expr; -import haxe.macro.Type.MetaAccess; -import haxe.macro.Type.FieldKind; -import haxe.macro.Type.ClassField; -import haxe.macro.Type.VarAccess; import haxe.macro.*; -import Sys; -import haxe.io.Path; using StringTools; using haxe.macro.PositionTools; diff --git a/source/funkin/backend/system/macros/Macros.hx b/source/funkin/backend/system/macros/Macros.hx index 4d569a0f..9183e4a4 100644 --- a/source/funkin/backend/system/macros/Macros.hx +++ b/source/funkin/backend/system/macros/Macros.hx @@ -39,7 +39,7 @@ class Macros { } } - Compiler.include("funkin", #if !UPDATE_CHECKING ['funkin.backend.system.updating'] #end); + Compiler.include("funkin", [#if !UPDATE_CHECKING 'funkin.backend.system.updating' #end]); } public static function initMacros() { diff --git a/source/funkin/backend/system/macros/OptionsMacro.hx b/source/funkin/backend/system/macros/OptionsMacro.hx index 0bf5959c..ae54eb66 100644 --- a/source/funkin/backend/system/macros/OptionsMacro.hx +++ b/source/funkin/backend/system/macros/OptionsMacro.hx @@ -6,7 +6,6 @@ import haxe.macro.Expr; using StringTools; - /** * Macro used in the options class to add getters for the SOLO keybinds. */ diff --git a/source/funkin/backend/system/macros/Utils.hx b/source/funkin/backend/system/macros/Utils.hx index 757c4c2c..df25030c 100644 --- a/source/funkin/backend/system/macros/Utils.hx +++ b/source/funkin/backend/system/macros/Utils.hx @@ -3,7 +3,6 @@ package funkin.backend.system.macros; #if macro import haxe.macro.Context; import haxe.macro.Expr; -import haxe.macro.Expr.ExprDef; #end class Utils { From d633d9b582708bf53479077982533c1372d8da95 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Fri, 15 Mar 2024 02:39:35 +0100 Subject: [PATCH 03/19] Set Icon on icons --- source/funkin/game/HealthIcon.hx | 50 ++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/source/funkin/game/HealthIcon.hx b/source/funkin/game/HealthIcon.hx index 9fd88170..d55bf14b 100644 --- a/source/funkin/game/HealthIcon.hx +++ b/source/funkin/game/HealthIcon.hx @@ -8,14 +8,21 @@ class HealthIcon extends FlxSprite */ public var sprTracker:FlxSprite; + /** + * The currently showing icon + */ + public var curCharacter:String = null; + + /** + * If the character is for the player + */ + public var isPlayer:Bool; + /** * Health steps in this format: * Min Percentage => Frame Index */ - public var healthSteps:Map = [ - 0 => 1, // losing icon - 20 => 0, // normal icon - ]; + public var healthSteps:Map = null; /** * Helper for HScript who can't make maps @@ -40,21 +47,34 @@ class HealthIcon extends FlxSprite { super(); health = 0.5; - var path = Paths.image('icons/$char'); - if (!Assets.exists(path)) path = Paths.image('icons/face'); - - loadGraphic(path, true, 150, 150); - - animation.add(char, [for(i in 0...frames.frames.length) i], 0, false, isPlayer); - antialiasing = true; - animation.play(char); - - if (frames.frames.length >= 3) - healthSteps[80] = 2; // winning icon + this.isPlayer = isPlayer; + setIcon(char); scrollFactor.set(); } + public function setIcon(char:String, width:Int = 150, height:Int = 150) { + if(curCharacter != char || this.width != width || this.height != height) { + curCharacter = char; + var path = Paths.image('icons/$char'); + if (!Assets.exists(path)) path = Paths.image('icons/face'); + + loadGraphic(path, true, width, height); + + animation.add(char, [for(i in 0...frames.frames.length) i], 0, false, isPlayer); + antialiasing = true; + animation.play(char); + + healthSteps = [ + 0 => 1, // losing icon + 20 => 0, // normal icon + ]; + + if (frames.frames.length >= 3) + healthSteps[80] = 2; // winning icon + } + } + override function update(elapsed:Float) { super.update(elapsed); From 1a86b8bd709a50296f027797013af15a78ee7d38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sat, 16 Mar 2024 20:34:27 +0100 Subject: [PATCH 04/19] updating lime for window.opacity --- libs.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs.xml b/libs.xml index 50ebe3b9..81618ce1 100644 --- a/libs.xml +++ b/libs.xml @@ -2,7 +2,7 @@ - + From c7e02d7e86a1701438b29c9a137df094bc36bb3f Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Sat, 16 Mar 2024 20:47:55 +0100 Subject: [PATCH 05/19] Fix Actions not running for mac --- .github/workflows/linux.yml | 15 +++++++++------ .github/workflows/macos.yml | 15 +++++++++------ .github/workflows/windows.yml | 10 +++++----- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a8452f77..76adeded 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -2,6 +2,7 @@ name: Linux Build on: push: + workflow_dispatch: jobs: build: name: Linux Build @@ -34,16 +35,18 @@ jobs: - name: Building the game run: | haxelib run lime build linux + - name: Tar files + run: tar -zcvf CodenameEngine.tar.gz export/release/linux/bin - name: Uploading artifact (entire build) uses: actions/upload-artifact@v2 with: name: Codename Engine - path: export/release/linux/bin - - name: Uploading artifact (executable) - uses: actions/upload-artifact@v2 - with: - name: Update-Linux - path: export/release/linux/bin/CodenameEngine + path: CodenameEngine.tar.gz + # - name: Uploading artifact (executable) + # uses: actions/upload-artifact@v2 + # with: + # name: Update-Linux + # path: export/release/linux/bin/CodenameEngine - name: Clearing already existing cache uses: actions/github-script@v6 with: diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 65a3fa2e..e6646418 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -2,6 +2,7 @@ name: Mac OS Build on: push: + workflow_dispatch: jobs: build: name: Mac OS Build @@ -31,16 +32,18 @@ jobs: - name: Building the game run: | haxelib run lime build mac + - name: Tar files + run: tar -zcvf CodenameEngine.tar.gz export/release/macos/bin - name: Uploading artifact (entire build) uses: actions/upload-artifact@v2 with: name: Codename Engine - path: export/release/macos/bin - - name: Uploading artifact (executable) - uses: actions/upload-artifact@v2 - with: - name: Update-Mac - path: export/release/macos/bin/CodenameEngine + path: CodenameEngine.tar.gz + # - name: Uploading artifact (executable) + # uses: actions/upload-artifact@v2 + # with: + # name: Update-Mac + # path: export/release/macos/bin/CodenameEngine - name: Clearing already existing cache uses: actions/github-script@v6 with: diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 6925d8ef..d89c1687 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -37,11 +37,11 @@ jobs: with: name: Codename Engine path: export/release/windows/bin - - name: Uploading artifact (executable) - uses: actions/upload-artifact@v2 - with: - name: Update-Windows - path: export/release/windows/bin/CodenameEngine.exe + # - name: Uploading artifact (executable) + # uses: actions/upload-artifact@v2 + # with: + # name: Update-Windows + # path: export/release/windows/bin/CodenameEngine.exe - name: Clearing already existing cache uses: actions/github-script@v6 with: From f8b20774e3f035eeddb9211a28a391b20db74456 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Sat, 16 Mar 2024 21:15:18 +0100 Subject: [PATCH 06/19] Remove useless indentation --- .vscode/settings.json | 4 +- FEATURES.md | 4 +- art/readme.txt | 54 +++++++++---------- assets/data/global.hx | 2 +- assets/data/scripts/pixel.hx | 4 +- assets/data/splashes/default.xml | 2 +- assets/data/splashes/pixel-default.xml | 2 +- assets/data/splashes/pixel-secret.xml | 2 +- assets/data/splashes/secret.xml | 2 +- assets/data/stages/mall.xml | 4 +- assets/data/stages/tank.xml | 2 +- .../images/editors/charter/event-spr-add.xml | 2 +- assets/images/editors/ui/topmenu.xml | 2 +- assets/shaders/chromaticAberration.frag | 14 ++--- assets/shaders/coloredVignette.frag | 6 +-- assets/shaders/engine/colorPicker.frag | 6 +-- assets/songs/test/scripts/modchart.hx | 8 +-- project.xml | 2 +- source/funkin/backend/MusicBeatTransition.hx | 2 +- source/funkin/backend/assets/Paths.hx | 2 +- source/funkin/backend/chart/EventsData.hx | 2 +- .../funkin/backend/scripting/DummyScript.hx | 2 +- source/funkin/backend/system/MainState.hx | 2 +- .../backend/system/framerate/FlixelInfo.hx | 4 +- .../backend/system/framerate/MemoryCounter.hx | 2 +- .../backend/system/framerate/StatsInfo.hx | 2 +- source/funkin/backend/system/github/GitHub.hx | 8 +-- .../backend/system/updating/AsyncUpdater.hx | 18 +++---- .../backend/system/updating/UpdateScreen.hx | 4 +- .../backend/system/updating/UpdateUtil.hx | 10 ++-- source/funkin/backend/utils/XMLUtil.hx | 12 ++--- source/funkin/editors/SaveWarning.hx | 2 +- .../editors/character/CharacterEditor.hx | 2 +- .../editors/character/CharacterInfoScreen.hx | 2 +- source/funkin/editors/charter/Charter.hx | 44 +++++++-------- .../editors/charter/CharterBackdropGroup.hx | 5 +- source/funkin/editors/charter/CharterEvent.hx | 2 +- source/funkin/editors/charter/CharterNote.hx | 4 +- .../editors/charter/CharterNoteGroup.hx | 2 +- .../editors/charter/CharterNoteHoverer.hx | 6 +-- .../editors/charter/CharterNoteTypesList.hx | 2 +- .../editors/charter/CharterSelection.hx | 2 +- .../editors/charter/CharterStrumLineGroup.hx | 2 +- .../editors/charter/CharterStrumlineScreen.hx | 4 +- source/funkin/editors/ui/UIAudioPlayer.hx | 8 +-- source/funkin/editors/ui/UIButtonList.hx | 1 - source/funkin/editors/ui/UIColorwheel.hx | 2 +- source/funkin/editors/ui/UISliceSprite.hx | 10 ++-- source/funkin/editors/ui/UISlider.hx | 48 ++++++++--------- source/funkin/game/PlayState.hx | 4 +- .../funkin/game/cutscenes/ScriptedCutscene.hx | 2 +- source/funkin/menus/FreeplayState.hx | 2 +- source/funkin/menus/GitarooPause.hx | 8 +-- source/funkin/menus/MainMenuState.hx | 1 - source/funkin/menus/PauseSubState.hx | 2 +- .../menus/PlaytestingWarningSubstate.hx | 2 +- source/funkin/menus/StoryMenuState.hx | 3 +- source/funkin/menus/TitleState.hx | 2 +- source/funkin/options/OptionsMenu.hx | 12 ++--- source/funkin/options/OptionsScreen.hx | 2 +- .../funkin/options/keybinds/KeybindSetting.hx | 4 +- .../options/keybinds/KeybindsOptions.hx | 2 +- .../_internal/backend/native/NativeWindow.hx | 2 +- 63 files changed, 192 insertions(+), 196 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 1d26a96f..fea6e023 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { - "editor.detectIndentation": false, - "editor.insertSpaces": false, + "editor.detectIndentation": false, + "editor.insertSpaces": false, "files.associations": { "*.hx": "haxe", "*.hscript": "haxe", diff --git a/FEATURES.md b/FEATURES.md index b2de03ca..9d53fcaf 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -5,7 +5,7 @@ _**QOL = Quality of Life**_

Player QOL Features

- + - New input system - New accuracy and misses system, added to fix the base game UI. - New options, including: @@ -72,7 +72,7 @@ _**QOL = Quality of Life**_ - Weeks are located in `data/weeks/weeks/` - If you need to rearrange the weeks in-game, you can use the `data/weeks/weeks.txt` file. - Editors for Charts and Characters (Stage coming soon) - - Undos/Redos supported + - Undos/Redos supported - Warning on closing unsaved work - Clean UI (for ocd freaks) - Mature Chart editor (Character editor rework soon) diff --git a/art/readme.txt b/art/readme.txt index 99aa167e..0f924efd 100644 --- a/art/readme.txt +++ b/art/readme.txt @@ -1,30 +1,30 @@ - __ / -/ _ _ |_ |_ . _ -\__) (- |_ |_ | | ) - - __ -|_ _ _ _ | -| | (- (_| |( \/ - / - - _ _ _ -(_) | ) (_| - - __ -|_ _ . _| _ _ . _ |_ |_ _ _ |_ -| | | (_| (_| \/ | ) | (_) | ) |_ \/ (- (_| | ) - / _/ / + __ / +/ _ _ |_ |_ . _ +\__) (- |_ |_ | | ) + + __ +|_ _ _ _ | +| | (- (_| |( \/ + / + + _ _ _ +(_) | ) (_| + + __ +|_ _ . _| _ _ . _ |_ |_ _ _ |_ +| | | (_| (_| \/ | ) | (_) | ) |_ \/ (- (_| | ) + / _/ / HEY Thanks for downloadin Friday Night FUNKIN' If you downloaded this from any other place than ninja-muffin24.itch.io/FUNKIN -You might be in DANGER!!! +You might be in DANGER!!! The Itch.io release is the only official source for the desktop (PC, Mac, Linux) versions of the game! As of right now, the game is FREE! If you paid for it, you got SCAMMED! Now that that's out of the way.... -THANKS FOR DOWNLOADIN. +THANKS FOR DOWNLOADIN. #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#- PERMISSIONS XDDDD @@ -77,16 +77,16 @@ I love Tom Fulp. - Cameron ♪(´▽`) ################################################################################## - - _ _ _____ _ _ ____ ____ ___ _ _ _ _ ____ ____ -| \ | | | ____| | | | | / ___| | _ \ / _ \ | | | | | \ | | | _ \ / ___| -| \| | | _| | | /\ | | | | _ | |_) | | | | | | | | | | \| | | | | | \___ \ + + _ _ _____ _ _ ____ ____ ___ _ _ _ _ ____ ____ +| \ | | | ____| | | | | / ___| | _ \ / _ \ | | | | | \ | | | _ \ / ___| +| \| | | _| | | /\ | | | | _ | |_) | | | | | | | | | | \| | | | | | \___ \ | |\ | | |___ \ V V / | |_| | | _ < | |_| | | |_| | | |\ | | |_| | ___) | -|_| \_| |_____| \_/\_/ \____| |_| \_\ \___/ \___/ |_| \_| |____/ |____/ - _ _ _ ___ ___ __ _ _ _ _ _ -|_ | | |_ |_) \_/ | |_| | |\ | /__ |_ |_ | | |_ |_) \_/ / \ |\ | |_ +|_| \_| |_____| \_/\_/ \____| |_| \_\ \___/ \___/ |_| \_| |____/ |____/ + _ _ _ ___ ___ __ _ _ _ _ _ +|_ | | |_ |_) \_/ | |_| | |\ | /__ |_ |_ | | |_ |_) \_/ / \ |\ | |_ |_ \/ |_ | \ | | | | _|_ | \| \_| o |_)\/ |_ \/ |_ | \ | \_/ | \| |_ o - / / - + / / + ################################################################################## i stole this from stamper. \ No newline at end of file diff --git a/assets/data/global.hx b/assets/data/global.hx index 5e479c62..4c49ef69 100644 --- a/assets/data/global.hx +++ b/assets/data/global.hx @@ -1,3 +1,3 @@ // function update(elapsed:Float) - if (FlxG.keys.justPressed.F5) FlxG.resetState(); \ No newline at end of file + if (FlxG.keys.justPressed.F5) FlxG.resetState(); \ No newline at end of file diff --git a/assets/data/scripts/pixel.hx b/assets/data/scripts/pixel.hx index 1d14aa4e..cc8239cf 100644 --- a/assets/data/scripts/pixel.hx +++ b/assets/data/scripts/pixel.hx @@ -35,8 +35,8 @@ function onNoteCreation(event) { note.updateHitbox(); } -function onPostNoteCreation(event) { - var splashes = event.note; +function onPostNoteCreation(event) { + var splashes = event.note; if (pixelSplashes) splashes.splash = "pixel-default"; } diff --git a/assets/data/splashes/default.xml b/assets/data/splashes/default.xml index 352e4932..886588e3 100644 --- a/assets/data/splashes/default.xml +++ b/assets/data/splashes/default.xml @@ -1,5 +1,5 @@ - + diff --git a/assets/data/splashes/pixel-default.xml b/assets/data/splashes/pixel-default.xml index 99a30bb3..97b8bf34 100644 --- a/assets/data/splashes/pixel-default.xml +++ b/assets/data/splashes/pixel-default.xml @@ -1,6 +1,6 @@ - + diff --git a/assets/data/splashes/pixel-secret.xml b/assets/data/splashes/pixel-secret.xml index 09fb5697..e710f2cf 100644 --- a/assets/data/splashes/pixel-secret.xml +++ b/assets/data/splashes/pixel-secret.xml @@ -1,6 +1,6 @@ - + diff --git a/assets/data/splashes/secret.xml b/assets/data/splashes/secret.xml index 31adb1f6..9122578b 100644 --- a/assets/data/splashes/secret.xml +++ b/assets/data/splashes/secret.xml @@ -1,5 +1,5 @@ - + diff --git a/assets/data/stages/mall.xml b/assets/data/stages/mall.xml index 8da8a472..0edfa942 100644 --- a/assets/data/stages/mall.xml +++ b/assets/data/stages/mall.xml @@ -1,7 +1,7 @@ - + @@ -9,7 +9,7 @@ - + diff --git a/assets/data/stages/tank.xml b/assets/data/stages/tank.xml index 8ba6121f..7ade888d 100644 --- a/assets/data/stages/tank.xml +++ b/assets/data/stages/tank.xml @@ -26,7 +26,7 @@ - + diff --git a/assets/images/editors/charter/event-spr-add.xml b/assets/images/editors/charter/event-spr-add.xml index 92cd0504..5783f5c1 100644 --- a/assets/images/editors/charter/event-spr-add.xml +++ b/assets/images/editors/charter/event-spr-add.xml @@ -10,7 +10,7 @@ - + diff --git a/assets/images/editors/ui/topmenu.xml b/assets/images/editors/ui/topmenu.xml index 416300cf..433ab890 100644 --- a/assets/images/editors/ui/topmenu.xml +++ b/assets/images/editors/ui/topmenu.xml @@ -8,7 +8,7 @@ - + diff --git a/assets/shaders/chromaticAberration.frag b/assets/shaders/chromaticAberration.frag index aa1ca662..bd869adb 100644 --- a/assets/shaders/chromaticAberration.frag +++ b/assets/shaders/chromaticAberration.frag @@ -6,12 +6,12 @@ uniform vec2 blueOff; void main() { - vec2 uv = getCamPos(openfl_TextureCoordv); - vec4 col; - col.r = textureCam(bitmap, uv + redOff).r; - col.g = textureCam(bitmap, uv + greenOff).g; - col.b = textureCam(bitmap, uv + blueOff).b; - col.a = texture2D(bitmap, openfl_TextureCoordv).a; + vec2 uv = getCamPos(openfl_TextureCoordv); + vec4 col; + col.r = textureCam(bitmap, uv + redOff).r; + col.g = textureCam(bitmap, uv + greenOff).g; + col.b = textureCam(bitmap, uv + blueOff).b; + col.a = texture2D(bitmap, openfl_TextureCoordv).a; - gl_FragColor = col; + gl_FragColor = col; } \ No newline at end of file diff --git a/assets/shaders/coloredVignette.frag b/assets/shaders/coloredVignette.frag index a012e78f..531431d3 100644 --- a/assets/shaders/coloredVignette.frag +++ b/assets/shaders/coloredVignette.frag @@ -6,10 +6,10 @@ uniform float strength; void main() { vec2 uv = getCamPos(openfl_TextureCoordv); - vec3 col = pow(textureCam(bitmap, uv).rgb, vec3(1.0 / strength)); + vec3 col = pow(textureCam(bitmap, uv).rgb, vec3(1.0 / strength)); - float vignette = mix(1.0, 1.0 - amount, distance(uv, vec2(0.5))); - col = pow(mix(col * color, col, vignette), vec3(strength)); + float vignette = mix(1.0, 1.0 - amount, distance(uv, vec2(0.5))); + col = pow(mix(col * color, col, vignette), vec3(strength)); gl_FragColor = vec4(col, 1.0); } \ No newline at end of file diff --git a/assets/shaders/engine/colorPicker.frag b/assets/shaders/engine/colorPicker.frag index d31972d8..bc6c6e0c 100644 --- a/assets/shaders/engine/colorPicker.frag +++ b/assets/shaders/engine/colorPicker.frag @@ -3,9 +3,9 @@ // Used in colorwheel vec3 hsvToRgb(vec3 c) { //hsv.x = hue, hsv.y = saturation, hsv.z = value - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); - vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); - return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } uniform float hue; diff --git a/assets/songs/test/scripts/modchart.hx b/assets/songs/test/scripts/modchart.hx index de01830f..df37fb12 100644 --- a/assets/songs/test/scripts/modchart.hx +++ b/assets/songs/test/scripts/modchart.hx @@ -21,7 +21,7 @@ function postUpdate(elapsed) { } } - + // for(s in strumLines) { // for(i in 0...4) { // var n = s.members[i]; @@ -29,7 +29,7 @@ function postUpdate(elapsed) { // n.angle = 180; // } // } - - // if (curSection != null) - // defaultCamZoom = curSection.mustHitSection ? 0.9 : 0.5; + + // if (curSection != null) + // defaultCamZoom = curSection.mustHitSection ? 0.9 : 0.5; } \ No newline at end of file diff --git a/project.xml b/project.xml index 5d17fa17..aee55825 100644 --- a/project.xml +++ b/project.xml @@ -7,7 +7,7 @@ package="com.yoshman29.codenameengine" version="0.1.0" company="Yoshman29" /> - diff --git a/source/funkin/backend/MusicBeatTransition.hx b/source/funkin/backend/MusicBeatTransition.hx index 6313c10b..34b02388 100644 --- a/source/funkin/backend/MusicBeatTransition.hx +++ b/source/funkin/backend/MusicBeatTransition.hx @@ -53,7 +53,7 @@ class MusicBeatTransition extends MusicBeatSubstate { finish(); } }); - + super.create(); } diff --git a/source/funkin/backend/assets/Paths.hx b/source/funkin/backend/assets/Paths.hx index 00aae99d..d8c6ba39 100644 --- a/source/funkin/backend/assets/Paths.hx +++ b/source/funkin/backend/assets/Paths.hx @@ -100,7 +100,7 @@ class Paths } return getPath('images/$key.$ext', library); } - + inline static public function script(key:String, ?library:String, isAssetsPath:Bool = false) { var scriptPath = isAssetsPath ? key : getPath(key, library); if (!OpenFlAssets.exists(scriptPath)) { diff --git a/source/funkin/backend/chart/EventsData.hx b/source/funkin/backend/chart/EventsData.hx index 36f20a2e..7c105d22 100644 --- a/source/funkin/backend/chart/EventsData.hx +++ b/source/funkin/backend/chart/EventsData.hx @@ -13,7 +13,7 @@ class EventsData { public static var defaultEventsList:Array = ["HScript Call", "Camera Movement", "Add Camera Zoom", "Camera Modulo Change", "Camera Flash", "BPM Change", "Scroll Speed Change", "Alt Animation Toggle", "Play Animation"]; public static var defaultEventsParams:Map> = [ "HScript Call" => [ - {name: "Function Name", type: TString, defValue: "myFunc"}, + {name: "Function Name", type: TString, defValue: "myFunc"}, {name: "Function Parameters (String split with commas)", type: TString, defValue: ""} ], "Camera Movement" => [{name: "Camera Target", type: TStrumLine, defValue: 0}], diff --git a/source/funkin/backend/scripting/DummyScript.hx b/source/funkin/backend/scripting/DummyScript.hx index 24ef2194..75080b45 100644 --- a/source/funkin/backend/scripting/DummyScript.hx +++ b/source/funkin/backend/scripting/DummyScript.hx @@ -5,7 +5,7 @@ package funkin.backend.scripting; */ class DummyScript extends Script { public var variables:Map = []; - + public override function get(v:String) {return variables.get(v);} public override function set(v:String, v2:Dynamic) {return variables.set(v, v2);} public override function onCall(method:String, parameters:Array):Dynamic { diff --git a/source/funkin/backend/system/MainState.hx b/source/funkin/backend/system/MainState.hx index 94b1a2d3..9a1502cd 100644 --- a/source/funkin/backend/system/MainState.hx +++ b/source/funkin/backend/system/MainState.hx @@ -41,7 +41,7 @@ class MainState extends FlxState { else if (addon.startsWith("[HIGH]")) _highPriorityAddons.insert(0, addon); else _noPriorityAddons.insert(0, addon); } - for (addon in _lowPriorityAddons) + for (addon in _lowPriorityAddons) Paths.assetsTree.addLibrary(ModsFolder.loadModLib('${ModsFolder.addonsPath}$addon', StringTools.ltrim(addon.substr("[LOW]".length)))); } if (ModsFolder.currentModFolder != null) diff --git a/source/funkin/backend/system/framerate/FlixelInfo.hx b/source/funkin/backend/system/framerate/FlixelInfo.hx index 5535c962..259b7f8f 100644 --- a/source/funkin/backend/system/framerate/FlixelInfo.hx +++ b/source/funkin/backend/system/framerate/FlixelInfo.hx @@ -13,7 +13,7 @@ class FlixelInfo extends FramerateCategory { var c:Int = 0; for(_ in FlxG.bitmap._cache.keys()) c++; - + _text = 'State: ${Type.getClassName(Type.getClass(FlxG.state))}'; _text += '\nObject Count: ${FlxG.state.members.length}'; _text += '\nCamera Count: ${FlxG.cameras.list.length}'; @@ -27,7 +27,7 @@ class FlixelInfo extends FramerateCategory { _text += '\nPoint Count: ${points._count}'; #end } - + this.text.text = _text; super.__enterFrame(t); } diff --git a/source/funkin/backend/system/framerate/MemoryCounter.hx b/source/funkin/backend/system/framerate/MemoryCounter.hx index 863bdb8c..01321f0d 100644 --- a/source/funkin/backend/system/framerate/MemoryCounter.hx +++ b/source/funkin/backend/system/framerate/MemoryCounter.hx @@ -7,7 +7,7 @@ import openfl.text.TextField; class MemoryCounter extends Sprite { public var memoryText:TextField; public var memoryPeakText:TextField; - + public var memory:Float = 0; public var memoryPeak:Float = 0; diff --git a/source/funkin/backend/system/framerate/StatsInfo.hx b/source/funkin/backend/system/framerate/StatsInfo.hx index 77a9cc9e..937bdb10 100644 --- a/source/funkin/backend/system/framerate/StatsInfo.hx +++ b/source/funkin/backend/system/framerate/StatsInfo.hx @@ -14,7 +14,7 @@ class StatsInfo extends FramerateCategory { _text = "totalDC: " + Context3DStats.totalDrawCalls(); _text += "\nstageDC: " + Context3DStats.contextDrawCalls(DrawCallContext.STAGE); _text += "\nstage3DDC: " + Context3DStats.contextDrawCalls(DrawCallContext.STAGE3D); - + this.text.text = _text; super.__enterFrame(t); } diff --git a/source/funkin/backend/system/github/GitHub.hx b/source/funkin/backend/system/github/GitHub.hx index eeb535c5..fa664112 100644 --- a/source/funkin/backend/system/github/GitHub.hx +++ b/source/funkin/backend/system/github/GitHub.hx @@ -179,12 +179,12 @@ class GitHub { return r; } private static function isRedirect(status:Int):Bool { - switch (status) { + switch (status) { // 301: Moved Permanently, 302: Found (Moved Temporarily), 307: Temporary Redirect, 308: Permanent Redirect - Nex - case 301 | 302 | 307 | 308 : - trace("Redirected with status code: " + status); + case 301 | 302 | 307 | 308 : + trace("Redirected with status code: " + status); return true; - } + } return false; } private static function __parseGitHubException(obj:Dynamic):GitHubException { diff --git a/source/funkin/backend/system/updating/AsyncUpdater.hx b/source/funkin/backend/system/updating/AsyncUpdater.hx index 52b59766..af7cfff5 100644 --- a/source/funkin/backend/system/updating/AsyncUpdater.hx +++ b/source/funkin/backend/system/updating/AsyncUpdater.hx @@ -21,14 +21,14 @@ class AsyncUpdater { public function new(releases:Array) { this.releases = releases; } - + public function execute() { Main.execAsync(installUpdates); } #end - - - #if windows + + + #if windows public static var executableGitHubName:String = "update-windows.exe"; public static var executableName:String = "CodenameEngine.exe"; #end @@ -49,7 +49,7 @@ class AsyncUpdater { public var lastTime:Float = 0; public var oldBytesLoaded:Float = 0; - + public function installUpdates() { prepareInstallationEnvironment(); downloadFiles(); @@ -64,7 +64,7 @@ class AsyncUpdater { progress.curFileName = e; trace('extracting file ${path}'); var reader = ZipUtil.openZip(path); - + progress.curZipProgress = new ZipProgress(); ZipUtil.uncompressZip(reader, './', null, progress.curZipProgress); // FileSystem.deleteFile(path); @@ -72,7 +72,7 @@ class AsyncUpdater { if (executableReplaced = FileSystem.exists('$path$executableName')) { progress.curFile = files.length; progress.curFileName = executableName; - + var progPath = Sys.programPath(); var bakFile = '${Path.withoutExtension(progPath)}.bak'; if (FileSystem.exists(bakFile)) @@ -133,7 +133,7 @@ class AsyncUpdater { downloadStream.addEventListener(ProgressEvent.PROGRESS, function(e) { progress.bytesLoaded = e.bytesLoaded; progress.bytesTotal = e.bytesTotal; - + var curTime = Lib.getTimer(); progress.downloadSpeed = (e.bytesLoaded - oldBytesLoaded) / ((curTime - lastTime) / 1000); @@ -160,7 +160,7 @@ class AsyncUpdater { public function prepareInstallationEnvironment() { progress.step = PREPARING; - + #if windows path = '${Sys.getEnv("TEMP")}\\Codename Engine\\Updater\\'; #else diff --git a/source/funkin/backend/system/updating/UpdateScreen.hx b/source/funkin/backend/system/updating/UpdateScreen.hx index d57a3d4a..4fbe4cf8 100644 --- a/source/funkin/backend/system/updating/UpdateScreen.hx +++ b/source/funkin/backend/system/updating/UpdateScreen.hx @@ -59,7 +59,7 @@ class UpdateScreen extends MusicBeatState { overSound = FlxG.sound.load(Paths.sound('gameOverEnd')); updater.execute(); - + FlxG.camera.addShader(rainbowShader = new CustomShader("engine/updaterShader")); } @@ -104,7 +104,7 @@ class UpdateScreen extends MusicBeatState { // update is done, play bf's anim FlxG.sound.music.stop(); overSound.play(); - + remove(generalProgress); remove(partProgress); generalProgress = FlxDestroyUtil.destroy(generalProgress); diff --git a/source/funkin/backend/system/updating/UpdateUtil.hx b/source/funkin/backend/system/updating/UpdateUtil.hx index 44b37beb..f8268b93 100644 --- a/source/funkin/backend/system/updating/UpdateUtil.hx +++ b/source/funkin/backend/system/updating/UpdateUtil.hx @@ -11,7 +11,7 @@ using funkin.backend.system.github.GitHub; class UpdateUtil { public static final repoOwner:String = "YoshiCrafter29"; public static final repoName:String = "CodenameTestRepo"; - + public static function init() { // deletes old bak file if it exists #if sys @@ -22,11 +22,11 @@ class UpdateUtil { } public static function checkForUpdates():UpdateCheckCallback { - var curTag = 'v${Application.current.meta.get('version')}'; + var curTag = 'v${Application.current.meta.get('version')}'; trace(curTag); - + var error = false; - + var newUpdates = __doReleaseFiltering(GitHub.getReleases(repoOwner, repoName, function(e) { error = true; }), curTag); @@ -35,7 +35,7 @@ class UpdateUtil { success: false, newUpdate: false }; - + if (newUpdates.length <= 0) { return { success: true, diff --git a/source/funkin/backend/utils/XMLUtil.hx b/source/funkin/backend/utils/XMLUtil.hx index 0ac1bef7..23ed0516 100644 --- a/source/funkin/backend/utils/XMLUtil.hx +++ b/source/funkin/backend/utils/XMLUtil.hx @@ -180,13 +180,13 @@ class XMLUtil { } /** - * Creates a new sprite based on a XML node. - */ + * Creates a new sprite based on a XML node. + */ public static inline function createSpriteFromXML(node:Access, parentFolder:String = "", defaultAnimType:XMLAnimType = BEAT, ?cl:Class, ?args:Array):FunkinSprite { - if(cl == null) cl = FunkinSprite; - if(args == null) args = []; - return loadSpriteFromXML(Type.createInstance(cl, args), node, parentFolder, defaultAnimType); - } + if(cl == null) cl = FunkinSprite; + if(args == null) args = []; + return loadSpriteFromXML(Type.createInstance(cl, args), node, parentFolder, defaultAnimType); + } public static function extractAnimFromXML(anim:Access, animType:XMLAnimType = NONE, loop:Bool = false):AnimData { var animData:AnimData = { diff --git a/source/funkin/editors/SaveWarning.hx b/source/funkin/editors/SaveWarning.hx index 86dedecb..b475e3e2 100644 --- a/source/funkin/editors/SaveWarning.hx +++ b/source/funkin/editors/SaveWarning.hx @@ -21,7 +21,7 @@ class SaveWarning { if (warningFunc != null) warningFunc(closingWindow); if (FlxG.state != null && FlxG.state is UIState) { - FlxG.state.openSubState(new UIWarningSubstate("Unsaved Changes!", "Your changes will be lost if you don't save them. (Can't be recovered)\n\n\nWould you like to Cancel?", + FlxG.state.openSubState(new UIWarningSubstate("Unsaved Changes!", "Your changes will be lost if you don't save them. (Can't be recovered)\n\n\nWould you like to Cancel?", [ { label: "Cancel", diff --git a/source/funkin/editors/character/CharacterEditor.hx b/source/funkin/editors/character/CharacterEditor.hx index 25c2d33b..3fb76ed0 100644 --- a/source/funkin/editors/character/CharacterEditor.hx +++ b/source/funkin/editors/character/CharacterEditor.hx @@ -52,7 +52,7 @@ class CharacterEditor extends UIState { WindowUtils.endfix = " (Character Editor)"; SaveWarning.selectionClass = CharacterSelection; SaveWarning.saveFunc = () -> {_file_save(null);}; - + topMenu = [ { label: "File", diff --git a/source/funkin/editors/character/CharacterInfoScreen.hx b/source/funkin/editors/character/CharacterInfoScreen.hx index d6be7ba7..f7645ca0 100644 --- a/source/funkin/editors/character/CharacterInfoScreen.hx +++ b/source/funkin/editors/character/CharacterInfoScreen.hx @@ -182,7 +182,7 @@ class CharacterInfoScreen extends UISubstateWindow { xml.set("sprite", spriteTextBox.label.text); if (iconColorWheel.colorChanged) xml.set("color", iconColorWheel.curColor.toHexString(false).replace("0x", "#")); - for (val in customPropertiesButtonList.buttons.members) + for (val in customPropertiesButtonList.buttons.members) xml.set(val.propertyText.label.text, val.valueText.label.text); for (anim in character.animDatas) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 38023cfc..376488a6 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -99,7 +99,7 @@ class Charter extends UIState { WindowUtils.endfix = " (Chart Editor)"; SaveWarning.selectionClass = CharterSelection; SaveWarning.saveFunc = () -> {_file_save(null);}; - + topMenu = [ { label: "File", @@ -501,7 +501,7 @@ class Charter extends UIState { for(strL in PlayState.SONG.strumLines) createStrumline(strumLines.members.length, strL, false, false); - + // create notes notesGroup.autoSort = false; var noteCount:Int = 0; @@ -669,11 +669,11 @@ class Charter extends UIState { for (s in selection) { if (s.draggable) { var changePoint:FlxPoint = FlxPoint.get(verticalChange, horizontalChange); - if (!FlxG.keys.pressed.SHIFT) + if (!FlxG.keys.pressed.SHIFT) changePoint.x -= ((s.step + verticalChange) - quantStepRounded(s.step+verticalChange, verticalChange > 0 ? 0.35 : 0.65)); var boundedChange:FlxPoint = changePoint.clone(); - + // Some maths, so cool bro -lunar (i dont know why i quopte my self here) if (s.step + changePoint.x < 0) boundedChange.x += Math.abs(s.step + changePoint.x); if (s.step + changePoint.x > __endStep-1) boundedChange.x -= (s.step + changePoint.x) - (__endStep-1); @@ -702,7 +702,7 @@ class Charter extends UIState { } case NONE: if (FlxG.mouse.justPressed) - FlxG.mouse.getWorldPosition(charterCamera, dragStartPos); + FlxG.mouse.getWorldPosition(charterCamera, dragStartPos); if (gridBackdropDummy.hovered) { // AUTO DETECT @@ -711,11 +711,11 @@ class Charter extends UIState { var id = Math.floor(mousePos.x / 40); var mouseOnGrid = id >= 0 && id < 4 * gridBackdrops.strumlinesAmount && mousePos.y >= 0; - + if (FlxG.mouse.justReleased) { for (n in selection) n.selected = false; selection = []; - + if (mouseOnGrid && mousePos.y > 0 && mousePos.y < (__endStep)*40) { var note = new CharterNote(); note.updatePos( @@ -760,7 +760,7 @@ class Charter extends UIState { var change:Float = Math.max((mousePos.y-(FlxG.keys.pressed.SHIFT ? dragStartPos.y : quantStep(dragStartPos.y))) / 40, -n.susLength); n.tempSusLength = change; - if (!FlxG.keys.pressed.SHIFT) + if (!FlxG.keys.pressed.SHIFT) n.tempSusLength -= (n.susLength + change) - quantStepRounded(n.susLength + change, change > 0 ? 0.35 : 0.65); @:privateAccess n.__susInstaLerp = FlxG.keys.pressed.SHIFT; }); @@ -777,7 +777,7 @@ class Charter extends UIState { undoChanges.push({before: oldSusLen, after: n.susLength, note: n}); }); undos.addToUndo(CEditSustains(undoChanges)); - + gridActionType = NONE; currentCursor = ARROW; } @@ -785,7 +785,7 @@ class Charter extends UIState { addEventSpr.selectable = !selectionBox.visible; var inBoundsY:Bool = (mousePos.y > 0 && mousePos.y < (__endStep)*40); - + // Event Spr if (mousePos.x < 0 && mousePos.x > -addEventSpr.bWidth && gridActionType == NONE && inBoundsY) { addEventSpr.incorporeal = false; @@ -927,7 +927,7 @@ class Charter extends UIState { var i = 0; var toBeDeleted:Selection = []; for (note in notesGroup.members) - if (note.strumLineID == strumLineID) { + if (note.strumLineID == strumLineID) { undoNotes.push(buildNote(note)); toBeDeleted.push(note); } @@ -1019,8 +1019,8 @@ class Charter extends UIState { var buttonI:Int = 0; for (button in quantButtons) { - button.visible = ((button.quant == quant) || - (button.quant == quants[FlxMath.wrap(quants.indexOf(quant)-1, 0, quants.length-1)]) || + button.visible = ((button.quant == quant) || + (button.quant == quants[FlxMath.wrap(quants.indexOf(quant)-1, 0, quants.length-1)]) || (button.quant == quants[FlxMath.wrap(quants.indexOf(quant)+1, 0, quants.length-1)])); button.selectable = button.visible; if (!button.visible) continue; @@ -1039,7 +1039,7 @@ class Charter extends UIState { noteTypeText.y = Std.int((noteTopButton.bHeight - noteTypeText.height) / 2); } noteTypeText.text = '($noteType) ${noteTypes[noteType-1] == null ? "Default Note" : noteTypes[noteType-1]}'; - + super.update(elapsed); scrollBar.size = (FlxG.height / 40 / charterCamera.zoom); @@ -1245,7 +1245,7 @@ class Charter extends UIState { } selection = sObjects; _edit_copy(_); // to fix stupid bugs - + undos.addToUndo(CCreateSelection(sObjects.copy())); } @@ -1263,7 +1263,7 @@ class Charter extends UIState { function _edit_undo(_) { if (strumLines.isDragging || selectionDragging || subState != null) return; - + selection = []; var undo = undos.undo(); switch(undo) { @@ -1286,7 +1286,7 @@ class Charter extends UIState { case CSelectionDrag(selectionDrags): for (s in selectionDrags) if (s.selectable.draggable) s.selectable.handleDrag(s.change * -1); - + selection = [for (s in selectionDrags) s.selectable]; case CEditSustains(changes): for(n in changes) @@ -1466,7 +1466,7 @@ class Charter extends UIState { null ]; - for (_quant in quants) + for (_quant in quants) newChilds.push({ label: '${_quant}x Grid Snap', onSelect: (_) -> {setquant(_quant); buildSnapsUI();}, @@ -1485,7 +1485,7 @@ class Charter extends UIState { function _note_selectall(_) { selection = [for (note in notesGroup.members) note]; - } + } function _note_selectmeasure(_) { selection = [for (note in notesGroup.members) @@ -1614,7 +1614,7 @@ class Charter extends UIState { } notesGroup.sortNotes(); for(n in notesGroup.members) { - if (PlayState.SONG.strumLines[n.strumLineID] != null) + if (PlayState.SONG.strumLines[n.strumLineID] != null) PlayState.SONG.strumLines[n.strumLineID].notes.push(buildNote(n)); } buildEvents(); @@ -1681,7 +1681,7 @@ class Charter extends UIState { newChanges[i] = CSelectionDrag([ for (selectionDrag in selectionDrags) { - selectable: __relinkSingleSelection(selectionDrag.selectable), + selectable: __relinkSingleSelection(selectionDrag.selectable), change: selectionDrag.change } ]); @@ -1725,7 +1725,7 @@ class Charter extends UIState { songPosition: Conductor.songPosition, playbackSpeed: playBackSlider.value, quantSelected: quant, - noteTypeSelected: noteType, + noteTypeSelected: noteType, strumlinesDraggable: strumLines.draggable, hitSounds: [for (strumLine in strumLines.members) strumLine.hitsounds], mutedVocals: [for (strumLine in strumLines.members) !(strumLine.vocals.volume > 0)], diff --git a/source/funkin/editors/charter/CharterBackdropGroup.hx b/source/funkin/editors/charter/CharterBackdropGroup.hx index f99571ab..851df461 100644 --- a/source/funkin/editors/charter/CharterBackdropGroup.hx +++ b/source/funkin/editors/charter/CharterBackdropGroup.hx @@ -46,7 +46,7 @@ class CharterBackdropGroup extends FlxTypedGroup { public override function update(elapsed:Float) { for (grid in members) grid.active = grid.visible = false; - + super.update(elapsed); for (i => strumLine in strumLineGroup.members) { @@ -74,7 +74,6 @@ class CharterBackdropGroup extends FlxTypedGroup { grid.active = grid.visible = true; grid.updateSprites(); } - } public var draggingObj:CharterBackdrop = null; @@ -135,7 +134,7 @@ class CharterBackdrop extends FlxTypedGroup { beatSeparator = new FlxBackdrop(null, Y, 0, 0); beatSeparator.y = -1; beatSeparator.visible = Options.charterShowBeats; - + for(sep in [sectionSeparator, beatSeparator]) { sep.makeSolid(1, 1, -1); sep.alpha = 0.5; diff --git a/source/funkin/editors/charter/CharterEvent.hx b/source/funkin/editors/charter/CharterEvent.hx index ff62f465..89a5d0d9 100644 --- a/source/funkin/editors/charter/CharterEvent.hx +++ b/source/funkin/editors/charter/CharterEvent.hx @@ -51,7 +51,7 @@ class CharterEvent extends UISliceSprite implements ICharterSelectable { if (Assets.exists(Paths.pack('events/$name'))) { var packimg = Assets.getText(Paths.pack('events/$name')).split('________PACKSEP________')[3]; if (isBase64 = (packimg != null)) - path = Assets.getText(Paths.pack('events/$name')).split('________PACKSEP________')[3]; + path = Assets.getText(Paths.pack('events/$name')).split('________PACKSEP________')[3]; } var spr = new FlxSprite().loadGraphic(isBase64 ? openfl.display.BitmapData.fromBase64(path.trim(), 'UTF8') : path); return spr; diff --git a/source/funkin/editors/charter/CharterNote.hx b/source/funkin/editors/charter/CharterNote.hx index 1ea7804d..1d130842 100644 --- a/source/funkin/editors/charter/CharterNote.hx +++ b/source/funkin/editors/charter/CharterNote.hx @@ -31,7 +31,7 @@ class CharterNote extends UISprite implements ICharterSelectable { public function new() { super(); - + antialiasing = true; ID = -1; loadGraphic(Paths.image('editors/charter/note'), true, 157, 154); animation.add("note", [for(i in 0...frames.frames.length) i], 0, true); @@ -154,7 +154,7 @@ class CharterNote extends UISprite implements ICharterSelectable { if (strumLine != null) { sustainSpr.alpha = alpha = !strumLine.strumLine.visible ? (__passed ? 0.2 : 0.4) : (__passed ? 0.6 : 1); - typeText.alpha = !strumLine.strumLine.visible ? (__passed ? 0.4 : 0.6) : (__passed ? 0.8 : 1); + typeText.alpha = !strumLine.strumLine.visible ? (__passed ? 0.4 : 0.6) : (__passed ? 0.8 : 1); } colorTransform.redMultiplier = colorTransform.greenMultiplier = colorTransform.blueMultiplier = selected ? 0.75 : 1; diff --git a/source/funkin/editors/charter/CharterNoteGroup.hx b/source/funkin/editors/charter/CharterNoteGroup.hx index 78995dca..66530af1 100644 --- a/source/funkin/editors/charter/CharterNoteGroup.hx +++ b/source/funkin/editors/charter/CharterNoteGroup.hx @@ -64,7 +64,7 @@ class CharterNoteGroup extends FlxTypedGroup { if (autoSort && members.length != __lastSort) sortNotes(); - + forEach((n) -> { if(n.exists && n.active) { n.cameras = n.__lastDrawCameras = cameras; diff --git a/source/funkin/editors/charter/CharterNoteHoverer.hx b/source/funkin/editors/charter/CharterNoteHoverer.hx index 46997a9b..e20000a2 100644 --- a/source/funkin/editors/charter/CharterNoteHoverer.hx +++ b/source/funkin/editors/charter/CharterNoteHoverer.hx @@ -44,18 +44,18 @@ class CharterNoteHoverer extends CharterNote { if (Charter.instance.gridActionType == NOTE_DRAG) { var verticalChange:Float = (__mousePos.y - Charter.instance.dragStartPos.y) / 40; var horizontalChange:Int = CoolUtil.floorInt((__mousePos.x - (Std.int(Charter.instance.dragStartPos.x / 40) * 40)) / 40); - + for (s in Charter.selection) { if (s != null && s.draggable && s is CharterNote) { var draggingNote:CharterNote = cast(s, CharterNote); y = (draggingNote.step + verticalChange); - if (!FlxG.keys.pressed.SHIFT) + if (!FlxG.keys.pressed.SHIFT) y -= ((draggingNote.step + verticalChange) - Charter.instance.quantStepRounded(draggingNote.step+verticalChange, verticalChange > 0 ? 0.35 : 0.65)); y *= 40; var newID:Int = Std.int(FlxMath.bound(draggingNote.fullID + horizontalChange, 0, (Charter.instance.strumLines.members.length*4)-1)); x = (id=newID) * 40; y = FlxMath.bound(y, 0, (Charter.instance.__endStep*40) - height); - + angle = switch(animation.curAnim.curFrame = (draggingNote.id % 4)) { case 0: -90; case 1: 180; diff --git a/source/funkin/editors/charter/CharterNoteTypesList.hx b/source/funkin/editors/charter/CharterNoteTypesList.hx index 7eb3abce..b1cc28b6 100644 --- a/source/funkin/editors/charter/CharterNoteTypesList.hx +++ b/source/funkin/editors/charter/CharterNoteTypesList.hx @@ -108,7 +108,7 @@ class NoteTypeButton extends UIButton { var path:String = 'game/notes/default'; if (Assets.exists(Paths.image('game/notes/${notetype}'))) path = 'game/notes/${notetype}'; - + noteSpr.frames = Paths.getFrames(path); noteSpr.animation.addByPrefix('scroll', 'green0'); noteSpr.animation.play("scroll"); diff --git a/source/funkin/editors/charter/CharterSelection.hx b/source/funkin/editors/charter/CharterSelection.hx index ba1acdc4..f9a1ea5e 100644 --- a/source/funkin/editors/charter/CharterSelection.hx +++ b/source/funkin/editors/charter/CharterSelection.hx @@ -29,7 +29,7 @@ class CharterSelection extends EditorTreeMenu { for(s in freeplayList.songs) new EditorIconOption(s.name, "Press ACCEPT to choose a difficulty to edit.", s.icon, function() { curSong = s; var list:Array = [ - for(d in s.difficulties) if (d != "") + for(d in s.difficulties) if (d != "") new TextOption(d, "Press ACCEPT to edit the chart for the selected difficulty", function() { FlxG.switchState(new Charter(s.name, d)); }) diff --git a/source/funkin/editors/charter/CharterStrumLineGroup.hx b/source/funkin/editors/charter/CharterStrumLineGroup.hx index a342c779..483b62ce 100644 --- a/source/funkin/editors/charter/CharterStrumLineGroup.hx +++ b/source/funkin/editors/charter/CharterStrumLineGroup.hx @@ -79,7 +79,7 @@ class CharterStrumLineGroup extends FlxTypedGroup { fixEvents(); } - public inline function fixEvents() { + public inline function fixEvents() { for (i in Charter.instance.eventsGroup.members) { for (j in i.events) { var paramTypes:Array = EventsData.getEventParams(j.name); diff --git a/source/funkin/editors/charter/CharterStrumlineScreen.hx b/source/funkin/editors/charter/CharterStrumlineScreen.hx index 5af1b606..3b8f7920 100644 --- a/source/funkin/editors/charter/CharterStrumlineScreen.hx +++ b/source/funkin/editors/charter/CharterStrumlineScreen.hx @@ -63,7 +63,7 @@ class CharterStrumlineScreen extends UISubstateWindow { var charFileList = Character.getList(true); if (charFileList.length == 0) charFileList = Character.getList(false); - + charactersList = new UIButtonList(15, title.y + title.height + 36, 250, 269, "", FlxPoint.get(250, 54), null, 0); charactersList.addButton.callback = () -> charactersList.add(new CharacterButton(0, 0, "New Char", charFileList, charactersList)); charactersList.cameraSpacing = 0; @@ -142,7 +142,7 @@ class CharterStrumlineScreen extends UISubstateWindow { closeButton.color = 0xFFFF0000; var suffixlist = ["NONE"]; - for (i in Paths.getFolderContent('songs/${Charter.__song.toLowerCase()}/song')) + for (i in Paths.getFolderContent('songs/${Charter.__song.toLowerCase()}/song')) if (i.startsWith("Voices")) { i = haxe.io.Path.withoutExtension(i.substr("Voices".length)); if (i == "") continue; diff --git a/source/funkin/editors/ui/UIAudioPlayer.hx b/source/funkin/editors/ui/UIAudioPlayer.hx index ad1ba457..b6b95448 100644 --- a/source/funkin/editors/ui/UIAudioPlayer.hx +++ b/source/funkin/editors/ui/UIAudioPlayer.hx @@ -87,7 +87,7 @@ class UIAudioPlayer extends UIButton { playingSprite.animation.play(sound.playing ? "playing" : "paused"); timeText.text = '${FlxStringUtil.formatTime(sound.time/1000, true)} / ${FlxStringUtil.formatTime(sound.length/1000)}'; - if(timeBarPlayer.clipRect == null) + if(timeBarPlayer.clipRect == null) timeBarPlayer.clipRect = new FlxRect(0, 0, timeBarPlayer.frameWidth, timeBarPlayer.frameHeight); timeBarPlayer.clipRect.x = timeBarPlayer.frameWidth * (sound.time/sound.length); @@ -106,13 +106,13 @@ class UIAudioPlayer extends UIButton { var spritePos:FlxPoint = sprite.getScreenPosition(FlxPoint.get(), __lastDrawCameras[0]); - if (((mousePos.x > (spritePos.x)) && (mousePos.x < (spritePos.x) + timeBar.barWidth)) + if (((mousePos.x > (spritePos.x)) && (mousePos.x < (spritePos.x) + timeBar.barWidth)) && ((mousePos.y > (spritePos.y)) && (mousePos.y < (spritePos.y) + timeBar.barHeight))) { if (FlxG.mouse.justPressed) { draggingObj = sprite; wasPlaying = draggingObj == timeBar ? sound.playing : false; } - + if (FlxG.mouse.pressed) { if (draggingObj == timeBar) { if (sound.playing) sound.pause(); @@ -137,7 +137,7 @@ class UIAudioPlayer extends UIButton { super.destroy(); sound.stop(); - @:privateAccess sound.reset(); + @:privateAccess sound.reset(); bytes = null; } } \ No newline at end of file diff --git a/source/funkin/editors/ui/UIButtonList.hx b/source/funkin/editors/ui/UIButtonList.hx index 59d88971..f6fbc3a1 100644 --- a/source/funkin/editors/ui/UIButtonList.hx +++ b/source/funkin/editors/ui/UIButtonList.hx @@ -121,7 +121,6 @@ class UIButtonList extends UIWindow { if (dragCallback != null) dragCallback(cast button, button.ID, i); button.ID = i; // Ok back to normal :D } - } addButton.selectable = (hovered && !dragging); diff --git a/source/funkin/editors/ui/UIColorwheel.hx b/source/funkin/editors/ui/UIColorwheel.hx index a25b41bd..421814c4 100644 --- a/source/funkin/editors/ui/UIColorwheel.hx +++ b/source/funkin/editors/ui/UIColorwheel.hx @@ -91,7 +91,7 @@ class UIColorwheel extends UISliceSprite { } inline function updateColorPickerSelector() - colorPickerSelector.selector.setPosition(colorPicker.x + (colorPicker.width *saturation) - 8, colorPicker.y + (colorPicker.height + (colorPicker.height * -brightness))- 8); + colorPickerSelector.selector.setPosition(colorPicker.x + (colorPicker.width *saturation) - 8, colorPicker.y + (colorPicker.height + (colorPicker.height * -brightness))- 8); inline function updateColorPickerMouse(mousePos:FlxPoint) { saturation = mousePos.x/colorPicker.width; brightness = 1 + -(mousePos.y/colorPicker.height); diff --git a/source/funkin/editors/ui/UISliceSprite.hx b/source/funkin/editors/ui/UISliceSprite.hx index 9556a521..09226205 100644 --- a/source/funkin/editors/ui/UISliceSprite.hx +++ b/source/funkin/editors/ui/UISliceSprite.hx @@ -55,7 +55,7 @@ class UISliceSprite extends UISprite { frame = topleft; setPosition(x, y); __setSize( - topleft.frame.width * Math.min(bWidth/(topleft.frame.width*2), 1), + topleft.frame.width * Math.min(bWidth/(topleft.frame.width*2), 1), topleft.frame.height * Math.min(bHeight/(topleft.frame.height*2), 1) ); super.drawSuper(); @@ -72,7 +72,7 @@ class UISliceSprite extends UISprite { setPosition(x + bWidth - (topright.frame.width * Math.min(bWidth/(topright.frame.width*2), 1)), y); frame = topright; __setSize( - topright.frame.width * Math.min(bWidth/(topright.frame.width*2), 1), + topright.frame.width * Math.min(bWidth/(topright.frame.width*2), 1), topright.frame.height * Math.min(bHeight/(topright.frame.height*2), 1) ); super.drawSuper(); @@ -110,7 +110,7 @@ class UISliceSprite extends UISprite { frame = bottomleft; setPosition(x, y + bHeight - (bottomleft.frame.height * Math.min(bHeight/(bottomleft.frame.height*2), 1))); __setSize( - bottomleft.frame.width * Math.min(bWidth/(bottomleft.frame.width*2), 1), + bottomleft.frame.width * Math.min(bWidth/(bottomleft.frame.width*2), 1), bottomleft.frame.height * Math.min(bHeight/(bottomleft.frame.height*2), 1) ); super.drawSuper(); @@ -126,11 +126,11 @@ class UISliceSprite extends UISprite { // BOTTOM RIGHT frame = bottomright; setPosition( - x + bWidth - (bottomright.frame.width * Math.min(bWidth/(bottomright.frame.width*2), 1)), + x + bWidth - (bottomright.frame.width * Math.min(bWidth/(bottomright.frame.width*2), 1)), y + bHeight - (bottomright.frame.height * Math.min(bHeight/(bottomright.frame.height*2), 1)) ); __setSize( - bottomright.frame.width * Math.min(bWidth/(bottomright.frame.width*2), 1), + bottomright.frame.width * Math.min(bWidth/(bottomright.frame.width*2), 1), bottomright.frame.height * Math.min(bHeight/(bottomright.frame.height*2), 1) ); super.drawSuper(); diff --git a/source/funkin/editors/ui/UISlider.hx b/source/funkin/editors/ui/UISlider.hx index 8c5a4537..277c7b95 100644 --- a/source/funkin/editors/ui/UISlider.hx +++ b/source/funkin/editors/ui/UISlider.hx @@ -43,21 +43,21 @@ class UISlider extends UISprite { makeGraphic(barWidth, 12, 0x00000000, true); this.drawRoundRect(0, 0, barWidth, 12, 8, 6, 0xFFC0C0C0); - this.drawRoundRect(1, 1, barWidth-2, 12-2, 8, 5, 0xFF140013); + this.drawRoundRect(1, 1, barWidth-2, 12-2, 8, 5, 0xFF140013); cursor = BUTTON; - progressbar = new UISprite(centered ? barWidth/2 : 0); + progressbar = new UISprite(centered ? barWidth/2 : 0); progressbar.makeGraphic(barWidth, 8, 0x00000000, true); progressbar.drawRoundRect(2, 0, barWidth-4, 8, 8, 2, 0xFFFFFFFF); - progressbar.origin.x = 0; progressbar.colorTransform.color = 0xFF67009B; - members.push(progressbar); + progressbar.origin.x = 0; progressbar.colorTransform.color = 0xFF67009B; + members.push(progressbar); this.value = value; visualProgress = __barProgress; members.push(startText = new UIText(x, y, 0, Std.string(segments[0].start).replace("0.", "."))); members.push(endText = new UIText(x + (barWidth) + 8, y, 0, Std.string(segments[segments.length-1].end).replace("0.", "."))); - + for (i in 0...2) { var selectableBar:UISprite = new UISprite(x,y); selectableBar.loadGraphic(Paths.image("editors/ui/slider")); @@ -91,14 +91,14 @@ class UISlider extends UISprite { var visualProgress:Float = 0; var __stepperWidth = 25; - + public override function update(elapsed:Float) { selectableHitbox.follow(this, 0, (height-selectableHitbox.height)/2); __stepperWidth = valueStepper.label.text.length <= 0 ? 25 : Std.int(valueStepper.label.textField.width) + 12; valueStepper.bWidth = Std.int(FlxMath.lerp(valueStepper.bWidth, __stepperWidth, 1/2.25)); valueStepper.follow(this, -startText.width-10 - valueStepper.bWidth - 4, (height-valueStepper.bHeight)/2); - + var lastBarProgress:Float = __barProgress; if (selectableHitbox.hovered && FlxG.mouse.pressed) { @@ -111,13 +111,13 @@ class UISlider extends UISprite { if (onChange != null) onChange(@:bypassAccessor value = __calcValue(__barProgress)); valueStepper.value = value; } - + visualProgress = FlxMath.lerp(visualProgress, __barProgress, 1/2.25); progressbar.follow(this, progressCentered ? barWidth/2 : 0, (height-progressbar.height)/2); progressbar.scale.x = FlxMath.bound(visualProgress-(progressCentered?0.5:0),-1,1); progressbar.colorTransform.color = FlxColor.interpolate(progressbar.colorTransform.color, selectableHitbox.hovered ? 0xFF7F00BF : 0xFF67009B, 1/14); - selectableBar.follow(this, (visualProgress * barWidth) - (selectableBar.width/2), (height-selectableBar.height)/2); selectableBarHighlight.follow(selectableBar); + selectableBar.follow(this, (visualProgress * barWidth) - (selectableBar.width/2), (height-selectableBar.height)/2); selectableBarHighlight.follow(selectableBar); selectableBarHighlight.alpha = FlxMath.lerp(selectableBarHighlight.alpha, selectableHitbox.hovered ? 0.1: 0, 1/14); startText.follow(this, -startText.width-10, (height/2) - (startText.height/2)); @@ -128,13 +128,13 @@ class UISlider extends UISprite { private function __calcValue(progress:Float):Float { var totalProgress:Float = 0; - for (segment in segments) { - if (progress < totalProgress + segment.size) { - var relativeProgress = (progress - totalProgress) / segment.size; - return FlxMath.remapToRange(relativeProgress, 0, 1, segment.start, segment.end); - } - totalProgress += segment.size; - } + for (segment in segments) { + if (progress < totalProgress + segment.size) { + var relativeProgress = (progress - totalProgress) / segment.size; + return FlxMath.remapToRange(relativeProgress, 0, 1, segment.start, segment.end); + } + totalProgress += segment.size; + } return segments[segments.length-1].end; } @@ -142,14 +142,14 @@ class UISlider extends UISprite { if (value >= segments[segments.length-1].end) return 1; if (value <= segments[0].start) return 0; - var totalProgress:Float = 0; - for (segment in segments) { - if (value >= segment.start && value <= segment.end) { - var relativeProgress = FlxMath.remapToRange(value, segment.start, segment.end, 0, 1); - return totalProgress + relativeProgress * segment.size; - } - totalProgress += segment.size; - } + var totalProgress:Float = 0; + for (segment in segments) { + if (value >= segment.start && value <= segment.end) { + var relativeProgress = FlxMath.remapToRange(value, segment.start, segment.end, 0, 1); + return totalProgress + relativeProgress * segment.size; + } + totalProgress += segment.size; + } return -1; } } \ No newline at end of file diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index c567b3c5..fd9b13e7 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -649,7 +649,7 @@ class PlayState extends MusicBeatState var strLine = new StrumLine(chars, startingPos, strumLine.strumScale == null ? 1 : strumLine.strumScale, - strumLine.type == 2 || (!coopMode && !((strumLine.type == 1 && !opponentMode) || (strumLine.type == 0 && opponentMode))), + strumLine.type == 2 || (!coopMode && !((strumLine.type == 1 && !opponentMode) || (strumLine.type == 0 && opponentMode))), strumLine.type != 1, coopMode ? (strumLine.type == 1 ? controlsP1 : controlsP2) : controls, strumLine.vocalsSuffix ); @@ -758,7 +758,7 @@ class PlayState extends MusicBeatState SaveWarning.selectionClass = CharterSelection; SaveWarning.warningFunc = saveWarn; SaveWarning.saveFunc = () -> { - @:privateAccess Chart.save('${Paths.getAssetsRoot()}/songs/${Charter.__song.toLowerCase()}', + @:privateAccess Chart.save('${Paths.getAssetsRoot()}/songs/${Charter.__song.toLowerCase()}', PlayState.SONG, Charter.__diff.toLowerCase(), {saveMetaInChart: false, saveEventsInChart: true}); } } diff --git a/source/funkin/game/cutscenes/ScriptedCutscene.hx b/source/funkin/game/cutscenes/ScriptedCutscene.hx index 522ad668..3f36f1af 100644 --- a/source/funkin/game/cutscenes/ScriptedCutscene.hx +++ b/source/funkin/game/cutscenes/ScriptedCutscene.hx @@ -51,7 +51,7 @@ class ScriptedCutscene extends Cutscene { script.call("destroy"); super.destroy(); } - + // VIDEOS #if REGION public function startVideo(path:String, ?callback:Void->Void) { diff --git a/source/funkin/menus/FreeplayState.hx b/source/funkin/menus/FreeplayState.hx index f88b8d99..0a6f3493 100644 --- a/source/funkin/menus/FreeplayState.hx +++ b/source/funkin/menus/FreeplayState.hx @@ -119,7 +119,7 @@ class FreeplayState extends MusicBeatState DiscordUtil.changePresence("In the Menus", null); super.create(); - + // LOAD CHARACTERS bg = new FlxSprite(0, 0).loadAnimatedGraphic(Paths.image('menus/menuDesat')); diff --git a/source/funkin/menus/GitarooPause.hx b/source/funkin/menus/GitarooPause.hx index a8448b4e..b1741978 100644 --- a/source/funkin/menus/GitarooPause.hx +++ b/source/funkin/menus/GitarooPause.hx @@ -19,25 +19,25 @@ class GitarooPause extends MusicBeatState if (FlxG.sound.music != null) FlxG.sound.music.stop(); - var bg:FlxSprite = new FlxSprite().loadAnimatedGraphic(Paths.image('menus/pauseAlt//pauseBG')); + var bg:FlxSprite = new FlxSprite().loadAnimatedGraphic(Paths.image('menus/pauseAlt/pauseBG')); add(bg); var bf:FlxSprite = new FlxSprite(0, 30); - bf.frames = Paths.getFrames('menus/pauseAlt//bfLol'); + bf.frames = Paths.getFrames('menus/pauseAlt/bfLol'); bf.animation.addByPrefix('lol', "funnyThing", 13); bf.animation.play('lol'); add(bf); bf.screenCenter(X); replayButton = new FlxSprite(FlxG.width * 0.28, FlxG.height * 0.7); - replayButton.frames = Paths.getFrames('menus/pauseAlt//pauseUI'); + replayButton.frames = Paths.getFrames('menus/pauseAlt/pauseUI'); replayButton.animation.addByPrefix('selected', 'bluereplay', 0, false); replayButton.animation.appendByPrefix('selected', 'yellowreplay'); replayButton.animation.play('selected'); add(replayButton); cancelButton = new FlxSprite(FlxG.width * 0.58, replayButton.y); - cancelButton.frames = Paths.getFrames('menus/pauseAlt//pauseUI'); + cancelButton.frames = Paths.getFrames('menus/pauseAlt/pauseUI'); cancelButton.animation.addByPrefix('selected', 'bluecancel', 0, false); cancelButton.animation.appendByPrefix('selected', 'cancelyellow'); cancelButton.animation.play('selected'); diff --git a/source/funkin/menus/MainMenuState.hx b/source/funkin/menus/MainMenuState.hx index 2c5c7101..7744564b 100644 --- a/source/funkin/menus/MainMenuState.hx +++ b/source/funkin/menus/MainMenuState.hx @@ -118,7 +118,6 @@ class MainMenuState extends MusicBeatState FlxG.switchState(new TitleState()); #if MOD_SUPPORT - // make it customisable if (controls.SWITCHMOD) { openSubState(new ModSwitchMenu()); persistentUpdate = false; diff --git a/source/funkin/menus/PauseSubState.hx b/source/funkin/menus/PauseSubState.hx index b0c34bf9..edc0cb61 100644 --- a/source/funkin/menus/PauseSubState.hx +++ b/source/funkin/menus/PauseSubState.hx @@ -161,7 +161,7 @@ class PauseSubState extends MusicBeatSubstate else { PlayState.resetSongInfos(); if (Charter.instance != null) Charter.instance.__clearStatics(); - + CoolUtil.playMenuSong(); FlxG.switchState(PlayState.isStoryMode ? new StoryMenuState() : new FreeplayState()); } diff --git a/source/funkin/menus/PlaytestingWarningSubstate.hx b/source/funkin/menus/PlaytestingWarningSubstate.hx index 047d42ce..e366bf9f 100644 --- a/source/funkin/menus/PlaytestingWarningSubstate.hx +++ b/source/funkin/menus/PlaytestingWarningSubstate.hx @@ -80,7 +80,7 @@ class PlaytestingWarningSubstate extends MusicBeatSubstate if (controls.RIGHT_P) changeSelection(1); if (controls.LEFT_P) changeSelection(-1); - + for (i => option in options) { option.x = FlxG.width * ((1+i)/4) - (option.fieldWidth/2); switch(i) { diff --git a/source/funkin/menus/StoryMenuState.hx b/source/funkin/menus/StoryMenuState.hx index 0f8dd1d5..6d9e27f2 100644 --- a/source/funkin/menus/StoryMenuState.hx +++ b/source/funkin/menus/StoryMenuState.hx @@ -276,7 +276,6 @@ class StoryMenuState extends MusicBeatState { } public function addCharacter(charName:String) { - var char:Access = null; try { char = new Access(Xml.parse(Assets.getText(Paths.xml('weeks/characters/$charName'))).firstElement()); @@ -307,7 +306,7 @@ class StoryMenuState extends MusicBeatState { } else { weeksFound = [for(c in Paths.getFolderContent('data/weeks/weeks/', false, source)) if (Path.extension(c).toLowerCase() == "xml") Path.withoutExtension(c)]; } - + if (weeksFound.length > 0) { for(s in weeksFound) weeks.push(s); diff --git a/source/funkin/menus/TitleState.hx b/source/funkin/menus/TitleState.hx index a24a8e86..491bc65a 100644 --- a/source/funkin/menus/TitleState.hx +++ b/source/funkin/menus/TitleState.hx @@ -34,7 +34,7 @@ class TitleState extends MusicBeatState MusicBeatState.skipTransIn = true; startIntro(); - + super.create(); } diff --git a/source/funkin/options/OptionsMenu.hx b/source/funkin/options/OptionsMenu.hx index e8226a9b..5b786e10 100644 --- a/source/funkin/options/OptionsMenu.hx +++ b/source/funkin/options/OptionsMenu.hx @@ -65,7 +65,7 @@ class OptionsMenu extends TreeMenu { } } })]); - + var xmlPath = Paths.xml("config/options"); for(source in [funkin.backend.assets.AssetsLibraryList.AssetSource.SOURCE, funkin.backend.assets.AssetsLibraryList.AssetSource.MODS]) { if (Paths.assetsTree.existsSpecific(xmlPath, "TEXT", source)) { @@ -75,13 +75,13 @@ class OptionsMenu extends TreeMenu { } catch(e) { Logs.trace('Error while parsing options.xml: ${Std.string(e)}', ERROR); } - + if (access != null) for(o in parseOptionsFromXML(access)) main.add(o); } } - + } public override function exit() { @@ -123,7 +123,7 @@ class OptionsMenu extends TreeMenu { Logs.trace("A choice option requires an \"id\" for option saving.", WARNING); continue; } - + var optionOptions:Array = []; var optionDisplayOptions:Array = []; @@ -131,10 +131,10 @@ class OptionsMenu extends TreeMenu { optionOptions.push(choice.att.value); optionDisplayOptions.push(choice.att.name); } - + if(optionOptions.length > 0) options.push(new ArrayOption(name, desc, optionOptions, optionDisplayOptions, node.att.id, null, FlxG.save.data)); - + case "menu": options.push(new TextOption(name + " >", desc, function() { optionsTree.add(new OptionsScreen(name, desc, parseOptionsFromXML(node))); diff --git a/source/funkin/options/OptionsScreen.hx b/source/funkin/options/OptionsScreen.hx index ad4f01b9..f21bdaaf 100644 --- a/source/funkin/options/OptionsScreen.hx +++ b/source/funkin/options/OptionsScreen.hx @@ -71,7 +71,7 @@ class OptionsScreen extends FlxTypedSpriteGroup { public function updateMenuDesc(?customTxt:String) { if (parent.treeParent == null) return; - + var text:String = members[curSelected].desc; if (customTxt != null) text = customTxt; parent.treeParent.updateDesc(text); diff --git a/source/funkin/options/keybinds/KeybindSetting.hx b/source/funkin/options/keybinds/KeybindSetting.hx index 3fa1a9fc..8201f013 100644 --- a/source/funkin/options/keybinds/KeybindSetting.hx +++ b/source/funkin/options/keybinds/KeybindSetting.hx @@ -52,10 +52,10 @@ class KeybindSetting extends FlxTypedSpriteGroup { var min = Math.min(icon.scale.x, icon.scale.y); icon.scale.set(min, min); add(icon); - + title.setPosition(100, 0); } - + setPosition(x, y); } diff --git a/source/funkin/options/keybinds/KeybindsOptions.hx b/source/funkin/options/keybinds/KeybindsOptions.hx index cb974c47..e4e7d26c 100644 --- a/source/funkin/options/keybinds/KeybindsOptions.hx +++ b/source/funkin/options/keybinds/KeybindsOptions.hx @@ -192,7 +192,7 @@ class KeybindsOptions extends MusicBeatSubstate { if (canSelect) { changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0)); - + if (controls.BACK) { MusicBeatState.skipTransIn = true; if (isSubState) diff --git a/source/lime/_internal/backend/native/NativeWindow.hx b/source/lime/_internal/backend/native/NativeWindow.hx index 9d318ec9..397d94ac 100644 --- a/source/lime/_internal/backend/native/NativeWindow.hx +++ b/source/lime/_internal/backend/native/NativeWindow.hx @@ -107,7 +107,7 @@ class NativeWindow #if (!macro && lime_cffi) handle = NativeCFFI.lime_window_create(parent.application.__backend.handle, width, height, flags, title); - + #if (DARK_MODE_WINDOW && !macro) funkin.backend.utils.NativeAPI.setDarkMode(title, true); #end From 5630bfa4ee15121ab535d83a44c8a0c89543206b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sat, 16 Mar 2024 21:39:05 +0100 Subject: [PATCH 07/19] synced sprites --- source/funkin/backend/FunkinSprite.hx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/funkin/backend/FunkinSprite.hx b/source/funkin/backend/FunkinSprite.hx index ec8183ce..53925e5d 100644 --- a/source/funkin/backend/FunkinSprite.hx +++ b/source/funkin/backend/FunkinSprite.hx @@ -41,7 +41,10 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I public var debugMode:Bool = false; public var animDatas:Map = []; - public var beatInterval:Int = 1; + /** + * ODD interval -> asycned; EVEN interval -> synced + */ + public var beatInterval:Int = 2; public var beatOffset:Int = 0; public var skipNegativeBeats:Bool = false; From 56bba6a822be6fb9e6ec5f0f7e04dd45f9d42221 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Sat, 16 Mar 2024 21:44:28 +0100 Subject: [PATCH 08/19] Cleanup --- source/funkin/backend/FunkinSprite.hx | 13 +++++- .../editors/character/CharacterInfoScreen.hx | 2 +- source/funkin/editors/ui/UIColorwheel.hx | 2 +- source/funkin/game/Character.hx | 44 ++++++++++--------- source/funkin/game/PlayState.hx | 4 +- source/funkin/options/OptionsTree.hx | 5 +-- 6 files changed, 40 insertions(+), 30 deletions(-) diff --git a/source/funkin/backend/FunkinSprite.hx b/source/funkin/backend/FunkinSprite.hx index 53925e5d..51a322c0 100644 --- a/source/funkin/backend/FunkinSprite.hx +++ b/source/funkin/backend/FunkinSprite.hx @@ -42,9 +42,9 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I public var animDatas:Map = []; /** - * ODD interval -> asycned; EVEN interval -> synced + * ODD interval -> asynced; EVEN interval -> synced */ - public var beatInterval:Int = 2; + public var beatInterval(default, set):Int = 2; public var beatOffset:Int = 0; public var skipNegativeBeats:Bool = false; @@ -361,4 +361,13 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I return animateAtlas != null ? (animateAtlas.anim.finished) : (animation.curAnim != null ? animation.curAnim.finished : true); } #end + + // Getter / Setters + + @:noCompletion private function set_beatInterval(v:Int) { + if (v < 1) + v = 1; + + return beatInterval = v; + } } diff --git a/source/funkin/editors/character/CharacterInfoScreen.hx b/source/funkin/editors/character/CharacterInfoScreen.hx index f7645ca0..28425c2e 100644 --- a/source/funkin/editors/character/CharacterInfoScreen.hx +++ b/source/funkin/editors/character/CharacterInfoScreen.hx @@ -181,7 +181,7 @@ class CharacterInfoScreen extends UISubstateWindow { xml.set("antialiasing", antialiasingCheckbox.checked ? "true" : "false"); xml.set("sprite", spriteTextBox.label.text); if (iconColorWheel.colorChanged) - xml.set("color", iconColorWheel.curColor.toHexString(false).replace("0x", "#")); + xml.set("color", iconColorWheel.curColor.toWebString()); for (val in customPropertiesButtonList.buttons.members) xml.set(val.propertyText.label.text, val.valueText.label.text); diff --git a/source/funkin/editors/ui/UIColorwheel.hx b/source/funkin/editors/ui/UIColorwheel.hx index 421814c4..0a28e20e 100644 --- a/source/funkin/editors/ui/UIColorwheel.hx +++ b/source/funkin/editors/ui/UIColorwheel.hx @@ -108,7 +108,7 @@ class UIColorwheel extends UISliceSprite { colorPickerSelector.curColor = color = curColor = FlxColor.fromHSB(hue, saturation, brightness); colorSliderSelector.curColor = FlxColor.fromHSB(hue, 1, 1); updateColorPickerSelector(); updateColorSliderPickerSelector(); - colorHexTextBox.label.text = curColorString = curColor.toHexString(false).replace("0x", "#"); + colorHexTextBox.label.text = curColorString = curColor.toWebString(); for (numStepper in rgbNumSteppers) { numStepper.label.text = Std.string(switch (numStepper.ID) { default: curColor.red; diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index 569b58dc..2087a91d 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -1,6 +1,5 @@ package funkin.game; -import haxe.xml.Printer; import flixel.util.FlxColor; import funkin.backend.FunkinSprite; import flixel.graphics.frames.FlxFrame; @@ -8,8 +7,6 @@ import flixel.math.FlxPoint; import funkin.backend.system.interfaces.IBeatReceiver; import funkin.backend.system.interfaces.IOffsetCompatible; import funkin.backend.utils.XMLUtil; -import flixel.animation.FlxBaseAnimation; -import flixel.graphics.frames.FlxAtlasFrames; import flixel.math.FlxRect; import haxe.xml.Access; import haxe.Exception; @@ -35,12 +32,6 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset public var stunned(default, set):Bool = false; - private function set_stunned(b:Bool) - { - __stunnedTime = 0; - return stunned = b; - } - public var isPlayer:Bool = false; public var isGF:Bool = false; public var curCharacter:String = 'bf'; @@ -80,10 +71,10 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset { var anims = ["singLEFT", "singDOWN", "singUP", "singRIGHT"]; - var event = EventManager.get(DirectionAnimEvent).recycle('${anims[direction]}$suffix', direction, suffix, Context, Reversed, Frame, Force); + var event = EventManager.get(DirectionAnimEvent).recycle(anims[direction] + suffix, direction, suffix, Context, Reversed, Frame, Force); script.call("onPlaySingAnim", [event]); if (!event.cancelled) - playAnim(event.animName, event.force, Context, event.reversed, event.frame); + playAnim(event.animName, event.force, event.context, event.reversed, event.frame); } public function new(x:Float, y:Float, ?character:String = "bf", isPlayer:Bool = false, switchAnims:Bool = true) @@ -250,17 +241,10 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset */ public var danceOnBeat:Bool = true; - /** - * Interval at which the character will dance (higher number = slower dance) - */ - public var danceInterval:Int = 1; - public override function beatHit(curBeat:Int) { script.call("beatHit", [curBeat]); - if (danceInterval < 1) - danceInterval = 1; - if (danceOnBeat && curBeat % danceInterval == 0 && !__lockAnimThisFrame) + if (danceOnBeat && (curBeat + beatOffset) % beatInterval == 0 && !__lockAnimThisFrame) { tryDance(); } @@ -448,7 +432,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset xml.set("flipX", Std.string(flipX)); xml.set("icon", getIcon()); if (iconColor != null) - xml.set("color", iconColor.toHexString(false).replace("0x", "#")); + xml.set("color", iconColor.toWebString()); xml.set("scale", Std.string(scale.x)); xml.set("antialiasing", antialiasing == true ? "true" : "false"); xml.set("sprite", sprite); @@ -474,6 +458,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset var offset:FlxPoint = getAnimOffset(anim.name); animXml.set("x", Std.string(offset.x)); animXml.set("y", Std.string(offset.y)); + offset.putWeak(); if (anim.indices.length > 0) animXml.set("indices", anim.indices.join(",")); xml.addChild(animXml); @@ -490,6 +475,25 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset return [for(a in xml.nodes.anim) if(a.has.name) a.att.name]; } + // Getters / Setters + + @:noCompletion private function set_stunned(b:Bool) + { + __stunnedTime = 0; + return stunned = b; + } + + // Backwards Compat + + /** + * Interval at which the character will dance (higher number = slower dance) + */ + @:noCompletion public var danceInterval(get, set):Int; + @:noCompletion private function set_danceInterval(v:Int) + return beatInterval = v; + @:noCompletion private function get_danceInterval() + return beatInterval; + // Statics public static function getIconFromCharName(?curCharacter:String) { diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index fd9b13e7..c7364225 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1846,10 +1846,10 @@ class PlayState extends MusicBeatState private inline function get_playerStrums():StrumLine return strumLines.members[1]; private inline function get_gfSpeed():Int - return (strumLines.members[2] != null && strumLines.members[2].characters[0] != null) ? strumLines.members[2].characters[0].danceInterval : 1; + return (strumLines.members[2] != null && strumLines.members[2].characters[0] != null) ? strumLines.members[2].characters[0].beatInterval : 1; private inline function set_gfSpeed(v:Int):Int { if (strumLines.members[2] != null && strumLines.members[2].characters[0] != null) - strumLines.members[2].characters[0].danceInterval = v; + strumLines.members[2].characters[0].beatInterval = v; return v; } diff --git a/source/funkin/options/OptionsTree.hx b/source/funkin/options/OptionsTree.hx index ae4d599c..c457d52e 100644 --- a/source/funkin/options/OptionsTree.hx +++ b/source/funkin/options/OptionsTree.hx @@ -53,10 +53,7 @@ class OptionsTree extends FlxTypedGroup { } public function clearLastMenu() { - if (lastMenu != null) { - lastMenu.destroy(); - lastMenu = null; - } + lastMenu = FlxDestroyUtil.destroy(lastMenu); } public override function destroy() { From b09c629b4625e5a78051ebd736a65e94a04e1b54 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Sat, 16 Mar 2024 21:53:24 +0100 Subject: [PATCH 09/19] HL fix --- source/funkin/backend/utils/MemoryUtil.hx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/funkin/backend/utils/MemoryUtil.hx b/source/funkin/backend/utils/MemoryUtil.hx index 4c0c40c0..6905d6b2 100644 --- a/source/funkin/backend/utils/MemoryUtil.hx +++ b/source/funkin/backend/utils/MemoryUtil.hx @@ -79,6 +79,8 @@ class MemoryUtil { public static inline function currentMemUsage() { #if cpp return Gc.memInfo64(Gc.MEM_INFO_USAGE); + #elseif hl + return Gc.stats().currentMemory; #elseif sys return cast(cast(System.totalMemory, UInt), Float); #else From de8882e43864c3e2084fca124c6c43c4d7cc00bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sat, 16 Mar 2024 23:02:13 +0100 Subject: [PATCH 10/19] auto intervals check and also on xml --- source/funkin/game/Character.hx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index 2087a91d..3733e7cc 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -148,9 +148,10 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset script.call("postCreate"); } - public function fixChar(switchAnims:Bool = false) + public function fixChar(switchAnims:Bool = false, autoInterval:Bool = false) { - isDanceLeftDanceRight = (hasAnimation("danceLeft") && hasAnimation("danceRight")); + if (isDanceLeftDanceRight = (hasAnimation("danceLeft") && hasAnimation("danceRight")) && autoInterval) + beatInterval = 1; // alternative to xor operator // for people who dont believe it, heres the truth table @@ -399,7 +400,10 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset if (xml.x.exists("antialiasing")) antialiasing = (xml.x.get("antialiasing") == "true"); if (xml.x.exists("sprite")) sprite = xml.x.get("sprite"); - var tempList = ["isPlayer", "isGF", "x", "y", "gameOverChar", "camx", "camy", "holdTime", "flipX", "icon", "color", "scale", "antialiasing", "sprite"]; + var hasInterval:Bool = xml.x.exists("interval"); + if (hasInterval) beatInterval = Std.parseInt(xml.x.get("interval")); + + var tempList = ["isPlayer", "isGF", "x", "y", "gameOverChar", "camx", "camy", "holdTime", "flipX", "icon", "color", "scale", "antialiasing", "sprite", "interval"]; var atts = [for (i in xml.x.attributes()) i]; for (i in atts) if (!tempList.contains(i)) { @@ -415,7 +419,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset XMLUtil.addXMLAnimation(this, anim); } - fixChar(true); + fixChar(true, !hasInterval); dance(); } From f961917b69d30e2562e3e98a62421fce56893311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sun, 17 Mar 2024 00:03:25 +0100 Subject: [PATCH 11/19] fix frozen post sing characters --- source/funkin/game/Character.hx | 37 ++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index 3733e7cc..b5c793b9 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -189,6 +189,10 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset if (__stunnedTime > 5 / 60) stunned = false; } + + if (!__lockAnimThisFrame && (lastAnimContext == SING || lastAnimContext == MISS)) + tryDance(); + __lockAnimThisFrame = false; } @@ -199,24 +203,23 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset */ public function dance() { - if (!debugMode) - { - var event = EventManager.get(DanceEvent).recycle(danced); - script.call("onDance", [event]); - if (event.cancelled) - return; + if(debugMode) return; - switch (curCharacter) - { - // hardcode custom dance animations here - default: - if (isDanceLeftDanceRight) - { - playAnim(((danced = !danced) ? 'danceLeft' : 'danceRight') + idleSuffix, DANCE); - } - else - playAnim('idle' + idleSuffix, DANCE); - } + var event = EventManager.get(DanceEvent).recycle(danced); + script.call("onDance", [event]); + if (event.cancelled) + return; + + switch (curCharacter) + { + // hardcode custom dance animations here + default: + if (isDanceLeftDanceRight) + { + playAnim(((danced = !danced) ? 'danceLeft' : 'danceRight') + idleSuffix, DANCE); + } + else + playAnim('idle' + idleSuffix, DANCE); } } From c3691c8f085dd1b211839e17c53b18e2b049a133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sun, 17 Mar 2024 01:49:23 +0100 Subject: [PATCH 12/19] clean tank stage n added the og stuff for tutorial --- assets/data/stages/tank.xml | 14 +++++++------- assets/songs/tutorial/charts/easy.json | 2 +- assets/songs/tutorial/charts/hard.json | 2 +- assets/songs/tutorial/charts/normal.json | 2 +- assets/songs/tutorial/events.json | 1 + assets/songs/tutorial/scripts/zoom.hx | 8 ++++++++ 6 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 assets/songs/tutorial/events.json create mode 100644 assets/songs/tutorial/scripts/zoom.hx diff --git a/assets/data/stages/tank.xml b/assets/data/stages/tank.xml index 7ade888d..d321e315 100644 --- a/assets/data/stages/tank.xml +++ b/assets/data/stages/tank.xml @@ -15,7 +15,7 @@ - + @@ -28,11 +28,11 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/assets/songs/tutorial/charts/easy.json b/assets/songs/tutorial/charts/easy.json index adf1e086..49a8146f 100644 --- a/assets/songs/tutorial/charts/easy.json +++ b/assets/songs/tutorial/charts/easy.json @@ -1 +1 @@ -{"events":[{"params":[1],"time":0,"type":1},{"params":[0],"time":9600,"type":1},{"params":[1],"time":14400,"type":1},{"params":[0],"time":19200,"type":1},{"params":[1],"time":24000,"type":1},{"params":[0],"time":28800,"type":1},{"params":[1],"time":33600,"type":1},{"params":[0],"time":38400,"type":1},{"params":[1],"time":43200,"type":1},{"params":[0],"time":48000,"type":1},{"params":[1],"time":50400,"type":1}],"strumLines":[{"notes":[{"id":0,"sLen":0,"time":9600,"type":0},{"id":3,"sLen":0,"time":10800,"type":0},{"id":0,"sLen":0,"time":12000,"type":0},{"id":3,"sLen":0,"time":13200,"type":0},{"id":2,"sLen":0,"time":19200,"type":0},{"id":1,"sLen":0,"time":20400,"type":0},{"id":2,"sLen":0,"time":21600,"type":0},{"id":1,"sLen":0,"time":22800,"type":0},{"id":0,"sLen":0,"time":28800,"type":0},{"id":2,"sLen":0,"time":30000,"type":0},{"id":1,"sLen":0,"time":31200,"type":0},{"id":3,"sLen":0,"time":32400,"type":0},{"id":1,"sLen":0,"time":38400,"type":0},{"id":1,"sLen":0,"time":39000,"type":0},{"id":2,"sLen":0,"time":39600,"type":0},{"id":1,"sLen":0,"time":40800,"type":0},{"id":1,"sLen":0,"time":41400,"type":0},{"id":3,"sLen":0,"time":42000,"type":0},{"id":1,"sLen":0,"time":48000,"type":0},{"id":2,"sLen":0,"time":48300,"type":0},{"id":3,"sLen":0,"time":48600,"type":0},{"id":2,"sLen":0,"time":48900,"type":0},{"id":3,"sLen":0,"time":49800,"type":0}],"position":"girlfriend","type":0,"characters":["gf"]},{"notes":[{"id":0,"sLen":0,"time":14400,"type":0},{"id":3,"sLen":0,"time":15600,"type":0},{"id":0,"sLen":0,"time":16800,"type":0},{"id":3,"sLen":0,"time":18000,"type":0},{"id":2,"sLen":0,"time":24000,"type":0},{"id":1,"sLen":0,"time":25200,"type":0},{"id":2,"sLen":0,"time":26400,"type":0},{"id":1,"sLen":0,"time":27600,"type":0},{"id":0,"sLen":0,"time":33600,"type":0},{"id":2,"sLen":0,"time":34800,"type":0},{"id":1,"sLen":0,"time":36000,"type":0},{"id":3,"sLen":0,"time":37200,"type":0},{"id":1,"sLen":0,"time":43200,"type":0},{"id":1,"sLen":0,"time":43800,"type":0},{"id":2,"sLen":0,"time":44400,"type":0},{"id":1,"sLen":0,"time":45600,"type":0},{"id":1,"sLen":0,"time":46200,"type":0},{"id":3,"sLen":0,"time":46800,"type":0},{"id":1,"sLen":0,"time":50400,"type":0},{"id":2,"sLen":0,"time":50700,"type":0},{"id":3,"sLen":0,"time":51000,"type":0},{"id":2,"sLen":0,"time":51300,"type":0},{"id":3,"sLen":0,"time":52200,"type":0},{"id":3,"sLen":0,"time":52800,"type":0},{"id":1,"sLen":0,"time":53400,"type":0},{"id":0,"sLen":0,"time":54000,"type":0},{"id":1,"sLen":0,"time":54600,"type":0},{"id":2,"sLen":0,"time":55200,"type":0},{"id":3,"sLen":0,"time":55800,"type":0},{"id":0,"sLen":0,"time":56400,"type":0},{"id":2,"sLen":0,"time":57000,"type":0},{"id":1,"sLen":750,"time":57600,"type":0}],"position":"boyfriend","type":1,"characters":["bf"]}],"codenameChart":true,"scrollSpeed":1,"noteTypes":[]} \ No newline at end of file +{"codenameChart":true,"strumLines":[{"position":"girlfriend","notes":[{"id":0,"sLen":0,"time":9600,"type":0},{"id":3,"sLen":0,"time":10800,"type":0},{"id":0,"sLen":0,"time":12000,"type":0},{"id":3,"sLen":0,"time":13200,"type":0},{"id":2,"sLen":0,"time":19200,"type":0},{"id":1,"sLen":0,"time":20400,"type":0},{"id":2,"sLen":0,"time":21600,"type":0},{"id":1,"sLen":0,"time":22800,"type":0},{"id":0,"sLen":0,"time":28800,"type":0},{"id":2,"sLen":0,"time":30000,"type":0},{"id":1,"sLen":0,"time":31200,"type":0},{"id":3,"sLen":0,"time":32400,"type":0},{"id":1,"sLen":0,"time":38400,"type":0},{"id":1,"sLen":0,"time":39000,"type":0},{"id":2,"sLen":0,"time":39600,"type":0},{"id":1,"sLen":0,"time":40800,"type":0},{"id":1,"sLen":0,"time":41400,"type":0},{"id":3,"sLen":0,"time":42000,"type":0},{"id":1,"sLen":0,"time":48000,"type":0},{"id":2,"sLen":0,"time":48300,"type":0},{"id":3,"sLen":0,"time":48600,"type":0},{"id":2,"sLen":0,"time":48900,"type":0},{"id":3,"sLen":0,"time":49800,"type":0}],"visible":true,"type":0,"characters":["gf"]},{"position":"boyfriend","notes":[{"id":0,"sLen":0,"time":14400,"type":0},{"id":3,"sLen":0,"time":15600,"type":0},{"id":0,"sLen":0,"time":16800,"type":0},{"id":3,"sLen":0,"time":18000,"type":0},{"id":2,"sLen":0,"time":24000,"type":0},{"id":1,"sLen":0,"time":25200,"type":0},{"id":2,"sLen":0,"time":26400,"type":0},{"id":1,"sLen":0,"time":27600,"type":0},{"id":0,"sLen":0,"time":33600,"type":0},{"id":2,"sLen":0,"time":34800,"type":0},{"id":1,"sLen":0,"time":36000,"type":0},{"id":3,"sLen":0,"time":37200,"type":0},{"id":1,"sLen":0,"time":43200,"type":0},{"id":1,"sLen":0,"time":43800,"type":0},{"id":2,"sLen":0,"time":44400,"type":0},{"id":1,"sLen":0,"time":45600,"type":0},{"id":1,"sLen":0,"time":46200,"type":0},{"id":3,"sLen":0,"time":46800,"type":0},{"id":1,"sLen":0,"time":50400,"type":0},{"id":2,"sLen":0,"time":50700,"type":0},{"id":3,"sLen":0,"time":51000,"type":0},{"id":2,"sLen":0,"time":51300,"type":0},{"id":3,"sLen":0,"time":52200,"type":0},{"id":3,"sLen":0,"time":52800,"type":0},{"id":1,"sLen":0,"time":53400,"type":0},{"id":0,"sLen":0,"time":54000,"type":0},{"id":1,"sLen":0,"time":54600,"type":0},{"id":2,"sLen":0,"time":55200,"type":0},{"id":3,"sLen":0,"time":55800,"type":0},{"id":0,"sLen":0,"time":56400,"type":0},{"id":2,"sLen":0,"time":57000,"type":0},{"id":1,"sLen":750,"time":57600,"type":0}],"visible":true,"type":1,"characters":["bf"]}],"scrollSpeed":1,"noteTypes":[]} \ No newline at end of file diff --git a/assets/songs/tutorial/charts/hard.json b/assets/songs/tutorial/charts/hard.json index 060a0b1f..c417029f 100644 --- a/assets/songs/tutorial/charts/hard.json +++ b/assets/songs/tutorial/charts/hard.json @@ -1 +1 @@ -{"events":[{"params":[1],"time":0,"type":1},{"params":[0],"time":9600,"type":1},{"params":[1],"time":14400,"type":1},{"params":[0],"time":19200,"type":1},{"params":[1],"time":24000,"type":1},{"params":[0],"time":28800,"type":1},{"params":[1],"time":33600,"type":1},{"params":[0],"time":38400,"type":1},{"params":[1],"time":43200,"type":1},{"params":[0],"time":48000,"type":1},{"params":[1],"time":50400,"type":1}],"strumLines":[{"notes":[{"id":0,"sLen":0,"time":9600,"type":0},{"id":3,"sLen":0,"time":10800,"type":0},{"id":0,"sLen":0,"time":12000,"type":0},{"id":3,"sLen":0,"time":13200,"type":0},{"id":2,"sLen":0,"time":19200,"type":0},{"id":1,"sLen":0,"time":20400,"type":0},{"id":2,"sLen":0,"time":21600,"type":0},{"id":1,"sLen":0,"time":22800,"type":0},{"id":0,"sLen":0,"time":28800,"type":0},{"id":2,"sLen":0,"time":30000,"type":0},{"id":1,"sLen":0,"time":31200,"type":0},{"id":3,"sLen":0,"time":32400,"type":0},{"id":1,"sLen":0,"time":38400,"type":0},{"id":1,"sLen":0,"time":39000,"type":0},{"id":2,"sLen":0,"time":39600,"type":0},{"id":1,"sLen":0,"time":40800,"type":0},{"id":1,"sLen":0,"time":41400,"type":0},{"id":3,"sLen":0,"time":42000,"type":0},{"id":1,"sLen":0,"time":48000,"type":0},{"id":2,"sLen":0,"time":48300,"type":0},{"id":3,"sLen":0,"time":48600,"type":0},{"id":2,"sLen":0,"time":48900,"type":0},{"id":3,"sLen":0,"time":49800,"type":0}],"position":"girlfriend","type":0,"characters":["gf"]},{"notes":[{"id":0,"sLen":0,"time":14400,"type":0},{"id":3,"sLen":0,"time":15600,"type":0},{"id":0,"sLen":0,"time":16800,"type":0},{"id":3,"sLen":0,"time":18000,"type":0},{"id":2,"sLen":0,"time":24000,"type":0},{"id":1,"sLen":0,"time":25200,"type":0},{"id":2,"sLen":0,"time":26400,"type":0},{"id":1,"sLen":0,"time":27600,"type":0},{"id":0,"sLen":0,"time":33600,"type":0},{"id":2,"sLen":0,"time":34800,"type":0},{"id":1,"sLen":0,"time":36000,"type":0},{"id":3,"sLen":0,"time":37200,"type":0},{"id":1,"sLen":0,"time":43200,"type":0},{"id":1,"sLen":0,"time":43800,"type":0},{"id":2,"sLen":0,"time":44400,"type":0},{"id":1,"sLen":0,"time":45600,"type":0},{"id":1,"sLen":0,"time":46200,"type":0},{"id":3,"sLen":0,"time":46800,"type":0},{"id":1,"sLen":0,"time":50400,"type":0},{"id":2,"sLen":0,"time":50700,"type":0},{"id":3,"sLen":0,"time":51000,"type":0},{"id":2,"sLen":0,"time":51300,"type":0},{"id":3,"sLen":0,"time":52200,"type":0},{"id":3,"sLen":0,"time":52800,"type":0},{"id":1,"sLen":0,"time":53400,"type":0},{"id":0,"sLen":0,"time":54000,"type":0},{"id":1,"sLen":0,"time":54600,"type":0},{"id":2,"sLen":0,"time":55200,"type":0},{"id":3,"sLen":0,"time":55800,"type":0},{"id":0,"sLen":0,"time":56400,"type":0},{"id":2,"sLen":0,"time":57000,"type":0},{"id":1,"sLen":750,"time":57600,"type":0},{"id":0,"sLen":0,"time":62400,"type":0},{"id":1,"sLen":0,"time":62550,"type":0},{"id":2,"sLen":0,"time":62700,"type":0},{"id":3,"sLen":0,"time":62850,"type":0},{"id":2,"sLen":0,"time":63000,"type":0},{"id":1,"sLen":0,"time":63150,"type":0},{"id":0,"sLen":0,"time":63300,"type":0},{"id":1,"sLen":0,"time":63450,"type":0},{"id":2,"sLen":0,"time":63600,"type":0},{"id":3,"sLen":0,"time":63750,"type":0},{"id":2,"sLen":0,"time":63900,"type":0},{"id":3,"sLen":0,"time":64050,"type":0},{"id":2,"sLen":0,"time":64200,"type":0},{"id":3,"sLen":0,"time":64350,"type":0},{"id":0,"sLen":0,"time":64650,"type":0},{"id":1,"sLen":0,"time":64500,"type":0}],"position":"boyfriend","type":1,"characters":["bf"]}],"codenameChart":true,"scrollSpeed":1,"noteTypes":[]} \ No newline at end of file +{"codenameChart":true,"strumLines":[{"position":"girlfriend","notes":[{"id":0,"sLen":0,"time":9600,"type":0},{"id":3,"sLen":0,"time":10800,"type":0},{"id":0,"sLen":0,"time":12000,"type":0},{"id":3,"sLen":0,"time":13200,"type":0},{"id":2,"sLen":0,"time":19200,"type":0},{"id":1,"sLen":0,"time":20400,"type":0},{"id":2,"sLen":0,"time":21600,"type":0},{"id":1,"sLen":0,"time":22800,"type":0},{"id":0,"sLen":0,"time":28800,"type":0},{"id":2,"sLen":0,"time":30000,"type":0},{"id":1,"sLen":0,"time":31200,"type":0},{"id":3,"sLen":0,"time":32400,"type":0},{"id":1,"sLen":0,"time":38400,"type":0},{"id":1,"sLen":0,"time":39000,"type":0},{"id":2,"sLen":0,"time":39600,"type":0},{"id":1,"sLen":0,"time":40800,"type":0},{"id":1,"sLen":0,"time":41400,"type":0},{"id":3,"sLen":0,"time":42000,"type":0},{"id":1,"sLen":0,"time":48000,"type":0},{"id":2,"sLen":0,"time":48300,"type":0},{"id":3,"sLen":0,"time":48600,"type":0},{"id":2,"sLen":0,"time":48900,"type":0},{"id":3,"sLen":0,"time":49800,"type":0}],"visible":true,"type":0,"characters":["gf"]},{"position":"boyfriend","notes":[{"id":0,"sLen":0,"time":14400,"type":0},{"id":3,"sLen":0,"time":15600,"type":0},{"id":0,"sLen":0,"time":16800,"type":0},{"id":3,"sLen":0,"time":18000,"type":0},{"id":2,"sLen":0,"time":24000,"type":0},{"id":1,"sLen":0,"time":25200,"type":0},{"id":2,"sLen":0,"time":26400,"type":0},{"id":1,"sLen":0,"time":27600,"type":0},{"id":0,"sLen":0,"time":33600,"type":0},{"id":2,"sLen":0,"time":34800,"type":0},{"id":1,"sLen":0,"time":36000,"type":0},{"id":3,"sLen":0,"time":37200,"type":0},{"id":1,"sLen":0,"time":43200,"type":0},{"id":1,"sLen":0,"time":43800,"type":0},{"id":2,"sLen":0,"time":44400,"type":0},{"id":1,"sLen":0,"time":45600,"type":0},{"id":1,"sLen":0,"time":46200,"type":0},{"id":3,"sLen":0,"time":46800,"type":0},{"id":1,"sLen":0,"time":50400,"type":0},{"id":2,"sLen":0,"time":50700,"type":0},{"id":3,"sLen":0,"time":51000,"type":0},{"id":2,"sLen":0,"time":51300,"type":0},{"id":3,"sLen":0,"time":52200,"type":0},{"id":3,"sLen":0,"time":52800,"type":0},{"id":1,"sLen":0,"time":53400,"type":0},{"id":0,"sLen":0,"time":54000,"type":0},{"id":1,"sLen":0,"time":54600,"type":0},{"id":2,"sLen":0,"time":55200,"type":0},{"id":3,"sLen":0,"time":55800,"type":0},{"id":0,"sLen":0,"time":56400,"type":0},{"id":2,"sLen":0,"time":57000,"type":0},{"id":1,"sLen":750,"time":57600,"type":0},{"id":0,"sLen":0,"time":62400,"type":0},{"id":1,"sLen":0,"time":62550,"type":0},{"id":2,"sLen":0,"time":62700,"type":0},{"id":3,"sLen":0,"time":62850,"type":0},{"id":2,"sLen":0,"time":63000,"type":0},{"id":1,"sLen":0,"time":63150,"type":0},{"id":0,"sLen":0,"time":63300,"type":0},{"id":1,"sLen":0,"time":63450,"type":0},{"id":2,"sLen":0,"time":63600,"type":0},{"id":3,"sLen":0,"time":63750,"type":0},{"id":2,"sLen":0,"time":63900,"type":0},{"id":3,"sLen":0,"time":64050,"type":0},{"id":2,"sLen":0,"time":64200,"type":0},{"id":3,"sLen":0,"time":64350,"type":0},{"id":1,"sLen":0,"time":64500,"type":0},{"id":0,"sLen":0,"time":64650,"type":0}],"visible":true,"type":1,"characters":["bf"]}],"scrollSpeed":1,"noteTypes":[]} \ No newline at end of file diff --git a/assets/songs/tutorial/charts/normal.json b/assets/songs/tutorial/charts/normal.json index adf1e086..49a8146f 100644 --- a/assets/songs/tutorial/charts/normal.json +++ b/assets/songs/tutorial/charts/normal.json @@ -1 +1 @@ -{"events":[{"params":[1],"time":0,"type":1},{"params":[0],"time":9600,"type":1},{"params":[1],"time":14400,"type":1},{"params":[0],"time":19200,"type":1},{"params":[1],"time":24000,"type":1},{"params":[0],"time":28800,"type":1},{"params":[1],"time":33600,"type":1},{"params":[0],"time":38400,"type":1},{"params":[1],"time":43200,"type":1},{"params":[0],"time":48000,"type":1},{"params":[1],"time":50400,"type":1}],"strumLines":[{"notes":[{"id":0,"sLen":0,"time":9600,"type":0},{"id":3,"sLen":0,"time":10800,"type":0},{"id":0,"sLen":0,"time":12000,"type":0},{"id":3,"sLen":0,"time":13200,"type":0},{"id":2,"sLen":0,"time":19200,"type":0},{"id":1,"sLen":0,"time":20400,"type":0},{"id":2,"sLen":0,"time":21600,"type":0},{"id":1,"sLen":0,"time":22800,"type":0},{"id":0,"sLen":0,"time":28800,"type":0},{"id":2,"sLen":0,"time":30000,"type":0},{"id":1,"sLen":0,"time":31200,"type":0},{"id":3,"sLen":0,"time":32400,"type":0},{"id":1,"sLen":0,"time":38400,"type":0},{"id":1,"sLen":0,"time":39000,"type":0},{"id":2,"sLen":0,"time":39600,"type":0},{"id":1,"sLen":0,"time":40800,"type":0},{"id":1,"sLen":0,"time":41400,"type":0},{"id":3,"sLen":0,"time":42000,"type":0},{"id":1,"sLen":0,"time":48000,"type":0},{"id":2,"sLen":0,"time":48300,"type":0},{"id":3,"sLen":0,"time":48600,"type":0},{"id":2,"sLen":0,"time":48900,"type":0},{"id":3,"sLen":0,"time":49800,"type":0}],"position":"girlfriend","type":0,"characters":["gf"]},{"notes":[{"id":0,"sLen":0,"time":14400,"type":0},{"id":3,"sLen":0,"time":15600,"type":0},{"id":0,"sLen":0,"time":16800,"type":0},{"id":3,"sLen":0,"time":18000,"type":0},{"id":2,"sLen":0,"time":24000,"type":0},{"id":1,"sLen":0,"time":25200,"type":0},{"id":2,"sLen":0,"time":26400,"type":0},{"id":1,"sLen":0,"time":27600,"type":0},{"id":0,"sLen":0,"time":33600,"type":0},{"id":2,"sLen":0,"time":34800,"type":0},{"id":1,"sLen":0,"time":36000,"type":0},{"id":3,"sLen":0,"time":37200,"type":0},{"id":1,"sLen":0,"time":43200,"type":0},{"id":1,"sLen":0,"time":43800,"type":0},{"id":2,"sLen":0,"time":44400,"type":0},{"id":1,"sLen":0,"time":45600,"type":0},{"id":1,"sLen":0,"time":46200,"type":0},{"id":3,"sLen":0,"time":46800,"type":0},{"id":1,"sLen":0,"time":50400,"type":0},{"id":2,"sLen":0,"time":50700,"type":0},{"id":3,"sLen":0,"time":51000,"type":0},{"id":2,"sLen":0,"time":51300,"type":0},{"id":3,"sLen":0,"time":52200,"type":0},{"id":3,"sLen":0,"time":52800,"type":0},{"id":1,"sLen":0,"time":53400,"type":0},{"id":0,"sLen":0,"time":54000,"type":0},{"id":1,"sLen":0,"time":54600,"type":0},{"id":2,"sLen":0,"time":55200,"type":0},{"id":3,"sLen":0,"time":55800,"type":0},{"id":0,"sLen":0,"time":56400,"type":0},{"id":2,"sLen":0,"time":57000,"type":0},{"id":1,"sLen":750,"time":57600,"type":0}],"position":"boyfriend","type":1,"characters":["bf"]}],"codenameChart":true,"scrollSpeed":1,"noteTypes":[]} \ No newline at end of file +{"codenameChart":true,"strumLines":[{"position":"girlfriend","notes":[{"id":0,"sLen":0,"time":9600,"type":0},{"id":3,"sLen":0,"time":10800,"type":0},{"id":0,"sLen":0,"time":12000,"type":0},{"id":3,"sLen":0,"time":13200,"type":0},{"id":2,"sLen":0,"time":19200,"type":0},{"id":1,"sLen":0,"time":20400,"type":0},{"id":2,"sLen":0,"time":21600,"type":0},{"id":1,"sLen":0,"time":22800,"type":0},{"id":0,"sLen":0,"time":28800,"type":0},{"id":2,"sLen":0,"time":30000,"type":0},{"id":1,"sLen":0,"time":31200,"type":0},{"id":3,"sLen":0,"time":32400,"type":0},{"id":1,"sLen":0,"time":38400,"type":0},{"id":1,"sLen":0,"time":39000,"type":0},{"id":2,"sLen":0,"time":39600,"type":0},{"id":1,"sLen":0,"time":40800,"type":0},{"id":1,"sLen":0,"time":41400,"type":0},{"id":3,"sLen":0,"time":42000,"type":0},{"id":1,"sLen":0,"time":48000,"type":0},{"id":2,"sLen":0,"time":48300,"type":0},{"id":3,"sLen":0,"time":48600,"type":0},{"id":2,"sLen":0,"time":48900,"type":0},{"id":3,"sLen":0,"time":49800,"type":0}],"visible":true,"type":0,"characters":["gf"]},{"position":"boyfriend","notes":[{"id":0,"sLen":0,"time":14400,"type":0},{"id":3,"sLen":0,"time":15600,"type":0},{"id":0,"sLen":0,"time":16800,"type":0},{"id":3,"sLen":0,"time":18000,"type":0},{"id":2,"sLen":0,"time":24000,"type":0},{"id":1,"sLen":0,"time":25200,"type":0},{"id":2,"sLen":0,"time":26400,"type":0},{"id":1,"sLen":0,"time":27600,"type":0},{"id":0,"sLen":0,"time":33600,"type":0},{"id":2,"sLen":0,"time":34800,"type":0},{"id":1,"sLen":0,"time":36000,"type":0},{"id":3,"sLen":0,"time":37200,"type":0},{"id":1,"sLen":0,"time":43200,"type":0},{"id":1,"sLen":0,"time":43800,"type":0},{"id":2,"sLen":0,"time":44400,"type":0},{"id":1,"sLen":0,"time":45600,"type":0},{"id":1,"sLen":0,"time":46200,"type":0},{"id":3,"sLen":0,"time":46800,"type":0},{"id":1,"sLen":0,"time":50400,"type":0},{"id":2,"sLen":0,"time":50700,"type":0},{"id":3,"sLen":0,"time":51000,"type":0},{"id":2,"sLen":0,"time":51300,"type":0},{"id":3,"sLen":0,"time":52200,"type":0},{"id":3,"sLen":0,"time":52800,"type":0},{"id":1,"sLen":0,"time":53400,"type":0},{"id":0,"sLen":0,"time":54000,"type":0},{"id":1,"sLen":0,"time":54600,"type":0},{"id":2,"sLen":0,"time":55200,"type":0},{"id":3,"sLen":0,"time":55800,"type":0},{"id":0,"sLen":0,"time":56400,"type":0},{"id":2,"sLen":0,"time":57000,"type":0},{"id":1,"sLen":750,"time":57600,"type":0}],"visible":true,"type":1,"characters":["bf"]}],"scrollSpeed":1,"noteTypes":[]} \ No newline at end of file diff --git a/assets/songs/tutorial/events.json b/assets/songs/tutorial/events.json new file mode 100644 index 00000000..a97b4b89 --- /dev/null +++ b/assets/songs/tutorial/events.json @@ -0,0 +1 @@ +{"events":[{"params":[1],"name":"Camera Movement","time":0},{"params":[0],"name":"Camera Movement","time":9600},{"params":[1],"name":"Camera Movement","time":14400},{"params":[0,"cheer"],"name":"Play Animation","time":18000},{"params":[1,"hey"],"name":"Play Animation","time":18600},{"params":[0],"name":"Camera Movement","time":19200},{"params":[1],"name":"Camera Movement","time":24000},{"params":[0,"cheer"],"time":27600,"name":"Play Animation"},{"params":[1,"hey"],"time":28200,"name":"Play Animation"},{"params":[0],"name":"Camera Movement","time":28800},{"params":[1],"name":"Camera Movement","time":33600},{"params":[0],"name":"Camera Movement","time":38400},{"params":[1],"name":"Camera Movement","time":43200},{"params":[0],"name":"Camera Movement","time":48000},{"params":[1],"name":"Camera Movement","time":50400}]} \ No newline at end of file diff --git a/assets/songs/tutorial/scripts/zoom.hx b/assets/songs/tutorial/scripts/zoom.hx new file mode 100644 index 00000000..0f7e37ac --- /dev/null +++ b/assets/songs/tutorial/scripts/zoom.hx @@ -0,0 +1,8 @@ +var lastFocused:Int = null; +var zoomin:FlxTween = null; + +function onNoteHit(event) + event.enableCamZooming = false; + +function onCameraMove(_) if(zoomin == null && lastFocused != (lastFocused = curCameraTarget)) + zoomin = FlxTween.tween(FlxG.camera, {zoom: curCameraTarget == 0 ? 1.3 : 1}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut, onComplete: function(_) zoomin = null}); \ No newline at end of file From 3de8fcc8040db23cd4e82c3e52a72204f2e8e68e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sun, 17 Mar 2024 18:00:18 +0100 Subject: [PATCH 13/19] bugfix for loading deleted mods + safe saves --- source/funkin/backend/assets/ModsFolder.hx | 23 +++++++++++++++++-- source/funkin/backend/chart/Chart.hx | 4 ++-- source/funkin/backend/system/Main.hx | 2 +- source/funkin/backend/utils/CoolUtil.hx | 16 +++++++++++++ source/funkin/editors/SaveSubstate.hx | 16 ++----------- .../editors/character/CharacterEditor.hx | 6 ++--- source/funkin/editors/charter/Charter.hx | 12 +++++----- .../editors/charter/CharterSelection.hx | 8 +++---- source/funkin/menus/MainMenuState.hx | 4 +--- source/funkin/menus/ModSwitchMenu.hx | 14 +---------- 10 files changed, 56 insertions(+), 49 deletions(-) diff --git a/source/funkin/backend/assets/ModsFolder.hx b/source/funkin/backend/assets/ModsFolder.hx index a88377ad..cd1704ed 100644 --- a/source/funkin/backend/assets/ModsFolder.hx +++ b/source/funkin/backend/assets/ModsFolder.hx @@ -51,10 +51,11 @@ class ModsFolder { */ private static var __firstTime:Bool = true; /** - * Initialises `mods` folder by adding callbacks and such. + * Initialises `mods` folder. */ public static function init() { - + if(!getModsList().contains(Options.lastLoadedMod)) + Options.lastLoadedMod = null; } /** @@ -89,6 +90,24 @@ class ModsFolder { #end } + public static function getModsList():Array { + var mods:Array = []; + #if MOD_SUPPORT + for(modFolder in FileSystem.readDirectory(modsPath)) { + if (FileSystem.isDirectory('${modsPath}${modFolder}')) { + mods.push(modFolder); + } else { + var ext = Path.extension(modFolder).toLowerCase(); + switch(ext) { + case 'zip': + // is a zip mod!! + mods.push(Path.withoutExtension(modFolder)); + } + } + } + #end + return mods; + } public static function getLoadedMods():Array { var libs = []; for (i in Paths.assetsTree.libraries) { diff --git a/source/funkin/backend/chart/Chart.hx b/source/funkin/backend/chart/Chart.hx index d18640bb..e7a2c2a4 100644 --- a/source/funkin/backend/chart/Chart.hx +++ b/source/funkin/backend/chart/Chart.hx @@ -206,11 +206,11 @@ class Chart { var chartPath = '${songFolderPath}/charts/${difficulty.trim()}.json'; var metaPath = '${songFolderPath}/meta.json'; - File.saveContent(chartPath, Json.stringify(filteredChart, null, saveSettings.prettyPrint == true ? "\t" : null)); + CoolUtil.safeSaveFile(chartPath, Json.stringify(filteredChart, null, saveSettings.prettyPrint == true ? "\t" : null)); // idk how null reacts to it so better be sure if (saveSettings.overrideExistingMeta == true || !FileSystem.exists(metaPath)) - File.saveContent(metaPath, Json.stringify(meta, null, saveSettings.prettyPrint == true ? "\t" : null)); + CoolUtil.safeSaveFile(metaPath, Json.stringify(meta, null, saveSettings.prettyPrint == true ? "\t" : null)); #end return filteredChart; } diff --git a/source/funkin/backend/system/Main.hx b/source/funkin/backend/system/Main.hx index 87bd26d8..d04d4f3d 100644 --- a/source/funkin/backend/system/Main.hx +++ b/source/funkin/backend/system/Main.hx @@ -120,7 +120,6 @@ class Main extends Sprite ShaderResizeFix.init(); Logs.init(); Paths.init(); - ModsFolder.init(); DiscordUtil.init(); #if GLOBAL_SCRIPT funkin.backend.scripting.GlobalScript.init(); @@ -159,6 +158,7 @@ class Main extends Sprite FlxG.mouse.useSystemCursor = true; + ModsFolder.init(); #if MOD_SUPPORT ModsFolder.switchMod(modToLoad.getDefault(Options.lastLoadedMod)); #end diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index 261e85f7..8bf1a167 100644 --- a/source/funkin/backend/utils/CoolUtil.hx +++ b/source/funkin/backend/utils/CoolUtil.hx @@ -77,6 +77,22 @@ class CoolUtil #end } + /** + * Safe saves a file and shows a warning box instead of making the program crash + * @param path Path to save the file at. + * @param data Content of the file to save. + */ + @:noUsing public static function safeSaveFile(path:String, content:String, showErrorBox:Bool = true) { + #if sys + try sys.io.File.saveContent(path, content) + catch(e) { + var errMsg:String = 'Error while trying to save the file: ${Std.string(e).replace('\n', ' ')}'; + Logs.traceColored([Logs.logText(errMsg, RED)], ERROR); + if(showErrorBox) funkin.backend.utils.NativeAPI.showMessageBox("Codename Engine Warning", errMsg, MSG_WARNING); + } + #end + } + /** * Shortcut to parse a JSON string * @param str Path to the JSON string diff --git a/source/funkin/editors/SaveSubstate.hx b/source/funkin/editors/SaveSubstate.hx index 6250050a..7202cf37 100644 --- a/source/funkin/editors/SaveSubstate.hx +++ b/source/funkin/editors/SaveSubstate.hx @@ -1,8 +1,5 @@ package funkin.editors; -#if desktop -import sys.io.File; -#end import haxe.io.Path; import lime.ui.FileDialog; @@ -30,13 +27,9 @@ class SaveSubstate extends MusicBeatSubstate { super.create(); var fileDialog = new FileDialog(); - fileDialog.onCancel.add(function() { - close(); - }); + fileDialog.onCancel.add(function() close()); fileDialog.onSelect.add(function(str) { - #if desktop - File.saveContent(str, data); - #end + CoolUtil.safeSaveFile(str, data); close(); }); fileDialog.browse(SAVE, options.saveExt.getDefault(Path.extension(options.defaultSaveFile)), options.defaultSaveFile); @@ -46,11 +39,6 @@ class SaveSubstate extends MusicBeatSubstate { super.update(elapsed); parent.persistentUpdate = false; } - - private function onError(_) { - // TODO: error handling - close(); - } } typedef SaveSubstateData = { diff --git a/source/funkin/editors/character/CharacterEditor.hx b/source/funkin/editors/character/CharacterEditor.hx index 3fb76ed0..8c5cf9c7 100644 --- a/source/funkin/editors/character/CharacterEditor.hx +++ b/source/funkin/editors/character/CharacterEditor.hx @@ -328,14 +328,14 @@ class CharacterEditor extends UIState { function _file_save(_) { #if sys - sys.io.File.saveContent( + CoolUtil.safeSaveFile( '${Paths.getAssetsRoot()}/data/characters/${character.curCharacter}.xml', buildCharacter() ); undos.save(); - return; - #end + #else _file_saveas(_); + #end } function _file_saveas(_) { diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 376488a6..8b08b4b8 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1165,13 +1165,13 @@ class Charter extends UIState { function _file_meta_save(_) { #if sys - sys.io.File.saveContent( + CoolUtil.safeSaveFile( '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/meta.json', Json.stringify(PlayState.SONG.meta == null ? {} : PlayState.SONG.meta, null, "\t") ); - return; - #end + #else _file_meta_saveas(_); + #end } function _file_meta_saveas(_) { @@ -1182,13 +1182,13 @@ class Charter extends UIState { function _file_events_save(_) { #if sys - sys.io.File.saveContent( + CoolUtil.safeSaveFile( '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/events.json', Json.stringify({events: PlayState.SONG.events == null ? [] : PlayState.SONG.events}) ); - return; - #end + #else _file_events_saveas(_); + #end } function _file_events_saveas(_) { diff --git a/source/funkin/editors/charter/CharterSelection.hx b/source/funkin/editors/charter/CharterSelection.hx index f9a1ea5e..b0957997 100644 --- a/source/funkin/editors/charter/CharterSelection.hx +++ b/source/funkin/editors/charter/CharterSelection.hx @@ -107,7 +107,7 @@ class CharterSelection extends EditorTreeMenu { sys.FileSystem.createDirectory('$songFolder/charts'); // Save Files - sys.io.File.saveContent('$songFolder/meta.json', Json.stringify(creation.meta, "\t")); + CoolUtil.safeSaveFile('$songFolder/meta.json', Json.stringify(creation.meta, "\t")); if (creation.instBytes != null) sys.io.File.saveBytes('$songFolder/song/Inst.${Paths.SOUND_EXT}', creation.instBytes); if (creation.voicesBytes != null) sys.io.File.saveBytes('$songFolder/song/Voices.${Paths.SOUND_EXT}', creation.voicesBytes); #end @@ -145,9 +145,7 @@ class CharterSelection extends EditorTreeMenu { var songFolder:String = '${Paths.getAssetsRoot()}/songs/${curSong.name}'; // Save Files - #if sys - sys.io.File.saveContent('$songFolder/charts/${name}.json', Json.stringify(data, "\t")); - #end + CoolUtil.safeSaveFile('$songFolder/charts/${name}.json', Json.stringify(data, "\t")); // Add to List curSong.difficulties.push(name); @@ -160,7 +158,7 @@ class CharterSelection extends EditorTreeMenu { var meta = Json.parse(sys.io.File.getContent('$songFolder/meta.json')); if (meta.difficulties != null && !meta.difficulties.contains(name)) { meta.difficulties.push(name); - sys.io.File.saveContent('$songFolder/meta.json', Json.stringify(meta)); + CoolUtil.safeSaveFile('$songFolder/meta.json', Json.stringify(meta)); } } } \ No newline at end of file diff --git a/source/funkin/menus/MainMenuState.hx b/source/funkin/menus/MainMenuState.hx index 7744564b..03e3bd8b 100644 --- a/source/funkin/menus/MainMenuState.hx +++ b/source/funkin/menus/MainMenuState.hx @@ -101,9 +101,7 @@ class MainMenuState extends MusicBeatState if (FlxG.keys.justPressed.SEVEN) FlxG.switchState(new funkin.desktop.DesktopMain()); if (FlxG.keys.justPressed.EIGHT) { - #if sys - sys.io.File.saveContent("chart.json", Json.stringify(funkin.backend.chart.Chart.parse("dadbattle", "hard"))); - #end + CoolUtil.safeSaveFile("chart.json", Json.stringify(funkin.backend.chart.Chart.parse("dadbattle", "hard"))); } */ } diff --git a/source/funkin/menus/ModSwitchMenu.hx b/source/funkin/menus/ModSwitchMenu.hx index 51509ebc..1b23b9d2 100644 --- a/source/funkin/menus/ModSwitchMenu.hx +++ b/source/funkin/menus/ModSwitchMenu.hx @@ -22,19 +22,7 @@ class ModSwitchMenu extends MusicBeatSubstate { bg.alpha = 0; FlxTween.tween(bg, {alpha: 0.5}, 0.25, {ease: FlxEase.cubeOut}); - for(modFolder in FileSystem.readDirectory(ModsFolder.modsPath)) { - if (FileSystem.isDirectory('${ModsFolder.modsPath}${modFolder}')) { - mods.push(modFolder); - } else { - var ext = Path.extension(modFolder).toLowerCase(); - switch(ext) { - case 'zip': - // is a zip mod!! - mods.push(Path.withoutExtension(modFolder)); - } - } - } - + mods = ModsFolder.getModsList(); mods.push(null); alphabets = new FlxTypedGroup(); From 69c9030b9ccfdcc7b284d955e8c7cd735502923f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sun, 17 Mar 2024 18:24:44 +0100 Subject: [PATCH 14/19] once again safer savings Co-Authored-By: Ne_Eo --- source/funkin/backend/utils/CoolUtil.hx | 27 +++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index 8bf1a167..66858865 100644 --- a/source/funkin/backend/utils/CoolUtil.hx +++ b/source/funkin/backend/utils/CoolUtil.hx @@ -78,13 +78,13 @@ class CoolUtil } /** - * Safe saves a file and shows a warning box instead of making the program crash + * Safe saves a file (even adding missing folder) and shows a warning box instead of making the program crash * @param path Path to save the file at. * @param data Content of the file to save. */ @:noUsing public static function safeSaveFile(path:String, content:String, showErrorBox:Bool = true) { #if sys - try sys.io.File.saveContent(path, content) + try sys.io.File.saveContent(addMissingFolders(path), content) catch(e) { var errMsg:String = 'Error while trying to save the file: ${Std.string(e).replace('\n', ' ')}'; Logs.traceColored([Logs.logText(errMsg, RED)], ERROR); @@ -93,6 +93,29 @@ class CoolUtil #end } + /** + * Creates eventual missing folders to the specified `path` + * + * WARNING: eventual files in `path` will be considered as folders! Just to make possible folders be named as `songs.json` for example + * + * @param path Path to check. + * @return The initial Path. + */ + @:noUsing public static function addMissingFolders(path:String):String { + #if sys + var folders:Array = path.split("/"); + var currentPath:String = ""; + + for (folder in folders) { + currentPath += folder + "/"; + if (!sys.FileSystem.exists(currentPath)) { + sys.FileSystem.createDirectory(currentPath); + } + } + #end + return path; + } + /** * Shortcut to parse a JSON string * @param str Path to the JSON string From b87e3f79f7256440a04b3d3892eaedda77843dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sun, 17 Mar 2024 19:16:37 +0100 Subject: [PATCH 15/19] safeSaveFile for both strings and bytes Co-Authored-By: Ne_Eo --- source/funkin/backend/utils/CoolUtil.hx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index 66858865..4817bf5d 100644 --- a/source/funkin/backend/utils/CoolUtil.hx +++ b/source/funkin/backend/utils/CoolUtil.hx @@ -2,6 +2,7 @@ package funkin.backend.utils; import flixel.text.FlxText; import funkin.backend.utils.XMLUtil.TextFormat; +import flixel.util.typeLimit.OneOfTwo; import flixel.tweens.FlxTween; import flixel.system.frontEnds.SoundFrontEnd; import flixel.sound.FlxSound; @@ -9,6 +10,7 @@ import funkin.backend.system.Conductor; import flixel.sound.FlxSoundGroup; import haxe.Json; import haxe.io.Path; +import haxe.io.Bytes; import haxe.xml.Access; import flixel.input.keyboard.FlxKey; import lime.utils.Assets; @@ -78,14 +80,17 @@ class CoolUtil } /** - * Safe saves a file (even adding missing folder) and shows a warning box instead of making the program crash + * Safe saves a file (even adding eventual missing folders) and shows a warning box instead of making the program crash * @param path Path to save the file at. - * @param data Content of the file to save. + * @param content Content of the file to save (as String or Bytes). */ - @:noUsing public static function safeSaveFile(path:String, content:String, showErrorBox:Bool = true) { + @:noUsing public static function safeSaveFile(path:String, content:OneOfTwo, showErrorBox:Bool = true) { #if sys - try sys.io.File.saveContent(addMissingFolders(path), content) - catch(e) { + try { + addMissingFolders(Path.directory(path)); + if(content is Bytes) sys.io.File.saveBytes(path, content); + else sys.io.File.saveContent(path, content); + } catch(e) { var errMsg:String = 'Error while trying to save the file: ${Std.string(e).replace('\n', ' ')}'; Logs.traceColored([Logs.logText(errMsg, RED)], ERROR); if(showErrorBox) funkin.backend.utils.NativeAPI.showMessageBox("Codename Engine Warning", errMsg, MSG_WARNING); From e8403d72a115acd3800da5e05343cbf124aabba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:45:51 +0100 Subject: [PATCH 16/19] last fix for freezing animations (i hope) --- assets/data/stages/limo.xml | 10 +++++----- assets/data/stages/mall.xml | 6 +++--- source/funkin/game/Character.hx | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/assets/data/stages/limo.xml b/assets/data/stages/limo.xml index b223b357..a0dafd89 100644 --- a/assets/data/stages/limo.xml +++ b/assets/data/stages/limo.xml @@ -7,23 +7,23 @@ - + - + - + - + - + diff --git a/assets/data/stages/mall.xml b/assets/data/stages/mall.xml index 0edfa942..3552cf27 100644 --- a/assets/data/stages/mall.xml +++ b/assets/data/stages/mall.xml @@ -3,15 +3,15 @@ - + - + - + diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index b5c793b9..68cfa627 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -190,7 +190,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset stunned = false; } - if (!__lockAnimThisFrame && (lastAnimContext == SING || lastAnimContext == MISS)) + if (!__lockAnimThisFrame && lastAnimContext != DANCE) tryDance(); __lockAnimThisFrame = false; From 72db6e1a6e69d839d4232f66cc2c7546b6a3e800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Mon, 18 Mar 2024 00:35:58 +0100 Subject: [PATCH 17/19] removed that goddamn terminal opening at the start --- source/funkin/backend/system/MainState.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/backend/system/MainState.hx b/source/funkin/backend/system/MainState.hx index 9a1502cd..e8192fc1 100644 --- a/source/funkin/backend/system/MainState.hx +++ b/source/funkin/backend/system/MainState.hx @@ -68,7 +68,7 @@ class MainState extends FlxState { #if sys sys.FileSystem.createDirectory('./.temp/'); - #if windows Sys.command("attrib +h .temp"); #end + #if windows new funkin.backend.utils.native.HiddenProcess("attrib +h .temp"); #end #end } } \ No newline at end of file From 16bd618ca8940b5187eb3ee5bf8adb6a529d0356 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Tue, 19 Mar 2024 00:30:21 +0100 Subject: [PATCH 18/19] Forgot to save these files --- source/funkin/backend/chart/ChartData.hx | 3 +-- source/funkin/editors/charter/CharterStrumlineButton.hx | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/source/funkin/backend/chart/ChartData.hx b/source/funkin/backend/chart/ChartData.hx index fc293475..c46164f5 100644 --- a/source/funkin/backend/chart/ChartData.hx +++ b/source/funkin/backend/chart/ChartData.hx @@ -59,8 +59,7 @@ typedef ChartEvent = { var params:Array; } -@:enum -abstract ChartStrumLineType(Int) from Int to Int { +enum abstract ChartStrumLineType(Int) from Int to Int { /** * STRUMLINE IS MARKED AS OPPONENT - WILL BE PLAYED BY CPU, OR PLAYED BY PLAYER IF OPPONENT MODE IS ON */ diff --git a/source/funkin/editors/charter/CharterStrumlineButton.hx b/source/funkin/editors/charter/CharterStrumlineButton.hx index 2a6fd184..b132dab1 100644 --- a/source/funkin/editors/charter/CharterStrumlineButton.hx +++ b/source/funkin/editors/charter/CharterStrumlineButton.hx @@ -62,7 +62,7 @@ class CharterStrumlineButton extends UISprite { if(UIState.state.isOverlapping(button, button.__rect)) { buttonScale.set(0.95, 0.95); if (FlxG.mouse.justReleased && onClick != null) { - onClick(); + onClick(); if (animationOnClick) pressAnimation(); } } @@ -96,7 +96,7 @@ class CharterStrumlineButton extends UISprite { scaleTween = FlxTween.tween(buttonScaleOffset, {x: .015 * (extra ? 3 : 1), y: .02 * (extra ? 3 : 1)}, .12, {ease: FlxEase.circOut}) .then(FlxTween.tween(buttonScaleOffset, {x: 0, y: 0}, .1 + FlxG.random.float(.1, .3), {ease: FlxEase.circIn})); - if (!extra) return; + if (!extra) return; if (angleTween != null) angleTween.cancel(); button.angle = 0; angleTween = FlxTween.tween(button, {angle: 360}, .5, {ease: FlxEase.circInOut}); From e95e1d3dfa0c63519d6b1d3a5c6f4f572fbfbe5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Tue, 19 Mar 2024 02:31:27 +0100 Subject: [PATCH 19/19] bugfix for +1 pixel when shaders (openfl objs) NO MORE THAT GODDAMN +1 PIXEL ON CAMERAS WITH SHADERS --- .../openfl/display/DisplayObjectRenderer.hx | 864 ++++++++++++++++++ 1 file changed, 864 insertions(+) create mode 100644 source/openfl/display/DisplayObjectRenderer.hx diff --git a/source/openfl/display/DisplayObjectRenderer.hx b/source/openfl/display/DisplayObjectRenderer.hx new file mode 100644 index 00000000..f25e330d --- /dev/null +++ b/source/openfl/display/DisplayObjectRenderer.hx @@ -0,0 +1,864 @@ +package openfl.display; + +#if !flash +import openfl.display._internal.Context3DGraphics; +import openfl.display.Bitmap; +import openfl.display.DisplayObject; +import openfl.display.Tilemap; +import openfl.events.EventDispatcher; +import openfl.events.RenderEvent; +import openfl.geom.ColorTransform; +import openfl.geom.Matrix; +import openfl.geom.Point; +import openfl.geom.Rectangle; +import openfl.text.TextField; +#if lime +import lime._internal.graphics.ImageCanvasUtil; // TODO +import lime.graphics.cairo.Cairo; +import lime.graphics.RenderContext; +import lime.graphics.RenderContextType; +#end + +#if !openfl_debug +@:fileXml('tags="haxe,release"') +@:noDebug +#end +@:access(openfl.display._internal.Context3DGraphics) +@:access(lime.graphics.ImageBuffer) +@:access(openfl.display.Bitmap) +@:access(openfl.display.BitmapData) +@:access(openfl.display.DisplayObject) +@:access(openfl.display.Graphics) +@:access(openfl.display.Tilemap) +@:access(openfl.display3D.Context3D) +@:access(openfl.events.RenderEvent) +@:access(openfl.filters.BitmapFilter) +@:access(openfl.geom.ColorTransform) +@:access(openfl.geom.Rectangle) +@:access(openfl.geom.Transform) +@:access(openfl.text.TextField) +@:allow(openfl.display._internal) +@:allow(openfl.display) +@:allow(openfl.text) +class DisplayObjectRenderer extends EventDispatcher +{ + @:noCompletion private var __allowSmoothing:Bool; + @:noCompletion private var __blendMode:BlendMode; + @:noCompletion private var __cleared:Bool; + @SuppressWarnings("checkstyle:Dynamic") @:noCompletion private var __context:#if lime RenderContext #else Dynamic #end; + @:noCompletion private var __overrideBlendMode:BlendMode; + @:noCompletion private var __pixelRatio:Float; + @:noCompletion private var __roundPixels:Bool; + @:noCompletion private var __stage:Stage; + @:noCompletion private var __tempColorTransform:ColorTransform; + @:noCompletion private var __transparent:Bool; + @SuppressWarnings("checkstyle:Dynamic") @:noCompletion private var __type:#if lime RenderContextType #else Dynamic #end; + @:noCompletion private var __worldAlpha:Float; + @:noCompletion private var __worldColorTransform:ColorTransform; + @:noCompletion private var __worldTransform:Matrix; + + @:noCompletion private function new() + { + super(); + + __allowSmoothing = true; + __pixelRatio = 1; + __tempColorTransform = new ColorTransform(); + __worldAlpha = 1; + } + + @:noCompletion private function __clear():Void {} + + @:noCompletion private function __getAlpha(value:Float):Float + { + return value * __worldAlpha; + } + + @:noCompletion private function __getColorTransform(value:ColorTransform):ColorTransform + { + if (__worldColorTransform != null) + { + __tempColorTransform.__copyFrom(__worldColorTransform); + __tempColorTransform.__combine(value); + return __tempColorTransform; + } + else + { + return value; + } + } + + @:noCompletion private function __popMask():Void {} + + @:noCompletion private function __popMaskObject(object:DisplayObject, handleScrollRect:Bool = true):Void {} + + @:noCompletion private function __popMaskRect():Void {} + + @:noCompletion private function __pushMask(mask:DisplayObject):Void {} + + @:noCompletion private function __pushMaskObject(object:DisplayObject, handleScrollRect:Bool = true):Void {} + + @:noCompletion private function __pushMaskRect(rect:Rectangle, transform:Matrix):Void {} + + @:noCompletion private function __render(object:IBitmapDrawable):Void {} + + @:noCompletion private function __renderEvent(displayObject:DisplayObject):Void + { + var renderer = this; + #if lime + if (displayObject.__customRenderEvent != null && displayObject.__renderable) + { + displayObject.__customRenderEvent.allowSmoothing = renderer.__allowSmoothing; + displayObject.__customRenderEvent.objectMatrix.copyFrom(displayObject.__renderTransform); + displayObject.__customRenderEvent.objectColorTransform.__copyFrom(displayObject.__worldColorTransform); + displayObject.__customRenderEvent.renderer = renderer; + + switch (renderer.__type) + { + case OPENGL: + if (!renderer.__cleared) renderer.__clear(); + + var renderer:OpenGLRenderer = cast renderer; + renderer.setShader(displayObject.__worldShader); + renderer.__context3D.__flushGL(); + + displayObject.__customRenderEvent.type = RenderEvent.RENDER_OPENGL; + + case CAIRO: + displayObject.__customRenderEvent.type = RenderEvent.RENDER_CAIRO; + + case DOM: + if (displayObject.stage != null && displayObject.__worldVisible) + { + displayObject.__customRenderEvent.type = RenderEvent.RENDER_DOM; + } + else + { + displayObject.__customRenderEvent.type = RenderEvent.CLEAR_DOM; + } + + case CANVAS: + displayObject.__customRenderEvent.type = RenderEvent.RENDER_CANVAS; + + default: + return; + } + + renderer.__setBlendMode(displayObject.__worldBlendMode); + renderer.__pushMaskObject(displayObject); + + displayObject.dispatchEvent(displayObject.__customRenderEvent); + + renderer.__popMaskObject(displayObject); + + if (renderer.__type == OPENGL) + { + var renderer:OpenGLRenderer = cast renderer; + renderer.setViewport(); + } + } + #end + } + + @:noCompletion private function __resize(width:Int, height:Int):Void {} + + @:noCompletion private function __setBlendMode(value:BlendMode):Void {} + + @:noCompletion private function __shouldCacheHardware(displayObject:DisplayObject, value:Null):Null + { + if (displayObject == null) return null; + + switch (displayObject.__drawableType) + { + case SPRITE, STAGE: + if (value == true) return true; + value = __shouldCacheHardware_DisplayObject(displayObject, value); + if (value == true) return true; + + if (displayObject.__children != null) + { + for (child in displayObject.__children) + { + value = __shouldCacheHardware_DisplayObject(child, value); + if (value == true) return true; + } + } + + return value; + + case TEXT_FIELD: + return value == true ? true : false; + + case TILEMAP: + return true; + + default: + return __shouldCacheHardware_DisplayObject(displayObject, value); + } + } + + @:noCompletion private function __shouldCacheHardware_DisplayObject(displayObject:DisplayObject, value:Null):Null + { + if (value == true || displayObject.__filters != null) return true; + + if (value == false || (displayObject.__graphics != null && !Context3DGraphics.isCompatible(displayObject.__graphics))) + { + return false; + } + + return null; + } + + @:noCompletion private function __updateCacheBitmap(displayObject:DisplayObject, force:Bool):Bool + { + if (displayObject == null) return false; + var renderer = this; + + switch (displayObject.__drawableType) + { + case BITMAP: + var bitmap:Bitmap = cast displayObject; + // TODO: Handle filters without an intermediate draw + if (bitmap.__bitmapData == null + || (bitmap.__filters == null #if lime && renderer.__type == OPENGL #end && bitmap.__cacheBitmap == null)) return false; + force = (bitmap.__bitmapData.image != null && bitmap.__bitmapData.image.version != bitmap.__imageVersion); + + case TEXT_FIELD: + var textField:TextField = cast displayObject; + if (textField.__filters == null #if lime && renderer.__type == OPENGL #end && textField.__cacheBitmap == null + && !textField.__domRender) return false; + if (force) textField.__renderDirty = true; + force = force || textField.__dirty; + + case TILEMAP: + var tilemap:Tilemap = cast displayObject; + if (tilemap.__filters == null #if lime && renderer.__type == OPENGL #end && tilemap.__cacheBitmap == null) return false; + + default: + } + + #if lime + if (displayObject.__isCacheBitmapRender) return false; + #if openfl_disable_cacheasbitmap + return false; + #end + + var colorTransform = ColorTransform.__pool.get(); + colorTransform.__copyFrom(displayObject.__worldColorTransform); + if (renderer.__worldColorTransform != null) colorTransform.__combine(renderer.__worldColorTransform); + var updated = false; + + // TODO: Do not force cacheAsBitmap on OpenGL once Scale-9 is properly supported in Context3DShape + if (displayObject.cacheAsBitmap + || (renderer.__type != OPENGL && !colorTransform.__isDefault(true)) + || (renderer.__type == OPENGL && displayObject.scale9Grid != null)) + { + var rect = null; + + var needRender = (displayObject.__cacheBitmap == null + || (displayObject.__renderDirty && (force || (displayObject.__children != null && displayObject.__children.length > 0))) + || displayObject.opaqueBackground != displayObject.__cacheBitmapBackground); + var softwareDirty = needRender + || (displayObject.__graphics != null && displayObject.__graphics.__softwareDirty) + || !displayObject.__cacheBitmapColorTransform.__equals(colorTransform, true); + var hardwareDirty = needRender || (displayObject.__graphics != null && displayObject.__graphics.__hardwareDirty); + + var renderType = renderer.__type; + + if (softwareDirty || hardwareDirty) + { + #if !openfl_force_gl_cacheasbitmap + if (renderType == OPENGL) + { + if (#if !openfl_disable_gl_cacheasbitmap __shouldCacheHardware(displayObject, null) == false #else true #end) + { + #if (js && html5) + renderType = CANVAS; + #else + renderType = CAIRO; + #end + } + } + #end + + if (softwareDirty && (renderType == CANVAS || renderType == CAIRO)) needRender = true; + if (hardwareDirty && renderType == OPENGL) needRender = true; + } + + var updateTransform = (needRender || !displayObject.__cacheBitmap.__worldTransform.equals(displayObject.__worldTransform)); + var hasFilters = #if !openfl_disable_filters displayObject.__filters != null #else false #end; + + #if !openfl_enable_cacheasbitmap + if (renderer.__type == DOM && !hasFilters) + { + return false; + } + #end + + if (hasFilters && !needRender) + { + for (filter in displayObject.__filters) + { + if (filter.__renderDirty) + { + needRender = true; + break; + } + } + } + + if (displayObject.__cacheBitmapMatrix == null) + { + displayObject.__cacheBitmapMatrix = new Matrix(); + } + + var bitmapMatrix = (displayObject.__cacheAsBitmapMatrix != null ? displayObject.__cacheAsBitmapMatrix : displayObject.__renderTransform); + + if (!needRender + && (bitmapMatrix.a != displayObject.__cacheBitmapMatrix.a + || bitmapMatrix.b != displayObject.__cacheBitmapMatrix.b + || bitmapMatrix.c != displayObject.__cacheBitmapMatrix.c + || bitmapMatrix.d != displayObject.__cacheBitmapMatrix.d)) + { + needRender = true; + } + + if (!needRender + && renderer.__type != OPENGL + && displayObject.__cacheBitmapData != null + && displayObject.__cacheBitmapData.image != null + && displayObject.__cacheBitmapData.image.version < displayObject.__cacheBitmapData.__textureVersion) + { + needRender = true; + } + + // Ensure that cached bitmap is updated after changes to scrollRect + if (!needRender) + { + var current = displayObject; + while (current != null) + { + if (current.scrollRect != null) + { + // TODO: do we need to update transform if scroll rects haven't changed? + updateTransform = true; + break; + } + current = current.parent; + } + } + + displayObject.__cacheBitmapMatrix.copyFrom(bitmapMatrix); + displayObject.__cacheBitmapMatrix.tx = 0; + displayObject.__cacheBitmapMatrix.ty = 0; + + // TODO: Handle dimensions better if object has a scrollRect? + + var bitmapWidth = 0, bitmapHeight = 0; + var filterWidth = 0, filterHeight = 0; + var offsetX = 0., offsetY = 0.; + + #if (openfl_disable_hdpi || openfl_disable_hdpi_cacheasbitmap) + var pixelRatio = 1; + #else + var pixelRatio = __pixelRatio; + #end + + if (updateTransform || needRender) + { + rect = Rectangle.__pool.get(); + + displayObject.__getFilterBounds(rect, displayObject.__cacheBitmapMatrix); + + filterWidth = rect.width > 0 ? Math.ceil(rect.width * pixelRatio) : 0; + filterHeight = rect.height > 0 ? Math.ceil(rect.height * pixelRatio) : 0; + + offsetX = rect.x > 0 ? Math.ceil(rect.x) : Math.floor(rect.x); + offsetY = rect.y > 0 ? Math.ceil(rect.y) : Math.floor(rect.y); + + if (displayObject.__cacheBitmapData != null) + { + if (filterWidth > displayObject.__cacheBitmapData.width || filterHeight > displayObject.__cacheBitmapData.height) + { + bitmapWidth = Math.ceil(Math.max(filterWidth * 1.25, displayObject.__cacheBitmapData.width)); + bitmapHeight = Math.ceil(Math.max(filterHeight * 1.25, displayObject.__cacheBitmapData.height)); + needRender = true; + } + else + { + bitmapWidth = displayObject.__cacheBitmapData.width; + bitmapHeight = displayObject.__cacheBitmapData.height; + } + } + else + { + bitmapWidth = filterWidth; + bitmapHeight = filterHeight; + } + } + + if (needRender) + { + updateTransform = true; + displayObject.__cacheBitmapBackground = displayObject.opaqueBackground; + + if (filterWidth >= 0.5 && filterHeight >= 0.5) + { + var needsFill = (displayObject.opaqueBackground != null + && (bitmapWidth != filterWidth || bitmapHeight != filterHeight)); + var fillColor = displayObject.opaqueBackground != null ? (0xFF << 24) | displayObject.opaqueBackground : 0; + var bitmapColor = needsFill ? 0 : fillColor; + var allowFramebuffer = (renderer.__type == OPENGL); + + if (displayObject.__cacheBitmapData == null + || bitmapWidth > displayObject.__cacheBitmapData.width + || bitmapHeight > displayObject.__cacheBitmapData.height) + { + displayObject.__cacheBitmapData = new BitmapData(bitmapWidth, bitmapHeight, true, bitmapColor); + + if (displayObject.__cacheBitmap == null) displayObject.__cacheBitmap = new Bitmap(); + displayObject.__cacheBitmap.__bitmapData = displayObject.__cacheBitmapData; + displayObject.__cacheBitmapRenderer = null; + } + else + { + displayObject.__cacheBitmapData.__fillRect(displayObject.__cacheBitmapData.rect, bitmapColor, allowFramebuffer); + } + + if (needsFill) + { + rect.setTo(0, 0, filterWidth, filterHeight); + displayObject.__cacheBitmapData.__fillRect(rect, fillColor, allowFramebuffer); + } + } + else + { + ColorTransform.__pool.release(colorTransform); + + displayObject.__cacheBitmap = null; + displayObject.__cacheBitmapData = null; + displayObject.__cacheBitmapData2 = null; + displayObject.__cacheBitmapData3 = null; + displayObject.__cacheBitmapRenderer = null; + + if (displayObject.__drawableType == TEXT_FIELD) + { + var textField:TextField = cast displayObject; + if (textField.__cacheBitmap != null) + { + textField.__cacheBitmap.__renderTransform.tx -= textField.__offsetX * pixelRatio; + textField.__cacheBitmap.__renderTransform.ty -= textField.__offsetY * pixelRatio; + } + } + + return true; + } + } + else + { + // Should we retain these longer? + + displayObject.__cacheBitmapData = displayObject.__cacheBitmap.bitmapData; + displayObject.__cacheBitmapData2 = null; + displayObject.__cacheBitmapData3 = null; + } + + if (updateTransform || needRender) + { + displayObject.__cacheBitmap.__worldTransform.copyFrom(displayObject.__worldTransform); + + if (bitmapMatrix == displayObject.__renderTransform) + { + displayObject.__cacheBitmap.__renderTransform.identity(); + displayObject.__cacheBitmap.__renderTransform.scale(1 / pixelRatio, 1 / pixelRatio); + displayObject.__cacheBitmap.__renderTransform.tx = displayObject.__renderTransform.tx + offsetX; + displayObject.__cacheBitmap.__renderTransform.ty = displayObject.__renderTransform.ty + offsetY; + } + else + { + displayObject.__cacheBitmap.__renderTransform.copyFrom(displayObject.__cacheBitmapMatrix); + displayObject.__cacheBitmap.__renderTransform.invert(); + displayObject.__cacheBitmap.__renderTransform.concat(displayObject.__renderTransform); + displayObject.__cacheBitmap.__renderTransform.a *= 1 / pixelRatio; + displayObject.__cacheBitmap.__renderTransform.d *= 1 / pixelRatio; + displayObject.__cacheBitmap.__renderTransform.tx += offsetX; + displayObject.__cacheBitmap.__renderTransform.ty += offsetY; + } + } + + displayObject.__cacheBitmap.smoothing = renderer.__allowSmoothing; + displayObject.__cacheBitmap.__renderable = displayObject.__renderable; + displayObject.__cacheBitmap.__worldAlpha = displayObject.__worldAlpha; + displayObject.__cacheBitmap.__worldBlendMode = displayObject.__worldBlendMode; + displayObject.__cacheBitmap.__worldShader = displayObject.__worldShader; + // displayObject.__cacheBitmap.__scrollRect = displayObject.__scrollRect; + // displayObject.__cacheBitmap.filters = displayObject.filters; + displayObject.__cacheBitmap.mask = displayObject.__mask; + + if (needRender) + { + #if lime + if (displayObject.__cacheBitmapRenderer == null || renderType != displayObject.__cacheBitmapRenderer.__type) + { + if (renderType == OPENGL) + { + displayObject.__cacheBitmapRenderer = new OpenGLRenderer(cast(renderer, OpenGLRenderer).__context3D, displayObject.__cacheBitmapData); + } + else + { + if (displayObject.__cacheBitmapData.image == null) + { + var color = displayObject.opaqueBackground != null ? (0xFF << 24) | displayObject.opaqueBackground : 0; + displayObject.__cacheBitmapData = new BitmapData(bitmapWidth, bitmapHeight, true, color); + displayObject.__cacheBitmap.__bitmapData = displayObject.__cacheBitmapData; + } + + #if (js && html5) + ImageCanvasUtil.convertToCanvas(displayObject.__cacheBitmapData.image); + displayObject.__cacheBitmapRenderer = new CanvasRenderer(displayObject.__cacheBitmapData.image.buffer.__srcContext); + #else + displayObject.__cacheBitmapRenderer = new CairoRenderer(new Cairo(displayObject.__cacheBitmapData.getSurface())); + #end + } + + displayObject.__cacheBitmapRenderer.__worldTransform = new Matrix(); + displayObject.__cacheBitmapRenderer.__worldColorTransform = new ColorTransform(); + } + #else + return false; + #end + + if (displayObject.__cacheBitmapColorTransform == null) displayObject.__cacheBitmapColorTransform = new ColorTransform(); + + displayObject.__cacheBitmapRenderer.__stage = displayObject.stage; + + displayObject.__cacheBitmapRenderer.__allowSmoothing = renderer.__allowSmoothing; + displayObject.__cacheBitmapRenderer.__setBlendMode(NORMAL); + displayObject.__cacheBitmapRenderer.__worldAlpha = 1 / displayObject.__worldAlpha; + + displayObject.__cacheBitmapRenderer.__worldTransform.copyFrom(displayObject.__renderTransform); + displayObject.__cacheBitmapRenderer.__worldTransform.invert(); + displayObject.__cacheBitmapRenderer.__worldTransform.concat(displayObject.__cacheBitmapMatrix); + displayObject.__cacheBitmapRenderer.__worldTransform.tx -= offsetX; + displayObject.__cacheBitmapRenderer.__worldTransform.ty -= offsetY; + displayObject.__cacheBitmapRenderer.__worldTransform.scale(pixelRatio, pixelRatio); + + displayObject.__cacheBitmapRenderer.__pixelRatio = pixelRatio; + + displayObject.__cacheBitmapRenderer.__worldColorTransform.__copyFrom(colorTransform); + displayObject.__cacheBitmapRenderer.__worldColorTransform.__invert(); + + displayObject.__isCacheBitmapRender = true; + + if (displayObject.__cacheBitmapRenderer.__type == OPENGL) + { + var parentRenderer:OpenGLRenderer = cast renderer; + var childRenderer:OpenGLRenderer = cast displayObject.__cacheBitmapRenderer; + + var context = childRenderer.__context3D; + + var cacheRTT = context.__state.renderToTexture; + var cacheRTTDepthStencil = context.__state.renderToTextureDepthStencil; + var cacheRTTAntiAlias = context.__state.renderToTextureAntiAlias; + var cacheRTTSurfaceSelector = context.__state.renderToTextureSurfaceSelector; + + // var cacheFramebuffer = context.__contextState.__currentGLFramebuffer; + + var cacheBlendMode = parentRenderer.__blendMode; + parentRenderer.__suspendClipAndMask(); + childRenderer.__copyShader(parentRenderer); + // childRenderer.__copyState (parentRenderer); + + displayObject.__cacheBitmapData.__setUVRect(context, 0, 0, filterWidth, filterHeight); + childRenderer.__setRenderTarget(displayObject.__cacheBitmapData); + if (displayObject.__cacheBitmapData.image != null) + displayObject.__cacheBitmapData.__textureVersion = displayObject.__cacheBitmapData.image.version + + 1; + + displayObject.__cacheBitmapData.__drawGL(displayObject, childRenderer); + + if (hasFilters) + { + var needSecondBitmapData = true; + var needCopyOfOriginal = false; + + for (filter in displayObject.__filters) + { + // if (filter.__needSecondBitmapData) { + // needSecondBitmapData = true; + // } + if (filter.__preserveObject) + { + needCopyOfOriginal = true; + } + } + + var bitmap = displayObject.__cacheBitmapData; + var bitmap2 = null; + var bitmap3 = null; + + // if (needSecondBitmapData) { + if (displayObject.__cacheBitmapData2 == null + || bitmapWidth > displayObject.__cacheBitmapData2.width + || bitmapHeight > displayObject.__cacheBitmapData2.height) + { + displayObject.__cacheBitmapData2 = new BitmapData(bitmapWidth, bitmapHeight, true, 0); + } + else + { + displayObject.__cacheBitmapData2.fillRect(displayObject.__cacheBitmapData2.rect, 0); + if (displayObject.__cacheBitmapData2.image != null) + { + displayObject.__cacheBitmapData2.__textureVersion = displayObject.__cacheBitmapData2.image.version + 1; + } + } + displayObject.__cacheBitmapData2.__setUVRect(context, 0, 0, filterWidth, filterHeight); + bitmap2 = displayObject.__cacheBitmapData2; + // } else { + // bitmap2 = bitmapData; + // } + + if (needCopyOfOriginal) + { + if (displayObject.__cacheBitmapData3 == null + || bitmapWidth > displayObject.__cacheBitmapData3.width + || bitmapHeight > displayObject.__cacheBitmapData3.height) + { + displayObject.__cacheBitmapData3 = new BitmapData(bitmapWidth, bitmapHeight, true, 0); + } + else + { + displayObject.__cacheBitmapData3.fillRect(displayObject.__cacheBitmapData3.rect, 0); + if (displayObject.__cacheBitmapData3.image != null) + { + displayObject.__cacheBitmapData3.__textureVersion = displayObject.__cacheBitmapData3.image.version + 1; + } + } + displayObject.__cacheBitmapData3.__setUVRect(context, 0, 0, filterWidth, filterHeight); + bitmap3 = displayObject.__cacheBitmapData3; + } + + childRenderer.__setBlendMode(NORMAL); + childRenderer.__worldAlpha = 1; + childRenderer.__worldTransform.identity(); + childRenderer.__worldColorTransform.__identity(); + + // var sourceRect = bitmap.rect; + // if (__tempPoint == null) __tempPoint = new Point (); + // var destPoint = __tempPoint; + var shader, cacheBitmap; + + for (filter in displayObject.__filters) + { + if (filter.__preserveObject) + { + childRenderer.__setRenderTarget(bitmap3); + childRenderer.__renderFilterPass(bitmap, childRenderer.__defaultDisplayShader, filter.__smooth); + } + + for (i in 0...filter.__numShaderPasses) + { + shader = filter.__initShader(childRenderer, i, filter.__preserveObject ? bitmap3 : null); + childRenderer.__setBlendMode(filter.__shaderBlendMode); + childRenderer.__setRenderTarget(bitmap2); + childRenderer.__renderFilterPass(bitmap, shader, filter.__smooth); + + cacheBitmap = bitmap; + bitmap = bitmap2; + bitmap2 = cacheBitmap; + } + + filter.__renderDirty = false; + } + + displayObject.__cacheBitmap.__bitmapData = bitmap; + } + + parentRenderer.__blendMode = NORMAL; + parentRenderer.__setBlendMode(cacheBlendMode); + parentRenderer.__copyShader(childRenderer); + + if (cacheRTT != null) + { + context.setRenderToTexture(cacheRTT, cacheRTTDepthStencil, cacheRTTAntiAlias, cacheRTTSurfaceSelector); + } + else + { + context.setRenderToBackBuffer(); + } + + // context.__bindGLFramebuffer (cacheFramebuffer); + + // parentRenderer.__restoreState (childRenderer); + parentRenderer.__resumeClipAndMask(childRenderer); + parentRenderer.setViewport(); + + displayObject.__cacheBitmapColorTransform.__copyFrom(colorTransform); + } + else + { + #if (js && html5) + displayObject.__cacheBitmapData.__drawCanvas(displayObject, cast displayObject.__cacheBitmapRenderer); + #else + displayObject.__cacheBitmapData.__drawCairo(displayObject, cast displayObject.__cacheBitmapRenderer); + #end + + if (hasFilters) + { + var needSecondBitmapData = false; + var needCopyOfOriginal = false; + + for (filter in displayObject.__filters) + { + if (filter.__needSecondBitmapData) + { + needSecondBitmapData = true; + } + if (filter.__preserveObject) + { + needCopyOfOriginal = true; + } + } + + var bitmap = displayObject.__cacheBitmapData; + var bitmap2 = null; + var bitmap3 = null; + + if (needSecondBitmapData) + { + if (displayObject.__cacheBitmapData2 == null + || displayObject.__cacheBitmapData2.image == null + || bitmapWidth > displayObject.__cacheBitmapData2.width + || bitmapHeight > displayObject.__cacheBitmapData2.height) + { + displayObject.__cacheBitmapData2 = new BitmapData(bitmapWidth, bitmapHeight, true, 0); + } + else + { + displayObject.__cacheBitmapData2.fillRect(displayObject.__cacheBitmapData2.rect, 0); + } + bitmap2 = displayObject.__cacheBitmapData2; + } + else + { + bitmap2 = bitmap; + } + + if (needCopyOfOriginal) + { + if (displayObject.__cacheBitmapData3 == null + || displayObject.__cacheBitmapData3.image == null + || bitmapWidth > displayObject.__cacheBitmapData3.width + || bitmapHeight > displayObject.__cacheBitmapData3.height) + { + displayObject.__cacheBitmapData3 = new BitmapData(bitmapWidth, bitmapHeight, true, 0); + } + else + { + displayObject.__cacheBitmapData3.fillRect(displayObject.__cacheBitmapData3.rect, 0); + } + bitmap3 = displayObject.__cacheBitmapData3; + } + + if (displayObject.__tempPoint == null) displayObject.__tempPoint = new Point(); + var destPoint = displayObject.__tempPoint; + var cacheBitmap, lastBitmap; + + for (filter in displayObject.__filters) + { + if (filter.__preserveObject) + { + bitmap3.copyPixels(bitmap, bitmap.rect, destPoint); + } + + lastBitmap = filter.__applyFilter(bitmap2, bitmap, bitmap.rect, destPoint); + + if (filter.__preserveObject) + { + lastBitmap.draw(bitmap3, null, + displayObject.__objectTransform != null ? displayObject.__objectTransform.__colorTransform : null); + } + filter.__renderDirty = false; + + if (needSecondBitmapData && lastBitmap == bitmap2) + { + cacheBitmap = bitmap; + bitmap = bitmap2; + bitmap2 = cacheBitmap; + } + } + + if (displayObject.__cacheBitmapData != bitmap) + { + // TODO: Fix issue with swapping __cacheBitmap.__bitmapData + // __cacheBitmapData.copyPixels (bitmap, bitmap.rect, destPoint); + + // Adding __cacheBitmapRenderer = null; makes this work + cacheBitmap = displayObject.__cacheBitmapData; + displayObject.__cacheBitmapData = bitmap; + displayObject.__cacheBitmapData2 = cacheBitmap; + displayObject.__cacheBitmap.__bitmapData = displayObject.__cacheBitmapData; + displayObject.__cacheBitmapRenderer = null; + } + + displayObject.__cacheBitmap.__imageVersion = displayObject.__cacheBitmapData.__textureVersion; + } + + displayObject.__cacheBitmapColorTransform.__copyFrom(colorTransform); + + if (!displayObject.__cacheBitmapColorTransform.__isDefault(true)) + { + displayObject.__cacheBitmapColorTransform.alphaMultiplier = 1; + displayObject.__cacheBitmapData.colorTransform(displayObject.__cacheBitmapData.rect, displayObject.__cacheBitmapColorTransform); + } + } + + displayObject.__isCacheBitmapRender = false; + } + + if (updateTransform || needRender) + { + Rectangle.__pool.release(rect); + } + + updated = updateTransform; + } + else if (displayObject.__cacheBitmap != null) + { + if (renderer.__type == DOM) + { + var domRenderer:DOMRenderer = cast renderer; + domRenderer.__renderDrawableClear(displayObject.__cacheBitmap); + } + + displayObject.__cacheBitmap = null; + displayObject.__cacheBitmapData = null; + displayObject.__cacheBitmapData2 = null; + displayObject.__cacheBitmapData3 = null; + displayObject.__cacheBitmapColorTransform = null; + displayObject.__cacheBitmapRenderer = null; + + updated = true; + } + + ColorTransform.__pool.release(colorTransform); + + if (updated && displayObject.__drawableType == TEXT_FIELD) + { + var textField:TextField = cast displayObject; + if (textField.__cacheBitmap != null) + { + textField.__cacheBitmap.__renderTransform.tx -= textField.__offsetX; + textField.__cacheBitmap.__renderTransform.ty -= textField.__offsetY; + } + } + + return updated; + #else + return false; + #end + } +} +#else +typedef DisplayObjectRenderer = Dynamic; +#end