Skip to content

Commit

Permalink
Handle broken display name; flag for resource defaulting to 0 conc
Browse files Browse the repository at this point in the history
  • Loading branch information
DMagic1 committed Aug 15, 2020
1 parent 7a1840a commit 73ad8e3
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions SCANsat/SCAN_Data/SCANresourceGlobal.cs
Expand Up @@ -46,6 +46,8 @@ public class SCANresourceGlobal : SCAN_ConfigNodeStorage
private float defaultTrans;
private string displayName;

private bool defaultZero;

private SCANresourceBody currentBody;

internal SCANresourceGlobal(string resource, string display, float trans, float defMin, float defMax, Color minC, Color maxC)
Expand Down Expand Up @@ -106,6 +108,8 @@ public override void OnDecodeFromConfigNode()
highColor32 = (Color32)highResourceColor;

setDefaultValues();

//SCANUtil.SCANlog("Loading SCANsat global resource config settings: {0}", name);
try
{
int l = Resource_Planetary_Config.Count;
Expand All @@ -117,6 +121,7 @@ public override void OnDecodeFromConfigNode()
if (r == null)
continue;

//SCANUtil.SCANlog("Loading SCANsat body resource config settings: {0} - {1}", name, r.BodyName);
if (!masterBodyConfigs.Contains(r.BodyName))
masterBodyConfigs.Add(r.BodyName, r);
}
Expand All @@ -142,12 +147,13 @@ public override void OnEncodeToConfigNode()
}
catch (Exception e)
{
SCANUtil.SCANlog("Error while saving SCANsat altimetry config data: {0}", e);
SCANUtil.SCANlog("Error while saving SCANsat resource config data: {0}", e);
}
}

public void addToBodyConfigs(string s, SCANresourceBody r, bool warn)
{
//SCANUtil.SCANlog("Adding SCANsat body resource config data: {0} - {1}", name, s);
if (!masterBodyConfigs.Contains(s))
masterBodyConfigs.Add(s, r);
else if (warn)
Expand All @@ -171,7 +177,13 @@ public string Name

public string DisplayName
{
get { return displayName; }
get
{
if (string.IsNullOrEmpty(displayName))
return name;

return displayName;
}
set { displayName = value; }
}

Expand All @@ -189,6 +201,12 @@ internal set
}
}

public bool DefaultZero
{
get { return defaultZero; }
set { defaultZero = value; }
}

public Color MinColor
{
get { return lowResourceColor; }
Expand Down Expand Up @@ -244,7 +262,7 @@ public int getBodyCount
get { return masterBodyConfigs.Count; }
}

public SCANresourceBody getBodyConfig (string body, bool warn = true)
public SCANresourceBody getBodyConfig(string body, bool warn = true)
{
if (masterBodyConfigs.Contains(body))
return masterBodyConfigs[body];
Expand Down

0 comments on commit 73ad8e3

Please sign in to comment.