/// <summary> /// Adds immigration options tab to tabstrip. /// </summary> /// <param name="tabStrip">Tab strip to add to</param> /// <param name="tabIndex">Index number of tab</param> public ImmigrationOptions(UITabstrip tabStrip, int tabIndex) { // Add tab. UIPanel immigrationTab = PanelUtils.AddTab(tabStrip, "Immigration", tabIndex); // Use vanilla. UICheckBox immigrationCheckBox = PanelUtils.AddPlainCheckBox(immigrationTab, "Apply 25% variation to immigrant education levels (game default off, mod default on)"); immigrationCheckBox.relativePosition = new Vector3(5f, 5f); immigrationCheckBox.isChecked = OptionsPanel.settings.RandomImmigrantEd; immigrationCheckBox.eventCheckChanged += (control, isChecked) => { // Update mod settings. ModSettings.UseTransportModes = isChecked; // Update configuration file. OptionsPanel.settings.RandomImmigrantEd = isChecked; Configuration <SettingsFile> .Save(); }; }
/// <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 death options tab to tabstrip. /// </summary> /// <param name="tabStrip">Tab strip to add to</param> /// <param name="tabIndex">Index number of tab</param> public TransportOptions(UITabstrip tabStrip, int tabIndex) { // Add tab. UIPanel transportTab = PanelUtils.AddTab(tabStrip, Translations.Translate("LBR_TRN"), tabIndex, true); transportTab.autoLayout = false; UICheckBox transportCheckBox = PanelUtils.AddPlainCheckBox(transportTab, Translations.Translate("LBR_TRN_CUS")); transportCheckBox.relativePosition = new Vector3(30f, 5f); transportCheckBox.isChecked = OptionsPanel.settings.UseTransportModes; transportCheckBox.eventCheckChanged += (control, isChecked) => { // Update mod settings. ModSettings.UseTransportModes = isChecked; // Update configuration file. OptionsPanel.settings.UseTransportModes = isChecked; Configuration <SettingsFile> .Save(); }; // Set up textfield arrays; low/high density. wealthLow = new UITextField[NumDensity][][]; wealthMed = new UITextField[NumDensity][][]; wealthHigh = new UITextField[NumDensity][][]; ecoWealthLow = new UITextField[NumDensity][][]; ecoWealthMed = new UITextField[NumDensity][][]; ecoWealthHigh = new UITextField[NumDensity][][]; // Second level of textfield arrays; age groups. for (int i = 0; i < NumDensity; ++i) { wealthLow[i] = new UITextField[NumAges][]; wealthMed[i] = new UITextField[NumAges][]; wealthHigh[i] = new UITextField[NumAges][]; ecoWealthLow[i] = new UITextField[NumAges][]; ecoWealthMed[i] = new UITextField[NumAges][]; ecoWealthHigh[i] = new UITextField[NumAges][]; // Third level of textfield arrays; transport modes. for (int j = 0; j < NumAges; ++j) { wealthLow[i][j] = new UITextField[NumTransport]; wealthMed[i][j] = new UITextField[NumTransport]; wealthHigh[i][j] = new UITextField[NumTransport]; ecoWealthLow[i][j] = new UITextField[NumTransport]; ecoWealthMed[i][j] = new UITextField[NumTransport]; ecoWealthHigh[i][j] = new UITextField[NumTransport]; } } // Headings. for (int i = 0; i < NumWealth; ++i) { // Wealth headings. float wealthX = (i * GroupWidth) + Column1; WealthIcon(transportTab, wealthX, 25f, ColumnWidth * 3, i + 1, Translations.Translate("LBR_TRN_WEA"), "InfoIconLandValue"); // Transport mode headings. ColumnIcon(transportTab, (i * GroupWidth) + Column1, ColumnIconHeight, FieldWidth, Translations.Translate("LBR_TRN_CAR"), "InfoIconTrafficCongestion"); ColumnIcon(transportTab, (i * GroupWidth) + Column2, ColumnIconHeight, FieldWidth, Translations.Translate("LBR_TRN_BIK"), "IconPolicyEncourageBiking"); ColumnIcon(transportTab, (i * GroupWidth) + Column3, ColumnIconHeight, FieldWidth, Translations.Translate("LBR_TRN_TAX"), "SubBarPublicTransportTaxi"); } // Rows by group. RowHeaderIcon(transportTab, currentY, Translations.Translate("LBR_TRN_RLO"), "ZoningResidentialLow", "Thumbnails"); AddDensityGroup(transportTab, wealthLow[0], wealthMed[0], wealthHigh[0]); RowHeaderIcon(transportTab, currentY, Translations.Translate("LBR_TRN_RHI"), "ZoningResidentialHigh", "Thumbnails"); AddDensityGroup(transportTab, wealthLow[1], wealthMed[1], wealthHigh[1]); RowHeaderIcon(transportTab, currentY, Translations.Translate("LBR_TRN_ERL"), "IconPolicySelfsufficient", "Ingame"); AddDensityGroup(transportTab, ecoWealthLow[0], ecoWealthMed[0], ecoWealthHigh[0]); RowHeaderIcon(transportTab, currentY, Translations.Translate("LBR_TRN_ERH"), "IconPolicySelfsufficient", "Ingame"); AddDensityGroup(transportTab, ecoWealthLow[1], ecoWealthMed[1], ecoWealthHigh[1]); // Buttons. AddButtons(transportTab); // Populate text fields. PopulateFields(); }
/// <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"); }; }
/// <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); }
/// <summary> /// Adds immigration options tab to tabstrip. /// </summary> /// <param name="tabStrip">Tab strip to add to</param> /// <param name="tabIndex">Index number of tab</param> public ImmigrationOptions(UITabstrip tabStrip, int tabIndex) { // Add tab. UIPanel immigrationTab = PanelUtils.AddTab(tabStrip, Translations.Translate("LBR_IMM"), tabIndex); // Use vanilla. UICheckBox immigrationCheckBox = PanelUtils.AddPlainCheckBox(immigrationTab, Translations.Translate("LBR_IMM_VAR")); immigrationCheckBox.relativePosition = new Vector3(5f, 5f); immigrationCheckBox.isChecked = OptionsPanel.settings.RandomImmigrantEd; immigrationCheckBox.eventCheckChanged += (control, isChecked) => { // Update mod settings. ModSettings.UseTransportModes = isChecked; // Update configuration file. OptionsPanel.settings.RandomImmigrantEd = isChecked; Configuration <SettingsFile> .Save(); }; // Boost immigrant education. UICheckBox immiEduBoostCheck = PanelUtils.AddPlainCheckBox(immigrationTab, Translations.Translate("LBR_IMM_INC")); immiEduBoostCheck.relativePosition = new Vector3(5f, 50f); immiEduBoostCheck.isChecked = ModSettings.immiEduBoost; // Suppress immigrant education. UICheckBox immiEduDragCheck = PanelUtils.AddPlainCheckBox(immigrationTab, Translations.Translate("LBR_IMM_DEC")); immiEduDragCheck.relativePosition = new Vector3(5f, 75f); immiEduDragCheck.isChecked = ModSettings.immiEduDrag; immiEduBoostCheck.eventCheckChanged += (control, isChecked) => { // Update mod settings. ModSettings.immiEduBoost = isChecked; // Toggle immigrant boost check if needed. if (isChecked && immiEduDragCheck.isChecked) { immiEduDragCheck.isChecked = false; } // Update configuration file. Configuration <SettingsFile> .Save(); }; immiEduDragCheck.eventCheckChanged += (control, isChecked) => { // Update mod settings. ModSettings.immiEduDrag = isChecked; // Toggle immigrant boost check if needed. if (isChecked && immiEduBoostCheck.isChecked) { immiEduBoostCheck.isChecked = false; } // Update configuration file. Configuration <SettingsFile> .Save(); }; }
/// <summary> /// Adds logging options tab to tabstrip. /// </summary /// <param name="tabStrip">Tab strip to add to</param> /// <param name="tabIndex">Index number of tab</param> public LoggingOptions(UITabstrip tabStrip, int tabIndex) { // Add tab. UIPanel loggingTab = PanelUtils.AddTab(tabStrip, "Logging", tabIndex, true); // Logging options. UICheckBox deathCheckBox = PanelUtils.AddPlainCheckBox(loggingTab, "Log deaths to 'Lifecycle death log.txt'"); deathCheckBox.isChecked = OptionsPanel.settings.LogDeaths; deathCheckBox.eventCheckChanged += (control, isChecked) => { // Update mod settings. Debugging.UseDeathLog = isChecked; // Update configuration file. OptionsPanel.settings.LogDeaths = isChecked; Configuration <SettingsFile> .Save(); Debugging.Message("death logging " + (OptionsPanel.settings.LogDeaths ? "enabled" : "disabled")); }; UICheckBox immigrantCheckBox = PanelUtils.AddPlainCheckBox(loggingTab, "Log immigrants to 'Lifecycle immigration log.txt'"); immigrantCheckBox.isChecked = OptionsPanel.settings.LogImmigrants; immigrantCheckBox.eventCheckChanged += (control, isChecked) => { // Update mod settings. Debugging.UseImmigrationLog = isChecked; // Update configuration file. OptionsPanel.settings.LogImmigrants = isChecked; Configuration <SettingsFile> .Save(); Debugging.Message("immigrant logging " + (OptionsPanel.settings.LogImmigrants ? "enabled" : "disabled")); }; UICheckBox transportCheckBox = PanelUtils.AddPlainCheckBox(loggingTab, "Log custom transport choices to 'Lifecycle transport log.txt' WARNING - SLOW!"); transportCheckBox.isChecked = OptionsPanel.settings.LogTransport; transportCheckBox.eventCheckChanged += (control, isChecked) => { // Update mod settings. Debugging.UseTransportLog = isChecked; // Update configuration file. OptionsPanel.settings.LogTransport = isChecked; Configuration <SettingsFile> .Save(); Debugging.Message("transport choices logging " + (OptionsPanel.settings.LogTransport ? "enabled" : "disabled")); }; UICheckBox sicknessCheckBox = PanelUtils.AddPlainCheckBox(loggingTab, "Log sickness events to 'Lifecycle sickness log.txt'"); sicknessCheckBox.isChecked = OptionsPanel.settings.LogSickness; sicknessCheckBox.eventCheckChanged += (control, isChecked) => { // Update mod settings. Debugging.UseSicknessLog = isChecked; // Update configuration file. OptionsPanel.settings.LogSickness = isChecked; Configuration <SettingsFile> .Save(); Debugging.Message("sickness logging " + (OptionsPanel.settings.LogSickness ? "enabled" : "disabled")); }; }