Merge remote-tracking branch 'public/main'

This commit is contained in:
⍚~Nex
2025-01-03 19:18:18 +01:00
6 changed files with 36 additions and 9 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
@ECHO OFF @ECHO OFF
cd .. cd ..
echo Building Game... echo Building Game...
lime build windows --haxeflag="--macro include('scripting')" --haxeflag="-xml docs/doc.xml" -D DOCUMENTATION --no-output lime build windows --haxeflag="-xml docs/doc.xml" -D doc-gen -D DOCUMENTATION --no-output
echo art echo art
echo Generated the api xml file at docs/doc.xml echo Generated the api xml file at docs/doc.xml
+8 -3
View File
@@ -3,15 +3,20 @@ package funkin.backend;
import flixel.graphics.frames.FlxFrame; import flixel.graphics.frames.FlxFrame;
import flixel.math.FlxAngle; import flixel.math.FlxAngle;
import flixel.math.FlxMatrix; import flixel.math.FlxMatrix;
import openfl.display.BlendMode;
import openfl.geom.ColorTransform; import openfl.geom.ColorTransform;
class FlxAnimate extends flxanimate.FlxAnimate { class FlxAnimate extends flxanimate.FlxAnimate {
static var rMatrix = new FlxMatrix(); static var rMatrix = new FlxMatrix();
override function drawLimb(limb:FlxFrame, _rMatrix:FlxMatrix, ?colorTransform:ColorTransform) override function drawLimb(limb:FlxFrame, _rMatrix:FlxMatrix, ?colorTransform:ColorTransform, ?blendMode:BlendMode)
{ {
if (alpha == 0 || colorTransform != null && (colorTransform.alphaMultiplier == 0 || colorTransform.alphaOffset == -255) || limb == null || limb.type == EMPTY) if (alpha == 0 || colorTransform != null && (colorTransform.alphaMultiplier == 0 || colorTransform.alphaOffset == -255) || limb == null || limb.type == EMPTY)
return; return;
if (blendMode == null)
blendMode = BlendMode.NORMAL;
for (camera in cameras) for (camera in cameras)
{ {
rMatrix.identity(); rMatrix.identity();
@@ -66,7 +71,7 @@ class FlxAnimate extends flxanimate.FlxAnimate {
} }
rMatrix.translate(_point.x, _point.y); rMatrix.translate(_point.x, _point.y);
camera.drawPixels(limb, null, rMatrix, colorTransform, blend, antialiasing, shaderEnabled ? shader : null); camera.drawPixels(limb, null, rMatrix, colorTransform, blendMode, antialiasing, shaderEnabled ? shader : null);
#if FLX_DEBUG #if FLX_DEBUG
FlxBasic.visibleCount++; FlxBasic.visibleCount++;
#end #end
@@ -84,4 +89,4 @@ class FlxAnimate extends flxanimate.FlxAnimate {
// TODO: ACTUAL OPTIMIZATION // TODO: ACTUAL OPTIMIZATION
return true; return true;
} }
} }
+7 -2
View File
@@ -86,7 +86,12 @@ class ModsFolder {
public static function getModsList():Array<String> { public static function getModsList():Array<String> {
var mods:Array<String> = []; var mods:Array<String> = [];
#if MOD_SUPPORT #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}')) { if (FileSystem.isDirectory('${modsPath}${modFolder}')) {
mods.push(modFolder); mods.push(modFolder);
} else { } else {
@@ -152,4 +157,4 @@ class ModsFolder {
return prepareModLibrary(libName, new ZipFolderLibrary(zipPath, libName, modName), force); return prepareModLibrary(libName, new ZipFolderLibrary(zipPath, libName, modName), force);
} }
#end #end
} }
+14
View File
@@ -46,6 +46,10 @@ class Main extends Sprite
public static var game:FunkinGame; 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; public static var time:Int = 0;
// You can pretty much ignore everything from here on - your code should go in your states. // You can pretty much ignore everything from here on - your code should go in your states.
@@ -152,6 +156,7 @@ class Main extends Sprite
Conductor.init(); Conductor.init();
AudioSwitchFix.init(); AudioSwitchFix.init();
EventManager.init(); EventManager.init();
FlxG.signals.focusGained.add(onFocus);
FlxG.signals.preStateSwitch.add(onStateSwitch); FlxG.signals.preStateSwitch.add(onStateSwitch);
FlxG.signals.postStateSwitch.add(onStateSwitchPost); FlxG.signals.postStateSwitch.add(onStateSwitchPost);
@@ -197,6 +202,10 @@ class Main extends Sprite
{asset: diamond, width: 32, height: 32}, new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4)); {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() { private static function onStateSwitch() {
scaleMode.resetSize(); scaleMode.resetSize();
} }
@@ -230,4 +239,9 @@ class Main extends Sprite
Sys.setCwd(Path.addTrailingSlash(openfl.filesystem.File.applicationStorageDirectory.nativePath)); Sys.setCwd(Path.addTrailingSlash(openfl.filesystem.File.applicationStorageDirectory.nativePath));
#end #end
} }
private static var _tickFocused:Float = 0;
public static function get_timeSinceFocus():Float {
return (FlxG.game.ticks - _tickFocused) / 1000;
}
} }
+5 -2
View File
@@ -6,6 +6,7 @@ import funkin.backend.chart.Chart;
import funkin.backend.chart.ChartData.ChartMetaData; import funkin.backend.chart.ChartData.ChartMetaData;
import funkin.backend.scripting.events.menu.MenuChangeEvent; import funkin.backend.scripting.events.menu.MenuChangeEvent;
import funkin.backend.scripting.events.menu.freeplay.*; import funkin.backend.scripting.events.menu.freeplay.*;
import funkin.backend.system.Conductor;
import funkin.game.HealthIcon; import funkin.game.HealthIcon;
import funkin.savedata.FunkinSave; import funkin.savedata.FunkinSave;
@@ -249,10 +250,12 @@ class FreeplayState extends MusicBeatState
else else
FlxG.log.error('Could not find a Sound asset with an ID of \'$soundPath\'.'); FlxG.log.error('Could not find a Sound asset with an ID of \'$soundPath\'.');
if (sound != null && autoplayShouldPlay) if (sound != null && autoplayShouldPlay) {
FlxG.sound.playMusic(sound, 0); FlxG.sound.playMusic(sound, 0);
Conductor.changeBPM(songs[curSelected].bpm, songs[curSelected].beatsPerMeasure, songs[curSelected].stepsPerBeat);
}
} }
if(!disableAsyncLoading) Main.execAsync(huh); if (!disableAsyncLoading) Main.execAsync(huh);
else huh(); else huh();
} }
songInstPlaying = true; songInstPlaying = true;
+1 -1
View File
@@ -45,7 +45,7 @@ class OptionsScreen extends FlxTypedSpriteGroup<OptionType> {
if (members.length > 0) { if (members.length > 0) {
members[curSelected].selected = true; members[curSelected].selected = true;
if (controls.ACCEPT || FlxG.mouse.justReleased) if (controls.ACCEPT || (FlxG.mouse.justReleased && Main.timeSinceFocus > 0.25))
members[curSelected].onSelect(); members[curSelected].onSelect();
if (controls.LEFT_P) if (controls.LEFT_P)
members[curSelected].onChangeSelection(-1); members[curSelected].onChangeSelection(-1);