Skip to content

Commit

Permalink
Merge pull request #97 from RimWorldCCLTeam/development
Browse files Browse the repository at this point in the history
Minimap Load/Save Fix
  • Loading branch information
ForsakenShell committed May 19, 2016
2 parents 986ab20 + 5fbfdd1 commit 6806691
Show file tree
Hide file tree
Showing 17 changed files with 159 additions and 63 deletions.
181 changes: 134 additions & 47 deletions DLL_Project/MapComponents/MiniMapController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,54 +79,13 @@ public override void MapComponentOnGUI()
public override void ExposeData()
{
base.ExposeData();
foreach( var minimap in Controller.Data.MiniMaps )
if( Scribe.mode == LoadSaveMode.Saving )
{
#region Minimap Header

Scribe.EnterNode( minimap.miniMapDef.defName );

#endregion

var hidden = minimap.Hidden;
Scribe_Values.LookValue( ref hidden, "hidden" );

if( Scribe.mode == LoadSaveMode.LoadingVars )
{
minimap.Hidden = hidden;
}

#region Handle all MiniMap Overlays

foreach( var overlay in minimap.overlayWorkers )
{
#region Overlay Header

Scribe.EnterNode( overlay.overlayDef.defName );

#endregion

hidden = overlay.Hidden;
Scribe_Values.LookValue( ref hidden, "hidden" );

if( Scribe.mode == LoadSaveMode.LoadingVars )
{
overlay.Hidden = hidden;
}

#region Finalize Overlay

Scribe.ExitNode();

#endregion
}

#endregion

#region Finalize Minimap

Scribe.ExitNode();

#endregion
ExposeDataSave();
}
else if( Scribe.mode == LoadSaveMode.LoadingVars )
{
ExposeDataLoad();
}
}

Expand Down Expand Up @@ -248,6 +207,134 @@ private void SortMiniMaps()

#endregion

#region Save/Load Minimap and Overlays

private void ExposeDataSave()
{
bool hidden;
foreach( var minimap in Controller.Data.MiniMaps )
{
// Note: Minimaps with dynamic overlays break scribing because they have
// a machine generated defName which may not be the same after load.
if( minimap.miniMapDef.dynamicOverlays )
{
continue;
}

#region Minimap Header

Scribe.EnterNode( minimap.miniMapDef.defName );

#endregion

hidden = minimap.Hidden;
Scribe_Values.LookValue( ref hidden, "hidden" );

#region Handle all MiniMap Overlays

foreach( var overlay in minimap.overlayWorkers )
{
#region Overlay Header

Scribe.EnterNode( overlay.overlayDef.defName );

#endregion

hidden = overlay.Hidden;
Scribe_Values.LookValue( ref hidden, "hidden" );

#region Finalize Overlay

Scribe.ExitNode();

#endregion
}

#endregion

#region Finalize Minimap

Scribe.ExitNode();

#endregion
}
}

private void ExposeDataLoad()
{
bool hidden = true; // Don't really need to set this but the compiler complains if we don't
foreach( var minimap in Controller.Data.MiniMaps )
{
if(
( minimap.miniMapDef.dynamicOverlays )||
( !XmlNodeExists( Scribe.curParent, minimap.miniMapDef.defName ) )
)
{ // Dynamic minimap overlays or no saved data for this minimap
continue;
}

#region Minimap Header

Scribe.EnterNode( minimap.miniMapDef.defName );

#endregion

Scribe_Values.LookValue( ref hidden, "hidden" );
minimap.Hidden = hidden;

#region Handle all MiniMap Overlays

foreach( var overlay in minimap.overlayWorkers )
{

if( !XmlNodeExists( Scribe.curParent, overlay.overlayDef.defName ) )
{ // No saved data for this overlay
continue;
}

#region Overlay Header

Scribe.EnterNode( overlay.overlayDef.defName );

#endregion

Scribe_Values.LookValue( ref hidden, "hidden" );
overlay.Hidden = hidden;

#region Finalize Overlay

Scribe.ExitNode();

#endregion
}

#endregion

#region Finalize Minimap

Scribe.ExitNode();

#endregion
}
}

private bool XmlNodeExists( System.Xml.XmlNode parentNode, string childNode )
{
var xmlEnumerator = parentNode.ChildNodes.GetEnumerator();
while( xmlEnumerator.MoveNext() )
{
var node = (System.Xml.XmlNode) xmlEnumerator.Current;
if( node.Name == childNode )
{ // Node exists
return true;
}
}
// Node doesn't exist
return false;
}

#endregion

}

}
2 changes: 1 addition & 1 deletion DLL_Project/MiniMapOverlays/MiniMapOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public virtual bool Hidden

// mark the controller dirty so everything is properly sorted
MiniMapController.dirty = true;
}
}
}

public virtual string label
Expand Down
10 changes: 8 additions & 2 deletions DLL_Project/MiniMapOverlays/MiniMapOverlay_PowerGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class MiniMapOverlay_PowerGrid : MiniMapOverlay, IConfigurable
#region Fields

