예제 #1
0
 /// <summary>
 /// Toggles the window visibility.
 /// </summary>
 public void ToggleWindow()
 {
     _active = !_active;
     if (_active)
     {
         RenderingManager.AddToPostDrawQueue(0, OnDraw);
     }
     else
     {
         RenderingManager.RemoveFromPostDrawQueue(0, OnDraw);
         Invoke("ControlUnlock", 1);
     }
 }
예제 #2
0
        internal override void Awake()
        {
            LogFormatted("Awakening the TransferWindowPlanner (TWP)");

            LogFormatted("Loading Settings");
            settings = new Settings("settings.cfg");
            if (!settings.Load())
            {
                LogFormatted("Settings Load Failed");
            }

            InitWindows();

            if (settings.SelectedCalendar == CalendarTypeEnum.Earth)
            {
                KSPDateStructure.SetEarthCalendar(settings.EarthEpoch);
                windowSettings.ddlSettingsCalendar.SelectedIndex = (Int32)settings.SelectedCalendar;
            }

            //plug us in to the draw queue and start the worker
            RenderingManager.AddToPostDrawQueue(1, DrawGUI);


            //Get whether the toolbar is there
            settings.BlizzyToolbarIsAvailable = ToolbarManager.ToolbarAvailable;

            //setup the Toolbar button if necessary
            if (settings.ButtonStyleToDisplay == Settings.ButtonStyleEnum.Toolbar)
            {
                btnToolbar = InitToolbarButton();
            }

            //Hook the App Launcher
            OnGUIAppLauncherReady();
            //GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
            GameEvents.onGameSceneLoadRequested.Add(OnGameSceneLoadRequestedForAppLauncher);

            //Hook the Angle renderers
            if (lstScenesForAngles.Contains(HighLogic.LoadedScene))
            {
                PhaseAngle = MapView.MapCamera.gameObject.AddComponent <AngleRenderPhase>();
                EjectAngle = MapView.MapCamera.gameObject.AddComponent <AngleRenderEject>();
            }

            //do the daily version check if required
            if (settings.DailyVersionCheck)
            {
                settings.VersionCheck(false);
            }
        }
예제 #3
0
    protected override void onPartFixedUpdate()
    {
        foreach (Part p in vessel.parts)
        {
            if (p.attachJoint != null)
            {
                // ozraven p.attachJoint.breakForce = breakingForce;
                // ozraven p.attachJoint.breakTorque = breakingTorque;
                p.attachJoint.SetBreakingForces(breakingForce, breakingTorque); // ozraven
            }
        }
        if ((vessel != null) && (GUIController == null))
        {
            RenderingManager.AddToPostDrawQueue(0, new Callback(drawGUI));
            GUIController = this;
        }

        //sound support
        if (HighLogic.LoadedSceneIsFlight)
        {
            for (int i = 0; i < groups.Count; i++)
            {
                List <MuMechServo> groupServos = new List <MuMechServo>();
                foreach (MuMechServo servo in allServos)
                {
                    if ((servo.group == i) && (servo.vessel == FlightGlobals.ActiveVessel))
                    {
                        groupServos.Add(servo);
                    }
                }
                if (groupServos.Count > 0)
                {
                    foreach (MuMechServo servo in groupServos)
                    {
                        if ((servo.revRotateKey != "" ? Input.GetKeyUp(servo.revRotateKey) : false) ||
                            (servo.rotateKey != "" ? Input.GetKeyUp(servo.rotateKey) : false) ||
                            (servo.translateKey != "" ? Input.GetKeyUp(servo.translateKey) : false) ||
                            (servo.revTranslateKey != "" ? Input.GetKeyUp(servo.revTranslateKey) : false))
                        {
                            servo.fxSndMotor.audio.Stop();
                            servo.isPlaying = false;
                        }
                    }
                }
            }
        }


        base.onPartFixedUpdate();
    }
