Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Commit

Permalink
quick html5 crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Apr 16, 2024
1 parent 6baf2b6 commit ff7f0dd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
8 changes: 5 additions & 3 deletions source/funkin/Preferences.hx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class Preferences {
/****/addHeader("UI");/****/

#if !mobile
#if !web
addPref('framerate', 'framerate', 60);
#end
addPref('fps-counter', 'fps counter', true);
#end
addPref('vanilla-ui', 'vanilla ui', false);
Expand All @@ -54,7 +56,7 @@ class Preferences {
#end
addPref('antialiasing', 'antialiasing', true);
addPref('quality', 'quality', {array:["high", "medium", "low", "rudy"], value:"high"});
#if !hl
#if !(hl || web)
addPref('gpu-textures', 'gpu textures', true);
#end
#if desktop
Expand Down Expand Up @@ -93,7 +95,7 @@ class Preferences {
}

public static inline function updateFramerate():Void
FlxG.drawFramerate = FlxG.updateFramerate = #if mobile 60; #else getPref('framerate'); #end
FlxG.drawFramerate = FlxG.updateFramerate = #if (mobile || web) 60; #else getPref('framerate'); #end

public static inline function updateFpsCounter():Void
#if !mobile Main.fpsCounter.visible = getPref('fps-counter'); #else {} #end
Expand All @@ -102,7 +104,7 @@ class Preferences {
#if desktop Main.resizeGame(getPref('resolution')); #else {} #end

public static inline function updateGpuTextures():Void
#if !hl AssetManager.gpuTextures = getPref('gpu-textures'); #else {} #end
#if !(hl || web) AssetManager.gpuTextures = getPref('gpu-textures'); #else {} #end

public static function effectPrefs():Void {
updateFramerate();
Expand Down
9 changes: 5 additions & 4 deletions source/funkin/sound/FlxFunkSoundGroup.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package funkin.sound;

import openfl.events.Event;

@:access(funkin.sound.FlxFunkSound)
class FlxFunkSoundGroup<T:FlxFunkSound> extends FlxBasic
{
public static var group:FlxFunkSoundGroup<FlxFunkSound>;
Expand All @@ -11,7 +12,7 @@ class FlxFunkSoundGroup<T:FlxFunkSound> extends FlxBasic
public function new() {
super();

@:privateAccess // Window lose focus, pause sounds
// Window lose focus, pause sounds
FlxG.stage.addEventListener(Event.DEACTIVATE, (e) -> {
sounds.fastForEach((sound, i) -> {
if (sound != null) if (sound.playing) {
Expand All @@ -21,7 +22,7 @@ class FlxFunkSoundGroup<T:FlxFunkSound> extends FlxBasic
});
});

@:privateAccess // Window gain focus, resume sounds
// Window gain focus, resume sounds
FlxG.stage.addEventListener(Event.ACTIVATE, (e) -> {
sounds.fastForEach((sound, i) -> {
if (sound != null) if (sound.__gainFocus) {
Expand All @@ -41,7 +42,7 @@ class FlxFunkSoundGroup<T:FlxFunkSound> extends FlxBasic
}

// Resumes all sounds set with pausable
public function resume():Void @:privateAccess
public function resume():Void
{
sounds.fastForEach((sound, i) -> {
if (sound != null) if (sound.__resume) {
Expand All @@ -52,7 +53,7 @@ class FlxFunkSoundGroup<T:FlxFunkSound> extends FlxBasic
}

// Pauses all sounds set with pausable
public function pause():Void @:privateAccess
public function pause():Void
{
sounds.fastForEach((sound, i) -> {
if (sound != null) if (sound.pausable) if (sound.playing) {
Expand Down
12 changes: 5 additions & 7 deletions source/funkin/util/backend/AssetManager.hx
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ class AssetManager
* GRAPHIC CACHE
*/

public static var gpuTextures:Bool = #if hl false; #else true; #end
public static var gpuTextures:Bool = #if (hl || web) false; #else true; #end
public static var lodQuality:LodLevel = HIGH;
public static function setLodQuality(level:String):LodLevel {
return lodQuality = LodLevel.fromString(level);
Expand All @@ -345,11 +345,6 @@ class AssetManager
}

var bitmap = __getFileBitmap(path);

#if web
if (bitmap == null) // Testing fail safe while i figure this shit out
bitmap = new BitmapData(5,5,false,FlxColor.MAGENTA);
#end

return __cacheFromBitmap(key, bitmap, staticAsset, lodLevel, useTexture);
}
Expand Down Expand Up @@ -509,7 +504,9 @@ class AssetManager
}

@:noCompletion
inline static function __clearCacheFromKeys(keys:Array<String>, clearGraphics:Bool, clearSounds:Bool):Array<String> {
inline static function __clearCacheFromKeys(keys:Array<String>, clearGraphics:Bool, clearSounds:Bool):Array<String>
{
#if !web // Temp slap-on fix till i figure out the problem with web disposing
var removeKeys:Array<String> = [];

keys.fastForEach((key, i) -> {
Expand All @@ -527,6 +524,7 @@ class AssetManager
removeKeys.fastForEach((key, i) -> {
keys.remove(key);
});
#end

return keys;
}
Expand Down

0 comments on commit ff7f0dd

Please sign in to comment.