/// <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_23_0");
            messageText = Translations.Translate("PRR_UPD_23_1");
            listText    = Translations.Translate("PRR_UPD_23_2") + "\r\n\r\n" + Translations.Translate("PRR_UPD_23_3") + "\r\n\r\n" + Translations.Translate("PRR_UPD_23_4") + "\r\n\r\n" + Translations.Translate("PRR_UPD_23_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.
                    notificationVersion = 3;
                    SettingsUtils.SaveSettings();

                    // Just hide this panel and destroy the game object - nothing more to do.
                    this.Hide();
                    GameObject.Destroy(uiGameObject);
                };
            }
            catch (Exception e)
            {
                Debugging.LogException(e);
            }
        }
Ejemplo n.º 2
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 ComplaintOptions(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab and helper.
            UIPanel  panel  = PanelUtils.AddTab(tabStrip, Translations.Translate("PRR_OPTION_COM"), tabIndex);
            UIHelper helper = new UIHelper(panel);

            panel.autoLayout = true;

            // Add 'ignore low value complaint' checkboxes.
            UIHelperBase valueGroup      = helper.AddGroup(Translations.Translate("PRR_OPTION_VAL"));
            UICheckBox   noValueRicoPlop = (UICheckBox)valueGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RPL"), ModSettings.noValueRicoPlop, isChecked =>
            {
                ModSettings.noValueRicoPlop = isChecked;
                SettingsUtils.SaveSettings();
            });

            valueGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RCO"), ModSettings.noValueRicoGrow, isChecked =>
            {
                ModSettings.noValueRicoGrow = isChecked;
                SettingsUtils.SaveSettings();

                // If this is active, then the checkbox above also needs to be checked if it isn't already.
                if (isChecked && !noValueRicoPlop.isChecked)
                {
                    noValueRicoPlop.isChecked = true;
                }
            });
            valueGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.noValueOther, isChecked =>
            {
                ModSettings.noValueOther = isChecked;
                SettingsUtils.SaveSettings();
            });

            // Add 'ignore too few services complaint' checkboxes.
            UIHelperBase servicesGroup      = helper.AddGroup(Translations.Translate("PRR_OPTION_SVC"));
            UICheckBox   noServicesRicoPlop = (UICheckBox)servicesGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RPL"), ModSettings.noServicesRicoPlop, isChecked =>
            {
                ModSettings.noServicesRicoPlop = isChecked;
                SettingsUtils.SaveSettings();
            });

            servicesGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RCO"), ModSettings.noServicesRicoGrow, isChecked =>
            {
                ModSettings.noServicesRicoGrow = isChecked;
                SettingsUtils.SaveSettings();

                // If this is active, then the checkbox above also needs to be checked if it isn't already.
                if (isChecked && !noServicesRicoPlop.isChecked)
                {
                    noServicesRicoPlop.isChecked = true;
                }
            });
            servicesGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.noServicesOther, isChecked =>
            {
                ModSettings.noServicesOther = isChecked;
                SettingsUtils.SaveSettings();
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 'Don't show again' button action.
        /// </summary>
        /// <returns>True (always)</returns>
        public static bool DontShowAgain()
        {
            // Save current version to settings file.
            ModSettings.whatsNewVersion     = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            ModSettings.whatsNewBetaVersion = WhatsNewMessages[0].betaVersion;
            SettingsUtils.SaveSettings();

            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Closes the panel by destroying the object (removing any ongoing UI overhead).
        /// </summary>
        private static void Close()
        {
            // Save settings first.
            SettingsUtils.SaveSettings();

            // We're no longer visible - destroy our game object.
            if (optionsGameObject != null)
            {
                GameObject.Destroy(optionsGameObject);
                optionsGameObject = null;
            }
        }
        /// <summary>
        /// Procesesses text change events.
        /// </summary>
        /// <param name="textField">Textfield control</param
        /// <param name="text">Text to attempt to parse</param
        /// <param name="setting">Field to store result in</param>
        private void TextSubmitted(UITextField textField, string text, ref int setting)
        {
            if (textField != null)
            {
                // Valid text to parse?
                if (!text.IsNullOrWhiteSpace())
                {
                    // Yes - attempt to parse.
                    if (uint.TryParse(text, out uint result))
                    {
                        // Sucessful parse; set value and return.
                        setting = (int)result;
                        SettingsUtils.SaveSettings();
                        return;
                    }
                }

                // If we got here, no valid value was oarsed; set text field text to the currently stored value.
                textField.text = setting.ToString();
            }
        }
        /// <summary>
        /// Event handler for demolish warning checkbox.
        /// </summary>
        /// <param name="control">Calling UIComponent</param>
        /// <param name="isChecked">New isChecked state</param>
        private void DemolishWarnCheckChanged(UIComponent control, bool isChecked)
        {
            // Update mod settings.
            ModSettings.warnBulldoze = isChecked;
            SettingsUtils.SaveSettings();

            // If we're in-game (dictionary has been initialized), iterate through dictionary, looking for RICO ploppable buildings and updating their auto-remove flags.
            if (Loading.xmlManager?.prefabHash != null)
            {
                foreach (BuildingInfo prefab in Loading.xmlManager.prefabHash.Keys)
                {
                    // Get active RICO settings.
                    RICOBuilding building = RICOUtils.CurrentRICOSetting(Loading.xmlManager.prefabHash[prefab]);

                    // Check that it's enabled and isn't growable.
                    if (building != null && building.ricoEnabled && !building.growable)
                    {
                        // Apply flag.
                        prefab.m_autoRemove = !isChecked;
                    }
                }
            }
        }
        /// <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;
                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();
            });

            // 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;
                    SettingsUtils.SaveSettings();
                });
                levelGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.lockLevelOther, isChecked =>
                {
                    ModSettings.lockLevelOther = isChecked;
                    SettingsUtils.SaveSettings();
                });
            }
        }
        /// <summary>
        /// Harmony postfix to perform actions require after the level has loaded.
        /// </summary>
        public static void Postfix()
        {
            // Don't do anything if mod hasn't activated for whatever reason (mod conflict, harmony error, something else).
            if (!Loading.isModEnabled)
            {
                return;
            }

            // Report any 'soft' mod conflicts.
            if (Loading.softModConflct)
            {
                // Soft conflict detected - display warning notification for each one.
                foreach (string mod in ModUtils.conflictingModNames)
                {
                    if (mod.Equals("PTG") && ModSettings.dsaPTG == 0)
                    {
                        // Plop the Growables.
                        DontShowAgainMessageBox softConflictBox = MessageBoxBase.ShowModal <DontShowAgainMessageBox>();
                        softConflictBox.AddParas(Translations.Translate("PRR_CON_PTG0"), Translations.Translate("PRR_CON_PTG1"), Translations.Translate("PRR_CON_PTG2"));
                        softConflictBox.DSAButton.eventClicked += (component, clickEvent) => { ModSettings.dsaPTG = 1; SettingsUtils.SaveSettings(); };
                    }
                }
            }

            // Report any broken assets and remove from our prefab dictionary.
            foreach (BuildingInfo prefab in Loading.brokenPrefabs)
            {
                Logging.Error("broken prefab: ", prefab.name);
                Loading.xmlManager.prefabHash.Remove(prefab);
            }
            Loading.brokenPrefabs.Clear();

            // Init Ploppable Tool panel.
            PloppableTool.Initialize();

            // Add buttons to access building details from zoned building info panels.
            SettingsPanel.AddInfoPanelButtons();

            // Display update notification.
            try
            {
                WhatsNew.ShowWhatsNew();
            }
            catch (Exception e)
            {
                Logging.LogException(e, "exception showing WhatsNew panel");
            }

            // Set up options panel event handler.
            try
            {
                OptionsPanel.OptionsEventHook();
            }
            catch (Exception e)
            {
                Logging.LogException(e, "exception hooking options panel");
            }

            Logging.KeyMessage("loading complete");
        }
        /// <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;
                SettingsUtils.SaveSettings();
            });

            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;
                SettingsUtils.SaveSettings();
            });

            // 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;
                SettingsUtils.SaveSettings();
            });

            // 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;
                SettingsUtils.SaveSettings();
            });

            // 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;
                SettingsUtils.SaveSettings();
            });
        }
