/// <summary>
        /// Called by the game when level loading is complete.
        /// </summary>
        /// <param name="mode">Loading mode (e.g. game, editor, scenario, etc.)</param>
        public override void OnLevelLoaded(LoadMode mode)
        {
            base.OnLevelLoaded(mode);

            // Check to see that Harmony 2 was properly loaded.
            if (!harmonyLoaded)
            {
                // Harmony 2 wasn't loaded; display warning notification and exit.
                ListMessageBox harmonyBox = MessageBoxBase.ShowModal <ListMessageBox>();

                // Key text items.
                harmonyBox.AddParas(Translations.Translate("ERR_HAR0"), Translations.Translate("PRR_ERR_HAR"), Translations.Translate("PRR_ERR_FAT"), Translations.Translate("ERR_HAR1"));

                // List of dot points.
                harmonyBox.AddList(Translations.Translate("ERR_HAR2"), Translations.Translate("ERR_HAR3"));

                // Closing para.
                harmonyBox.AddParas(Translations.Translate("MES_PAGE"));
            }

            // Check to see if a conflicting mod has been detected.
            if (conflictingMod)
            {
                // Mod conflict detected - display warning notification and exit.
                ListMessageBox modConflictBox = MessageBoxBase.ShowModal <ListMessageBox>();

                // Key text items.
                modConflictBox.AddParas(Translations.Translate("ERR_CON0"), Translations.Translate("PRR_ERR_CON0"), Translations.Translate("PRR_ERR_FAT"), Translations.Translate("ERR_CON1"));

                // Add conflicting mod name(s).
                modConflictBox.AddList(ModUtils.conflictingModNames.ToArray());

                // Closing para.
                modConflictBox.AddParas(Translations.Translate("PRR_ERR_CON1"));
            }
        }
        /// <summary>
        /// Create the update notification panel; called by Unity just before any of the Update methods is called for the first time.
        /// </summary>
        public override void Start()
        {
            // Add text.
            headerText  = Translations.Translate("PRR_UPD_21_0");
            messageText = Translations.Translate("PRR_UPD_21_1");
            listText    = Translations.Translate("PRR_UPD_21_2") + "\r\n\r\n" + Translations.Translate("PRR_UPD_21_3") + "\r\n\r\n" + Translations.Translate("PRR_UPD_21_4") + "\r\n\r\n" + Translations.Translate("PRR_UPD_21_5");

            base.Start();

            try
            {
                // "Don't show again" button.
                UIButton noShowButton = CreateButton(this);
                noShowButton.relativePosition = new Vector3(this.width - noShowButton.width - spacing, this.height - noShowButton.height - spacing);
                noShowButton.text             = "Don't show again";
                noShowButton.Enable();

                // Event handler.
                noShowButton.eventClick += (control, clickEvent) =>
                {
                    // Update and save settings file.
                    Loading.settingsFile.NotificationVersion = 2;
                    Configuration <SettingsFile> .Save();

                    // Just hide this panel and destroy the game object - nothing more to do.
                    this.Hide();
                    GameObject.Destroy(uiGameObject);
                };
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogException(e);
            }
        }
        /// <summary>
        /// Draws the Ploppable Tool panel.
        /// </summary>
        private void DrawPloppablePanel()
        {
            // Check to make sure that we haven't already done this.
            if (PloppableButton == null)
            {
                // Set state flag; this is a new setup.
                hasShown = false;

                // Main button on ingame toolbar.
                PloppableButton                  = UIView.GetAView().FindUIComponent <UITabstrip>("MainToolstrip").AddUIComponent <UIButton>();
                PloppableButton.size             = new Vector2(43, 49);
                PloppableButton.normalBgSprite   = "ToolbarIconGroup6Normal";
                PloppableButton.normalFgSprite   = "IconPolicyBigBusiness";
                PloppableButton.focusedBgSprite  = "ToolbarIconGroup6Focused";
                PloppableButton.hoveredBgSprite  = "ToolbarIconGroup6Hovered";
                PloppableButton.pressedBgSprite  = "ToolbarIconGroup6Pressed";
                PloppableButton.disabledBgSprite = "ToolbarIconGroup6Disabled";
                PloppableButton.relativePosition = new Vector2(800, 0);
                PloppableButton.name             = "PloppableButton";
                PloppableButton.tooltip          = Translations.Translate("PRR_NAME");

                // Event handler - show the Ploppable Tool panel when the button is clicked.
                PloppableButton.eventClick += (component, clickEvent) =>
                {
                    component.Focus();
                    buildingPanel.isVisible = true;
                };

                // Base panel.
                buildingPanel = UIView.GetAView().FindUIComponent("TSContainer").AddUIComponent <UIPanel>();
                buildingPanel.backgroundSprite = "SubcategoriesPanel";
                buildingPanel.isVisible        = false;
                buildingPanel.name             = "PloppableBuildingPanel";
                buildingPanel.size             = new Vector2(859, 109);
                buildingPanel.relativePosition = new Vector2(0, 0);

                // Tabstrip.
                Tabs                  = UIView.GetAView().FindUIComponent("PloppableBuildingPanel").AddUIComponent <UITabstrip>();
                Tabs.size             = new Vector2(832, 25);
                Tabs.relativePosition = new Vector2(13, -25);
                Tabs.pivot            = UIPivotPoint.BottomCenter;
                Tabs.padding          = new RectOffset(0, 3, 0, 0);

                // Get game sprite thumbnail atlas.
                UITextureAtlas gameIconAtlas = Resources.FindObjectsOfTypeAll <UITextureAtlas>().FirstOrDefault(a => a.name == "Thumbnails");

                // Scroll panel.
                AddScrollPanel();

                // Tabs.
                for (int i = 0; i <= NumTypes; i++)
                {
                    // Draw tabs in tabstrip.
                    TabButtons[i]                  = new UIButton();
                    TabButtons[i]                  = Tabs.AddUIComponent <UIButton>();
                    TabButtons[i].size             = new Vector2(46, 25);
                    TabButtons[i].normalBgSprite   = "SubBarButtonBase";
                    TabButtons[i].disabledBgSprite = "SubBarButtonBaseDisabled";
                    TabButtons[i].pressedBgSprite  = "SubBarButtonBasePressed";
                    TabButtons[i].hoveredBgSprite  = "SubBarButtonBaseHovered";
                    TabButtons[i].focusedBgSprite  = "SubBarButtonBaseFocused";
                    TabButtons[i].state            = UIButton.ButtonState.Normal;
                    TabButtons[i].name             = Names[i] + "Button";
                    TabButtons[i].tabStrip         = true;

                    TabSprites[i] = new UISprite();
                    TabSprites[i] = TabButtons[i].AddUIComponent <UISprite>();

                    // Standard "Vanilla" categories (low and high residential, low and high commercial, and offices) - use standard zoning icons from original vanilla release.
                    if (i <= 5)
                    {
                        TabSprites[i].atlas = gameIconAtlas;
                        SetTabSprite(TabSprites[i], "Zoning" + Names[i]);
                    }
                    else
                    {
                        // Other types don't have standard zoning icons; use policy icons instead.
                        SetTabSprite(TabSprites[i], "IconPolicy" + Names[i]);
                    }
                }

                // This can't happen in a loop, because the loop index is undefined after setup has occured (i.e. when the function is actually called).
                TabButtons[0].eventClick += (component, clickEvent) => TabClicked(0, TabSprites[0]);
                TabButtons[1].eventClick += (component, clickEvent) => TabClicked(1, TabSprites[1]);
                TabButtons[2].eventClick += (component, clickEvent) => TabClicked(2, TabSprites[2]);
                TabButtons[3].eventClick += (component, clickEvent) => TabClicked(3, TabSprites[3]);
                TabButtons[4].eventClick += (component, clickEvent) => TabClicked(4, TabSprites[4]);
                TabButtons[5].eventClick += (component, clickEvent) => TabClicked(5, TabSprites[5]);
                TabButtons[6].eventClick += (component, clickEvent) => TabClicked(6, TabSprites[6]);
                TabButtons[7].eventClick += (component, clickEvent) => TabClicked(7, TabSprites[7]);
                TabButtons[8].eventClick += (component, clickEvent) => TabClicked(8, TabSprites[8]);
                TabButtons[9].eventClick += (component, clickEvent) => TabClicked(9, TabSprites[9]);
                // Below are DLC categories - AD for first two, then GC for next 3.  Will be hidden if relevant DLC is not installed.
                TabButtons[10].eventClick += (component, clickEvent) => TabClicked(10, TabSprites[10]);
                TabButtons[11].eventClick += (component, clickEvent) => TabClicked(11, TabSprites[11]);
                TabButtons[12].eventClick += (component, clickEvent) => TabClicked(12, TabSprites[12]);
                TabButtons[13].eventClick += (component, clickEvent) => TabClicked(13, TabSprites[13]);
                TabButtons[14].eventClick += (component, clickEvent) => TabClicked(14, TabSprites[14]);

                // Activate low residential panel to start with (what the user sees on first opening the panel).
                //BuildingPanels[0].isVisible = true;

                // Hide AD tabs if AD is not installed.
                if (!Util.isADinstalled())
                {
                    TabButtons[10].isVisible = false;
                    TabButtons[11].isVisible = false;
                }

                // Hide GC tabs if GC is not installed.
                if (!Util.isGCinstalled())
                {
                    TabButtons[12].isVisible = false;
                    TabButtons[13].isVisible = false;
                    TabButtons[14].isVisible = false;
                }

                // Settings tab.
                showSettings                = UIUtils.CreateButton(Tabs);
                showSettings.size           = new Vector2(100, 25);
                showSettings.normalBgSprite = "SubBarButtonBase";
                showSettings.eventClick    += (component, clickEvent) =>
                {
                    SettingsPanel.Open(scrollPanel?.selectedItem?.prefab);
                };

                // Add UI text.
                SetText();


                // Toggle active state on visibility changed if we're using the UI speed boost (deactivating when hidden to minimise UI workload and impact on performance).
                buildingPanel.eventVisibilityChanged += (component, isVisible) =>
                {
                    // Additional check to allow for the case where speedboost has been deactivated mid-game while the panel was deactivated.
                    if ((ModSettings.speedBoost) || (isVisible && !buildingPanel.gameObject.activeSelf))
                    {
                        buildingPanel.gameObject.SetActive(isVisible);
                    }

                    // Other checks.
                    if (isVisible)
                    {
                        // If this is the first time we're visible, set the display to the initial default tab (low residential).
                        if (!hasShown)
                        {
                            // Set initial default tab.
                            TabClicked(0, _instance.TabSprites[0]);

                            // Done!
                            hasShown = true;
                        }
                        else
                        {
                            // Clear previous selection and refresh panel.
                            scrollPanel.selectedItem = null;
                            scrollPanel.Refresh();
                        }
                    }
                    else
                    {
                        // Destroy thumbnail renderer if we're no longer visible.
                        ThumbnailManager.Close();
                    }
                };
            }
        }
