Skip to content

Commit

Permalink
nvm
Browse files Browse the repository at this point in the history
  • Loading branch information
Burgerballs committed Jun 22, 2024
1 parent 18bf130 commit 79a9530
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 28 deletions.
2 changes: 1 addition & 1 deletion source/funkin/play/PauseSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ class PauseSubState extends MusicBeatSubState
function changeSelection(change:Int = 0):Void
{
var prevEntry:Int = currentEntry;
currentEntry = MathUtil.curSelectionWrap(currentEntry, change, currentMenuEntries);
currentEntry = FlxMath.wrap(currentEntry + change, 0, currentMenuEntries.length - 1);

if (currentEntry != prevEntry) FunkinSound.playOnce(Paths.sound('scrollMenu'), 0.4);

Expand Down
13 changes: 4 additions & 9 deletions source/funkin/ui/MenuList.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import flixel.FlxSprite;
import flixel.effects.FlxFlicker;
import flixel.group.FlxGroup;
import flixel.math.FlxPoint;
import funkin.util.MathUtil;
import flixel.math.FlxMath;
import flixel.util.FlxSignal;
import funkin.audio.FunkinSound;

Expand Down Expand Up @@ -106,19 +106,14 @@ class MenuTypedList<T:MenuListItem> extends FlxTypedGroup<T>
function navAxis(index:Int, size:Int, prev:Bool, next:Bool, allowWrap:Bool):Int
{
if (prev == next) return index;
var change:Int = (prev ? -1 : 1);
if (allowWrap)
{
var change:Int = (prev ? -1 : 1);
return MathUtil.curSelectionWrap(index, change, members);
}

if (prev)
{
if (index > 0) index--;
return FlxMath.wrap(index + change, 0, size - 1);
}
else
{
if (index < size - 1) index++;
return FlxMath.bound(index + change, 0, size - 1);
}

return index;
Expand Down
4 changes: 2 additions & 2 deletions source/funkin/ui/freeplay/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ class FreeplayState extends MusicBeatSubState
if (currentDifficultyIndex == -1) currentDifficultyIndex = diffIdsCurrent.indexOf(Constants.DEFAULT_DIFFICULTY);

// Wrap around
currentDifficultyIndex = MathUtil.curSelectionWrap(currentDifficultyIndex, change, diffIdsCurrent);
currentDifficultyIndex = FlxMath.wrap(currentDifficultyIndex + change, 0, diffIdsCurrent.length - 1);

currentDifficulty = diffIdsCurrent[currentDifficultyIndex];

Expand Down Expand Up @@ -1821,7 +1821,7 @@ class FreeplayState extends MusicBeatSubState
{
var prevSelected:Int = curSelected;

curSelected = FlxMath.wrap(curSelected + change, 0, grpCapsules.countLiving() - 1); // Doesn't use MathUtil.curSelectionWrap cuz your mom!!!
curSelected = FlxMath.wrap(curSelected + change, 0, grpCapsules.countLiving() - 1);

if (!prepForNewRank && curSelected != prevSelected) FunkinSound.playOnce(Paths.sound('scrollMenu'), 0.4);

Expand Down
2 changes: 1 addition & 1 deletion source/funkin/ui/story/StoryMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ class StoryMenuState extends MusicBeatState
var currentIndex:Int = difficultyList.indexOf(currentDifficultyId);

// Wrap around
currentIndex = MathUtil.curSelectionWrap(currentIndex, change, difficultyList);
currentIndex = FlxMath.wrap(currentIndex + change, 0, difficultyList - 1);

var hasChanged:Bool = currentDifficultyId != difficultyList[currentIndex];
currentDifficultyId = difficultyList[currentIndex];
Expand Down
15 changes: 0 additions & 15 deletions source/funkin/util/MathUtil.hx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package funkin.util;

import flixel.math.FlxMath;
import flixel.group.FlxGroup.FlxTypedGroup;

/**
* Utilities for performing mathematical operations.
*/
Expand Down Expand Up @@ -40,18 +37,6 @@ class MathUtil
return lerp * (FlxG.elapsed / (1 / 60));
}

/**
* Simple way to wrap the curSelection index variable, used in menus
* @param curSelection Value of the current selected index.
* @param increment Value of the number you want the index to be incremented by.
* @param target The array or group used in the wrapping procedure.
* @return The wrapped value.
*/
public static function curSelectionWrap(curSelection, increment, target):Int
{
return FlxMath.wrap(curSelection + increment, 0, target.length - 1);
}

/**
* Get the logarithm of a value with a given base.
* @param base The base of the logarithm.
Expand Down

0 comments on commit 79a9530

Please sign in to comment.