예제 #4
0
        public override void OnStart(PartModule.StartState state)
        {
            String[] resources_to_supply = { FNResourceManager.FNRESOURCE_THERMALPOWER, FNResourceManager.FNRESOURCE_WASTEHEAT, FNResourceManager.FNRESOURCE_CHARGED_PARTICLES };
            this.resources_to_supply = resources_to_supply;
            print("[KSP Interstellar] Configuring Reactor Fuel Modes");
            fuel_modes = getReactorFuelModes();
            setDefaultFuelMode();
            print("[KSP Interstellar] Configuration Complete");
            System.Random rnd = new System.Random();
            windowID = rnd.Next(int.MaxValue);
            base.OnStart(state);

            if (state == StartState.Editor)
            {
                if (this.HasTechsRequiredToUpgrade())
                {
                    isupgraded = true;
                    upgradePartModule();
                }
                return;
            }

            if (this.HasTechsRequiredToUpgrade())
            {
                hasrequiredupgrade = true;
            }

            if (!reactorInit && startDisabled)
            {
                last_active_time = (float)(Planetarium.GetUniversalTime() - 4.0 * 86400.0);
                IsEnabled        = false;
                startDisabled    = false;
                reactorInit      = true;
            }
            else if (!reactorInit)
            {
                IsEnabled   = true;
                reactorInit = true;
            }
            print("[KSP Interstellar] Reactor Persistent Resource Update");
            if (IsEnabled && last_active_time > 0)
            {
                doPersistentResourceUpdate();
            }

            this.part.force_activate();
            RenderingManager.AddToPostDrawQueue(0, OnGUI);

            print("[KSP Interstellar] Configuring Reactor");
        }
예제 #5
0
    protected override void onActiveUpdate()
    {
        if (!vessels.ContainsKey(vessel))
        {
            vessels[vessel] = new MuMechRCSLiquidEngineGroup();
        }
        if (vessels[vessel].controller == null)
        {
            vessels[vessel].controller = this;
            RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI));
        }

        base.onActiveUpdate();
    }
예제 #6
0
 //**************************************************************
 public override void OnStart(PartModule.StartState state)
 {
     base.OnStart(state);
     if (state.Equals(PartModule.StartState.Editor))
     {
         return;                                            //don't start stuff in the editor
     }
     windowPos = new Rect();
     if ((windowPos.x == 0) && (windowPos.y == 0))//windowPos is used to position the GUI window, lets set it in the center of the screen
     {
         windowPos = new Rect(Screen.width / 2, Screen.height / 2, 100, 100);
     }
     RenderingManager.AddToPostDrawQueue(3, new Callback(draw));
 }
예제 #7
0
 public void TogglePowerCurve()
 {
     DrawPowerGraph();
     _powerCurveView = !_powerCurveView;
     if (_powerCurveView)
     {
         RenderingManager.AddToPostDrawQueue(0, OnDraw);
     }
     else
     {
         RenderingManager.RemoveFromPostDrawQueue(0, OnDraw);
         ControlUnlock();
     }
 }
예제 #8
0
 public override void OnStart(PartModule.StartState state)
 {
     if (state != StartState.Editor)
     {
         if (!_hasInitStyles)
         {
             InitStyles();
         }
         _launchSequenceIsActive = false;
         _buttonPushed           = false;
         _buttonPushed2          = false;
         RenderingManager.AddToPostDrawQueue(0, OnDraw);
     }
 }
예제 #9
0
 public void Start()
 {
     background = new Texture2D(20, 20);
     background.SetPixels(Enumerable.Repeat(Color.white, 20 * 20).ToArray());
     for (int i = 0; i < background.width; i += 5)
     {
         for (int j = 0; j < background.height; j += 5)
         {
             background.SetPixel(i, j, Color.black);
         }
     }
     RenderingManager.AddToPostDrawQueue(0, OnDraw);
     groundStationCS = new CommSystem();
 }
