@@ -62,6 +62,8 @@ public class Stage1Loader extends LoaderBase {
62
62
private Class <?> oneconfigMainClass ;
63
63
private Object oneconfigMainInstance ;
64
64
65
+ private LoaderFrame loaderFrame = null ;
66
+
65
67
public Stage1Loader (Capabilities capabilities ) {
66
68
super (
67
69
"stage1" ,
@@ -80,16 +82,14 @@ public void load() {
80
82
String targetSpecifier = gameMetadata .getTargetSpecifier ();
81
83
log .info ("Target specifier: {}" , targetSpecifier );
82
84
83
- log .info ("Creating UI" );
84
- LoaderFrame loaderFrame = new LoaderFrame ();
85
- loaderFrame .display ();
86
-
87
- checkForUpdates (loaderFrame );
88
- maybeDownloadRelaunch (loaderFrame );
89
- downloadOneConfigArtifacts (loaderFrame );
85
+ checkForUpdates ();
86
+ maybeDownloadRelaunch ();
87
+ downloadOneConfigArtifacts ();
90
88
91
89
// Close our updater window, we're done
92
- loaderFrame .destroy ();
90
+ if (this .loaderFrame != null ) {
91
+ this .loaderFrame .destroy ();
92
+ }
93
93
94
94
try {
95
95
ClassLoader classLoader = runtimeAccess .getClassLoader ();
@@ -119,7 +119,7 @@ public void postLoad() {
119
119
}
120
120
}
121
121
122
- private void checkForUpdates (LoaderFrame loaderFrame ) {
122
+ private void checkForUpdates () {
123
123
if (isUpdateChecked ) {
124
124
return ;
125
125
}
@@ -141,6 +141,7 @@ private void checkForUpdates(LoaderFrame loaderFrame) {
141
141
Path selfFile = dataDir .resolve ("stage1.jar" );
142
142
143
143
if (!stage1Artifact .checksum .isMatching (selfFile )) {
144
+ requestLoaderFrame ();
144
145
loaderFrame .updateMessage ("Downloading OneConfig Loader stage 1..." );
145
146
stage1Artifact .downloadTo (getRequestHelper (), dataDir .resolve ("stage1.update.jar" ), loaderFrame ::updateProgress );
146
147
@@ -151,7 +152,7 @@ private void checkForUpdates(LoaderFrame loaderFrame) {
151
152
}
152
153
153
154
@ SneakyThrows
154
- private void maybeDownloadRelaunch (LoaderFrame loaderFrame ) {
155
+ private void maybeDownloadRelaunch () {
155
156
if (isRelaunchDownloaded ) {
156
157
return ;
157
158
}
@@ -176,6 +177,7 @@ private void maybeDownloadRelaunch(LoaderFrame loaderFrame) {
176
177
Path relaunchFile = dataDir .resolve ("relaunch.jar" );
177
178
178
179
if (!Files .exists (relaunchFile ) || !relaunchArtifact .checksum .isMatching (relaunchFile )) {
180
+ requestLoaderFrame ();
179
181
loaderFrame .updateMessage ("Downloading OneConfig Loader Relaunch..." );
180
182
relaunchArtifact .downloadTo (getRequestHelper (), relaunchFile , loaderFrame ::updateProgress );
181
183
}
@@ -185,7 +187,7 @@ private void maybeDownloadRelaunch(LoaderFrame loaderFrame) {
185
187
}
186
188
187
189
@ SneakyThrows
188
- private void downloadOneConfigArtifacts (LoaderFrame loaderFrame ) {
190
+ private void downloadOneConfigArtifacts () {
189
191
if (isOneConfigDownloaded ) {
190
192
return ;
191
193
}
@@ -232,6 +234,7 @@ private void downloadOneConfigArtifacts(LoaderFrame loaderFrame) {
232
234
for (BackendArtifact artifact : artifacts ) {
233
235
Path artifactFile = dataDir .resolve (artifact .name + ".jar" );
234
236
if (!Files .exists (artifactFile ) || !artifact .checksum .isMatching (artifactFile )) {
237
+ requestLoaderFrame ();
235
238
loaderFrame .updateMessage ("Downloading OneConfig artifact: " + artifact .name );
236
239
artifact .downloadTo (getRequestHelper (), artifactFile , loaderFrame ::updateProgress );
237
240
}
@@ -283,6 +286,14 @@ private void downloadOneConfigArtifacts(LoaderFrame loaderFrame) {
283
286
isOneConfigDownloaded = true ;
284
287
}
285
288
289
+ private void requestLoaderFrame () {
290
+ if (this .loaderFrame == null ) {
291
+ log .info ("Creating UI" );
292
+ loaderFrame = new LoaderFrame ();
293
+ loaderFrame .display ();
294
+ }
295
+ }
296
+
286
297
@ SneakyThrows
287
298
private BackendArtifact readArtifactAt (String url ) {
288
299
URLConnection connection = getRequestHelper ().establishConnection (URI .create (url ).toURL ());
0 commit comments