// Build the gradient from data found in the node void IParserEventSubscriber.Apply(ConfigNode node) { // List of keyframes points = new SortedList<float, Color>(); // Iterate through all the values in the node (all are keyframes) foreach(ConfigNode.Value point in node.values) { // Convert the "name" (left side) into a float for sorting float p = float.Parse(point.name); // Get the color at this point ColorParser cp = new ColorParser(); cp.SetFromString(point.value); // Add the keyframe to the list points.Add(p, cp.value); } }
// Build the gradient from data found in the node void IParserEventSubscriber.Apply(ConfigNode node) { // List of keyframes points = new SortedList <float, Color>(); // Iterate through all the values in the node (all are keyframes) foreach (ConfigNode.Value point in node.values) { // Convert the "name" (left side) into a float for sorting float p = float.Parse(point.name); // Get the color at this point ColorParser cp = new ColorParser(); cp.SetFromString(point.value); // Add the keyframe to the list points.Add(p, cp.value); } }
private void ScaledExporterWindow(int id) { GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); scaledExporterScrollView1 = GUILayout.BeginScrollView(scaledExporterScrollView1, false, true, GUILayout.Width(400f)); var selectedBody = PQSBodies [selectedPQSBody]; GUILayout.Label("<b><color=#b7fe00>" + selectedBody.theName + "</color></b>", centeredText); GUILayout.Space(5f); GUILayout.BeginHorizontal(); if (previewIsBump) { if (GUILayout.Button("Color Map", smallButton, GUILayout.ExpandWidth(false))) { previewIsBump = false; } } else { GUILayout.Toggle(true, "Color Map", smallButton, GUILayout.ExpandWidth(false)); } if (!previewIsBump) { if (GUILayout.Button("Bump Map", smallButton, GUILayout.ExpandWidth(false))) { previewIsBump = true; } } else { GUILayout.Toggle(true, "Bump Map", smallButton, GUILayout.ExpandWidth(false)); } GUILayout.EndHorizontal(); if (previewIsBump) { GUILayout.Label(previewTextureBump, GUILayout.Width(360f), GUILayout.Height(180f)); } else { GUILayout.Label(previewTextureColor, GUILayout.Width(360f), GUILayout.Height(180f)); } if (HighLogic.LoadedScene == GameScenes.TRACKSTATION || HighLogic.LoadedScene == GameScenes.FLIGHT) { string buttonText = HighLogic.LoadedSceneIsFlight ? "View in Map Mode" : "Focus on planet"; if (GUILayout.Button(buttonText, smallButton, GUILayout.ExpandWidth(false))) { if (HighLogic.LoadedSceneIsFlight) { MapView.EnterMapView(); MapView.MapCamera.SetTarget(selectedBody); MapView.MapCamera.SetDistance((float)selectedBody.Radius * 4f * ScaledSpace.InverseScaleFactor); } else { PlanetariumCamera.fetch.SetTarget(selectedBody); PlanetariumCamera.fetch.SetDistance((float)selectedBody.Radius * 4f * ScaledSpace.InverseScaleFactor); } } } GUILayout.Space(5f); //resolution GUILayout.Label("Resolution:"); exportResolution = (int)(DrawManipulationSlider("exportResolution", "", (float)exportResolution, 4f, 8192f, true, "###0") / 2f) * 2; //normal strength GUILayout.Label("Normal Map Strength:"); normalStrength = DrawManipulationSlider("normalStrength", "", normalStrength, 0f, 16f, false); //specular map selection GUILayout.Label("Specular Map Path"); if (!GameDatabase.Instance.ExistsTexture(specPath)) { GUI.color = Color.red; } specPath = GUILayout.TextField(specPath); GUI.color = Color.white; GUILayout.Space(5f); var lineRect = GUILayoutUtility.GetRect(1f, 1f, 1f, 1f); lineRect.xMax -= 10f; GUI.DrawTexture(lineRect, lineTexture, ScaleMode.StretchToFill, true); GUILayout.Space(5f); //ocean related options if (selectedBody.ocean) { //ocean color colorOceans = GUILayout.Toggle(colorOceans, "Render Oceans"); if (colorOceans) { //ocean color selection GUILayout.Label("Ocean Color (hexadecimal)"); try { oceanColorColorParser.SetFromString(oceanColorString); GUI.backgroundColor = oceanColorColorParser.value; GUI.contentColor = oceanColorColorParser.value.grayscale < 0.5f ? Color.white : Color.black; } catch { GUI.contentColor = Color.red; GUI.backgroundColor = Color.red; GUI.color = Color.red; } oceanColorString = GUILayout.TextField(oceanColorString, colorSelectorTextField); GUI.contentColor = Color.white; GUI.backgroundColor = Color.white; GUI.color = Color.white; } //spec genSpecFromOceans = GUILayout.Toggle(genSpecFromOceans, "Generate Specular Map from Oceans"); GUILayout.Space(5f); lineRect = GUILayoutUtility.GetRect(1f, 1f, 1f, 1f); lineRect.xMax -= 10f; GUI.DrawTexture(lineRect, lineTexture, ScaleMode.StretchToFill, true); GUILayout.Space(5f); } //build options updateScaled = GUILayout.Toggle(updateScaled, "Update ScaledSpace"); writeFiles = GUILayout.Toggle(writeFiles, "Export Files"); if (GUILayout.Button("<b>Build Maps</b>")) { var specMap = GameDatabase.Instance.GetTexture(specPath, false); Color oceanColor = Color.black; try { oceanColorColorParser.SetFromString(oceanColorString); oceanColor = oceanColorColorParser.value; } catch {} Utils.BuildMaps(selectedBody, specMap, exportResolution, normalStrength, writeFiles, genSpecFromOceans, colorOceans, oceanColor, updateScaled); var material = Utils.GetScaled(selectedBody.name).renderer.sharedMaterial; previewTextureColor = (Texture2D)material.GetTexture("_MainTex"); previewTextureBump = (Texture2D)material.GetTexture("_BumpMap"); if (previewTextureColor == null) { previewTextureBump = Texture2D.blackTexture; } if (previewTextureBump == null) { previewTextureBump = Texture2D.blackTexture; } } GUILayout.Label("<color=white>You can see more information about the exported maps in the exported log file at <color=orange>Logs/KopernicusExpansion/" + selectedBody.bodyName + ".ScaledExport.log</color></color>"); GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.Space(1f); GUILayout.BeginVertical(); GUILayout.Label("<b><color=#b7fe00>Celestial Bodies</color></b>", centeredText); scaledExporterScrollView2 = GUILayout.BeginScrollView(scaledExporterScrollView2); for (int i = 0; i < PQSBodies.Length; i++) { var body = PQSBodies [i]; if (i == selectedPQSBody) { GUILayout.Toggle(true, body.theName, skin.button); } else { if (GUILayout.Button(body.theName)) { selectedPQSBody = i; var material = Utils.GetScaled(PQSBodies [selectedPQSBody].name).renderer.sharedMaterial; previewTextureColor = (Texture2D)material.GetTexture("_MainTex"); previewTextureBump = (Texture2D)material.GetTexture("_BumpMap"); if (previewTextureColor == null) { previewTextureBump = Texture2D.blackTexture; } if (previewTextureBump == null) { previewTextureBump = Texture2D.blackTexture; } } } } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUI.DragWindow(); }