Skip to content

Commit

Permalink
options shit
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyrid19 committed Jun 23, 2024
1 parent 813c03e commit 61c2863
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 67 deletions.
Binary file removed assets/preload/images/main_menu.png
Binary file not shown.
65 changes: 0 additions & 65 deletions assets/preload/images/main_menu.xml

This file was deleted.

Binary file added assets/preload/images/options/optionbg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions source/funkin/objects/ui/OptionItem.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package funkin.objects.ui;

import flixel.group.FlxSpriteGroup;
import flixel.addons.display.FlxSliceSprite;
import flixel.math.FlxRect;

class OptionItem extends FlxSpriteGroup {
var alphabet:Alphabet;
var background:FlxSliceSprite;

public function new(x:Float, y:Float, text:String) {
super(x, y);

alphabet = new Alphabet(0, 0, text, true);
background = new FlxSliceSprite(Paths.image('options/optionbg'), new FlxRect(37, 1, 1, 37), alphabet.width, 75);

alphabet.x = this.x;
alphabet.y = this.y;

background.x = alphabet.x - 20;
background.y = alphabet.y + 20;

add(background);
add(alphabet);
}
}
15 changes: 15 additions & 0 deletions source/funkin/states/options/Option.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package funkin.states.options;

class Option {
var name:String;
var description:String;
var variable:String;
var type:String; // String, Bool, Array, Dynamic

public function new(name:String, description:String, variable:String, type:String) {
this.name = name;
this.description = description;
this.variable = variable;
this.type = type;
}
}
55 changes: 53 additions & 2 deletions source/funkin/states/options/OptionsStateNew.hx
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
package funkin.states.options;

import flixel.addons.display.FlxBackdrop;
import funkin.objects.ui.OptionItem;

class OptionsStateNew extends MusicBeatState {
var curSelected:Int = 0;

var menuItems:FlxTypedGroup<Alphabet>;
var optionsList:Array<String> = [
'Gameplay',
'Controls',
'Graphics'
];

class OptionsStateNew extends MusicBeatState
{
override function create() {
#if discord_rpc
Discord.changePresence('Changing Preferences');
Expand All @@ -27,6 +36,19 @@ class OptionsStateNew extends MusicBeatState
bfGrid.alpha = 0.4;
add(bfGrid);

menuItems = new FlxTypedGroup<Alphabet>();
add(menuItems);

var spacing:Float = 100;
for (i in 0...optionsList.length) {
var menuItem:Alphabet = new Alphabet(0, 100+(i*spacing), optionsList[i], true);
menuItem.screenCenter(X);
menuItem.ID = i;
menuItems.add(menuItem);
}

changeSelection(0, false);

super.create();
}

Expand All @@ -35,6 +57,35 @@ class OptionsStateNew extends MusicBeatState
FlxG.switchState(new MainMenuState());
}

if (controls.UI_UP_P) {
changeSelection(-1);
}

if (controls.UI_DOWN_P) {
changeSelection(1);
}

for (item in menuItems) {
if (curSelected == item.ID) {
item.text = '>' + optionsList[item.ID] + '<';
} else {
item.text = optionsList[item.ID];
}

item.screenCenter(X);
}

super.update(elapsed);
}

function changeSelection(change:Int = 0, playSound:Bool = true) {
if (playSound) FlxG.sound.play(Paths.sound('scrollMenu'));

curSelected += change;

if (curSelected < 0)
curSelected = menuItems.length - 1;
if (curSelected > menuItems.length - 1)
curSelected = 0;
}
}

0 comments on commit 61c2863

Please sign in to comment.