diff --git a/About/Preview.png b/About/Preview.png
index e969ee8..4d288ce 100644
Binary files a/About/Preview.png and b/About/Preview.png differ
diff --git a/Defs/PawnColumnDefs.xml b/Defs/PawnColumnDefs.xml
index 4dd4668..3af3e8f 100644
--- a/Defs/PawnColumnDefs.xml
+++ b/Defs/PawnColumnDefs.xml
@@ -19,6 +19,14 @@
(16,16)
+
+ JobText
+ WorkTab.PawnColumnWorker_JobText
+ true
+
+ Current job
+
+
CopyPasteDetailedWorkPrioritiesWorkTab.PawnColumnWorker_CopyPasteDetailedWorkPriorities
diff --git a/Languages/English/Keyed/Keyed-English.xml b/Languages/English/Keyed/Keyed-English.xml
index 1d18a97..7767f41 100644
--- a/Languages/English/Keyed/Keyed-English.xml
+++ b/Languages/English/Keyed/Keyed-English.xml
@@ -11,7 +11,7 @@
Click to collapse all priorities\nCtrl-click headers to toggle expanding individual priorities
- Shift + left-click or scroll up to increase priorities\nShift + right click or scroll down to decrease priorities
+ Shift + left-click or scroll up to raise priorities\nShift + right click or scroll down to lower prioritiesShift + left-click or scroll up to toggle priorities on\nShift + right click or scroll down to toggle priorities offCtrl + click to expand list of detailed prioritiesCtrl + click to collapse list of detailed priorities
@@ -21,12 +21,18 @@
Should times be shown in 12h (e.g. noon, 9p.m.) or 24h (e.g. 12:00, 21:00) mode?Levels of priorityHow many levels of priority should we use? (Limited to between 4 and 9)
+ Default priority
+ Which level of priority is assigned by default?SoundsPlay sounds when a priority is changed?Crunchy soundsPlay a crunchy sound when a pawn is assigned to a job they are not skilled at?Disable ScrollwheelDisable the scrollwheel functions (when hovering over skills)
+ Current job column as text (requires restart)
+ Render the current job column as a text description of current activity.\nWhen disabled, an icon is displayed.\n\n(Due to a technical limitation, you must restart the game after changing this option.)
+ Highlight current job cell
+ Highlight the grid square in the work tab when the pawn is actually working that job right now.Vertical labelsDisplay work labels verticallyFix vertical fonts
@@ -48,7 +54,7 @@
{0} is assigned to {1}
- Click to jump to\nShift-left-click or scroll up to increment priorities\nShift-right-click or scroll down to decrement priorities
+ Click to jump to\nShift-left-click or scroll up to raise priorities\nShift-right-click or scroll down to lower prioritiesCreate new favourite
@@ -77,4 +83,4 @@
Very low priorityLowest priority
-
\ No newline at end of file
+
diff --git a/Readme.md b/Readme.md
index 65b776f..2ba8025 100644
--- a/Readme.md
+++ b/Readme.md
@@ -1,10 +1,10 @@
Provides a vastly more customizable work tab.
-
+
Work Tab completely takes over job priorities from the vanilla game. In order to support core functionalities and other mods, it intercepts calls to get/set priorities. However, when it is told to set priorities by other modded code that is not aware of the time schedule or detailed priorities, the priority will be set for the whole day, and/or for all workgivers in a worktype.
-
+
Various usability extentions to the 'vanilla' work tab;
@@ -14,32 +14,32 @@ Various usability extentions to the 'vanilla' work tab;
- Various small UX tweaks; scrolling to increase/decrease/toggle priorities, increase/decrease priorities for whole columns/rows (by holding shift and clicking/scrolling while hovering over the column header/pawn name respectively).
- _All functions are detailed in the tooltips, take a moment to hover over and read them!_
-
+
- `"Star Wars -- The Force"` versions prior to 1.21.1 cause priorities to reset for force users. **THIS INCLUDES THE CURRENT STEAM VERSION OF STAR WARS -- THE FORCE!** (as of 25/3/20). There is an official update available by one of the collaborators on the mod on [GitHub](https://github.com/jecrell/Star-Wars---The-Force/releases).
- `Better Pawn Control` has added support for `Work Tab` and `Animal Tab`, but there currently (as of 27/7/21) still is an issue where work settings may reset.
-
+
With great power comes great responsibility. The default priorities of tasks within a job is set for a good reason; it's (usually) a sensible default. Changing these can lead to deadlock situations, so change the priorities of individual jobs at your own risk!
Finally, there will never be an 'autolabour' mode where a mod sets priorities for you. Due to the way the AI is handled (e.g. pawns actively look for work, instead of there being a 'bulletin board' of jobs that need doing), it's not feasible to get the complete list of work that needs doing that would be needed to make this a reality, without extreme overhead and loads of special exception coding.
-
+

-
+
Please read [this guide](http://steamcommunity.com/sharedfiles/filedetails/?id=725234314) before creating a bug report,
and then create a bug report [here](https://github.com/fluffy-mods/WorkTab/issues)
-
+
All current and past versions of this mod can be downloaded from [GitHub](https://github.com/fluffy-mods/WorkTab/releases).
-
+
All original code in this mod is licensed under the [MIT license](https://opensource.org/licenses/MIT). Do what you want, but give me credit.
All original content (e.g. text, imagery, sounds) in this mod is licensed under the [CC-BY-SA 4.0 license](http://creativecommons.org/licenses/by-sa/4.0/).
@@ -50,26 +50,12 @@ Parts of this mod were created by, or derived from works created by;
- Freepik / flaticon.com: helmet preview image ([BY-NC](https://www.freepik.com/))
-
+
-Normally, this is where I ask you to show you appreciation by buying me a coffee.
+Become a supporter and show your appreciation by buying me a coffee (or contribute towards a nice single malt).
-These are not normal times. Ukraine is being invaded by Russia, at the whim of a ruthless dictator. Innocent people are loosing their lives, and fighting for their continued freedom.
+[](https://ko-fi.com/fluffymods)
-This is not a matter of politics. This is not a debate. Putins' bloody campaign in Ukraine is illegal, and he will stop at nothing to get what he wants, when he wants it, no matter the cost. The Russian army is invading a country without provocation, bombing civilians and murdering innocents.
+[](https://ko-fi.com/fluffymods)
-The prospect of waking up to see my country at war is alien to me, as it must have seemed to most Ukrainians. I can do little to influence the outcome of current affairs, but I will do whatever I can.
-
-**I ask you to join me in supporting the people of Ukraine**
-
-
-
-If you can, donate to the various charities providing humanitarian aid. If you don't know where to donate, Global Citizen maintains a list of charitable organizations active in the region.
-
-
-
-
-
-Leaders around the world are deciding on how to respond to Putins' aggression. They are balancing their conscience, and their desire to be re-elected. Many are afraid to impose heavy sanctions because the economic repercussions might loose them votes. The Dutch government, my government, has hinted that they are unwilling to accept Ukranian refugees, and has played a part in allowing Russia to have continued access to international finance. I am ashamed of these actions, taken in my name.
-
-Whereever your live, please let your government know you care more about supporting the people of Ukraine than you do about the price of gas. Join a protest, write letters, call your representatives, and show them that you care about justice!
+[](https://www.youtube.com/watch?v=XiCrniLQGYc)
diff --git a/Source/Core/Constants.cs b/Source/Core/Constants.cs
index e89c628..4eeef82 100644
--- a/Source/Core/Constants.cs
+++ b/Source/Core/Constants.cs
@@ -12,6 +12,7 @@ public static class Constants {
public const float MinTimeBarLabelSpacing = 50f;
public const int TimeBarHeight = 40;
public const int VerticalHeaderHeight = 100;
+ public const int JobTextWidth = 150;
public const int WorkGiverBoxSize = 20;
public const int WorkGiverWidth = 25;
public const int WorkTypeBoxSize = 25;
diff --git a/Source/Core/Settings.cs b/Source/Core/Settings.cs
index f0cb3cc..1eb33df 100644
--- a/Source/Core/Settings.cs
+++ b/Source/Core/Settings.cs
@@ -1,4 +1,4 @@
-// Settings.cs
+// Settings.cs
// Copyright Karel Kroeze, 2020-2020
using UnityEngine;
@@ -6,20 +6,22 @@
namespace WorkTab {
public class Settings: ModSettings {
- public static int defaultPriority = 3;
- public static bool disableScrollwheel;
- public static int maxPriority = 9;
- public static bool playCrunch = true;
- public static bool playSounds = true;
- public static bool TwentyFourHourMode = true;
- public static bool verticalLabels = true;
- private static string _defaultPriorityBuffer = defaultPriority.ToString();
-
- // public static bool sharedFavourites = true;
+ public static int maxPriority = 9;
+ public static int defaultPriority = 3;
+ public static bool TwentyFourHourMode = true;
+ public static bool playSounds = true;
+ public static bool playCrunch = true;
+ public static bool disableScrollwheel = false;
+ public static bool jobTextMode = false;
+ public static bool highlightCurrentJobCell = true;
+ public static bool verticalLabels = true;
private static bool _fontFix = true;
+ // public static bool sharedFavourites = true;
- // buffers
- private static string _maxPriorityBuffer = maxPriority.ToString();
+ // Buffers will be initialized with current settings as soon as
+ // DoWindowContents() → Listing_Standard.TextFieldNumericLabeled() → Widgets.TextFieldNumeric() will be called.
+ private static string maxPriorityBuffer = null;
+ private static string defaultPriorityBuffer = null;
public Settings() {
ApplyFontFix(_fontFix);
@@ -37,20 +39,23 @@ public static void ApplyFontFix(bool state) {
public static void DoWindowContents(Rect rect) {
Listing_Standard options = new Listing_Standard();
options.Begin(rect);
- options.TextFieldNumericLabeled("WorkTab.MaxPriority".Translate(), ref maxPriority, ref _maxPriorityBuffer,
+ options.TextFieldNumericLabeled("WorkTab.MaxPriority".Translate(), ref maxPriority, ref maxPriorityBuffer,
4, 9, "WorkTab.MaxPriorityTip".Translate(), 1 / 8f);
options.TextFieldNumericLabeled("WorkTab.DefaultPriority".Translate(), ref defaultPriority,
- ref _defaultPriorityBuffer, 1, 9, "WorkTab.DefaultPriorityTip".Translate(),
+ ref defaultPriorityBuffer, 1, 9, "WorkTab.DefaultPriorityTip".Translate(),
1 / 8f);
options.CheckboxLabeled("WorkTab.24HourMode".Translate(), ref TwentyFourHourMode,
"WorkTab.24HourModeTip".Translate());
options.CheckboxLabeled("WorkTab.PlaySounds".Translate(), ref playSounds,
"WorkTab.PlaySoundsTip".Translate());
- playCrunch = playSounds && playCrunch; // disabling sounds also disables crunch.
options.CheckboxLabeled("WorkTab.PlayCrunch".Translate(), ref playCrunch, !playSounds,
"WorkTab.PlayCrunchTip".Translate());
options.CheckboxLabeled("WorkTab.DisableScrollwheel".Translate(), ref disableScrollwheel,
"WorkTab.DisableScrollwheelTip".Translate());
+ options.CheckboxLabeled("WorkTab.JobTextMode".Translate(), ref jobTextMode,
+ "WorkTab.JobTextModeTip".Translate());
+ options.CheckboxLabeled("WorkTab.HighlightCurrentJobCell".Translate(), ref highlightCurrentJobCell,
+ "WorkTab.HighlightCurrentJobCellTip".Translate());
bool verticalLabelsBuffer = verticalLabels;
options.CheckboxLabeled("WorkTab.VerticalLabels".Translate(), ref verticalLabelsBuffer,
"WorkTab.VerticalLabelsTip".Translate());
@@ -64,7 +69,7 @@ public static void DoWindowContents(Rect rect) {
options.CheckboxLabeled("WorkTab.FontFix".Translate(), ref _fontFixBuffer,
"WorkTab.FontFixTip".Translate());
_fontFixBuffer =
- verticalLabels && _fontFixBuffer; // disabling vertical labels makes the font fix unnecesary.
+ verticalLabels && _fontFixBuffer; // disabling vertical labels makes the font fix unnecessary.
// apply any changes.
if (_fontFixBuffer != _fontFix) {
@@ -86,7 +91,9 @@ public override void ExposeData() {
Scribe_Values.Look(ref playSounds, "PlaySounds", true);
Scribe_Values.Look(ref playCrunch, "PlayCrunch", true);
Scribe_Values.Look(ref disableScrollwheel, "DisableScrollwheel");
+ Scribe_Values.Look(ref jobTextMode, "JobTextMode");
Scribe_Values.Look(ref verticalLabels, "VerticalLabels", true);
+ Scribe_Values.Look(ref highlightCurrentJobCell, "HighlightCurrentJobCell", true);
Scribe_Values.Look(ref _fontFix, "FontFix", true);
// apply font-fix on load
diff --git a/Source/Extensions/PawnTable_Extensions.cs b/Source/Extensions/PawnTable_Extensions.cs
new file mode 100644
index 0000000..5d94289
--- /dev/null
+++ b/Source/Extensions/PawnTable_Extensions.cs
@@ -0,0 +1,35 @@
+using RimWorld;
+using RimWorld.BaseGen;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using UnityEngine;
+
+namespace WorkTab.Extensions {
+ internal static class PawnTable_Extensions {
+ private static ConditionalWeakTable> outRectDictionary=new ConditionalWeakTable>();
+ ///
+ /// Sets the rectangle the is drawn in.
+ ///
+ /// The being extended.
+ /// The rectangle the will be drawn in.
+ internal static void set_OutRect(this PawnTable pawnTable, Rect outRect) {
+ var value = outRectDictionary.GetValue(
+ pawnTable,
+ a => new StrongBox(outRect)
+ );
+ value.Value = outRect;
+ }
+ ///
+ /// Gets the rectangle the will be drawn in.
+ ///
+ /// The being extended.
+ /// The rectangle the will be drawn in.
+ internal static Rect get_OutRect(this PawnTable pawnTable) {
+ return outRectDictionary.GetOrCreateValue(pawnTable).Value;
+ }
+ }
+}
diff --git a/Source/Favourites/FavouriteManager.cs b/Source/Favourites/FavouriteManager.cs
index 9aa454f..879b0e6 100644
--- a/Source/Favourites/FavouriteManager.cs
+++ b/Source/Favourites/FavouriteManager.cs
@@ -179,7 +179,7 @@ private static void LoadFavouriteFloatMenu(Pawn pawn) {
() => LoadFavourite(f.path, pawn)))
.ToList();
if (options.Count == 0) {
- options.Add(new FloatMenuOption("Fluffy.WorkTab.NoStoredFavourites", null));
+ options.Add(new FloatMenuOption("Fluffy.WorkTab.NoStoredFavourites".Translate(), null));
}
Find.WindowStack.Add(new FloatMenu(options));
}
diff --git a/Source/HarmonyPatches/DefGenerator_GenerateImpliedDefs_PreResolve.cs b/Source/HarmonyPatches/DefGenerator_GenerateImpliedDefs_PreResolve.cs
index f7e7dfb..3199a3d 100644
--- a/Source/HarmonyPatches/DefGenerator_GenerateImpliedDefs_PreResolve.cs
+++ b/Source/HarmonyPatches/DefGenerator_GenerateImpliedDefs_PreResolve.cs
@@ -16,25 +16,30 @@ private static void Postfix() {
// get our table
PawnTableDef workTable = PawnTableDefOf.Work;
- // replace label column
- int labelIndex = workTable.columns.IndexOf(PawnColumnDefOf.LabelShortWithIcon);
- // Fix for 1.5 returning invalid index
- if (labelIndex != -1)
+ // Replace label column.
+ // The def of label column changes from version to version of RimWorld.
+ // v1.3: Label
+ // v1.4: LabelShortWithIcon
+ // v1.5: LabelWithIcon
+ // Look for a column with the specific def, in case some other mod interferes and rearranges/adds columns,
+ // and the label column is not the first one.
+ // If not found, assume that it is the first column. This should improve compatibility with possible future changes.
+ int labelIndex = workTable.columns.IndexOf(PawnColumnDefOf.LabelWithIcon);
+ if (labelIndex < 0)
{
- workTable.columns.RemoveAt(labelIndex);
- workTable.columns.Insert(labelIndex, PawnColumnDefOf.WorkTabLabel);
- }
- else
- {
- //Logger.Debug($"Invalid work table index for {PawnColumnDefOf.LabelShortWithIcon.LabelCap}.");
- workTable.columns.RemoveAt(0);
- workTable.columns.Insert(0, PawnColumnDefOf.WorkTabLabel);
+ labelIndex = 0;
+ Logger.Warning($"Warning: Cannot find label column in the original Work tab. Assuming that it is the first column.");
}
+ workTable.columns[labelIndex] = PawnColumnDefOf.WorkTabLabel;
// insert mood and job columns before first work column name
int firstWorkindex =
workTable.columns.FindIndex(d => d.workerClass == typeof(PawnColumnWorker_WorkPriority));
- workTable.columns.Insert(firstWorkindex, PawnColumnDefOf.Job);
+ if (Settings.jobTextMode) {
+ workTable.columns.Insert(firstWorkindex, PawnColumnDefOf.JobText);
+ } else {
+ workTable.columns.Insert(firstWorkindex, PawnColumnDefOf.Job);
+ }
workTable.columns.Insert(firstWorkindex + 1, PawnColumnDefOf.Mood);
// go over PawnColumnDefs and replace all PawnColumnWorker_WorkPriority
diff --git a/Source/HarmonyPatches/PawnTable/PawnTable_PawnTableOnGUI.cs b/Source/HarmonyPatches/PawnTable/PawnTable_PawnTableOnGUI.cs
index 28462f6..3c0d8bd 100644
--- a/Source/HarmonyPatches/PawnTable/PawnTable_PawnTableOnGUI.cs
+++ b/Source/HarmonyPatches/PawnTable/PawnTable_PawnTableOnGUI.cs
@@ -8,6 +8,7 @@
using RimWorld;
using UnityEngine;
using Verse;
+using WorkTab.Extensions;
namespace WorkTab {
[HarmonyPatch(typeof(PawnTable), nameof(PawnTable.PawnTableOnGUI))]
@@ -79,7 +80,11 @@ public static bool Prefix(PawnTable __instance,
// Instead, we want to limit outRect to the available view area, so a horizontal scrollbar can appear.
float labelWidth = cachedColumnWidths[0];
var labelCol = columns[0];
- float outWidth = Mathf.Min( cachedSize.x - labelWidth, UI.screenWidth - (standardWindowMargin * 2f) );
+ // ideally this method would be called with a Rect outRect
+ // indicating the window it is being drawn in instead
+ // of a Vector2 position
+ var outRect = __instance.get_OutRect();
+ float outWidth = outRect.width - labelWidth;
float viewWidth = cachedSize.x - labelWidth - 16f;
Rect labelHeaderRect = new Rect(
diff --git a/Source/PawnColumns/PawnColumnWorker_JobText.cs b/Source/PawnColumns/PawnColumnWorker_JobText.cs
new file mode 100644
index 0000000..2c83c21
--- /dev/null
+++ b/Source/PawnColumns/PawnColumnWorker_JobText.cs
@@ -0,0 +1,33 @@
+// Copyright Karel Kroeze, 2020-2021.
+// WorkTab/WorkTab/PawnColumnWorker_JobText.cs
+
+using RimWorld;
+using Verse;
+using static WorkTab.Constants;
+
+namespace WorkTab {
+ public class PawnColumnWorker_JobText : PawnColumnWorker_Text {
+ public override int GetMinWidth(PawnTable table)
+ {
+ return JobTextWidth;
+ }
+ private string GetJobString(Pawn pawn)
+ {
+ return pawn.jobs?.curDriver?.GetReport() ?? "";
+ }
+ protected override string GetTextFor(Pawn pawn) {
+ return GetJobString(pawn);
+ }
+ protected override string GetTip(Pawn pawn) {
+ return GetJobString(pawn);
+ }
+ public string GetValueToCompare(Pawn pawn)
+ {
+ return GetJobString(pawn);
+ }
+ public override int Compare(Pawn a, Pawn b)
+ {
+ return GetValueToCompare(a).CompareTo(GetValueToCompare(b));
+ }
+ }
+}
diff --git a/Source/PawnColumns/PawnColumnWorker_WorkGiver.cs b/Source/PawnColumns/PawnColumnWorker_WorkGiver.cs
index f8dd1c1..df56e78 100644
--- a/Source/PawnColumns/PawnColumnWorker_WorkGiver.cs
+++ b/Source/PawnColumns/PawnColumnWorker_WorkGiver.cs
@@ -50,20 +50,18 @@ public override int Compare(Pawn a, Pawn b) {
public override void DoCell(Rect rect, Pawn pawn, PawnTable table) {
// bail out if showing worksettings is nonsensical
- if (pawn.Dead
- || !pawn.workSettings.EverWork) {
+ if (pawn.Dead || !pawn.workSettings.EverWork) {
return;
}
WorkGiverDef workgiver = WorkGiver;
+ // is the pawn currently capable of doing this job?
+ bool incapable = !pawn.CapableOf(workgiver);
// 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 );
- // is the pawn currently capable of doing this job?
- bool incapable = !pawn.CapableOf( workgiver );
-
// plop in the tooltip
string tipGetter() { return DrawUtilities.TipForPawnWorker(pawn, workgiver, incapable); }
TooltipHandler.TipRegion(box, tipGetter, pawn.thingIDNumber ^ workgiver.workType.GetHashCode());
@@ -73,9 +71,16 @@ public override void DoCell(Rect rect, Pawn pawn, PawnTable table) {
return;
}
+ // Highlight the cell if currently doing the job.
+ if (Settings.highlightCurrentJobCell && pawn.CurJob?.workGiverDef == workgiver) {
+ GUI.color = Color.white;
+ GUI.DrawTexture(box.ExpandedBy(4), DrawUtilities.GetCurrentJobHighlightTexture());
+ }
+
// draw the workbox
Text.Font = GameFont.Tiny;
DrawWorkGiverBoxFor(box, pawn, workgiver, incapable);
+ Text.Font = GameFont.Small;
// handle interactions
HandleInteractions(rect, pawn);
diff --git a/Source/PawnColumns/PawnColumnWorker_WorkType.cs b/Source/PawnColumns/PawnColumnWorker_WorkType.cs
index d1d2524..583e14b 100644
--- a/Source/PawnColumns/PawnColumnWorker_WorkType.cs
+++ b/Source/PawnColumns/PawnColumnWorker_WorkType.cs
@@ -79,8 +79,8 @@ public override void DoCell(Rect rect, Pawn pawn, PawnTable table) {
return;
}
+ WorkTypeDef worktype = def.workType;
bool incapable = IncapableOfWholeWorkType( pawn );
- WorkTypeDef worktype = def.workType;
// create rect in centre of cell
Vector2 pos = rect.center - (new Vector2( WorkTypeBoxSize, WorkTypeBoxSize ) / 2f);
@@ -95,6 +95,12 @@ public override void DoCell(Rect rect, Pawn pawn, PawnTable table) {
return;
}
+ // Highlight the cell if currently doing the work type.
+ if (Settings.highlightCurrentJobCell && pawn.CurJob?.workGiverDef?.workType == worktype) {
+ GUI.color = Color.white;
+ GUI.DrawTexture(box.ExpandedBy(4), DrawUtilities.GetCurrentJobHighlightTexture());
+ }
+
// draw the workbox
Text.Font = GameFont.Medium;
DrawWorkTypeBoxFor(box, pawn, worktype, incapable);
@@ -381,7 +387,7 @@ private void HandleInteractionsDetailed(Rect rect, Pawn pawn) {
}
private void HandleInteractionsToggle(Rect rect, Pawn pawn) {
- if ((Event.current.type == EventType.MouseDown || Event.current.type == EventType.ScrollWheel)
+ if ((Event.current.type == EventType.MouseDown || (Event.current.type == EventType.ScrollWheel && !Settings.disableScrollwheel))
&& Mouse.IsOver(rect)) {
// track priority so we can play appropriate sounds
bool active = pawn.GetPriority( def.workType, VisibleHour ) > 0;
diff --git a/Source/PawnTable/MainTabWindow_WorkTab.cs b/Source/PawnTable/MainTabWindow_WorkTab.cs
index 4e1bf05..f4c8009 100644
--- a/Source/PawnTable/MainTabWindow_WorkTab.cs
+++ b/Source/PawnTable/MainTabWindow_WorkTab.cs
@@ -10,6 +10,7 @@
using RimWorld.Planet;
using UnityEngine;
using Verse;
+using WorkTab.Extensions;
using static WorkTab.Constants;
using static WorkTab.InteractionUtilities;
using static WorkTab.Resources;
@@ -122,6 +123,7 @@ public static void SelectWholeDay() {
}
public override void DoWindowContents(Rect rect) {
+ Instance.Table.set_OutRect(rect);
if (_columnsChanged) {
RebuildTable();
}
diff --git a/Source/Priorities/PriorityManager.cs b/Source/Priorities/PriorityManager.cs
index 79d6046..fd43f4e 100644
--- a/Source/Priorities/PriorityManager.cs
+++ b/Source/Priorities/PriorityManager.cs
@@ -16,11 +16,15 @@ public class PriorityManager: GameComponent {
private List pawnPriorityTrackersScribe;
private List pawnsScribe;
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "RimWorld requires a constructor with parameter")]
public PriorityManager(Game game) : this() {
}
public PriorityManager() {
_instance = this;
+ _nextId = 0;
+ _showScheduler = false;
+ priorities = new Dictionary();
}
public static PriorityManager Get {
@@ -90,7 +94,7 @@ public override void ExposeData() {
List pawns = priorities.Keys.ToList();
foreach (Pawn pawn in pawns) {
if (pawn?.Destroyed ?? true) // null or destroyed
-{
+ {
priorities.Remove(pawn);
}
}
diff --git a/Source/Utilities/DefOf.cs b/Source/Utilities/DefOf.cs
index c643126..799d5d7 100644
--- a/Source/Utilities/DefOf.cs
+++ b/Source/Utilities/DefOf.cs
@@ -14,7 +14,8 @@ public static class PawnColumnDefOf {
[MayRequireIdeology] public static PawnColumnDef Guest;
[MayRequireIdeology] public static PawnColumnDef Ideo;
public static PawnColumnDef Job;
- public static PawnColumnDef LabelShortWithIcon;
+ public static PawnColumnDef JobText;
+ public static PawnColumnDef LabelWithIcon;
public static PawnColumnDef Mood;
public static PawnColumnDef WorkTabLabel;
}
diff --git a/Source/Utilities/DrawUtilities.cs b/Source/Utilities/DrawUtilities.cs
index 6cd3d2b..e196de7 100644
--- a/Source/Utilities/DrawUtilities.cs
+++ b/Source/Utilities/DrawUtilities.cs
@@ -11,6 +11,7 @@
using Verse;
namespace WorkTab {
+ [StaticConstructorOnStartup]
public static class DrawUtilities {
private static MethodInfo _drawWorkBoxBackgroundMethodInfo;
@@ -31,7 +32,7 @@ public static void DrawPriority(Rect box, int priority, bool small = false) {
GameFont font = small ? GameFont.Small : GameFont.Medium;
- // detailed mode
+ // detailed mode?
if (Find.PlaySettings.useWorkPriorities) {
Text.Anchor = TextAnchor.MiddleCenter;
Text.Font = font;
@@ -41,9 +42,8 @@ public static void DrawPriority(Rect box, int priority, bool small = false) {
Text.Font = GameFont.Small;
Text.Anchor = TextAnchor.UpperLeft;
}
-
- // toggle mode
else {
+ // draw for toggle mode
GUI.DrawTexture(box.ContractedBy(3f), WidgetsWork.WorkBoxCheckTex);
}
}
@@ -70,6 +70,36 @@ public static void DrawWorkBoxBackground(Rect box, Pawn pawn, WorkTypeDef workty
_drawWorkBoxBackgroundMethodInfo.Invoke(null, new object[] { box, pawn, worktype });
}
+ private static Texture2D currentJobHighlightTexture;
+ public static Texture2D GetCurrentJobHighlightTexture() {
+ if (currentJobHighlightTexture != null) {
+ return currentJobHighlightTexture;
+ }
+
+ // Caribbean green. Non-transparent.
+ Color color = new Color(0, 0.8f, 0.6f);
+
+ // Work type priority box has a red outline of width 2 for low skills.
+ // The current job highlight outline should have width of 2 beyond the red outline.
+ // So, the highlight texture should be bigger than priority box by 8.
+ // The texture will be resampled, so, for better quality, define it's size as triple of what is needed.
+ int oneThird = Constants.WorkTypeBoxSize + 8;
+ int texSize = oneThird * 3;
+ Texture2D texture = new Texture2D(texSize, texSize);
+
+ // Split the texture 3x3.
+ // Color the corner zones, make other zones transparent.
+ // When priority box will be drawn on top of this, the peeking parts of texture will look like corner brackets.
+ for (int x = 0; x < texSize; ++x) {
+ for (int y = 0; y < texSize; ++y) {
+ texture.SetPixel(x, y, (((x / oneThird) | (y / oneThird)) & 1) == 0 ? color : Color.clear);
+ }
+ }
+
+ texture.Apply();
+ return currentJobHighlightTexture = texture;
+ }
+
public static string PriorityLabel(int priority) {
/**
* 9 8 7 6 5 4
diff --git a/Source/Utilities/Logger.cs b/Source/Utilities/Logger.cs
index 4eac397..1c7b9e1 100644
--- a/Source/Utilities/Logger.cs
+++ b/Source/Utilities/Logger.cs
@@ -34,5 +34,10 @@ public static void Message(string msg) {
public static void Trace(string msg) {
Log.Error(FormatMessage(msg));
}
+
+ public static void Warning(string msg)
+ {
+ Log.Warning(FormatMessage(msg));
+ }
}
}
diff --git a/Source/WorkTab.sln b/Source/WorkTab.sln
index 0d621db..68f5132 100644
--- a/Source/WorkTab.sln
+++ b/Source/WorkTab.sln
@@ -5,8 +5,6 @@ VisualStudioVersion = 15.0.26430.6
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkTab", "WorkTab.csproj", "{5C909B0F-E82A-46B1-AE39-E56285B236A2}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamicPawnTable", "..\..\..\TOOLS\DynamicPawnTable\DynamicPawnTable\DynamicPawnTable.csproj", "{E93B85A6-EEFF-4BDE-A6F4-CCE6D3487F9A}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluffyUI", "..\..\..\TOOLS\FluffyUI\FluffyUI\FluffyUI.csproj", "{3E905175-2540-4C06-B4C6-F955836C0451}"
EndProject
Global
@@ -19,10 +17,6 @@ Global
{5C909B0F-E82A-46B1-AE39-E56285B236A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C909B0F-E82A-46B1-AE39-E56285B236A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C909B0F-E82A-46B1-AE39-E56285B236A2}.Release|Any CPU.Build.0 = Release|Any CPU
- {E93B85A6-EEFF-4BDE-A6F4-CCE6D3487F9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E93B85A6-EEFF-4BDE-A6F4-CCE6D3487F9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E93B85A6-EEFF-4BDE-A6F4-CCE6D3487F9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E93B85A6-EEFF-4BDE-A6F4-CCE6D3487F9A}.Release|Any CPU.Build.0 = Release|Any CPU
{3E905175-2540-4C06-B4C6-F955836C0451}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E905175-2540-4C06-B4C6-F955836C0451}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E905175-2540-4C06-B4C6-F955836C0451}.Release|Any CPU.ActiveCfg = Release|Any CPU