private Color
poweredColor = GenUI.MouseoverColor,
poweredColor = GenUI.MouseoverColor,
poweredByBatteriesColor = Color.green,
notPoweredColor = Color.red,
offColor = Color.grey;
Expand Down Expand Up @@ -63,7 +63,13 @@ public float DrawMCMRegion( Rect InRect )

public void ExposeData()
{
//throw new NotImplementedException();
Scribe_Values.LookValue( ref poweredColor, "poweredColor" );
Scribe_Values.LookValue( ref poweredByBatteriesColor, "poweredByBatteriesColor" );
Scribe_Values.LookValue( ref notPoweredColor, "notPoweredColor" );
Scribe_Values.LookValue( ref offColor, "offColor" );

if ( Scribe.mode == LoadSaveMode.LoadingVars )
UpdateInputFields();
}

public override void Update()
Expand Down
2 changes: 1 addition & 1 deletion DLL_Project/MiniMapOverlays/MiniMapOverlay_Wildlife.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class MiniMapOverlay_Wildlife : MiniMapOverlay_Pawns, IConfigurable
#region Fields

private Color
wildColor = Color.yellow,
wildColor = Color.yellow,
tameColor = Color.green,
hostileColor = Color.red,
huntingColor = GenUI.MouseoverColor,
Expand Down
4 changes: 3 additions & 1 deletion DLL_Project/Version/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public static class Version
#region Instance Data

private static System.Version versionMin = new System.Version( "0.13.0" );
private const string versionCurrentInt = "0.13.2.1";

private static System.Version versionCurrent;

#endregion
Expand All @@ -32,7 +34,7 @@ public static System.Version Current
// TODO: Fix issue #30 so we can use proper assembly versioning
//System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
//CCLVersion = assembly.GetName().Version;
versionCurrent = new System.Version( "0.13.2" );
versionCurrent = new System.Version( versionCurrentInt );
}
return versionCurrent;
}
Expand Down
2 changes: 1 addition & 1 deletion Forum/1_Release_Post.bbc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[center][img]https://github.com/RimWorldCCLTeam/CommunityCoreLibrary/blob/master/WebGraphics/CCL_Logo_Long.png?raw=true[/img]
v0.13.2
v0.13.2.1

[glow=red,2,300]This forum thread and the first 10 posts serve as the documentation/manual.

Expand Down
5 changes: 3 additions & 2 deletions Forum/7_Changelog.bbc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[size=12pt][color=orange]Changelog[/color][/size]

For the full list of changes in each version, please refer to the [url=https://github.com/RimWorldCCLTeam/CommunityCoreLibrary/pull/87]commit log[/url]. This section is just for convenience sake.
For the full list of changes in each version, please refer to the [url=https://github.com/RimWorldCCLTeam/CommunityCoreLibrary/pull/??]commit log[/url]. This section is just for convenience sake.

[code]v0.13.2 - New Minimap feature! Fixes some bugs in CCL and in core (BiomeDef).
[code]v0.13.2.1 - Fixes load/save issue with minimaps.
v0.13.2 - New Minimap feature! Fixes some bugs in CCL and in core (BiomeDef).
v0.13.1.1 - Bug fixes
v0.13.1 - Adds InterModCommunication, CompGlowerToggleable, fixes some issues reported.
v0.13.0 - Alpha 13 update.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<url>https://ludeon.com/forums/index.php?topic=14172.0</url>

<targetVersion>Community Core Library v0.13.2</targetVersion>
<targetVersion>Community Core Library v0.13.2.1</targetVersion>

<description>Makes optional changes to the core game objects.\n\nThis mod is optional but recommended (by the CCL modding team, but we're biased).</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ModName>Community Core Library - Vanilla Tweaks</ModName>

<minCCLVersion>0.13.2</minCCLVersion>
<minCCLVersion>0.13.2.1</minCCLVersion>

<ThingComps>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<ModMetaData>

<name>Community Core Library v0.13.2</name>
<name>Community Core Library v0.13.2.1</name>

<author>RimWorld CCL Team</author>

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ModName>Community Core Library</ModName>

<minCCLVersion>0.13.2</minCCLVersion>
<minCCLVersion>0.13.2.1</minCCLVersion>

<ModConfigurationMenus>
<li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<url>https://ludeon.com/forums/index.php?topic=14172.0</url>

<targetVersion>Community Core Library v0.13.2</targetVersion>
<targetVersion>Community Core Library v0.13.2.1</targetVersion>

<description>Makes optional changes to the core game objects.\n\nThis mod is optional but recommended (by the CCL modding team, but we're biased).</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ModName>Community Core Library - Vanilla Tweaks</ModName>

<minCCLVersion>0.13.2</minCCLVersion>
<minCCLVersion>0.13.2.1</minCCLVersion>

<ThingComps>

Expand Down
2 changes: 1 addition & 1 deletion _Mod/User Release/Community Core Library/About/About.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<ModMetaData>

<name>Community Core Library v0.13.2</name>
<name>Community Core Library v0.13.2.1</name>

<author>RimWorld CCL Team</author>

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ModName>Community Core Library</ModName>

<minCCLVersion>0.13.2</minCCLVersion>
<minCCLVersion>0.13.2.1</minCCLVersion>

<ModConfigurationMenus>
<li>
Expand Down

0 comments on commit 6806691

Please sign in to comment.