/// <summary>
        /// Adds mod options tab to tabstrip.
        /// </summary
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        public ModOptions(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab.
            UIPanel modTab = PanelUtils.AddTab(tabStrip, Translations.Translate("LBR_SET"), tabIndex, true);

            // Language dropdown.
            UIDropDown languageDrop = PanelUtils.AddPlainDropDown(modTab, Translations.Translate("TRN_CHOICE"), Translations.LanguageList, Translations.Index);

            languageDrop.eventSelectedIndexChanged += (control, index) =>
            {
                Translations.Index = index;
                Configuration <SettingsFile> .Save();
            };

            // Detail logging options.
            UICheckBox logCheckBox = PanelUtils.AddPlainCheckBox(modTab, Translations.Translate("LBR_SET_LDT"));

            logCheckBox.isChecked          = Logging.detailLogging;
            logCheckBox.eventCheckChanged += (control, isChecked) =>
            {
                // Update mod settings.
                Logging.detailLogging = isChecked;

                // Update configuration file.
                Configuration <SettingsFile> .Save();

                Logging.KeyMessage("detailed logging ", Logging.detailLogging ? "enabled" : "disabled");
            };

            // Logging options.
            UICheckBox deathCheckBox = PanelUtils.AddPlainCheckBox(modTab, Translations.Translate("LBR_SET_LGD"));

            deathCheckBox.isChecked          = OptionsPanel.settings.LogDeaths;
            deathCheckBox.eventCheckChanged += (control, isChecked) =>
            {
                // Update mod settings.
                Logging.UseDeathLog = isChecked;

                // Update configuration file.
                OptionsPanel.settings.LogDeaths = isChecked;
                Configuration <SettingsFile> .Save();

                Logging.Message("death logging ", OptionsPanel.settings.LogDeaths ? "enabled" : "disabled");
            };

            UICheckBox immigrantCheckBox = PanelUtils.AddPlainCheckBox(modTab, Translations.Translate("LBR_SET_LGI"));

            immigrantCheckBox.isChecked          = OptionsPanel.settings.LogImmigrants;
            immigrantCheckBox.eventCheckChanged += (control, isChecked) =>
            {
                // Update mod settings.
                Logging.UseImmigrationLog = isChecked;

                // Update configuration file.
                OptionsPanel.settings.LogImmigrants = isChecked;
                Configuration <SettingsFile> .Save();

                Logging.Message("immigrant logging ", OptionsPanel.settings.LogImmigrants ? "enabled" : "disabled");
            };

            UICheckBox transportCheckBox = PanelUtils.AddPlainCheckBox(modTab, Translations.Translate("LBR_SET_LGT"));

            transportCheckBox.isChecked          = OptionsPanel.settings.LogTransport;
            transportCheckBox.eventCheckChanged += (control, isChecked) =>
            {
                // Update mod settings.
                Logging.UseTransportLog = isChecked;

                // Update configuration file.
                OptionsPanel.settings.LogTransport = isChecked;
                Configuration <SettingsFile> .Save();

                Logging.Message("transport choices logging ", OptionsPanel.settings.LogTransport ? "enabled" : "disabled");
            };

            UICheckBox sicknessCheckBox = PanelUtils.AddPlainCheckBox(modTab, Translations.Translate("LBR_SET_LGS"));

            sicknessCheckBox.isChecked          = OptionsPanel.settings.LogSickness;
            sicknessCheckBox.eventCheckChanged += (control, isChecked) =>
            {
                // Update mod settings.
                Logging.UseSicknessLog = isChecked;

                // Update configuration file.
                OptionsPanel.settings.LogSickness = isChecked;
                Configuration <SettingsFile> .Save();

                Logging.Message("sickness logging ", OptionsPanel.settings.LogSickness ? "enabled" : "disabled");
            };
        }
예제 #2
0
        /// <summary>
        /// Adds calculation options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        public CalculationOptions(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab.
            UIPanel calculationsTab = PanelUtils.AddTab(tabStrip, Translations.Translate("LBR_SPN"), tabIndex, true);

            // Add warning text message.
            PanelUtils.AddLabel(calculationsTab, Translations.Translate("LBR_SPN_WRN") + "\r\n" + Translations.Translate("LBR_SPN_BAL") + "\r\n" + Translations.Translate("LBR_SPN_BAK"));

            // Calculation models.
            PanelUtils.AddPanelSpacer(calculationsTab);
            PanelUtils.AddLabel(calculationsTab, Translations.Translate("LBR_CAL"), 1.3f);

            sunsetCheckBox            = PanelUtils.AddPlainCheckBox(calculationsTab, Translations.Translate("LBR_CAL_SUN"));
            sunsetCheckBox.isChecked  = !OptionsPanel.settings.UseLegacy;
            legacyCheckBox            = PanelUtils.AddPlainCheckBox(calculationsTab, Translations.Translate("LBR_CAL_LEG"));
            legacyCheckBox.isChecked  = OptionsPanel.settings.UseLegacy;
            vanillaCheckBox           = PanelUtils.AddPlainCheckBox(calculationsTab, Translations.Translate("LBR_CAL_VAN"));
            vanillaCheckBox.isChecked = OptionsPanel.settings.UseVanilla;

            // Custom retirement ages.
            PanelUtils.AddPanelSpacer(calculationsTab);
            PanelUtils.AddLabel(calculationsTab, Translations.Translate("LBR_RET"), 1.3f);

            retireCheckBox           = PanelUtils.AddPlainCheckBox(calculationsTab, Translations.Translate("LBR_RET_USE"));
            retireCheckBox.isChecked = OptionsPanel.settings.CustomRetirement;

            ageDropDown = PanelUtils.AddPlainDropDown(calculationsTab, Translations.Translate("LBR_RET_CUS"), retirementAges, (OptionsPanel.settings.RetirementYear - 50) / 5);
            ageDropDown.eventSelectedIndexChanged += (control, index) =>
            {
                int ageYears = 50 + (index * 5);

                // Update mod settings.
                ModSettings.RetirementYear = ageYears;

                // Update configuration file.
                OptionsPanel.settings.RetirementYear = ageYears;
                Configuration <SettingsFile> .Save();
            };

            // Add enabled/disabled event handler to age dropdown to repopulate items on re-enabling.
            ageDropDown.eventIsEnabledChanged += (control, isEnabled) =>
            {
                if (isEnabled)
                {
                    ageDropDown.items         = retirementAges;
                    ageDropDown.selectedIndex = (OptionsPanel.settings.RetirementYear - 50) / 5;
                }
            };

            UILabel retireNote1 = PanelUtils.AddLabel(calculationsTab, Translations.Translate("LBR_RET_NT1"));
            UILabel retireNote2 = PanelUtils.AddLabel(calculationsTab, Translations.Translate("LBR_RET_NT2"));

            // Event handlers (here so other controls referenced are all set up prior to referencing in handlers).
            sunsetCheckBox.eventCheckChanged += (control, isChecked) =>
            {
                if (isChecked)
                {
                    // If this has been checked, update group checkboxes and set configuration - index for this checkbox is 0.
                    UpdateCheckboxes(0);
                }
                else if (!legacyCheckBox.isChecked && !vanillaCheckBox.isChecked)
                {
                    // This has been unchecked when no others have been selected; reset it and make no changes.
                    sunsetCheckBox.isChecked = true;
                }
            };

            legacyCheckBox.eventCheckChanged += (control, isChecked) =>
            {
                if (isChecked)
                {
                    // If this has been checked, update group checkboxes and set configuration - index for this checkbox is 1.
                    UpdateCheckboxes(1);
                }
                else if (!sunsetCheckBox.isChecked && !vanillaCheckBox.isChecked)
                {
                    // This has been unchecked when no others have been selected; reset it and make no changes.
                    legacyCheckBox.isChecked = true;
                }
            };

            vanillaCheckBox.eventCheckChanged += (control, isChecked) =>
            {
                if (isChecked)
                {
                    // If this has been checked, update group checkboxes and set configuration - index for this checkbox is 2.
                    UpdateCheckboxes(2);
                }
                else if (!sunsetCheckBox.isChecked && !legacyCheckBox.isChecked)
                {
                    // This has been unchecked when no others have been selected; reset it and make no changes.
                    vanillaCheckBox.isChecked = true;
                }
            };

            retireCheckBox.eventCheckChanged += (control, isChecked) =>
            {
                // Update mod settings.
                ModSettings.CustomRetirement = isChecked;

                // Show/hide retirement age dropdown.
                if (isChecked)
                {
                    ageDropDown.Enable();
                }
                else
                {
                    ageDropDown.Disable();
                }

                // Update configuration file.
                OptionsPanel.settings.CustomRetirement = isChecked;
                Configuration <SettingsFile> .Save();
            };

            // Show or hide notes attached to age dropdown to match visibility of dropdown itself.
            ageDropDown.eventIsEnabledChanged += (control, isEnabled) =>
            {
                if (isEnabled)
                {
                    retireNote1.Show();
                    retireNote2.Show();
                    ageDropDown.parent.Show();
                }
                else
                {
                    retireNote1.Hide();
                    retireNote2.Hide();
                    ageDropDown.parent.Hide();
                }
            };

            // Update our visibility status based on current settings.
            UpdateCheckboxes(OptionsPanel.settings.UseVanilla ? 2 : OptionsPanel.settings.UseLegacy ? 1 : 0);
        }
        /// <summary>
        /// Adds calculation options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        public CalculationOptions(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab.
            UIPanel calculationsTab = PanelUtils.AddTab(tabStrip, "Lifespan", tabIndex, true);

            // Add warning text message.
            PanelUtils.AddLabel(calculationsTab, "WARNING:\r\nChanging settings during a game can temporarily disrupt city balance.\r\nSaving a backup before changing is HIGHLY recommended.");

            // Calculation models.
            PanelUtils.AddPanelSpacer(calculationsTab);
            PanelUtils.AddLabel(calculationsTab, "Lifecycle calculation model", 1.3f);

            sunsetCheckBox            = PanelUtils.AddPlainCheckBox(calculationsTab, "Mod Sunset Harbor lifespans (default)");
            sunsetCheckBox.isChecked  = !OptionsPanel.settings.UseLegacy;
            legacyCheckBox            = PanelUtils.AddPlainCheckBox(calculationsTab, "Mod legacy lifespans (original WG mod) - shorter lifespans, fewer seniors");
            legacyCheckBox.isChecked  = OptionsPanel.settings.UseLegacy;
            vanillaCheckBox           = PanelUtils.AddPlainCheckBox(calculationsTab, "Vanilla Sunset Harbor lifespans - less variable lifespans, slightly more seniors");
            vanillaCheckBox.isChecked = OptionsPanel.settings.UseVanilla;

            // Custom retirement ages.
            PanelUtils.AddPanelSpacer(calculationsTab);
            PanelUtils.AddLabel(calculationsTab, "Retirement age options (only when using mod's Sunset Harbor lifespans)", 1.3f);

            retireCheckBox           = PanelUtils.AddPlainCheckBox(calculationsTab, "Use custom retirement age");
            retireCheckBox.isChecked = OptionsPanel.settings.CustomRetirement;

            ageDropDown = PanelUtils.AddPlainDropDown(calculationsTab, "Custom retirement age", retirementAges, (OptionsPanel.settings.RetirementYear - 50) / 5);
            ageDropDown.eventSelectedIndexChanged += (control, index) =>
            {
                int ageYears = 50 + (index * 5);

                // Update mod settings.
                ModSettings.RetirementYear = ageYears;

                // Update configuration file.
                OptionsPanel.settings.RetirementYear = ageYears;
                Configuration <SettingsFile> .Save();
            };

            // Add enabled/disabled event handler to age dropdown to repopulate items on re-enabling.
            ageDropDown.eventIsEnabledChanged += (control, isEnabled) =>
            {
                if (isEnabled)
                {
                    ageDropDown.items         = retirementAges;
                    ageDropDown.selectedIndex = (OptionsPanel.settings.RetirementYear - 50) / 5;
                }
            };

            UILabel retireNote1 = PanelUtils.AddLabel(calculationsTab, "Decreasing retirement age won't change the status of citizens who have already retired under previous settings.");
            UILabel retireNote2 = PanelUtils.AddLabel(calculationsTab, "Increasing retirement age won't change the appearance of citzens who have already retired under previous settings.");

            // Event handlers (here so other controls referenced are all set up prior to referencing in handlers).
            sunsetCheckBox.eventCheckChanged += (control, isChecked) =>
            {
                if (isChecked)
                {
                    // If this has been checked, update group checkboxes and set configuration - index for this checkbox is 0.
                    UpdateCheckboxes(0);
                }
                else if (!legacyCheckBox.isChecked && !vanillaCheckBox.isChecked)
                {
                    // This has been unchecked when no others have been selected; reset it and make no changes.
                    sunsetCheckBox.isChecked = true;
                }
            };

            legacyCheckBox.eventCheckChanged += (control, isChecked) =>
            {
                if (isChecked)
                {
                    // If this has been checked, update group checkboxes and set configuration - index for this checkbox is 1.
                    UpdateCheckboxes(1);
                }
                else if (!sunsetCheckBox.isChecked && !vanillaCheckBox.isChecked)
                {
                    // This has been unchecked when no others have been selected; reset it and make no changes.
                    legacyCheckBox.isChecked = true;
                }
            };

            vanillaCheckBox.eventCheckChanged += (control, isChecked) =>
            {
                if (isChecked)
                {
                    // If this has been checked, update group checkboxes and set configuration - index for this checkbox is 2.
                    UpdateCheckboxes(2);
                }
                else if (!sunsetCheckBox.isChecked && !legacyCheckBox.isChecked)
                {
                    // This has been unchecked when no others have been selected; reset it and make no changes.
                    vanillaCheckBox.isChecked = true;
                }
            };

            retireCheckBox.eventCheckChanged += (control, isChecked) =>
            {
                // Update mod settings.
                ModSettings.CustomRetirement = isChecked;

                // Show/hide retirement age dropdown.
                if (isChecked)
                {
                    ageDropDown.Enable();
                }
                else
                {
                    ageDropDown.Disable();
                }

                // Update configuration file.
                OptionsPanel.settings.CustomRetirement = isChecked;
                Configuration <SettingsFile> .Save();
            };

            // Show or hide notes attached to age dropdown to match visibility of dropdown itself.
            ageDropDown.eventIsEnabledChanged += (control, isEnabled) =>
            {
                if (isEnabled)
                {
                    retireNote1.Show();
                    retireNote2.Show();
                    ageDropDown.parent.Show();
                }
                else
                {
                    retireNote1.Hide();
                    retireNote2.Hide();
                    ageDropDown.parent.Hide();
                }
            };

            // Update our visibility status based on current settings.
            UpdateCheckboxes(OptionsPanel.settings.UseVanilla ? 2 : OptionsPanel.settings.UseLegacy ? 1 : 0);
        }