Exemple #1
0
        private void Start()
        {
            // Keep alive so we can save settings at exit
            DontDestroyOnLoad(this);

            settings = ChangelogSettings.Load(GameDatabase.Instance);

            changelogs = GameDatabase.Instance.GetConfigs("KERBALCHANGELOG")
                         .Select(cfg => new Changelog(cfg.config, cfg))
                         .ToList();

            for (int i = changelogs.Count - 1; i >= 0; --i)
            {
                var cl = changelogs[i];
                if (cl.alreadySeen)
                {
                    // A previous version displayed these changes,
                    // mark them as seen so they'll be hidden in the next update
                    foreach (var cs in cl.versions)
                    {
                        settings.SetSeen(cl.modName, cs, true);
                    }
                }
            }

            // Don't auto-open at start if the user's already seen everything
            if (changelogs.Any(cl => cl.HasUnseen(settings.SeenVersions(cl.modName))))
            {
                var controller = gameObject.AddComponent <ChangelogController>();
                controller.settings   = settings;
                controller.changelogs = changelogs;
            }
        }
		/// <summary>
		/// A factory method disguising a singleton
		/// </summary>
		/// <param name="db">Game database</param>
		/// <returns>
		/// Existing instance if exists, a new one otherwise
		/// </returns>
		public static ChangelogSettings Load(GameDatabase db)
		{
			if (Instance == null)
			{
				Instance = new ChangelogSettings(db);
			}
			return Instance;
		}
        /// <summary>
        /// This is called when they click our toolbar button
        /// </summary>
        private void onAppLaunchToggleOn()
        {
            if (controller != null)
            {
                Destroy(controller);
            }
            controller            = gameObject.AddComponent <ChangelogController>();
            controller.settings   = ChangelogSettings.Load(GameDatabase.Instance);
            controller.changelogs = GameDatabase.Instance.GetConfigs("KERBALCHANGELOG")
                                    .Select(cfg => new Changelog(cfg.config, cfg))
                                    .ToList();

            // Unclick the launcher, since we don't want a toggle
            launcher.SetFalse(true);
        }