Пример #4
0
        /// <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>
        internal ModOptions(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab and helper.
            UIPanel  panel  = PanelUtils.AddTab(tabStrip, Translations.Translate("PRR_OPTION_MOD"), tabIndex, true);
            UIHelper helper = new UIHelper(panel);


            UIDropDown translationDropDown = (UIDropDown)helper.AddDropdown(Translations.Translate("TRN_CHOICE"), Translations.LanguageList, Translations.Index, (value) =>
            {
                Translations.Index = value;
                OptionsPanel.LocaleChanged();
            });

            translationDropDown.autoSize = false;
            translationDropDown.width    = 270f;

            // Game options.

            /*UIHelperBase gameGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_LOA"));
             *
             * // Add reset on load checkbox.
             * gameGroup.AddCheckbox(Translations.Translate("PRR_OPTION_FORCERESET"), ModSettings.resetOnLoad, isChecked =>
             * {
             *  ModSettings.resetOnLoad = isChecked;
             *  SettingsUtils.SaveSettings();
             * });*/

            // Notification options.
            UIHelperBase notificationGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_NOT"));

            // Add logging checkbox.
            notificationGroup.AddCheckbox(Translations.Translate("PRR_OPTION_WHATSNEW"), ModSettings.showWhatsNew, isChecked =>
            {
                ModSettings.showWhatsNew = isChecked;
            });

            // Logging options.
            UIHelperBase logGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_LOG"));

            // Add logging checkbox.
            logGroup.AddCheckbox(Translations.Translate("PRR_OPTION_MOREDEBUG"), Logging.detailLogging, isChecked =>
            {
                Logging.detailLogging = isChecked;
            });

            // Thumbnail options.
            UIHelperBase thumbGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_TMB"));

            // Add thumbnail background dropdown.
            thumbGroup.AddDropdown(Translations.Translate("PRR_OPTION_THUMBACK"), ModSettings.ThumbBackNames, ModSettings.thumbBacks, (value) =>
            {
                ModSettings.thumbBacks = value;
            });

            // Add regenerate thumbnails button.
            thumbGroup.AddButton(Translations.Translate("PRR_OPTION_REGENTHUMBS"), () => PloppableTool.Instance.RegenerateThumbnails());

            // Add speed boost checkbox.
            UIHelperBase speedGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_SPDHDR"));

            speedGroup.AddCheckbox(Translations.Translate("PRR_OPTION_SPEED"), ModSettings.speedBoost, isChecked =>
            {
                ModSettings.speedBoost = isChecked;
            });
        }
