From 139d5daefa486263cbcb36ac18995d654dfcf2a8 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Mon, 20 Mar 2023 02:15:40 +0100 Subject: [PATCH] SPONGEBOB ME BOI! YOU ALMOST FUCKED THE BUILD NUMBER --- buildnumber.txt | 2 +- source/funkin/editors/charter/Charter.hx | 139 +++++++++++++++++- .../editors/charter/CharterSelection.hx | 3 +- source/funkin/editors/import.hx | 2 + source/funkin/editors/ui/UIBackdrop.hx | 40 +++++ 5 files changed, 182 insertions(+), 4 deletions(-) create mode 100644 source/funkin/editors/ui/UIBackdrop.hx diff --git a/buildnumber.txt b/buildnumber.txt index 497235a9..f1488c48 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -2628 \ No newline at end of file +2651 \ No newline at end of file diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 8185a20d..6920486b 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1,5 +1,142 @@ package funkin.editors.charter; -class Charter extends MusicBeatState { +import openfl.display.BitmapData; +import flixel.util.FlxColor; +import flixel.addons.display.FlxBackdrop; +import funkin.editors.ui.UIContextMenu.UIContextMenuOption; +import funkin.editors.ui.UIState; +class Charter extends UIState { + var __song:String; + var __diff:String; + + /** + * CONFIG (might make this customizable later) + */ + private var gridColor1:FlxColor = 0xFF404040; // white + private var gridColor2:FlxColor = 0xFF212121; // gray + + public var topMenu:Array = [ + { + label: "File", + childs: [ + { + label: "New" + }, + null, + { + label: "Exit", + onSelect: function() { + FlxG.switchState(new CharterSelection()); + } + } + ] + }, + { + label: "Edit", + childs: [ + { + label: "Undo" + }, + { + label: "Redo" + }, + null, + { + label: "Cut" + }, + { + label: "Copy" + }, + { + label: "Paste" + }, + null, + { + label: "Delete" + } + ] + }, + { + label: "Chart", + childs: [ + { + label: "Playtest" + }, + { + label: "Playtest here" + }, + null, + { + label: "Playtest as opponent" + }, + { + label: "Playtest as opponent here" + }, + null, + { + label: "Edit metadata information" + } + ] + }, + { + label: "Playback", + childs: [ + { + label: "Play/Pause" + }, + null, + { + label: "Go back a section" + }, + { + label: "Go forward a section" + }, + null, + { + label: "Go back to the start" + } + ] + } + ]; + + public var topMenuSpr:UITopMenu; + public var gridBackdrop:FlxBackdrop; + + public function new(song:String, diff:String) { + super(); + __song = song; + __diff = diff; + } + + public override function create() { + super.create(); + trace('Entering Charter for song $__song with difficulty $__diff.'); + CoolUtil.loadSong(__song, __diff, false, false); + + gridBackdrop = new FlxBackdrop(null, 1, 1, true, true); + gridBackdrop.makeGraphic(4, 4, gridColor1, true); + gridBackdrop.pixels.lock(); + for(y in 0...4) + for(x in 0...2) + gridBackdrop.pixels.setPixel32((x*2)+(y%2), y, gridColor2); + gridBackdrop.pixels.unlock(); + gridBackdrop.scale.set(40, 40); + gridBackdrop.updateHitbox(); + gridBackdrop.loadFrame(gridBackdrop.frame); + gridBackdrop.cameras = cameras; + add(gridBackdrop); + + + // ALWAYS ADD LAST + topMenuSpr = new UITopMenu(topMenu); + add(topMenuSpr); + } + + public override function update(elapsed:Float) { + super.update(elapsed); + // TODO: remove this bs!! + if (controls.BACK) + FlxG.switchState(new funkin.menus.MainMenuState()); + } } \ No newline at end of file diff --git a/source/funkin/editors/charter/CharterSelection.hx b/source/funkin/editors/charter/CharterSelection.hx index 9a7c5e4e..7415ee63 100644 --- a/source/funkin/editors/charter/CharterSelection.hx +++ b/source/funkin/editors/charter/CharterSelection.hx @@ -19,8 +19,7 @@ class CharterSelection extends EditorTreeMenu { for(s in freeplayList.songs) new IconOption(s.name, "Press ACCEPT to choose a difficulty to edit.", s.icon, function() { optionsTree.add(new OptionsScreen(s.name, "Select a difficulty to continue, or press 1 to add a new one.", [ for(d in s.difficulties) new TextOption(d, "Press ACCEPT to edit the chart for the selected difficulty", function() { - trace(s.name); - trace(d); + FlxG.switchState(new Charter(s.name, d)); }) ])); }) diff --git a/source/funkin/editors/import.hx b/source/funkin/editors/import.hx index a5cced1d..3083047d 100644 --- a/source/funkin/editors/import.hx +++ b/source/funkin/editors/import.hx @@ -1,3 +1,5 @@ package funkin.editors; +import funkin.editors.ui.*; + using funkin.editors.ui.UIUtil; \ No newline at end of file diff --git a/source/funkin/editors/ui/UIBackdrop.hx b/source/funkin/editors/ui/UIBackdrop.hx new file mode 100644 index 00000000..c933fa86 --- /dev/null +++ b/source/funkin/editors/ui/UIBackdrop.hx @@ -0,0 +1,40 @@ +package funkin.editors.ui; + +import flixel.math.FlxPoint; + +class UIBackdrop extends UISprite { + public override function draw() { + var __oldPos = FlxPoint.get(x, y); + var __oldScroll = FlxPoint.get(scrollFactor.x, scrollFactor.y); + + x -= camera.scroll.x * scrollFactor.x; + y -= camera.scroll.y * scrollFactor.y; + + while(x > -width) + x -= width; + while(y > -height) + y -= height; + + var defX = x; + + while(y < FlxG.height) { + while(x < FlxG.width) { + super.drawSuper(); + x += width; + } + y += height; + x = defX; + } + + + setPosition(__oldPos.x, __oldPos.y); + scrollFactor.set(__oldScroll.x, __oldScroll.y); + __oldPos.put(); + __oldScroll.put(); + drawMembers(); + } + + public override function destroy() { + super.destroy(); + } +} \ No newline at end of file