Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into cne-pr
Browse files Browse the repository at this point in the history
  • Loading branch information
mcagabe19 committed Jan 5, 2025
2 parents 7524b5e + 1f224be commit b4ddee1
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
9 changes: 7 additions & 2 deletions source/funkin/backend/assets/ModsFolder.hx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ class ModsFolder {
public static function getModsList():Array<String> {
var mods:Array<String> = [];
#if MOD_SUPPORT
for(modFolder in FileSystem.readDirectory(modsPath)) {
final modsList:Array<String> = FileSystem.readDirectory(modsPath);

if (modsList == null || modsList.length <= 0)
return mods;

for (modFolder in modsList) {
if (FileSystem.isDirectory('${modsPath}${modFolder}')) {
mods.push(modFolder);
} else {
Expand Down Expand Up @@ -161,4 +166,4 @@ class ModsFolder {
return prepareModLibrary(libName, new ZipFolderLibrary(zipPath, libName, modName), force);
}
#end
}
}
14 changes: 14 additions & 0 deletions source/funkin/backend/system/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class Main extends Sprite

public static var game:FunkinGame;

/**
* The time since the game was focused last time in seconds.
*/
public static var timeSinceFocus(get, never):Float;
public static var time:Int = 0;

// You can pretty much ignore everything from here on - your code should go in your states.
Expand Down Expand Up @@ -165,6 +169,7 @@ class Main extends Sprite
Conductor.init();
AudioSwitchFix.init();
EventManager.init();
FlxG.signals.focusGained.add(onFocus);
FlxG.signals.preStateSwitch.add(onStateSwitch);
FlxG.signals.postStateSwitch.add(onStateSwitchPost);

Expand Down Expand Up @@ -206,6 +211,10 @@ class Main extends Sprite
{asset: diamond, width: 32, height: 32}, new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4));
}

public static function onFocus() {
_tickFocused = FlxG.game.ticks;
}

private static function onStateSwitch() {
scaleMode.resetSize();
}
Expand All @@ -225,4 +234,9 @@ class Main extends Sprite

MemoryUtil.clearMajor();
}

private static var _tickFocused:Float = 0;
public static function get_timeSinceFocus():Float {
return (FlxG.game.ticks - _tickFocused) / 1000;
}
}
1 change: 1 addition & 0 deletions source/funkin/game/StrumLine.hx
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ class StrumLine extends FlxTypedGroup<Strum> {
super.destroy();
if(startingPos != null)
startingPos.put();
notes = FlxDestroyUtil.destroy(notes);
}

/**
Expand Down
7 changes: 6 additions & 1 deletion source/funkin/menus/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package funkin.menus;

import funkin.backend.chart.Chart;
import funkin.backend.chart.ChartData.ChartMetaData;
import funkin.backend.system.Conductor;
import haxe.io.Path;
import openfl.text.TextField;
import flixel.text.FlxText;
Expand Down Expand Up @@ -244,7 +245,11 @@ class FreeplayState extends MusicBeatState
autoplayElapsed += elapsed;
if (!disableAutoPlay && !songInstPlaying && (autoplayElapsed > timeUntilAutoplay || FlxG.keys.justPressed.SPACE)) {
if (curPlayingInst != (curPlayingInst = Paths.inst(songs[curSelected].name, songs[curSelected].difficulties[curDifficulty]))) {
var huh:Void->Void = function() FlxG.sound.playMusic(curPlayingInst, 0);
var huh:Void->Void = function()
{
FlxG.sound.playMusic(curPlayingInst, 0);
Conductor.changeBPM(songs[curSelected].bpm, songs[curSelected].beatsPerMeasure, songs[curSelected].stepsPerBeat);
}
if(!disableAsyncLoading) Main.execAsync(huh);
else huh();
}
Expand Down
2 changes: 1 addition & 1 deletion source/funkin/options/OptionsScreen.hx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class OptionsScreen extends FlxTypedSpriteGroup<OptionType> {

if (members.length > 0) {
members[curSelected].selected = true;
if (controls.ACCEPT || (FlxG.mouse.justReleased && !controls.touchC))
if (controls.ACCEPT || ((FlxG.mouse.justReleased && !controls.touchC) && Main.timeSinceFocus > 0.25))
members[curSelected].onSelect();
if (controls.LEFT_P)
members[curSelected].onChangeSelection(-1);
Expand Down

0 comments on commit b4ddee1

Please sign in to comment.