Ejemplo n.º 10
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_RCO"), 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_RCO"), 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_RCO"), ModSettings.noSpecRico, isChecked =>
            {
                ModSettings.noSpecRico = isChecked;
                SettingsUtils.SaveSettings();
            });
            specGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.noSpecOther, isChecked =>
            {
                ModSettings.noSpecOther = isChecked;
                SettingsUtils.SaveSettings();
            });

            // Add 'ignore low value complaint' checkboxes.
            UIHelperBase valueGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_VAL"));

            valueGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RCO"), ModSettings.noValueRico, isChecked =>
            {
                ModSettings.noValueRico = isChecked;
                SettingsUtils.SaveSettings();
            });
            valueGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.noValueOther, isChecked =>
            {
                ModSettings.noValueOther = isChecked;
                SettingsUtils.SaveSettings();
            });

            // Add 'ignore too few services complaint' checkboxes.
            UIHelperBase servicesGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_SVC"));

            servicesGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RCO"), ModSettings.noServicesRico, isChecked =>
            {
                ModSettings.noServicesRico = isChecked;
                SettingsUtils.SaveSettings();
            });
            servicesGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.noServicesOther, isChecked =>
            {
                ModSettings.noServicesOther = isChecked;
                SettingsUtils.SaveSettings();
            });

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

            histGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RCO"), ModSettings.historicalRico, isChecked =>
            {
                ModSettings.historicalRico = isChecked;
                SettingsUtils.SaveSettings();
            });
            histGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.historicalOther, isChecked =>
            {
                ModSettings.historicalOther = isChecked;
                SettingsUtils.SaveSettings();
            });
        }
 /// <summary>
 /// Event handler for override cost checkbox.
 /// </summary>
 /// <param name="control">Calling UIComponent</param>
 /// <param name="isChecked">New isChecked state</param>
 private void OverrideCostCheckChanged(UIComponent control, bool isChecked)
 {
     ModSettings.overrideCost = isChecked;
     SettingsUtils.SaveSettings();
 }
 /// <summary>
 /// Event handler for auto demolish checkbox.
 /// </summary>
 /// <param name="control">Calling UIComponent</param>
 /// <param name="isChecked">New isChecked state</param>
 private void DemolishAutoCheckChanged(UIComponent control, bool isChecked)
 {
     ModSettings.autoDemolish = isChecked;
     SettingsUtils.SaveSettings();
 }