private void btnSaveAll_Click(object sender, EventArgs e) { float curDur = 0; float maxDur = 0; try { curDur = float.Parse(txtCurrentDurability.Text); maxDur = float.Parse(txtMaxDurability.Text); } catch { MessageBox.Show("Invalid durability input."); return; } if (curDur == 100 || maxDur == 100) { MessageBox.Show("Perfect 100! Congrats for finding this hidden nugget!"); return; } if (curDur > maxDur || curDur > 99999 || curDur < 0 || maxDur <= 0) { MessageBox.Show("Invalid durability input."); return; } if (!txtName.ReadOnly) { if (txtName.Text.Trim() == "") { MessageBox.Show("No name entered! Reverting to default item name."); } foreach (char c in txtName.Text) { if (c < 20 || c > 127) { MessageBox.Show("Name can only contain English characters."); return; } } } if (!txtName.ReadOnly) { weaponInfo.ItemName = txtName.Text.Trim(); } weaponInfo.CurrentDurability = curDur; weaponInfo.MaxDurability = maxDur; editor.WriteWeaponByte(weaponInfo); MessageBox.Show("Modification successful. Please save."); isEdit = true; this.DialogResult = DialogResult.Yes; this.Close(); }
private void btnSave_Click(object sender, EventArgs e) { List <byte> btList = new List <byte>(); foreach (string line in txtByte.Lines) { string[] str = line.Trim().Split(' '); foreach (string s in str) { if (s.Trim().Length != 2) { MessageBox.Show("输入的代码格式不正确"); return; } byte b = byte.Parse(s.Trim(), System.Globalization.NumberStyles.HexNumber); btList.Add(b); } } weapon.ItemBytes = btList.ToArray(); editer.WriteWeaponByte(weapon); this.DialogResult = DialogResult.Yes; btnSave.Enabled = false; }