From 5ad32adfbc93a41de31bc8bce7f0fcc10cdf4aa4 Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Thu, 5 Dec 2024 22:18:15 +0100 Subject: [PATCH] sparrow + markers in results --- .../dialogs/results/ResultsAnimDialog.hx | 51 ++++++++---- .../char/pages/CharCreatorResultsPage.hx | 77 ++++++++++++++++++- 2 files changed, 111 insertions(+), 17 deletions(-) diff --git a/source/funkin/ui/debug/char/components/dialogs/results/ResultsAnimDialog.hx b/source/funkin/ui/debug/char/components/dialogs/results/ResultsAnimDialog.hx index 11e1d82210..eef157615c 100644 --- a/source/funkin/ui/debug/char/components/dialogs/results/ResultsAnimDialog.hx +++ b/source/funkin/ui/debug/char/components/dialogs/results/ResultsAnimDialog.hx @@ -10,6 +10,7 @@ import funkin.graphics.adobeanimate.FlxAtlasSprite; import funkin.ui.debug.char.animate.CharSelectAtlasSprite; import funkin.graphics.FunkinSprite; import funkin.ui.debug.char.pages.CharCreatorResultsPage; +import funkin.util.FileUtil; import flixel.FlxSprite; import haxe.io.Path; @@ -267,19 +268,22 @@ private class AddRankAnimationDataBox extends HBox var obj = page.currentAnims[box.ID]; if (obj?.sprite == null) return; + page.setStatusOfEverything(false); + var animPath:String = Paths.stripLibrary(box.animData.assetPath); var animLibrary:String = Paths.getLibrary(box.animData.assetPath); var isAbsolute:Bool = Path.isAbsolute(box.animData.assetPath); + var newObj:Dynamic = null; if (box.animData.renderType == "animateatlas") { - var newObj = new CharSelectAtlasSprite(0, 0, null, null); + newObj = new CharSelectAtlasSprite(0, 0, null, null); if (isAbsolute) { if (Path.extension(box.animData.assetPath) != "zip") return; - newObj.loadFromZip(funkin.util.FileUtil.readBytesFromPath(box.animData.assetPath)); + newObj.loadFromZip(FileUtil.readBytesFromPath(box.animData.assetPath)); } else { @@ -289,22 +293,41 @@ private class AddRankAnimationDataBox extends HBox if (newObj.anim == null || newObj.frames == null) return; newObj.initSymbols(); + } + else + { + newObj = new FunkinSprite(0, 0); - var spr:FlxSprite = cast obj.sprite; - spr.kill(); - page.remove(spr); - spr.destroy(); + if (isAbsolute) + { + if (Path.extension(box.animData.assetPath) != "png") return; - obj.sprite = newObj; - box.onOffsetsChange(); - box.onLoopDataChange(); - newObj.zIndex = box.animData.zIndex; - newObj.scale.set(box.animData.scale, box.animData.scale); + var bitmap = openfl.display.BitmapData.fromBytes(FileUtil.readBytesFromPath(box.animData.assetPath)); + newObj.frames = flixel.graphics.frames.FlxAtlasFrames.fromSparrow(bitmap, FileUtil.readStringFromPath(box.animData.assetPath.replace(".png", ".xml"))); + } + else + { + newObj.loadSparrow(animPath); + } - page.add(newObj); - page.refresh(); + if (newObj.frames == null) return; + newObj.animation.addByPrefix('idle', '', 24, false, false, false); } - else {} // will do + + var spr:FlxSprite = cast obj.sprite; + spr.kill(); + page.remove(spr); + spr.destroy(); + + obj.sprite = newObj; + box.onOffsetsChange(); + box.onLoopDataChange(); + newObj.zIndex = box.animData.zIndex; + newObj.scale.set(box.animData.scale, box.animData.scale); + + page.add(newObj); + page.makeMarkers(); + page.refresh(); copyData(dialog.rankAnimationDataMap[dialog.currentRank][box.ID], box.animData); } diff --git a/source/funkin/ui/debug/char/pages/CharCreatorResultsPage.hx b/source/funkin/ui/debug/char/pages/CharCreatorResultsPage.hx index 9af8a55119..87d2857138 100644 --- a/source/funkin/ui/debug/char/pages/CharCreatorResultsPage.hx +++ b/source/funkin/ui/debug/char/pages/CharCreatorResultsPage.hx @@ -33,6 +33,8 @@ import flixel.util.FlxSort; import flixel.FlxSprite; import flixel.FlxG; import lime.media.AudioBuffer; +import flixel.util.FlxColor; +import flixel.addons.display.shapes.FlxShapeCircle; using StringTools; @@ -47,6 +49,7 @@ class CharCreatorResultsPage extends CharCreatorDefaultPage var rankMusicMap:Map = []; public var currentAnims:Array = []; + public var currentMarkers:Array = []; override public function new(state:CharCreatorState, data:WizardGenerateParams) { @@ -67,9 +70,8 @@ class CharCreatorResultsPage extends CharCreatorDefaultPage } generateUI(); - initFunkinUI(); - + makeMarkers(); refresh(); } @@ -138,6 +140,33 @@ class CharCreatorResultsPage extends CharCreatorDefaultPage { super.update(elapsed); + for (marker in currentMarkers) + { + if (currentAnims[marker.ID].sprite == null) continue; + + switch (marker.fillColor) + { + case 0xffff00ff: + var atlas:CharSelectAtlasSprite = cast currentAnims[marker.ID].sprite; + var pivotPos = atlas.getPivotPosition(); + marker.visible = (daState.menubarCheckViewPivot.selected); + + if (pivotPos != null) marker.setPosition(pivotPos.x - marker.width / 2, pivotPos.y - marker.height / 2); + + case 0xff00ffff: + var atlas:CharSelectAtlasSprite = cast currentAnims[marker.ID].sprite; + var basePos = atlas.getBasePosition(); + marker.visible = (daState.menubarCheckViewBase.selected); + + if (basePos != null) marker.setPosition(basePos.x - marker.width / 2, basePos.y - marker.height / 2); + + case 0xffffff00: + var sparrow:FunkinSprite = cast currentAnims[marker.ID].sprite; + marker.visible = (daState.menubarCheckViewMidpoint.selected); + marker.setPosition(sparrow.getMidpoint().x - marker.width / 2, sparrow.getMidpoint().y - marker.height / 2); + } + } + if (FlxG.keys.justPressed.SPACE) { if (FlxG.keys.pressed.SHIFT) @@ -177,6 +206,47 @@ class CharCreatorResultsPage extends CharCreatorDefaultPage } } + public function makeMarkers() + { + while (currentMarkers.length > 0) + { + var circ = currentMarkers.shift(); + + circ.kill(); + remove(circ, true); + circ.destroy(); + } + + for (i in 0...currentAnims.length) + { + var isAtlas:Bool = Std.isOfType(currentAnims[i].sprite, CharSelectAtlasSprite); + + if (isAtlas) + { + var pivotPointer = new FlxShapeCircle(0, 0, 16, cast {thickness: 2, color: 0xffff00ff}, 0xffff00ff); + var basePointer = new FlxShapeCircle(0, 0, 16, cast {thickness: 2, color: 0xff00ffff}, 0xff00ffff); + + pivotPointer.ID = basePointer.ID = i; + pivotPointer.visible = basePointer.visible = false; + pivotPointer.zIndex = basePointer.zIndex = flixel.math.FlxMath.MAX_VALUE_INT; + + add(pivotPointer); + add(basePointer); + currentMarkers.push(pivotPointer); + currentMarkers.push(basePointer); + } + else + { + var midPointPointer = new FlxShapeCircle(0, 0, 16, cast {thickness: 2, color: 0xffffff00}, 0xffffff00); + midPointPointer.ID = i; + midPointPointer.visible = false; + midPointPointer.zIndex = flixel.math.FlxMath.MAX_VALUE_INT; + add(midPointPointer); + currentMarkers.push(midPointPointer); + } + } + } + public function generateSpritesByData(data:Array) { clearSprites(); @@ -251,6 +321,7 @@ class CharCreatorResultsPage extends CharCreatorDefaultPage } refresh(); + makeMarkers(); } var animTimers:Array = []; @@ -396,7 +467,7 @@ class CharCreatorResultsPage extends CharCreatorDefaultPage var activityStatus:Bool = true; - function setStatusOfEverything(value:Bool = true) + public function setStatusOfEverything(value:Bool = true) { activityStatus = value; for (timer in animTimers)