Exemplo n.º 1
0
 void Init()
 {
     if (toolbarControl == null)
     {
         if (HighLogic.CurrentGame != null && HighLogic.CurrentGame.Mode != Game.Modes.CAREER && HighLogic.CurrentGame.Mode != Game.Modes.SCIENCE_SANDBOX)
         {
             AppScenes = ApplicationLauncher.AppScenes.SPH | ApplicationLauncher.AppScenes.VAB;
             QDebug.Warning("Hide applauncher on the SpaceCenter", "QStockToolbar");
         }
         else
         {
             AppScenes = ApplicationLauncher.AppScenes.SPACECENTER | ApplicationLauncher.AppScenes.SPH | ApplicationLauncher.AppScenes.VAB;
         }
         toolbarControl = gameObject.AddComponent <ToolbarControl>();
         toolbarControl.AddToAllToolbars(OnClick, OnClick,
                                         AppScenes,
                                         MODID,
                                         "quickSearchButton",
                                         QUtils.Texture.STOCKTOOLBAR_PATH,
                                         QUtils.Texture.BLIZZY_PATH,
                                         MODNAME
                                         );
     }
     QDebug.Log("Init", "QStockToolbar");
 }
Exemplo n.º 2
0
 protected override void Awake()
 {
     if (HighLogic.LoadedScene != GameScenes.SPACECENTER)
     {
         QDebug.Warning("The RnD search function works only on the SpaceCenter. Destroy.", "QRnD");
         Destroy(this);
         return;
     }
     QStock.ResetScenes();
     if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER && HighLogic.CurrentGame.Mode != Game.Modes.SCIENCE_SANDBOX)
     {
         QDebug.Warning("The RnD search function works only on a Career or on a Science gamemode. Destroy.", "QRnD");
         Destroy(this);
         return;
     }
     if (Instance != null)
     {
         QDebug.Warning("There's already an Instance of " + MOD + ". Destroy.", "QRnD");
         Destroy(this);
         return;
     }
     Instance = this;
     if (!QSettings.Instance.RnDSearch)
     {
         QDebug.Warning("The RnD search function is disabled. Destroy.", "QRnD");
         Destroy(this);
         return;
     }
     base.Awake();
     QDebug.Log("Awake", "QRnD");
 }
Exemplo n.º 3
0
        internal static void ResetScenes()
        {
            if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER && HighLogic.CurrentGame.Mode != Game.Modes.SCIENCE_SANDBOX)
            {
                AppScenes = ApplicationLauncher.AppScenes.SPH | ApplicationLauncher.AppScenes.VAB;
                QDebug.Warning("Hide applauncher on the SpaceCenter", "QStockToolbar");
            }
            else
            {
                AppScenes = ApplicationLauncher.AppScenes.SPACECENTER | ApplicationLauncher.AppScenes.SPH | ApplicationLauncher.AppScenes.VAB;
            }
            if (QStock.Instance == null)
            {
                return;
            }
            if (QStock.Instance.toolbarControl != null)
            {
                QStock.Instance.toolbarControl.OnDestroy();
                Destroy(QStock.Instance.toolbarControl);
                QStock.Instance.toolbarControl = null;
            }
            QStock.Instance.Init();

            QDebug.Log("ResetScenes", "QStockToolbar");
        }
Exemplo n.º 4
0
        void Awake()
        {
            if (QLoading.Ended)
            {
                QDebug.Warning("Reload? Destroy.", "QLoading");
                Destroy(this);
                return;
            }
            if (!QSettings.Instance.enablePauseOnFlight || !QSettings.Instance.Enabled || QSettings.Instance.gameScene != (int)GameScenes.FLIGHT)
            {
                QDebug.Log("No need to keep it loaded.", "QFlight");
                QLoading.Ended = true;
                Destroy(this);
                return;
            }
            if (Instance != null)
            {
                QDebug.Warning("There's already an Instance", "QFlight");
                Destroy(this);
                return;
            }
            Instance = this;

            GameEvents.onFlightReady.Add(OnFlightReady);

            QDebug.Log("Awake", "QFlight");
        }
Exemplo n.º 5
0
 public override void OnSave(ConfigNode node)
 {
     try {
         if (!string.IsNullOrEmpty(vesselID))
         {
             node.AddValue("vesselID", vesselID);
         }
         QDebug.Log("OnSave " + vesselID, "QPersistent");
     } catch (Exception e) {
         QDebug.Warning("Can't save: {0} " + e, "QPersistent");
     }
 }
Exemplo n.º 6
0
 void Awake()
 {
     if (QLoading.Ended)
     {
         QDebug.Warning("Reload? Destroy.", "QSpaceCenter");
         Destroy(this);
         return;
     }
     if (Instance != null)
     {
         QDebug.Warning("There's already an Instance", "QSpaceCenter");
         Destroy(this);
         return;
     }
     Instance = this;
     QDebug.Log("Awake", "QSpaceCenter");
 }
Exemplo n.º 7
0
        IEnumerator QStart()
        {
            if (string.IsNullOrEmpty(QSaveGame.LastUsed))
            {
                QDebug.Warning("Last savegame not found!", "QMainMenu");
                DestroyThis();
                yield break;
            }
            if (!QSettings.Instance.Enabled)
            {
                QDebug.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());

            QDebug.Log("MainMenu Loaded", "QMainMenu");
            QDebug.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);
                }
                QDebug.Log("Goto SpaceCenter", "QMainMenu");
                HighLogic.CurrentGame.startScene = GameScenes.SPACECENTER;
                HighLogic.CurrentGame.Start();
                InputLockManager.ClearControlLocks();
                Destroy(this);
                yield break;
            }
            QDebug.Warning("Can't load the last save game", "QMainMenu");
            DestroyThis();
            yield break;
        }
