diff --git a/FEATURES.md b/FEATURES.md index caa85417..2272cee4 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -13,7 +13,7 @@ _**QOL = Quality of Life**_ - Downscroll - Ghost Tapping - Opponent & Co-op modes -- Memory optimisation (most of the game runs < 500mb) +- Memory optimization (most of the game runs < 500mb) - Usage of [flxanimate](https://github.com/Dot-Stuff/flxanimate) on big sprites, such as Girlfriend to save memory. - You can further optimize it on certain stages by enabling `Low Memory Mode` in `Options > Appearance`. - New volume change SFX (no more loud flixel beep, customizable) @@ -36,7 +36,7 @@ _**QOL = Quality of Life**_ - Support for `hscript-improved`, a fork made to allow HScript to push modding even further - Allows for imports - Allows for public variables (variables shared between every script in a ScriptPack such as a song scripts) - - Allows for static variables (variabels shared between every single script ran in this mod) + - Allows for static variables (variables shared between every single script ran in this mod) - Allows you to use for example `boyfriend` instead of `PlayState.boyfriend` or `game.boyfriend`, for smaller and easier to comprehend code. - Allows you to use `@:bypassAccessor` - Allows you to use maps @@ -59,7 +59,7 @@ _**QOL = Quality of Life**_ - Position them - Add animations - Change their scale - - Change their scrollfactor + - Change their scroll factor - Change their zoomfactor - Turn on/off their antialiasing (on by default) - Change additional properties via child nodes. diff --git a/PATCHNOTES.md b/PATCHNOTES.md index 5a1512fe..08ea5e2b 100644 --- a/PATCHNOTES.md +++ b/PATCHNOTES.md @@ -15,7 +15,7 @@ - New SEXY editor assets by paige and nex!!!! (and lunar, does 16x16 even count??? 😭) - NEW EVENTS (Camera events, play animation, scroll speed change) - Events window is now scrollable (more events, more room) - - Custom Properities in Meta AND Character (Editable in Charter and Character Editor :D) (accessible with SONG.meta.customValues.[property] and [character].extras.[property]) + - Custom Properties in Meta AND Character (Editable in Charter and Character Editor :D) (accessible with SONG.meta.customValues.[property] and [character].extras.[property]) - SMALLER BUT STILL COOL - Multiple Icons now show up on strumlines with multiple characters in the charter - Note hoverer to show where your note is going to be placed @@ -41,9 +41,9 @@ - Reworked Lagless Credits Codename Engine's Contributors Menu - New Credit Method for GitHub accounts (also lagless) in Mod Credits (First gets the data normally, if fails uses the ratelimited api) - MANY OG GAME WEEK STUFF!! (still wip and softcoded and also many reworks by nex!) - - Senpai Cutscene got reworked! (https://github.com/FNF-CNE-Devs/CodenameEngine/assets/87421482/3b3f32fc-78d1-40fa-8398-776554cab1d6) - - Thorns got reworked with a cool chromatic aberration effect! (https://github.com/FNF-CNE-Devs/CodenameEngine/assets/87421482/73d9f7c5-1c9c-407e-baf0-e8e2c381ecbb) - - Winter Horrorland got reworked with a bloody vignette effect! (https://github.com/FNF-CNE-Devs/CodenameEngine/assets/87421482/1e10c3e2-32dc-4de2-b31a-d9d577d516da - https://github.com/FNF-CNE-Devs/CodenameEngine/assets/87421482/cad852c3-1ee2-409e-a70e-b3571ab5cf7b) + - Senpai Cutscene got reworked! (https://github.com/CodenameCrew/CodenameEngine/assets/87421482/3b3f32fc-78d1-40fa-8398-776554cab1d6) + - Thorns got reworked with a cool chromatic aberration effect! (https://github.com/CodenameCrew/CodenameEngine/assets/87421482/73d9f7c5-1c9c-407e-baf0-e8e2c381ecbb) + - Winter Horrorland got reworked with a bloody vignette effect! (https://github.com/CodenameCrew/CodenameEngine/assets/87421482/1e10c3e2-32dc-4de2-b31a-d9d577d516da - https://github.com/CodenameCrew/CodenameEngine/assets/87421482/cad852c3-1ee2-409e-a70e-b3571ab5cf7b) - SMALLER BUT STILL COOL - Ability to set Controls.hx variables (Being able to block inputs or even trigger them (needs to be in an if statement)) - You can now easily check if a cutscene was played (by default is disabled and makes it auto play or not; Check startCutscene() code for more details in PlayState) @@ -63,7 +63,7 @@ - Fix for pressing F5 in an editor breaking it - Fix when getting GitHub data and a redirect happens - Fix for healthbar incorrectly colored in opponent mode - - Video cutscenes are ALOT more stable (thanks majigsaw :D) + - Video cutscenes are A LOT more stable (thanks majigsaw :D) - 3D now works again (so cool i love away3d in 2024) - Lots and lots of grammar and wording fixes (so true bro -lunar) - Lots and lots of other optimizations made @@ -76,5 +76,5 @@ - Some other shit idk ill add it whenever someone tells me backward compat is broke 💔 -thanks so much for the support and always being there, it really does mean alot to us < 3 +thanks so much for the support and always being there, it really does mean a lot to us < 3 we are one step closer to turning beta so we really can't wait ! \ No newline at end of file diff --git a/README.md b/README.md index 93b36034..4ba32a47 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Also, the command `.\cne test` uses the source assets folder instead of the expo ## Codename Engine Codename Engine is a new Friday Night Funkin' Engine aimed at simplifying modding, along with extensiblity and ease of use.
-### Before making issues or need help with something, check our website [HERE](https://fnf-cne-devs.github.io/) (it contains a wiki of how to mod with EXAMPLES, an api, lists of mods made with Codename Engine and more)!!! +### Before making issues or need help with something, check our website [HERE](https://codename-engine.com/) (it contains a wiki of how to mod with EXAMPLES, an api, lists of mods made with Codename Engine and more)!!! #### The Engine includes many new features, as seen [here](FEATURES.md)
#### Wanna see the new features added in the most recent update? Click [here](PATCHNOTES.md)
@@ -69,7 +69,7 @@ If you don't have a github account please go onto https://fnf-cne-devs.github.io - Download and play the engine with its mods and modpacks - Mod and fork the engine (without using it for illicit purposes) - Contribute to the engine (for example through *Pull Requests*, *Issues*, etc) - - Create a sub engine with Codename Engine as **TEMPLATE** with **CREDITS** (for example leaving the *credits menu submenu with the GitHub contributors* and putting the *[main devs](https://github.com/FNF-CNE-Devs)* in a *README* specifying that it's a *sub engine from Codename Engine*) + - Create a sub engine with Codename Engine as **TEMPLATE** with **CREDITS** (for example leaving the *credits menu submenu with the GitHub contributors* and putting the *[main devs](https://github.com/CodenameCrew)* in a *README* specifying that it's a *sub engine from Codename Engine*) - Release excutable mods that use Codename Engine as source (Specifing that uses Codename Engine by for example the same way written above this) - Release modpacks diff --git a/TODO.md b/TODO.md index 66ba0373..b3d2e4cf 100644 --- a/TODO.md +++ b/TODO.md @@ -26,7 +26,7 @@ - [ ] BPM Changes Events - [ ] Character Editor - [x] Animation Editing - - [x] Animation Deletion/Creationg + - [x] Animation Deletion/Creation - [x] Character Info Editing - [x] Character Saving - [x] Add Undos to Actions @@ -49,7 +49,7 @@ - [ ] Fix bugs ## `v1.1.0` -- [ ] Charter Waveforms (maybe in v1.1.0, dont wanna slow shit down) +- [ ] Charter Waveforms (maybe in v1.1.0, don't wanna slow shit down) - [ ] Custom classes - [ ] Proper super overrides (FlxText_HSX doesn't allow overrides for update because of this) - [ ] Custom Class extending Custom Classes diff --git a/art/generateDoc.bat b/art/generateDoc.bat index e2d35e4f..595314b1 100644 --- a/art/generateDoc.bat +++ b/art/generateDoc.bat @@ -1,8 +1,8 @@ @ECHO OFF cd .. echo Building Game... -lime build windows --haxeflag="--macro include('scripting')" --haxeflag="-xml docs/doc.xml" -D DOCUMENTATION --no-output +lime build windows --haxeflag="-xml docs/doc.xml" -D doc-gen -D DOCUMENTATION --no-output echo art echo Generated the api xml file at docs/doc.xml -echo Please put this in FNF-CNE-Devs.github.io/api-generator/api/doc.xml \ No newline at end of file +echo Please put this in codename-website/api-generator/api/doc.xml \ No newline at end of file diff --git a/assets/data/characters/spirit.hx b/assets/data/characters/spirit.hx index 137787e8..41b554af 100644 --- a/assets/data/characters/spirit.hx +++ b/assets/data/characters/spirit.hx @@ -7,7 +7,7 @@ function postCreate() { } var toAdd:Bool = true; // Using this just to make sure -function update(elpased) { +function update(elapsed) { if(toAdd) { toAdd = false; PlayState.instance.insert(PlayState.instance.members.indexOf(self), trail); diff --git a/assets/data/dialogue/boxes/hating-simulator.hx b/assets/data/dialogue/boxes/hating-simulator.hx index b3584aee..12bab0d2 100644 --- a/assets/data/dialogue/boxes/hating-simulator.hx +++ b/assets/data/dialogue/boxes/hating-simulator.hx @@ -1,4 +1,4 @@ -var loopedTimah:FlxTimer; // Hey! a man has fallen into the river in lego city! and if youre asking why this is here, you shall disappear! - Nex +var loopedTimer:FlxTimer; // Hey! a man has fallen into the river in lego city! and if youre asking why this is here, you shall disappear! - Nex var bgFade:FlxSprite; var hand:FlxSprite; @@ -9,7 +9,7 @@ function postCreate() { bgFade.alpha = 0; cutscene.insert(0, bgFade); - loopedTimah = new FlxTimer().start(0.83, function(tmr:FlxTimer) + loopedTimer = new FlxTimer().start(0.83, function(tmr:FlxTimer) { bgFade.alpha += (1 / 5) * 0.7; if (bgFade.alpha > 0.7) @@ -30,8 +30,8 @@ function close(event) { cutscene.curMusic?.fadeOut(1, 0); for(c in cutscene.charMap) c.visible = false; - loopedTimah.cancel(); - loopedTimah = new FlxTimer().start(0.2, function(tmr:FlxTimer) + loopedTimer.cancel(); + loopedTimer = new FlxTimer().start(0.2, function(tmr:FlxTimer) { if (tmr.elapsedLoops <= 5) { cutscene.dialogueBox.alpha -= 1 / 5; diff --git a/assets/data/stages/mall-evil.hx b/assets/data/stages/mall-evil.hx index ef8685cf..ead73b80 100644 --- a/assets/data/stages/mall-evil.hx +++ b/assets/data/stages/mall-evil.hx @@ -11,7 +11,7 @@ function create() { } var adder:Int = 0; -function postUpdate(elapsed:Float) { // Doing it like this so at least the red bump doesnt look too much instant +function postUpdate(elapsed:Float) { // Doing it like this so at least the red bump doesn't look too much instant var toAdd:Int = lerp(adder, 0, elapsed); idk.amount = camGame.zoom * camHUD.zoom + toAdd; idk.strength = (camGame.zoom - camHUD.zoom + toAdd) * 5; diff --git a/assets/data/stages/school.xml b/assets/data/stages/school.xml index 7a2740ad..5647a6f7 100644 --- a/assets/data/stages/school.xml +++ b/assets/data/stages/school.xml @@ -16,7 +16,7 @@ antialiasing="false" scale="4.797" scroll="0.9" updateHitbox="true" type="loop"/> - + diff --git a/assets/data/stages/spooky.hx b/assets/data/stages/spooky.hx index 340a80f3..a8531fe4 100644 --- a/assets/data/stages/spooky.hx +++ b/assets/data/stages/spooky.hx @@ -16,7 +16,7 @@ public function lightningStrikeShit():Void lightningStrikeBeat = curBeat; lightningOffset = FlxG.random.int(8, 24); - boyfriend.playAnim('scared', true, "SING"); // SING so that they dont get indefinitely looped + boyfriend.playAnim('scared', true, "SING"); // SING so that they don't get indefinitely looped gf.playAnim('scared', true, "SING"); } diff --git a/assets/data/stages/tank.xml b/assets/data/stages/tank.xml index d321e315..b0c1d97a 100644 --- a/assets/data/stages/tank.xml +++ b/assets/data/stages/tank.xml @@ -25,7 +25,7 @@ - + diff --git a/assets/data/weeks/weeks.txt b/assets/data/weeks/weeks.txt index 570a1bb5..d5b81933 100644 --- a/assets/data/weeks/weeks.txt +++ b/assets/data/weeks/weeks.txt @@ -1,4 +1,4 @@ -# THIS FILE ISNT NECESSARY, +# THIS FILE ISN'T NECESSARY, # BUT YOU CAN USE IT TO SORT WEEKS tutorial diff --git a/assets/shaders/engine/CompatabilityGuide.md b/assets/shaders/engine/CompatabilityGuide.md index 2fe7bc87..bee94522 100644 --- a/assets/shaders/engine/CompatabilityGuide.md +++ b/assets/shaders/engine/CompatabilityGuide.md @@ -1,4 +1,4 @@ -## Here are guides on common mistakes and advices for writting shaders for flixel and openfl. +## Here are guides on common mistakes and advices for writing shaders for flixel and openfl. It's important to follow this guide as most shader coders make these mistakes a lot and end up with shaders that only work on certain devices. @@ -51,7 +51,7 @@ We will show each step to converting this shader into an usable openfl/flixel sh 1. replace ``void mainImage( out vec4 fragColor, in vec2 fragCoord )`` with a simple ``void main()`` (flixel and openfl do not have any parameters since the coords are defined outside the function) 2. replace ``vec2 uv = fragCoord/iResolution.xy;`` with ``vec2 uv = openfl_TextureCoordv`` (or in some cases, add ``vec2 fragCoord = openfl_TextureCoordv*openfl_TextureSize.xy`` before it and replace `iResolution.xy` with ``openfl_TextureSize.xy`` (if the uv value is different than usual)) -3. replace ``vec4 col = texture(iChannel0, uv);`` with ``vec4 col = texture2D(bitmap, uv);`` or ``vec4 col = flixel_texture2D(bitmap, uv);`` (keep in mind bitmap is the pixels of the camera/sprite the shader is aplied to) +3. replace ``vec4 col = texture(iChannel0, uv);`` with ``vec4 col = texture2D(bitmap, uv);`` or ``vec4 col = flixel_texture2D(bitmap, uv);`` (keep in mind bitmap is the pixels of the camera/sprite the shader is applied to) 4. finally, replace ``fragColor = col;`` with ``gl_FragColor = col;`` ###### Keep in mind that this covers the most basic on how to convert a shader from shadertoy.com, complex shaders will need more expertise with handling shaders before converting those. diff --git a/assets/shaders/engine/editorWaveforms.frag b/assets/shaders/engine/editorWaveforms.frag index 530f78df..c65452dc 100644 --- a/assets/shaders/engine/editorWaveforms.frag +++ b/assets/shaders/engine/editorWaveforms.frag @@ -5,8 +5,8 @@ const vec3 gradient1 = vec3(114.0/255.0, 81.0/255.0, 135.0/255.0); const vec3 gradient2 = vec3(144.0/255.0, 80.0/255.0, 186.0/255.0); -const vec4 outlinecolor = vec4(0.1); -const vec3 lowdetailcol = vec3(0.0, 0.0, 1.0); +const vec4 outlineColor = vec4(0.1); +const vec3 lowDetailCol = vec3(0.0, 0.0, 1.0); uniform vec2 textureRes; uniform float pixelOffset; @@ -42,28 +42,28 @@ bool inWaveForm(vec2 pixel, float width) { return pixel.x > widthdiv2 && pixel.x < textureRes.x-widthdiv2; } -float getHightlight(float ampwidth) { - float remapCoord = (ampwidth/textureRes.x)/2.0; +float getHighlight(float ampWidth) { + float remapCoord = (ampWidth/textureRes.x)/2.0; float mappedCoord = map(openfl_TextureCoordv.x, remapCoord, 1.0-remapCoord, 0.0, 1.0); return 1.0-(abs(mappedCoord-0.5)*2.0); } void outlineWaveform(vec2 pixel, vec2 offset) { float amplitude = getAmplitude(pixel - offset); - float ampwidth = (1.0-amplitude) * textureRes.x; + float ampWidth = (1.0-amplitude) * textureRes.x; - if (!inWaveForm(pixel, ampwidth)) - gl_FragColor -= outlinecolor*mix(0.5, 0.8, amplitude); + if (!inWaveForm(pixel, ampWidth)) + gl_FragColor -= outlineColor*mix(0.5, 0.8, amplitude); } -void highDetailWaveform(vec2 pixel, float amplitude, float ampwidth) { +void highDetailWaveform(vec2 pixel, float amplitude, float ampWidth) { vec3 gradientColor = mix(gradient1, gradient2, openfl_TextureCoordv.x); gradientColor *= pixel.y+pixelOffset>playerPosition ? 0.7 : 1.0; - gradientColor = mix(gradientColor, gradientColor * vec3(1.8), map(getHightlight(amplitude), 0.0, 1.0, 0.5, 1.0)); + gradientColor = mix(gradientColor, gradientColor * vec3(1.8), map(getHighlight(amplitude), 0.0, 1.0, 0.5, 1.0)); - float ampwidthHighlight = getAmpWidth(amplitude/3.0); - if (inWaveForm(pixel, ampwidthHighlight)) - gradientColor = mix(gradientColor, gradientColor * vec3(1.8), map(getHightlight(ampwidthHighlight), 0.0, 1.0, 0.5, 1.0)); + float ampWidthHighlight = getAmpWidth(amplitude/3.0); + if (inWaveForm(pixel, ampWidthHighlight)) + gradientColor = mix(gradientColor, gradientColor * vec3(1.8), map(getHighlight(ampWidthHighlight), 0.0, 1.0, 0.5, 1.0)); gl_FragColor = vec4(vec3(gradientColor * mix(0.5, 0.8, amplitude))*openfl_Alphav, openfl_Alphav); @@ -71,19 +71,19 @@ void highDetailWaveform(vec2 pixel, float amplitude, float ampwidth) { outlineWaveform(pixel, vec2(0.0, 1.0)); } -void lowDetailWaveform(vec2 pixel, float amplitude, float ampwidth) { - gl_FragColor = vec4(lowdetailcol * (pixel.y+pixelOffset>playerPosition ? 0.7 : 1.0), 1.0); +void lowDetailWaveform(vec2 pixel, float amplitude, float ampWidth) { + gl_FragColor = vec4(lowDetailCol * (pixel.y+pixelOffset>playerPosition ? 0.7 : 1.0), 1.0); } void main() { vec2 pixel = openfl_TextureCoordv * textureRes; float amplitude = getAmplitude(pixel); - float ampwidth = getAmpWidth(amplitude); + float ampWidth = getAmpWidth(amplitude); gl_FragColor = vec4(0.0); - if (!inWaveForm(pixel, ampwidth)) return; + if (!inWaveForm(pixel, ampWidth)) return; - if (lowDetail) lowDetailWaveform(pixel, amplitude, ampwidth); - else highDetailWaveform(pixel, amplitude, ampwidth); + if (lowDetail) lowDetailWaveform(pixel, amplitude, ampWidth); + else highDetailWaveform(pixel, amplitude, ampWidth); } \ No newline at end of file diff --git a/commandline/Main.hx b/commandline/Main.hx index 1a1db23c..beb170f0 100644 --- a/commandline/Main.hx +++ b/commandline/Main.hx @@ -41,7 +41,7 @@ class Main { dDoc: [ "Usage: test ", "", - "This will create a quick debug build binded to the source then run it, which means:", + "This will create a quick debug build connected to the source then run it, which means:", "- The assets WON'T be copied over - Assets will be read from the game's source.", "- This build WON'T be ready for release - Running anywhere else than in the bin folder will result in a crash from missing assets", "- This build will also use the mods folder from the source directory.", @@ -60,7 +60,7 @@ class Main { dDoc: [ "Usage: build ", "", - "This will create a quick debug build binded to the source then run it, which means:", + "This will create a quick debug build connected to the source then run it, which means:", "- The assets WON'T be copied over - Assets will be read from the game's source.", "- This build WON'T be ready for release - Running anywhere else than in the bin folder will result in a crash from missing assets", "- This build will also use the mods folder from the source directory.", @@ -121,7 +121,7 @@ class Main { "", "This will optimize a JSON file, which means it will remove all unnecessary spacing from the file.", "WARNING: Order might be lost.", - "WARNING: Comments arent supported.", + "WARNING: Comments aren't supported.", "", "-O | --no-old : No Old file will be created.", ].join("\n") diff --git a/commandline/commands/Setup.hx b/commandline/commands/Setup.hx index 3d85705d..2ddac7eb 100644 --- a/commandline/commands/Setup.hx +++ b/commandline/commands/Setup.hx @@ -271,13 +271,13 @@ class Setup { prettyPrint("Installing Microsoft Visual Studio Community (Dependency)"); // thanks to @crowplexus for these two lines! - Nex - Sys.command("curl -# -O https://download.visualstudio.microsoft.com/download/pr/3105fcfe-e771-41d6-9a1c-fc971e7d03a7/8eb13958dc429a6e6f7e0d6704d43a55f18d02a253608351b6bf6723ffdaf24e/vs_Community.exe"); - Sys.command("vs_Community.exe --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.19041 -p"); + command("curl -# -O https://download.visualstudio.microsoft.com/download/pr/3105fcfe-e771-41d6-9a1c-fc971e7d03a7/8eb13958dc429a6e6f7e0d6704d43a55f18d02a253608351b6bf6723ffdaf24e/vs_Community.exe"); + command("vs_Community.exe --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.19041 -p"); FileSystem.deleteFile("vs_Community.exe"); prettyPrint('If it didn\'t say it before: Because of this component if you want to compile you have to restart the device.'); Sys.print("Do you wish to do it now [y/n]? "); - if(Sys.stdin().readLine().toLowerCase() == "y") Sys.command("shutdown /r /t 0 /f"); + if(Sys.stdin().readLine().toLowerCase() == "y") command("shutdown /r /t 0 /f"); } } diff --git a/libs.xml b/libs.xml index 2a5dada4..e1653aed 100644 --- a/libs.xml +++ b/libs.xml @@ -4,23 +4,23 @@ Preparing installation... - + - + - - + + - - - + + + - - + + @@ -29,10 +29,7 @@ - - - - + diff --git a/project.xml b/project.xml index c42c312c..fa9f7f48 100644 --- a/project.xml +++ b/project.xml @@ -133,7 +133,7 @@ - + diff --git a/source/Xml.hx b/source/Xml.hx index 82613dcd..143bc693 100644 --- a/source/Xml.hx +++ b/source/Xml.hx @@ -363,7 +363,7 @@ class Xml { /** Removes a child from the Document or Element. - Returns true if the child was successfuly removed. + Returns true if the child was successfully removed. **/ public function removeChild(x:Xml):Bool { ensureElementType(); diff --git a/source/flx3d/Flx3DUtil.hx b/source/flx3d/Flx3DUtil.hx index e6c85bb0..71706e35 100644 --- a/source/flx3d/Flx3DUtil.hx +++ b/source/flx3d/Flx3DUtil.hx @@ -7,7 +7,7 @@ import flixel.FlxG; #end /** - * @author lunarclient + * @author lunarcleint * @see https://twitter.com/lunarcleint * * Help from Ne_Eo diff --git a/source/funkin/backend/FlxAnimate.hx b/source/funkin/backend/FlxAnimate.hx index a0df7cf9..87b585c8 100644 --- a/source/funkin/backend/FlxAnimate.hx +++ b/source/funkin/backend/FlxAnimate.hx @@ -3,15 +3,20 @@ package funkin.backend; import flixel.graphics.frames.FlxFrame; import flixel.math.FlxAngle; import flixel.math.FlxMatrix; +import openfl.display.BlendMode; import openfl.geom.ColorTransform; class FlxAnimate extends flxanimate.FlxAnimate { static var rMatrix = new FlxMatrix(); - override function drawLimb(limb:FlxFrame, _rMatrix:FlxMatrix, ?colorTransform:ColorTransform) + override function drawLimb(limb:FlxFrame, _rMatrix:FlxMatrix, ?colorTransform:ColorTransform, ?blendMode:BlendMode) { if (alpha == 0 || colorTransform != null && (colorTransform.alphaMultiplier == 0 || colorTransform.alphaOffset == -255) || limb == null || limb.type == EMPTY) return; + + if (blendMode == null) + blendMode = BlendMode.NORMAL; + for (camera in cameras) { rMatrix.identity(); @@ -28,7 +33,7 @@ class FlxAnimate extends flxanimate.FlxAnimate { var angleOff = (frameOffsetAngle - angle) * FlxAngle.TO_RAD; var cos = Math.cos(angleOff); var sin = Math.sin(angleOff); - // cos doesnt need to be negated + // cos doesn't need to be negated rMatrix.rotateWithTrig(cos, -sin); rMatrix.translate(-frameOffset.x, -frameOffset.y); rMatrix.rotateWithTrig(cos, sin); @@ -66,13 +71,13 @@ class FlxAnimate extends flxanimate.FlxAnimate { } rMatrix.translate(_point.x, _point.y); - camera.drawPixels(limb, null, rMatrix, colorTransform, blend, antialiasing, shaderEnabled ? shader : null); + camera.drawPixels(limb, null, rMatrix, colorTransform, blendMode, antialiasing, shaderEnabled ? shader : null); #if FLX_DEBUG FlxBasic.visibleCount++; #end } - // doesnt work, needs to be remade + // doesn't work, needs to be remade // #if FLX_DEBUG // if (FlxG.debugger.drawDebug) // drawDebug(); @@ -81,7 +86,7 @@ class FlxAnimate extends flxanimate.FlxAnimate { override function limbOnScreen(limb:FlxFrame, m:FlxMatrix, ?Camera:FlxCamera) { - // TODO: ACTUAL OPTIMISATION + // TODO: ACTUAL OPTIMIZATION return true; } -} \ No newline at end of file +} diff --git a/source/funkin/backend/FunkinSprite.hx b/source/funkin/backend/FunkinSprite.hx index 6a1da437..58048dbc 100644 --- a/source/funkin/backend/FunkinSprite.hx +++ b/source/funkin/backend/FunkinSprite.hx @@ -59,7 +59,8 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I public var globalCurFrame(get, set):Int; /** - * ODD interval -> asynced; EVEN interval -> synced + * ODD interval -> not aligned to beats + * EVEN interval -> aligned to beats */ public var beatInterval(default, set):Int = 2; public var beatOffset:Int = 0; @@ -326,7 +327,31 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I lastAnimContext = Context; } - public function getAnim(name:String):OneOfTwo { + public inline function addAnim(name:String, prefix:String, frameRate:Float = 24, ?looped:Bool, ?forced:Bool, ?indices:Array, x:Float = 0, y:Float = 0, animType:XMLAnimType = NONE) + { + return XMLUtil.addAnimToSprite(this, { + name: name, + anim: prefix, + fps: frameRate, + loop: looped == null ? animType == LOOP : looped, + animType: animType, + x: x, + y: y, + indices: indices, + forced: forced + }); + } + + public inline function removeAnim(name:String) + { + if (animateAtlas != null) + @:privateAccess animateAtlas.anim.animsMap.remove(name); + else + animation.remove(name); + } + + public function getAnim(name:String):OneOfTwo + { if(animateAtlas != null) return animateAtlas.anim.getByName(name); return animation.getByName(name); @@ -339,7 +364,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I return FlxPoint.weak(0, 0); } - public inline function hasAnimation(AnimName:String):Bool @:privateAccess + public inline function hasAnim(AnimName:String):Bool @:privateAccess return animateAtlas != null ? (animateAtlas.anim.animsMap.exists(AnimName) || animateAtlas.anim.symbolDictionary.exists(AnimName)) : animation.exists(AnimName); @@ -351,13 +376,6 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I return animateAtlas != null ? animateAtlas.anim.reversed : animation.curAnim != null ? animation.curAnim.reversed : false; } - public inline function removeAnimation(name:String) { - if (animateAtlas != null) - @:privateAccess animateAtlas.anim.animsMap.remove(name); - else - animation.remove(name); - } - public inline function getNameList():Array { if (animateAtlas != null) return [for (name in @:privateAccess animateAtlas.anim.animsMap.keys()) name]; @@ -365,7 +383,8 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I return animation.getNameList(); } - public inline function stopAnimation() { + public inline function stopAnim() + { if (animateAtlas != null) animateAtlas.anim.pause(); else @@ -384,6 +403,11 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I if (animEnabled) super.updateAnimation(elapsed); } + + // Backwards compat (the names used to be all different and it sucked, please lets use the same format in the future) - Nex + public inline function hasAnimation(AnimName:String) return hasAnim(AnimName); + public inline function removeAnimation(name:String) return removeAnim(name); + public inline function stopAnimation() return stopAnim(); #end // Getter / Setters diff --git a/source/funkin/backend/MusicBeatGroup.hx b/source/funkin/backend/MusicBeatGroup.hx index 5cccf0f6..0e723ecd 100644 --- a/source/funkin/backend/MusicBeatGroup.hx +++ b/source/funkin/backend/MusicBeatGroup.hx @@ -2,6 +2,9 @@ package funkin.backend; import funkin.backend.system.interfaces.IBeatReceiver; +/** + * Group of FlxSprites, if the sprite implements `IBeatReceiver`, then beatHit, stepHit and measureHit will be called. +**/ class MusicBeatGroup extends FlxTypedSpriteGroup implements IBeatReceiver { public function beatHit(curBeat:Int) { for(e in members) if (e is IBeatReceiver) ({var _:IBeatReceiver = cast e;_;}).beatHit(curBeat); diff --git a/source/funkin/backend/MusicBeatState.hx b/source/funkin/backend/MusicBeatState.hx index 2413d8ba..5ff8b6df 100644 --- a/source/funkin/backend/MusicBeatState.hx +++ b/source/funkin/backend/MusicBeatState.hx @@ -13,6 +13,10 @@ import funkin.backend.system.framerate.Framerate; import funkin.backend.system.interfaces.IBeatReceiver; import funkin.options.PlayerSettings; +/** + * Base class for all the states. + * Handles the scripts, the transitions, and the beat and step events. +**/ class MusicBeatState extends FlxState implements IBeatReceiver { private var lastBeat:Float = 0; @@ -93,6 +97,9 @@ class MusicBeatState extends FlxState implements IBeatReceiver public var scriptsAllowed:Bool = true; + public static var lastScriptName:String = null; + public static var lastStateName:String = null; + public var scriptName:String = null; public static var skipTransOut:Bool = false; @@ -108,7 +115,12 @@ class MusicBeatState extends FlxState implements IBeatReceiver public function new(scriptsAllowed:Bool = true, ?scriptName:String) { super(); this.scriptsAllowed = #if SOFTCODED_STATES scriptsAllowed #else false #end; - this.scriptName = scriptName; + + if(lastStateName != (lastStateName = Type.getClassName(Type.getClass(this)))) { + lastScriptName = null; + } + this.scriptName = scriptName != null ? scriptName : lastScriptName; + lastScriptName = this.scriptName; } function loadScript() { diff --git a/source/funkin/backend/MusicBeatSubstate.hx b/source/funkin/backend/MusicBeatSubstate.hx index cee1ad5b..6cb0d33a 100644 --- a/source/funkin/backend/MusicBeatSubstate.hx +++ b/source/funkin/backend/MusicBeatSubstate.hx @@ -11,13 +11,17 @@ import funkin.backend.system.Controls; import funkin.backend.system.interfaces.IBeatReceiver; import funkin.options.PlayerSettings; +/** + * Base class for all the sub states. + * Handles the scripts, the transitions, and the beat and step events. +**/ class MusicBeatSubstate extends FlxSubState implements IBeatReceiver { private var lastBeat:Float = 0; private var lastStep:Float = 0; /** - * Whether this specifc substate can open custom transitions + * Whether this specific substate can open custom transitions */ public var canOpenCustomTransition:Bool = false; /** diff --git a/source/funkin/backend/MusicBeatTransition.hx b/source/funkin/backend/MusicBeatTransition.hx index 7bb1805d..0cb44df0 100644 --- a/source/funkin/backend/MusicBeatTransition.hx +++ b/source/funkin/backend/MusicBeatTransition.hx @@ -2,14 +2,23 @@ package funkin.backend; import flixel.FlxState; import flixel.tweens.FlxTween; +import funkin.backend.scripting.Script; +import funkin.backend.scripting.events.CancellableEvent; +import funkin.backend.scripting.events.TransitionCreationEvent; import funkin.backend.utils.FunkinParentDisabler; class MusicBeatTransition extends MusicBeatSubstate { + public static var script:String = Flags.DEFAULT_TRANSITION_SCRIPT; + public var transitionScript:Script; + var nextFrameSkip:Bool = false; public var transitionTween:FlxTween = null; public var transitionCamera:FlxCamera; public var newState:FlxState; + public var transOut:Bool = false; + + public var allowSkip:Bool = true; public var blackSpr:FlxSprite; public var transitionSprite:FunkinSprite; @@ -20,16 +29,30 @@ class MusicBeatTransition extends MusicBeatSubstate { public override function create() { if (newState != null) - add(new FunkinParentDisabler(true)); + add(new FunkinParentDisabler(true, false)); transitionCamera = new FlxCamera(); transitionCamera.bgColor = 0; FlxG.cameras.add(transitionCamera, false); cameras = [transitionCamera]; - var out = newState != null; - blackSpr = new FlxSprite(0, out ? -transitionCamera.height : transitionCamera.height).makeGraphic(1, 1, -1); + transitionScript = Script.create(Paths.script(script)); + transitionScript.setParent(this); + transitionScript.load(); + + var event = EventManager.get(TransitionCreationEvent).recycle(newState != null, newState); + transitionScript.call('create', [event]); + + transOut = event.transOut; + newState = event.newState; + + if (event.cancelled) { + super.create(); + return; + } + + blackSpr = new FlxSprite(0, transOut ? -transitionCamera.height : transitionCamera.height).makeGraphic(1, 1, -1); blackSpr.scale.set(transitionCamera.width, transitionCamera.height); blackSpr.color = 0xFF000000; blackSpr.updateHitbox(); @@ -43,7 +66,7 @@ class MusicBeatTransition extends MusicBeatSubstate { } else { transitionSprite.screenCenter(); } - transitionCamera.flipY = !out; + transitionCamera.flipY = !transOut; add(transitionSprite); transitionCamera.scroll.y = transitionCamera.height; @@ -55,41 +78,59 @@ class MusicBeatTransition extends MusicBeatSubstate { }); super.create(); + transitionScript.call('postCreate', [event]); } public override function update(elapsed:Float) { + transitionScript.call('update', [elapsed]); super.update(elapsed); if (nextFrameSkip) { - finish(); - return; + var event = new CancellableEvent(); + transitionScript.call('onSkip', [event]); + if (!event.cancelled) { + finish(); + return; + } } - if (!parent.persistentUpdate && FlxG.keys.pressed.SHIFT) { + if (allowSkip && !parent.persistentUpdate && FlxG.keys.pressed.SHIFT) { // skip if (newState != null) { nextFrameSkip = true; parent.persistentDraw = false; } else { - finish(); + var event = new CancellableEvent(); + transitionScript.call('onSkip', [event]); + if (!event.cancelled) { + finish(); + } } } + transitionScript.call('postUpdate', [elapsed]); } public function finish() { + var event = new CancellableEvent(); + transitionScript.call('onFinish', [event]); + if (event.cancelled) return; + if (newState != null) FlxG.switchState(newState); close(); + + transitionScript.call('onPostFinish'); } public override function destroy() { - if (transitionTween != null) - transitionTween.cancel(); + transitionScript.call('destroy'); + + if (transitionTween != null) transitionTween.cancel(); transitionTween = FlxDestroyUtil.destroy(transitionTween); - if (newState == null && FlxG.cameras.list.contains(transitionCamera)) - FlxG.cameras.remove(transitionCamera); - else - transitionCamera.bgColor = 0xFF000000; + if (newState == null && FlxG.cameras.list.contains(transitionCamera)) FlxG.cameras.remove(transitionCamera); + else transitionCamera.bgColor = 0xFF000000; + + transitionScript.destroy(); super.destroy(); } } \ No newline at end of file diff --git a/source/funkin/backend/assets/ModsFolder.hx b/source/funkin/backend/assets/ModsFolder.hx index 68074ea8..cd5cf515 100644 --- a/source/funkin/backend/assets/ModsFolder.hx +++ b/source/funkin/backend/assets/ModsFolder.hx @@ -42,8 +42,9 @@ class ModsFolder { * Whenever its the first time mods has been reloaded. */ private static var __firstTime:Bool = true; + /** - * Initialises `mods` folder. + * Initializes `mods` folder. */ public static function init() { if(!getModsList().contains(Options.lastLoadedMod)) @@ -85,7 +86,12 @@ class ModsFolder { public static function getModsList():Array { var mods:Array = []; #if MOD_SUPPORT - for(modFolder in FileSystem.readDirectory(modsPath)) { + final modsList:Array = FileSystem.readDirectory(modsPath); + + if (modsList == null || modsList.length <= 0) + return mods; + + for (modFolder in modsList) { if (FileSystem.isDirectory(modsPath + modFolder)) { mods.push(modFolder); } else { @@ -151,4 +157,4 @@ class ModsFolder { return prepareModLibrary(libName, new ZipFolderLibrary(zipPath, libName, modName), force); } #end -} \ No newline at end of file +} diff --git a/source/funkin/backend/chart/BaseGameParser.hx b/source/funkin/backend/chart/BaseGameParser.hx index 84b281aa..02c89c81 100644 --- a/source/funkin/backend/chart/BaseGameParser.hx +++ b/source/funkin/backend/chart/BaseGameParser.hx @@ -15,9 +15,9 @@ class BaseGameParser { result.customValues = {}; result.customValues.timeChanges = data.timeChanges; - var firstTimeChng:SwagTimeChange = data.timeChanges[0]; - result.bpm = firstTimeChng.bpm; - result.beatsPerMeasure = firstTimeChng.b != null ? firstTimeChng.b : Flags.DEFAULT_BEATS_PER_MEASURE; + var firstTimeChange:SwagTimeChange = data.timeChanges[0]; + result.bpm = firstTimeChange.bpm; + result.beatsPerMeasure = firstTimeChange.b != null ? firstTimeChange.b : Flags.DEFAULT_BEATS_PER_MEASURE; result.difficulties = data.playData.difficulties.concat(data.playData.songVariations); Reflect.deleteField(data.playData, "difficulties"); diff --git a/source/funkin/backend/chart/Chart.hx b/source/funkin/backend/chart/Chart.hx index 48ee9d8a..37d82d44 100644 --- a/source/funkin/backend/chart/Chart.hx +++ b/source/funkin/backend/chart/Chart.hx @@ -1,5 +1,6 @@ package funkin.backend.chart; +import funkin.backend.chart.ChartData; import flixel.util.FlxColor; import funkin.backend.chart.ChartData; import haxe.Json; @@ -11,9 +12,65 @@ import sys.FileSystem; using StringTools; -final class Chart { +enum abstract ChartFormat(Int) { + var CODENAME = 0; + var LEGACY = 1; // also used by many other engines (old Psych, Kade and more) - Nex + var VSLICE = 2; + var PSYCH_NEW = 3; + + @:to public function toString():String { + return switch(cast (this, ChartFormat)) { + case CODENAME: "CODENAME"; + case LEGACY: "LEGACY"; + case VSLICE: "VSLICE"; + case PSYCH_NEW: "PSYCH_NEW"; + } + } + + public static function fromString(str:String, def:ChartFormat = ChartFormat.LEGACY) { + str = str.toLowerCase(); + str = StringTools.replace(str, " ", ""); + str = StringTools.replace(str, "_", ""); + str = StringTools.replace(str, ".", ""); + + if(StringTools.startsWith(str, "psychv1") || StringTools.startsWith(str, "psych1")) + return PSYCH_NEW; + + return switch(str) { + case "codename" | "codenameengine": CODENAME; + case "newpsych" | "psychnew": PSYCH_NEW; + default: def; + } + } +} + +class Chart { public static final version:String = "1.6.0"; + public static function cleanSongData(data:Dynamic):Dynamic { + if (Reflect.hasField(data, "song")) { + var field:Dynamic = Reflect.field(data, "song"); + if (field != null && Type.typeof(field) == TObject) // Cant use Reflect.isObject, because it detects strings for some reason + return field; + } + return data; + } + + public static function detectChartFormat(data:Dynamic):ChartFormat { + var __temp:Dynamic; // imma reuse this var so the program doesn't have to get values multiple times - Nex + + if ((__temp = data.codenameChart) == true || __temp == "true") + return CODENAME; + + if (Reflect.hasField(data, "version") && Reflect.hasField(data, "scrollSpeed")) + return VSLICE; + + if ((__temp = cleanSongData(data).format) != null && __temp is String && StringTools.startsWith(__temp, "psych_v1")) + return PSYCH_NEW; + + return LEGACY; + } + public static function loadEventsJson(songName:String) { var path = Paths.file('songs/${songName.toLowerCase()}/events.json'); var data:Array = null; @@ -30,8 +87,9 @@ final class Chart { public static function loadChartMeta(songName:String, ?difficulty:String, fromMods:Bool = true) { if (difficulty == null) difficulty = Flags.DEFAULT_DIFFICULTY; - var metaPath = Paths.file('songs/${songName.toLowerCase()}/meta.json'); - var metaDiffPath = Paths.file('songs/${songName.toLowerCase()}/meta-${difficulty.toLowerCase()}.json'); + var songNameLower = songName.toLowerCase(); + var metaPath = Paths.file('songs/${songNameLower}/meta.json'); + var metaDiffPath = Paths.file('songs/${songNameLower}/meta-${difficulty.toLowerCase()}.json'); var data:ChartMetaData = null; var fromMods:Bool = fromMods; @@ -64,7 +122,7 @@ final class Chart { data.setFieldDefault("parsedColor", data.color.getColorFromDynamic().getDefault(Flags.DEFAULT_COLOR)); if (data.difficulties.length <= 0) { - data.difficulties = [for(f in Paths.getFolderContent('songs/${songName.toLowerCase()}/charts/', false, fromMods ? MODS : SOURCE)) if (Path.extension(f = f.toUpperCase()) == "JSON") Path.withoutExtension(f)]; + data.difficulties = [for(f in Paths.getFolderContent('songs/${songNameLower}/charts/', false, fromMods ? MODS : SOURCE)) if (Path.extension(f = f.toUpperCase()) == "JSON") Path.withoutExtension(f)]; if (data.difficulties.length == 3) { var hasHard = false, hasNormal = false, hasEasy = false; for(d in data.difficulties) { @@ -115,12 +173,12 @@ final class Chart { Logs.trace('Could not parse chart for song ${songName} ($difficulty): ${Std.string(e)}', ERROR, RED); } - if (data != null) { - /** - * CHART CONVERSION - */ - #if REGION - if (Reflect.hasField(data, "codenameChart") && Reflect.field(data, "codenameChart") == true) { + /** + * CHART CONVERSION + */ + #if REGION + if (data != null) switch (detectChartFormat(data)) { + case CODENAME: // backward compat on events since its caused problems var eventTypesToString:Map = [ -1 => "HScript Call", @@ -131,28 +189,23 @@ final class Chart { ]; if (data.events == null) data.events = []; - for (event in cast(data.events, Array)) { - if (Reflect.hasField(event, "type")) { - if(event.type != null) - event.name = eventTypesToString[event.type]; - Reflect.deleteField(event, "type"); - } + for (event in cast(data.events, Array)) if (Reflect.hasField(event, "type")) { + if (event.type != null) + event.name = eventTypesToString[event.type]; + Reflect.deleteField(event, "type"); } - // codename chart base = data; - } else { - // base game chart - FNFLegacyParser.parse(data, base); - } - #end + case PSYCH_NEW: PsychParser.parse(data, base); + case VSLICE: // TODO + case LEGACY: FNFLegacyParser.parse(data, base); } + #end - if (base.meta == null) - base.meta = loadChartMeta(songName, difficulty, base.fromMods); + var loadedMeta = loadChartMeta(songName, difficulty, base.fromMods); + if (base.meta == null) base.meta = loadedMeta; else { - var loadedMeta = loadChartMeta(songName, difficulty, base.fromMods); - for(field in Reflect.fields(base.meta)) { + for (field in Reflect.fields(base.meta)) { var f = Reflect.field(base.meta, field); if (f != null) Reflect.setField(loadedMeta, field, f); @@ -257,4 +310,4 @@ typedef ChartSaveSettings = { var ?saveEventsInChart:Bool; var ?prettyPrint:Bool; var ?folder:String; -} +} \ No newline at end of file diff --git a/source/funkin/backend/chart/ChartData.hx b/source/funkin/backend/chart/ChartData.hx index e84540b0..5f7f96f4 100644 --- a/source/funkin/backend/chart/ChartData.hx +++ b/source/funkin/backend/chart/ChartData.hx @@ -47,7 +47,7 @@ typedef ChartStrumLine = { var ?vocalsSuffix:String; var ?keyCount:Int; // default=4 - var ?strumLinePos:Float; // Backwards compatability + var ?strumLinePos:Float; // Backwards compatibility } typedef ChartNote = { diff --git a/source/funkin/backend/chart/FNFLegacyParser.hx b/source/funkin/backend/chart/FNFLegacyParser.hx index e4e60d9b..2ba3e809 100644 --- a/source/funkin/backend/chart/FNFLegacyParser.hx +++ b/source/funkin/backend/chart/FNFLegacyParser.hx @@ -3,15 +3,14 @@ package funkin.backend.chart; import funkin.backend.chart.ChartData.ChartEvent; import funkin.backend.system.Conductor; +/** + * Legacy FNF chart parser. + * This is for charts that that were made before v0.5.0. +**/ class FNFLegacyParser { public static function parse(data:Dynamic, result:ChartData) { // base fnf chart parsing - var data:SwagSong = data; - if (Reflect.hasField(data, "song")) { - var field:Dynamic = Reflect.field(data, "song"); - if (!(field is String)) - data = field; - } + var data:SwagSong = Chart.cleanSongData(data); result.scrollSpeed = data.speed; result.stage = data.stage; @@ -29,7 +28,7 @@ class FNFLegacyParser { position: "boyfriend", notes: [] }); - var gfName = data.gf != null ? data.gf : (data.gfVersion != null ? data.gfVersion : "gf"); + var gfName = data.gf != null ? data.gf : (data.gfVersion != null ? data.gfVersion : (data.player3 != null ? data.player3 : "gf")); if (!p2isGF && gfName != "none") { result.strumLines.push({ characters: [gfName], @@ -214,6 +213,7 @@ typedef SwagSong = var player1:String; var player2:String; + var ?player3:String; // alt for gf but idr if it was just used in psych or what but eh whatever maybe its better here anyways - Nex var ?gf:String; var ?gfVersion:String; var validScore:Bool; diff --git a/source/funkin/backend/chart/PsychParser.hx b/source/funkin/backend/chart/PsychParser.hx index 5fb420d3..731857cc 100644 --- a/source/funkin/backend/chart/PsychParser.hx +++ b/source/funkin/backend/chart/PsychParser.hx @@ -5,16 +5,38 @@ import funkin.backend.chart.FNFLegacyParser.SwagSection; import funkin.backend.chart.FNFLegacyParser.SwagSong; import funkin.backend.system.Conductor; +/** + * Parser for Psych Charts. + * Both for pre-v1.0.0 and v1.0.0 charts. +**/ class PsychParser { - // Alreadly parsed in sections + // Already parsed in sections public static var ignoreEvents:Array = [ "Camera Movement", "Alt Animation Toggle", "BPM Change" ]; - public static function parse(data:Dynamic, result:ChartData) + /** + * Converts 1.0 Psych charts to older ones + */ + public static function standardize(data:Dynamic, result:ChartData) { + var sectionsData:Array = Chart.cleanSongData(data).notes; + if (sectionsData == null) return; + + for (section in sectionsData) for (note in cast(section.sectionNotes, Array)) { + var gottaHitNote:Bool = section.mustHitSection == (note[1] >= 4); + note[1] = (note[1] % 4) + (gottaHitNote ? 4 : 0); + + if (note[3] != null && Std.isOfType(note[3], String)) + note[3] = Chart.addNoteType(result, note[3]); + } + } + + public static function parse(data:Dynamic, result:ChartData) { + if (Chart.detectChartFormat(data) == PSYCH_NEW) standardize(data, result); FNFLegacyParser.parse(data, result); + } public static function encode(chart:ChartData):Dynamic { var base:SwagSong = FNFLegacyParser.__convertToSwagSong(chart); @@ -44,7 +66,7 @@ class PsychParser { if ((swagSection.mustHitSection && strumLine.type == OPPONENT) || (!swagSection.mustHitSection && strumLine.type == PLAYER)) sectionNote[1] += 4; - swagSection.sectionNotes.push(sectionNote); + swagSection.sectionNotes.push(sectionNote); } } @@ -88,10 +110,10 @@ class PsychParser { var eventStep:Float = Conductor.getStepForTime(event.time); psychEvents.push([ "Change Scroll Speed", - FlxMath.roundDecimal(event.params[1]/chart.scrollSpeed, 2), // SCROLL SPEED MULTIPLER + FlxMath.roundDecimal(event.params[1]/chart.scrollSpeed, 2), // SCROLL SPEED MULTIPLIER FlxMath.roundDecimal( // TIME event.params[0] ? // IS TWEENED? - (Conductor.getTimeForStep(eventStep+event.params[2]) - Conductor.getTimeForStep(eventStep))/1000 + (Conductor.getTimeForStep(eventStep+event.params[2]) - Conductor.getTimeForStep(eventStep))/1000 : 0, 2) ]); default: diff --git a/source/funkin/backend/scripting/EventManager.hx b/source/funkin/backend/scripting/EventManager.hx index 90b67b4c..162d72fa 100644 --- a/source/funkin/backend/scripting/EventManager.hx +++ b/source/funkin/backend/scripting/EventManager.hx @@ -4,7 +4,7 @@ import flixel.FlxState; import funkin.backend.scripting.events.*; final class EventManager { - // map doesnt work for that + // map doesn't work for that public static var eventValues:Array = []; public static var eventKeys:Array> = []; diff --git a/source/funkin/backend/scripting/GlobalScript.hx b/source/funkin/backend/scripting/GlobalScript.hx index d3b8aded..08d39d62 100644 --- a/source/funkin/backend/scripting/GlobalScript.hx +++ b/source/funkin/backend/scripting/GlobalScript.hx @@ -11,11 +11,11 @@ import funkin.backend.system.Conductor; class GlobalScript { public static var scripts:ScriptPack; - private static var initalized:Bool = false; + private static var initialized:Bool = false; public static function init() { - if(initalized) return; - initalized = true; + if(initialized) return; + initialized = true; #if MOD_SUPPORT ModsFolder.onModSwitch.add(onModSwitch); #end diff --git a/source/funkin/backend/scripting/HScript.hx b/source/funkin/backend/scripting/HScript.hx index 62a80fe4..f937d3dc 100644 --- a/source/funkin/backend/scripting/HScript.hx +++ b/source/funkin/backend/scripting/HScript.hx @@ -16,7 +16,7 @@ class HScript extends Script { public static function initParser() { var parser = new Parser(); parser.allowJSON = parser.allowMetadata = parser.allowTypes = true; - parser.preprocesorValues = Script.getDefaultPreprocessors(); + parser.preprocessorValues = Script.getDefaultPreprocessors(); return parser; } diff --git a/source/funkin/backend/scripting/Script.hx b/source/funkin/backend/scripting/Script.hx index 12bf14c0..b4b46791 100644 --- a/source/funkin/backend/scripting/Script.hx +++ b/source/funkin/backend/scripting/Script.hx @@ -8,6 +8,7 @@ import lime.app.Application; @:allow(funkin.backend.scripting.ScriptPack) /** * Class used for scripting. + * Use `Script.create` to create a script. */ class Script extends FlxBasic implements IFlxDestroyable { /** @@ -16,6 +17,9 @@ class Script extends FlxBasic implements IFlxDestroyable { */ public static var staticVariables:Map = []; + /** + * Gets the default variables for a script. + */ public static function getDefaultVariables(?script:Script):Map { return [ // Haxe related stuff @@ -104,7 +108,6 @@ class Script extends FlxBasic implements IFlxDestroyable { **/ public static function getDefaultImportRedirects():Map { var redirects:Map = [ - "funkin.savedata.FunkinSave" => "funkin.backend.utils.FunkinSave" ]; final events = "funkin.backend.scripting.events."; @@ -141,6 +144,10 @@ class Script extends FlxBasic implements IFlxDestroyable { return redirects; } + /** + * Gets the default defines for a script. + * Includes all of the defines that the build was compiled with. + */ public static function getDefaultPreprocessors():Map { var defines = funkin.backend.system.macros.DefinesMacro.defines; defines.set("CODENAME_ENGINE", true); @@ -182,6 +189,10 @@ class Script extends FlxBasic implements IFlxDestroyable { private var didLoad:Bool = false; + /** + * Remapped filenames. + * Used for trace messages, to show what mod the script is from. + */ public var remappedNames:Map = []; /** @@ -307,7 +318,7 @@ class Script extends FlxBasic implements IFlxDestroyable { } /** - * Loads the code from a string, doesnt really work after the script has been loaded + * Loads the code from a string, doesn't really work after the script has been loaded * @param code The code. */ public function loadFromString(code:String) { @@ -366,7 +377,14 @@ class Script extends FlxBasic implements IFlxDestroyable { private function onCall(func:String, parameters:Array):Dynamic { return null; } + /** + * Called when the script is created. + * @param path Path to the script + */ public function onCreate(path:String) {} + /** + * Called when the script is loaded. + */ public function onLoad() {} } \ No newline at end of file diff --git a/source/funkin/backend/scripting/ScriptPack.hx b/source/funkin/backend/scripting/ScriptPack.hx index 32c590fc..4e9af4f7 100644 --- a/source/funkin/backend/scripting/ScriptPack.hx +++ b/source/funkin/backend/scripting/ScriptPack.hx @@ -3,6 +3,9 @@ package funkin.backend.scripting; import flixel.util.FlxStringUtil; import funkin.backend.scripting.events.CancellableEvent; +/** + * Used to group multiple scripts together, and easily be able to call them. +**/ @:access(CancellableEvent) class ScriptPack extends Script { public var scripts:Array