1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-04 12:43:16 +00:00
Funkin/source/funkin/ui/debug/DebugMenuSubState.hx

132 lines
3.4 KiB
Haxe
Raw Normal View History

package funkin.ui.debug;
import flixel.math.FlxPoint;
import flixel.FlxObject;
import flixel.FlxSprite;
import funkin.ui.MusicBeatSubState;
import funkin.ui.TextMenuList;
import funkin.ui.debug.charting.ChartEditorState;
import funkin.ui.MusicBeatSubState;
2023-11-21 06:37:49 +00:00
import funkin.util.logging.CrashHandler;
2023-11-21 21:09:13 +00:00
import flixel.addons.transition.FlxTransitionableState;
2023-06-09 19:44:29 +00:00
class DebugMenuSubState extends MusicBeatSubState
{
var items:TextMenuList;
/**
* Camera focus point
*/
var camFocusPoint:FlxObject;
2023-04-06 05:39:27 +00:00
override function create():Void
{
super.create();
2023-04-06 05:39:27 +00:00
bgColor = 0x00000000;
// Create an object for the camera to track.
camFocusPoint = new FlxObject(0, 0);
add(camFocusPoint);
// Follow the camera focus as we scroll.
FlxG.camera.follow(camFocusPoint, null, 0.06);
// Create the green background.
var menuBG = new FlxSprite().loadGraphic(Paths.image('menuDesat'));
menuBG.color = 0xFF4CAF50;
menuBG.setGraphicSize(Std.int(menuBG.width * 1.1));
menuBG.updateHitbox();
menuBG.screenCenter();
menuBG.scrollFactor.set(0, 0);
add(menuBG);
// Create the list for menu items.
items = new TextMenuList();
// Move the camera when the menu is scrolled.
items.onChange.add(onMenuChange);
add(items);
// Create each menu item.
// Call onMenuChange when the first item is created to move the camera .
onMenuChange(createItem("CHART EDITOR", openChartEditor));
createItem("ANIMATION EDITOR", openAnimationEditor);
createItem("STAGE EDITOR", openStageEditor);
2023-04-05 04:56:02 +00:00
createItem("TEST STICKERS", testStickers);
2023-11-21 06:37:49 +00:00
#if sys
createItem("OPEN CRASH LOG FOLDER", openLogFolder);
#end
FlxG.camera.focusOn(new FlxPoint(camFocusPoint.x, camFocusPoint.y));
FlxG.camera.focusOn(new FlxPoint(camFocusPoint.x, camFocusPoint.y + 500));
}
function onMenuChange(selected:TextMenuItem)
{
camFocusPoint.setPosition(selected.x + selected.width / 2, selected.y + selected.height / 2);
}
override function update(elapsed:Float)
{
super.update(elapsed);
if (controls.BACK)
{
FlxG.sound.play(Paths.sound('cancelMenu'));
exitDebugMenu();
}
}
function createItem(name:String, callback:Void->Void, fireInstantly = false)
{
var item = items.createItem(0, 100 + items.length * 100, name, BOLD, callback);
item.fireInstantly = fireInstantly;
item.screenCenter(X);
return item;
}
function openChartEditor()
{
2023-11-21 21:09:13 +00:00
FlxTransitionableState.skipNextTransIn = true;
FlxG.switchState(new ChartEditorState());
}
function openAnimationEditor()
{
FlxG.switchState(new funkin.ui.debug.anim.DebugBoundingState());
trace('Animation Editor');
}
2023-04-05 04:56:02 +00:00
function testStickers()
{
openSubState(new funkin.ui.transition.StickerSubState());
2023-04-05 04:56:02 +00:00
trace('opened stickers');
}
function openStageEditor()
{
trace('Stage Editor');
}
2023-11-21 06:37:49 +00:00
#if sys
function openLogFolder()
{
#if windows
Sys.command('explorer', [CrashHandler.LOG_FOLDER]);
#elseif mac
// mac could be fuckie with where the log folder is relative to the game file...
// if this comment is still here... it means it has NOT been verified on mac yet!
Sys.command('open', [CrashHandler.LOG_FOLDER]);
#end
// TODO: implement linux
// some shit with xdg-open :thinking: emoji...
}
#end
function exitDebugMenu()
{
// TODO: Add a transition?
this.close();
}
}