Skip to content

Commit

Permalink
Animation debug now checks actual frames instead of parsing the xml A…
Browse files Browse the repository at this point in the history
…GAIN

Changing loopstart will re-play the animation from that frame
combine assets readDirectory
  • Loading branch information
superpowers04 committed Jul 28, 2024
1 parent 5885981 commit 08aa59e
Show file tree
Hide file tree
Showing 14 changed files with 199 additions and 149 deletions.
67 changes: 40 additions & 27 deletions source/AnimationDebug.hx
Original file line number Diff line number Diff line change
Expand Up @@ -449,38 +449,48 @@ class AnimationDebug extends MusicBeatState
charJson = chara.charProperties;
animList = [];
charAnims = ["**Unbind"];
if (chara.charXml != null){
if(chara.charXml.trim().substring(0,1) == "{"){ // Probably a sprite atlas
var obj:flixel.graphics.atlas.TexturePackerAtlas = Json.parse(chara.charXml);
inline function addAnim(name:String){
if(name.lastIndexOf('-') != -1 ) name = name.substring(0,name.lastIndexOf('-') - 1);
else if(name.lastIndexOf('0') != -1)name = name.substring(0,name.lastIndexOf('0') - 1);
if(!charAnims.contains(name))charAnims.push(name);
}
// yes I stole this from flxatlasframes, fight me
if ((obj.frames is Array)){
for (frame in Lambda.array(obj.frames)){
addAnim(frame.filename);
}
}else{
for (frameName in Reflect.fields(obj.frames)){
addAnim(frameName);
}
}
}else{
var charAnimsContains:Map<String,Bool> = [];
var regTP:EReg = (~/<SubTexture name="([A-z0-9\-_ !?:;\(\)\[\]'\/\{\}+@#$%^&*~`.,\\\|]+)[0-9][0-9][0-9][0-9]"/gm);
var input:String = chara.charXml;
while (regTP.match(input)) {
input=regTP.matchedRight();
// if (chara.charXml != null){
// if(chara.charXml.trim().substring(0,1) == "{"){ // Probably a sprite atlas
// var obj:flixel.graphics.atlas.TexturePackerAtlas = Json.parse(chara.charXml);
// inline function addAnim(name:String){
// if(name.lastIndexOf('-') != -1 ) name = name.substring(0,name.lastIndexOf('-') - 1);
// else if(name.lastIndexOf('0') != -1)name = name.substring(0,name.lastIndexOf('0') - 1);
// if(!charAnims.contains(name))charAnims.push(name);
// }
// // yes I stole this from flxatlasframes, fight me
// if ((obj.frames is Array)){
// for (frame in Lambda.array(obj.frames)){
// addAnim(frame.filename);
// }
// }else{
// for (frameName in Reflect.fields(obj.frames)){
// addAnim(frameName);
// }
// }
// }else{
var regTP:EReg = (~/([A-z0-9\-_ !?:;\(\)\[\]'\/\{\}+@#$%^&*~`.,\\\|]+)[0-9][0-9][0-9][0-9]/gm);
var charAnimsContains:Map<String,Bool> = [];
@:privateAccess{
for(name=>_ in chara.frames.framesByName){
if(!regTP.match(name)) continue;
var matched = regTP.matched(1);
if (charAnimsContains.exists(matched)) continue;

charAnimsContains[matched] = true;
charAnims.push(matched);
}
}
}
}
// var regTP:EReg = (~/<SubTexture name="([A-z0-9\-_ !?:;\(\)\[\]'\/\{\}+@#$%^&*~`.,\\\|]+)[0-9][0-9][0-9][0-9]"/gm);
// var input:String = chara.charXml;
// while (regTP.match(input)) {
// input=regTP.matchedRight();
// var matched = regTP.matched(1);
// if (charAnimsContains.exists(matched)) continue;

// charAnimsContains[matched] = true;
// charAnims.push(matched);
// }
// }
// }
try{
canEditJson = (charJson == null || chara.loadedFrom == "");
if(charJson.animations != null && charJson.animations[0] != null){
Expand Down Expand Up @@ -979,6 +989,9 @@ class AnimationDebug extends MusicBeatState
uiMap["animFPS"] = new FlxUINumericStepper(140, 110, 1, 24);
uiMap["looptxt"] = new FlxText(10, 130,0,"Loop start frame");
uiMap["loopStart"] = new FlxUINumericStepper(140, 130, 1, 0,0);
uiMap["loopStart"].callback=function(index:Int){
chara.playAnim("ANIMATIONDEBUG_tempAnim",true,index);
}
uiMap["AnimationLengthText"] = new FlxText(10, 130,0,"Animation Start > Finish");
uiMap["animStart"] = new FlxUINumericStepper(140, 130, 1, 0,0);
uiMap["animFinish"] = new FlxUINumericStepper(140, 130, 1, 0,0);
Expand Down
193 changes: 103 additions & 90 deletions source/FuckState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,108 @@ class FuckState extends FlxUIState {
public static var useOpenFL:Bool = false;
public static var lastERROR = "";
public static var allowLogWrite:Bool = true;
public static function generateReport(error:String = "UNKNOWN ERROR?",type:String = "CRASH"):Bool{

var dateNow:String = "";
var err = "";
try{
var funnyQuip = "insert funny line here";
var _date = Date.now();
try{
var jokes = [
"Hey look, mom! I'm on a crash report!",
"This wasn't supposed to go down like this...",
"Don't look at me that way.. I tried",
"Ow, that really hurt :(",
"missingno",
"Did I ask for your opinion?",
"Oh lawd it crashing",
"get stickbugged lmao",
"Mom? Come pick me up. I'm scared...",
"It's just standing there... Menacingly.",
"Are you having fun? I'm having fun.",
"That crash though",
"I'm out of ideas.",
"Where do we go from here?",
"Coded in Haxe.",
"Oh what the hell?",
"I just wanted to have fun.. :(",
"Oh no, not this again",
"null object reference is real and haunts us",
'What is a error exactly?',
"I just got ratioed :(",
"L + Ratio + Skill Issue",
"Now with more crashes",
"I'm out of ideas.",
"me when null object reference",
'you looked at me funny :(',
'Hey VSauce, Michael here. What is an error?',
'AAAHHHHHHHHHHHHHH! Don\'t mind me, I\'m practicing my screaming',
'crash% speedrun less goooo!',
'hey look, the consequences of my actions are coming to haunt me',
'time to go to stack overflow for a solution',
'you\'re mother',
'sex pt 2: electric boobaloo',
'sex pt 3: gone wrong',
'the stalemate button was boobytrapped',
'mf shoulda just stayed with psych engine :sob:',
'super engine moment',
'Another one bites the dust',
"It's fine, everything is good. What do you mean this is a crash report?"

];
funnyQuip = jokes[Std.int(Math.random() * jokes.length - 1) ]; // I know, this isn't FlxG.random but fuck you the game just crashed
}catch(e){}
err = '# Super Engine Crash Report: \n# $funnyQuip\n$error';
if(!SELoader.exists('crashReports/')){
SELoader.createDirectory('crashReports/');
}

dateNow = StringTools.replace(StringTools.replace(_date.toString(), " ", "_"), ":", ".");
try{
currentStateName = haxe.rtti.Rtti.getRtti(cast FlxG.state).path;
}catch(e){}
try{
err +="\n\n # ---------- SYSTEM INFORMATION --------";

err +='\n Operating System: ${Sys.systemName()}';
err +='\n Working Path: ${SELoader.absolutePath('')}';
err +='\n Current Working Directory: ${Sys.getCwd()}';
err +='\n Executable path: ${Sys.programPath()}';
err +='\n Arguments: ${Sys.args()}';
err +="\n # ---------- GAME INFORMATION ----------";
err +='\n Version: ${MainMenuState.ver}';
err +='\n Buildtype: ${MainMenuState.compileType}';
err +='\n Debug: ${SESave.data.animDebug}';
err +='\n Registered character count: ${TitleState.characters.length}';
err +='\n Scripts: ${SESave.data.scripts}';
err +='\n State: ${currentStateName}';
err +='\n Save: ${SESave.data}';
err +='\n # --------------------------------------';

}catch(e){
trace('Unable to get system information! ${e.message}');
}
try{
SELoader.saveContent('crashReports/SUPERENGINE_${type}-${dateNow}.log',err);
}catch(e){
sys.io.File.saveContent('crashReports/SUPERENGINE_${type}-${dateNow}.log',err);

}


trace('Wrote a crash report to ./crashReports/SUPERENGINE_${type}-${dateNow}.log!');
trace('Crash Report:\n$err');
return true;
}catch(e){
trace('Unable to write a crash report!');
if(err != null && err.indexOf('SYSTEM INFORMATION') != -1){
trace('Here is generated crash report:\n$err');

}
}
return false;
}
// This function has a lot of try statements.
// The game just crashed, we need as many failsafes as possible to prevent the game from closing or crash looping
@:keep inline public static function FUCK(e:Dynamic,?info:String = "unknown",_forced:Bool = false,_FATAL:Bool = false,_rawError:Bool=false){
Expand Down Expand Up @@ -87,104 +189,15 @@ class FuckState extends FlxUIState {
}catch(e){}
}
var saved = false;
var dateNow:String = "";
var err = "";
exception += _stack;

// Crash log
if(lastERROR != exception && allowLogWrite){
lastERROR = exception;

try{
var funnyQuip = "insert funny line here";
var _date = Date.now();
try{
var jokes = [
"Hey look, mom! I'm on a crash report!",
"This wasn't supposed to go down like this...",
"Don't look at me that way.. I tried",
"Ow, that really hurt :(",
"missingno",
"Did I ask for your opinion?",
"Oh lawd it crashing",
"get stickbugged lmao",
"Mom? Come pick me up. I'm scared...",
"It's just standing there... Menacingly.",
"Are you having fun? I'm having fun.",
"That crash though",
"I'm out of ideas.",
"Where do we go from here?",
"Coded in Haxe.",
"Oh what the hell?",
"I just wanted to have fun.. :(",
"Oh no, not this again",
"null object reference is real and haunts us",
'What is a error exactly?',
"I just got ratioed :(",
"L + Ratio + Skill Issue",
"Now with more crashes",
"I'm out of ideas.",
"me when null object reference",
'you looked at me funny :(',
'Hey VSauce, Michael here. What is an error?',
'AAAHHHHHHHHHHHHHH! Don\'t mind me, I\'m practicing my screaming',
'crash% speedrun less goooo!',
'hey look, the consequences of my actions are coming to haunt me',
'time to go to stack overflow for a solution',
'you\'re mother',
'sex pt 2: electric boobaloo',
'sex pt 3: gone wrong',
'the stalemate button was boobytrapped',
'mf shoulda just stayed with psych engine :sob:',
'super engine moment',
'Another one bites the dust',
"It's fine, everything is good. What do you mean this is a crash report?"

];
funnyQuip = jokes[Std.int(Math.random() * jokes.length - 1) ]; // I know, this isn't FlxG.random but fuck you the game just crashed
}catch(e){}
err = '# Super Engine Crash Report: \n# $funnyQuip\n${exception}\nThis happened in ${info}';
if(!SELoader.exists('crashReports/')){
SELoader.createDirectory('crashReports/');
}
saved = generateReport('${exception}\nThis happened in ${info}','CRASH');

dateNow = StringTools.replace(StringTools.replace(_date.toString(), " ", "_"), ":", ".");
try{
currentStateName = haxe.rtti.Rtti.getRtti(cast FlxG.state).path;
}catch(e){}
try{
err +="\n\n # ---------- SYSTEM INFORMATION --------";

err +='\n Operating System: ${Sys.systemName()}';
err +='\n Working Path: ${SELoader.absolutePath('')}';
err +='\n Current Working Directory: ${Sys.getCwd()}';
err +='\n Executable path: ${Sys.programPath()}';
err +='\n Arguments: ${Sys.args()}';
err +="\n # ---------- GAME INFORMATION ----------";
err +='\n Version: ${MainMenuState.ver}';
err +='\n Buildtype: ${MainMenuState.compileType}';
err +='\n Debug: ${SESave.data.animDebug}';
err +='\n Registered character count: ${TitleState.characters.length}';
err +='\n Scripts: ${SESave.data.scripts}';
err +='\n State: ${currentStateName}';
err +='\n Save: ${SESave.data}';
err +='\n # --------------------------------------';

}catch(e){
trace('Unable to get system information! ${e.message}');
}
sys.io.File.saveContent('crashReports/SUPERENGINE_CRASH-${dateNow}.log',err);

saved = true;
trace('Wrote a crash report to ./crashReports/SUPERENGINE_CRASH-${dateNow}.log!');
trace('Crash Report:\n$err');
}catch(e){
trace('Unable to write a crash report!');
if(err != null && err.indexOf('SYSTEM INFORMATION') != -1){
trace('Here is generated crash report:\n$err');

}
}
}
Main.renderLock.release();
if(Main.game == null || _rawError || !TitleState.initialized || useOpenFL){
Expand Down
22 changes: 10 additions & 12 deletions source/HealthIcon.hx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class HealthIcon extends FlxSprite
public var trackingOffset:Float = 0;
// public var pathh = "mods/characters";

public function new(?char:String = 'bf', ?isPlayer:Bool = false,?clone:String = "",?isMenuIcon:Bool = false,?path:String = "mods/characters") {
public function new(?char:String = 'face', ?isPlayer:Bool = false,?clone:String = "",?isMenuIcon:Bool = false,?path:String = "mods/characters") {
super();
this.isPlayer = isPlayer;
this.isMenuIcon = isMenuIcon;
Expand Down Expand Up @@ -48,13 +48,13 @@ class HealthIcon extends FlxSprite
if(char is CharInfo){
charInfo = cast(char);
}
if(char.namespace == "INTERNAL"){
changeSprite(charInfo?.getNamespacedName() ?? "face");
return;
}
if(charInfo == null){
trace('Invalid type passed, defaulting to vanilla');
changeSprite('INTERNAL|bf');
changeSprite('face');
return;
}
if(charInfo.nameSpace == "INTERNAL"){
changeSprite(charInfo?.getNamespacedName() ?? "face");
return;
}

Expand Down Expand Up @@ -112,7 +112,7 @@ class HealthIcon extends FlxSprite
public function changeSprite(?char:String = 'face',?clone:String = "face",?useClone:Bool = true,?pathh:String = "mods/characters") {
if(char == hichar) return;
if(char == "lonely") char = "face";
var chars:Array<String> = ["INTERNAL|bf","INTERNAL|gf","face",'EVENTNOTE','gf'];
var chars:Array<String> = ["INTERNAL|bf","INTERNAL|gf","internal|bf","internal|gf",'bf',"face",'EVENTNOTE','gf'];
var relAnims:Bool = true;

var _path = "";
Expand Down Expand Up @@ -169,15 +169,13 @@ class HealthIcon extends FlxSprite

if(chars.contains(char.toLowerCase())){ // For vanilla characters
if (relAnims){
animation.add('bf-car', [0, 1], 0, false, isPlayer);
animation.add('bf-christmas', [0, 1], 0, false, isPlayer);
if(graphic.width > 451){ // Old icon grid
MainMenuState.errorMessage += ('You are using a really old iconGrid, this is usually caused by updating from a really old version of the game\nPlease reinstall the game');
}else{ // Based icon grid
animation.add('internal|bf', [0, 1], 0, false, isPlayer);
animation.add('internal|gf', [2], 0, false, isPlayer);
animation.add('gf', [2], 0, false, isPlayer);
animation.add('INTERNAL|gf', [2], 0, false, isPlayer);

animation.add('EVENTNOTE', [5, 5], 0, false, false);
animation.add('eventnote', [5, 5], 0, false, false);
}
}
animation.play(char.toLowerCase());
Expand Down
4 changes: 4 additions & 0 deletions source/LoadingScreen.hx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import openfl.text.TextFormat;
import flixel.math.FlxMath;
import flixel.text.FlxText;
import lime.app.Application;
import se.SEProfiler;

@:NullSafety(StrictThreaded) class LoadingScreen extends Sprite{
public static var object:LoadingScreen;
Expand Down Expand Up @@ -261,6 +262,7 @@ import lime.app.Application;
forceHide();
return;
}
SEProfiler.decay = false;
// object.alpha = 1;
if(tween != null){tween.cancel();}
isVisible = object.funni = true;
Expand All @@ -277,6 +279,7 @@ import lime.app.Application;
}
public static function forceHide(){
if(object == null) return;
SEProfiler.decay = true;
if(tween != null){tween.cancel();}
isVisible = object.funni = false;
object.alpha = 0;
Expand All @@ -287,6 +290,7 @@ import lime.app.Application;
public static function hide(){
if(Main.game != null) Main.game.blockUpdate = Main.game.blockDraw = false;
if(object == null) return;
SEProfiler.decay = true;
if(!object.funni){
object.alpha = 0;
return;
Expand Down
4 changes: 2 additions & 2 deletions source/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ class Note extends FlxSprite
case 1:if (SESave.data.cpuStrums) {PlayState.instance.DadStrumPlayAnim(noteData);}
}; // Strums
if(noteAnimation != null){
var anim = (if(noteAnimation == "") getNoteAnim(noteData) else noteAnimation);
var char = (if(char == null)PlayState.getCharFromID(charID,true) else char);
var anim = ((noteAnimation == "") ? getNoteAnim(noteData) : noteAnimation);
var char = ((char == null) ? PlayState.getCharFromID(charID,true) : char);
if(!isSustainNote && char.animName == anim){
char.animation.play('idle',true);
}
Expand Down
Loading

0 comments on commit 08aa59e

Please sign in to comment.