Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Option to Highlight Current Active Work Cell #206

Open
wants to merge 1 commit into
base: 1.4
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions Languages/English/Keyed/Keyed-English.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<WorkTab.PlayCrunchTip>Play a crunchy sound when a pawn is assigned to a job they are not skilled at?</WorkTab.PlayCrunchTip>
<WorkTab.DisableScrollwheel>Disable Scrollwheel</WorkTab.DisableScrollwheel>
<WorkTab.DisableScrollwheelTip>Disable the scrollwheel functions (when hovering over skills)</WorkTab.DisableScrollwheelTip>
<WorkTab.HighlightActiveWorkCells>Highlight Active Work Cells</WorkTab.HighlightActiveWorkCells>
<WorkTab.HighlightActiveWorkCellsTip>Highlight the grid squares in the work tab when the pawn is actually working that job right now.</WorkTab.HighlightActiveWorkCellsTip>
<WorkTab.VerticalLabels>Vertical labels</WorkTab.VerticalLabels>
<WorkTab.VerticalLabelsTip>Display work labels vertically</WorkTab.VerticalLabelsTip>
<WorkTab.FontFix>Fix vertical fonts</WorkTab.FontFix>
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class Settings: ModSettings {
public static bool playSounds = true;
public static bool TwentyFourHourMode = true;
public static bool verticalLabels = true;
public static bool highlightActiveWorkCells;
private static string _defaultPriorityBuffer = defaultPriority.ToString();

// public static bool sharedFavourites = true;
Expand Down Expand Up @@ -51,6 +52,8 @@ public static void DoWindowContents(Rect rect) {
"WorkTab.PlayCrunchTip".Translate());
options.CheckboxLabeled("WorkTab.DisableScrollwheel".Translate(), ref disableScrollwheel,
"WorkTab.DisableScrollwheelTip".Translate());
options.CheckboxLabeled("WorkTab.HighlightActiveWorkCells".Translate(), ref highlightActiveWorkCells,
"WorkTab.HighlightActiveWorkCellsTip".Translate());
bool verticalLabelsBuffer = verticalLabels;
options.CheckboxLabeled("WorkTab.VerticalLabels".Translate(), ref verticalLabelsBuffer,
"WorkTab.VerticalLabelsTip".Translate());
Expand Down Expand Up @@ -87,6 +90,7 @@ public override void ExposeData() {
Scribe_Values.Look(ref playCrunch, "PlayCrunch", true);
Scribe_Values.Look(ref disableScrollwheel, "DisableScrollwheel");
Scribe_Values.Look(ref verticalLabels, "VerticalLabels", true);
Scribe_Values.Look(ref highlightActiveWorkCells, "HighlightActiveWorkCells");
Scribe_Values.Look(ref _fontFix, "FontFix", true);

// apply font-fix on load
Expand Down
10 changes: 10 additions & 0 deletions Source/PawnColumns/PawnColumnWorker_WorkGiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ public override void DoCell(Rect rect, Pawn pawn, PawnTable table) {

WorkGiverDef workgiver = WorkGiver;

if (Settings.highlightActiveWorkCells)
{
bool doingNow = (pawn.CurJob?.workGiverDef?.defName == workgiver?.defName);
if (doingNow)
{
GUI.color = Color.white;
GUI.DrawTexture(rect.ContractedBy(-2f), DrawUtilities.getActiveHighlightBox());
}
}

// create rect in centre of cell, slightly offsetting left to give the appearance of aligning to worktype.
Vector2 pos = rect.center - (new Vector2( WorkGiverBoxSize, WorkGiverBoxSize ) / 2f);
Rect box = new Rect( pos.x - 2f, pos.y, WorkGiverBoxSize, WorkGiverBoxSize );
Expand Down
10 changes: 10 additions & 0 deletions Source/PawnColumns/PawnColumnWorker_WorkType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ public override void DoCell(Rect rect, Pawn pawn, PawnTable table) {
bool incapable = IncapableOfWholeWorkType( pawn );
WorkTypeDef worktype = def.workType;

if (Settings.highlightActiveWorkCells)
{
bool doingNow = (pawn.CurJob?.workGiverDef?.workType?.defName == worktype?.defName);
if (doingNow)
{
GUI.color = Color.white;
GUI.DrawTexture(rect.ContractedBy(-2f), DrawUtilities.getActiveHighlightBox());
}
}

// create rect in centre of cell
Vector2 pos = rect.center - (new Vector2( WorkTypeBoxSize, WorkTypeBoxSize ) / 2f);
Rect box = new Rect( pos.x, pos.y, WorkTypeBoxSize, WorkTypeBoxSize );
Expand Down
19 changes: 19 additions & 0 deletions Source/Utilities/DrawUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,25 @@ public static void DrawWorkBoxBackground(Rect box, Pawn pawn, WorkTypeDef workty
_drawWorkBoxBackgroundMethodInfo.Invoke(null, new object[] { box, pawn, worktype });
}

private static Texture2D activeHighlightBox;
public static Texture2D getActiveHighlightBox()
{
if (activeHighlightBox != null)
{
return activeHighlightBox;
}
Color color = Color.magenta;
Texture2D startingExample = WidgetsWork.WorkBoxOverlay_PreceptWarning;
int width = startingExample.width;
int height = startingExample.height;
Texture2D texture = new Texture2D(width, height);
Color[] pixels = Enumerable.Repeat(color, width * height).ToArray();
texture.SetPixels(pixels);
texture.Apply();
activeHighlightBox = texture;
return activeHighlightBox;
}

public static string PriorityLabel(int priority) {
/**
* 9 8 7 6 5 4
Expand Down