Beispiel #1
0
        /// <summary>
        /// Performs actions to be taken once an update (application or reversion) has been applied, including saving data, updating button states, and refreshing renders.
        /// </summary>
        protected override void FinishUpdate()
        {
            base.FinishUpdate();

            // Update any dirty net renders.
            NetData.Update();
        }
Beispiel #2
0
        /// <summary>
        /// (Re-)loads the current config (per ConfigurationUtils.CurrentSavedConfigName).
        /// </summary>
        private void LoadConfig()
        {
            // Clear current replacements.
            ReplacementUtils.NukeSettings();

            // Load config file.
            ConfigurationUtils.LoadConfig();

            Logging.KeyMessage("reloaded global configuration");

            // Update button states accordingly.
            UpdateButtonStates();

            // Update dirty renders.
            BuildingData.Update();
            NetData.Update();
        }
Beispiel #3
0
        /// <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)
        {
            Logging.Message("commencing loading checks");

            base.OnLevelLoaded(mode);

            // Don't do anything further if we're not operating.
            if (!isModEnabled)
            {
                Logging.Message("exiting");
                return;
            }

            // Check to see that Harmony 2 was properly loaded.
            if (!Patcher.Patched)
            {
                // Harmony 2 wasn't loaded; abort.
                Logging.Error("Harmony patches not applied; aborting");
                isModEnabled = false;

                // Display warning message.
                ListMessageBox harmonyBox = MessageBoxBase.ShowModal <ListMessageBox>();

                // Key text items.
                harmonyBox.AddParas(Translations.Translate("ERR_HAR0"), Translations.Translate("BOB_ERR_HAR"), Translations.Translate("BOB_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"));

                // Don't do anything further.
                return;
            }

            Logging.Message("loading checks passed");

            // Build lists of loaded prefabs.
            PrefabLists.BuildLists();

            // Load prop packs.
            new NetworkPackReplacement();

            // Load configuration file.
            ConfigurationUtils.LoadConfig();

            // Set up BOB tool.
            ToolsModifierControl.toolController.gameObject.AddComponent <BOBTool>();

            // Display update notification.
            WhatsNew.ShowWhatsNew();

            // Set up Network Skins 2 reflection.
            ModUtils.NS2Reflection();

            // Enable thin wires, if applicable.
            if (ModSettings.ThinnerWires)
            {
                ElectricalWires.Instance.ApplyThinnerWires();
            }

            // Force update of any dirty net or building prefabs from replacement process.
            Logging.Message("updating dirty prefabs");
            BuildingData.Update();
            NetData.Update();

            // Set up options panel event handler.
            OptionsPanel.OptionsEventHook();

            // Display any exception message that occured during load.
            InfoPanelManager.CheckException();

            // Activate tool hotkey.
            UIThreading.Operating = true;

            Logging.Message("loading complete");
        }
Beispiel #4
0
        /// <summary>
        /// Reverts all current settings and clears replacement dictionaries.
        /// </summary>
        internal static void NukeSettings()
        {
            Logging.KeyMessage("reverting all replacements");

            // Revert all-building replacements.
            try
            {
                AllBuildingReplacement.Instance?.RevertAll();
            }
            catch (Exception e)
            {
                // Don't let a single failure stop us.
                Logging.LogException(e, "exception reverting all-building replacements");
            }

            // Revert building replacements.
            try
            {
                BuildingReplacement.Instance?.RevertAll();
            }
            catch (Exception e)
            {
                // Don't let a single failure stop us.
                Logging.LogException(e, "exception reverting building replacements");
            }

            // Revert individual building replacements.
            try
            {
                IndividualBuildingReplacement.Instance?.RevertAll();
            }
            catch (Exception e)
            {
                // Don't let a single failure stop us.
                Logging.LogException(e, "exception reverting individual building replacements");
            }

            // Revert network pack replacements.
            try
            {
                NetworkPackReplacement.Instance?.RevertAll();
            }
            catch (Exception e)
            {
                // Don't let a single failure stop us.
                Logging.LogException(e, "exception reverting network pack replacements");
            }

            // Revert all-network replacements.
            try
            {
                AllNetworkReplacement.Instance?.RevertAll();
            }
            catch (Exception e)
            {
                // Don't let a single failure stop us.
                Logging.LogException(e, "exception reverting all-network replacements");
            }

            // Revert network replacements.
            try
            {
                NetworkReplacement.Instance?.RevertAll();
            }
            catch (Exception e)
            {
                // Don't let a single failure stop us.
                Logging.LogException(e, "exception reverting network replacements");
            }

            // Revert individual network replacements.
            try
            {
                IndividualNetworkReplacement.Instance?.RevertAll();
            }
            catch (Exception e)
            {
                // Don't let a single failure stop us.
                Logging.LogException(e, "exception reverting individual network replacements");
            }

            // Revert scaling.
            try
            {
                Scaling.Instance?.RevertAll();
            }
            catch (Exception e)
            {
                // Don't let a single failure stop us.
                Logging.LogException(e, "exception reverting scaling elemennts");
            }

            // Regenerate dirty renders.
            NetData.Update();
            BuildingData.Update();
        }