From 696b1b895745f35d5f3ddb67dfd956e0847ffb2a Mon Sep 17 00:00:00 2001
From: MaybeMaru <97055307+MaybeMaru@users.noreply.github.com>
Date: Fri, 29 Dec 2023 13:33:13 +0100
Subject: [PATCH] cum
---
Project.xml | 2 +-
source/FPS_Mem.hx | 5 +++++
source/Main.hx | 13 +++++++++++--
source/funkin/graphics/FlxSpriteExt.hx | 11 ++++++++---
source/funkin/states/menus/TitleState.hx | 8 +++++---
source/funkin/states/options/OptionsState.hx | 7 +++++++
6 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/Project.xml b/Project.xml
index c5a02fc1..868b9756 100644
--- a/Project.xml
+++ b/Project.xml
@@ -44,7 +44,7 @@
-
+
diff --git a/source/FPS_Mem.hx b/source/FPS_Mem.hx
index 782bad8b..4e6b4ff0 100644
--- a/source/FPS_Mem.hx
+++ b/source/FPS_Mem.hx
@@ -61,7 +61,12 @@ class FPS_Mem extends TextField
times.shift();
final fps:Int = times.length;
+ #if web
+ final mem:Float = FlxMath.roundDecimal(Math.round(System.totalMemory * memDiv) * 0.01, 2);
+ #else
final mem:Float = Math.round(System.totalMemory * memDiv) * 0.01;
+ #end
+
if (mem > memPeak) memPeak = mem;
final result:UTF8String =
diff --git a/source/Main.hx b/source/Main.hx
index 3317f528..369fb975 100644
--- a/source/Main.hx
+++ b/source/Main.hx
@@ -1,5 +1,7 @@
package;
+import openfl.display.BitmapData;
+import flixel.system.FlxAssets;
import lime.app.Application;
import openfl.events.UncaughtErrorEvent;
import openfl.Lib;
@@ -107,18 +109,21 @@ class Main extends Sprite
private function init(?E:Event):Void
{
- #if mac throw("no."); #end
+ #if (mac || web) throw("no."); #end
if (hasEventListener(Event.ADDED_TO_STAGE))
removeEventListener(Event.ADDED_TO_STAGE, init);
setupGame();
}
- public static final DEFAULT_GRAPHIC:FlxGraphic = FlxGraphic.fromAssetKey("flixel/images/logo/default.png", true, "::default_graphic::", false);
+ public static var DEFAULT_GRAPHIC(default, null):GlobalGraphic = null;
private function setupGame():Void {
final stageWidth:Int = Lib.current.stage.stageWidth;
final stageHeight:Int = Lib.current.stage.stageHeight;
+
+ @:privateAccess
+ DEFAULT_GRAPHIC = new GlobalGraphic(null, FlxAssets.getBitmapData("flixel/images/logo/default.png"));
if (settings.zoom == -1.0) {
final ratioX:Float = stageWidth / settings.width;
@@ -130,4 +135,8 @@ class Main extends Sprite
addChild(game = new FlxFunkGame(settings.width, settings.height, settings.initialState, settings.framerate, settings.framerate, settings.skipSplash, settings.startFullscreen));
}
+}
+
+class GlobalGraphic extends FlxGraphic {
+ override function destroy() {} // Lol
}
\ No newline at end of file
diff --git a/source/funkin/graphics/FlxSpriteExt.hx b/source/funkin/graphics/FlxSpriteExt.hx
index 5ee4c5fc..a12d54fb 100644
--- a/source/funkin/graphics/FlxSpriteExt.hx
+++ b/source/funkin/graphics/FlxSpriteExt.hx
@@ -1,5 +1,6 @@
package funkin.graphics;
+import flixel.graphics.frames.FlxFrame;
import flixel.addons.effects.FlxSkewedSprite;
import flixel.util.FlxDestroyUtil;
import flixel.math.FlxMatrix;
@@ -114,14 +115,18 @@ class FlxSpriteExt extends FlxSkewedSprite {
}
override function checkEmptyFrame() {
- if (_frame == null)
- loadGraphic(Main.DEFAULT_GRAPHIC);
+ if (_frame == null) {
+ //trace(Main.DEFAULT_GRAPHIC);
+ frames = Main.DEFAULT_GRAPHIC.imageFrame;
+ }
+
+ //loadGraphic(Main.DEFAULT_GRAPHIC);
}
@:noCompletion
private inline function __superDraw() {
inline checkEmptyFrame();
- if (alpha == 0 || _frame.type == EMPTY) return;
+ if (alpha == 0 || #if web _frame == null #elseif desktop _frame.type == FlxFrameType.EMPTY #end) return;
if (dirty) calcFrame(useFramePixels); // rarely
for (i in 0...cameras.length) {
diff --git a/source/funkin/states/menus/TitleState.hx b/source/funkin/states/menus/TitleState.hx
index f3230640..b7daa0df 100644
--- a/source/funkin/states/menus/TitleState.hx
+++ b/source/funkin/states/menus/TitleState.hx
@@ -56,9 +56,11 @@ class TitleState extends MusicBeatState {
titleGroup.add(gfDance);
final colorSwap = Shader.initShader('colorSwap');
- colorSwap.updateTime = false;
- Shader.setSpriteShader(logoBump, 'colorSwap');
- Shader.setSpriteShader(gfDance, 'colorSwap');
+ if (colorSwap != null) {
+ colorSwap.updateTime = false;
+ Shader.setSpriteShader(logoBump, 'colorSwap');
+ Shader.setSpriteShader(gfDance, 'colorSwap');
+ }
titleText = new FunkinSprite('title/titleEnter', [100,FlxG.height*0.8]);
titleText.addAnim('idle', 'Press Enter to Begin');
diff --git a/source/funkin/states/options/OptionsState.hx b/source/funkin/states/options/OptionsState.hx
index 40c86f55..27e45526 100644
--- a/source/funkin/states/options/OptionsState.hx
+++ b/source/funkin/states/options/OptionsState.hx
@@ -14,8 +14,13 @@ class OptionsState extends MusicBeatState {
var selectedSomethin:Bool = false;
override function create():Void {
+ #if web
+ if (fromPlayState && FlxG.sound.music == null) FlxG.sound.playMusic(Paths.music('freakyMenu'));
+ #else
if (!fromPlayState) optionItems.push('Mod Folders');
else if (FlxG.sound.music == null) FlxG.sound.playMusic(Paths.music('freakyMenu'));
+ #end
+
optionItems.push('Exit');
var bg:FunkinSprite = new FunkinSprite('menuBGMagenta');
@@ -104,7 +109,9 @@ class OptionsState extends MusicBeatState {
case 'Preferences': switchState(new funkin.states.options.PreferencesState());
case 'Controls': switchState(new funkin.states.options.ControlsState());
case 'Latency': switchState(new funkin.states.options.LatencyState());
+ #if desktop
case 'Mod Folders': switchState(new funkin.states.options.ModFoldersState());
+ #end
default: exitOptions();
}
}