@@ -20,8 +20,6 @@ public class ModuleManager : MonoBehaviour |
20 | 20 |
|
21 | 21 | private bool inRnDCenter; |
22 | 22 |
|
23 | | - private bool reloading; |
24 | | - |
25 | 23 | public bool showUI = false; |
26 | 24 |
|
27 | 25 | private Rect windowPos = new Rect(80f, 60f, 240f, 40f); |
@@ -296,19 +294,6 @@ internal void Update() |
296 | 294 | errors.transform.localPosition = new Vector3(0, offsetY); |
297 | 295 | } |
298 | 296 | } |
299 | | - |
300 | | - if (reloading) |
301 | | - { |
302 | | - float percent = 0; |
303 | | - if (!GameDatabase.Instance.IsReady()) |
304 | | - percent = GameDatabase.Instance.ProgressFraction(); |
305 | | - else if (!PartLoader.Instance.IsReady()) |
306 | | - percent = 2f + PartLoader.Instance.ProgressFraction(); |
307 | | - |
308 | | - int intPercent = Mathf.CeilToInt(percent * 100f / 3f); |
309 | | - ScreenMessages.PostScreenMessage("Database reloading " + intPercent + "%", Time.deltaTime, |
310 | | - ScreenMessageStyle.UPPER_CENTER); |
311 | | - } |
312 | 297 | } |
313 | 298 |
|
314 | 299 | #region GUI stuff. |
@@ -323,20 +308,83 @@ public static bool IsABadIdea() |
323 | 308 |
|
324 | 309 | private IEnumerator DataBaseReloadWithMM(bool dump = false) |
325 | 310 | { |
326 | | - reloading = true; |
327 | | - |
328 | 311 | QualitySettings.vSyncCount = 0; |
329 | 312 | Application.targetFrameRate = -1; |
330 | 313 |
|
331 | | - ScreenMessages.PostScreenMessage("Database reloading started", 1, ScreenMessageStyle.UPPER_CENTER); |
| 314 | + patchRunner = new MMPatchRunner(new ModLogger("ModuleManager", new UnityLogger(Debug.unityLogger))); |
| 315 | + |
| 316 | + float totalLoadWeight = GameDatabase.Instance.LoadWeight() + PartLoader.Instance.LoadWeight(); |
| 317 | + bool startedReload = false; |
| 318 | + |
| 319 | + UISkinDef skinDef = HighLogic.UISkin; |
| 320 | + UIStyle centeredTextStyle = new UIStyle(skinDef.label) |
| 321 | + { |
| 322 | + alignment = TextAnchor.UpperCenter |
| 323 | + }; |
| 324 | + |
| 325 | + PopupDialog reloadingDialog = PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), |
| 326 | + new Vector2(0.5f, 0.5f), |
| 327 | + new MultiOptionDialog( |
| 328 | + "ModuleManagerReloading", |
| 329 | + "", |
| 330 | + "ModuleManager - Reloading Database", |
| 331 | + skinDef, |
| 332 | + new Rect(0.5f, 0.5f, 600f, 60f), |
| 333 | + new DialogGUIFlexibleSpace(), |
| 334 | + new DialogGUIVerticalLayout( |
| 335 | + new DialogGUIFlexibleSpace(), |
| 336 | + new DialogGUILabel(delegate () |
| 337 | + { |
| 338 | + float progressFraction; |
| 339 | + if (!startedReload) |
| 340 | + { |
| 341 | + progressFraction = 0f; |
| 342 | + } |
| 343 | + else if (!GameDatabase.Instance.IsReady()) |
| 344 | + { |
| 345 | + progressFraction = GameDatabase.Instance.ProgressFraction() * GameDatabase.Instance.LoadWeight(); |
| 346 | + progressFraction /= totalLoadWeight; |
| 347 | + } |
| 348 | + else if (!PartLoader.Instance.IsReady()) |
| 349 | + { |
| 350 | + progressFraction = GameDatabase.Instance.LoadWeight() + (PartLoader.Instance.ProgressFraction() * GameDatabase.Instance.LoadWeight()); |
| 351 | + progressFraction /= totalLoadWeight; |
| 352 | + } |
| 353 | + else |
| 354 | + { |
| 355 | + progressFraction = 1f; |
| 356 | + } |
| 357 | + |
| 358 | + return $"Overall progress: {progressFraction:P0}"; |
| 359 | + }, centeredTextStyle, expandW: true), |
| 360 | + new DialogGUILabel(delegate () |
| 361 | + { |
| 362 | + if (!startedReload) |
| 363 | + return "Starting"; |
| 364 | + else if (!GameDatabase.Instance.IsReady()) |
| 365 | + return GameDatabase.Instance.ProgressTitle(); |
| 366 | + else if (!PostPatchLoader.Instance.IsReady()) |
| 367 | + return PostPatchLoader.Instance.ProgressTitle(); |
| 368 | + else if (!PartLoader.Instance.IsReady()) |
| 369 | + return PartLoader.Instance.ProgressTitle(); |
| 370 | + else |
| 371 | + return ""; |
| 372 | + }), |
| 373 | + new DialogGUISpace(5f), |
| 374 | + new DialogGUILabel(() => patchRunner.Status) |
| 375 | + ) |
| 376 | + ), |
| 377 | + false, |
| 378 | + skinDef); |
| 379 | + |
332 | 380 | yield return null; |
333 | 381 |
|
334 | 382 | GameDatabase.Instance.Recompile = true; |
335 | 383 | GameDatabase.Instance.StartLoad(); |
336 | 384 |
|
337 | | - yield return null; |
| 385 | + startedReload = true; |
338 | 386 |
|
339 | | - patchRunner = new MMPatchRunner(new ModLogger("ModuleManager", new UnityLogger(Debug.unityLogger))); |
| 387 | + yield return null; |
340 | 388 | StartCoroutine(patchRunner.Run()); |
341 | 389 |
|
342 | 390 | // wait for it to finish |
@@ -372,8 +420,8 @@ private IEnumerator DataBaseReloadWithMM(bool dump = false) |
372 | 420 |
|
373 | 421 | QualitySettings.vSyncCount = GameSettings.SYNC_VBL; |
374 | 422 | Application.targetFrameRate = GameSettings.FRAMERATE_LIMIT; |
375 | | - reloading = false; |
376 | | - ScreenMessages.PostScreenMessage("Database reloading finished", 1, ScreenMessageStyle.UPPER_CENTER); |
| 423 | + |
| 424 | + reloadingDialog.Dismiss(); |
377 | 425 | } |
378 | 426 |
|
379 | 427 | public static void OutputAllConfigs() |
|