private void FrmEditGundam_Load(object sender, EventArgs e) { List <short> limit = null; if (gundamInfo != null) { limit = new List <short>(); short wid = gundamInfo.WeaponId; if (wid >= 0 && gundamInfo.WeaponCount > 0) { for (short i = 0; i < gundamInfo.WeaponCount; i++) { limit.Add((short)(wid + i)); } } short map = gundamInfo.WeaponMapID; if (map >= 0 && gundamInfo.WeaponMapCount > 0) { for (short i = 0; i < gundamInfo.WeaponMapCount; i++) { limit.Add((short)(map + i + gundamFile.WeaponNormalCount)); } } } bindAll(); weapons = new List <WeaponInfo>(); List <WeaponInfo> allWeapons = gundamFile.ListWeapons(); List <KeyValuePair <string, string> > ranges = GGCRUtil.ListWeaponRange(); Dictionary <short, WeaponInfo> noranges = new Dictionary <short, WeaponInfo>(); foreach (WeaponInfo w in allWeapons) { if (limit == null || limit.Contains(w.ID)) { weapons.Add(w); } bool find = false; foreach (KeyValuePair <string, string> rngs in ranges) { if (rngs.Key == w.Range.ToString()) { find = true; break; } } if (!find) { if (!noranges.ContainsKey(w.Range)) { noranges.Add(w.Range, w); } } } foreach (KeyValuePair <short, WeaponInfo> kv in noranges) { GGCRUtil.AddWeaponRange(kv.Key, kv.Key + " " + (kv.Value.IsMap ? ("MAP " + kv.Value.UnitName) : ("普通 " + kv.Value.UnitName))); } bindAll(); lsGundam.DataSource = weapons; lsGundam.DisplayMember = "UnitName"; lsGundam.ValueMember = "Address"; }
private void LoadData(WeaponInfo weapon) { if (weapon != null) { txtId.Text = weapon.ID.ToString(); txtName.Text = weapon.UnitName; txtAddress.Text = weapon.Address; txtPower.Text = weapon.POWER.ToString(); txtEN.Text = weapon.EN.ToString(); txtMP.Text = weapon.MP.ToString(); txtMoveAct.Text = weapon.MoveACT.ToString(); string useEarth = weapon.UseEarth; chkUse1.Checked = useEarth[4] == '1'; chkUse2.Checked = useEarth[3] == '1'; chkUse3.Checked = useEarth[2] == '1'; chkUse4.Checked = useEarth[1] == '1'; chkUse5.Checked = useEarth[0] == '1'; string actEarch = weapon.ActEarth; cboAE1.SelectedValue = "" + actEarch[8] + actEarch[9]; cboAE2.SelectedValue = "" + actEarch[6] + actEarch[7]; cboAE3.SelectedValue = "" + actEarch[4] + actEarch[5]; cboAE4.SelectedValue = "" + actEarch[2] + actEarch[3]; cboAE5.SelectedValue = "" + actEarch[0] + actEarch[1]; cboMpLimit.SelectedValue = weapon.MPLimit.ToString(); if (cboMpLimit.SelectedValue == null) { GGCRUtil.AddWeaponMPLimit(weapon.MPLimit, "未知" + weapon.MPLimit); bindAll(); LoadData(weapon); return; } if (weapon is WeaponNormalInfo) { panNormal.Enabled = true; panMap.Enabled = false; cboProp.DataSource = this.gundamFile.ListWeaponProp(); cboProp.DisplayMember = "Value"; cboProp.ValueMember = "Key"; cboIco.DataSource = this.gundamFile.ListWeaponProp(); cboIco.DisplayMember = "Value"; cboIco.ValueMember = "Key"; txtHitRate.Text = (weapon as WeaponNormalInfo).HitRate.ToString(); txtCT.Text = (weapon as WeaponNormalInfo).CT.ToString(); txtHitCount.Text = (weapon as WeaponNormalInfo).HitCount.ToString(); txtMapTurn.Text = null; txtAttMaxCount.Text = null; cboWeaponType.SelectedValue = -1; } else { panNormal.Enabled = false; panMap.Enabled = true; cboProp.DataSource = this.gundamFile.ListWeaponProp(); cboProp.DisplayMember = "Value"; cboProp.ValueMember = "Key"; cboIco.DataSource = this.gundamFile.ListWeaponProp(); cboIco.DisplayMember = "Value"; cboIco.ValueMember = "Key"; txtHitRate.Text = null; txtCT.Text = null; txtHitCount.Text = null; txtMapTurn.Text = (weapon as WeaponMapInfo).MapTurn.ToString(); txtAttMaxCount.Text = (weapon as WeaponMapInfo).AttMaxCount.ToString(); cboWeaponType.SelectedValue = (weapon as WeaponMapInfo).WeaponType.ToString(); if (cboWeaponType.SelectedValue == null) { GGCRUtil.AddWeaponType((weapon as WeaponMapInfo).WeaponType, "未知" + (weapon as WeaponMapInfo).WeaponType); bindAll(); LoadData(weapon); return; } } cboProp.SelectedValue = weapon.PROPER.ToString(); cboIco.SelectedValue = weapon.ICO.ToString(); cboSpec.SelectedValue = weapon.Spec.ToString(); cboRange.SelectedValue = weapon.Range.ToString(); if (cboRange.SelectedValue == null) { GGCRUtil.AddWeaponRange(weapon.Range, "未知" + weapon.Range); bindAll(); LoadData(weapon); return; } btnSave.Enabled = true; } else { txtId.Text = null; txtName.Text = null; txtAddress.Text = null; txtPower.Text = null; txtEN.Text = null; txtMP.Text = null; txtMoveAct.Text = null; txtHitRate.Text = null; txtCT.Text = null; txtHitCount.Text = null; txtMapTurn.Text = null; txtAttMaxCount.Text = null; chkUse1.Checked = false; chkUse2.Checked = false; chkUse3.Checked = false; chkUse4.Checked = false; chkUse5.Checked = false; cboAE1.SelectedValue = -1; cboAE2.SelectedValue = -1; cboAE3.SelectedValue = -1; cboAE4.SelectedValue = -1; cboAE5.SelectedValue = -1; cboProp.SelectedValue = -1; cboIco.SelectedValue = -1; cboSpec.SelectedValue = -1; cboWeaponType.SelectedValue = -1; btnSave.Enabled = false; } }