Esempio n. 1
0
        public void Awake()
        {
#if KSP1_4
            // 1.4 Addition
            if (KCT_Utilities.CurrentGameIsMission())
            {
                return;
            }
#endif
            KCTDebug.Log("Awake called");
            KCT_GameStates.erroredDuringOnLoad.OnLoadStart();
            KCT_GameStates.PersistenceLoaded = false;

            instance = this;

            KCT_GameStates.settings.Load(); //Load the settings file, if it exists

            string SavedFile = KSPUtil.ApplicationRootPath + "/saves/" + HighLogic.SaveFolder + "/KCT_Settings.cfg";
            if (!System.IO.File.Exists(SavedFile))
            {
                KCT_GameStates.firstStart = true;
            }

            if (KCT_PresetManager.Instance == null)
            {
                KCT_PresetManager.Instance = new KCT_PresetManager();
            }
            KCT_PresetManager.Instance.SetActiveFromSaveData();

            // Create events for other mods
            if (!KCT_Events.instance.createdEvents)
            {
                KCT_Events.instance.CreateEvents();
            }

            //Add the toolbar button
            if (ToolbarManager.ToolbarAvailable && ToolbarManager.Instance != null && KCT_GameStates.settings.PreferBlizzyToolbar)
            {
                KCTDebug.Log("Adding Toolbar Button");
                KCT_GameStates.kctToolbarButton = ToolbarManager.Instance.add("Kerbal_Construction_Time", "MainButton");
                if (KCT_GameStates.kctToolbarButton != null)
                {
                    if (KCT_PresetManager.PresetLoaded() && !KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled)
                    {
                        KCT_GameStates.kctToolbarButton.Visibility = new GameScenesVisibility(GameScenes.SPACECENTER);
                    }
                    else
                    {
                        KCT_GameStates.kctToolbarButton.Visibility = new GameScenesVisibility(new GameScenes[] { GameScenes.SPACECENTER, GameScenes.FLIGHT, GameScenes.TRACKSTATION, GameScenes.EDITOR });
                    }
                    KCT_GameStates.kctToolbarButton.TexturePath = KCT_Utilities.GetButtonTexture();
                    KCT_GameStates.kctToolbarButton.ToolTip     = "Kerbal Construction Time";
                    KCT_GameStates.kctToolbarButton.OnClick    += ((e) =>
                    {
                        KCT_GUI.ClickToggle();
                    });
                }
            }
            KCTDebug.Log("Awake finished");
        }
Esempio n. 2
0
        public override void OnLoad(ConfigNode node)
        {
            KCTDebug.Log("Reading from persistence.");
            base.OnLoad(node);
            KCT_GameStates.KSCs.Clear();
            KCT_GameStates.ActiveKSC = null;
            //KCT_Utilities.SetActiveKSC("Stock");
            KCT_GameStates.TechList.Clear();
            KCT_GameStates.TechUpgradesTotal = 0;

            KCT_DataStorage kctVS = new KCT_DataStorage();
            ConfigNode      CN    = node.GetNode(kctVS.GetType().Name);

            if (CN != null)
            {
                ConfigNode.LoadObjectFromConfig(kctVS, CN);
            }

            foreach (ConfigNode ksc in node.GetNodes("KSC"))
            {
                string  name       = ksc.GetValue("KSCName");
                KCT_KSC loaded_KSC = new KCT_KSC(name);
                loaded_KSC.FromConfigNode(ksc);
                if (loaded_KSC != null && loaded_KSC.KSCName != null && loaded_KSC.KSCName.Length > 0)
                {
                    loaded_KSC.RDUpgrades[1] = KCT_GameStates.TechUpgradesTotal;
                    if (KCT_GameStates.KSCs.Find(k => k.KSCName == loaded_KSC.KSCName) == null)
                    {
                        KCT_GameStates.KSCs.Add(loaded_KSC);
                    }
                }
            }
            KCT_Utilities.SetActiveKSCToRSS();
            //KCT_Utilities.SetActiveKSC(KCT_GameStates.activeKSCName);


            ConfigNode tmp = node.GetNode("TechList");

            if (tmp != null)
            {
                foreach (ConfigNode techNode in tmp.GetNodes("Tech"))
                {
                    KCT_TechStorageItem techStorageItem = new KCT_TechStorageItem();
                    ConfigNode.LoadObjectFromConfig(techStorageItem, techNode);
                    KCT_TechItem techItem = techStorageItem.ToTechItem();
                    techItem.protoNode = new ProtoTechNode(techNode.GetNode("ProtoNode"));
                    KCT_GameStates.TechList.Add(techItem);
                }
            }
            //KCT_GameStates.ActiveKSC.AsConfigNode().Save(KSPUtil.ApplicationRootPath + "/KSC.node");

            KerbalConstructionTime.DelayedStart();
            KCT_GUI.CheckToolbar();
            KCT_GameStates.erroredDuringOnLoad.OnLoadFinish();
        }
