v1.3.0: removed the unneeded separate thread for loading in WndRanking

This commit is contained in:
Evan Debenham
2022-06-29 13:03:52 -04:00
parent 77711aba5d
commit 3e13dee370
@@ -65,67 +65,43 @@ public class WndRanking extends WndTabbed {
private static final int WIDTH = 115; private static final int WIDTH = 115;
private static final int HEIGHT = 144; private static final int HEIGHT = 144;
private static Thread thread; private static WndRanking INSTANCE;
private String error = null;
private Image busy; private String gameID;
private Rankings.Record record;
public WndRanking( final Rankings.Record rec ) { public WndRanking( final Rankings.Record rec ) {
super(); super();
resize( WIDTH, HEIGHT ); resize( WIDTH, HEIGHT );
if (thread != null){ if (INSTANCE != null){
hide(); INSTANCE.hide();
return;
} }
INSTANCE = this;
this.gameID = rec.gameID;
this.record = rec;
thread = new Thread() {
@Override
public void run() {
try { try {
Badges.loadGlobal(); Badges.loadGlobal();
Rankings.INSTANCE.loadGameData( rec ); Rankings.INSTANCE.loadGameData( rec );
} catch ( Exception e ) {
error = Messages.get(WndRanking.class, "error");
}
}
};
busy = Icons.BUSY.get();
busy.origin.set( busy.width / 2, busy.height / 2 );
busy.angularSpeed = 720;
busy.x = (WIDTH - busy.width) / 2;
busy.y = (HEIGHT - busy.height) / 2;
add( busy );
thread.start();
}
@Override
public void update() {
super.update();
if (thread != null && !thread.isAlive() && busy != null) {
if (error == null) {
remove( busy );
busy = null;
if (Dungeon.hero != null) { if (Dungeon.hero != null) {
createControls(); createControls();
} else { } else {
hide(); hide();
} }
} else { } catch ( Exception e ) {
hide(); Game.scene().add( new WndError( Messages.get(WndRanking.class, "error" )));
Game.scene().add( new WndError( error ) );
}
} }
} }
@Override @Override
public void destroy() { public void destroy() {
super.destroy(); super.destroy();
thread = null; if (INSTANCE == this){
INSTANCE = null;
}
} }
private void createControls() { private void createControls() {