Example #1
0
        private void refershListAndKeepSelection(Trigger trigDef, PlayerDef pselPld)
        {
            updateLists();
            int  index = 0;
            bool found = false;

            // Check if trigger is still under selected player list
            if (trigDef != null)
            {
                if (!trigDef.getAffectedPlayers().Contains(pselPld))   // Select another player who has this trigger (the first one)
                {
                    pselPld = trigDef.getAffectedPlayers()[0];
                }
            }

            // Find the player and activate it
            foreach (MySelectableListItem pl in lstPlayers.GetAllItems())
            {
                PlayerDef pld = ((object[])pl.CustomData)[0] as PlayerDef;
                if (pld == pselPld)
                {
                    lstPlayers.SelectedIndex = index;
                    found = true;
                    break;
                }
                index++;
            }
            if (!found)
            {
                // Should never happen
                if (lstPlayers.GetAllItems().Count == 0)
                {
                    lstTriggers.Clear();
                    return;
                }
                else
                {
                    lstPlayers.SelectedIndex = 0;
                    lstTriggers.Clear();
                    return;
                }
            }
            else
            {
                // Select trigger now
                index = 0;
                foreach (MySelectableListItem trg in lstTriggers.GetAllItems())
                {
                    Trigger trig = ((object[])trg.CustomData)[1] as Trigger;
                    lstTriggers.SelectedIndex = index;
                    if (trig == trigDef)
                    {
                        break;
                    }
                    index++;
                }
            }
        }
Example #2
0
        private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (tabs.SelectedIndex >= 0)
            {
                switch (tabs.SelectedIndex)
                {
                case 0:
                    wnd.Title = "Select players trigger should execute for.";
                    break;

                case 1:
                    wnd.Title = "Trigger conditions (" + lstCond.GetAllItems().Count + "/16).";
                    break;

                case 2:
                    wnd.Title = "Trigger actions (" + lstAct.GetAllItems().Count + "/64).";
                    break;

                default:
                    wnd.Title = "Trigger editor";
                    break;
                }
            }
        }