/// <summary> /// Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). /// </summary> protected override void KeyTyped(char par1, int par2) { if (par2 == 15) { CompletePlayerName(); } else { Field_50060_d = false; } if (par2 == 1) { Mc.DisplayGuiScreen(null); } else if (par2 == 28) { string s = Field_50064_a.GetText().Trim(); if (s.Length > 0 && !Mc.LineIsCommand(s)) { Mc.ThePlayer.SendChatMessage(s); } Mc.DisplayGuiScreen(null); } else if (par2 == 200) { Func_50058_a(-1); } else if (par2 == 208) { Func_50058_a(1); } else if (par2 == 201) { Mc.IngameGUI.Func_50011_a(19); } else if (par2 == 209) { Mc.IngameGUI.Func_50011_a(-19); } else { Field_50064_a.Func_50037_a(par1, par2); } }
/// <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> /// 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) { ParentGui.ConfirmClicked(false, 0); } else if (par1GuiButton.Id == 0) { ServerNBTStorage.Name = ServerName.GetText(); ServerNBTStorage.Host = ServerAddress.GetText(); ParentGui.ConfirmClicked(true, 0); } }
/// <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> /// 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("selectServer.select"))); ControlList.Add(new GuiButton(1, Width / 2 - 100, Height / 4 + 120 + 12, stringtranslate.TranslateKey("gui.cancel"))); ServerTextField = new GuiTextField(FontRenderer, Width / 2 - 100, 116, 200, 20); ServerTextField.SetMaxStringLength(128); ServerTextField.setFocused(true); ServerTextField.SetText(Field_52009_d); ControlList[0].Enabled = ServerTextField.GetText().Length > 0 && StringHelperClass.StringSplit(ServerTextField.GetText(), ":", true).Length > 0; }
/// <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("addServer.add"))); ControlList.Add(new GuiButton(1, Width / 2 - 100, Height / 4 + 120 + 12, stringtranslate.TranslateKey("gui.cancel"))); ServerName = new GuiTextField(FontRenderer, Width / 2 - 100, 76, 200, 20); ServerName.setFocused(true); ServerName.SetText(ServerNBTStorage.Name); ServerAddress = new GuiTextField(FontRenderer, Width / 2 - 100, 116, 200, 20); ServerAddress.SetMaxStringLength(128); ServerAddress.SetText(ServerNBTStorage.Host); ControlList[0].Enabled = ServerAddress.GetText().Length > 0 && StringHelperClass.StringSplit(ServerAddress.GetText(), ":", true).Length > 0 && ServerName.GetText().Length > 0; }
/// <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) { Mc.DisplayGuiScreen(null); if (CreateClicked) { return; } CreateClicked = true; long l = (new Random()).Next(); string s = TextboxSeed.GetText(); if (!string.IsNullOrEmpty(s)) { try { long l1 = Convert.ToInt64(s); if (l1 != 0L) { l = l1; } } catch (FormatException numberformatexception) { Utilities.LogException(numberformatexception); l = s.GetHashCode(); } } int i = 0; if (GameMode.Equals("creative")) { i = 1; Mc.PlayerController = new PlayerControllerCreative(Mc); } else { Mc.PlayerController = new PlayerControllerSP(Mc); } Mc.StartWorld(FolderName, TextboxWorldName.GetText(), new WorldSettings(l, i, Field_35365_g, Field_40232_h, WorldType.WorldTypes[Field_46030_z])); Mc.DisplayGuiScreen(null); } else if (par1GuiButton.Id == 3) { MoreOptions = !MoreOptions; GameModeButton.ShowButton = !MoreOptions; GenerateStructuresButton.ShowButton = MoreOptions; WorldTypeButton.ShowButton = MoreOptions; if (MoreOptions) { StringTranslate stringtranslate = StringTranslate.GetInstance(); MoreWorldOptions.DisplayString = stringtranslate.TranslateKey("gui.done"); } else { StringTranslate stringtranslate1 = StringTranslate.GetInstance(); MoreWorldOptions.DisplayString = stringtranslate1.TranslateKey("selectWorld.moreWorldOptions"); } } else if (par1GuiButton.Id == 2) { if (GameMode.Equals("survival")) { Field_40232_h = false; GameMode = "hardcore"; Field_40232_h = true; Func_35363_g(); } else if (GameMode.Equals("hardcore")) { Field_40232_h = false; GameMode = "creative"; Func_35363_g(); Field_40232_h = false; } else { GameMode = "survival"; Func_35363_g(); Field_40232_h = false; } Func_35363_g(); } else if (par1GuiButton.Id == 4) { Field_35365_g = !Field_35365_g; Func_35363_g(); } else if (par1GuiButton.Id == 5) { Field_46030_z++; if (Field_46030_z >= WorldType.WorldTypes.Length) { Field_46030_z = 0; } do { if (WorldType.WorldTypes[Field_46030_z] != null && WorldType.WorldTypes[Field_46030_z].GetCanBeCreated()) { break; } Field_46030_z++; if (Field_46030_z >= WorldType.WorldTypes.Length) { Field_46030_z = 0; } }while (true); Func_35363_g(); } }
/// <summary> /// Called when the screen is unloaded. Used to disable keyboard repeat events /// </summary> public override void OnGuiClosed() { //Keyboard.EnableRepeatEvents(false); Field_52009_d = ServerTextField.GetText(); }