/// <summary> /// Called by the game when the mod is enabled. /// </summary> public void OnEnabled() { // Apply Harmony patches via Cities Harmony. // Called here instead of OnCreated to allow the auto-downloader to do its work prior to launch. HarmonyHelper.DoOnHarmonyReady(() => Patcher.PatchAll()); // Load settings file. SettingsUtils.LoadSettings(); // Populate (legacy) Datastore from configuration file. // Make sure this happens before loading the new configuration file, which will overwrite any settings here. // This establishes the correct priority (new over legacy). XMLUtilsWG.ReadFromXML(); // Attaching options panel event hook - check to see if UIView is ready. if (UIView.GetAView() != null) { // It's ready - attach the hook now. OptionsPanel.OptionsEventHook(); } else { // Otherwise, queue the hook for when the intro's finished loading. LoadingManager.instance.m_introLoaded += OptionsPanel.OptionsEventHook; } }
/// <summary> /// Adds control buttons to the bottom of the panel. /// </summary> /// <param name="panel">UI panel instance</param> protected void AddButtons(UIPanel panel) { // Add extra space. currentY += Margin; // Reset button. UIButton resetButton = UIControls.AddButton(panel, Margin, currentY, Translations.Translate("RPR_OPT_RTD"), 150f); resetButton.eventClicked += (component, clickEvent) => ResetToDefaults(); UIButton revertToSaveButton = UIControls.AddButton(panel, (Margin * 2) + 150f, currentY, Translations.Translate("RPR_OPT_RTS"), 150f); revertToSaveButton.eventClicked += (component, clickEvent) => { XMLUtilsWG.ReadFromXML(); PopulateFields(); }; UIButton saveButton = UIControls.AddButton(panel, (Margin * 3) + 300f, currentY, Translations.Translate("RPR_OPT_SAA"), 150f); saveButton.eventClicked += (component, clickEvent) => ApplyFields(); }