Exemple #1
0
        public SkillTable(string tableFileLoc)
        {
            var tableByteData   = File.ReadAllBytes(tableFileLoc);
            var tableByteLength = new FileInfo(tableFileLoc).Length;

            numberOfSkills = (int)tableByteLength / EO3Skill.SKILL_LENGTH;
            skillData      = new EO3Skill[numberOfSkills];

            for (int i = 0; i < numberOfSkills; i++)
            {
                skillData[i] = new EO3Skill(tableByteData.Skip(i * EO3Skill.SKILL_LENGTH).Take(EO3Skill.SKILL_LENGTH).ToArray());
            }
        }
Exemple #2
0
        private void SkillChanged(object sender, EventArgs e)
        {
            var senderList = (ComboBox)sender;
            var skillId    = senderList.SelectedIndex;

            selectedSkill = st.skillData[skillId];

            skillNameTextBox.Text = skillList.Text.Split(new string[] { ": " }, StringSplitOptions.None)[1];

            // set max level
            if (selectedSkill.SkillLevel == 1)
            {
                maxLevel1.Checked = true;
            }
            else if (selectedSkill.SkillLevel == 5)
            {
                maxLevel5.Checked = true;
            }
            else if (selectedSkill.SkillLevel == 10)
            {
                maxLevel10.Checked = true;
            }

            // set skill type
            skillTypeTextBox.Text = selectedSkill.SkillType.ToString("x");

            // set body part and weapon
            foreach (CheckBox entry in bodyPartsWeaponsBox.Controls)
            {
                entry.Checked = false;
                var entryFlag = int.Parse(entry.Tag.ToString().Replace("0x", ""), System.Globalization.NumberStyles.HexNumber);

                if ((entryFlag & selectedSkill.BodyParts) == entryFlag)
                {
                    entry.Checked = true;
                }
            }

            // set status required
            statusRequiredTextBox.Text = selectedSkill.StatusRequired.ToString("x");

            // set usable state
            usableStateTextBox.Text = selectedSkill.UsableState.ToString("x");

            // set target team
            foreach (RadioButton entry in targetTeamBox.Controls)
            {
                entry.Checked = false;
                var entryFlag = int.Parse(entry.Tag.ToString().Replace("0x", ""), System.Globalization.NumberStyles.HexNumber);

                if (entryFlag == selectedSkill.TargetTeam)
                {
                    entry.Checked = true;
                    break;
                }
            }

            // set target type
            foreach (RadioButton entry in targetTypeBox.Controls)
            {
                entry.Checked = false;
                var entryFlag = int.Parse(entry.Tag.ToString().Replace("0x", ""), System.Globalization.NumberStyles.HexNumber);

                if (entryFlag == selectedSkill.TargetType)
                {
                    entry.Checked = true;
                    break;
                }
            }

            // set modifier status
            foreach (RadioButton entry in modifierStatusBox.Controls)
            {
                entry.Checked = false;
                var entryFlag = int.Parse(entry.Tag.ToString().Replace("0x", ""), System.Globalization.NumberStyles.HexNumber);

                if (entryFlag == selectedSkill.ModifierStatus)
                {
                    entry.Checked = true;

                    // set modifier type (only need to do this if status isn't empty!)
                    foreach (RadioButton nestedEntry in modifierTypeBox.Controls)
                    {
                        var nestedEntryFlag = int.Parse(nestedEntry.Tag.ToString().Replace("0x", ""), System.Globalization.NumberStyles.HexNumber);

                        if (nestedEntryFlag == selectedSkill.ModifierType)
                        {
                            nestedEntry.Checked = true;
                            break;
                        }
                    }
                }
            }

            // set modifier element
            foreach (CheckBox entry in modifierElementBox.Controls)
            {
                entry.Checked = false;
                var entryFlag = int.Parse(entry.Tag.ToString().Replace("0x", ""), System.Globalization.NumberStyles.HexNumber);

                if ((entryFlag & selectedSkill.ModifierElement) == entryFlag)
                {
                    entry.Checked = true;
                }
            }

            // set damage type
            foreach (CheckBox entry in damageTypeBox.Controls)
            {
                entry.Checked = false;
                var entryFlag = int.Parse(entry.Tag.ToString().Replace("0x", ""), System.Globalization.NumberStyles.HexNumber);

                if ((entryFlag & selectedSkill.DamageType) == entryFlag)
                {
                    entry.Checked = true;
                }
            }

            // set infliction flag
            foreach (RadioButton entry in inflictPanel.Controls)
            {
                entry.Checked = false;
                var entryFlag = int.Parse(entry.Tag.ToString().Replace("0x", ""), System.Globalization.NumberStyles.HexNumber);

                if (entryFlag == selectedSkill.InflictionFlag)
                {
                    entry.Checked = true;
                    break;
                }
            }

            // set disables flags, if the box is enabled
            if (disableBox.Enabled == true)
            {
                foreach (CheckBox entry in disableBox.Controls)
                {
                    entry.Checked = false;
                    var entryFlag = int.Parse(entry.Tag.ToString().Replace("0x", ""), System.Globalization.NumberStyles.HexNumber);

                    if ((entryFlag & selectedSkill.DisablesInflicted) == entryFlag)
                    {
                        entry.Checked = true;
                    }
                }
            }

            // set skill flags
            skillFlagsTextBox.Text = selectedSkill.SkillFlags.ToString("x");

            // set repurposed
            repurposedTextBox.Text = selectedSkill.Repurposed.ToString("x");

            UpdateSubheaderInfo(null, null);

            // set requirements
            for (int i = 0; i < 3; i++)
            {
                try
                {
                    ComboBox      listToSet  = requirementsEditorBox.Controls.OfType <ComboBox>().FirstOrDefault(x => x.Name == "skill" + (i + 1) + "List");
                    NumericUpDown levelToSet = requirementsEditorBox.Controls.OfType <NumericUpDown>().FirstOrDefault(x => x.Name == "skill" + (i + 1) + "Level");
                    listToSet.SelectedIndex = rt.Skills[skillId].requiredSkills[i].Item1;
                    levelToSet.Value        = rt.Skills[skillId].requiredSkills[i].Item2;
                }

                // skills beyond the player skill table will throw this
                catch (IndexOutOfRangeException)
                {
                    ComboBox      listToSet  = requirementsEditorBox.Controls.OfType <ComboBox>().FirstOrDefault(x => x.Name == "skill" + (i + 1) + "List");
                    NumericUpDown levelToSet = requirementsEditorBox.Controls.OfType <NumericUpDown>().FirstOrDefault(x => x.Name == "skill" + (i + 1) + "Level");
                    listToSet.SelectedIndex = 0;
                    levelToSet.Value        = 0;
                }
            }

            // set custom text
            if (ct != null)
            {
                var skillStringsStart = skillList.SelectedIndex * 11;

                // magic number here
                for (int i = 0; i < 11; i++)
                {
                    var nameToTest      = "customText" + (i + 1).ToString();
                    var textBoxToModify = customBox.Controls
                                          .OfType <TextBox>()
                                          .FirstOrDefault(x => x.Name == nameToTest);

                    try
                    {
                        textBoxToModify.Text = ct.sjisStrings[skillStringsStart + i].GetAscii();
                    }

                    // skills beyond the player skill table will throw this
                    catch (IndexOutOfRangeException)
                    {
                        textBoxToModify.Text = "";
                    }
                }
            }
        }