Skip to content

Commit

Permalink
Fixed edit window exception + version increment.
Browse files Browse the repository at this point in the history
  • Loading branch information
ISOR3X committed Apr 22, 2024
1 parent 16cfc54 commit ca202de
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<li>1.5</li>
</supportedVersions>
<packageId>ISOREX.PawnEditor</packageId>
<modVersion>1.0.4-dev</modVersion>
<modVersion>1.0.5</modVersion>
<modDependencies>
<li>
<packageId>brrainz.harmony</packageId>
Expand Down
Binary file modified Assemblies/PawnEditor.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions Languages/English/Keyed/UI.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<!-- Selection -->
<PawnEditor.Selected>selected</PawnEditor.Selected>
<PawnEditor.Colony>colony</PawnEditor.Colony>
<PawnEditor.Selection>selection</PawnEditor.Selection>
<PawnEditor.StartingPreset>starting preset</PawnEditor.StartingPreset>

<!-- Load and Randomize -->
<PawnEditor.LoadPawn>Load pawn</PawnEditor.LoadPawn>
Expand Down Expand Up @@ -82,7 +82,7 @@
<PawnEditor.ShowHeadgear>Show headgear</PawnEditor.ShowHeadgear>
<PawnEditor.ShowApparel>Show apparel</PawnEditor.ShowApparel>


<!-- Name and Hitpoints -->
<PawnEditor.Name>Name</PawnEditor.Name>
<PawnEditor.Hitpoints>Hitpoints</PawnEditor.Hitpoints>
Expand Down
2 changes: 0 additions & 2 deletions Source/PawnEditor/Dialogs/Dialog_ColorPicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public class Dialog_ColorPicker : Window
private Color _selectedColor;

private Color _textfieldColorBuffer;
private string _hexfieldStringBuffer;

public Dialog_ColorPicker(Action<Color> onSelect, ColorType colorType, Color oldColor)
{
_onSelect = onSelect;
Expand Down
6 changes: 6 additions & 0 deletions Source/PawnEditor/Dialogs/EditMenus/Dialog_EditItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public override void SetInitialSizeAndPosition()
setPosition = false;
}

public override void PostClose()
{
base.PostClose();
listing.ClearCache();
}

protected abstract void DoContents(Listing_Horizontal listing);

public override void DoWindowContents(Rect inRect)
Expand Down
10 changes: 5 additions & 5 deletions Source/PawnEditor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("PawnEditor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("A mod for RimWorld that allows you to edit pawns.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("isorex")]
[assembly: AssemblyProduct("PawnEditor")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.4")]
[assembly: AssemblyFileVersion("1.0.4")]
[assembly: AssemblyVersion("1.0.5")]
[assembly: AssemblyFileVersion("1.0.5")]
6 changes: 5 additions & 1 deletion Source/PawnEditor/Tabs/Humanlike/TabWorker_Social.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ static void DoRomance(Pawn initiator, Pawn recipient)
.AllCaravansAndTravelingTransportPods_Alive;

Find.WindowStack.Add(new FloatMenu(pawns.Where(p => p.RaceProps.Humanlike)
.Select(p => new FloatMenuOption(p.LabelCap, () => DoRomance(pawn, p)))
.Select(p => new FloatMenuOption(p.LabelCap, () =>
{
DoRomance(pawn, p);
table.ClearCache();
}))
.ToList()));
// ToDo: Add success message
})
Expand Down
2 changes: 1 addition & 1 deletion Source/PawnEditor/UI/PawnEditorUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private static IEnumerable<SaveLoadItem> GetSaveLoadItems()
}

if (Pregame)
yield return new SaveLoadItem<StartingThingsManager.StartingPreset>("PawnEditor.Selection".Translate(), new());
yield return new SaveLoadItem<StartingThingsManager.StartingPreset>("PawnEditor.StartingPreset".Translate().CapitalizeFirst(), new());
else
yield return new SaveLoadItem<Map>("PawnEditor.Colony".Translate(), Find.CurrentMap, new()
{
Expand Down
16 changes: 13 additions & 3 deletions Source/PawnEditor/Utils/RimUI/Listing_Horizontal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public class Listing_Horizontal
public Rect ListingRect;
public float curHeight;

private readonly List<ListingCell> _cells = new();
private readonly List<Rect> _cachedRects = new();
private List<ListingCell> _cells = new();
private List<Rect> _cachedRects = new();
public List<Rect> Rects = new();

private int _cellIndex;
Expand All @@ -47,12 +47,22 @@ public void End()
if (Rects.NullOrEmpty())
{
if (_rowWidth > 0) CacheCurrentRow(); // Cache final row
Rects = _cachedRects;
Rects = _cachedRects.ListFullCopy();
}

Text.Anchor = TextAnchor.UpperLeft;
Widgets.EndGroup();
}

public void ClearCache()
{
_cells.Clear();
_cachedRects.Clear();
Rects.Clear();
_rowWidth = 0;
curHeight = 0;
_maxLabelWidth = 0;
}

public Rect GetRect(int relativeWidth = -1, float height = DefaultRowHeight, bool grow = true)
{
Expand Down

0 comments on commit ca202de

Please sign in to comment.