Пример #5
0
        /// <summary>
        /// Adds growable options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        internal GrowableOptions(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab and helper.
            UIPanel  panel  = PanelUtils.AddTab(tabStrip, Translations.Translate("PRR_OPTION_GRO"), tabIndex);
            UIHelper helper = new UIHelper(panel);

            panel.autoLayout = true;

            // Add plop growables checkboxes.
            UIHelperBase plopGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_PLP"));

            plopGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RGR"), ModSettings.plopRico, isChecked =>
            {
                ModSettings.plopRico = isChecked;
                SettingsUtils.SaveSettings();
            });
            plopGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.plopOther, isChecked =>
            {
                ModSettings.plopOther = isChecked;
                SettingsUtils.SaveSettings();
            });

            // Add no zone checks checkboxes.
            UIHelperBase zoneGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_ZON"));

            zoneGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RGR"), ModSettings.noZonesRico, isChecked =>
            {
                ModSettings.noZonesRico = isChecked;
                SettingsUtils.SaveSettings();
            });
            zoneGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.noZonesOther, isChecked =>
            {
                ModSettings.noZonesOther = isChecked;
                SettingsUtils.SaveSettings();
            });

            // Add no specialisation checks checkboxes.
            UIHelperBase specGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_SPC"));

            specGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RGR"), ModSettings.noSpecRico, isChecked =>
            {
                ModSettings.noSpecRico = isChecked;
                SettingsUtils.SaveSettings();
            });
            specGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.noSpecOther, isChecked =>
            {
                ModSettings.noSpecOther = isChecked;
                SettingsUtils.SaveSettings();
            });

            // Add 'make plopped growables historical' checkboxes.
            UIHelperBase histGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_HST"));

            histGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RGR"), ModSettings.historicalRico, isChecked =>
            {
                ModSettings.historicalRico = isChecked;
                SettingsUtils.SaveSettings();
            });
            histGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.historicalOther, isChecked =>
            {
                ModSettings.historicalOther = isChecked;
                SettingsUtils.SaveSettings();
            });
        }
