Beispiel #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");
                }
            }
        }
Beispiel #2
0
 private void saveCloudLayers()
 {
     //Debug.Log("Save Cloud Layers Called"); Called on GUI Saving
     foreach (KeyValuePair <String, List <CloudLayer> > cloudList in CloudLayer.BodyDatabase.ToArray())
     {
         String            body = cloudList.Key;
         List <CloudLayer> list = cloudList.Value;
         foreach (CloudLayer cloudLayer in list)
         {
             ConfigNode saveNode = cloudLayer.ConfigNode.GetNode("SAVED");
             if (saveNode == null)
             {
                 saveNode = cloudLayer.ConfigNode.AddNode("SAVED");
             }
             saveNode.ClearData();
             saveNode.AddValue("body", body);
             saveNode.AddValue("altitude", cloudLayer.Altitude.ToString());
             saveNode.AddValue("volume", cloudLayer.UseVolume);
             ConfigNode colorNode = saveNode.AddNode("color");
             colorNode.AddValue("r", cloudLayer.Color.r.ToString());
             colorNode.AddValue("g", cloudLayer.Color.g.ToString());
             colorNode.AddValue("b", cloudLayer.Color.b.ToString());
             colorNode.AddValue("a", cloudLayer.Color.a.ToString());
             saveNode.AddNode(cloudLayer.MainTexture.GetNode("main_texture"));
             ConfigNode detailNode = cloudLayer.DetailTexture.GetNode("detail_texture");
             if (detailNode != null)
             {
                 saveNode.AddNode(detailNode);
             }
             ConfigNode scaledShaderFloatNode = cloudLayer.ScaledShaderFloats.GetNode("scaled_shader_floats");
             if (!CloudLayer.IsDefaultShaderFloat(cloudLayer.ScaledShaderFloats, true))
             {
                 saveNode.AddNode(scaledShaderFloatNode);
             }
             ConfigNode shaderFloatNode = cloudLayer.ShaderFloats.GetNode("shader_floats");
             if (!CloudLayer.IsDefaultShaderFloat(cloudLayer.ShaderFloats, false))
             {
                 saveNode.AddNode(shaderFloatNode);
             }
         }
     }
     UrlDir.UrlConfig[] packLayersConfigs = GameDatabase.Instance.GetConfigs("CLOUD_LAYER_PACK");
     foreach (UrlDir.UrlConfig node in packLayersConfigs)
     {
         List <ConfigNode> remove = new List <ConfigNode>();
         foreach (ConfigNode config in node.config.nodes)
         {
             if (config.HasValue("REMOVED") && bool.Parse(config.GetValue("REMOVED")) &&
                 !config.HasNode("DEFAULTS"))
             {
                 remove.Add(config);
             }
         }
         foreach (ConfigNode config in remove)
         {
             node.config.nodes.Remove(config);
         }
         node.parent.SaveConfigs();
     }
 }
 internal static void RemoveLayer(string url, string body, int SelectedLayer)
 {
     if (ConfigBodyDatabase[url].ContainsKey(body))
     {
         CloudLayer layer = ConfigBodyDatabase[url][body][SelectedLayer];
         layer.node.AddValue("REMOVED", true);
         layer.Remove();
     }
 }
 internal void Destroy()
 {
     GameObject.DestroyImmediate(translator);
     foreach (VolumeSection vs in VolumeList)
     {
         vs.Destroy();
     }
     CloudLayer.Log("Volume Destroyed");
 }
 public VolumeManager(float cloudSphereRadius, Texture2D texture, Material cloudParticleMaterial, Transform transform)
     : this(cloudSphereRadius, transform)
 {
     atmosphere = false;
     VolumeList.Add(new VolumeSection(texture, cloudParticleMaterial, transform, Center.localPosition, Magnitude, new Vector3(-radius, 0, 0), radius, divisions));
     VolumeList.Add(new VolumeSection(texture, cloudParticleMaterial, transform, Center.localPosition, Magnitude, new Vector3(halfRad, 0, opp), radius, divisions));
     VolumeList.Add(new VolumeSection(texture, cloudParticleMaterial, transform, Center.localPosition, Magnitude, new Vector3(halfRad, 0, -opp), radius, divisions));
     forceUpdate = true;
     CloudLayer.Log("Volume Initialized");
 }
 private void MacroCallback(bool isNotScaled)
 {
     if (volume != null)
     {
         volume.Enabled = isNotScaled;
         CloudLayer.Log("Volume Enabled=" + isNotScaled);
     }
     else if (volume == null && isNotScaled)
     {
         volume = new VolumeManager(CloudOverlay.Radius, (Texture2D)this.mainTexture.Texture, CloudParticleMaterial, this.CloudOverlay.Transform);
     }
 }
Beispiel #7
0
        private void LoadConfigNode(ConfigNode node, string url, bool useVolume, bool defaults)
        {
            //Debug.Log("LoadConfigNode Called"); Called on MainMenu
            ConfigNode loadNode = node.GetNode("SAVED");

            if ((loadNode == null || defaults) && node.HasNode("DEFAULTS"))
            {
                loadNode = node.GetNode("DEFAULTS");
                loadNode.RemoveValue("REMOVED");
            }
            else if (node.HasValue("REMOVED") && bool.Parse(node.GetValue("REMOVED")))
            {
                return;
            }
            else if (defaults && !node.HasNode("DEFAULTS"))
            {
                node.AddValue("REMOVED", true);
                return;
            }
            String    body          = loadNode.GetValue("body");
            Transform bodyTransform = null;

            try
            {
                bodyTransform = ScaledSpace.Instance.scaledSpaceTransforms.Single(t => t.name == body);
            }
            catch
            {
            }
            if (bodyTransform != null)
            {
                float        altitude     = float.Parse(loadNode.GetValue("altitude"));
                TextureSet   mTexture     = new TextureSet(loadNode.GetNode("main_texture"), false);
                TextureSet   dTexture     = new TextureSet(loadNode.GetNode("detail_texture"), false);
                ConfigNode   floatsConfig = loadNode.GetNode("shader_floats");
                ShaderFloats shaderFloats = null;
                if (floatsConfig != null)
                {
                    shaderFloats = new ShaderFloats(floatsConfig);
                }
                ConfigNode   scaledfloatsConfig = loadNode.GetNode("scaled_shader_floats");
                ShaderFloats scaledShaderFloats = null;
                if (scaledfloatsConfig != null)
                {
                    scaledShaderFloats = new ShaderFloats(scaledfloatsConfig);
                }
                ConfigNode colorNode = loadNode.GetNode("color");
                Color      color     = new Color(
                    float.Parse(colorNode.GetValue("r")),
                    float.Parse(colorNode.GetValue("g")),
                    float.Parse(colorNode.GetValue("b")),
                    float.Parse(colorNode.GetValue("a")));
                if (useVolume)
                {
                    bool.TryParse(loadNode.GetValue("volume"), out useVolume);
                }
                CloudLayer.Layers.Add(
                    new CloudLayer(url, node, body, color, altitude,
                                   mTexture, dTexture, scaledShaderFloats, shaderFloats, useVolume));
            }
            else
            {
                CloudLayer.Log("body " + body + " does not exist!");
            }
        }
Beispiel #8
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));
 }