Skip to content

Commit

Permalink
wip editor
Browse files Browse the repository at this point in the history
  • Loading branch information
khuonghoanghuy committed Aug 2, 2024
1 parent 5c0d314 commit 6d1da4c
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
65 changes: 65 additions & 0 deletions source/states/EditorState.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package states;

class EditorState extends ExtendableState {
final options:Array<String> = [
"Chart Editor",
"Song Selection Editor"
];
var grpOptions:FlxTypedGroup<FlxText>;
var curSelected:Int = 0;
var daText:FlxText;

override function create() {
super.create();

var bg:FlxSprite = new FlxSprite().loadGraphic(Paths.image('options/options_bg'));
add(bg);

var grid:FlxBackdrop = new FlxBackdrop(FlxGridOverlay.createGrid(80, 80, 160, 160, true, 0x33FFFFFF, 0x0));
grid.velocity.set(40, 40);
add(grid);

grpOptions = new FlxTypedGroup<FlxText>();
add(grpOptions);

for (i in 0...options.length) {
var optionTxt:FlxText = new FlxText(20, 20 + (i * 50), 0, options[i], 32);
optionTxt.setFormat(Paths.font('vcr.ttf'), 60, FlxColor.WHITE, FlxTextAlign.LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
optionTxt.ID = i;
grpOptions.add(optionTxt);
}

daText = new FlxText(5, FlxG.height - 24, 0, "", 12);
daText.setFormat(Paths.font('vcr.ttf'), 20, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
add(daText);
}

override function update(elapsed:Float) {
super.update(elapsed);

updateText();

if (Input.is('up') || Input.is('down'))
changeSelection(Input.is('up') ? -1 : 1);

if (Input.is('exit')) {
ExtendableState.switchState(new MenuState());
FlxG.sound.play(Paths.sound('cancel'));
}
}

private function changeSelection(change:Int = 0) {
FlxG.sound.play(Paths.sound('scroll'));
curSelected = FlxMath.wrap(curSelected + change, 0, options.length - 1);
grpOptions.forEach(function(txt:FlxText) {
txt.alpha = (txt.ID == curSelected) ? 1 : 0.6;
});
}

function updateText() {
switch (curSelected) {
case 0: daText.text = "Making your own chart";
case 1: daText.text = "Add your own song onto play selection";
}
}
}
6 changes: 6 additions & 0 deletions source/states/MenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ class MenuState extends ExtendableState {
ExtendableState.switchState(new TitleState());
FlxG.sound.play(Paths.sound('cancel'));
}

#if desktop
if (Input.is("seven")) {
ExtendableState.switchState(new EditorState());
}
#end
}

function changeSelection(change:Int = 0) {
Expand Down

0 comments on commit 6d1da4c

Please sign in to comment.