Exemplo n.º 1
0
        // this could be further broken down into another class (IntegerSettingOption) but not right now
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            OptionResult result = base.Run(parameters);

            if (result != OptionResult.Failure)
            {
                string text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Prompt", false), ""); // def

                if (string.IsNullOrEmpty(text))
                {
                    return(OptionResult.Failure);
                }

                int value;
                if (!int.TryParse(text, out value))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    return(OptionResult.Failure);
                }

                foreach (OccupationNames name in base.mPicks)
                {
                    NRaas.CareerSpace.PersistedSettings.CareerSettings settings = NRaas.Careers.Settings.GetCareerSettings(name, true);
                    settings.minCoworkers = value;
                    NRaas.Careers.Settings.UpdateCareerSettings(settings);
                }

                Common.Notify("Generic:Success");
                return(OptionResult.SuccessLevelDown);
            }

            return(result);
        }
Exemplo n.º 2
0
        // this could be further broken down into another class (IntegerSettingOption) but not right now
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            OptionResult result = base.Run(parameters);

            if (result != OptionResult.Failure)
            {
                foreach (OccupationNames name in base.mPicks)
                {
                    string defaultText = string.Empty;
                    if (name != OccupationNames.Any)
                    {
                        NRaas.CareerSpace.PersistedSettings.CareerSettings settings = NRaas.Careers.Settings.GetCareerSettings(name, true);

                        defaultText = settings.mMaxCoworkers.ToString();
                    }

                    string text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Prompt", false), defaultText);

                    if (string.IsNullOrEmpty(text))
                    {
                        return(OptionResult.Failure);
                    }

                    int value;
                    if (!int.TryParse(text, out value))
                    {
                        SimpleMessageDialog.Show(Name, Common.Localize("InputError:Numeric"));
                        return(OptionResult.Failure);
                    }

                    if (name == OccupationNames.Any)
                    {
                        foreach (Career career in CareerManager.CareerList)
                        {
                            PersistedSettings.CareerSettings settings = NRaas.Careers.Settings.GetCareerSettings(career.Guid, true);

                            settings.mMaxCoworkers = value;

                            NRaas.Careers.Settings.SetCareerData(settings);
                        }

                        Common.Notify(GetTitlePrefix() + " " + Common.Localize("Selection:All") + " " + value);
                    }
                    else
                    {
                        PersistedSettings.CareerSettings settings = NRaas.Careers.Settings.GetCareerSettings(name, true);
                        settings.mMaxCoworkers = value;

                        NRaas.Careers.Settings.SetCareerData(settings);

                        Common.Notify(GetTitlePrefix() + " " + CareerManager.GetStaticCareer(name).Name + " " + value);
                    }
                }

                Common.Notify(Common.Localize("Generic:Success"));
                return(OptionResult.SuccessLevelDown);
            }

            return(result);
        }