From 1f475b67caf2c599ab2e4900ed934ec6223bf9fc Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Sat, 4 Jan 2025 22:01:37 +0100 Subject: [PATCH 1/2] dumb bugs fixed + add asset flips --- assets | 2 +- .../ui/debug/stageeditor/StageEditorState.hx | 17 +++++----- .../stageeditor/handlers/AssetDataHandler.hx | 34 ++++++++++++++++--- .../stageeditor/handlers/StageDataHandler.hx | 6 ++++ .../toolboxes/StageEditorObjectToolbox.hx | 16 +++++++++ 5 files changed, 61 insertions(+), 14 deletions(-) diff --git a/assets b/assets index c1899ffbef..8a7d3db08e 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit c1899ffbefb9a7c98b030c75a33623431d7ea6ba +Subproject commit 8a7d3db08ea95cb8b335b81fef601d02caca2c05 diff --git a/source/funkin/ui/debug/stageeditor/StageEditorState.hx b/source/funkin/ui/debug/stageeditor/StageEditorState.hx index a536a09ee5..9207ed58ee 100644 --- a/source/funkin/ui/debug/stageeditor/StageEditorState.hx +++ b/source/funkin/ui/debug/stageeditor/StageEditorState.hx @@ -138,6 +138,7 @@ class StageEditorState extends UIState function set_selectedSprite(value:StageEditorObject) { + selectedSprite?.selectedShader.setAmount(0); this.selectedSprite = value; updateDialog(StageEditorDialogType.OBJECT); @@ -619,15 +620,12 @@ class StageEditorState extends UIState { for (spr in spriteArray) { - spr.active = spr.isOnScreen(); - - if (spr.pixelsOverlapPoint(FlxG.mouse.getWorldPosition())) + if (FlxG.mouse.overlaps(spr)) { if (spr.visible && !FlxG.keys.pressed.SHIFT) nameTxt.text = spr.name; if (FlxG.mouse.justPressed && allowInput && spr.visible && !FlxG.keys.pressed.SHIFT && !isCursorOverHaxeUI) { - selectedSprite.selectedShader.setAmount(0); selectedSprite = spr; updateDialog(StageEditorDialogType.OBJECT); } @@ -1138,8 +1136,6 @@ class StageEditorState extends UIState currentFile = path; }, null, stageName + "." + FileUtil.FILE_EXTENSION_INFO_FNFS.extension); - bitmaps.clear(); - case "save stage": if (currentFile == "") { @@ -1159,8 +1155,7 @@ class StageEditorState extends UIState saved = true; - updateRecentFiles(); - bitmaps.clear(); + reloadRecentFiles(); case "open stage": if (!saved) @@ -1212,7 +1207,10 @@ class StageEditorState extends UIState FlxG.sound.music.stop(); case "switch mode": - if (!testingMode) moveMode = (moveMode == "assets" ? "chars" : "assets"); + if (testingMode) return; + moveMode = (moveMode == "assets" ? "chars" : "assets"); + + selectedSprite?.selectedShader.setAmount((moveMode == "assets" ? 1 : 0)); case "switch focus": if (testingMode) @@ -1288,6 +1286,7 @@ class StageEditorState extends UIState if (!testingMode) menubarItemWindowObject.selected = menubarItemWindowCharacter.selected = menubarItemWindowStage.selected = false; + selectedSprite?.selectedShader.setAmount((testingMode ? (moveMode == "assets" ? 1 : 0) : 0)); testingMode = !testingMode; case "clear assets": diff --git a/source/funkin/ui/debug/stageeditor/handlers/AssetDataHandler.hx b/source/funkin/ui/debug/stageeditor/handlers/AssetDataHandler.hx index a6f57bd7ce..deff8bdbc7 100644 --- a/source/funkin/ui/debug/stageeditor/handlers/AssetDataHandler.hx +++ b/source/funkin/ui/debug/stageeditor/handlers/AssetDataHandler.hx @@ -47,6 +47,8 @@ class AssetDataHandler startingAnimation: obj.startingAnimation, animType: "sparrow", // automatically making sparrow atlases yeah angle: obj.angle, + flipX: obj.flipX, + flipY: obj.flipY, blend: obj.blend == null ? "" : Std.string(obj.blend), color: obj.color.toWebString(), xmlData: obj.generateXML() @@ -81,8 +83,20 @@ class AssetDataHandler { if (data.bitmap != null) { - var bitToLoad = state.addBitmap(data.bitmap.clone()); - object.loadGraphic(state.bitmaps[bitToLoad]); + if (data.animations != null && data.animations.length > 0) + { + var bitToLoad = state.addBitmap(data.bitmap.clone()); + object.frames = flixel.graphics.frames.FlxAtlasFrames.fromSparrow(state.bitmaps[bitToLoad], data.xmlData); + } + else if (areTheseBitmapsEqual(data.bitmap, getDefaultGraphic())) + { + object.loadGraphic(getDefaultGraphic()); + } + else + { + var bitToLoad = state.addBitmap(data.bitmap.clone()); + object.loadGraphic(state.bitmaps[bitToLoad]); + } } else { @@ -168,10 +182,22 @@ class AssetDataHandler // the last check is for if the only frame is the standard graphic frame if (obj == null || obj.frames.frames.length == 0 || obj.frames.frames[0].name == null) return ""; + var bitmapName = ""; + for (name => bitmap in state.bitmaps) + { + if (areTheseBitmapsEqual(bitmap, obj.pixels)) + { + bitmapName = name; + break; + } + } + + if (bitmapName == "") return ""; + var xml = [ - "", + "", '', - '' + '' ].join("\n"); for (daFrame in obj.frames.frames) diff --git a/source/funkin/ui/debug/stageeditor/handlers/StageDataHandler.hx b/source/funkin/ui/debug/stageeditor/handlers/StageDataHandler.hx index 56dc7a775b..a1b6d9a1bf 100644 --- a/source/funkin/ui/debug/stageeditor/handlers/StageDataHandler.hx +++ b/source/funkin/ui/debug/stageeditor/handlers/StageDataHandler.hx @@ -49,6 +49,8 @@ class StageDataHandler animations: data.animations, startingAnimation: data.startingAnimation, animType: data.animType, + flipX: data.flipX, + flipY: data.flipY, angle: data.angle, blend: data.blend, color: data.assetPath.startsWith("#") ? "#FFFFFF" : data.color @@ -210,6 +212,8 @@ class StageDataHandler scroll: objData.scroll.copy(), color: objData.color, blend: objData.blend, + flipX: objData.flipX, + flipY: objData.flipY, startingAnimation: objData.startingAnimation, xmlData: xmls[objData.assetPath] ?? "" }); @@ -309,6 +313,8 @@ class StageDataHandler scroll: objData.scroll.copy(), color: objData.color, blend: objData.blend, + flipX: objData.flipX, + flipY: objData.flipY, startingAnimation: objData.startingAnimation, xmlData: Assets.exists(Paths.file("images/" + objData.assetPath + ".xml")) ? Assets.getText(Paths.file("images/" + objData.assetPath + ".xml")) : "" }); diff --git a/source/funkin/ui/debug/stageeditor/toolboxes/StageEditorObjectToolbox.hx b/source/funkin/ui/debug/stageeditor/toolboxes/StageEditorObjectToolbox.hx index 36dd127ecb..3b496edaec 100644 --- a/source/funkin/ui/debug/stageeditor/toolboxes/StageEditorObjectToolbox.hx +++ b/source/funkin/ui/debug/stageeditor/toolboxes/StageEditorObjectToolbox.hx @@ -86,6 +86,8 @@ class StageEditorObjectToolbox extends StageEditorDefaultToolbox var objectMiscAntialias:CheckBox; var objectMiscAntialiasReset:Button; + var objectMiscFlipX:CheckBox; + var objectMiscFlipY:CheckBox; var objectMiscFlipReset:Button; var objectMiscBlendDrop:DropDown; var objectMiscBlendReset:Button; @@ -404,6 +406,14 @@ class StageEditorObjectToolbox extends StageEditorDefaultToolbox if (linkedObject != null) linkedObject.antialiasing = objectMiscAntialias.selected; } + objectMiscFlipX.onChange = function(_) { + if (linkedObject != null) linkedObject.flipX = objectMiscFlipX.selected; + } + + objectMiscFlipY.onChange = function(_) { + if (linkedObject != null) linkedObject.flipY = objectMiscFlipY.selected; + } + objectMiscBlendDrop.onChange = function(_) { if (linkedObject != null) linkedObject.blend = objectMiscBlendDrop.selectedItem.text == "NONE" ? null : AssetDataHandler.blendFromString(objectMiscBlendDrop.selectedItem.text); @@ -474,6 +484,10 @@ class StageEditorObjectToolbox extends StageEditorDefaultToolbox if (linkedObject != null) objectMiscAntialias.selected = true; } + objectMiscFlipReset.onClick = function(_) { + if (linkedObject != null) objectMiscFlipX.selected = objectMiscFlipY.selected = false; + } + objectMiscBlendReset.onClick = function(_) { if (linkedObject != null) objectMiscBlendDrop.selectedItem = "NORMAL"; } @@ -526,6 +540,8 @@ class StageEditorObjectToolbox extends StageEditorDefaultToolbox if (objectScrollXSlider.pos != linkedObject.scrollFactor.x) objectScrollXSlider.pos = linkedObject.scrollFactor.x; if (objectScrollYSlider.pos != linkedObject.scrollFactor.y) objectScrollYSlider.pos = linkedObject.scrollFactor.y; if (objectMiscAntialias.selected != linkedObject.antialiasing) objectMiscAntialias.selected = linkedObject.antialiasing; + if (objectMiscFlipX.selected != linkedObject.flipX) objectMiscFlipX.selected = linkedObject.flipX; + if (objectMiscFlipY.selected != linkedObject.flipY) objectMiscFlipY.selected = linkedObject.flipY; if (objectMiscColor.currentColor != Color.fromString(linkedObject.color.toHexString() ?? "white")) objectMiscColor.currentColor = Color.fromString(linkedObject.color.toHexString()); From 08ac8eb76eafc7f91ac53d22b81e9abf54b174d6 Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Sun, 12 Jan 2025 19:06:21 +0100 Subject: [PATCH 2/2] some more fixes and features --- assets | 2 +- .../ui/debug/stageeditor/StageEditorState.hx | 5 +++++ .../toolboxes/StageEditorObjectToolbox.hx | 21 +++++++------------ 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/assets b/assets index 8a7d3db08e..55a51f8020 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 8a7d3db08ea95cb8b335b81fef601d02caca2c05 +Subproject commit 55a51f802069f5e1fc2df9af728b288a051e679c diff --git a/source/funkin/ui/debug/stageeditor/StageEditorState.hx b/source/funkin/ui/debug/stageeditor/StageEditorState.hx index 9207ed58ee..541ce5082c 100644 --- a/source/funkin/ui/debug/stageeditor/StageEditorState.hx +++ b/source/funkin/ui/debug/stageeditor/StageEditorState.hx @@ -618,6 +618,11 @@ class StageEditorState extends UIState if (moveMode == "assets") { + if (selectedSprite != null && !FlxG.mouse.overlaps(selectedSprite) && FlxG.mouse.justPressed && !isCursorOverHaxeUI) + { + selectedSprite = null; + } + for (spr in spriteArray) { if (FlxG.mouse.overlaps(spr)) diff --git a/source/funkin/ui/debug/stageeditor/toolboxes/StageEditorObjectToolbox.hx b/source/funkin/ui/debug/stageeditor/toolboxes/StageEditorObjectToolbox.hx index 3b496edaec..9c927c306f 100644 --- a/source/funkin/ui/debug/stageeditor/toolboxes/StageEditorObjectToolbox.hx +++ b/source/funkin/ui/debug/stageeditor/toolboxes/StageEditorObjectToolbox.hx @@ -37,7 +37,6 @@ class StageEditorObjectToolbox extends StageEditorDefaultToolbox var objectImagePreview:Image; var objectLoadImageButton:Button; var objectLoadInternetButton:Button; - var objectDownloadImageButton:Button; var objectResetImageButton:Button; var objectZIdxStepper:NumberStepper; var objectZIdxReset:Button; @@ -140,13 +139,6 @@ class StageEditorObjectToolbox extends StageEditorDefaultToolbox }); } - objectDownloadImageButton.onClick = function(_) { - if (linkedObject == null) return; - - FileUtil.saveFile(linkedObject.pixels.image.encode(PNG), [FileUtil.FILE_FILTER_PNG], null, null, - linkedObject.name + "-graphic.png"); // i'on need any callbacks - } - objectZIdxStepper.max = StageEditorState.MAX_Z_INDEX; objectZIdxStepper.onChange = function(_) { if (linkedObject != null) @@ -463,6 +455,7 @@ class StageEditorObjectToolbox extends StageEditorDefaultToolbox if (linkedObject != null) { linkedObject.scale.set(1, 1); + linkedObject.updateHitbox(); refresh(); // refreshes like multiple shit } } @@ -507,7 +500,7 @@ class StageEditorObjectToolbox extends StageEditorDefaultToolbox refresh(); } - var prevFrames:Array = []; + var prevFrames:Array = []; var prevAnims:Array = []; override public function refresh() @@ -544,7 +537,7 @@ class StageEditorObjectToolbox extends StageEditorDefaultToolbox if (objectMiscFlipY.selected != linkedObject.flipY) objectMiscFlipY.selected = linkedObject.flipY; if (objectMiscColor.currentColor != Color.fromString(linkedObject.color.toHexString() ?? "white")) - objectMiscColor.currentColor = Color.fromString(linkedObject.color.toHexString()); + objectMiscColor.currentColor = Color.fromString(linkedObject.color.toHexString() ?? "white"); if (objectAnimDanceBeat.pos != linkedObject.danceEvery) objectAnimDanceBeat.pos = linkedObject.danceEvery; if (objectAnimStart.text != linkedObject.startingAnimation) objectAnimStart.text = linkedObject.startingAnimation; @@ -553,11 +546,11 @@ class StageEditorObjectToolbox extends StageEditorDefaultToolbox if (objectMiscBlendDrop.selectedItem != objBlend.toUpperCase()) objectMiscBlendDrop.selectedItem = objBlend.toUpperCase(); // ough the max - if (objectFrameImageWidth.max != linkedObject.pixels.width) objectFrameImageWidth.max = linkedObject.graphic.width; - if (objectFrameImageHeight.max != linkedObject.pixels.height) objectFrameImageHeight.max = linkedObject.graphic.height; + if (objectFrameImageWidth.max != linkedObject.pixels.width) objectFrameImageWidth.max = linkedObject.pixels.width; + if (objectFrameImageHeight.max != linkedObject.pixels.height) objectFrameImageHeight.max = linkedObject.pixels.height; // update some anim shit - if (prevFrames != linkedObject.frames.frames.copy()) updateFrameList(); + if (prevFrames != [for (f in linkedObject.frames.frames) f.name]) updateFrameList(); if (prevAnims != linkedObject.animation.getNameList().copy()) updateAnimList(); } @@ -572,7 +565,7 @@ class StageEditorObjectToolbox extends StageEditorDefaultToolbox { if (fname != null) objectAnimFrameList.dataSource.add({name: fname.name, tooltip: fname.name}); - prevFrames.push(fname); + prevFrames.push(fname.name); } }