Beispiel #1
0
        public override void OnEncodeToConfigNode()
        {
            SCANUtil.SCANdebugLog("Saving Terrain Node");
            if (clampTerrain == null)
            {
                clampHeight = "Null";
            }
            else
            {
                clampHeight = clampTerrain.Value.ToString("F0");
            }

            paletteName = colorPal.name;
        }
Beispiel #2
0
        public override void OnDecodeFromConfigNode()
        {
            body = FlightGlobals.Bodies.FirstOrDefault(b => b.flightGlobalsIndex == index);
            if (body != null)
            {
                name = body.name;
            }

            colorPal = SCANUtil.paletteLoader(paletteName, paletteSize);

            float tempClamp = 0;

            if (clampHeight == "Null" || clampHeight == "null" || string.IsNullOrEmpty(clampHeight))
            {
                clampTerrain = null;
            }
            else if (float.TryParse(clampHeight, out tempClamp))
            {
                clampTerrain = tempClamp;
            }
            else
            {
                clampTerrain = null;
            }

            setDefaultValues();

            SCANUtil.SCANdebugLog("SCANsat Terrain Config Decode");
            SCANUtil.SCANdebugLog("-------->Body Name             =>   {0}", name);
            SCANUtil.SCANdebugLog("-------->Body Index            =>   {0}", index);
            SCANUtil.SCANdebugLog("-------->Min Height Range      =>   {0}", minHeightRange);
            SCANUtil.SCANdebugLog("-------->Max Height Range      =>   {0}", maxHeightRange);
            SCANUtil.SCANdebugLog("-------->Clamp Height          =>   {0}", clampHeight);
            SCANUtil.SCANdebugLog("-------->Palette Name          =>   {0}", paletteName);
            SCANUtil.SCANdebugLog("-------->Palette Size          =>   {0}", paletteSize);
            SCANUtil.SCANdebugLog("-------->Palette Reverse       =>   {0}", paletteReverse);
            SCANUtil.SCANdebugLog("-------->Palette Discrete      =>   {0}", paletteDiscrete);
        }
Beispiel #3
0
        protected override void DrawWindowPost(int id)
        {
            if (dropDown && Event.current.type == EventType.mouseDown && !ddRect.Contains(Event.current.mousePosition))
            {
                dropDown = false;
            }

            //These methods update all of the UI elements whenever any of the options are changed
            if (windowMode == 0)
            {
                if (currentTerrain.PalRev != oldReverseState)
                {
                    oldReverseState = currentTerrain.PalRev;
                    drawPreviewLegend();
                }

                if (minTerrainSlider.valueChanged() || maxTerrainSlider.valueChanged())
                {
                    setTerrainSliders();
                }

                if (currentTerrain.PalDis != oldDiscreteState)
                {
                    oldDiscreteState = currentTerrain.PalDis;
                    drawPreviewLegend();
                }

                if (clampState != oldClampState)
                {
                    oldClampState = clampState;
                    drawPreviewLegend();
                }

                if (paletteSizeSlider.valueChanged())
                {
                    regenPaletteSets();
                    currentTerrain.ColorPal = palette.CurrentPalettes.availablePalettes[paletteIndex];
                    drawPreviewLegend();
                }
            }
            else if (windowMode == 1)
            {
                slopeColorPickerLow.colorStateChanged();
                slopeColorPickerLow.brightnessChanged();
                slopeColorPickerHigh.colorStateChanged();
                slopeColorPickerHigh.brightnessChanged();
            }
            else if (windowMode == 2)
            {
                biomeColorPicker.colorStateChanged();
                biomeColorPicker.brightnessChanged();
            }
            else if (windowMode == 3)
            {
                if (resourceMinSlider.valueChanged() || resourceMaxSlider.valueChanged())
                {
                    setResourceSliders();
                }

                if (bodyIndex != data.Body.flightGlobalsIndex)
                {
                    SCANUtil.SCANdebugLog("Trigger Body Change");
                    bodyIndex = data.Body.flightGlobalsIndex;

                    currentResource.CurrentBodyConfig(data.Body.name);

                    lowRCutoff  = currentResource.CurrentBody.MinValue;
                    highRCutoff = currentResource.CurrentBody.MaxValue;

                    oldFineControl = fineControlMode = false;

                    setResourceSliders();
                }

                if (oldFineControl != fineControlMode)
                {
                    oldFineControl = fineControlMode;
                    if (fineControlMode)
                    {
                        if (lowRCutoff < 5f)
                        {
                            resourceMinSlider.MinValue = 0f;
                        }
                        else
                        {
                            resourceMinSlider.MinValue = lowRCutoff - 5;
                        }

                        if (lowRCutoff > 95f)
                        {
                            resourceMinSlider.MaxValue = 100f;
                        }
                        else if (highRCutoff < lowRCutoff + 5f)
                        {
                            resourceMinSlider.MaxValue = highRCutoff - 0.1f;
                        }
                        else
                        {
                            resourceMinSlider.MaxValue = lowRCutoff + 5f;
                        }

                        if (highRCutoff < 5f)
                        {
                            resourceMaxSlider.MinValue = 0f;
                        }
                        else if (lowRCutoff > highRCutoff - 5f)
                        {
                            resourceMaxSlider.MinValue = lowRCutoff + 0.1f;
                        }
                        else
                        {
                            resourceMaxSlider.MinValue = highRCutoff - 5f;
                        }

                        if (highRCutoff > 95f)
                        {
                            resourceMaxSlider.MaxValue = 100f;
                        }
                        else
                        {
                            resourceMaxSlider.MaxValue = highRCutoff + 5f;
                        }
                    }
                    else
                    {
                        setResourceSliders();
                    }
                }

                resourceColorPicker.colorStateChanged();
                resourceColorPicker.brightnessChanged();
            }

            sessionRect = WindowRect;
        }
