Exemple #1
0
        void onGameStateCreated(Game game)
        {
            LastKSC.CreateSettings(game);
            bool noSite = false;

            if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                foreach (ProtoScenarioModule m in HighLogic.CurrentGame.scenarios)
                {
                    if (m.moduleName == "LastKSC")
                    {
                        LastKSC l = (LastKSC)m.Load(ScenarioRunner.Instance);
                        if (l.lastSite.Length > 0)
                        {
                            // found a site, load it
                            ConfigNode site = Sites.getSiteByName(l.lastSite);
                            if (site == null)
                            {
                                l.lastSite = Sites.defaultSite;
                                noSite     = true;
                            }
                            else
                            {
                                KSCSwitcher.setSite(site);
                                Debug.Log("KSCSwitcher set the launch site to " + l.lastSite);
                                return;
                            }
                        }
                        else
                        {
                            l.lastSite = Sites.defaultSite;
                            noSite     = true;
                        }
                        if (noSite)
                        {
                            if (Sites.defaultSite.Length > 0)
                            {
                                ConfigNode site = Sites.getSiteByName(Sites.defaultSite);
                                if (site == null)
                                {
                                    Debug.LogError("KSCSwitcher found a default site name but could not retrieve the site config: " + Sites.defaultSite);
                                    return;
                                }
                                else
                                {
                                    KSCSwitcher.setSite(site);
                                    Debug.Log("KSCSwitcher set the initial launch site to " + Sites.defaultSite);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
        private void setSite(LaunchSite newSite)
        {
            ConfigNode site = KSCLoader.instance.Sites.getSiteByName(newSite.name);

            if (site == null)
            {
                return;
            }

            if (KSCSwitcher.setSite(site))
            {
                activeSite = newSite.name;
                ScreenMessages.PostScreenMessage("Launch site changed to " + newSite.displayName, 2.5f, ScreenMessageStyle.LOWER_CENTER);
                showWindow = false;
            }
        }