Пример #6
0
        /// <summary>
        /// Adds growable options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        internal GrowableOptions(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab and helper.
            UIPanel  panel  = PanelUtils.AddTab(tabStrip, Translations.Translate("PRR_OPTION_GRO"), tabIndex, true);
            UIHelper helper = new UIHelper(panel);

            // Add plop growables checkboxes.
            UIHelperBase plopGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_PLP"));

            plopGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RGR"), ModSettings.plopRico, isChecked =>
            {
                ModSettings.plopRico = isChecked;
            });
            plopGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.plopOther, isChecked =>
            {
                ModSettings.plopOther = isChecked;
            });

            // Add no zone checks checkboxes.
            UIHelperBase zoneGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_ZON"));

            zoneGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RGR"), ModSettings.noZonesRico, isChecked =>
            {
                ModSettings.noZonesRico = isChecked;
            });
            zoneGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.noZonesOther, isChecked =>
            {
                ModSettings.noZonesOther = isChecked;
            });

            // Add no specialisation checks checkboxes.
            UIHelperBase specGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_SPC"));

            specGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RGR"), ModSettings.noSpecRico, isChecked =>
            {
                ModSettings.noSpecRico = isChecked;
            });
            specGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.noSpecOther, isChecked =>
            {
                ModSettings.noSpecOther = isChecked;
            });

            // Add 'make plopped growables historical' checkboxes.
            UIHelperBase histGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_HST"));

            histGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RGR"), ModSettings.historicalRico, isChecked =>
            {
                ModSettings.historicalRico = isChecked;
            });
            histGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.historicalOther, isChecked =>
            {
                ModSettings.historicalOther = isChecked;
            });

            // Add level control checkboxes.
            UIHelperBase levelGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_BLC"));

            // If we haven't already, check for Advanced Building Level Control.
            if (ModUtils.ablcLockBuildingLevel == null)
            {
                ModUtils.ABLCReflection();
            }

            // Is it (still) null?
            if (ModUtils.ablcLockBuildingLevel != null)
            {
                // ABLC installed; display checkboxes.
                levelGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RGR"), ModSettings.lockLevelRico, isChecked =>
                {
                    ModSettings.lockLevelRico = isChecked;
                });
                levelGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.lockLevelOther, isChecked =>
                {
                    ModSettings.lockLevelOther = isChecked;
                });
            }

            // Add 'disable style despawn' checkbox.
            UIHelperBase styleGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_STY"));

            styleGroup.AddCheckbox(Translations.Translate("PRR_OPTION_STR"), PrivateBuildingSimStep.disableStyleDespawn, isChecked =>
            {
                PrivateBuildingSimStep.disableStyleDespawn = isChecked;
            });
        }
