Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            WeaponInfo weapon = lsGundam.SelectedItem as WeaponInfo;

            if (weapon != null)
            {
                weapon.POWER    = int.Parse(txtPower.Text);
                weapon.EN       = short.Parse(txtEN.Text);
                weapon.MP       = short.Parse(txtMP.Text);
                weapon.MoveACT  = byte.Parse(txtMoveAct.Text);
                weapon.MPLimit  = short.Parse(cboMpLimit.SelectedValue.ToString());
                weapon.UseEarth = (chkUse5.Checked ? "1" : "0") + (chkUse4.Checked ? "1" : "0") + (chkUse3.Checked ? "1" : "0") + (chkUse2.Checked ? "1" : "0") + (chkUse1.Checked ? "1" : "0");
                weapon.ActEarth = cboAE5.SelectedValue.ToString() + cboAE4.SelectedValue.ToString() + cboAE3.SelectedValue.ToString() + cboAE2.SelectedValue.ToString() + cboAE1.SelectedValue.ToString();
                weapon.PROPER   = byte.Parse(cboProp.SelectedValue.ToString());
                weapon.ICO      = byte.Parse(cboIco.SelectedValue.ToString());
                weapon.Spec     = byte.Parse(cboSpec.SelectedValue.ToString());

                weapon.Range = short.Parse(cboRange.SelectedValue.ToString());

                if (txtName.Text != weapon.UnitName)
                {
                    weapon.SetUnitName(txtName.Text);
                }

                if (weapon is WeaponNormalInfo)
                {
                    (weapon as WeaponNormalInfo).HitRate  = byte.Parse(txtHitRate.Text);
                    (weapon as WeaponNormalInfo).CT       = byte.Parse(txtCT.Text);
                    (weapon as WeaponNormalInfo).HitCount = byte.Parse(txtHitCount.Text);
                }
                else
                {
                    (weapon as WeaponMapInfo).MapTurn     = short.Parse(txtMapTurn.Text);
                    (weapon as WeaponMapInfo).WeaponType  = byte.Parse(cboWeaponType.SelectedValue.ToString());
                    (weapon as WeaponMapInfo).AttMaxCount = byte.Parse(txtAttMaxCount.Text);
                }

                weapon.Save();

                weapon.Refresh();
                LoadData(weapon);

                tsmiLblState.Text      = "保存成功";
                tsmiLblState.ForeColor = Color.Green;
            }
        }
Example #2
0
        private void btnBatchImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            //dialog.RestoreDirectory = true;
            dialog.Filter      = "武器数据|*.weapon";
            dialog.Multiselect = true;

            if (dialog.ShowDialog() == DialogResult.OK && dialog.FileNames.Length > 0)
            {
                txtSearch.Text = null;

                foreach (string fileName in dialog.FileNames)
                {
                    byte[] data = File.ReadAllBytes(fileName);

                    byte[] bt = new byte[GGCRStaticConfig.WeaponUIDLength];
                    Array.Copy(data, 0, bt, 0, bt.Length);
                    string uid = ByteHelper.ByteArrayToHexString(bt).Trim();

                    WeaponInfo select = null;
                    foreach (WeaponInfo info in weapons)
                    {
                        if (info.UUID == uid)
                        {
                            select = info;
                            break;
                        }
                    }
                    if (select != null)
                    {
                        select.Replace(data);
                        select.Save();
                    }
                }

                lsGundam.SelectedItem = null;

                bindAll();

                MessageBox.Show("导入成功,已自动保存", "操作提示");
                // lsGundam.SelectedIndex = 0;
            }
        }