public void openFile(string path) { string ext = Path.GetExtension(path); FileInfo fi = new FileInfo(path); if (fi.Length > 0x802C) { Util.Error("Input file is too large.", path); } else { byte[] input; try { input = File.ReadAllBytes(path); } catch { Util.Error("File is in use by another program!", path); return; } try { openFile(input, path, ext); } catch { try { PokemonList empty = new PokemonList((byte[])PokemonList.EMPTY_LIST.Clone()) { [0] = { OT_Name = RBY_Encoding.GetBytes(JP_Mode ? "サイドン" : "Rhydon", JP_Mode) }, [0] = { Nickname = RBY_Encoding.GetBytes(JP_Mode ? "サイドン" : "RHYDON", JP_Mode) }, [0] = { TID = 12345 }, [0] = { Species = 1 }, [0] = { Level = 1 } }; openFile(empty.GetBytes(), path, ext); } catch { openFile(input, path, ext); } } } }
private void InitializeFields() { pk1 = JP_Mode ? new JPK1() : new PK1(); pk1.Species = (byte)PK1.SpeciesType.Rhydon; pk1.Move_1 = (byte)PK1.MoveType.Pound; PopulateFields(pk1); { if (JP_Mode) { TB_OT.Text = "サイドン"; TB_Nickname.Text = "サイドン"; } else { TB_OT.Text = "Rhydon"; TB_Nickname.Text = "RHYDON"; } TB_TID.Text = 12345.ToString(); pk1.OT_Name = RBY_Encoding.GetBytes(TB_OT.Text, JP_Mode); pk1.Nickname = RBY_Encoding.GetBytes(TB_Nickname.Text, JP_Mode); pk1.TID = 12345; CB_PPu1.SelectedIndex = CB_PPu2.SelectedIndex = CB_PPu3.SelectedIndex = CB_PPu4.SelectedIndex = 0; } SetStatusEditing(); }
private void updateOT(object sender, EventArgs e) { if (changingFields || !initializedFields) { return; } changingFields = true; if (!RBY_Encoding.Validate(TB_OT.Text, JP_Mode)) { TB_OT.Text = RBY_Encoding.FixString(TB_OT.Text, JP_Mode); } pk1.OT_Name = RBY_Encoding.GetBytes(TB_OT.Text, JP_Mode); changingFields = false; }
private void updateNickname(object sender, EventArgs e) { if (changingFields || !initializedFields) { return; } changingFields = true; if (!RBY_Encoding.Validate(TB_Nickname.Text, JP_Mode)) { TB_Nickname.Text = RBY_Encoding.FixString(TB_Nickname.Text, JP_Mode); } pk1.Nickname = RBY_Encoding.GetBytes(TB_Nickname.Text, JP_Mode); changingFields = false; SetStatusEditing(); }