예제 #10
0
        protected void Start()
        {
            // Load the 32x32 pure white png texture
            string path = KSPUtil.ApplicationRootPath.Replace(@"\", "/") + "/GameData/G-Force/White32x32.png";

            byte[] texture = File.ReadAllBytes(path);
            whiteTexture.LoadImage(texture);

            // Hook into the rendering queue to draw the G effects
            RenderingManager.AddToPostDrawQueue(3, new Callback(drawGEffects));

            // Add another rendering queue hook for the GUI
            //RenderingManager.AddToPostDrawQueue(4, new Callback(drawGUI));
        }
예제 #11
0
 /// <summary>
 ///     Initialises the object's state on creation.
 /// </summary>
 protected void Start()
 {
     try
     {
         this.windowId = this.GetHashCode();
         this.InitialiseStyles();
         this.Load();
         RenderingManager.AddToPostDrawQueue(0, this.Draw);
         Logger.Log("ActionMenu->Start");
     }
     catch (Exception ex)
     {
         Logger.Exception(ex);
     }
 }
예제 #12
0
 public void Start()
 {
     showWindow = false;
     if (!CompatibilityChecker.IsCompatible())
     {
         isCompatible = false;
         return;
     }
     scrollPosition = Vector2.zero;
     siteLocations  = KSCLoader.instance.Sites.getSitesGeographicalList();
     loadTextures();
     RenderingManager.AddToPostDrawQueue(2, this.onDraw);
     RenderingManager.AddToPostDrawQueue(3, this.onDrawGUI);
     print("*RSS* KSCSwitcher initialized");
 }
예제 #13
0
        public override void OnStart(StartState state)
        {
            if (state != StartState.Editor)
            {
                RenderingManager.AddToPostDrawQueue(0, OnDraw);
                sampleRate = AudioSettings.outputSampleRate;

                obj = new GameObject();
                obj.AddComponent("AudioSource");
                MakeBeep();
                obj.audio.ignoreListenerVolume = true;
                obj.audio.volume = 1f;
                DontDestroyOnLoad(obj);
            }
        }
예제 #14
0
 private void OnEditorAttach()
 {
     RenderingManager.AddToPostDrawQueue(99, updateEditor);
     if (autoSetRoll)
     {
         setRoll(part.symmetryCounterparts.Count() != 0);
         print("KM_Gimbal: Setting roll for auto set:");
     }
     else
     {
         setRoll(enableRoll);
         print("KM_Gimbal: Leaving roll as is:" + enableRoll);
     }
     //print("KM_Gimbal: attaching");
 }
예제 #15
0
        protected void Start()
        {
            /*string path = KSPUtil.ApplicationRootPath.Replace(@"\", "/") + "/GameData/G-Effects/blackout.png";
             * byte[] texture = File.ReadAllBytes(path);
             * blackoutTexture.LoadImage(texture);*/
            blackoutTexture = GameDatabase.Instance.GetTexture("G-Effects/blackout", false);

            // Hook into the rendering queue to draw the G effects
            RenderingManager.AddToPostDrawQueue(3, new Callback(drawGEffects));
            GameEvents.onGamePause.Add(onPause);
            GameEvents.onGameUnpause.Add(onUnPause);
            GameEvents.onCrewKilled.Add(onCrewKilled);
            GameEvents.onVesselChange.Add(onVesselChange);
            // Add another rendering queue hook for the GUI
            //RenderingManager.AddToPostDrawQueue(4, new Callback(drawGUI));
        }
예제 #16
0
        public void Awake()
        {
            print("Distant Object Enhancement v1.3 -- SettingsGUI initialized");

            foreach (AssemblyLoader.LoadedAssembly assembly in AssemblyLoader.loadedAssemblies)
            {
                if (assembly.name == "Toolbar")
                {
                    toolbarInstalled = true;
                }
            }

            if (toolbarInstalled)
            {
                toolbarButton();
            }

            RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI));

            //Load settings
            settings = ConfigNode.Load(KSPUtil.ApplicationRootPath + "GameData/DistantObject/Settings.cfg");
            foreach (ConfigNode node in settings.GetNodes("DistantFlare"))
            {
                flaresEnabled     = bool.Parse(node.GetValue("flaresEnabled"));
                flareSaturation   = float.Parse(node.GetValue("flareSaturation"));
                flareSize         = float.Parse(node.GetValue("flareSize"));
                flareBrightness   = float.Parse(node.GetValue("flareBrightness"));
                ignoreDebrisFlare = bool.Parse(node.GetValue("ignoreDebrisFlare"));
                debrisBrightness  = float.Parse(node.GetValue("debrisBrightness"));
                debugMode         = bool.Parse(node.GetValue("debugMode"));
                showNames         = bool.Parse(node.GetValue("showNames"));
            }

            foreach (ConfigNode node in settings.GetNodes("DistantVessel"))
            {
                renderVessels = bool.Parse(node.GetValue("renderVessels"));
                maxDistance   = float.Parse(node.GetValue("maxDistance"));
                renderMode    = int.Parse(node.GetValue("renderMode"));
                ignoreDebris  = bool.Parse(node.GetValue("ignoreDebris"));
            }

            foreach (ConfigNode node in settings.GetNodes("SkyboxBrightness"))
            {
                changeSkybox  = bool.Parse(node.GetValue("changeSkybox"));
                maxBrightness = float.Parse(node.GetValue("maxBrightness"));
            }
        }
