protected override OptionResult Run(GameHitParameters<GameObject> parameters)
        {
            List<SimSelection.ICriteria> filters = new List<SimSelection.ICriteria>();

            foreach (SavedFilter filter in NRaas.MasterController.Settings.mFilters)
            {
                filters.Add(new SavedFilter.Item(filter));
            }

            SimSelection.ICriteria selection = new SimSelection.CriteriaSelection(Name, filters, callingMod).SelectSingle();
            if (selection == null) return OptionResult.Failure;

            Delete(selection.Name);
            return OptionResult.SuccessRetain;
        }
Exemple #2
0
        public virtual SimSelection.ICriteria RunFilterSelection(string callingMod)
        {
            List <SimSelection.ICriteria> filters = new List <SimSelection.ICriteria>();

            foreach (SavedFilter filter in NRaas.MasterController.Settings.mFilters)
            {
                filters.Add(new SavedFilter.Item(filter));
            }

            SimSelection.ICriteria selection = new SimSelection.CriteriaSelection(Name, filters, callingMod).SelectSingle();
            if (selection == null)
            {
                return(null);
            }

            return(selection);
        }
Exemple #3
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            List <SimSelection.ICriteria> filters = new List <SimSelection.ICriteria>();

            foreach (SavedFilter filter in NRaas.MasterController.Settings.mFilters)
            {
                filters.Add(new SavedFilter.Item(filter));
            }

            SimSelection.ICriteria selection = new SimSelection.CriteriaSelection(Name, filters, callingMod).SelectSingle();
            if (selection == null)
            {
                return(OptionResult.Failure);
            }

            Delete(selection.Name);
            return(OptionResult.SuccessRetain);
        }
Exemple #4
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            SimSelection.CriteriaSelection.Results uncheckedCriteria = new SimSelection.CriteriaSelection(Name, SelectionCriteria.SelectionOption.List).SelectMultiple(20);
            if (uncheckedCriteria.Count == 0)
            {
                if (uncheckedCriteria.mOkayed)
                {
                    return(OptionResult.SuccessClose);
                }
                else
                {
                    return(OptionResult.Failure);
                }
            }

            bool showSpecial = false;

            foreach (SimSelection.ICriteria crit in uncheckedCriteria)
            {
                if (crit is SimTypeOr)
                {
                    showSpecial = true;
                    break;
                }
            }

            Sim sim = parameters.mActor as Sim;

            List <IMiniSimDescription> simsList = new List <IMiniSimDescription>();

            foreach (List <IMiniSimDescription> sims in SimListing.AllSims <IMiniSimDescription>(sim.SimDescription, showSpecial).Values)
            {
                if (!showSpecial)
                {
                    sims.RemoveAll((e) => { return(SimSelection.IsSpecial(e)); });
                }

                simsList.AddRange(sims);
            }

            List <SimSelection.ICriteria> criteria = new List <SimSelection.ICriteria> ();

            foreach (SimSelection.ICriteria crit in uncheckedCriteria)
            {
                // Update changes the sims list, so we need a new copy for each call
                List <IMiniSimDescription> newList = new List <IMiniSimDescription>(simsList);
                if (crit.Update(sim.SimDescription, uncheckedCriteria, newList, false) != SimSelection.UpdateResult.Failure)
                {
                    criteria.Add(crit);
                }
            }

            string name = null;

            while (true)
            {
                name = StringInputDialog.Show(Name, Common.Localize("SaveFilterSetting:Prompt"), name, 256, StringInputDialog.Validation.None);
                if (string.IsNullOrEmpty(name))
                {
                    return(OptionResult.Failure);
                }

                if (callingMod != string.Empty)
                {
                    name = callingMod + "." + name;
                }

                if (Find(name) == null)
                {
                    break;
                }
                else if (AcceptCancelDialog.Show(Common.Localize("SaveFilterSetting:Exists")))
                {
                    Delete(name);
                    break;
                }
            }

            NRaas.MasterController.Settings.mFilters.Add(new SavedFilter(name, criteria));

            SimpleMessageDialog.Show(Name, Common.Localize("SaveFilterSetting:Success"));
            return(OptionResult.SuccessRetain);
        }
        protected override OptionResult Run(GameHitParameters<GameObject> parameters)
        {
            SimSelection.CriteriaSelection.Results uncheckedCriteria = new SimSelection.CriteriaSelection(Name, SelectionCriteria.SelectionOption.List).SelectMultiple(20);
            if (uncheckedCriteria.Count == 0)
            {
                if (uncheckedCriteria.mOkayed)
                {
                    return OptionResult.SuccessClose;
                }
                else
                {
                    return OptionResult.Failure;
                }
            }

            bool showSpecial = false;
            foreach (SimSelection.ICriteria crit in uncheckedCriteria)
            {
                if (crit is SimTypeOr)
                {
                    showSpecial = true;
                    break;
                }
            }

            Sim sim = parameters.mActor as Sim;

            List<IMiniSimDescription> simsList = new List<IMiniSimDescription>();
            foreach (List<IMiniSimDescription> sims in SimListing.AllSims<IMiniSimDescription>(sim.SimDescription, showSpecial).Values)
            {
                if (!showSpecial)
                {
                    sims.RemoveAll((e) => { return SimSelection.IsSpecial(e); });
                }

                simsList.AddRange(sims);
            }

            List<SimSelection.ICriteria> criteria = new List<SimSelection.ICriteria> ();

            foreach (SimSelection.ICriteria crit in uncheckedCriteria)
            {
                // Update changes the sims list, so we need a new copy for each call
                List<IMiniSimDescription> newList = new List<IMiniSimDescription>(simsList);
                if (crit.Update(sim.SimDescription, uncheckedCriteria, newList, false) != SimSelection.UpdateResult.Failure)
                {
                    criteria.Add(crit);
                }
            }

            string name = null;

            while (true)
            {
                name = StringInputDialog.Show(Name, Common.Localize("SaveFilterSetting:Prompt"), name, 256, StringInputDialog.Validation.None);
                if (string.IsNullOrEmpty(name))
                {
                    return OptionResult.Failure;
                }

                if (callingMod != string.Empty)
                {
                    name = callingMod + "." + name;
                }

                if (Find(name) == null)
                {
                    break;
                }
                else if (AcceptCancelDialog.Show(Common.Localize("SaveFilterSetting:Exists")))
                {
                    Delete(name);
                    break;
                }
            }
            
            NRaas.MasterController.Settings.mFilters.Add (new SavedFilter(name, criteria));

            SimpleMessageDialog.Show(Name, Common.Localize("SaveFilterSetting:Success"));
            return OptionResult.SuccessRetain;
        }
