Exemplo n.º 1
0
 /// <summary>
 /// Set all bytes in equipment[] to 0 
 /// </summary>
 /// <param name="equipments"></param>
 public static void ClearEquipment(Equipment[] equipments)
 {
     foreach (Equipment equip in equipments)
     {
         Array.Clear(equip.EquipmentBytes, 0, Constants.SIZEOF_EQUIPMENT);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Set all bytes in equipment[] to 0 in a specified range
 /// </summary>
 /// <param name="equipments">Equipment[] to clear</param>
 /// <param name="startIndex">Start index (index 0)</param>
 /// <param name="endIndex">End index</param>
 public static void ClearEquipment(Equipment[] equipments, int startIndex, int endIndex)
 {
     for (int eqIndex = startIndex; eqIndex < endIndex; eqIndex++)
     {
         Array.Clear(equipments[eqIndex].EquipmentBytes, 0, Constants.SIZEOF_EQUIPMENT);
     }
 }
        private void buttonImport_Click(object sender, EventArgs e)
        {
            Equipment temp = new Equipment(equipment);
            try
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "EquipmentFile (*.eqp)|*.eqp|All files (*.*)|*.*";
                ofd.FilterIndex = 1;

                if (ofd.ShowDialog() != DialogResult.OK)
                {
                    ofd.Dispose();
                    return;
                }

                byte[] fileData = File.ReadAllBytes(ofd.FileName);
                if (fileData.Length != Constants.SIZEOF_EQUIPMENT)
                {
                    MessageBox.Show("Invalid Equipment", "Error");
                    return;
                }

                this.equipment.EquipmentBytes = fileData;
                loadData();

                ofd.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Loading Error");
                this.equipment = temp;
            }
        }
        private void buttonExport_Click(object sender, EventArgs e)
        {
            Equipment temp = new Equipment(equipment);
            try
            {
                using (SaveFileDialog sfd = new SaveFileDialog())
                {
                    sfd.Filter = "EquipmentFile (*.eqp)|*.eqp|All files (*.*)|*.*";
                    sfd.FilterIndex = 1;
                    sfd.RestoreDirectory = true;

                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        saveData();
                        File.WriteAllBytes(sfd.FileName, equipment.EquipmentBytes);
                        this.equipment = temp;
                        MessageBox.Show(string.Format("Exported equipment to {0}", sfd.FileName), "Success!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Save Unsucessful");
            }
        }
Exemplo n.º 5
0
        public Equipment(Equipment equip)
        {
            byte[] temp = new byte[equip.EquipmentBytes.Length];
            for (int i = 0; i < temp.Length; i++)
            {
                byte b = equip.EquipmentBytes[i];
                temp[i] = b;
            }

            EquipmentBytes = temp;
        }
 public EquipmentEditDialog(Equipment equipment)
 {
     InitializeComponent();
     numericUpDownItemID.Maximum = 65535;
     numericUpDownLevel.Minimum = 0;
     numericUpDownLevel.Maximum = 255;
     textBoxDecoration1.MaxLength = 4;
     textBoxDecoration2.MaxLength = 4;
     textBoxDecoration3.MaxLength = 4;
     comboBoxEquipmentType.DataSource = GameConstants.EquipmentTypes;
     this.equipment = equipment;
     loadData();
 }
 public ImportEquipmentBoxDialog(Equipment[] equips)
 {
     InitializeComponent();
     this.equips = equips;
     comboBoxDest.SelectedIndex = 0;
 }
 public ExportEquipmentBoxDialog(Equipment[] equips)
 {
     InitializeComponent();
     comboBoxSelectedBox.SelectedIndex = 0;
     this.equips = equips;
 }