Skip to content

Commit

Permalink
fix: Use SkillRecord.Level instead of SkillRecord.levelInt. (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
krafs authored Oct 25, 2022
1 parent 00d1794 commit 8d9ee45
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 33 deletions.
2 changes: 1 addition & 1 deletion LevelUp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="5.10.3" />
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.4.3525" />
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.4.3527" />
<PackageReference Include="Lib.Harmony" Version="2.2.2" ExcludeAssets="runtime" />
</ItemGroup>

Expand Down
25 changes: 17 additions & 8 deletions Source/Actions/TextAction.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Globalization;
using System.Text;
using RimWorld;
using UnityEngine;
using Verse;

Expand All @@ -20,25 +21,33 @@ public override void Prepare()
}

protected static string ResolveText(LevelingInfo levelingInfo, string text)
{
return ResolveText(levelingInfo.Pawn.LabelShortCap, levelingInfo.SkillRecord.Level, levelingInfo.SkillRecord.def.LabelCap, text);
}

private static string ResolveText(string pawnLabel, int skillLevel, string skillLabel, string text)
{
return stringBuilder
.Clear()
.Append(text)
.Replace("{PAWN}", levelingInfo.Pawn.LabelShortCap)
.Replace("{LEVEL}", levelingInfo.SkillRecord.levelInt.ToString(CultureInfo.InvariantCulture))
.Replace("{SKILL}", levelingInfo.SkillRecord.def.LabelCap)
.Replace("{PAWN}", pawnLabel)
.Replace("{LEVEL}", skillLevel.ToString(CultureInfo.InvariantCulture))
.Replace("{SKILL}", skillLabel)
.ToString();
}

protected Rect DrawTextBuilder(Rect rect)
{
var pawnLabel = "Levelyn";
var skillLevel = 18;
var skillLabel = SkillDefOf.Intellectual.LabelCap;

var rowRect = new Rect(rect) { height = 24f };

var exampleTextRect = new Rect(rowRect) { height = rowRect.height * 2 };
var curAnchor = Verse.Text.Anchor;
Verse.Text.Anchor = TextAnchor.MiddleCenter;
var levelingInfo = GenLevelingInfo.Fake;
Widgets.Label(exampleTextRect, ResolveText(levelingInfo, Text));
Widgets.Label(exampleTextRect, ResolveText(pawnLabel, skillLevel, skillLabel, Text));
Verse.Text.Anchor = curAnchor;

rowRect.y = rowRect.yMax + 5f;
Expand All @@ -56,17 +65,17 @@ protected Rect DrawTextBuilder(Rect rect)
guideRowRect.y = guideRowRect.yMax;
label2Rect.y = label2Rect.yMax;
Widgets.Label(guideRowRect, "{PAWN}");
Widgets.Label(label2Rect, levelingInfo.Pawn.LabelShortCap);
Widgets.Label(label2Rect, pawnLabel);

guideRowRect.y = guideRowRect.yMax;
label2Rect.y = label2Rect.yMax;
Widgets.Label(guideRowRect, "{LEVEL}");
Widgets.Label(label2Rect, levelingInfo.SkillRecord.levelInt.ToString(CultureInfo.InvariantCulture));
Widgets.Label(label2Rect, skillLevel.ToString(CultureInfo.InvariantCulture));

guideRowRect.y = guideRowRect.yMax;
label2Rect.y = label2Rect.yMax;
Widgets.Label(guideRowRect, "{SKILL}");
Widgets.Label(label2Rect, levelingInfo.SkillRecord.def.LabelCap);
Widgets.Label(label2Rect, skillLabel);

guideRowRect.y = guideRowRect.yMax + 5f;
label2Rect.y = label2Rect.yMax + 5f;
Expand Down
24 changes: 0 additions & 24 deletions Source/GenLevelingInfo.cs

This file was deleted.

0 comments on commit 8d9ee45

Please sign in to comment.