Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 120 additions & 4 deletions [Source]/SigmaCartographer/MapGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -723,4 +839,4 @@ internal static void CreateSatelliteMap(ref Texture2D baseMap, ref Texture2D nor
}
}
}
}
}
80 changes: 78 additions & 2 deletions [Source]/SigmaCartographer/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,84 @@ void Awake()
if (!File.Exists(folder + file + ".cfg"))
{
UnityEngine.Debug.Log(Debug.Tag + " WARNING: Missing file => " + folder + file + ".cfg");

File.WriteAllLines(folder + file + ".cfg", new[] { nodeName + " {}" });
UnityEngine.Debug.Log(Debug.Tag + " Writing file => " + folder + file + ".cfg");
//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;
}

Expand Down