Skip to content

Commit

Permalink
DUMBASS
Browse files Browse the repository at this point in the history
Fix threaded loading
Add loading icon
  • Loading branch information
superpowers04 committed Jul 18, 2024
1 parent aee0e0a commit e288200
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 45 deletions.
Binary file modified assets/shared/images/loadingIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@

<haxelib name="extension-androidtools" if="android" /> <!-- I am not reimplementing this shit myself -->

<!-- <haxelib name="hxCodec" if="desktop || android"/> -->
<haxelib name="hxCodec" if="desktop || android"/>

<!-- <haxelib name="newgrounds"/> -->
<haxelib name="faxe" if='switch'/>
Expand Down
13 changes: 1 addition & 12 deletions source/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -678,20 +678,11 @@ class CharAnimController extends FlxAnimationController{
} else {
charXml = SELoader.loadXML(xmlName); // Loads the XML as a string.
if (charXml == null){throw('$curCharacter is missing their XML!');} // Boot to main menu if character's XML can't be loaded
// if(charXml.substr(2).replace(String.fromCharCode(0),'').contains('UTF-16')){ // Flash CS6 outputs a UTF-16 xml even though no UTF-16 characters are usually used. This reformats the file to be UTF-8 *hopefully*
// charXml = '<?' + charXml.substr(2).replace(String.fromCharCode(0),'').replace('UTF-16','utf-8');
// }
tex = SEFlxFrames.fromSparrow(SELoader.loadGraphic(pngName), charXml);
}
if (tex == null){throw('$curCharacter is missing their XML!');} // Boot to main menu if character's texture can't be loaded
}
// animOffsets['all'] = charProperties.position;
// animOffsets['all'][1] *=-1;
// animOffsets['all'][0] *=-1;
// animOffsets['all'][0] *=-1;
// dad = new EmptyCharacter(100, 100);
// boyfriend = new EmptyCharacter(400,100);
// gf = new EmptyCharacter(400, 100);