Exemple #6
0
        public virtual List <SimSelection.ICriteria> RunCriteriaSelection(GameHitParameters <GameObject> parameters, int maxSelection, bool withOptions)
        {
            List <SimSelection.ICriteria> selCrit = new List <SimSelection.ICriteria>();

            if (mForbiddenCrit.Count > 0)
            {
                foreach (SimSelection.ICriteria critItem in SelectionCriteria.SelectionOption.List)
                {
                    if (!mForbiddenCrit.Contains(critItem.GetType().Name))
                    {
                        selCrit.Add(critItem);
                    }
                }
            }
            else
            {
                selCrit = SelectionCriteria.SelectionOption.List;
            }

            SimSelection.CriteriaSelection.Results uncheckedCriteria = new SimSelection.CriteriaSelection(Name, selCrit).SelectMultiple(maxSelection);
            if (uncheckedCriteria.Count == 0)
            {
                if (uncheckedCriteria.mOkayed)
                {
                    return(selCrit);
                }
                else
                {
                    return(selCrit);
                }
            }

            bool showSpecial = false;

            foreach (SimSelection.ICriteria crit in uncheckedCriteria)
            {
                Common.Notify("Selected: " + crit.GetType().Name);
                if (crit is SimTypeOr)
                {
                    showSpecial = true;
                    break;
                }
            }

            Sim sim = parameters.mActor as Sim;

            List <IMiniSimDescription> simsList = new List <IMiniSimDescription>();

            foreach (List <IMiniSimDescription> sims in SimListing.AllSims <IMiniSimDescription>(sim.SimDescription, showSpecial).Values)
            {
                if (!showSpecial)
                {
                    sims.RemoveAll((e) => { return(SimSelection.IsSpecial(e)); });
                }

                simsList.AddRange(sims);
            }

            List <SimSelection.ICriteria> criteria = new List <SimSelection.ICriteria>();

            foreach (SimSelection.ICriteria crit in uncheckedCriteria)
            {
                if (withOptions)
                {
                    // Update changes the sims list, so we need a new copy for each call
                    List <IMiniSimDescription> newList = new List <IMiniSimDescription>(simsList);
                    if (crit.Update(sim.SimDescription, uncheckedCriteria, newList, false, false, false) != SimSelection.UpdateResult.Failure)
                    {
                        Common.Notify("Adding: " + crit.GetType().Name);
                        criteria.Add(crit);
                    }
                }
                else
                {
                    criteria.Add(crit);
                }
            }

            return(criteria);
        }