Пример #1
0
 private void Awake()
 {
     if (Ended)
     {
         QuickStart.Warning("Reload? Destroy.", "QLoading");
         Destroy(this);
         return;
     }
     if (HighLogic.LoadedScene != GameScenes.LOADING)
     {
         QuickStart.Warning("It's not a real Loading? Destroy.", "QLoading");
         Ended = true;
         Destroy(this);
         return;
     }
     if (Instance != null)
     {
         QuickStart.Warning("There's already an Instance", "QLoading");
         Destroy(this);
         return;
     }
     Instance             = this;
     Button               = new GUIStyle(HighLogic.Skin.button);
     Button.contentOffset = new Vector2(2, 2);
     Button.alignment     = TextAnchor.MiddleCenter;
     QuickStart.Log("Awake", "QLoading");
 }
Пример #2
0
 void OnDestroy()
 {
     GameEvents.onFlightReady.Remove(OnFlightReady);
     GameEvents.onVesselChange.Remove(OnVesselChange);
     GameEvents.onGameSceneSwitchRequested.Remove(OnSceneSwitch);
     QuickStart.Log("OnDestroy", "QPersistent");
 }
Пример #3
0
 private void DestroyThis()
 {
     QuickStart.Log("DestroyThis", "QMainMenu");
     QuickStart_Persistent.vesselID = string.Empty;
     QLoading.Ended = true;
     Destroy(this);
 }
Пример #4
0
 private void LateUpdate()
 {
     if (!Ready)
     {
         QuickStart.Log("Ready", "QSpaceCenter");
         Ready = true;
     }
 }
Пример #5
0
 private void LateUpdate()
 {
     if (!Ready)
     {
         QuickStart.Log("Ready", "QMainMenu");
         Ready = true;
     }
 }
Пример #6
0
 void Start()
 {
     if (HighLogic.LoadedSceneIsEditor && QSettings.Instance.enableEditorAutoSaveShip)
     {
         StartCoroutine(autoSaveShip());
     }
     Ready = true;
     QuickStart.Log("Start", "QPersistent");
 }
Пример #7
0
 private void Start()
 {
     if (!QSettings.Instance.Enabled)
     {
         QuickStart.Log("No need to keep it loaded.", "QMainMenu");
         DestroyThis();
         return;
     }
     StartCoroutine(QStart());
     QuickStart.Log("Start", "QMainMenu");
 }
Пример #8
0
 private void Start()
 {
     if (string.IsNullOrEmpty(QSaveGame.LastUsed))
     {
         ScreenMessages.PostScreenMessage("[" + QuickStart.MOD + "]: No savegame found.", 10);
         QuickStart.Log("No savegame found, destroy...", "QLoading");
         Ended = true;
         Destroy(this);
         return;
     }
     QuickStart.Log("Start", "QLoading");
 }
Пример #9
0
 public override void OnSave(ConfigNode node)
 {
     try {
         if (!string.IsNullOrEmpty(vesselID))
         {
             node.AddValue("vesselID", vesselID);
         }
         QuickStart.Log("OnSave " + vesselID, "QPersistent");
     } catch (Exception e) {
         QuickStart.Warning("Can't save: {0} " + e, "QPersistent");
     }
 }
Пример #10
0
        IEnumerator autoSaveShip()
        {
            QuickStart.Log("autoSaveShip: start", "QPersistent");
            while (HighLogic.LoadedSceneIsEditor && QSettings.Instance.enableEditorAutoSaveShip)
            {
                yield return(new WaitForSeconds(QSettings.Instance.editorTimeToSave));

                ShipConstruction.SaveShip(shipFilename);
                QuickStart.Log("autoSaveShip: save", "QPersistent");
            }
            QuickStart.Log("autoSaveShip: end", "QPersistent");
        }
