Ejemplo n.º 1
0
        private void insert_Click(object sender, System.EventArgs e)
        {
            MacroAction a = null;

            try
            {
                if (varList.SelectedIndex == (int)IfAction.IfVarType.SysMessage)
                {
                    a = new IfAction((IfAction.IfVarType)varList.SelectedIndex, txtAmount.Text);
                }
                else if (varList.SelectedIndex >= m_SkillStart)
                {
                    int skillId = -1;

                    foreach (Skill skill in World.Player.Skills)
                    {
                        if (Skills.GetSkillDisplayName(skill.Index).Equals(varList.SelectedItem as string))
                        {
                            skillId = skill.Index;
                            break;
                        }
                    }

                    if (skillId != -1)
                    {
                        a = new IfAction(IfAction.IfVarType.Skill, (sbyte)opList.SelectedIndex,
                                         Utility.ToDouble(txtAmount.Text, 0.0), skillId);
                    }
                }
                else if (varList.SelectedIndex >= (int)IfAction.IfVarType.BeginCountersMarker)
                {
                    a = new IfAction(IfAction.IfVarType.Counter, (sbyte)opList.SelectedIndex,
                                     Utility.ToInt32(txtAmount.Text, 0), varList.SelectedItem as string);
                }
                else
                {
                    a = txtAmount.Text.Contains("{") // using an if variable
                        ? new IfAction((IfAction.IfVarType)varList.SelectedIndex, (sbyte)opList.SelectedIndex,
                                       txtAmount.Text)
                        : new IfAction((IfAction.IfVarType)varList.SelectedIndex, (sbyte)opList.SelectedIndex,
                                       Utility.ToInt32(txtAmount.Text, 0));
                }
            }
            catch
            {
                return;
            }

            if (m_Action == null)
            {
                m_Macro.Insert(m_Idx + 1, a);
            }
            else
            {
                m_Action.Parent.Convert(m_Action, a);
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }