/// <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); }