Skip to content

Commit 15604d9

Browse files
committed
Add Option to Highlight Current Active Work Cell
1 parent 80a0feb commit 15604d9

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed

Languages/English/Keyed/Keyed-English.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
<WorkTab.PlayCrunchTip>Play a crunchy sound when a pawn is assigned to a job they are not skilled at?</WorkTab.PlayCrunchTip>
2828
<WorkTab.DisableScrollwheel>Disable Scrollwheel</WorkTab.DisableScrollwheel>
2929
<WorkTab.DisableScrollwheelTip>Disable the scrollwheel functions (when hovering over skills)</WorkTab.DisableScrollwheelTip>
30+
<WorkTab.HighlightActiveWorkCells>Highlight Active Work Cells</WorkTab.HighlightActiveWorkCells>
31+
<WorkTab.HighlightActiveWorkCellsTip>Highlight the grid squares in the work tab when the pawn is actually working that job right now.</WorkTab.HighlightActiveWorkCellsTip>
3032
<WorkTab.VerticalLabels>Vertical labels</WorkTab.VerticalLabels>
3133
<WorkTab.VerticalLabelsTip>Display work labels vertically</WorkTab.VerticalLabelsTip>
3234
<WorkTab.FontFix>Fix vertical fonts</WorkTab.FontFix>

Source/Core/Settings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class Settings: ModSettings {
1313
public static bool playSounds = true;
1414
public static bool TwentyFourHourMode = true;
1515
public static bool verticalLabels = true;
16+
public static bool highlightActiveWorkCells;
1617
private static string _defaultPriorityBuffer = defaultPriority.ToString();
1718

1819
// public static bool sharedFavourites = true;
@@ -51,6 +52,8 @@ public static void DoWindowContents(Rect rect) {
5152
"WorkTab.PlayCrunchTip".Translate());
5253
options.CheckboxLabeled("WorkTab.DisableScrollwheel".Translate(), ref disableScrollwheel,
5354
"WorkTab.DisableScrollwheelTip".Translate());
55+
options.CheckboxLabeled("WorkTab.HighlightActiveWorkCells".Translate(), ref highlightActiveWorkCells,
56+
"WorkTab.HighlightActiveWorkCellsTip".Translate());
5457
bool verticalLabelsBuffer = verticalLabels;
5558
options.CheckboxLabeled("WorkTab.VerticalLabels".Translate(), ref verticalLabelsBuffer,
5659
"WorkTab.VerticalLabelsTip".Translate());
@@ -87,6 +90,7 @@ public override void ExposeData() {
8790
Scribe_Values.Look(ref playCrunch, "PlayCrunch", true);
8891
Scribe_Values.Look(ref disableScrollwheel, "DisableScrollwheel");
8992
Scribe_Values.Look(ref verticalLabels, "VerticalLabels", true);
93+
Scribe_Values.Look(ref highlightActiveWorkCells, "HighlightActiveWorkCells");
9094
Scribe_Values.Look(ref _fontFix, "FontFix", true);
9195

9296
// apply font-fix on load

Source/PawnColumns/PawnColumnWorker_WorkGiver.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ public override void DoCell(Rect rect, Pawn pawn, PawnTable table) {
5757

5858
WorkGiverDef workgiver = WorkGiver;
5959

60+
if (Settings.highlightActiveWorkCells)
61+
{
62+
bool doingNow = (pawn.CurJob?.workGiverDef?.defName == workgiver?.defName);
63+
if (doingNow)
64+
{
65+
GUI.color = Color.white;
66+
GUI.DrawTexture(rect.ContractedBy(-2f), DrawUtilities.getActiveHighlightBox());
67+
}
68+
}
69+
6070
// create rect in centre of cell, slightly offsetting left to give the appearance of aligning to worktype.
6171
Vector2 pos = rect.center - (new Vector2( WorkGiverBoxSize, WorkGiverBoxSize ) / 2f);
6272
Rect box = new Rect( pos.x - 2f, pos.y, WorkGiverBoxSize, WorkGiverBoxSize );

Source/PawnColumns/PawnColumnWorker_WorkType.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ public override void DoCell(Rect rect, Pawn pawn, PawnTable table) {
8282
bool incapable = IncapableOfWholeWorkType( pawn );
8383
WorkTypeDef worktype = def.workType;
8484

85+
if (Settings.highlightActiveWorkCells)
86+
{
87+
bool doingNow = (pawn.CurJob?.workGiverDef?.workType?.defName == worktype?.defName);
88+
if (doingNow)
89+
{
90+
GUI.color = Color.white;
91+
GUI.DrawTexture(rect.ContractedBy(-2f), DrawUtilities.getActiveHighlightBox());
92+
}
93+
}
94+
8595
// create rect in centre of cell
8696
Vector2 pos = rect.center - (new Vector2( WorkTypeBoxSize, WorkTypeBoxSize ) / 2f);
8797
Rect box = new Rect( pos.x, pos.y, WorkTypeBoxSize, WorkTypeBoxSize );

Source/Utilities/DrawUtilities.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,25 @@ public static void DrawWorkBoxBackground(Rect box, Pawn pawn, WorkTypeDef workty
7070
_drawWorkBoxBackgroundMethodInfo.Invoke(null, new object[] { box, pawn, worktype });
7171
}
7272

73+
private static Texture2D activeHighlightBox;
74+
public static Texture2D getActiveHighlightBox()
75+
{
76+
if (activeHighlightBox != null)
77+
{
78+
return activeHighlightBox;
79+
}
80+
Color color = Color.magenta;
81+
Texture2D startingExample = WidgetsWork.WorkBoxOverlay_PreceptWarning;
82+
int width = startingExample.width;
83+
int height = startingExample.height;
84+
Texture2D texture = new Texture2D(width, height);
85+
Color[] pixels = Enumerable.Repeat(color, width * height).ToArray();
86+
texture.SetPixels(pixels);
87+
texture.Apply();
88+
activeHighlightBox = texture;
89+
return activeHighlightBox;
90+
}
91+
7392
public static string PriorityLabel(int priority) {
7493
/**
7594
* 9 8 7 6 5 4

0 commit comments

Comments
 (0)