From 5304827035c7e5327ae7dfa49b2edda46508cd20 Mon Sep 17 00:00:00 2001 From: Yoshman29 Date: Sun, 23 Oct 2022 03:12:47 +0200 Subject: [PATCH] character editor (F1 in codename ui) --- buildnumber.txt | 2 +- source/funkin/desktop/DesktopMain.hx | 4 +- .../funkin/desktop/editors/CharacterEditor.hx | 64 +++++++++++++++++++ source/funkin/desktop/editors/HelloWorld.hx | 6 ++ source/funkin/desktop/windows/Window.hx | 14 +++- .../funkin/desktop/windows/WindowContent.hx | 3 +- 6 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 source/funkin/desktop/editors/CharacterEditor.hx diff --git a/buildnumber.txt b/buildnumber.txt index c7105757..ddc27b0c 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -732 \ No newline at end of file +739 \ No newline at end of file diff --git a/source/funkin/desktop/DesktopMain.hx b/source/funkin/desktop/DesktopMain.hx index 32b5342b..dbe5aa28 100644 --- a/source/funkin/desktop/DesktopMain.hx +++ b/source/funkin/desktop/DesktopMain.hx @@ -11,7 +11,7 @@ import flixel.FlxSprite; import flixel.FlxBasic; import flixel.FlxCamera; import flixel.math.FlxPoint; -import funkin.desktop.editors.HelloWorld; +import funkin.desktop.editors.*; import funkin.desktop.windows.*; import funkin.desktop.theme.Theme; @@ -66,6 +66,8 @@ class DesktopMain extends MusicBeatState { // debug window if (FlxG.keys.justPressed.SPACE) windows.add(new Window(new HelloWorld())); + if (FlxG.keys.justPressed.F1) + windows.add(new Window(new CharacterEditor('dad'))); } public function updateScreenRes() { diff --git a/source/funkin/desktop/editors/CharacterEditor.hx b/source/funkin/desktop/editors/CharacterEditor.hx new file mode 100644 index 00000000..f97f5935 --- /dev/null +++ b/source/funkin/desktop/editors/CharacterEditor.hx @@ -0,0 +1,64 @@ +package funkin.desktop.editors; + +import funkin.game.Character; +import flixel.FlxSprite; +import flixel.FlxObject; +import flixel.FlxCamera; +import flixel.FlxG; + +class CharacterEditor extends WindowContent { + public function new(curCharacter:String) { + super('Character Editor - Loading...', 0, 0, 800, 600); + } + + public var camHUD:FlxCamera; + public var char:Character; + public var curCharacter:String; + public var camFollow:FlxObject; + + public override function create() { + super.create(); + + // camera stuff + parent.windowCameras[0].resizeScroll = false; + camHUD = new FlxCamera(800, 600, 1); + camHUD.pixelPerfectRender = true; + camHUD.bgColor = 0; + parent.addCamera(camHUD); + + // stage + var bg = new FlxSprite(-600, -200, Paths.image('stages/default/stageback')); + bg.scrollFactor.set(0.9, 0.9); + var stageFront = new FlxSprite(-600, 600, Paths.image('stages/default/stagefront')); + stageFront.scrollFactor.set(0.9, 0.9); + var stageCurtains = new FlxSprite(-500, -300, Paths.image('stages/default/stagecurtains')); + stageCurtains.scrollFactor.set(1.3, 1.3); + char = new Character(100, 100, curCharacter, false); + + for(e in [bg, stageFront, stageCurtains]) { + e.antialiasing = true; + } + add(bg); + add(stageFront); + add(char); + add(stageCurtains); + + // character setup & following + camFollow = new FlxObject(0, 0, 2, 2); + var charMidpoint = char.getGraphicMidpoint(); + camFollow.setPosition(charMidpoint.x, charMidpoint.y); + add(camFollow); + windowCamera.follow(camFollow, LOCKON, 999); + title = 'Character Editor - ${char.curCharacter}.xml'; + } + + public override function update(elapsed:Float) { + super.update(elapsed); + if (parent.focused) { + if (FlxG.keys.pressed.RIGHT) camFollow.x += elapsed * 200; + if (FlxG.keys.pressed.LEFT) camFollow.x -= elapsed * 200; + if (FlxG.keys.pressed.DOWN) camFollow.y += elapsed * 200; + if (FlxG.keys.pressed.UP) camFollow.y -= elapsed * 200; + } + } +} \ No newline at end of file diff --git a/source/funkin/desktop/editors/HelloWorld.hx b/source/funkin/desktop/editors/HelloWorld.hx index a7cd7505..a9ce1b2f 100644 --- a/source/funkin/desktop/editors/HelloWorld.hx +++ b/source/funkin/desktop/editors/HelloWorld.hx @@ -23,6 +23,12 @@ class HelloWorld extends WindowContent { t.setPosition(630 - t.width, 470 - t.height); t.scrollFactor.set(1, 1); add(t); + + var t = new FlxUIText(0, 0, 0, "Top right text!"); + t.color = 0xFF000000; + t.setPosition(630 - t.width, 10); + t.scrollFactor.set(1, 0); + add(t); } public var time:Float = 0; diff --git a/source/funkin/desktop/windows/Window.hx b/source/funkin/desktop/windows/Window.hx index 78860997..fffe9d1b 100644 --- a/source/funkin/desktop/windows/Window.hx +++ b/source/funkin/desktop/windows/Window.hx @@ -23,6 +23,7 @@ typedef WindowCam = { } class Window extends FlxTypedGroup { public var windowFrame:FlxUI9SliceSprite; + public var windowInactiveFrame:FlxUI9SliceSprite; public var captionButtons:FlxTypedSpriteGroup; public var windowWidth:Int = 0; @@ -63,7 +64,16 @@ class Window extends FlxTypedGroup { Std.int(DesktopMain.theme.captionActive.right), Std.int(DesktopMain.theme.captionActive.bottom) ]); + windowInactiveFrame = new FlxUI9SliceSprite(0, 0, + Paths.image(DesktopMain.theme.captionInactive.sprite), + new Rectangle(10, 10), [ + Std.int(DesktopMain.theme.captionInactive.left), + Std.int(DesktopMain.theme.captionInactive.top), + Std.int(DesktopMain.theme.captionInactive.right), + Std.int(DesktopMain.theme.captionInactive.bottom) + ]); add(windowFrame); + add(windowInactiveFrame); caption = new FlxUIText(24, 4, 0, content.title); captionButtons = new FlxTypedSpriteGroup(); @@ -176,6 +186,7 @@ class Window extends FlxTypedGroup { destroy(); return; } + windowInactiveFrame.visible = !(windowFrame.visible = focused); var i = members.length; var shouldCancel = DesktopMain.instance.mouseInput.overlapsRect(this, new Rectangle(0, 0, windowCaptionCamera.width, windowCaptionCamera.height), windowCaptionCamera); @@ -199,7 +210,8 @@ class Window extends FlxTypedGroup { } public function updateWindowFrame() { - windowFrame.resize(windowWidth + Std.int(DesktopMain.theme.captionActive.left * 2), windowHeight + Std.int(DesktopMain.theme.captionActive.top) + Std.int(DesktopMain.theme.captionActive.left)); + for(frame in [windowInactiveFrame, windowFrame]) + frame.resize(windowWidth + Std.int(DesktopMain.theme.captionActive.left * 2), windowHeight + Std.int(DesktopMain.theme.captionActive.top) + Std.int(DesktopMain.theme.captionActive.left)); windowCaptionCamera.setSize(windowWidth + Std.int(DesktopMain.theme.captionActive.left * 2), windowHeight + Std.int(DesktopMain.theme.captionActive.top) + Std.int(DesktopMain.theme.captionActive.left)); captionButtons.setPosition(windowWidth + Std.int((DesktopMain.theme.captionActive.left * 2) - DesktopMain.theme.captionButtons.offset.x), Std.int(DesktopMain.theme.captionButtons.offset.y)); for(e in windowCameras) { diff --git a/source/funkin/desktop/windows/WindowContent.hx b/source/funkin/desktop/windows/WindowContent.hx index 58d18de9..eb9bb041 100644 --- a/source/funkin/desktop/windows/WindowContent.hx +++ b/source/funkin/desktop/windows/WindowContent.hx @@ -1,10 +1,11 @@ package funkin.desktop.windows; +import flixel.FlxBasic; import flixel.FlxSprite; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.FlxCamera; -class WindowContent extends FlxTypedGroup { +class WindowContent extends FlxTypedGroup { public var winX(default, set):Float = 0; public var winY(default, set):Float = 0; public var title(default, set):String = "Window";