Beispiel #4
0
        protected override void DrawWindowPre(int id)
        {
            //Some clumsy logic is used here to ensure that the color selection fields always remain in sync with the current map in each scene
            if (HighLogic.LoadedSceneIsFlight)
            {
                if (data == null)
                {
                    data = SCANUtil.getData(FlightGlobals.currentMainBody);
                    if (data == null)
                    {
                        data = new SCANdata(FlightGlobals.currentMainBody);
                        SCANcontroller.controller.addToBodyData(FlightGlobals.currentMainBody, data);
                    }
                }

                if (bigMapObj.Visible && SCANBigMap.BigMap != null)
                {
                    data   = bigMapObj.Data;
                    bigMap = SCANBigMap.BigMap;
                }
                else if (data.Body != FlightGlobals.currentMainBody)
                {
                    data = SCANUtil.getData(FlightGlobals.currentMainBody);
                    if (data == null)
                    {
                        data = new SCANdata(FlightGlobals.currentMainBody);
                        SCANcontroller.controller.addToBodyData(FlightGlobals.currentMainBody, data);
                    }
                }

                if (bigMap == null)
                {
                    if (SCANBigMap.BigMap != null)
                    {
                        bigMap = SCANBigMap.BigMap;
                    }
                }
            }

            //Lock space center click through - Sync SCANdata
            else if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                if (data == null)
                {
                    data = SCANUtil.getData(Planetarium.fetch.Home);
                    if (data == null)
                    {
                        data = new SCANdata(Planetarium.fetch.Home);
                        SCANcontroller.controller.addToBodyData(Planetarium.fetch.Home, data);
                    }
                }
                if (kscMapObj.Visible)
                {
                    data   = kscMapObj.Data;
                    bigMap = SCANkscMap.BigMap;
                }
                else if (data.Body != Planetarium.fetch.Home)
                {
                    data = SCANUtil.getData(Planetarium.fetch.Home);
                    if (data == null)
                    {
                        data = new SCANdata(Planetarium.fetch.Home);
                        SCANcontroller.controller.addToBodyData(Planetarium.fetch.Home, data);
                    }
                }
                if (bigMap == null)
                {
                    if (SCANkscMap.BigMap != null)
                    {
                        bigMap = SCANkscMap.BigMap;
                    }
                }
                Vector2 mousePos = Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;
                if (WindowRect.Contains(mousePos) && !controlLock)
                {
                    InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS | ControlTypes.KSC_ALL, lockID);
                    controlLock = true;
                }
                else if (!WindowRect.Contains(mousePos) && controlLock)
                {
                    removeControlLocks();
                }
            }

            //Lock tracking scene click through - Sync SCANdata
            else if (HighLogic.LoadedScene == GameScenes.TRACKSTATION)
            {
                if (data == null)
                {
                    data = SCANUtil.getData(Planetarium.fetch.Home);
                    if (data == null)
                    {
                        data = new SCANdata(Planetarium.fetch.Home);
                        SCANcontroller.controller.addToBodyData(Planetarium.fetch.Home, data);
                    }
                }
                if (kscMapObj.Visible)
                {
                    data   = kscMapObj.Data;
                    bigMap = SCANkscMap.BigMap;
                }
                else if (data.Body != Planetarium.fetch.Home)
                {
                    data = SCANUtil.getData(Planetarium.fetch.Home);
                    if (data == null)
                    {
                        data = new SCANdata(Planetarium.fetch.Home);
                        SCANcontroller.controller.addToBodyData(Planetarium.fetch.Home, data);
                    }
                }
                if (bigMap == null)
                {
                    if (SCANkscMap.BigMap != null)
                    {
                        bigMap = SCANkscMap.BigMap;
                    }
                }
                Vector2 mousePos = Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;
                if (WindowRect.Contains(mousePos) && !controlLock)
                {
                    InputLockManager.SetControlLock(ControlTypes.TRACKINGSTATION_UI, lockID);
                    controlLock = true;
                }
                else if (!WindowRect.Contains(mousePos) && controlLock)
                {
                    removeControlLocks();
                }
            }

            //This updates all of the fields whenever the palette selection is changed
            if (windowMode == 0 && (currentLegend == null || bodyIndex != data.Body.flightGlobalsIndex))
            {
                currentTerrain = new SCANterrainConfig(data.TerrainConfig);

                SCANUtil.SCANdebugLog("Trigger Body Change");
                bodyIndex = data.Body.flightGlobalsIndex;

                currentTerrain = new SCANterrainConfig(data.TerrainConfig);

                updateUI();
            }

            if (windowMode == 0 && previewLegend == null)
            {
                drawPreviewLegend();
            }

            if (!dropDown)
            {
                paletteBox  = false;
                resourceBox = false;
                saveWarning = false;
            }
        }