Пример #1
0
        public override void OnAwake()
        {
            this.Log_DebugOnly("OnAwake", "Scene[{0}]", HighLogic.LoadedScene);
            base.OnAwake();

            if (cls == null)
            {
                cls = CLSClient.GetCLS();
            }

            if (mainWindow == null)
            {
                mainWindow = gameObject.AddComponent<MainWindow>();
                mainWindow.Init(this);
            }

            if (logWindow == null)
            {
                logWindow = gameObject.AddComponent<LogWindow>();
                logWindow.Init(this);
            }

            if (configWindow == null)
            {
                configWindow = gameObject.AddComponent<ConfigWindow>();
                configWindow.Init(this);
            }

            if (rosterWindow == null)
            {
                this.Log_DebugOnly("OnAwake", "Constructing rosterWindow");
                rosterWindow = gameObject.AddComponent<RosterWindow>();
                rosterWindow.Init(this);
            }

            if (allVesselsWindow == null)
            {
                this.Log_DebugOnly("OnAwake", "Constructing allVesselsWindow");
                allVesselsWindow = gameObject.AddComponent<AllVesselsWindow>();
                allVesselsWindow.Init(this);
            }

            if (appLauncherButton != null)
            {
                this.Log_DebugOnly("OnAwake", "AppLauncher button already here");
            }
            else
            {
                this.Log_DebugOnly("OnAwake", "Adding AppLauncher button");

                Texture toolbarButtonTexture = (Texture)GameDatabase.Instance.GetTexture("KeepFit/KeepFit", false);
                ApplicationLauncher.AppScenes scenes = ApplicationLauncher.AppScenes.FLIGHT |
                                                       ApplicationLauncher.AppScenes.MAPVIEW |
                                                       ApplicationLauncher.AppScenes.SPACECENTER |
                                                       ApplicationLauncher.AppScenes.SPH |
                                                       ApplicationLauncher.AppScenes.VAB |
                                                       ApplicationLauncher.AppScenes.TRACKSTATION;

                appLauncherButton = ApplicationLauncher.Instance.AddModApplication(onAppLaunchToggleOn,
                                                               onAppLaunchToggleOff,
                                                               onAppLaunchHoverOn,
                                                               onAppLaunchHoverOff,
                                                               onAppLaunchEnable,
                                                               onAppLaunchDisable,
                                                               scenes,
                                                               toolbarButtonTexture);
                ApplicationLauncher.Instance.AddOnRepositionCallback(onAppLauncherReposition);
            }

            this.Log_DebugOnly("OnAwake", "Adding KeepFitCrewRosterController");
            crewRosterController = gameObject.AddComponent<KeepFitCrewRosterController>();
            crewRosterController.Init(this);

            if (HighLogic.LoadedScene == GameScenes.FLIGHT ||
                HighLogic.LoadedScene == GameScenes.TRACKSTATION ||
                HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                this.Log_DebugOnly("OnAwake", "Adding KeepFitCrewFitnessController");
                crewFitnessController = gameObject.AddComponent<KeepFitCrewFitnessController>();
                crewFitnessController.Init(this);
            }

            if (HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                this.Log_DebugOnly("OnAwake", "Adding KeepFitGeeEffectsController");
                this.geeEffectsController = gameObject.AddComponent<KeepFitGeeEffectsController>();
                this.geeEffectsController.Init(this);
            }
        }
Пример #2
0
        void OnDestroy()
        {
            this.Log_DebugOnly("OnDestroy", ".");
            if (appLauncherButton == null)
            {
                this.Log_DebugOnly("OnDestroy", "No appLauncher button to remove.");
            }
            else
            {
                this.Log_DebugOnly("OnDestroy", "Removing appLauncher button.");
                ApplicationLauncher.Instance.DisableMutuallyExclusive(appLauncherButton);
                ApplicationLauncher.Instance.RemoveModApplication(appLauncherButton);
                appLauncherButton = null;
            }

            if (this.crewFitnessController == null)
            {
                this.Log_DebugOnly("OnDestroy", "No crewFitness controller to destroy.");
            }
            else
            {
                this.Log_DebugOnly("OnDestroy", "Destroying crewFitness controller.");
                Destroy(crewFitnessController);
                crewFitnessController = null;
            }

            if (this.crewRosterController == null)
            {
                this.Log_DebugOnly("OnDestroy", "No crewRoster controller to destroy.");
            }
            else
            {
                this.Log_DebugOnly("OnDestroy", "Destroying crewRoster controller.");
                Destroy(crewRosterController);
                crewRosterController = null;
            }

            if (this.geeEffectsController == null)
            {
                this.Log_DebugOnly("OnDestroy", "No geeEffects controller to destroy.");
            }
            else
            {
                this.Log_DebugOnly("OnDestroy", "Destroying geeEffects controller.");
                Destroy(geeEffectsController);
                geeEffectsController = null;
            }

            if (mainWindow != null)
            {
                Destroy(mainWindow);
                mainWindow = null;
            }

            if (logWindow != null)
            {
                Destroy(logWindow);
                logWindow = null;
            }

            if (configWindow != null)
            {
                Destroy(configWindow);
                configWindow = null;
            }

            if (rosterWindow != null)
            {
                Destroy(rosterWindow);
                rosterWindow = null;
            }

            if (allVesselsWindow == null)
            {
                Destroy(allVesselsWindow);
                allVesselsWindow = null;
            }

        }