예제 #17
0
        public void Awake()
        {
            //Load settings
            ReadSettings();

            if (DistantObjectSettings.debugMode)
            {
                Debug.Log(Constants.DistantObject + " -- awake - " + this.GetInstanceID());
            }

            // Load and configure once
            if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                if (useAppLauncher && appLauncherButton == null && ApplicationLauncher.Ready)
                {
                    if (DistantObjectSettings.debugMode)
                    {
                        Debug.Log(Constants.DistantObject + " -- creating new appLauncher instance - " + this.GetInstanceID());
                    }
                    appLauncherButton = InitAppLauncherButton();
                    GameEvents.onGameSceneLoadRequested.Add(onGameSceneLoadRequestedForAppLauncher);
                }


                if (useAppLauncher && appLauncherButton != null)
                {
                    if (onlyInSpaceCenter)
                    {
                        appLauncherButton.VisibleInScenes = ApplicationLauncher.AppScenes.SPACECENTER;
                    }
                    else
                    {
                        appLauncherButton.VisibleInScenes = ApplicationLauncher.AppScenes.SPACECENTER |
                                                            ApplicationLauncher.AppScenes.FLIGHT;
                    }
                }


                if (useToolbar && ToolbarManager.ToolbarAvailable)
                {
                    toolbarButton();
                }

                callback = new Callback(drawGUI);
                RenderingManager.AddToPostDrawQueue(3, callback);
            }
        }
예제 #18
0
 protected override void onPartFixedUpdate()
 {
     foreach (Part p in vessel.parts)
     {
         if (p.attachJoint != null)
         {
             p.attachJoint.breakForce  = breakingForce;
             p.attachJoint.breakTorque = breakingTorque;
         }
     }
     if ((vessel != null) && (GUIController == null))
     {
         RenderingManager.AddToPostDrawQueue(0, new Callback(drawGUI));
         GUIController = this;
     }
     base.onPartFixedUpdate();
 }
예제 #19
0
        protected void onFlightStart()
        {
            //print("FLIGHT STARDER FROM PROGCOM");
            //called at load at launchpad
            if (!shipHasOtherActiveComputer())
            {
                //print("ProgCom initialised!");
                partActive = true;

                //add the gui iff the vessel is the active vessel.
                if (this.vessel.isActiveVessel)
                {
                    partGUI = true;
                    RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI));//start the GUI
                }
            }
        }
