//////////////// public void ClearAllWorlds() { if (ResetModeMod.Instance.Config.DebugModeInfo) { LogHelpers.Alert("Deletes all world files, Sets PlayersValidated.Clear(), CurrentSessionedWorldId=\"\", AwaitingNextWorld=true"); } try { Main.LoadWorlds(); while (Main.WorldList.Count > 0) { WorldFileData worldData = Main.WorldList[0]; WorldFileHelpers.EraseWorld(worldData, false); } this.Data.PlayersValidated.Clear(); this.Data.CurrentSessionedWorldId = ""; this.Data.AwaitingNextWorld = true; if (Main.netMode != 1) { this.Save(); } } catch (Exception e) { LogHelpers.Warn(e.ToString()); } }
private bool CanWorldBePlayed(WorldFileData file) { bool num = Main.ActivePlayerFileData.Player.difficulty == 3; bool flag = file.GameMode == 3; return(num == flag); }
public void getWorld(StreamWriter sw) { try { SerializedWorld world = new SerializedWorld(); WorldFileData currentWorld = Main.ActiveWorldFileData; world.name = currentWorld.Name; world.creationTime = currentWorld.CreationTime; world.hardmode = currentWorld.IsHardMode; world.evilBiome = currentWorld.HasCorruption ? "corruption" : "crimson"; world.size = currentWorld.WorldSizeName; world.seed = currentWorld.Seed; world.expert = currentWorld.IsExpertMode; sw.WriteLine(JsonConvert.SerializeObject(world)); } catch (NullReferenceException _) { SerializedError serializedError = new SerializedError(500, "World isn't started yet on the server."); sw.WriteLine(JsonConvert.SerializeObject(serializedError)); } catch (Exception e) { SerializedError serializedError = new SerializedError(500, e.Message); sw.WriteLine(JsonConvert.SerializeObject(serializedError)); } }
/*public static void EraseWorld_WIN( int which ) { * WorldFileData data = Main.WorldList[which]; * * try { * if( !data.IsCloudSave ) { * FileOperationAPIWrapper.MoveToRecycleBin( data.Path ); * FileOperationAPIWrapper.MoveToRecycleBin( data + ".bak"); * } else if( SocialAPI.Cloud != null ) { * SocialAPI.Cloud.Delete( data.Path ); * } * * string tpath = Path.ChangeExtension( data.Path, ".twld" ); * * if( !data.IsCloudSave ) { * FileOperationAPIWrapper.MoveToRecycleBin( tPath ); * FileOperationAPIWrapper.MoveToRecycleBin( tPath + ".bak" ); * } else if( SocialAPI.Cloud != null ) { * SocialAPI.Cloud.Delete( tPath ); * } * } catch { } * * Main.LoadWorlds(); * }*/ /// <summary> /// Deletes a given world file. Use with care. /// </summary> /// <param name="data"></param> /// <param name="alsoBak"></param> public static void EraseWorld(WorldFileData data, bool alsoBak = true) { try { if (!data.IsCloudSave) { File.Delete(data.Path); if (alsoBak) { File.Delete(data.Path + ".bak"); } } else if (SocialAPI.Cloud != null) { SocialAPI.Cloud.Delete(data.Path); } string tPath = Path.ChangeExtension(data.Path, ".twld"); if (!data.IsCloudSave) { File.Delete(tPath); if (alsoBak) { File.Delete(tPath + ".bak"); } } else if (SocialAPI.Cloud != null) { SocialAPI.Cloud.Delete(tPath); } LogLibraries.Log("WorldFileLibraries.EraseWorld - World \"" + data.Name + "\" deleted. (" + data.Path + ")"); } catch (Exception e) { LogLibraries.Log("WorldFileLibraries.EraseWorld - Error (path: " + data.Path + ") - " + e.ToString()); } Main.LoadWorlds(); }
public UIWorldListItem(WorldFileData data, int snapPointIndex) { this.BorderColor = new Color(89, 116, 213) * 0.7f; this._dividerTexture = TextureManager.Load("Images/UI/Divider"); this._innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); this._buttonCloudActiveTexture = TextureManager.Load("Images/UI/ButtonCloudActive"); this._buttonCloudInactiveTexture = TextureManager.Load("Images/UI/ButtonCloudInactive"); this._buttonFavoriteActiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteActive"); this._buttonFavoriteInactiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteInactive"); this._buttonPlayTexture = TextureManager.Load("Images/UI/ButtonPlay"); this._buttonSeedTexture = TextureManager.Load("Images/UI/ButtonSeed"); this._buttonDeleteTexture = TextureManager.Load("Images/UI/ButtonDelete"); this.Height.Set(96f, 0.0f); this.Width.Set(0.0f, 1f); this.SetPadding(6f); this._data = data; this._worldIcon = new UIImage(this.GetIcon()); this._worldIcon.Left.Set(4f, 0.0f); this._worldIcon.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame); this.Append((UIElement)this._worldIcon); float pixels1 = 4f; UIImageButton uiImageButton1 = new UIImageButton(this._buttonPlayTexture); uiImageButton1.VAlign = 1f; uiImageButton1.Left.Set(pixels1, 0.0f); uiImageButton1.OnClick += new UIElement.MouseEvent(this.PlayGame); this.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame); uiImageButton1.OnMouseOver += new UIElement.MouseEvent(this.PlayMouseOver); uiImageButton1.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut); this.Append((UIElement)uiImageButton1); float pixels2 = 28f; UIImageButton uiImageButton2 = new UIImageButton(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture); uiImageButton2.VAlign = 1f; uiImageButton2.Left.Set(pixels2, 0.0f); uiImageButton2.OnClick += new UIElement.MouseEvent(this.FavoriteButtonClick); uiImageButton2.OnMouseOver += new UIElement.MouseEvent(this.FavoriteMouseOver); uiImageButton2.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut); uiImageButton2.SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f); this.Append((UIElement)uiImageButton2); float pixels3 = pixels2 + 24f; if (SocialAPI.Cloud != null) { UIImageButton uiImageButton3 = new UIImageButton(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture); uiImageButton3.VAlign = 1f; uiImageButton3.Left.Set(pixels3, 0.0f); uiImageButton3.OnClick += new UIElement.MouseEvent(this.CloudButtonClick); uiImageButton3.OnMouseOver += new UIElement.MouseEvent(this.CloudMouseOver); uiImageButton3.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut); uiImageButton3.SetSnapPoint("Cloud", snapPointIndex, new Vector2?(), new Vector2?()); this.Append((UIElement)uiImageButton3); pixels3 += 24f; } if (Main.UseSeedUI && (long)this._data.WorldGeneratorVersion != 0L) { UIImageButton uiImageButton3 = new UIImageButton(this._buttonSeedTexture); uiImageButton3.VAlign = 1f; uiImageButton3.Left.Set(pixels3, 0.0f); uiImageButton3.OnClick += new UIElement.MouseEvent(this.SeedButtonClick); uiImageButton3.OnMouseOver += new UIElement.MouseEvent(this.SeedMouseOver); uiImageButton3.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut); uiImageButton3.SetSnapPoint("Seed", snapPointIndex, new Vector2?(), new Vector2?()); this.Append((UIElement)uiImageButton3); pixels3 += 24f; } UIImageButton uiImageButton4 = new UIImageButton(this._buttonDeleteTexture); uiImageButton4.VAlign = 1f; uiImageButton4.HAlign = 1f; uiImageButton4.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick); uiImageButton4.OnMouseOver += new UIElement.MouseEvent(this.DeleteMouseOver); uiImageButton4.OnMouseOut += new UIElement.MouseEvent(this.DeleteMouseOut); this._deleteButton = uiImageButton4; if (!this._data.IsFavorite) { this.Append((UIElement)uiImageButton4); } float pixels4 = pixels3 + 4f; this._buttonLabel = new UIText("", 1f, false); this._buttonLabel.VAlign = 1f; this._buttonLabel.Left.Set(pixels4, 0.0f); this._buttonLabel.Top.Set(-3f, 0.0f); this.Append((UIElement)this._buttonLabel); this._deleteButtonLabel = new UIText("", 1f, false); this._deleteButtonLabel.VAlign = 1f; this._deleteButtonLabel.HAlign = 1f; this._deleteButtonLabel.Left.Set(-30f, 0.0f); this._deleteButtonLabel.Top.Set(-3f, 0.0f); this.Append((UIElement)this._deleteButtonLabel); uiImageButton1.SetSnapPoint("Play", snapPointIndex, new Vector2?(), new Vector2?()); uiImageButton2.SetSnapPoint("Favorite", snapPointIndex, new Vector2?(), new Vector2?()); uiImageButton4.SetSnapPoint("Delete", snapPointIndex, new Vector2?(), new Vector2?()); }
public UIWorldListItem(WorldFileData data, int snapPointIndex) { this._data = data; this.LoadTextures(); this.InitializeAppearance(); this._worldIcon = new UIImage(this.GetIcon()); this._worldIcon.Left.Set(4f, 0.0f); this._worldIcon.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame); this.Append((UIElement)this._worldIcon); float pixels1 = 4f; UIImageButton uiImageButton1 = new UIImageButton(this._buttonPlayTexture); uiImageButton1.VAlign = 1f; uiImageButton1.Left.Set(pixels1, 0.0f); uiImageButton1.OnClick += new UIElement.MouseEvent(this.PlayGame); this.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame); uiImageButton1.OnMouseOver += new UIElement.MouseEvent(this.PlayMouseOver); uiImageButton1.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut); this.Append((UIElement)uiImageButton1); float pixels2 = pixels1 + 24f; UIImageButton uiImageButton2 = new UIImageButton(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture); uiImageButton2.VAlign = 1f; uiImageButton2.Left.Set(pixels2, 0.0f); uiImageButton2.OnClick += new UIElement.MouseEvent(this.FavoriteButtonClick); uiImageButton2.OnMouseOver += new UIElement.MouseEvent(this.FavoriteMouseOver); uiImageButton2.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut); uiImageButton2.SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f); this.Append((UIElement)uiImageButton2); float pixels3 = pixels2 + 24f; if (SocialAPI.Cloud != null) { UIImageButton uiImageButton3 = new UIImageButton(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture); uiImageButton3.VAlign = 1f; uiImageButton3.Left.Set(pixels3, 0.0f); uiImageButton3.OnClick += new UIElement.MouseEvent(this.CloudButtonClick); uiImageButton3.OnMouseOver += new UIElement.MouseEvent(this.CloudMouseOver); uiImageButton3.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut); uiImageButton3.SetSnapPoint("Cloud", snapPointIndex, new Vector2?(), new Vector2?()); this.Append((UIElement)uiImageButton3); pixels3 += 24f; } if (Main.UseSeedUI && (long)this._data.WorldGeneratorVersion != 0L) { UIImageButton uiImageButton3 = new UIImageButton(this._buttonSeedTexture); uiImageButton3.VAlign = 1f; uiImageButton3.Left.Set(pixels3, 0.0f); uiImageButton3.OnClick += new UIElement.MouseEvent(this.SeedButtonClick); uiImageButton3.OnMouseOver += new UIElement.MouseEvent(this.SeedMouseOver); uiImageButton3.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut); uiImageButton3.SetSnapPoint("Seed", snapPointIndex, new Vector2?(), new Vector2?()); this.Append((UIElement)uiImageButton3); pixels3 += 24f; } UIImageButton uiImageButton4 = new UIImageButton(this._buttonDeleteTexture); uiImageButton4.VAlign = 1f; uiImageButton4.HAlign = 1f; uiImageButton4.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick); uiImageButton4.OnMouseOver += new UIElement.MouseEvent(this.DeleteMouseOver); uiImageButton4.OnMouseOut += new UIElement.MouseEvent(this.DeleteMouseOut); this._deleteButton = uiImageButton4; if (!this._data.IsFavorite) { this.Append((UIElement)uiImageButton4); } float pixels4 = pixels3 + 4f; this._buttonLabel = new UIText("", 1f, false); this._buttonLabel.VAlign = 1f; this._buttonLabel.Left.Set(pixels4, 0.0f); this._buttonLabel.Top.Set(-3f, 0.0f); this.Append((UIElement)this._buttonLabel); this._deleteButtonLabel = new UIText("", 1f, false); this._deleteButtonLabel.VAlign = 1f; this._deleteButtonLabel.HAlign = 1f; this._deleteButtonLabel.Left.Set(-30f, 0.0f); this._deleteButtonLabel.Top.Set(-3f, 0.0f); this.Append((UIElement)this._deleteButtonLabel); uiImageButton1.SetSnapPoint("Play", snapPointIndex, new Vector2?(), new Vector2?()); uiImageButton2.SetSnapPoint("Favorite", snapPointIndex, new Vector2?(), new Vector2?()); uiImageButton4.SetSnapPoint("Delete", snapPointIndex, new Vector2?(), new Vector2?()); }
public MyUIWorldListItem(WorldFileData data, bool mentalMode) { MentalMode = mentalMode; BorderColor = new Color(89, 116, 213) * 0.7f; _dividerTexture = TextureManager.Load("Images/UI/Divider"); _innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); _buttonCloudActiveTexture = TextureManager.Load("Images/UI/ButtonCloudActive"); _buttonCloudInactiveTexture = TextureManager.Load("Images/UI/ButtonCloudInactive"); _buttonFavoriteActiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteActive"); _buttonFavoriteInactiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteInactive"); _buttonPlayTexture = TextureManager.Load("Images/UI/ButtonPlay"); _buttonDeleteTexture = TextureManager.Load("Images/UI/ButtonDelete"); Height.Set(96f, 0f); Width.Set(0f, 1f); base.SetPadding(6f); _data = data; _worldIcon = new UIImage(GetIcon()); _worldIcon.Left.Set(4f, 0f); _worldIcon.OnDoubleClick += new UIElement.MouseEvent(PlayGame); base.Append(_worldIcon); UIImageButton uIImageButton = new UIImageButton(_buttonPlayTexture); uIImageButton.VAlign = 1f; uIImageButton.Left.Set(4f, 0f); uIImageButton.OnClick += new UIElement.MouseEvent(PlayGame); base.OnDoubleClick += new UIElement.MouseEvent(PlayGame); uIImageButton.OnMouseOver += new UIElement.MouseEvent(PlayMouseOver); uIImageButton.OnMouseOut += new UIElement.MouseEvent(ButtonMouseOut); base.Append(uIImageButton); UIImageButton uIImageButton2 = new UIImageButton(_data.IsFavorite ? _buttonFavoriteActiveTexture : _buttonFavoriteInactiveTexture); uIImageButton2.VAlign = 1f; uIImageButton2.Left.Set(28f, 0f); uIImageButton2.OnClick += new UIElement.MouseEvent(FavoriteButtonClick); uIImageButton2.OnMouseOver += new UIElement.MouseEvent(FavoriteMouseOver); uIImageButton2.OnMouseOut += new UIElement.MouseEvent(ButtonMouseOut); uIImageButton2.SetVisibility(1f, _data.IsFavorite ? 0.8f : 0.4f); base.Append(uIImageButton2); if (SocialAPI.Cloud != null) { UIImageButton uIImageButton3 = new UIImageButton(_data.IsCloudSave ? _buttonCloudActiveTexture : _buttonCloudInactiveTexture); uIImageButton3.VAlign = 1f; uIImageButton3.Left.Set(52f, 0f); uIImageButton3.OnClick += new UIElement.MouseEvent(CloudButtonClick); uIImageButton3.OnMouseOver += new UIElement.MouseEvent(CloudMouseOver); uIImageButton3.OnMouseOut += new UIElement.MouseEvent(ButtonMouseOut); base.Append(uIImageButton3); } UIImageButton uIImageButton4 = new UIImageButton(_buttonDeleteTexture); uIImageButton4.VAlign = 1f; uIImageButton4.HAlign = 1f; uIImageButton4.OnClick += new UIElement.MouseEvent(DeleteButtonClick); uIImageButton4.OnMouseOver += new UIElement.MouseEvent(DeleteMouseOver); uIImageButton4.OnMouseOut += new UIElement.MouseEvent(DeleteMouseOut); _deleteButton = uIImageButton4; if (!_data.IsFavorite) { base.Append(uIImageButton4); } _buttonLabel = new UIText("", 1f, false); _buttonLabel.VAlign = 1f; _buttonLabel.Left.Set(80f, 0f); _buttonLabel.Top.Set(-3f, 0f); base.Append(_buttonLabel); _deleteButtonLabel = new UIText("", 1f, false); _deleteButtonLabel.VAlign = 1f; _deleteButtonLabel.HAlign = 1f; _deleteButtonLabel.Left.Set(-30f, 0f); _deleteButtonLabel.Top.Set(-3f, 0f); base.Append(_deleteButtonLabel); }
private bool CanWorldBePlayed(WorldFileData file) { return(Main.ActivePlayerFileData.Player.difficulty == (byte)3 == (file.GameMode == 3)); }
public UIWorldListItem(WorldFileData data, int orderInList, bool canBePlayed) { _orderInList = orderInList; _data = data; _canBePlayed = canBePlayed; LoadTextures(); InitializeAppearance(); _worldIcon = new UIImage(GetIcon()); _worldIcon.Left.Set(4f, 0f); _worldIcon.OnDoubleClick += PlayGame; Append(_worldIcon); float num = 4f; UIImageButton uIImageButton = new UIImageButton(_buttonPlayTexture); uIImageButton.VAlign = 1f; uIImageButton.Left.Set(num, 0f); uIImageButton.OnClick += PlayGame; base.OnDoubleClick += PlayGame; uIImageButton.OnMouseOver += PlayMouseOver; uIImageButton.OnMouseOut += ButtonMouseOut; Append(uIImageButton); num += 24f; UIImageButton uIImageButton2 = new UIImageButton(_data.IsFavorite ? _buttonFavoriteActiveTexture : _buttonFavoriteInactiveTexture); uIImageButton2.VAlign = 1f; uIImageButton2.Left.Set(num, 0f); uIImageButton2.OnClick += FavoriteButtonClick; uIImageButton2.OnMouseOver += FavoriteMouseOver; uIImageButton2.OnMouseOut += ButtonMouseOut; uIImageButton2.SetVisibility(1f, _data.IsFavorite ? 0.8f : 0.4f); Append(uIImageButton2); num += 24f; if (SocialAPI.Cloud != null) { UIImageButton uIImageButton3 = new UIImageButton(_data.IsCloudSave ? _buttonCloudActiveTexture : _buttonCloudInactiveTexture); uIImageButton3.VAlign = 1f; uIImageButton3.Left.Set(num, 0f); uIImageButton3.OnClick += CloudButtonClick; uIImageButton3.OnMouseOver += CloudMouseOver; uIImageButton3.OnMouseOut += ButtonMouseOut; uIImageButton3.SetSnapPoint("Cloud", orderInList); Append(uIImageButton3); num += 24f; } if (Main.UseSeedUI && _data.WorldGeneratorVersion != 0L) { UIImageButton uIImageButton4 = new UIImageButton(_buttonSeedTexture); uIImageButton4.VAlign = 1f; uIImageButton4.Left.Set(num, 0f); uIImageButton4.OnClick += SeedButtonClick; uIImageButton4.OnMouseOver += SeedMouseOver; uIImageButton4.OnMouseOut += ButtonMouseOut; uIImageButton4.SetSnapPoint("Seed", orderInList); Append(uIImageButton4); num += 24f; } UIImageButton uIImageButton5 = new UIImageButton(_buttonDeleteTexture) { VAlign = 1f, HAlign = 1f }; if (!_data.IsFavorite) { uIImageButton5.OnClick += DeleteButtonClick; } uIImageButton5.OnMouseOver += DeleteMouseOver; uIImageButton5.OnMouseOut += DeleteMouseOut; _deleteButton = uIImageButton5; Append(uIImageButton5); num += 4f; _buttonLabel = new UIText(""); _buttonLabel.VAlign = 1f; _buttonLabel.Left.Set(num, 0f); _buttonLabel.Top.Set(-3f, 0f); Append(_buttonLabel); _deleteButtonLabel = new UIText(""); _deleteButtonLabel.VAlign = 1f; _deleteButtonLabel.HAlign = 1f; _deleteButtonLabel.Left.Set(-30f, 0f); _deleteButtonLabel.Top.Set(-3f, 0f); Append(_deleteButtonLabel); uIImageButton.SetSnapPoint("Play", orderInList); uIImageButton2.SetSnapPoint("Favorite", orderInList); uIImageButton5.SetSnapPoint("Delete", orderInList); }
// Token: 0x0600115C RID: 4444 RVA: 0x0040B5E0 File Offset: 0x004097E0 public UIWorldListItem(WorldFileData data, int snapPointIndex) { this._data = data; this.LoadTextures(); this.InitializeAppearance(); this._worldIcon = new UIImage(this.GetIcon()); this._worldIcon.Left.Set(4f, 0f); this._worldIcon.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame); base.Append(this._worldIcon); float num = 4f; UIImageButton uIImageButton = new UIImageButton(this._buttonPlayTexture); uIImageButton.VAlign = 1f; uIImageButton.Left.Set(num, 0f); uIImageButton.OnClick += new UIElement.MouseEvent(this.PlayGame); base.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame); uIImageButton.OnMouseOver += new UIElement.MouseEvent(this.PlayMouseOver); uIImageButton.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut); base.Append(uIImageButton); num += 24f; UIImageButton uIImageButton2 = new UIImageButton(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture); uIImageButton2.VAlign = 1f; uIImageButton2.Left.Set(num, 0f); uIImageButton2.OnClick += new UIElement.MouseEvent(this.FavoriteButtonClick); uIImageButton2.OnMouseOver += new UIElement.MouseEvent(this.FavoriteMouseOver); uIImageButton2.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut); uIImageButton2.SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f); base.Append(uIImageButton2); num += 24f; if (SocialAPI.Cloud != null) { UIImageButton uIImageButton3 = new UIImageButton(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture); uIImageButton3.VAlign = 1f; uIImageButton3.Left.Set(num, 0f); uIImageButton3.OnClick += new UIElement.MouseEvent(this.CloudButtonClick); uIImageButton3.OnMouseOver += new UIElement.MouseEvent(this.CloudMouseOver); uIImageButton3.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut); uIImageButton3.SetSnapPoint("Cloud", snapPointIndex, null, null); base.Append(uIImageButton3); num += 24f; } if (Main.UseSeedUI && this._data.WorldGeneratorVersion != 0uL) { UIImageButton uIImageButton4 = new UIImageButton(this._buttonSeedTexture); uIImageButton4.VAlign = 1f; uIImageButton4.Left.Set(num, 0f); uIImageButton4.OnClick += new UIElement.MouseEvent(this.SeedButtonClick); uIImageButton4.OnMouseOver += new UIElement.MouseEvent(this.SeedMouseOver); uIImageButton4.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut); uIImageButton4.SetSnapPoint("Seed", snapPointIndex, null, null); base.Append(uIImageButton4); num += 24f; } UIImageButton uIImageButton5 = new UIImageButton(this._buttonDeleteTexture); uIImageButton5.VAlign = 1f; uIImageButton5.HAlign = 1f; uIImageButton5.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick); uIImageButton5.OnMouseOver += new UIElement.MouseEvent(this.DeleteMouseOver); uIImageButton5.OnMouseOut += new UIElement.MouseEvent(this.DeleteMouseOut); this._deleteButton = uIImageButton5; if (!this._data.IsFavorite) { base.Append(uIImageButton5); } num += 4f; this._buttonLabel = new UIText("", 1f, false); this._buttonLabel.VAlign = 1f; this._buttonLabel.Left.Set(num, 0f); this._buttonLabel.Top.Set(-3f, 0f); base.Append(this._buttonLabel); this._deleteButtonLabel = new UIText("", 1f, false); this._deleteButtonLabel.VAlign = 1f; this._deleteButtonLabel.HAlign = 1f; this._deleteButtonLabel.Left.Set(-30f, 0f); this._deleteButtonLabel.Top.Set(-3f, 0f); base.Append(this._deleteButtonLabel); uIImageButton.SetSnapPoint("Play", snapPointIndex, null, null); uIImageButton2.SetSnapPoint("Favorite", snapPointIndex, null, null); uIImageButton5.SetSnapPoint("Delete", snapPointIndex, null, null); }
private static void ConstructorBlack(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_ctor orig, UIWorldListItem self, WorldFileData data, int snapPointIndex) { orig(self, data, snapPointIndex); if (File.Exists(Path.ChangeExtension(data.Path, ".fwim"))) { self.BackgroundColor = new Color(25, 25, 25); self.BorderColor = new Color(50, 50, 50); } }
public static void EraseWorld(int which, bool also_bak = true) { WorldFileData data = Main.WorldList[which]; WorldFileHelpers.EraseWorld(data, also_bak); }
private static void CtorModWorlData(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_ctor orig, UIWorldListItem self, WorldFileData data, int snapPointIndex) { orig(self, data, snapPointIndex); if (!SGAConfigClient.Instance.PlayerWorldData) { return; } string path = data.Path.Replace(".wld", ".twld"); TagCompound tag; try { byte[] buffer = FileUtilities.ReadAllBytes(path, data.IsCloudSave); tag = TagIO.FromStream(new MemoryStream(buffer), true); } catch { tag = null; } TagCompound tag2 = tag?.GetList <TagCompound>("modData").FirstOrDefault(testby => testby.GetString("mod") == "SGAmod" && testby.GetString("name") == "SGAWorld"); TagCompound tag3 = tag2?.Get <TagCompound>("data"); SGAmodData.Add(self, tag3); }
public UIWorldListItem(WorldFileData data) { BorderColor = new Color(89, 116, 213) * 0.7f; _dividerTexture = TextureManager.Load("Images/UI/Divider"); _innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); _buttonCloudActiveTexture = TextureManager.Load("Images/UI/ButtonCloudActive"); _buttonCloudInactiveTexture = TextureManager.Load("Images/UI/ButtonCloudInactive"); _buttonFavoriteActiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteActive"); _buttonFavoriteInactiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteInactive"); _buttonPlayTexture = TextureManager.Load("Images/UI/ButtonPlay"); _buttonDeleteTexture = TextureManager.Load("Images/UI/ButtonDelete"); Height.Set(96f, 0.0f); Width.Set(0.0f, 1f); SetPadding(6f); _data = data; _worldIcon = new UIImage(GetIcon()); _worldIcon.Left.Set(4f, 0.0f); _worldIcon.OnDoubleClick += new UIElement.MouseEvent(PlayGame); Append(_worldIcon); UIImageButton uiImageButton1 = new UIImageButton(_buttonPlayTexture); uiImageButton1.VAlign = 1f; uiImageButton1.Left.Set(4f, 0.0f); uiImageButton1.OnClick += new UIElement.MouseEvent(PlayGame); OnDoubleClick += new UIElement.MouseEvent(PlayGame); uiImageButton1.OnMouseOver += new UIElement.MouseEvent(PlayMouseOver); uiImageButton1.OnMouseOut += new UIElement.MouseEvent(ButtonMouseOut); Append(uiImageButton1); UIImageButton uiImageButton2 = new UIImageButton(_data.IsFavorite ? _buttonFavoriteActiveTexture : _buttonFavoriteInactiveTexture); uiImageButton2.VAlign = 1f; uiImageButton2.Left.Set(28f, 0.0f); uiImageButton2.OnClick += new UIElement.MouseEvent(FavoriteButtonClick); uiImageButton2.OnMouseOver += new UIElement.MouseEvent(FavoriteMouseOver); uiImageButton2.OnMouseOut += new UIElement.MouseEvent(ButtonMouseOut); uiImageButton2.SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f); Append(uiImageButton2); UIImageButton uiImageButton4 = new UIImageButton(_buttonDeleteTexture); uiImageButton4.VAlign = 1f; uiImageButton4.HAlign = 1f; uiImageButton4.OnClick += new UIElement.MouseEvent(DeleteButtonClick); uiImageButton4.OnMouseOver += new UIElement.MouseEvent(DeleteMouseOver); uiImageButton4.OnMouseOut += new UIElement.MouseEvent(DeleteMouseOut); _deleteButton = uiImageButton4; if (!_data.IsFavorite) { Append(uiImageButton4); } _buttonLabel = new UIText("", 1f, false); _buttonLabel.VAlign = 1f; _buttonLabel.Left.Set(80f, 0.0f); _buttonLabel.Top.Set(-3f, 0.0f); Append(_buttonLabel); _deleteButtonLabel = new UIText("", 1f, false); _deleteButtonLabel.VAlign = 1f; _deleteButtonLabel.HAlign = 1f; _deleteButtonLabel.Left.Set(-30f, 0.0f); _deleteButtonLabel.Top.Set(-3f, 0.0f); Append(_deleteButtonLabel); }
private void ProfessionalText(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_DrawSelf orig, Terraria.GameContent.UI.Elements.UIWorldListItem self, SpriteBatch spriteBatch) { orig(self, spriteBatch); FieldInfo dataInfo = self.GetType().GetField("_data", BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo worldIconInfo = self.GetType().GetField("_worldIcon", BindingFlags.NonPublic | BindingFlags.Instance); WorldFileData fileData = (WorldFileData)dataInfo.GetValue(self); UIImage worldIcon = (UIImage)worldIconInfo.GetValue(self); string filePath = fileData.Path.Replace(".wld", ".twld"); //remember .wld exists ahh TagCompound tagCompound1; try { byte[] bytes = FileUtilities.ReadAllBytes(filePath, fileData.IsCloudSave); tagCompound1 = TagIO.FromStream(new MemoryStream(bytes), true); } catch { tagCompound1 = null; } TagCompound tagCompound2 = tagCompound1?.GetList <TagCompound>("modData").FirstOrDefault(i => i.GetString("mod") == "SpectraMod" && i.GetString("name") == "SpectraWorld"); //allow null TagCompound tagCompound3 = tagCompound2?.Get <TagCompound>("data"); CalculatedStyle innerDimensions = self.GetInnerDimensions(); CalculatedStyle dimensions = worldIcon.GetDimensions(); float num7 = dimensions.X + dimensions.Width; Color color = fileData.IsValid ? Color.White : Color.Red; Utils.DrawBorderString(spriteBatch, fileData.Name, new Vector2(num7 + 6f, dimensions.Y - 2f), color); spriteBatch.Draw(TextureManager.Load("Images/UI/Divider"), new Vector2(num7, innerDimensions.Y + 21f), null, Color.White, 0f, Vector2.Zero, new Vector2((self.GetDimensions().X + self.GetDimensions().Width - num7) / 8f, 1f), SpriteEffects.None, 0f); Vector2 vector = new Vector2(num7 + 6f, innerDimensions.Y + 29f); float num6 = 100f; DrawPanel(spriteBatch, vector, num6); bool?IsProfessionalMode = tagCompound3?.GetBool("IsProfessionalMode"); if (IsProfessionalMode == null) { IsProfessionalMode = false; } string text; if ((bool)IsProfessionalMode) { text = "Professional"; } else if (fileData.IsExpertMode && (bool)!IsProfessionalMode) { text = Language.GetTextValue("UI.Expert"); } else { text = Language.GetTextValue("UI.Normal"); } float x11 = Main.fontMouseText.MeasureString(text).X; float x10 = num6 * 0.5f - x11 * 0.5f; if ((bool)IsProfessionalMode) { text = "Professional"; } else if (fileData.IsExpertMode && (bool)!IsProfessionalMode) { text = Language.GetTextValue("UI.Expert"); } else { text = Language.GetTextValue("UI.Normal"); } Color difficultyColor; if ((bool)IsProfessionalMode) { difficultyColor = new Color(255, 0, 0); } else if (fileData.IsExpertMode && (bool)!IsProfessionalMode) { difficultyColor = new Color(217, 143, 244); } else { difficultyColor = Color.White; } Utils.DrawBorderString(spriteBatch, text, vector + new Vector2(x10, 3f), difficultyColor); vector.X += num6 + 5f; float num5 = 150f; if (!GameCulture.English.IsActive) { num5 += 40f; } DrawPanel(spriteBatch, vector, num5); string textValue3 = Language.GetTextValue("UI.WorldSizeFormat", fileData.WorldSizeName); float x9 = Main.fontMouseText.MeasureString(textValue3).X; float x8 = num5 * 0.5f - x9 * 0.5f; Utils.DrawBorderString(spriteBatch, textValue3, vector + new Vector2(x8, 3f), Color.White); vector.X += num5 + 5f; float num4 = innerDimensions.X + innerDimensions.Width - vector.X; DrawPanel(spriteBatch, vector, num4); string arg = (!GameCulture.English.IsActive) ? fileData.CreationTime.ToShortDateString() : fileData.CreationTime.ToString("d MMMM yyyy"); string textValue2 = Language.GetTextValue("UI.WorldCreatedFormat", arg); float x7 = Main.fontMouseText.MeasureString(textValue2).X; float x6 = num4 * 0.5f - x7 * 0.5f; Utils.DrawBorderString(spriteBatch, textValue2, vector + new Vector2(x6, 3f), Color.White); vector.X += num4 + 5f; }
public void PutMeInAWorld() { var config = ModContent.GetInstance <Config>(); WorldGen.gen = true; WorldFileData temp = new WorldFileData(ModLoader.ModPath + "/TempWorld", false); temp.SetAsActive(); if (config.size == WorldSize.small) { temp.SetWorldSize(4200, 1200); Main.maxTilesX = 4200; Main.maxTilesY = 1200; Main.tile = new Tile[4200, 1200]; } if (config.size == WorldSize.medium) { temp.SetWorldSize(6400, 1800); Main.maxTilesX = 6400; Main.maxTilesY = 1800; Main.tile = new Tile[6400, 1800]; } if (config.size == WorldSize.large) { temp.SetWorldSize(8400, 2400); Main.maxTilesX = 8400; Main.maxTilesY = 2400; Main.tile = new Tile[8400, 2400]; } if (config.size == WorldSize.custom) { temp.SetWorldSize(config.customWidth, config.customHeight); Main.maxTilesX = config.customWidth; Main.maxTilesY = config.customHeight; Main.tile = new Tile[config.customWidth, config.customHeight]; } if (config.evil == Evil.corruption) { temp.HasCrimson = false; } if (config.evil == Evil.crimson) { temp.HasCrimson = true; } temp.IsExpertMode = config.expert; Main.expertMode = config.expert; if (config.seed == "" || config.seed is null) { temp.SetSeedToRandom(); } else { temp.SetSeed(config.seed); } Main.ActiveWorldFileData = temp; WorldGen.CreateNewWorld(); }
private void AddWorldData(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_ctor orig, UIWorldListItem self, WorldFileData data, int snapPointIndex) { orig(self, data, snapPointIndex); string path = data.Path.Replace(".wld", ".twld"); TagCompound tag; try { byte[] buf = FileUtilities.ReadAllBytes(path, data.IsCloudSave); tag = TagIO.FromStream(new MemoryStream(buf), true); } catch { tag = null; } TagCompound tag2 = tag?.GetList <TagCompound>("modData").FirstOrDefault(k => k.GetString("mod") == "StarlightRiver" && k.GetString("name") == "StarlightWorld"); TagCompound tag3 = tag2?.Get <TagCompound>("data"); worldDataCache.Add(self, tag3); }
public static Color GetPanelColor(WorldFileData data, Color color) => File.Exists(Path.ChangeExtension(data.Path, ".fwim")) ? color : Color.White;
private static void UIWorldListItemOnctor(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_ctor orig, Terraria.GameContent.UI.Elements.UIWorldListItem self, WorldFileData data, int snappointindex) { orig(self, data, snappointindex); try { string path = Path.ChangeExtension(data.Path, ".twld"); if (File.Exists(path)) { var buf = FileUtilities.ReadAllBytes(path, data.IsCloudSave); var tag = TagIO.FromStream(new MemoryStream(buf)); var list = tag.GetList <TagCompound>("modData").FirstOrDefault((TagCompound m) => m.Get <string>("mod") == "TUA" && m.Get <string>("name") == "TUAWorld"); if (list != null) { TUAWorldData.Add(data.UniqueId, tag.GetList <TagCompound>("modData").FirstOrDefault((TagCompound m) => m.Get <string>("mod") == "TUA" && m.Get <string>("name") == "TUAWorld")); } } } catch (Exception e) { ErrorLogger.Log(e.Message); } }