Esempio n. 3
0
        public void Awake()
        {
            const string logBlockName = nameof(KerbalConstructionTime) + "." + nameof(Awake);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                if (KCT_Utilities.CurrentGameIsMission())
                {
                    return;
                }
                GameStates.erroredDuringOnLoad.OnLoadStart();
                GameStates.PersistenceLoaded = false;

                instance = this;

                GameStates.settings.Load(); //Load the settings file, if it exists

                string SavedFile = KSPUtil.ApplicationRootPath + "/saves/" + HighLogic.SaveFolder + "/KCT_Settings.cfg";
                if (!System.IO.File.Exists(SavedFile))
                {
                    GameStates.firstStart = true;
                }

                if (KCT_PresetManager.Instance == null)
                {
                    KCT_PresetManager.Instance = new KCT_PresetManager();
                }
                KCT_PresetManager.Instance.SetActiveFromSaveData();


                //Add the toolbar button
                if (ToolbarManager.ToolbarAvailable && ToolbarManager.Instance != null && GameStates.settings.PreferBlizzyToolbar)
                {
                    Log.Trace("Adding Toolbar Button");
                    GameStates.kctToolbarButton = ToolbarManager.Instance.add("Kerbal_Construction_Time", "MainButton");
                    if (GameStates.kctToolbarButton != null)
                    {
                        if (KCT_PresetManager.PresetLoaded() && !KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled)
                        {
                            GameStates.kctToolbarButton.Visibility = new GameScenesVisibility(GameScenes.SPACECENTER);
                        }
                        else
                        {
                            GameStates.kctToolbarButton.Visibility = new GameScenesVisibility(new GameScenes[] { GameScenes.SPACECENTER, GameScenes.FLIGHT, GameScenes.TRACKSTATION, GameScenes.EDITOR });
                        }
                        GameStates.kctToolbarButton.TexturePath = KCT_Utilities.GetButtonTexture();
                        GameStates.kctToolbarButton.ToolTip     = "Kerbal Construction Time";
                        GameStates.kctToolbarButton.OnClick    += ((e) =>
                        {
                            KCT_GUI.ClickToggle();
                        });
                    }
                }
            }
        }
