[#1579] Add command-line argument to bypass preset and motor loading at startup

This commit is contained in:
SiboVG 2024-09-06 11:31:16 +02:00
parent 0c0ae11fbc
commit 58d091998f
2 changed files with 30 additions and 7 deletions

View File

@ -42,6 +42,18 @@ public abstract class AsynchronousDatabaseLoader {
new LoadingThread().start(); new LoadingThread().start();
} }
/**
* Mark the database as loaded. This method is called by the loading thread when it has finished loading the database.
* You can also use this to bypass the database loading, but still mark it as loaded.
*/
public void markAsLoaded() {
synchronized (this) {
startedLoading = true;
endedLoading = true;
this.notifyAll();
}
}
/** /**
* @return whether loading the database has ended. * @return whether loading the database has ended.
*/ */
@ -95,10 +107,7 @@ public abstract class AsynchronousDatabaseLoader {
loadDatabase(); loadDatabase();
synchronized (this) { markAsLoaded();
endedLoading = true;
this.notifyAll();
}
} }
/** /**

View File

@ -58,7 +58,10 @@ public class GuiModule extends AbstractModule {
BlockingMotorDatabaseProvider motorDatabaseProvider = new BlockingMotorDatabaseProvider(motorLoader); BlockingMotorDatabaseProvider motorDatabaseProvider = new BlockingMotorDatabaseProvider(motorLoader);
bind(ThrustCurveMotorSetDatabase.class).toProvider(motorDatabaseProvider).in(Scopes.SINGLETON); bind(ThrustCurveMotorSetDatabase.class).toProvider(motorDatabaseProvider).in(Scopes.SINGLETON);
bind(MotorDatabase.class).toProvider(motorDatabaseProvider).in(Scopes.SINGLETON); bind(MotorDatabase.class).toProvider(motorDatabaseProvider).in(Scopes.SINGLETON);
if (System.getProperty("openrocket.debug") != null) {
}
} }
/** /**
@ -67,8 +70,19 @@ public class GuiModule extends AbstractModule {
* object's locator methods to return the correct objects. * object's locator methods to return the correct objects.
*/ */
public void startLoader() { public void startLoader() {
presetLoader.startLoading(); boolean bypassPresets = System.getProperty("openrocket.bypass.presets") != null;
motorLoader.startLoading(); boolean bypassMotors = System.getProperty("openrocket.bypass.motors") != null;
if (!bypassPresets) {
presetLoader.startLoading();
} else {
presetLoader.markAsLoaded();
}
if (!bypassMotors) {
motorLoader.startLoading();
} else {
motorLoader.markAsLoaded();
}
} }
} }