/// <summary> /// loads the saves /// </summary> private void LoadSaves() { ISaveFormat isaveformat = Mc.GetSaveLoader(); SaveList = isaveformat.GetSaveList(); SaveList.Sort(); SelectedWorld = -1; Console.WriteLine(SaveList.Count + " is total loaded saves"); }
/// <summary> /// Adds the buttons (and other controls) to the screen in question. /// </summary> public override void InitGui() { StringTranslate stringtranslate = StringTranslate.GetInstance(); //Keyboard.EnableRepeatEvents(true); ControlList.Clear(); ControlList.Add(new GuiButton(0, Width / 2 - 100, Height / 4 + 96 + 12, stringtranslate.TranslateKey("selectWorld.renameButton"))); ControlList.Add(new GuiButton(1, Width / 2 - 100, Height / 4 + 120 + 12, stringtranslate.TranslateKey("gui.cancel"))); ISaveFormat isaveformat = Mc.GetSaveLoader(); WorldInfo worldinfo = isaveformat.GetWorldInfo(WorldName); string s = worldinfo.GetWorldName(); TheGuiTextField = new GuiTextField(FontRenderer, Width / 2 - 100, 60, 200, 20); TheGuiTextField.setFocused(true); TheGuiTextField.SetText(s); }
public override void ConfirmClicked(bool par1, int par2) { if (Deleting) { Deleting = false; if (par1) { ISaveFormat isaveformat = Mc.GetSaveLoader(); isaveformat.FlushCache(); isaveformat.DeleteWorldDirectory(GetSaveFileName(par2)); LoadSaves(); } Mc.DisplayGuiScreen(this); } }
/// <summary> /// Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). /// </summary> protected override void ActionPerformed(GuiButton par1GuiButton) { if (!par1GuiButton.Enabled) { return; } if (par1GuiButton.Id == 1) { Mc.DisplayGuiScreen(ParentGuiScreen); } else if (par1GuiButton.Id == 0) { ISaveFormat isaveformat = Mc.GetSaveLoader(); isaveformat.RenameWorld(WorldName, TheGuiTextField.GetText().Trim()); Mc.DisplayGuiScreen(ParentGuiScreen); } }
/// <summary> /// Makes a the name for a world save folder based on your world name, replacing specific characters for _s and /// Appending -s to the end until a free name is available. /// </summary> private void MakeUseableName() { FolderName = TextboxWorldName.GetText().Trim(); char[] ac = ChatAllowedCharacters.AllowedCharactersArray; int i = ac.Length; for (int j = 0; j < i; j++) { char c = ac[j]; FolderName = FolderName.Replace(c, '_'); } if (MathHelper2.StringNullOrLengthZero(FolderName)) { FolderName = "World"; } FolderName = Func_25097_a(Mc.GetSaveLoader(), FolderName); }
/// <summary> /// Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). /// </summary> protected override void ActionPerformed(GuiButton par1GuiButton) { switch (par1GuiButton.Id) { default: break; case 1: if (Mc.TheWorld.GetWorldInfo().IsHardcoreModeEnabled()) { string s = Mc.TheWorld.GetSaveHandler().GetSaveDirectoryName(); Mc.ExitToMainMenu("Deleting world"); ISaveFormat isaveformat = Mc.GetSaveLoader(); isaveformat.FlushCache(); isaveformat.DeleteWorldDirectory(s); Mc.DisplayGuiScreen(new GuiMainMenu()); } else { Mc.ThePlayer.RespawnPlayer(); Mc.DisplayGuiScreen(null); } break; case 2: if (Mc.IsMultiplayerWorld()) { Mc.TheWorld.SendQuittingDisconnectingPacket(); } Mc.ChangeWorld1(null); Mc.DisplayGuiScreen(new GuiMainMenu()); break; } }