Пример #7
0
        /// <summary>
        /// Adds growable options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        internal PloppableOptions(UITabstrip tabStrip, int tabIndex)
        {
            // Y position indicator.
            float currentY     = Margin;
            int   tabbingIndex = 0;

            // Add tab and helper.
            UIPanel panel = PanelUtils.AddTab(tabStrip, Translations.Translate("PRR_OPTION_PLO"), tabIndex, false);

            // Demolition options.
            UILabel demolishLabel = UIControls.AddLabel(panel, TitleMarginX, currentY, Translations.Translate("PRR_OPTION_DEM"), textScale: 1.125f);

            demolishLabel.font     = Resources.FindObjectsOfTypeAll <UIFont>().FirstOrDefault((UIFont f) => f.name == "OpenSans-Semibold");
            demolishLabel.tabIndex = ++tabbingIndex;
            currentY += demolishLabel.height + TitleMarginY;

            // Add 'warn if bulldozing ploppables' checkbox.
            UICheckBox demolishWarnCheck = UIControls.AddPlainCheckBox(panel, Translations.Translate("PRR_OPTION_BDZ"));

            demolishWarnCheck.relativePosition   = new Vector2(LeftMargin, currentY);
            demolishWarnCheck.isChecked          = ModSettings.warnBulldoze;
            demolishWarnCheck.eventCheckChanged += DemolishWarnCheckChanged;
            demolishWarnCheck.tabIndex           = ++tabbingIndex;
            currentY += CheckRowHeight + Margin;

            // Add auto-demolish checkbox.
            UICheckBox demolishAutoCheck = UIControls.AddPlainCheckBox(panel, Translations.Translate("PRR_OPTION_IMP"));

            demolishAutoCheck.relativePosition   = new Vector2(LeftMargin, currentY);
            demolishAutoCheck.isChecked          = ModSettings.autoDemolish;
            demolishAutoCheck.tabIndex           = ++tabbingIndex;
            demolishAutoCheck.eventCheckChanged += DemolishAutoCheckChanged;
            currentY += CheckRowHeight;

            // Auto-demolish sub-label.
            UILabel demolishAutoLabel = UIControls.AddLabel(panel, SubTitleX, currentY, Translations.Translate("PRR_OPTION_IMP2"), textScale: 1.125f);

            demolishAutoLabel.font = Resources.FindObjectsOfTypeAll <UIFont>().FirstOrDefault((UIFont f) => f.name == "OpenSans-Regular");
            currentY += CheckRowHeight + GroupMargin;

            // Cost options.
            UILabel costLabel = UIControls.AddLabel(panel, TitleMarginX, currentY, Translations.Translate("PRR_OPTION_CST"), textScale: 1.125f);

            costLabel.font = Resources.FindObjectsOfTypeAll <UIFont>().FirstOrDefault((UIFont f) => f.name == "OpenSans-Semibold");
            currentY      += costLabel.height + TitleMarginY;

            // Add override cost checkbox.
            UICheckBox overrideCostCheck = UIControls.AddPlainCheckBox(panel, Translations.Translate("PRR_OPTION_COV"));

            overrideCostCheck.relativePosition   = new Vector2(LeftMargin, currentY);
            overrideCostCheck.isChecked          = ModSettings.overrideCost;
            overrideCostCheck.eventCheckChanged += OverrideCostCheckChanged;
            overrideCostCheck.tabIndex           = ++tabbingIndex;
            currentY += CheckRowHeight + Margin;

            // Houshold costs.
            UITextField costPerHouseField     = AddCostTextField(panel, "PRR_OPTION_CPH", ModSettings.costPerHousehold, ref currentY);
            UITextField costMultResLevelField = AddCostTextField(panel, "PRR_OPTION_CHM", ModSettings.costMultResLevel, ref currentY);

            costPerHouseField.eventTextSubmitted     += (control, text) => TextSubmitted(control as UITextField, text, ref ModSettings.costPerHousehold);
            costMultResLevelField.eventTextSubmitted += (control, text) => TextSubmitted(control as UITextField, text, ref ModSettings.costMultResLevel);

            // Workplace costs.
            UITextField costPerJob0Field = AddCostTextField(panel, "PRR_OPTION_CJ0", ModSettings.costPerJob0, ref currentY);
            UITextField costPerJob1Field = AddCostTextField(panel, "PRR_OPTION_CJ1", ModSettings.costPerJob1, ref currentY);
            UITextField costPerJob2Field = AddCostTextField(panel, "PRR_OPTION_CJ2", ModSettings.costPerJob2, ref currentY);
            UITextField costPerJob3Field = AddCostTextField(panel, "PRR_OPTION_CJ3", ModSettings.costPerJob3, ref currentY);

            costPerJob0Field.tabIndex            = ++tabbingIndex;
            costPerJob1Field.tabIndex            = ++tabbingIndex;
            costPerJob2Field.tabIndex            = ++tabbingIndex;
            costPerJob3Field.tabIndex            = ++tabbingIndex;
            costPerJob0Field.eventTextSubmitted += (control, text) => TextSubmitted(control as UITextField, text, ref ModSettings.costPerJob0);
            costPerJob1Field.eventTextSubmitted += (control, text) => TextSubmitted(control as UITextField, text, ref ModSettings.costPerJob1);
            costPerJob2Field.eventTextSubmitted += (control, text) => TextSubmitted(control as UITextField, text, ref ModSettings.costPerJob2);

            // Natural disasters.
            currentY += TitleMarginY;
            UILabel disasterLabel = UIControls.AddLabel(panel, TitleMarginX, currentY, Translations.Translate("PRR_OPTION_DIS"), textScale: 1.125f);

            disasterLabel.font = Resources.FindObjectsOfTypeAll <UIFont>().FirstOrDefault((UIFont f) => f.name == "OpenSans-Semibold");
            currentY          += disasterLabel.height + TitleMarginY;

            // Add auto-demolish checkbox.
            UICheckBox noCollapseCheck = UIControls.AddPlainCheckBox(panel, Translations.Translate("PRR_OPTION_NOC"));

            noCollapseCheck.relativePosition   = new Vector2(LeftMargin, currentY);
            noCollapseCheck.isChecked          = ModSettings.noCollapse;
            noCollapseCheck.tabIndex           = ++tabbingIndex;
            noCollapseCheck.eventCheckChanged += NoCollapseCheckChanged;
            currentY += CheckRowHeight;
        }