Skip to content

Commit

Permalink
Fix thing
Browse files Browse the repository at this point in the history
  • Loading branch information
LokiVKlokeNaAndoke committed Oct 23, 2022
1 parent 41c8934 commit 98eb667
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 12 deletions.
Binary file modified 1.4/Assemblies/AutoPriorities.dll
Binary file not shown.
Binary file modified ConditionalAssemblies/1.4/FluffyWorktabPatch.dll
Binary file not shown.
20 changes: 10 additions & 10 deletions Source/AutoPriorities/AutoPriorities/Core/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ namespace AutoPriorities.Core
{
public class Controller : ModBase
{
private static ILogger? _logger;
public static ILogger? logger;
public static PawnsData? pawnData;

public static AutoPrioritiesDialog? Dialog { get; private set; }

public override void Initialize()
{
base.Initialize();
_logger = new Logger(Logger);
logger = new Logger(Logger);

PatchMod("fluffy.worktab", "FluffyWorktabPatch.dll");
HarmonyInst.PatchAll();
Expand All @@ -41,7 +41,7 @@ private void PatchMod(string packageId, string patchName)
{
if (!LoadedModManager.RunningModsListForReading.Exists(m => m.PackageId == packageId)) return;

_logger?.Info($"Patching for: {packageId}");
logger?.Info($"Patching for: {packageId}");

var asm = Assembly.LoadFile(
Path.Combine(ModContentPack.RootDir, Path.Combine("ConditionalAssemblies/1.4/", patchName)));
Expand All @@ -68,16 +68,16 @@ private static AutoPrioritiesDialog CreateDialog()
var savePath = GetSaveLocation();

var worldInfo = new WorldInfoRetriever.WorldInfoRetriever();
var logger = _logger!;
var worldFacade = new WorldInfoFacade(worldInfo, logger);
var stringSerializer = new PawnDataStringSerializer(logger, worldFacade);
var log = Controller.logger!;
var worldFacade = new WorldInfoFacade(worldInfo, log);
var stringSerializer = new PawnDataStringSerializer(log, worldFacade);
var mapSpecificSerializer = new MapSpecificDataPawnsDataSerializer(worldInfo, stringSerializer);
pawnData = new PawnsDataBuilder(mapSpecificSerializer, worldInfo, logger).Build();
pawnData = new PawnsDataBuilder(mapSpecificSerializer, worldInfo, log).Build();
var importantWorkTypes = new ImportantJobsProvider(worldFacade);
var priorityAssigner = new PrioritiesAssigner(pawnData, logger, importantWorkTypes);
var pawnDataExporter = new PawnDataExporter(logger, savePath, pawnData, stringSerializer);
var priorityAssigner = new PrioritiesAssigner(pawnData, log, importantWorkTypes);
var pawnDataExporter = new PawnDataExporter(log, savePath, pawnData, stringSerializer);

return new AutoPrioritiesDialog(pawnData, priorityAssigner, logger, importantWorkTypes, pawnDataExporter);
return new AutoPrioritiesDialog(pawnData, priorityAssigner, log, importantWorkTypes, pawnDataExporter);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AutoPriorities.Core;
using AutoPriorities.Ui;
using HarmonyLib;
using RimWorld;
using Verse;
Expand All @@ -14,7 +15,20 @@ public static class DirtyPawnsNotifyRebuildPawnsTable
// ReSharper disable once UnusedMember.Local
private static void Postfix()
{
Controller.pawnData?.Rebuild();
var windowStack = Find.WindowStack;
if (windowStack.WindowOfType<AutoPrioritiesDialog>() is not null)
{
#if DEBUG
Controller.logger?.Info("Rebuild by notification");
#endif
Controller.pawnData?.Rebuild();
}
else
{
#if DEBUG
Controller.logger?.Info("Rebuild by notification: auto priority window not found");
#endif
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,12 @@ private void DrawWorkListForPriority(WorkTableEntry pr, Rect slidersRect)
try
{
var currentPercent = pr.WorkTypes[workType];

var numberColonists = _pawnsData.NumberColonists(workType);
if (currentPercent.Variant == PercentVariant.Number)
{
currentPercent = TablePercent.Number(numberColonists, currentPercent.NumberCount);
}

float elementXPos;
Rect labelRect;
double available;
Expand Down

0 comments on commit 98eb667

Please sign in to comment.