-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- area overlay - dynamicOverlays toggle in minimap def to suppress 'no overlays' error - removed some redundant code (Size property where Find.Map.Size is just as simple) - some missing translations/icons [fixed] - scale button keeps minimap anchored to the same quadrant of the screen on resize.
- Loading branch information
1 parent
c83e716
commit 55e786e
Showing
17 changed files
with
267 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using CommunityCoreLibrary; | ||
using RimWorld; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using UnityEngine; | ||
using Verse; | ||
|
||
namespace CommunityCoreLibrary.MiniMap | ||
{ | ||
public class MiniMapOverlay_Area : MiniMapOverlay | ||
{ | ||
#region Fields | ||
|
||
public Area area; | ||
public static float opacity = .5f; | ||
|
||
#endregion Fields | ||
|
||
#region Constructors | ||
|
||
public MiniMapOverlay_Area( MiniMap minimap, MiniMapOverlayDef def, Area area ) : base( minimap, def ) | ||
{ | ||
this.area = area; | ||
|
||
// initial update | ||
Update(); | ||
texture.Apply(); | ||
} | ||
|
||
#endregion Constructors | ||
|
||
#region Properties | ||
|
||
public override string label => area.Label; | ||
|
||
#endregion Properties | ||
|
||
#region Methods | ||
|
||
public override void Update() | ||
{ | ||
Color color = area.Color; | ||
color.a = opacity; | ||
ClearTexture(); | ||
|
||
foreach ( var cell in area.ActiveCells ) | ||
{ | ||
texture.SetPixel( cell.x, cell.z, color ); | ||
} | ||
} | ||
|
||
#endregion Methods | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using CommunityCoreLibrary; | ||
using RimWorld; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using UnityEngine; | ||
using Verse; | ||
|
||
namespace CommunityCoreLibrary.MiniMap | ||
{ | ||
public class MiniMap_Areas : MiniMap | ||
{ | ||
#region Constructors | ||
|
||
public MiniMap_Areas( MiniMapDef def ) : base( def ) { } | ||
|
||
#endregion Constructors | ||
|
||
#region Methods | ||
|
||
public override void Update() | ||
{ | ||
UpdateAreaOverlays(); | ||
} | ||
|
||
private void UpdateAreaOverlays() | ||
{ | ||
// since this is called every frame (FRAME, not tick), just checking area count should be good enough to detect changes. | ||
if ( Find.AreaManager.AllAreas.Count == overlayWorkers.Count ) | ||
return; | ||
|
||
// check if we need to add area overlays | ||
foreach ( var area in Find.AreaManager.AllAreas ) | ||
{ | ||
if ( !overlayWorkers.Any( w => ((MiniMapOverlay_Area)w).area == area ) ) | ||
overlayWorkers.Add( new MiniMapOverlay_Area( this, new MiniMapOverlayDef(), area ) ); | ||
} | ||
|
||
// check if we should remove area overlays | ||
if ( overlayWorkers?.Any() ?? false ) | ||
{ | ||
for ( int i = overlayWorkers.Count - 1; i >= 0; i-- ) | ||
{ | ||
MiniMapOverlay_Area overlay = overlayWorkers[i] as MiniMapOverlay_Area; | ||
if ( overlay == null || !Find.AreaManager.AllAreas.Contains( overlay.area ) ) | ||
overlayWorkers.RemoveAt( i ); | ||
} | ||
} | ||
} | ||
|
||
#endregion Methods | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.