Skip to content

Commit

Permalink
309
Browse files Browse the repository at this point in the history
  • Loading branch information
DetectiveBaldi committed Nov 30, 2024
1 parent 837b96b commit 7ccdb19
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 30 deletions.
2 changes: 0 additions & 2 deletions source/menus/BaseOptionItem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ class BaseOptionItem<T> extends FlxSpriteGroup

background.antialiasing = true;

background.color = background.color.getDarkened(0.25);

background.frames = FlxAtlasFrames.fromSparrow(AssetMan.graphic(Paths.png("assets/images/menus/BaseOptionItem/background")), Paths.xml("assets/images/menus/BaseOptionItem/background"));

background.animation.addByPrefix("background", "background", 12.0);
Expand Down
2 changes: 0 additions & 2 deletions source/menus/BoolOptionItem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class BoolOptionItem extends BaseOptionItem<Bool>

checkbox.antialiasing = true;

checkbox.color = checkbox.color.getDarkened(0.25);

checkbox.frames = FlxAtlasFrames.fromSparrow(AssetMan.graphic(Paths.png("assets/images/menus/BoolOptionItem/checkbox")), Paths.xml("assets/images/menus/BoolOptionItem/checkbox"));

checkbox.animation.addByIndices("check", "checkbox", [0, 1, 2, 3, 4, 5, 6], "", 24.0, false);
Expand Down
31 changes: 10 additions & 21 deletions source/menus/OptionsMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import flixel.graphics.frames.FlxAtlasFrames;

import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;

import flixel.math.FlxMath;

import flixel.sound.FlxSound;

import flixel.text.FlxText;
Expand All @@ -23,8 +25,6 @@ import core.Paths;

import game.levels.Level1;

import util.MathUtil;

class OptionsMenu extends FlxState
{
public var background:FlxSprite;
Expand Down Expand Up @@ -182,8 +182,6 @@ class OptionsMenu extends FlxState

descriptor.antialiasing = true;

descriptor.color = descriptor.color.getDarkened(0.25);

descriptor.frames = FlxAtlasFrames.fromSparrow(AssetMan.graphic(Paths.png("assets/images/menus/OptionsMenu/descriptor")), Paths.xml("assets/images/menus/OptionsMenu/descriptor"));

descriptor.animation.addByPrefix("descriptor", "descriptor", 12.0);
Expand All @@ -204,9 +202,9 @@ class OptionsMenu extends FlxState

descText.font = Paths.ttf("assets/fonts/Ubuntu Regular");

descText.alignment = LEFT;
descText.alignment = CENTER;

descText.setPosition(descriptor.x + 300.0, descriptor.getMidpoint().y - descText.height * 0.5 - 35.0);
descText.setPosition(descriptor.getMidpoint().x - descText.width * 0.5, descriptor.getMidpoint().y - descText.height * 0.5 - 25.0);

add(descText);

Expand All @@ -221,29 +219,20 @@ class OptionsMenu extends FlxState
{
super.update(elapsed);

if (FlxG.keys.justPressed.DOWN)
if (FlxG.keys.justPressed.DOWN || FlxG.mouse.wheel == -1.0)
{
var _option:Int = option;
FlxG.sound.play(AssetMan.sound(Paths.ogg("assets/sounds/menus/OptionsMenu/scroll"), false), 0.35);

option = MathUtil.boundInt(option + 1, 0, options.members.length - 1);

if (_option != options.members.length - 1.0)
FlxG.sound.play(AssetMan.sound(Paths.ogg("assets/sounds/menus/OptionsMenu/scroll"), false), 0.35);
option = FlxMath.wrap(option + 1, 0, options.members.length - 1);
}

if (FlxG.keys.justPressed.UP)
if (FlxG.keys.justPressed.UP || FlxG.mouse.wheel == 1.0)
{
var _option:Int = option;

option = MathUtil.boundInt(option - 1, 0, options.members.length - 1);
FlxG.sound.play(AssetMan.sound(Paths.ogg("assets/sounds/menus/OptionsMenu/scroll"), false), 0.35);

if (_option != 0)
FlxG.sound.play(AssetMan.sound(Paths.ogg("assets/sounds/menus/OptionsMenu/scroll"), false), 0.35);
option = FlxMath.wrap(option - 1, 0, options.members.length - 1);
}

if (FlxG.mouse.wheel != 0.0)
option = MathUtil.boundInt(option - FlxG.mouse.wheel, 0, options.members.length - 1);

if (FlxG.keys.justPressed.DOWN || FlxG.keys.justPressed.UP || FlxG.mouse.wheel != 0.0)
descText.text = options.members[option].description;

Expand Down
5 changes: 0 additions & 5 deletions source/util/MathUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,4 @@ class MathUtil

return output;
}

public static function boundInt(int:Int, min:Null<Float> = null, max:Null<Float> = null):Int
{
return Std.int(FlxMath.bound(int, min, max));
}
}

0 comments on commit 7ccdb19

Please sign in to comment.