if(charProperties.position != null){

charProperties.cam_pos= charProperties.camera_position;
Expand Down Expand Up @@ -758,8 +749,6 @@ class CharAnimController extends FlxAnimationController{
throw('$curCharacter\'s JSON is invalid!');
return;
} // Boot to main menu if character's JSON can't be loaded
// if ((charProperties == null || charProperties.animations == null || charProperties.animations[0] == null) && amPreview){

loadedFrom = '${charLoc}/$curCharacter/config.json';
if(frames == null){
var pngName:String = "character.png";
Expand Down
1 change: 1 addition & 0 deletions source/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,7 @@ class ChartingState extends ScriptMusicBeatState
deselectNotes();
deleteNote(note);
modifyingNote = true;
}
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions source/LoadingScreen.hx
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,20 @@ import lime.app.Application;
loadingText.isMenuItem = false;
loadingText.visible = true;
if(SESave.data.doCoolLoading){
// loadingIcon = new Sprite();
// loadingIcon.x = 640;
// loadingIcon.y = 300;
// addChild(loadingIcon);
// // var note = new Note(0, 0, null,false,false);
// // note.useFramePixels = true;
// // note.draw();
// var note = SELoader.loadBitmap('assets/shared/images/loadingIcon.png',true);
// loadingIcon.graphics.beginBitmapFill(note,false,true);
// // loadingIcon.graphics.moveTo();
// //
// loadingIcon.graphics.drawRect(0,0, note.width, note.height);
// loadingIcon.graphics.endFill();
// loadingIcon.scaleX = loadingIcon.scaleY= 0.5;
loadingIcon = new Sprite();
loadingIcon.x = 640;
loadingIcon.y = 300;
addChild(loadingIcon);
// var note = new Note(0, 0, null,false,false);
// note.useFramePixels = true;
// note.draw();
var note = SELoader.loadBitmap('assets/shared/images/loadingIcon.png',true);
loadingIcon.graphics.beginBitmapFill(note,false,true);
// loadingIcon.graphics.moveTo();
//
loadingIcon.graphics.drawRect(0,0, note.width, note.height);
loadingIcon.graphics.endFill();
loadingIcon.scaleX = loadingIcon.scaleY= 0.5;

}

Expand Down
78 changes: 64 additions & 14 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -277,26 +277,76 @@ class FlxGameEnhanced extends FlxGame{
public function set__requestedState(e:flixel.util.typeLimit.NextState) return _nextState=e;
public function get__requestedState() return _nextState;
#end
override function switchState():Void
{
SEProfiler.qStart('switch_state');
try{
// Basic reset stuff
FlxG.cameras.reset();
FlxG.inputs.onStateSwitch();
#if FLX_SOUND_SYSTEM
FlxG.sound.destroy();
#end

FlxG.signals.preStateSwitch.dispatch();

#if FLX_RECORD
FlxRandom.updateStateSeed();
#end

// Destroy the old state (if there is an old state)
if (_state != null)
_state.destroy();

// we need to clear bitmap cache only after previous state is destroyed, which will reset useCount for FlxGraphic objects
FlxG.bitmap.clearCache();
if(_nextState == null) throw('Switch state called with a null state?');

// Finally assign and create the new state
_state = _nextState.createInstance();
_state._constructor = _nextState;
_nextState = null;

if (_gameJustStarted)
FlxG.signals.preGameStart.dispatch();

FlxG.signals.preStateCreate.dispatch(_state);

_state.create();

if (_gameJustStarted)
gameStart();

#if FLX_DEBUG
debugger.console.registerObject("state", _state);
#end

FlxG.signals.postStateSwitch.dispatch();
}catch(e){
FuckState.FUCK(e,"FlxGame.SwitchState");
}
SEProfiler.qStamp('switch_state');
}
override function update(){

try{
SEProfiler.start('update');

#if(target.threaded && !hl)
// if(_state != _requestedState && SESave.data.doCoolLoading){
// blockUpdate = blockEnterFrame = blockDraw = true;
// Main.funniSprite.removeChild(this);
// _oldAutoPause = FlxG.autoPause;
// FlxG.autoPause = false;
// visible = false;
// hasUpdated = false;
// sys.thread.Thread.create(() -> {
// switchState();
// requestAdd = true;
// visible = true;
// });
// return;
// }
if(_state != _requestedState && _requestedState != null && SESave.data.doCoolLoading){
blockUpdate = blockEnterFrame = blockDraw = true;
Main.funniSprite.removeChild(this);
_oldAutoPause = FlxG.autoPause;
FlxG.autoPause = false;
visible = false;
hasUpdated = false;
sys.thread.Thread.create(() -> {
switchState();
requestAdd = true;
visible = true;
});
return;
}
#end
if(blockUpdate) _update(); else {
hasUpdated = true;
Expand Down
2 changes: 1 addition & 1 deletion source/OptionsMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class OptionsMenu extends MusicBeatState
// new HCBoolOption("Cache Modded Songs list", "Toggle whether the song list entirely reloads every time it's opened",'cacheMultiList'),
new HCBoolOption("Threaded loading screen","Makes the loading screen use threads and show loading progress but is buggy and can cause crashes","doCoolLoading"),
new HCBoolOption("Pause screen transparency","Toggle the pause screen using transparency. Can help with lag on some machines","transparentPause"),
new HCBoolOption("Hard Drive Mode","Changes some loading routines to work better with slower drives.\nMay increase ram usage, disable stuff like pack asset replacing and/or disable hot reloading","HDDMode"),
new HCBoolOption("Hard Drive Mode","Changes some loading routines to work better with slower drives.\nMay increase ram usage, disables stuff like pack asset replacing and disables hot reloading","HDDMode"),

// new HCBoolOption("Doesn't destroy the opponent when you exit a song. Makes loading quicker but uses more ram and might cause issues","Persistant Opponent","persistOpp"),
// new UnloadSongOption("Unload the song when exiting the game"),
Expand Down
4 changes: 2 additions & 2 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ class PlayState extends ScriptMusicBeatState
loadBaseStage();
} default:{
stage = TitleState.retStage(stage);
if(stage == "nothing"){
if(stage == "nothing" || stage == "empty"){
defaultCamZoom = 0.9;
stageObject = new Stage();
stageObject.tags = ["empty"];
Expand Down Expand Up @@ -883,7 +883,7 @@ class PlayState extends ScriptMusicBeatState

// if(dad == null || !SESave.data.persistOpp || (!(dadShow || SESave.data.dadShow) && !Std.isOfType(dad,EmptyCharacter)) || dad.getNamespacedName() != player2){

dad = (player2 == "gf" || player2 == gf.curChar || player2CharInfo.id == gf.curCharacter) ? gf
dad = (player2 == "gf" || player2 == gf.curCharacter || player2CharInfo.id == gf.curCharacter) ? gf
: _dadShow ? {x:100, y:100, charInfo:player2CharInfo,isPlayer:false,charType:1}
: new EmptyCharacter(100, 100);
dad.playAnim("songStart");
Expand Down
1 change: 1 addition & 0 deletions source/SELoader.hx
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class SELoader {
return BitmapData.fromFile(pngPath);
}


public static function loadSparrowFrames(pngPath:String,?cache:Bool=false):FlxAtlasFrames{
pngPath = getPath(pngPath);
if(!exists('${pngPath}.png')){
Expand Down
2 changes: 1 addition & 1 deletion version.downloadMe
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
24.07.15.0004;
24.07.17.0300;
* Better Psych character support(Still kinda experimental but should be more stable)
* Fix some small errors
* Fix characters not loading due to using ID instead of folderName
Expand Down

0 comments on commit e288200

Please sign in to comment.