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

◆ LoadMigratablePlayers()

void Terraria.GameContent.UI.States.UICharacterSelect.LoadMigratablePlayers ( )
inlineprivate

Definition at line 378 of file UICharacterSelect.cs.

379 {
381 UIText playerMigrationPanelTitle = new UIText(Language.GetTextValue("tModLoader.MigrateIndividualPlayersHeader"));
382 playerMigrationPanelTitle.Top.Set(4f, 0f);
385 migratePlayerList.Width.Set(-22f, 1f);
386 migratePlayerList.Left.Set(0f, 0f);
387 migratePlayerList.Top.Set(30f, 0f);
388 migratePlayerList.MinHeight.Set(300f, 0f);
389 migratePlayerList.ListPadding = 5f;
390 _migrationPanel.VisibleWhenExpanded.Add(migratePlayerList);
392 scrollbar.SetView(100f, 1000f);
393 scrollbar.Height.Set(-42f, 1f);
394 scrollbar.Top.Set(36f, 0f);
395 scrollbar.Left.Pixels -= 0f;
396 scrollbar.HAlign = 1f;
397 migratePlayerList.SetScrollbar(scrollbar);
398 _migrationPanel.VisibleWhenExpanded.Add(scrollbar);
399 (string, string, int)[] otherPaths = FileUtilities.GetAlternateSavePathFiles("Players");
400 int currentStabilityLevel = BuildInfo.Purpose switch
401 {
402 BuildInfo.BuildPurpose.Stable => 1,
403 BuildInfo.BuildPurpose.Preview => 2,
404 _ => 3,
405 };
406 (string, string, int)[] array = otherPaths;
407 for (int j = 0; j < array.Length; j++)
408 {
409 var (otherSaveFolderPath, message, stabilityLevel) = array[j];
411 {
412 continue;
413 }
414 string[] files = Directory.GetFiles(otherSaveFolderPath, "*.plr");
415 int num2 = Math.Min(1000, files.Length);
416 for (int i = 0; i < num2; i++)
417 {
418 string playerInThisPlayersPath = Path.Combine(Main.PlayerPath, Path.GetFileName(files[i]));
419 if (File.Exists(playerInThisPlayersPath) && File.GetLastWriteTime(playerInThisPlayersPath) == File.GetLastWriteTime(files[i]))
420 {
421 continue;
422 }
423 PlayerFileData fileData = Player.GetFileData(files[i], cloudSave: false);
424 if (fileData == null)
425 {
426 continue;
427 }
429 migrateIndividualPlayerPanel.Width.Set(0f, 1f);
430 migrateIndividualPlayerPanel.Height.Set(50f, 0f);
431 float left = 0f;
433 {
434 UIHoverImage warningImage2 = new UIHoverImage(UICommon.ButtonErrorTexture, Language.GetTextValue("tModLoader.PlayerFromNewerTModMightNotWork"))
435 {
436 Left =
437 {
438 Pixels = left
439 },
440 Top =
441 {
442 Pixels = 3f
443 }
444 };
446 left += warningImage2.Width.Pixels + 6f;
447 }
448 PlayerFileData playerWithSameName = Main.PlayerList.FirstOrDefault((PlayerFileData x) => x.Name == fileData.Name);
449 if (playerWithSameName != null)
450 {
451 UIHoverImage warningImage = new UIHoverImage(UICommon.ButtonExclamationTexture, Language.GetTextValue("tModLoader.PlayerWithThisNameExistsWillBeOverwritten"))
452 {
453 Left =
454 {
455 Pixels = left
456 },
457 Top =
458 {
459 Pixels = 3f
460 }
461 };
463 left += warningImage.Width.Pixels + 6f;
464 if (File.GetLastWriteTime(playerWithSameName.Path) > File.GetLastWriteTime(files[i]))
465 {
466 warningImage = new UIHoverImage(UICommon.ButtonExclamationTexture, Language.GetTextValue("tModLoader.ExistingPlayerPlayedMoreRecently"))
467 {
468 Left =
469 {
470 Pixels = left
471 },
472 Top =
473 {
474 Pixels = 3f
475 }
476 };
478 left += warningImage.Width.Pixels + 6f;
479 }
480 }
481 UIText migrateIndividualPlayerText = new UIText(string.Format(message, fileData.Name));
482 migrateIndividualPlayerText.Width.Set(0f - left, 1f);
483 migrateIndividualPlayerText.Left.Set(left, 0f);
484 migrateIndividualPlayerText.Height.Set(0f, 1f);
485 migrateIndividualPlayerText.OnLeftClick += delegate
486 {
488 {
490 migrateIndividualPlayerText.SetText(Language.GetText("tModLoader.MigratingWorldsText"));
491 Task.Factory.StartNew(delegate
492 {
494 }, TaskCreationOptions.PreferFairness);
495 }
496 };
499 }
500 }
501 }
static void ExecuteIndividualPlayerMigration(PlayerFileData fileData, string otherSaveFolderPath)
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.UICharacterSelect._currentlyMigratingFiles, Terraria.GameContent.UI.States.UICharacterSelect._migrationPanel, Terraria.ModLoader.UI.UICommon.ButtonErrorTexture, Terraria.ModLoader.UI.UICommon.ButtonExclamationTexture, Terraria.GameContent.UI.States.UICharacterSelect.ExecuteIndividualPlayerMigration(), Terraria.Utilities.FileUtilities.GetAlternateSavePathFiles(), Terraria.Player.GetFileData(), Terraria.Localization.Language.GetText(), Terraria.Localization.Language.GetTextValue(), Terraria.UI.UIElement.Left, Terraria.IO.FileData.Name, Terraria.Main.PlayerList, Terraria.Main.PlayerPath, and Terraria.UI.UIElement.Top.

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

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