Esempio n. 1
0
        /// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
        {
            try
            {
                try
                {
                    _modDataFileName = Path.Combine(Helper.DirectoryPath, Game1.player.Name + "_modData.xml");
                }
                catch
                {
                    Monitor.Log("Error: Player name contains character that cannot be used in file name. Using generic file name." + Environment.NewLine +
                                "Options may not be able to be different between characters.", LogLevel.Warn);
                    _modDataFileName = Path.Combine(Helper.DirectoryPath, "default_modData.xml");
                }

                if (File.Exists(_modDataFileName))
                {
                    XmlDocument document = new XmlDocument();

                    document.Load(_modDataFileName);
                    XmlNodeList nodes = document.GetElementsByTagName("option");

                    foreach (XmlNode node in nodes)
                    {
                        String key   = node.Attributes["name"]?.Value;
                        String value = node.InnerText;

                        if (key != null)
                        {
                            _options[key] = value;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Monitor.Log("Error loading mod config. " + ex.Message + Environment.NewLine + ex.StackTrace, LogLevel.Error);
            }

            _modOptionsPageHandler = new ModOptionPageHandler(_options);

            if (Helper.ModRegistry.IsLoaded("Bouhm.NPCMapLocations"))
            {
                _modOptionsPageHandler._showNPCOnMap.ToggleShowNPCLocationsOnMap(false);
            }
        }
Esempio n. 2
0
 /// <summary>Raised after the game returns to the title screen.</summary>
 /// <param name="sender">The event sender.</param>
 private void OnReturnedToTitle(object sender, ReturnedToTitleEventArgs e)
 {
     _modOptionsPageHandler?.Dispose();
     _modOptionsPageHandler = null;
 }