Exemplo n.º 8
0
 public override void OnLoad(ConfigNode node)
 {
     try {
         if (node != null)
         {
             if (vesselID == string.Empty)
             {
                 if (node.HasValue("vesselID"))
                 {
                     vesselID = node.GetValue("vesselID");
                     QDebug.Log("OnLoad " + vesselID, "QPersistent");
                 }
             }
         }
     } catch (Exception e) {
         QDebug.Warning("Can't load: {0} " + e, "QPersistent");
     }
 }
Exemplo n.º 9
0
        void Start()
        {
            if (Ended)
            {
                QDebug.Warning("Reload? Destroy.", "QLoading");
                Destroy(this);
                return;
            }
            if (HighLogic.LoadedScene != GameScenes.LOADING)
            {
                QDebug.Warning("It's not a real Loading? Destroy.", "QLoading");
                Ended = true;
                Destroy(this);
                return;
            }
            if (Instance != null)
            {
                QDebug.Warning("There's already an Instance", "QLoading");
                Destroy(this);
                return;
            }
            Instance = this;
            //QDebug.Log ("Awake", "QLoading");

            if (string.IsNullOrEmpty(QSaveGame.LastUsed))
            {
                ScreenMessages.PostScreenMessage("[" + RegisterToolbar.MOD + "]: No savegame found.", 10);
                QDebug.Log("No savegame found, destroy...", "QLoading");
                Ended = true;
                Destroy(this);
                return;
            }
            QKey.VerifyKey();
            QDebug.Log("Start", "QLoading");

            if (QSettings.Instance.enableStopWatch)
            {
                InvokeRepeating("UpdateStopWatch", 0, 1.0f);
            }
            else
            {
                StopWatchText = "";
            }
        }
Exemplo n.º 10
0
 protected override void Awake()
 {
     if (HighLogic.LoadedScene != GameScenes.EDITOR)
     {
         QDebug.Warning("The editor search function works only on the on the Editor. Destroy.", "QEditor");
         Destroy(this);
         return;
     }
     if (Instance != null)
     {
         QDebug.Warning("There's already an Instance of " + RegisterToolbar.MOD + ". Destroy.", "QEditor");
         Destroy(this);
         return;
     }
     Instance = this;
     if (!QSettings.Instance.EditorSearch)
     {
         QDebug.Warning("The editor search function is disabled. Destroy.", "QEditor");
         Destroy(this);
         return;
     }
     base.Awake();
     QDebug.Log("Awake", "QEditor");
 }
Exemplo n.º 11
0
 void Awake()
 {
     if (Ended)
     {
         QDebug.Warning("Reload? Destroy.", "QLoading");
         Destroy(this);
         return;
     }
     if (HighLogic.LoadedScene != GameScenes.LOADING)
     {
         QDebug.Warning("It's not a real Loading? Destroy.", "QLoading");
         Ended = true;
         Destroy(this);
         return;
     }
     if (Instance != null)
     {
         QDebug.Warning("There's already an Instance", "QLoading");
         Destroy(this);
         return;
     }
     Instance = this;
     QDebug.Log("Awake", "QLoading");
 }
Exemplo n.º 12
0
        IEnumerator QStart()
        {
            while (!Ready || !QuickStart_Persistent.Ready)
            {
                yield return(0);
            }
            yield return(new WaitForSecondsRealtime(QSettings.Instance.WaitLoading));

            yield return(new WaitForEndOfFrame());

            QDebug.Log("SpaceCenter Loaded", "QSpaceCenter");
            if (QSettings.Instance.gameScene == (int)GameScenes.FLIGHT)
            {
                string _saveGame = GamePersistence.SaveGame(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)
                    {
                        QDebug.Log(string.Format("StartAndFocusVessel: {0}({1})[{2}] idx: {3}", QSaveGame.vesselName, QSaveGame.vesselType, QuickStart_Persistent.vesselID, _idx), "QSpaceCenter");
                        FlightDriver.StartAndFocusVessel(_saveGame, _idx);
                    }
                    else
                    {
                        QDebug.Warning("QStart: invalid idx", "QSpaceCenter");
                        DestroyThis();
                    }
                }
                else
                {
                    QDebug.Warning("QStart: No vessel found", "QSpaceCenter");
                    DestroyThis();
                }
            }
            if (QSettings.Instance.gameScene == (int)GameScenes.TRACKSTATION)
            {
                HighLogic.LoadScene(GameScenes.LOADINGBUFFER);
                HighLogic.LoadScene(GameScenes.TRACKSTATION);
                InputLockManager.ClearControlLocks();
                QDebug.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);
                    QDebug.Log("StartAndLoadVessel: " + QuickStart_Persistent.shipPath, "QSpaceCenter");
                }
                else
                {
                    EditorDriver.StartupBehaviour = EditorDriver.StartupBehaviours.START_CLEAN;
                    EditorDriver.StartEditor((EditorFacility)QSettings.Instance.editorFacility);
                    QDebug.Log("StartEditor", "QSpaceCenter");
                }
                InputLockManager.ClearControlLocks();
                QDebug.Log("Goto " + (QSettings.Instance.editorFacility == (int)EditorFacility.VAB ? "Vehicle Assembly Building" : "Space Plane Hangar"), "QSpaceCenter");
                DestroyThis();
            }
            Destroy(this);
            yield break;
        }