Пример #11
0
 private void Start()
 {
     InputLockManager.RemoveControlLock("applicationFocus");
     if (!QSettings.Instance.Enabled || QSettings.Instance.gameScene == (int)GameScenes.SPACECENTER)
     {
         QuickStart.Log("Not need to keep it loaded.", "QSpaceCenter");
         QLoading.Ended = true;
         Destroy(this);
         return;
     }
     StartCoroutine(QStart());
     QuickStart.Log("Start", "QSpaceCenter");
 }
Пример #12
0
 public override void OnAwake()
 {
     Instance = this;
     GameEvents.onFlightReady.Add(OnFlightReady);
     GameEvents.onVesselChange.Add(OnVesselChange);
     GameEvents.onGameSceneSwitchRequested.Add(OnSceneSwitch);
     if (QSpaceCenter.Instance == null)
     {
         QSettings.Instance.gameScene = (int)HighLogic.LoadedScene;
         if (HighLogic.LoadedSceneIsEditor)
         {
             QSettings.Instance.editorFacility = (int)EditorDriver.editorFacility;
         }
     }
     QSettings.Instance.Save();
     QuickStart.Log("OnAwake", "QPersistent");
 }
Пример #13
0
 private void Awake()
 {
     if (QLoading.Ended)
     {
         QuickStart.Warning("Reload? Destroy.", "QSpaceCenter");
         Destroy(this);
         return;
     }
     if (Instance != null)
     {
         QuickStart.Warning("There's already an Instance", "QSpaceCenter");
         Destroy(this);
         return;
     }
     Instance = this;
     QuickStart.Log("Awake", "QSpaceCenter");
 }
Пример #14
0
        private IEnumerator QStart()
        {
            if (string.IsNullOrEmpty(QSaveGame.LastUsed))
            {
                QuickStart.Warning("Last savegame not found!", "QMainMenu");
                DestroyThis();
                yield break;
            }
            if (!QSettings.Instance.Enabled)
            {
                QuickStart.Log("QuickStart is disabled!", "QMainMenu");
                DestroyThis();
                yield break;
            }
            while (!Ready)
            {
                yield return(0);
            }
            yield return(new WaitForEndOfFrame());

            yield return(new WaitForSeconds(QSettings.Instance.WaitLoading));

            yield return(new WaitForEndOfFrame());

            QuickStart.Log("MainMenu Loaded", "QMainMenu");
            QuickStart.Warning("The last game found: " + QSaveGame.LastUsed, "QMainMenu");
            HighLogic.CurrentGame = GamePersistence.LoadGame(QSaveGame.File, QSaveGame.LastUsed, true, false);
            if (HighLogic.CurrentGame != null)
            {
                HighLogic.SaveFolder = QSaveGame.LastUsed;
                if (GamePersistence.UpdateScenarioModules(HighLogic.CurrentGame))
                {
                    GamePersistence.SaveGame(HighLogic.CurrentGame, QSaveGame.File, HighLogic.SaveFolder, SaveMode.OVERWRITE);
                }
                QuickStart.Log("Goto SpaceCenter", "QMainMenu");
                HighLogic.CurrentGame.startScene = GameScenes.SPACECENTER;
                HighLogic.CurrentGame.Start();
                InputLockManager.ClearControlLocks();
                Destroy(this);
                yield break;
            }
            QuickStart.Warning("Can't load the last save game", "QMainMenu");
            DestroyThis();
            yield break;
        }
Пример #15
0
 public override void OnLoad(ConfigNode node)
 {
     try {
         if (node != null)
         {
             if (vesselID == string.Empty)
             {
                 if (node.HasValue("vesselID"))
                 {
                     vesselID = node.GetValue("vesselID");
                     QuickStart.Log("OnLoad " + vesselID, "QPersistent");
                 }
             }
         }
     } catch (Exception e) {
         QuickStart.Warning("Can't load: {0} " + e, "QPersistent");
     }
 }
Пример #16
0
 private void OnDestroy()
 {
     QuickStart.Log("OnDestroy", "QMainMenu");
 }