예제 #20
0
 protected override void onEditorUpdate()
 {
     if (GUIController == null)
     {
         IRMinimizeButton             = ToolbarManager.Instance.add("sirkut", "IREditorButton");
         IRMinimizeButton.TexturePath = "MagicSmokeIndustries/Textures/icon_button";
         IRMinimizeButton.ToolTip     = "Infernal Robotics";
         IRMinimizeButton.OnClick    += (e) => minimizeGUI = !minimizeGUI;
         RenderingManager.AddToPostDrawQueue(0, new Callback(editorDrawGUI));
         GUIController = this;
     }
     if (group < 0)
     {
         group = groups.Count - 1;
     }
     base.onEditorUpdate();
 }
예제 #21
0
 private void CreateLightCone()
 {
     RenderingManager.AddToPostDrawQueue(0, DrawLightCone);
     if (lightConeRenderer == null)
     {
         lightCone         = new GameObject();
         lightConeRenderer = lightCone.AddComponent <LineRenderer>();
         lightConeRenderer.useWorldSpace = true;
         lightConeRenderer.material      = lightConeMaterial;
         lightConeRenderer.SetWidth(0.054f, endSpan);
         lightConeRenderer.SetVertexCount(2);
         lightConeRenderer.castShadows    = false;
         lightConeRenderer.receiveShadows = false;
         lightConeRenderer.SetPosition(0, Vector3.zero);
         lightConeRenderer.SetPosition(1, Vector3.zero);
         ColorizeLightCone();
     }
 }
예제 #22
0
 void onAppLauncherToggleOn()
 {
     Debug.Log("Toggled on");
     RenderingManager.AddToPostDrawQueue(0, OnDraw);
     Debug.Log("Saving config to" + save_folder);
     Debug.Log("billing_enabled = " + billing_enabled);
     Debug.Log("autopayEnabled = " + autopayEnabled);
     Debug.Log("threshold = " + threshold);
     Debug.Log("level0 = " + level0);
     Debug.Log("level1 = " + level1);
     Debug.Log("level2 = " + level2);
     Debug.Log("level3 = " + level3);
     Debug.Log("level4 = " + level4);
     Debug.Log("level5 = " + level5);
     Debug.Log("standbyPct = " + standbyPct);
     Debug.Log("yearly = " + yearly);
     //ResetToDefault();
 }
예제 #23
0
    protected override void onActiveUpdate()
    {
        if ((vessel != null) && !vessels.ContainsKey(vessel))
        {
            vessels[vessel] = new MuMechVariableEngineGroup();
        }
        if (vessels[vessel].controller == null)
        {
            vessels[vessel].controller = this;
            RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI));
        }
        if (!vessels[vessel].groups.ContainsKey(group))
        {
            vessels[vessel].groups[group] = start;
        }

        base.onActiveUpdate();
    }
예제 #24
0
    protected override void onFlightStart()
    {
        if (!vessels.ContainsKey(vessel))
        {
            vessels[vessel] = new MuMechRCSLiquidEngineGroup();
        }
        if (vessels[vessel].controller == null)
        {
            vessels[vessel].controller = this;
            RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI));
        }
        if (!vessels[vessel].groups.ContainsKey(group) || start)
        {
            vessels[vessel].groups[group] = start;
        }

        base.onFlightStart();
    }
