Ejemplo n.º 1
0
        private void OnGUI()
        {
            //GUI.skin = _mySkin;
            CelestialBody current = null;

            if (MapView.MapIsEnabled)
            {
                current = OverlayManager.GetMapBody();
            }
            else
            {
                current = FlightGlobals.currentMainBody;
            }
            if (HeadMaster.useEditor && current != null)
            {
                if (AdvancedGUI)
                {
                    _mainWindowRect.width = 520;
                }
                else
                {
                    _mainWindowRect.width = 260;
                }
                if (CloudLayer.GetBodyLayerCount(ConfigNodeList[SelectedConfig].url, current.name) != 0)
                {
                    _mainWindowRect.height = 745;
                    _mainWindowRect        = GUI.Window(0x8100, _mainWindowRect, DrawMainWindow, "Clouds");
                }
                else
                {
                    _mainWindowRect.height = 115;
                    _mainWindowRect        = GUI.Window(0x8100, _mainWindowRect, DrawMainWindow, "Clouds");
                }
            }
        }
Ejemplo n.º 2
0
 private void DrawMainWindow(int windowID)
 {
     oldBody     = currentBody;
     currentBody = null;
     if (MapView.MapIsEnabled)
     {
         currentBody = OverlayManager.GetMapBody();
     }
     else
     {
         currentBody = FlightGlobals.currentMainBody;
     }
     if (currentBody != null)
     {
         GUIStyle gs = new GUIStyle(GUI.skin.label);
         gs.alignment = TextAnchor.MiddleCenter;
         AdvancedGUI  = GUI.Toggle(
             new Rect(10, 110, 125, 25), AdvancedGUI, "Advanced Settings");
         float itemFullWidth = AdvancedGUI ? (_mainWindowRect.width / 2) - 20 : _mainWindowRect.width - 20;
         GUI.Label(new Rect(35, 20, itemFullWidth - 50, 25), currentBody.name, gs);
         if (MapView.MapIsEnabled)
         {
             if (GUI.Button(new Rect(10, 20, 25, 25), "<"))
             {
                 MapView.MapCamera.SetTarget(OverlayManager.GetPreviousBody(currentBody).name);
             }
             if (GUI.Button(new Rect(itemFullWidth - 15, 20, 25, 25), ">"))
             {
                 MapView.MapCamera.SetTarget(OverlayManager.GetNextBody(currentBody).name);
             }
         }
         float halfWidth = (itemFullWidth / 2) - 5;
         if (GUI.Button(new Rect(10, 50, halfWidth, 25), "Reset to Save"))
         {
             loadCloudLayers(false);
             oldBody = null;
         }
         if (GUI.Button(new Rect(halfWidth + 20, 50, halfWidth, 25), "Reset to Default"))
         {
             loadCloudLayers(true);
             oldBody = null;
         }
         bool selectedConfigChanged = false;
         if (GUI.Button(new Rect(itemFullWidth - 15, 80, 25, 25), ">"))
         {
             SelectedConfig++;
             if (ConfigNodeList.Count <= SelectedConfig)
             {
                 SelectedConfig = 0;
             }
             selectedConfigChanged = true;
         }
         string configUrl = ConfigNodeList[SelectedConfig].url;
         GUI.Button(new Rect(10, 80, itemFullWidth - 30, 25), ConfigNodeList[SelectedConfig].parent.url);
         int  layerCount = CloudLayer.GetBodyLayerCount(configUrl, currentBody.name);
         bool hasLayers  = layerCount != 0;
         halfWidth = hasLayers ? (itemFullWidth / 2) - 5 : itemFullWidth;
         if (GUI.Button(new Rect(10, 140, halfWidth, 25), "Add"))
         {
             ConfigNode newNode = new ConfigNode("CLOUD_LAYER");
             ConfigNodeList.First(n => n.url == configUrl).config.AddNode(newNode);
             CloudLayer.Layers.Add(
                 new CloudLayer(configUrl, newNode, currentBody.name, new Color(1, 1, 1, 1), 1000f,
                                new TextureSet(true), new TextureSet(), null, null, false));
         }
         if (hasLayers)
         {
             GUI.Box(new Rect(10, 170, itemFullWidth, 115), "");
             String[] layerList = CloudLayer.GetBodyLayerStringList(configUrl, currentBody.name);
             ScrollPosLayerList = GUI.BeginScrollView(new Rect(15, 175, itemFullWidth - 10, 100), ScrollPosLayerList, new Rect(0, 0, itemFullWidth - 30, 25 * layerList.Length));
             float layerWidth       = layerCount > 4 ? itemFullWidth - 30 : itemFullWidth - 10;
             int   OldSelectedLayer = SelectedLayer;
             SelectedLayer = SelectedLayer >= layerCount || SelectedLayer < 0 ? 0 : SelectedLayer;
             SelectedLayer = GUI.SelectionGrid(new Rect(0, 0, layerWidth, 25 * layerList.Length), SelectedLayer, layerList, 1);
             GUI.EndScrollView();
             if (GUI.Button(new Rect(halfWidth + 20, 140, halfWidth, 25), "Remove"))
             {
                 CloudLayer.RemoveLayer(configUrl, currentBody.name, SelectedLayer);
                 SelectedLayer = -1;
                 return;
             }
             if (SelectedLayer != OldSelectedLayer || currentBody != oldBody || selectedConfigChanged)
             {
                 if (CloudLayer.ConfigBodyDatabase[configUrl].ContainsKey(currentBody.name) && CloudLayer.ConfigBodyDatabase[configUrl][currentBody.name].Count > SelectedLayer)
                 {
                     CloudGUI.MainTexture.Clone(CloudLayer.ConfigBodyDatabase[configUrl][currentBody.name][SelectedLayer].MainTexture);
                     CloudGUI.DetailTexture.Clone(CloudLayer.ConfigBodyDatabase[configUrl][currentBody.name][SelectedLayer].DetailTexture);
                     CloudGUI.Color.Clone(CloudLayer.ConfigBodyDatabase[configUrl][currentBody.name][SelectedLayer].Color);
                     CloudGUI.Altitude.Clone(CloudLayer.ConfigBodyDatabase[configUrl][currentBody.name][SelectedLayer].Altitude);
                     CloudGUI.ScaledShaderFloats.Clone(CloudLayer.ConfigBodyDatabase[configUrl][currentBody.name][SelectedLayer].ScaledShaderFloats);
                     CloudGUI.ShaderFloats.Clone(CloudLayer.ConfigBodyDatabase[configUrl][currentBody.name][SelectedLayer].ShaderFloats);
                     CloudGUI.UseVolume = CloudLayer.ConfigBodyDatabase[configUrl][currentBody.name][SelectedLayer].UseVolume;
                 }
             }
             if (CloudGUI.IsValid())
             {
                 if (GUI.Button(new Rect(145, 110, 50, 25), "Apply"))
                 {
                     CloudLayer.ConfigBodyDatabase[configUrl][currentBody.name][SelectedLayer].ApplyGUIUpdate(CloudGUI);
                 }
                 if (GUI.Button(new Rect(200, 110, 50, 25), "Save"))
                 {
                     CloudLayer.ConfigBodyDatabase[configUrl][currentBody.name][SelectedLayer].ApplyGUIUpdate(CloudGUI);
                     saveCloudLayers();
                 }
             }
             gs.alignment = TextAnchor.MiddleRight;
             if (AdvancedGUI)
             {
                 GUI.Label(new Rect((_mainWindowRect.width / 2) + 10, 20, itemFullWidth, 25), "Settings:");
                 int advancedNextLine = HandleAdvancedGUI(CloudGUI.ShaderFloats, 50, _mainWindowRect.width / 2);
                 GUI.Label(new Rect((_mainWindowRect.width / 2) + 10, advancedNextLine, itemFullWidth, 25), "Scaled Settings:");
                 HandleAdvancedGUI(CloudGUI.ScaledShaderFloats, advancedNextLine + 30, _mainWindowRect.width / 2);
             }
             int nextLine = 290;
             nextLine           = HandleAltitudeGUI(CloudGUI.Altitude, nextLine);
             CloudGUI.UseVolume = GUI.Toggle(new Rect(10, nextLine, 125, 25), CloudGUI.UseVolume, "Volumetric Clouds");
             nextLine          += 30;
             nextLine           = HandleColorGUI(CloudGUI.Color, nextLine);
             GUI.Label(new Rect(10, nextLine, 80, 25), "MainTex: ", gs);
             nextLine = HandleTextureGUI(CloudGUI.MainTexture, nextLine);
             GUI.Label(new Rect(10, nextLine, 80, 25), "DetailTex: ", gs);
             CloudGUI.DetailTexture.InUse = GUI.Toggle(new Rect(10, nextLine, 25, 25), CloudGUI.DetailTexture.InUse, "");
             if (CloudGUI.DetailTexture.InUse)
             {
                 nextLine = HandleTextureGUI(CloudGUI.DetailTexture, nextLine);
             }
             else
             {
                 nextLine += 30;
             }
         }
     }
     else
     {
         GUI.Label(new Rect(50, 50, 230, 25), "----");
     }
     GUI.DragWindow(new Rect(0, 0, 10000, 10000));
 }