private void cmbReqType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Working)
            {
                return;
            }
            FileChanged = true;
            Working     = true;

            iLootRule     newlr;
            eLootRuleType ruletype = RequirementComboEntries[cmbReqType.SelectedIndex];

            newlr = LootRuleCreator.CreateLootRule(ruletype);
            if (newlr == null)
            {
                newlr = CurrentReq;
            }

            if (newlr.GetRuleType() != CurrentReq.GetRuleType())
            {
                //Change type
                CurrentRule.IntRules[CurrentReqNum] = newlr;
                SetCurrentReq(newlr, CurrentReqNum);
                lstRequirements.Items[CurrentReqNum] = newlr.DisplayString();

                lstRules.Invalidate();
                lstRequirements.Invalidate();
            }

            Working = false;
        }
        void SetCurrentReq(iLootRule cr, int crn)
        {
            Working = true;

            CurrentReq    = cr;
            CurrentReqNum = crn;
            if (cr == null)
            {
                groupReqs.Visible = false;
            }
            else
            {
                lstRequirements.SelectedIndex = crn;
                groupReqs.Visible             = true;
                cmbReqType.Items.Clear();
                RequirementComboEntries.Clear();

                Array arr = Enum.GetValues(typeof(eLootRuleType));
                SortedList <string, eLootRuleType> incomingrules = new SortedList <string, eLootRuleType>();
                foreach (int it in arr)
                {
                    eLootRuleType lrt = ((eLootRuleType)it);
                    iLootRule     lr  = LootRuleCreator.CreateLootRule(lrt);
                    if (lr == null)
                    {
                        continue;
                    }

                    if (lrt == eLootRuleType.DisabledRule)
                    {
                        AddRequirementComboEntry(lr.FriendlyName(), lrt);
                    }
                    else
                    {
                        incomingrules[lr.FriendlyName()] = lrt;
                    }
                }
                foreach (KeyValuePair <string, eLootRuleType> kp in incomingrules)
                {
                    AddRequirementComboEntry(kp.Key, kp.Value);
                }


                cmbReqType.SelectedIndex = GetRequirementComboIndexForRuleType((eLootRuleType)cr.GetRuleType());

                //*******************
                //Fill control values
                //*******************

                lblActsOn.Visible = cr.UI_ActsOnCombo_Uses();
                cmbActsOn.Visible = lblActsOn.Visible;
                if (lblActsOn.Visible)
                {
                    lblActsOn.Text = cr.UI_ActsOnCombo_Label();
                    cmbActsOn.Items.Clear();
                    foreach (string s in cr.UI_ActsOnCombo_Options())
                    {
                        cmbActsOn.Items.Add(s);
                    }
                    cmbActsOn.SelectedIndex = cr.UI_ActsOnCombo_Get();
                }

                lblKey.Visible = cr.UI_KeyCombo_Uses();
                cmbKey.Visible = lblKey.Visible;
                if (lblKey.Visible)
                {
                    lblKey.Text = cr.UI_KeyCombo_Label();
                    cmbKey.Items.Clear();
                    foreach (string s in cr.UI_KeyCombo_Options())
                    {
                        cmbKey.Items.Add(s);
                    }
                    cmbActsOn.SelectedIndex = cr.UI_KeyCombo_Get();
                }

                lblValue.Visible = cr.UI_TextValue_Uses();
                txtValue.Visible = lblValue.Visible;
                if (lblValue.Visible)
                {
                    lblValue.Text = cr.UI_TextValue_Label();
                    txtValue.Text = cr.UI_TextValue_Get();
                }

                lblValue2.Visible = cr.UI_TextValue2_Uses();
                txtValue2.Visible = lblValue2.Visible;
                if (lblValue2.Visible)
                {
                    lblValue2.Text = cr.UI_TextValue2_Label();
                    txtValue2.Text = cr.UI_TextValue2_Get();
                }

                lblValue3.Visible = cr.UI_TextValue3_Uses();
                txtValue3.Visible = lblValue3.Visible;
                if (lblValue3.Visible)
                {
                    lblValue3.Text = cr.UI_TextValue3_Label();
                    txtValue3.Text = cr.UI_TextValue3_Get();
                }

                lblValue4.Visible = cr.UI_TextValue4_Uses();
                txtValue4.Visible = lblValue4.Visible;
                if (lblValue4.Visible)
                {
                    lblValue4.Text = cr.UI_TextValue4_Label();
                    txtValue4.Text = cr.UI_TextValue4_Get();
                }

                //*******************
                //*******************
            }

            RefreshColorSample();

            Working = false;
        }