예제 #25
0
 public override void OnStart(PartModule.StartState state)
 {
     if (state == StartState.Editor)
     {
         return;
     }
     System.Random rnd = new System.Random();
     _window_ID           = rnd.Next(int.MaxValue);
     _refinery_activities = new List <IRefineryActivity>();
     _refinery_activities.Add(new NuclearFuelReprocessor(this.part));
     _refinery_activities.Add(new AluminiumElectrolyser(this.part));
     _refinery_activities.Add(new SabatierReactor(this.part));
     _refinery_activities.Add(new WaterElectroliser(this.part));
     _refinery_activities.Add(new AnthraquinoneProcessor(this.part));
     _refinery_activities.Add(new MonopropellantProducer(this.part));
     _refinery_activities.Add(new UF4Ammonolysiser(this.part));
     RenderingManager.AddToPostDrawQueue(0, OnGUI);
 }
        public override void OnStart(PartModule.StartState state)
        {
            if (UseStagingIcon)
            {
                this.part.stagingIcon = "FUEL_TANK";
            }
            else
            {
                Debug.Log("NFPP:Reactor Staging Icon Disabled");
            }

            PressureCurve = new FloatCurve();
            PressureCurve.Add(0f, 0f);
            PressureCurve.Add(1f, 2f);



            if (state != StartState.Editor)
            {
                if (UseStagingIcon)
                {
                    infoBox = this.part.stackIcon.DisplayInfo();

                    infoBox.SetMsgBgColor(XKCDColors.RedOrange);
                    infoBox.SetMsgTextColor(XKCDColors.Orange);
                    infoBox.SetLength(1.0f);
                    infoBox.SetMessage("CoreHeat");
                    infoBox.SetProgressBarBgColor(XKCDColors.RedOrange);
                    infoBox.SetProgressBarColor(XKCDColors.Orange);
                }
                generatorAnimation = part.Modules.OfType <FissionGeneratorAnimator>().First();
                SetupRadiators();

                if (UseForcedActivation)
                {
                    this.part.force_activate();
                }
                RenderingManager.AddToPostDrawQueue(0, DrawGUI);

                FuelUpdate();
            }

            // LogItAll();
        }
예제 #27
0
        public override void OnStart(StartState state)
        {
            //print("###Biomatic OnStart");
            if (!useStockToolBar) // blizzy
            {
                try
                {
                    //print("###Toolbar init");
                    toolbarButton = new ToolbarButtonWrapper("Biomatic", "toolbarButton");
                    RefreshBlizzyButton();
                    toolbarButton.ToolTip = "Biomatic settings";
                    toolbarButton.Visible = true;
                    toolbarButton.AddButtonClickHandler((e) =>
                    {
                        //print("### prox toolbar button clicked");
                        toolbarShowSettings = !toolbarShowSettings;
                        RefreshBlizzyButton();
                        sizechange = true;
                    });
                }
                catch (Exception ex)
                {
                    //print("###Exception on blizzy toolbar init, msg = " + ex.Message);
                }
                UseToolbar = true;
            }
            else // stock
            {
                UseToolbar = true;
            }

            if (state != StartState.Editor)
            {
                RenderingManager.AddToPostDrawQueue(0, OnDraw);

                if (listIgnore == null)
                {
                    listIgnore = new List <string>();
                }

                historyArray = new BiomeSituation[5];
                sizechange   = true;
            }
        }
예제 #28
0
        public virtual void SetVisible(bool newValue)
        {
            if (newValue)
            {
                if (!visible)
                {
                    RenderingManager.AddToPostDrawQueue(3, new Callback(DrawWindow));
                }
            }
            else
            {
                if (visible)
                {
                    RenderingManager.RemoveFromPostDrawQueue(3, new Callback(DrawWindow));
                }
            }

            this.visible = newValue;
        }
예제 #29
0
        public override void OnStart(PartModule.StartState state)
        {
            if (state != PartModule.StartState.None && state != PartModule.StartState.Editor)
            {
                RenderingManager.AddToPostDrawQueue(1, DrawBoundingBox);

                // Turn off docking AP on successful docking (in case other checks for successful docking fail)
                GameEvents.onPartCouple.Add((GameEvents.FromToAction <Part, Part> ev) =>
                {
                    if (dockingStep != DockingStep.OFF)
                    {
                        if (ev.from.vessel == vessel || ev.to.vessel == vessel)
                        {
                            EndDocking();
                        }
                    }
                });
            }
        }
예제 #30
0
        public void SetVisible(bool newValue)
        {
            if (newValue)
            {
                if (!visible)
                {
                    RenderingManager.AddToPostDrawQueue(3, DrawIcon);
                }
            }
            else
            {
                if (visible)
                {
                    RenderingManager.RemoveFromPostDrawQueue(3, DrawIcon);
                }
            }

            this.visible = newValue;
        }