Пример #17
0
 void OnVesselChange(Vessel vessel)
 {
     vesselID = vessel.id.ToString();
     QuickStart.Log("OnVesselChange " + vesselID, "QPersistent");
 }
Пример #18
0
 void OnFlightReady()
 {
     vesselID = FlightGlobals.ActiveVessel.id.ToString();
     QuickStart.Log("OnFlightReady " + vesselID, "QPersistent");
 }
Пример #19
0
 private void OnDestroy()
 {
     QSettings.Instance.Save();
     QuickStart.Log("OnDestroy", "QLoading");
 }
Пример #20
0
 private void OnDestroy()
 {
     QuickStart.Log("OnDestroy", "QSpaceCenter");
 }
Пример #21
0
 private void DestroyThis()
 {
     QuickStart.Log("DestroyThis", "QSpaceCenter");
     QLoading.Ended = true;
     Destroy(this);
 }
Пример #22
0
        private IEnumerator QStart()
        {
            while (!Ready || !QuickStart_Persistent.Ready)
            {
                yield return(0);
            }
            yield return(new WaitForEndOfFrame());

            yield return(new WaitForSecondsRealtime(QSettings.Instance.WaitLoading));

            yield return(new WaitForEndOfFrame());

            QuickStart.Log("SpaceCenter Loaded", "QSpaceCenter");
            if (QSettings.Instance.gameScene == (int)GameScenes.FLIGHT)
            {
                string _saveGame = GamePersistence.SaveGame(HighLogic.CurrentGame, QSaveGame.File, HighLogic.SaveFolder, SaveMode.OVERWRITE);
                if (!string.IsNullOrEmpty(QuickStart_Persistent.vesselID))
                {
                    int _idx = HighLogic.CurrentGame.flightState.protoVessels.FindLastIndex(pv => pv.vesselID == QuickStart_Persistent.VesselID);
                    if (_idx != -1)
                    {
                        QuickStart.Log(string.Format("StartAndFocusVessel: {0}({1})[{2}] idx: {3}", QSaveGame.vesselName, QSaveGame.vesselType, QuickStart_Persistent.vesselID, _idx), "QSpaceCenter");
                        FlightDriver.StartAndFocusVessel(_saveGame, _idx);
                    }
                    else
                    {
                        QuickStart.Warning("QStart: invalid idx", "QSpaceCenter");
                        DestroyThis();
                    }
                }
                else
                {
                    QuickStart.Warning("QStart: No vessel found", "QSpaceCenter");
                    DestroyThis();
                }
            }
            if (QSettings.Instance.gameScene == (int)GameScenes.TRACKSTATION)
            {
                HighLogic.LoadScene(GameScenes.LOADINGBUFFER);
                HighLogic.LoadScene(GameScenes.TRACKSTATION);
                InputLockManager.ClearControlLocks();
                QuickStart.Log("Goto Tracking Station", "QSpaceCenter");
                DestroyThis();
            }
            if (QSettings.Instance.gameScene == (int)GameScenes.EDITOR)
            {
                if (QSettings.Instance.enableEditorLoadAutoSave && File.Exists(QuickStart_Persistent.shipPath))
                {
                    EditorDriver.StartAndLoadVessel(QuickStart_Persistent.shipPath, (EditorFacility)QSettings.Instance.editorFacility);
                    QuickStart.Log("StartAndLoadVessel: " + QuickStart_Persistent.shipPath, "QSpaceCenter");
                }
                else
                {
                    EditorDriver.StartupBehaviour = EditorDriver.StartupBehaviours.START_CLEAN;
                    EditorDriver.StartEditor((EditorFacility)QSettings.Instance.editorFacility);
                    QuickStart.Log("StartEditor", "QSpaceCenter");
                }
                InputLockManager.ClearControlLocks();
                QuickStart.Log("Goto " + (QSettings.Instance.editorFacility == (int)EditorFacility.VAB ? "Vehicle Assembly Building" : "Space Plane Hangar"), "QSpaceCenter");
                DestroyThis();
            }
            Destroy(this);
            yield break;
        }