Beispiel #3
0
        void SetCurrentReq(iLootRule cr, int crn)
        {
            Working = true;

            CurrentReq    = cr;
            CurrentReqNum = crn;
            if (cr == null)
            {
                groupReqs.Visible = false;
            }
            else
            {
                lstRequirements.SelectedIndex = crn;
                groupReqs.Visible             = true;
                cmbReqType.Items.Clear();
                RequirementComboEntries.Clear();

                Array arr = Enum.GetValues(typeof(eLootRuleType));
                // Mag-nus added, new way, 3/14,2013
                List <int> sortedRequirements = new List <int>();
                foreach (int it in arr)
                {
                    eLootRuleType lrt = ((eLootRuleType)it);

                    if (lrt == eLootRuleType.MinDamageGE || lrt == eLootRuleType.DamagePercentGE || lrt == eLootRuleType.BuffedMedianDamageGE || lrt == eLootRuleType.CalcdBuffedTinkedDamageGE)
                    {
                        continue;
                    }

                    iLootRule lr = LootRuleCreator.CreateLootRule(lrt);
                    if (lr == null)
                    {
                        continue;
                    }
                    sortedRequirements.Add(it);
                }
                sortedRequirements.Sort((a, b) =>
                {
                    eLootRuleType alrt = ((eLootRuleType)a);
                    iLootRule alr      = LootRuleCreator.CreateLootRule(alrt);
                    eLootRuleType blrt = ((eLootRuleType)b);
                    iLootRule blr      = LootRuleCreator.CreateLootRule(blrt);
                    if (blrt == eLootRuleType.DisabledRule)
                    {
                        return(-1);                                                        // Enable/Disable goes at the end
                    }
                    return(alr.FriendlyName().CompareTo(blr.FriendlyName()));
                });
                // Mag-nus added end, new way, 3/14,2013
                // foreach (int it in arr) Mag-nus commented out, 3/14/2013
                foreach (int it in sortedRequirements)
                {
                    eLootRuleType lrt = ((eLootRuleType)it);
                    iLootRule     lr  = LootRuleCreator.CreateLootRule(lrt);
                    if (lr == null)
                    {
                        continue;
                    }

                    AddRequirementComboEntry(lr.FriendlyName(), lrt);
                }

                cmbReqType.SelectedIndex = GetRequirementComboIndexForRuleType((eLootRuleType)cr.GetRuleType());

                //*******************
                //Fill control values
                //*******************

                lblActsOn.Visible = cr.UI_ActsOnCombo_Uses();
                cmbActsOn.Visible = lblActsOn.Visible;
                if (lblActsOn.Visible)
                {
                    lblActsOn.Text = cr.UI_ActsOnCombo_Label();
                    cmbActsOn.Items.Clear();
                    foreach (string s in cr.UI_ActsOnCombo_Options())
                    {
                        cmbActsOn.Items.Add(s);
                    }
                    cmbActsOn.SelectedIndex = cr.UI_ActsOnCombo_Get();
                }

                lblKey.Visible = cr.UI_KeyCombo_Uses();
                cmbKey.Visible = lblKey.Visible;
                if (lblKey.Visible)
                {
                    lblKey.Text = cr.UI_KeyCombo_Label();
                    cmbKey.Items.Clear();
                    foreach (string s in cr.UI_KeyCombo_Options())
                    {
                        cmbKey.Items.Add(s);
                    }
                    cmbActsOn.SelectedIndex = cr.UI_KeyCombo_Get();
                }

                lblValue.Visible = cr.UI_TextValue_Uses();
                txtValue.Visible = lblValue.Visible;
                if (lblValue.Visible)
                {
                    lblValue.Text = cr.UI_TextValue_Label();
                    txtValue.Text = cr.UI_TextValue_Get();
                }

                lblValue2.Visible = cr.UI_TextValue2_Uses();
                txtValue2.Visible = lblValue2.Visible;
                if (lblValue2.Visible)
                {
                    lblValue2.Text = cr.UI_TextValue2_Label();
                    txtValue2.Text = cr.UI_TextValue2_Get();
                }

                lblValue3.Visible = cr.UI_TextValue3_Uses();
                txtValue3.Visible = lblValue3.Visible;
                if (lblValue3.Visible)
                {
                    lblValue3.Text = cr.UI_TextValue3_Label();
                    txtValue3.Text = cr.UI_TextValue3_Get();
                }

                lblValue4.Visible = cr.UI_TextValue4_Uses();
                txtValue4.Visible = lblValue4.Visible;
                if (lblValue4.Visible)
                {
                    lblValue4.Text = cr.UI_TextValue4_Label();
                    txtValue4.Text = cr.UI_TextValue4_Get();
                }

                //*******************
                //*******************
            }

            RefreshColorSample();

            Working = false;
        }