Esempio n. 4
0
        public void Awake()
        {
            if (KCT_Utilities.CurrentGameIsMission())
            {
                return;
            }

            KCTDebug.Log("Awake called");
            KCT_GameStates.erroredDuringOnLoad.OnLoadStart();
            KCT_GameStates.PersistenceLoaded = false;

            instance = this;

            KCT_GameStates.settings.Load(); //Load the settings file, if it exists

            string SavedFile = KSPUtil.ApplicationRootPath + "/saves/" + HighLogic.SaveFolder + "/KCT_Settings.cfg";

            if (!System.IO.File.Exists(SavedFile))
            {
                KCT_GameStates.firstStart = true;
            }

            if (KCT_PresetManager.Instance == null)
            {
                KCT_PresetManager.Instance = new KCT_PresetManager();
            }
            KCT_PresetManager.Instance.SetActiveFromSaveData();

            // Create events for other mods
            if (!KCT_Events.instance.createdEvents)
            {
                KCT_Events.instance.CreateEvents();
            }

            var go = new GameObject();

            KCT_GameStates.toolbarControl = go.AddComponent <ToolbarControl>();
            KCT_GameStates.toolbarControl.AddToAllToolbars(null, null,//KCT_GUI.ClickOn, KCT_GUI.ClickOff,
                                                           null, null, /* KCT_GUI.onHoverOn, KCT_GUI.onHoverOff, */ null, null,
                                                           ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW | ApplicationLauncher.AppScenes.SPACECENTER | ApplicationLauncher.AppScenes.SPH | ApplicationLauncher.AppScenes.TRACKSTATION | ApplicationLauncher.AppScenes.VAB,
                                                           KCT_GameStates.MODID,
                                                           "MainButton",
                                                           "KerbalConstructionTime/PluginData/Icons/KCT_on-38",
                                                           "KerbalConstructionTime/PluginData/Icons/KCT_off-38",
                                                           "KerbalConstructionTime/PluginData/Icons/KCT_on-24",
                                                           "KerbalConstructionTime/PluginData/Icons/KCT_off-24",
                                                           KCT_GameStates.MODNAME
                                                           );

            KCT_GameStates.toolbarControl.AddLeftRightClickCallbacks(KCT_GUI.ClickToggle, KCT_GUI.onRightClick);

            KCTDebug.Log("Awake finished");
        }
Esempio n. 5
0
        public void Awake()
        {
            if (Utilities.CurrentGameIsMission())
            {
                return;
            }

            KCTDebug.Log("Awake called");
            KCTGameStates.ErroredDuringOnLoad.OnLoadStart();
            KCTGameStates.PersistenceLoaded = false;

            Instance = this;

            KCTGameStates.Settings.Load();

            if (!File.Exists(PresetManager.SettingsFilePath))
            {
                KCTGameStates.IsFirstStart = true;
            }

            if (PresetManager.Instance == null)
            {
                PresetManager.Instance = new PresetManager();
            }
            PresetManager.Instance.SetActiveFromSaveData();

            // Create events for other mods
            if (!KCTEvents.Instance.CreatedEvents)
            {
                KCTEvents.Instance.CreateEvents();
            }

            var obj = new GameObject();

            KCTGameStates.ToolbarControl = obj.AddComponent <ToolbarControl>();
            KCTGameStates.ToolbarControl.AddToAllToolbars(null, null,
                                                          null, null, null, null,
                                                          ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW | ApplicationLauncher.AppScenes.SPACECENTER | ApplicationLauncher.AppScenes.SPH | ApplicationLauncher.AppScenes.TRACKSTATION | ApplicationLauncher.AppScenes.VAB,
                                                          KCTGameStates._modId,
                                                          "MainButton",
                                                          Utilities._icon_KCT_On_38,
                                                          Utilities._icon_KCT_Off_38,
                                                          Utilities._icon_KCT_On_24,
                                                          Utilities._icon_KCT_Off_24,
                                                          KCTGameStates._modName
                                                          );

            KCTGameStates.ToolbarControl.AddLeftRightClickCallbacks(KCT_GUI.ClickToggle, KCT_GUI.OnRightClick);
        }
Esempio n. 6
0
 public EngineersReportClobberer(KerbalConstructionTime instance)
 {
     _kctInstance = instance;
 }
Esempio n. 7
0
        private void ShipModifiedEvent(ShipConstruct vessel)
        {
            KerbalConstructionTime instance = (KerbalConstructionTime)KerbalConstructionTime.instance;

            instance.editorRecalcuationRequired = true;
        }