From f62f695134957512c75202e707d44fad4dc2dd70 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Thu, 23 Mar 2023 18:24:31 +0100 Subject: [PATCH] bro i have so many changes if i have a merge conflict --- Project.xml | 7 +-- source/funkin/editors/charter/Charter.hx | 21 ++++++-- source/funkin/editors/charter/CharterNote.hx | 5 +- .../editors/charter/CharterNoteGroup.hx | 50 ++++++++++++++++++ source/funkin/game/Note.hx | 2 + source/funkin/macros/BuildCounterMacro.hx | 28 ---------- source/funkin/macros/GitCommitMacro.hx | 52 ++++++++++++++++--- source/funkin/menus/MainMenuState.hx | 2 +- source/funkin/scripting/Script.hx | 6 ++- source/funkin/system/Main.hx | 4 -- .../system/framerate/CodenameBuildField.hx | 3 +- 11 files changed, 127 insertions(+), 53 deletions(-) create mode 100644 source/funkin/editors/charter/CharterNoteGroup.hx delete mode 100644 source/funkin/macros/BuildCounterMacro.hx diff --git a/Project.xml b/Project.xml index 02417b46..f014c797 100644 --- a/Project.xml +++ b/Project.xml @@ -131,8 +131,8 @@ - - + + @@ -168,9 +168,6 @@ - - - diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 206107eb..a7ffb382 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -45,7 +45,7 @@ class Charter extends UIState { * ACTUAL CHART DATA */ public var strumLines:Array = []; - public var notesGroup:FlxTypedGroup = new FlxTypedGroup(); + public var notesGroup:CharterNoteGroup = new CharterNoteGroup(); /** * CAMERAS @@ -308,12 +308,13 @@ class Charter extends UIState { } selectionBoxEnabled = false; + } else if (selection.length > 0) { + selection = []; } else { // place note var note = new CharterNote(); note.updatePos(FlxG.keys.pressed.SHIFT ? (mousePos.y / 40) : Std.int(mousePos.y / 40), Std.int(mousePos.x / 40), 0, 0); notesGroup.add(note); - selection = [note]; addToUndo(CPlaceNote(note)); } } @@ -362,6 +363,7 @@ class Charter extends UIState { for(n in notes) { notesGroup.remove(n, true); n.kill(); + selection.remove(n); } case CDeleteNotes(notes): for(n in notes) { @@ -372,6 +374,7 @@ class Charter extends UIState { case CPlaceNote(note): notesGroup.remove(note, true); note.kill(); + selection.remove(note); } if (v != null) redoList.insert(0, v); @@ -460,8 +463,12 @@ class Charter extends UIState { Conductor.songPosition = FlxMath.bound(Conductor.songPosition, 0, FlxG.sound.music.length); - conductorFollowerSpr.y = curStepFloat * 40; - charterCamera.scroll.set(conductorFollowerSpr.x + conductorFollowerSpr.scale.x - (FlxG.width / 2), conductorFollowerSpr.y - (FlxG.height * 0.25)); + if (FlxG.sound.music.playing) { + conductorFollowerSpr.y = curStepFloat * 40; + } else { + conductorFollowerSpr.y = lerp(conductorFollowerSpr.y, curStepFloat * 40, 1/3); + } + charterCamera.scroll.set(conductorFollowerSpr.x + conductorFollowerSpr.scale.x - (FlxG.width / 2), conductorFollowerSpr.y - (FlxG.height * 0.5)); } @@ -475,16 +482,20 @@ class Charter extends UIState { selection = deleteNotes(selection); } function _playback_back(_) { + if (FlxG.sound.music.playing) return; Conductor.songPosition -= Conductor.beatsPerMesure * __crochet; } function _playback_forward(_) { + if (FlxG.sound.music.playing) return; Conductor.songPosition += Conductor.beatsPerMesure * __crochet; } function _playback_start(_) { + if (FlxG.sound.music.playing) return; Conductor.songPosition = 0; } function _playback_end(_) { - Conductor.songPosition = FlxG.sound.music.time; + if (FlxG.sound.music.playing) return; + Conductor.songPosition = FlxG.sound.music.length; } #end } diff --git a/source/funkin/editors/charter/CharterNote.hx b/source/funkin/editors/charter/CharterNote.hx index 8e87dbc8..e6effaf5 100644 --- a/source/funkin/editors/charter/CharterNote.hx +++ b/source/funkin/editors/charter/CharterNote.hx @@ -20,6 +20,8 @@ class CharterNote extends UISprite { angle = 45; // green-red inbetween cursor = BUTTON; + + moves = false; } @@ -65,7 +67,8 @@ class CharterNote extends UISprite { } public override function update(elapsed:Float) { - super.update(elapsed); + super.update(elapsed); + colorTransform.redMultiplier = colorTransform.greenMultiplier = colorTransform.blueMultiplier = selected ? 0.75 : 1; colorTransform.redOffset = colorTransform.greenOffset = selected ? 96 : 0; colorTransform.blueOffset = selected ? 168 : 0; diff --git a/source/funkin/editors/charter/CharterNoteGroup.hx b/source/funkin/editors/charter/CharterNoteGroup.hx new file mode 100644 index 00000000..326bb7a1 --- /dev/null +++ b/source/funkin/editors/charter/CharterNoteGroup.hx @@ -0,0 +1,50 @@ +package funkin.editors.charter; + +import funkin.system.Conductor; + +class CharterNoteGroup extends FlxTypedGroup { + var __loopSprite:CharterNote; + var i:Int = 0; + var max:Float = 0; + var __currentlyLooping:Bool = false; + + public override function forEach(noteFunc:CharterNote->Void, recursive:Bool = false) { + i = 0; + __loopSprite = null; + + max = FlxG.height / 70 / camera.zoom; + + var oldCur = __currentlyLooping; + __currentlyLooping = true; + + while(i < length) { + __loopSprite = members[i]; + if (__loopSprite == null || !__loopSprite.exists) { + i++; + continue; + } + if (Math.abs(__loopSprite.step - Conductor.curStepFloat) < max) + noteFunc(__loopSprite); + i++; + } + __currentlyLooping = oldCur; + } + + public override function draw() { + @:privateAccess var oldDefaultCameras = FlxCamera._defaultCameras; + @:privateAccess if (cameras != null) FlxCamera._defaultCameras = cameras; + + forEach((n) -> n.draw()); + + @:privateAccess FlxCamera._defaultCameras = oldDefaultCameras; + } + + public override function update(elapsed:Float) { + @:privateAccess var oldDefaultCameras = FlxCamera._defaultCameras; + @:privateAccess if (cameras != null) FlxCamera._defaultCameras = cameras; + + forEach((n) -> n.update(elapsed)); + + @:privateAccess FlxCamera._defaultCameras = oldDefaultCameras; + } +} \ No newline at end of file diff --git a/source/funkin/game/Note.hx b/source/funkin/game/Note.hx index 2fee02a3..f6f2cf94 100644 --- a/source/funkin/game/Note.hx +++ b/source/funkin/game/Note.hx @@ -93,6 +93,8 @@ class Note extends FlxSprite public function new(strumLine:StrumLine, noteData:ChartNote, sustain:Bool = false, sustainLength:Float = 0, sustainOffset:Float = 0) { super(); + + moves = false; this.prevNote = strumLine.notes.members.last(); this.noteTypeID = noteData.type.getDefault(0); diff --git a/source/funkin/macros/BuildCounterMacro.hx b/source/funkin/macros/BuildCounterMacro.hx deleted file mode 100644 index 6f18d997..00000000 --- a/source/funkin/macros/BuildCounterMacro.hx +++ /dev/null @@ -1,28 +0,0 @@ -package funkin.macros; - -#if !macro -import haxe.macro.Expr.Field; -import haxe.macro.Context; -#end -#if sys -import sys.io.File; -#end - -/** - * Macro that loads the current build number from `buildnumber.txt`, then make it available as an integer. - * - * `buildnumber.txt` is automatically incremented when the engine is launched with `lime test windows`. - */ -class BuildCounterMacro { - /** - * Returns the obtained build number. - */ - public static macro function getBuildNumber():haxe.macro.Expr.ExprOf { - #if !display - var buildNum:Int = Std.parseInt(File.getContent("buildnumber.txt")); - return macro $v{buildNum+1}; - #else - return macro $v{0}; - #end - } -} \ No newline at end of file diff --git a/source/funkin/macros/GitCommitMacro.hx b/source/funkin/macros/GitCommitMacro.hx index b7227ba7..f6f73c67 100644 --- a/source/funkin/macros/GitCommitMacro.hx +++ b/source/funkin/macros/GitCommitMacro.hx @@ -1,16 +1,56 @@ package funkin.macros; +#if macro +import sys.io.Process; +#end + class GitCommitMacro { - public static macro function getCommitNumber() { + /** + * Returns the current commit number + */ + public static var commitNumber(get, null):Int; + /** + * Returns the current commit hash + */ + public static var commitHash(get, null):String; + + // GETTERS + #if REGION + private static inline function get_commitNumber() + return __getCommitNumber(); + + private static inline function get_commitHash() + return __getCommitHash(); + #end + + // INTERNAL MACROS + #if REGION + private static macro function __getCommitHash() { + #if display + return macro $v{"-"}; + #else + try { + var proc = new Process('git', ['rev-parse', '--short', 'HEAD'], false); + proc.exitCode(true); + + return macro $v{proc.stdout.readLine()}; + } catch(e) {} + return macro $v{"-"} + #end + } + + private static macro function __getCommitNumber() { #if display return macro $v{0}; #else - var proc = new Process('git', ['rev-list', 'HEAD', '--count'], false); - proc.exitCode(true); + try { + var proc = new Process('git', ['rev-list', 'HEAD', '--count'], false); + proc.exitCode(true); - var c = Std.parseInt(proc.stdout.readLine()); - trace(c); - return macro $v{c}; + return macro $v{Std.parseInt(proc.stdout.readLine())}; + } catch(e) {} + return macro $v{0} #end } + #end } \ No newline at end of file diff --git a/source/funkin/menus/MainMenuState.hx b/source/funkin/menus/MainMenuState.hx index 5072107a..0ed425f4 100644 --- a/source/funkin/menus/MainMenuState.hx +++ b/source/funkin/menus/MainMenuState.hx @@ -76,7 +76,7 @@ class MainMenuState extends MusicBeatState FlxG.camera.follow(camFollow, null, 0.06); - var versionShit:FunkinText = new FunkinText(5, FlxG.height - 2, 0, 'Codename Engine v${Application.current.meta.get('version')}\nBeta: Build ${funkin.macros.BuildCounterMacro.getBuildNumber()}\n[TAB] Open Mods menu\n'); + var versionShit:FunkinText = new FunkinText(5, FlxG.height - 2, 0, 'Codename Engine v${Application.current.meta.get('version')}\nBeta: Commit ${funkin.macros.GitCommitMacro.commitNumber} (${funkin.macros.GitCommitMacro.commitHash})\n[TAB] Open Mods menu\n'); versionShit.scrollFactor.set(); versionShit.y -= versionShit.height; add(versionShit); diff --git a/source/funkin/scripting/Script.hx b/source/funkin/scripting/Script.hx index b425e8ce..7ec3f4e8 100644 --- a/source/funkin/scripting/Script.hx +++ b/source/funkin/scripting/Script.hx @@ -51,7 +51,8 @@ class Script extends FlxBasic implements IFlxDestroyable { // Engine related stuff "engine" => { - build: funkin.macros.BuildCounterMacro.getBuildNumber(), + commit: funkin.macros.GitCommitMacro.commitNumber, + build: 2675, // 2675 being the last build num before it was removed name: "Codename Engine" }, "ModState" => funkin.scripting.ModState, @@ -91,7 +92,8 @@ class Script extends FlxBasic implements IFlxDestroyable { return [ "CODENAME_ENGINE" => true, "CODENAME_VER" => Application.current.meta.get('version'), - "CODENAME_BUILD" => funkin.macros.BuildCounterMacro.getBuildNumber(), + "CODENAME_BUILD" => 2675, + "CODENAME_COMMIT" => funkin.macros.GitCommitMacro.commitNumber, "desktop" => #if desktop true #else false #end, "windows" => #if windows true #else false #end, "hl" => #if hl true #else false #end, diff --git a/source/funkin/system/Main.hx b/source/funkin/system/Main.hx index 6038c232..88f1a39d 100644 --- a/source/funkin/system/Main.hx +++ b/source/funkin/system/Main.hx @@ -178,10 +178,6 @@ class Main extends Sprite Paths.assetsTree.addLibrary(ModsFolder.loadLibraryFromFolder('assets', './${pathBack}assets/', true)); Paths.assetsTree.sourceLibsAmount++; #end - - var buildNum:Int = Std.parseInt(File.getContent('./${pathBack}buildnumber.txt')); - buildNum++; - File.saveContent('./${pathBack}buildnumber.txt', Std.string(buildNum)); } else { #if USE_ADAPTED_ASSETS Paths.assetsTree.addLibrary(ModsFolder.loadLibraryFromFolder('assets', './assets/', true)); diff --git a/source/funkin/system/framerate/CodenameBuildField.hx b/source/funkin/system/framerate/CodenameBuildField.hx index 05c411a0..10fe06f4 100644 --- a/source/funkin/system/framerate/CodenameBuildField.hx +++ b/source/funkin/system/framerate/CodenameBuildField.hx @@ -3,6 +3,7 @@ package funkin.system.framerate; import openfl.text.TextFormat; import openfl.display.Sprite; import openfl.text.TextField; +import funkin.macros.GitCommitMacro; class CodenameBuildField extends TextField { public function new() { @@ -10,6 +11,6 @@ class CodenameBuildField extends TextField { defaultTextFormat = Framerate.textFormat; autoSize = LEFT; multiline = wordWrap = false; - text = 'Codename Engine Beta\nBuild ${funkin.macros.BuildCounterMacro.getBuildNumber()}'; + text = 'Codename Engine Beta\nCommit ${GitCommitMacro.commitNumber} (${GitCommitMacro.commitHash})'; } } \ No newline at end of file