示例#1
0
        public void ReloadInfo()
        {
            // Set default info
            Title              = "Untitled Mod";
            Version            = new Version(1, 0, 0);
            MinimumGameVersion = new Version(0, 0, 0);
            Author             = null;
            AuthorTwitter      = null;
            AutoLoad           = false;
            SteamWorkshopID    = null;
            SteamUserID        = null;

            // Reload the index
            if (m_contents != null)
            {
                m_contents.ReloadIndex();
            }

            // Parse info.txt
            var infoPath = "info.txt";

            if (m_contents != null && m_contents.FileExists(infoPath))
            {
                var kvp = new KeyValuePairs();
                using (var stream = m_contents.OpenTextFile(infoPath))
                {
                    kvp.Load(stream);
                }

                Title              = kvp.GetString("title", Title);
                Version            = kvp.GetVersion("version", Version);
                MinimumGameVersion = kvp.GetVersion("game_version", MinimumGameVersion);
                Author             = kvp.GetString("author", null);
                AuthorTwitter      = kvp.GetString("author_twitter", null);
                AutoLoad           = kvp.GetBool("autoload", false);
                if (kvp.ContainsKey("steam_workshop_id"))
                {
                    SteamWorkshopID = kvp.GetULong("steam_workshop_id");
                }
                else
                {
                    SteamWorkshopID = null;
                }
                if (kvp.ContainsKey("steam_user_id"))
                {
                    SteamUserID = kvp.GetULong("steam_user_id");
                }
                else
                {
                    SteamUserID = null;
                }
            }

            // Reload the index
            m_assets.Name = Title;
            m_assets.FileStore.ReloadIndex();
        }