tiny chart fix
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package funkin.system.modules;
|
||||
|
||||
import lime.media.AudioManager;
|
||||
import flixel.system.FlxSound;
|
||||
import flixel.FlxState;
|
||||
import funkin.windows.WindowsAPI;
|
||||
|
||||
/**
|
||||
* if youre stealing this keep this comment at least please lol
|
||||
*
|
||||
* hi gray itsa me yoshicrafter29 i fixed it hehe
|
||||
*/
|
||||
@:dox(hide)
|
||||
class AudioSwitchFix {
|
||||
@:noCompletion
|
||||
private static function onStateSwitch(state:FlxState):Void {
|
||||
#if windows
|
||||
if (Main.audioDisconnected) {
|
||||
|
||||
var playingList:Array<PlayingSound> = [];
|
||||
for(e in FlxG.sound.list) {
|
||||
if (e.playing) {
|
||||
playingList.push({
|
||||
sound: e,
|
||||
time: e.time
|
||||
});
|
||||
e.stop();
|
||||
}
|
||||
}
|
||||
if (FlxG.sound.music != null)
|
||||
FlxG.sound.music.stop();
|
||||
|
||||
AudioManager.shutdown();
|
||||
AudioManager.init();
|
||||
// #if !lime_doc_gen
|
||||
// if (AudioManager.context.type == OPENAL)
|
||||
// {
|
||||
// var alc = AudioManager.context.openal;
|
||||
|
||||
// var device = alc.openDevice();
|
||||
// var ctx = alc.createContext(device);
|
||||
// alc.makeContextCurrent(ctx);
|
||||
// alc.processContext(ctx);
|
||||
// }
|
||||
// #end
|
||||
Main.changeID++;
|
||||
|
||||
for(e in playingList) {
|
||||
e.sound.play(e.time);
|
||||
}
|
||||
|
||||
Main.audioDisconnected = false;
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
||||
public static function init() {
|
||||
#if windows
|
||||
WindowsAPI.registerAudio();
|
||||
FlxG.signals.preStateCreate.add(onStateSwitch);
|
||||
#end
|
||||
}
|
||||
}
|
||||
|
||||
typedef PlayingSound = {
|
||||
var sound:FlxSound;
|
||||
var time:Float;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package funkin.system.modules;
|
||||
|
||||
import lime.system.System;
|
||||
import funkin.windows.WindowsAPI;
|
||||
import openfl.Lib;
|
||||
import openfl.events.UncaughtErrorEvent;
|
||||
import openfl.events.ErrorEvent;
|
||||
import openfl.errors.Error;
|
||||
import openfl.events.UncaughtErrorEvent;
|
||||
import haxe.CallStack;
|
||||
|
||||
class CrashHandler {
|
||||
public static function init() {
|
||||
Lib.current.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onError);
|
||||
}
|
||||
|
||||
public static function onError(e:UncaughtErrorEvent) {
|
||||
var m:String = e.error;
|
||||
if (Std.isOfType(e.error, Error)) {
|
||||
var err = cast(e.error, Error);
|
||||
m = '${err.message}';
|
||||
} else if (Std.isOfType(e.error, ErrorEvent)) {
|
||||
var err = cast(e.error, ErrorEvent);
|
||||
m = '${err.text}';
|
||||
}
|
||||
var stack = CallStack.exceptionStack();
|
||||
var stackLabel:String = "";
|
||||
for(e in stack) {
|
||||
switch(e) {
|
||||
case CFunction: stackLabel += "Non-Haxe (C) Function";
|
||||
case Module(c): stackLabel += 'Module ${c}';
|
||||
case FilePos(parent, file, line, col):
|
||||
switch(parent) {
|
||||
case Method(cla, func):
|
||||
stackLabel += '(${file}) ${cla.split(".").last()}.$func() - line $line';
|
||||
case _:
|
||||
stackLabel += '(${file}) - line $line';
|
||||
}
|
||||
case LocalFunction(v):
|
||||
stackLabel += 'Local Function ${v}';
|
||||
case Method(cl, m):
|
||||
stackLabel += '${cl} - ${m}';
|
||||
}
|
||||
stackLabel += "\r\n";
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
WindowsAPI.showMessageBox("Codename Engine Crash Handler", 'Uncaught Error:$m\n\n$stackLabel', MSG_ERROR);
|
||||
#if sys
|
||||
Sys.exit(1);
|
||||
#end
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package funkin.system.modules;
|
||||
|
||||
import openfl.utils.AssetCache;
|
||||
import openfl.display.BitmapData;
|
||||
import openfl.media.Sound;
|
||||
import openfl.text.Font;
|
||||
#if lime
|
||||
import lime.utils.Assets as LimeAssets;
|
||||
#end
|
||||
|
||||
|
||||
class FunkinCache extends AssetCache {
|
||||
public static var instance:FunkinCache;
|
||||
/**
|
||||
Internal
|
||||
**/
|
||||
@:noCompletion @:dox(hide) public var bitmapData2:Map<String, BitmapData>;
|
||||
|
||||
/**
|
||||
Internal
|
||||
**/
|
||||
@:noCompletion @:dox(hide) public var font2:Map<String, Font>;
|
||||
|
||||
/**
|
||||
Internal
|
||||
**/
|
||||
@:noCompletion @:dox(hide) public var sound2:Map<String, Sound>;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
moveToSecondLayer();
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public static function init() {
|
||||
openfl.utils.Assets.cache = new FunkinCache();
|
||||
|
||||
FlxG.signals.preStateSwitch.add(function() {
|
||||
instance.moveToSecondLayer();
|
||||
});
|
||||
|
||||
FlxG.signals.postStateSwitch.add(function() {
|
||||
instance.clearSecondLayer();
|
||||
});
|
||||
}
|
||||
|
||||
public function moveToSecondLayer() {
|
||||
bitmapData2 = bitmapData;
|
||||
font2 = font;
|
||||
sound2 = sound;
|
||||
bitmapData = [];
|
||||
font = [];
|
||||
sound = [];
|
||||
}
|
||||
|
||||
public function clearSecondLayer() {
|
||||
for(k=>b in bitmapData2) {
|
||||
FlxG.bitmap.removeByKey(k);
|
||||
LimeAssets.cache.image.remove(k);
|
||||
}
|
||||
for(k=>f in font2) {
|
||||
LimeAssets.cache.font.remove(k);
|
||||
}
|
||||
for(k=>s in sound2) {
|
||||
LimeAssets.cache.audio.remove(k);
|
||||
}
|
||||
|
||||
bitmapData2 = [];
|
||||
font2 = [];
|
||||
sound2 = [];
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves a cached BitmapData.
|
||||
|
||||
@param id The ID of the cached BitmapData
|
||||
@return The cached BitmapData instance
|
||||
**/
|
||||
public override function getBitmapData(id:String):BitmapData
|
||||
{
|
||||
var s = bitmapData.get(id);
|
||||
if (s != null)
|
||||
return s;
|
||||
var s2 = bitmapData2.get(id);
|
||||
if (s2 != null) {
|
||||
bitmapData2.remove(id);
|
||||
bitmapData.set(id, s2);
|
||||
}
|
||||
return s2;
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves a cached Font.
|
||||
|
||||
@param id The ID of the cached Font
|
||||
@return The cached Font instance
|
||||
**/
|
||||
public override function getFont(id:String):Font
|
||||
{
|
||||
var s = font.get(id);
|
||||
if (s != null)
|
||||
return s;
|
||||
var s2 = font2.get(id);
|
||||
if (s2 != null) {
|
||||
font2.remove(id);
|
||||
font.set(id, s2);
|
||||
}
|
||||
return s2;
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves a cached Sound.
|
||||
|
||||
@param id The ID of the cached Sound
|
||||
@return The cached Sound instance
|
||||
**/
|
||||
public override function getSound(id:String):Sound
|
||||
{
|
||||
var s = sound.get(id);
|
||||
if (s != null)
|
||||
return s;
|
||||
var s2 = sound2.get(id);
|
||||
if (s2 != null) {
|
||||
sound2.remove(id);
|
||||
sound.set(id, s2);
|
||||
}
|
||||
return s2;
|
||||
}
|
||||
|
||||
/**
|
||||
Checks whether a BitmapData asset is cached.
|
||||
|
||||
@param id The ID of a BitmapData asset
|
||||
@return Whether the object has been cached
|
||||
**/
|
||||
public override function hasBitmapData(id:String):Bool
|
||||
{
|
||||
return bitmapData.exists(id) || bitmapData2.exists(id);
|
||||
}
|
||||
|
||||
/**
|
||||
Checks whether a Font asset is cached.
|
||||
|
||||
@param id The ID of a Font asset
|
||||
@return Whether the object has been cached
|
||||
**/
|
||||
public override function hasFont(id:String):Bool
|
||||
{
|
||||
return font.exists(id) || font2.exists(id);
|
||||
}
|
||||
|
||||
/**
|
||||
Checks whether a Sound asset is cached.
|
||||
|
||||
@param id The ID of a Sound asset
|
||||
@return Whether the object has been cached
|
||||
**/
|
||||
public override function hasSound(id:String):Bool
|
||||
{
|
||||
return sound.exists(id) || sound2.exists(id);
|
||||
}
|
||||
/**
|
||||
Removes a BitmapData from the cache.
|
||||
|
||||
@param id The ID of a BitmapData asset
|
||||
@return `true` if the asset was removed, `false` if it was not in the cache
|
||||
**/
|
||||
public override function removeBitmapData(id:String):Bool
|
||||
{
|
||||
#if lime
|
||||
LimeAssets.cache.image.remove(id);
|
||||
#end
|
||||
return bitmapData.remove(id) || bitmapData2.remove(id);
|
||||
}
|
||||
|
||||
/**
|
||||
Removes a Font from the cache.
|
||||
|
||||
@param id The ID of a Font asset
|
||||
@return `true` if the asset was removed, `false` if it was not in the cache
|
||||
**/
|
||||
public override function removeFont(id:String):Bool
|
||||
{
|
||||
#if lime
|
||||
LimeAssets.cache.font.remove(id);
|
||||
#end
|
||||
return font.remove(id) || font2.remove(id);
|
||||
}
|
||||
|
||||
/**
|
||||
Removes a Sound from the cache.
|
||||
|
||||
@param id The ID of a Sound asset
|
||||
@return `true` if the asset was removed, `false` if it was not in the cache
|
||||
**/
|
||||
public override function removeSound(id:String):Bool
|
||||
{
|
||||
#if lime
|
||||
LimeAssets.cache.audio.remove(id);
|
||||
#end
|
||||
return sound.remove(id) || sound2.remove(id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user