From f1888bd11bb65c710dcad39db3a6d717060e1fd6 Mon Sep 17 00:00:00 2001 From: seanth Date: Fri, 30 Aug 2019 17:57:52 -0500 Subject: [PATCH 1/6] Make clear file is created Added a log file message making it clear that the missing file will be created as a stub --- [Source]/SigmaCartographer/UserSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[Source]/SigmaCartographer/UserSettings.cs b/[Source]/SigmaCartographer/UserSettings.cs index aafb620..6d83172 100644 --- a/[Source]/SigmaCartographer/UserSettings.cs +++ b/[Source]/SigmaCartographer/UserSettings.cs @@ -38,7 +38,7 @@ void Awake() if (!File.Exists(folder + file + ".cfg")) { UnityEngine.Debug.Log(Debug.Tag + " WARNING: Missing file => " + folder + file + ".cfg"); - + UnityEngine.Debug.Log(Debug.Tag + " Writing file => " + folder + file + ".cfg"); File.WriteAllLines(folder + file + ".cfg", new[] { nodeName + " {}" }); return; } From d6b6a0bf3bb3f8912f231eb83809962dfb034995 Mon Sep 17 00:00:00 2001 From: seanth Date: Fri, 30 Aug 2019 17:59:00 -0500 Subject: [PATCH 2/6] defining variables for checking for image overwrite permission --- [Source]/SigmaCartographer/MapGenerator.cs | 44 ++++++++++++++++------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/[Source]/SigmaCartographer/MapGenerator.cs b/[Source]/SigmaCartographer/MapGenerator.cs index bbd6247..42fad77 100644 --- a/[Source]/SigmaCartographer/MapGenerator.cs +++ b/[Source]/SigmaCartographer/MapGenerator.cs @@ -14,8 +14,9 @@ internal static class MapGenerator internal static bool exportAny { - get { return exportHeightMap || exportNormalMap || exportSlopeMap || exportColorMap || exportOceanMap || satelliteAny; } - set { exportHeightMap = exportNormalMap = exportSlopeMap = exportColorMap = exportOceanMap = satelliteAny = value; } + //--adding in a check to see whether maps exist. 2019-0830 STH + get { return exportHeightMap || exportNormalMap || exportSlopeMap || exportColorMap || exportOceanMap || satelliteAny || overwriteAny; } + set { exportHeightMap = exportNormalMap = exportSlopeMap = exportColorMap = exportOceanMap = satelliteAny = overwriteAny = value; } } static bool satelliteAny @@ -24,6 +25,15 @@ static bool satelliteAny set { exportSatelliteHeight = exportSatelliteSlope = exportSatelliteMap = exportSatelliteBiome = value; } } + //------------------ + //--adding in a check to see whether maps exist. 2019-0830 STH + static bool overwriteAny + { + get { return overwriteHeightMap || overwriteNormalMap || overwriteSlopeMap || overwriteColorMap || overwriteOceanMap || overwriteSatelliteHeight || overwriteSatelliteSlope || overwriteSatelliteMap || overwriteSatelliteBiome; } + set { overwriteHeightMap = overwriteNormalMap = overwriteSlopeMap = overwriteColorMap = overwriteOceanMap = overwriteSatelliteHeight = overwriteSatelliteSlope = overwriteSatelliteMap = overwriteSatelliteBiome = value; } + } + //------------------ + static bool exportHeightMap = false; static bool exportNormalMap = false; static bool exportSlopeMap = false; @@ -36,6 +46,21 @@ static bool satelliteAny static bool exportSatelliteMap = false; static bool exportSatelliteBiome = false; + //------------------ + //--adding in a check to see whether maps exist. 2019-0830 STH + static bool overwriteHeightMap = true; + static bool overwriteNormalMap = false; + static bool overwriteSlopeMap = false; + static bool overwriteColorMap = true; + static bool overwriteOceanMap = false; + internal static bool overwriteBiomeMap = false; + + static bool overwriteSatelliteHeight = false; + static bool overwriteSatelliteSlope = false; + static bool overwriteSatelliteMap = false; + static bool overwriteSatelliteBiome = false; + //------------------ + internal static CelestialBody body; static int width = 2048; static int tile = 1024; @@ -72,25 +97,20 @@ static bool satelliteAny internal static void LoadSettings(ConfigNode node) { bool.TryParse(node.GetValue("heightMap"), out exportHeightMap); - bool.TryParse(node.GetValue("satelliteHeight"), out exportSatelliteHeight); - bool.TryParse(node.GetValue("normalMap"), out exportNormalMap); - bool.TryParse(node.GetValue("slopeMap"), out exportSlopeMap); - bool.TryParse(node.GetValue("satelliteSlope"), out exportSatelliteSlope); - if (!bool.TryParse(node.GetValue("colorMap"), out exportColorMap)) { exportColorMap = true; } - bool.TryParse(node.GetValue("satelliteMap"), out exportSatelliteMap); - bool.TryParse(node.GetValue("oceanMap"), out exportOceanMap); - bool.TryParse(node.GetValue("biomeMap"), out exportBiomeMap); - bool.TryParse(node.GetValue("satelliteBiome"), out exportSatelliteBiome); - + bool.TryParse(node.GetValue("satelliteHeight"), out exportSatelliteHeight); + bool.TryParse(node.GetValue("satelliteSlope"), out exportSatelliteSlope); + bool.TryParse(node.GetValue("satelliteMap"), out exportSatelliteMap); + bool.TryParse(node.GetValue("satelliteBiome"), out exportSatelliteBiome); + if (!exportAny && !exportBiomeMap) return; string bodyName = node.GetValue("body"); From a175ab9fe977d24ce5cd4b61d67b039eb1845fb4 Mon Sep 17 00:00:00 2001 From: seanth Date: Fri, 30 Aug 2019 18:00:47 -0500 Subject: [PATCH 3/6] set default overwrite behaviour to true --- [Source]/SigmaCartographer/MapGenerator.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/[Source]/SigmaCartographer/MapGenerator.cs b/[Source]/SigmaCartographer/MapGenerator.cs index 42fad77..4df2c9c 100644 --- a/[Source]/SigmaCartographer/MapGenerator.cs +++ b/[Source]/SigmaCartographer/MapGenerator.cs @@ -49,16 +49,16 @@ static bool overwriteAny //------------------ //--adding in a check to see whether maps exist. 2019-0830 STH static bool overwriteHeightMap = true; - static bool overwriteNormalMap = false; - static bool overwriteSlopeMap = false; + static bool overwriteNormalMap = true; + static bool overwriteSlopeMap = true; static bool overwriteColorMap = true; - static bool overwriteOceanMap = false; - internal static bool overwriteBiomeMap = false; + static bool overwriteOceanMap = true; + internal static bool overwriteBiomeMap = true; - static bool overwriteSatelliteHeight = false; - static bool overwriteSatelliteSlope = false; - static bool overwriteSatelliteMap = false; - static bool overwriteSatelliteBiome = false; + static bool overwriteSatelliteHeight = true; + static bool overwriteSatelliteSlope = true; + static bool overwriteSatelliteMap = true; + static bool overwriteSatelliteBiome = true; //------------------ internal static CelestialBody body; From 62aa08aabee51e152acc4ba810fb6b7f0d7097f8 Mon Sep 17 00:00:00 2001 From: seanth Date: Sat, 31 Aug 2019 21:16:49 -0500 Subject: [PATCH 4/6] revert --- [Source]/SigmaCartographer/MapGenerator.cs | 46 ++++++---------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/[Source]/SigmaCartographer/MapGenerator.cs b/[Source]/SigmaCartographer/MapGenerator.cs index 4df2c9c..0588960 100644 --- a/[Source]/SigmaCartographer/MapGenerator.cs +++ b/[Source]/SigmaCartographer/MapGenerator.cs @@ -14,9 +14,8 @@ internal static class MapGenerator internal static bool exportAny { - //--adding in a check to see whether maps exist. 2019-0830 STH - get { return exportHeightMap || exportNormalMap || exportSlopeMap || exportColorMap || exportOceanMap || satelliteAny || overwriteAny; } - set { exportHeightMap = exportNormalMap = exportSlopeMap = exportColorMap = exportOceanMap = satelliteAny = overwriteAny = value; } + get { return exportHeightMap || exportNormalMap || exportSlopeMap || exportColorMap || exportOceanMap || satelliteAny; } + set { exportHeightMap = exportNormalMap = exportSlopeMap = exportColorMap = exportOceanMap = satelliteAny = value; } } static bool satelliteAny @@ -25,15 +24,6 @@ static bool satelliteAny set { exportSatelliteHeight = exportSatelliteSlope = exportSatelliteMap = exportSatelliteBiome = value; } } - //------------------ - //--adding in a check to see whether maps exist. 2019-0830 STH - static bool overwriteAny - { - get { return overwriteHeightMap || overwriteNormalMap || overwriteSlopeMap || overwriteColorMap || overwriteOceanMap || overwriteSatelliteHeight || overwriteSatelliteSlope || overwriteSatelliteMap || overwriteSatelliteBiome; } - set { overwriteHeightMap = overwriteNormalMap = overwriteSlopeMap = overwriteColorMap = overwriteOceanMap = overwriteSatelliteHeight = overwriteSatelliteSlope = overwriteSatelliteMap = overwriteSatelliteBiome = value; } - } - //------------------ - static bool exportHeightMap = false; static bool exportNormalMap = false; static bool exportSlopeMap = false; @@ -46,21 +36,6 @@ static bool overwriteAny static bool exportSatelliteMap = false; static bool exportSatelliteBiome = false; - //------------------ - //--adding in a check to see whether maps exist. 2019-0830 STH - static bool overwriteHeightMap = true; - static bool overwriteNormalMap = true; - static bool overwriteSlopeMap = true; - static bool overwriteColorMap = true; - static bool overwriteOceanMap = true; - internal static bool overwriteBiomeMap = true; - - static bool overwriteSatelliteHeight = true; - static bool overwriteSatelliteSlope = true; - static bool overwriteSatelliteMap = true; - static bool overwriteSatelliteBiome = true; - //------------------ - internal static CelestialBody body; static int width = 2048; static int tile = 1024; @@ -97,20 +72,25 @@ static bool overwriteAny internal static void LoadSettings(ConfigNode node) { bool.TryParse(node.GetValue("heightMap"), out exportHeightMap); + bool.TryParse(node.GetValue("satelliteHeight"), out exportSatelliteHeight); + bool.TryParse(node.GetValue("normalMap"), out exportNormalMap); + bool.TryParse(node.GetValue("slopeMap"), out exportSlopeMap); + bool.TryParse(node.GetValue("satelliteSlope"), out exportSatelliteSlope); + if (!bool.TryParse(node.GetValue("colorMap"), out exportColorMap)) { exportColorMap = true; } + bool.TryParse(node.GetValue("satelliteMap"), out exportSatelliteMap); + bool.TryParse(node.GetValue("oceanMap"), out exportOceanMap); - bool.TryParse(node.GetValue("biomeMap"), out exportBiomeMap); - bool.TryParse(node.GetValue("satelliteHeight"), out exportSatelliteHeight); - bool.TryParse(node.GetValue("satelliteSlope"), out exportSatelliteSlope); - bool.TryParse(node.GetValue("satelliteMap"), out exportSatelliteMap); + bool.TryParse(node.GetValue("biomeMap"), out exportBiomeMap); bool.TryParse(node.GetValue("satelliteBiome"), out exportSatelliteBiome); - + + if (!exportAny && !exportBiomeMap) return; string bodyName = node.GetValue("body"); @@ -743,4 +723,4 @@ internal static void CreateSatelliteMap(ref Texture2D baseMap, ref Texture2D nor } } } -} +} \ No newline at end of file From 7f912da80f9b5e938b9781771c5d2bcb80f012a6 Mon Sep 17 00:00:00 2001 From: seanth Date: Mon, 2 Sep 2019 00:31:47 -0500 Subject: [PATCH 5/6] Documentation for settings included in default settings file Included example settings that are commented out for newly generated Settings.cfg files --- [Source]/SigmaCartographer/UserSettings.cs | 78 +++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/[Source]/SigmaCartographer/UserSettings.cs b/[Source]/SigmaCartographer/UserSettings.cs index 6d83172..ee801e3 100644 --- a/[Source]/SigmaCartographer/UserSettings.cs +++ b/[Source]/SigmaCartographer/UserSettings.cs @@ -39,7 +39,83 @@ void Awake() { UnityEngine.Debug.Log(Debug.Tag + " WARNING: Missing file => " + folder + file + ".cfg"); UnityEngine.Debug.Log(Debug.Tag + " Writing file => " + folder + file + ".cfg"); - File.WriteAllLines(folder + file + ".cfg", new[] { nodeName + " {}" }); + //File.WriteAllLines(folder + file + ".cfg", new[] { nodeName + " {}" }); + //------ + //The following writes the default Settings.cfg file + //but includes commented lines that can act as documentation + //for users. + //STH 2019-0831 + File.WriteAllLines( + folder + file + ".cfg", + new string[] + { + "//The configuration file has the following format:", + "//"+nodeName, + "//{", + "// Maps", + "// {", + "// body = Kerbin // the name of the body (default = Kerbin)", + "// width = 2048 // the total width of the texture (default = 2048)", + "// tile = 1024 // the width of one tile (default = 1024)", + "// flipV = false // flip the image vertically (default = false)", + "// flipH = false // flip the image horizontally (default = false)", + "// exportFolder = Sigma/Cartographer/Maps // path for the export folder", + "// leaflet = false // export in folders divided by columns and rows (default = false)", + "//", + "// heightMap = false // export height map (default = false)", + "// normalMap = false // ? (default = false)", + "// slopeMap = false // export slope map (default = false)", + "// colorMap = true // ? (default = true)", + "// oceanMap = false // export surface ocean (default = false)", + "// biomeMap = false // export biome map (default = false)", + "// satelliteHeight = false // if true, forces heightMap to be true (default = false)", + "// satelliteSlope = false // if true, forces slopeMap to be true (default = false)", + "// satelliteMap = false // if true, forces colorMap to be true (default = false)", + "// satelliteBiome = false // if true, forces biomeMap to be true (default = false)", + "//", + "// //To have Sigma Cartographer export images only if they don't exist:", + "// overwriteHeightMap = false //(default = true)", + "// overwriteNormalMap = false //(default = true)", + "// overwriteSlopeMap = false //(default = true)", + "// overwriteColorMap = false //(default = true)", + "// overwriteOceanMap = false //(default = true)", + "// overwriteBiomeMap = false //(default = true)", + "//", + "// overwriteSatelliteHeight = true //(default = true)", + "// overwriteSatelliteSlope = true //(default = true)", + "// overwriteSatelliteMap = true //(default = true)", + "// overwriteSatelliteBiome = true //(default = true)", + "//-----------", + "// oceanFloor = true // include the ocean floor on maps. (default = true)", + "//", + "// normalStrength = 1 // strength of normals (default = 1)", + "// slopeMin = 0.2,0.3,0.4 // color for 0° slope (default = 0.2,0.3,0.4)", + "// slopeMax = 0.9,0.6,0.5 // color for 90° slope (default = 0.9,0.6,0.5)", + "//", + "// LAToffset = 0 // offset latitude (default = 0)", + "// LONoffset = 0 // offset longitude (default = 0)", + "//", + "// //if you want to print only selected tiles", + "// //add as many of these as you want", + "// //if you don't add any of these", + "// //all tiles will be exported", + "// printTile = 0", + "// printTile = 1", + "// }", + "// Info", + "// {", + "// //List all the bodies for which you want info on", + "// //the lowest and highest point on the planet.", + "// //Examples:", + "// body = Kerbin", + "// body = Mun", + "// }", + "//}", + "", + nodeName + " {}" + } + ); + //------- return; } From e7472253700621f2e67580f17cd5b5c9e6c90347 Mon Sep 17 00:00:00 2001 From: seanth Date: Mon, 2 Sep 2019 00:33:05 -0500 Subject: [PATCH 6/6] Overwrite existing map options Included the ability to check for existing maps, and whether the user wants existing maps overwritten or not. Choosing not to overwrite them speeds load tim up. --- [Source]/SigmaCartographer/MapGenerator.cs | 122 ++++++++++++++++++++- 1 file changed, 119 insertions(+), 3 deletions(-) diff --git a/[Source]/SigmaCartographer/MapGenerator.cs b/[Source]/SigmaCartographer/MapGenerator.cs index 0588960..d5f11c5 100644 --- a/[Source]/SigmaCartographer/MapGenerator.cs +++ b/[Source]/SigmaCartographer/MapGenerator.cs @@ -36,6 +36,21 @@ static bool satelliteAny static bool exportSatelliteMap = false; static bool exportSatelliteBiome = false; + //------------------ + //--adding in a check to see whether maps exist. 2019-0830 STH + static bool overwriteHeightMap = true; + static bool overwriteNormalMap = true; + static bool overwriteSlopeMap = true; + static bool overwriteColorMap = true; + static bool overwriteOceanMap = true; + internal static bool overwriteBiomeMap = true; + + static bool overwriteSatelliteHeight = true; + static bool overwriteSatelliteSlope = true; + static bool overwriteSatelliteMap = true; + static bool overwriteSatelliteBiome = true; + //------------------ + internal static CelestialBody body; static int width = 2048; static int tile = 1024; @@ -90,6 +105,20 @@ internal static void LoadSettings(ConfigNode node) bool.TryParse(node.GetValue("biomeMap"), out exportBiomeMap); bool.TryParse(node.GetValue("satelliteBiome"), out exportSatelliteBiome); + //------------------ + //--adding in a check to see whether maps exist. 2019-0830 STH + bool.TryParse(node.GetValue("overwriteHeightMap"), out overwriteHeightMap); + bool.TryParse(node.GetValue("overwriteNormalMap"), out overwriteNormalMap); + bool.TryParse(node.GetValue("overwriteSlopeMap"), out overwriteSlopeMap); + bool.TryParse(node.GetValue("overwriteColorMap"), out overwriteColorMap); + bool.TryParse(node.GetValue("overwriteOceanMap"), out overwriteOceanMap); + bool.TryParse(node.GetValue("overwriteBiomeMap"), out overwriteBiomeMap); + + bool.TryParse(node.GetValue("overwriteSatelliteHeight"), out overwriteSatelliteHeight); + bool.TryParse(node.GetValue("overwriteSatelliteSlope"), out overwriteSatelliteSlope); + bool.TryParse(node.GetValue("overwriteSatelliteMap"), out overwriteSatelliteMap); + bool.TryParse(node.GetValue("overwriteSatelliteBiome"), out overwriteSatelliteBiome); + //------------------ if (!exportAny && !exportBiomeMap) return; @@ -280,6 +309,89 @@ internal static void GeneratePQSMaps(string subfolder = "", bool split = false) // reset current current = 0; + //generate folder & file names + int position = Flip(current); + //string folder = leaflet ? (position % (width / tile) + "/") : ""; + //string fileName = leaflet ? (position / (width / tile)) + ".png" : "Tile" + position.ToString("D4") + ".png"; + // Expanded statements for greater understandability. STH 2019-0831 + string folder; + string fileName; + if (leaflet){ + folder = (position % (width / tile) + "/"); + fileName = (position / (width / tile)) + ".png"; + } + else + { + folder = ""; + fileName = "Tile" + position.ToString("D4") + ".png"; + } + + //-------------------------- + //put checks for images here + //STH 2019-0831 + string checkFile; + checkFile = exportFolder + folder + "HeightMap/" + fileName; + if (File.Exists(checkFile) && !overwriteHeightMap) + { + exportHeightMap = false; + //UnityEngine.Debug.Log(Debug.Tag + " Overwrite of HeightMap skipped"); + } + checkFile = exportFolder + folder + "NormalMap/" + fileName; + if (File.Exists(checkFile) && !overwriteNormalMap) + { + exportNormalMap = false; + //UnityEngine.Debug.Log(Debug.Tag + " Overwrite of NormalMap skipped"); + } + checkFile = exportFolder + folder + "SlopeMap/" + fileName; + if (File.Exists(checkFile) && !overwriteSlopeMap) + { + exportSlopeMap = false; + //UnityEngine.Debug.Log(Debug.Tag + " Overwrite of SlopeMap skipped"); + } + checkFile = exportFolder + folder + "ColorMap/" + fileName; + if (File.Exists(checkFile) && !overwriteColorMap) + { + exportColorMap = false; + //UnityEngine.Debug.Log(Debug.Tag + " Overwrite of ColorMap skipped"); + } + checkFile = exportFolder + folder + "OceanMap/" + fileName; + if (File.Exists(checkFile) && !overwriteOceanMap) + { + exportOceanMap = false; + //UnityEngine.Debug.Log(Debug.Tag + " Overwrite of OceanMap skipped"); + } + checkFile = exportFolder + folder + "BiomeMap/" + fileName; + if (File.Exists(checkFile) && !overwriteBiomeMap) + { + exportBiomeMap = false; + //UnityEngine.Debug.Log(Debug.Tag + " Overwrite of BiomeMap skipped"); + } + //sat maps + checkFile = exportFolder + folder + "SatelliteHeight/" + fileName; + if (File.Exists(checkFile) && !overwriteSatelliteHeight) + { + exportSatelliteHeight = false; + //UnityEngine.Debug.Log(Debug.Tag + " Overwrite of SatelliteHeight skipped"); + } + checkFile = exportFolder + folder + "SatelliteSlope/" + fileName; + if (File.Exists(checkFile) && !overwriteSatelliteSlope) + { + exportSatelliteSlope = false; + //UnityEngine.Debug.Log(Debug.Tag + " Overwrite of SatelliteSlope skipped"); + } + checkFile = exportFolder + folder + "SatelliteMap/" + fileName; + if (File.Exists(checkFile) && !overwriteSatelliteMap) + { + exportSatelliteMap = false; + //UnityEngine.Debug.Log(Debug.Tag + " Overwrite of SatelliteMap skipped"); + } + checkFile = exportFolder + folder + "SatelliteBiome/" + fileName; + if (File.Exists(checkFile) && !overwriteSatelliteBiome) + { + exportSatelliteBiome = false; + //UnityEngine.Debug.Log(Debug.Tag + " Overwrite of SatelliteBiome skipped"); + } + //-------------------------- // Get PQS PQS pqs = null; @@ -488,9 +600,13 @@ internal static void GeneratePQSMaps(string subfolder = "", bool split = false) } // Serialize them to disk - int position = Flip(current); - string folder = leaflet ? (position % (width / tile) + "/") : ""; - string fileName = leaflet ? (position / (width / tile)) + ".png" : "Tile" + position.ToString("D4") + ".png"; + //-------- + //moved to before processing + //STH 2019-0831 + //int position = Flip(current); + //string folder = leaflet ? (position % (width / tile) + "/") : ""; + //string fileName = leaflet ? (position / (width / tile)) + ".png" : "Tile" + position.ToString("D4") + ".png"; + //-------- // Export try