TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ LoadMigratableWorlds()

void Terraria.GameContent.UI.States.UIWorldSelect.LoadMigratableWorlds ( )
inlineprivate

Definition at line 386 of file UIWorldSelect.cs.

387 {
390 UIText playerMigrationPanelTitle = new UIText(Language.GetTextValue("tModLoader.MigrateIndividualWorldsHeader"));
391 playerMigrationPanelTitle.Top.Set(4f, 0f);
394 migrateWorldList.Width.Set(-22f, 1f);
395 migrateWorldList.Left.Set(0f, 0f);
396 migrateWorldList.Top.Set(30f, 0f);
397 migrateWorldList.MinHeight.Set(300f, 0f);
398 migrateWorldList.ListPadding = 5f;
399 _migrationPanel.VisibleWhenExpanded.Add(migrateWorldList);
401 scrollbar.SetView(100f, 1000f);
402 scrollbar.Height.Set(-42f, 1f);
403 scrollbar.Top.Set(36f, 0f);
404 scrollbar.Left.Pixels -= 0f;
405 scrollbar.HAlign = 1f;
406 migrateWorldList.SetScrollbar(scrollbar);
407 _migrationPanel.VisibleWhenExpanded.Add(scrollbar);
408 (string, string, int)[] otherPaths = FileUtilities.GetAlternateSavePathFiles("Worlds");
409 int currentStabilityLevel = BuildInfo.Purpose switch
410 {
411 BuildInfo.BuildPurpose.Stable => 1,
412 BuildInfo.BuildPurpose.Preview => 2,
413 _ => 3,
414 };
415 (string, string, int)[] array = otherPaths;
416 for (int j = 0; j < array.Length; j++)
417 {
418 var (otherSaveFolderPath, message, stabilityLevel) = array[j];
420 {
421 continue;
422 }
423 string[] files = Directory.GetFiles(otherSaveFolderPath, "*.wld");
424 int num2 = Math.Min(1000, files.Length);
425 for (int i = 0; i < num2; i++)
426 {
427 string worldInThisWorldsPath = Path.Combine(Main.WorldPath, Path.GetFileName(files[i]));
428 if (File.Exists(worldInThisWorldsPath) && File.GetLastWriteTime(worldInThisWorldsPath) == File.GetLastWriteTime(files[i]))
429 {
430 continue;
431 }
433 if (fileData == null)
434 {
435 continue;
436 }
438 migrateIndividualWorldPanel.Width.Set(0f, 1f);
439 migrateIndividualWorldPanel.Height.Set(50f, 0f);
440 float left = 0f;
442 {
443 UIHoverImage warningImage2 = new UIHoverImage(UICommon.ButtonErrorTexture, Language.GetTextValue("tModLoader.WorldFromNewerTModMightNotWork"))
444 {
445 Left =
446 {
447 Pixels = left
448 },
449 Top =
450 {
451 Pixels = 3f
452 }
453 };
455 left += warningImage2.Width.Pixels + 6f;
456 }
457 WorldFileData worldWithSameName = Main.WorldList.FirstOrDefault((WorldFileData x) => x.Name == fileData.Name);
458 if (worldWithSameName != null)
459 {
460 UIHoverImage warningImage = new UIHoverImage(UICommon.ButtonExclamationTexture, Language.GetTextValue("tModLoader.WorldWithThisNameExistsWillBeOverwritten"))
461 {
462 Left =
463 {
464 Pixels = left
465 },
466 Top =
467 {
468 Pixels = 3f
469 }
470 };
472 left += warningImage.Width.Pixels + 6f;
473 if (File.GetLastWriteTime(worldWithSameName.Path) > File.GetLastWriteTime(files[i]))
474 {
475 warningImage = new UIHoverImage(UICommon.ButtonExclamationTexture, Language.GetTextValue("tModLoader.ExistingWorldPlayedMoreRecently"))
476 {
477 Left =
478 {
479 Pixels = left
480 },
481 Top =
482 {
483 Pixels = 3f
484 }
485 };
487 left += warningImage.Width.Pixels + 6f;
488 }
489 }
490 UIText migrateIndividualWorldText = new UIText(string.Format(message, fileData.Name));
491 migrateIndividualWorldText.Width.Set(0f - left, 1f);
492 migrateIndividualWorldText.Left.Set(left, 0f);
493 migrateIndividualWorldText.Height.Set(0f, 1f);
494 migrateIndividualWorldText.OnLeftClick += delegate
495 {
497 {
499 migrateIndividualWorldText.SetText(Language.GetText("tModLoader.MigratingWorldsText"));
500 Task.Factory.StartNew(delegate
501 {
503 }, TaskCreationOptions.PreferFairness);
504 }
505 };
508 }
509 }
510 }
virtual void Add(UIElement item)
Definition UIList.cs:106
static void ExecuteIndividualWorldMigration(WorldFileData fileData, string otherSaveFolderPath)
static WorldFileData GetAllMetadata(string file, bool cloudSave)
Definition WorldFile.cs:246
static LocalizedText GetText(string key)
Retrieves a LocalizedText object for a specified localization key. The actual text value can be retri...
Definition Language.cs:25
static string GetTextValue(string key)
Retrieves the text value for a specified localization key. The text returned will be for the currentl...
Definition Language.cs:35
Contains methods to access or retrieve localization values. The Localization Guideteaches more about ...
Definition Language.cs:12
static Asset< Texture2D > ButtonErrorTexture
Definition UICommon.cs:28
static Asset< Texture2D > ButtonExclamationTexture
Definition UICommon.cs:42
StyleDimension Left
Definition UIElement.cs:25
StyleDimension Top
Definition UIElement.cs:23
static string string int stabilityLevel[] GetAlternateSavePathFiles(string folderName)

References Terraria.GameContent.UI.States.UIWorldSelect._currentlyMigratingFiles, Terraria.GameContent.UI.States.UIWorldSelect._migrationPanel, Terraria.GameContent.UI.States.UIWorldSelect._worldList, Terraria.GameContent.UI.Elements.UIList.Add(), Terraria.ModLoader.UI.UICommon.ButtonErrorTexture, Terraria.ModLoader.UI.UICommon.ButtonExclamationTexture, Terraria.GameContent.UI.States.UIWorldSelect.ExecuteIndividualWorldMigration(), Terraria.IO.WorldFile.GetAllMetadata(), Terraria.Utilities.FileUtilities.GetAlternateSavePathFiles(), Terraria.Localization.Language.GetText(), Terraria.Localization.Language.GetTextValue(), Terraria.UI.UIElement.Left, Terraria.IO.FileData.Name, Terraria.UI.UIElement.Top, Terraria.Main.WorldList, and Terraria.Main.WorldPath.

Referenced by Terraria.GameContent.UI.States.UIWorldSelect.OnActivate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: