Skip to content

Commit

Permalink
UI Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
koisama committed May 3, 2016
1 parent 8aa2108 commit e67f68e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
Binary file modified Assemblies/RWNumbers.dll
Binary file not shown.
19 changes: 16 additions & 3 deletions Source/kNumbers/KListObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public KListObject(objectType type, string defName, object dObject)
break;

case objectType.CurrentJob:
minWidthDesired = 320f;
minWidthDesired = 260f;
break;
}

Expand Down Expand Up @@ -363,6 +363,8 @@ public static void MedicalCareSetter(Rect rect, ref MedicalCareCategory medCare)

public void Draw(Rect rect, ThingWithComps ownerPawn)
{
Text.Font = GameFont.Small;

switch (oType)
{
case objectType.Stat:
Expand Down Expand Up @@ -450,8 +452,19 @@ public void Draw(Rect rect, ThingWithComps ownerPawn)
case objectType.CurrentJob:
if(ownerPawn is Pawn)
{
Text.Anchor = TextAnchor.MiddleLeft;
Widgets.Label(rect, " "+((Pawn)ownerPawn).jobs.curDriver.GetReport());
string text = ((Pawn)ownerPawn).jobs.curDriver.GetReport();
Text.Anchor = TextAnchor.MiddleLeft;
Rect tRect = new Rect(rect.xMin + 2, rect.yMin + 3, rect.width - 2, rect.height);
GenText.SetTextSizeToFit(text, tRect);

if (Text.Font == GameFont.Tiny)
Widgets.Label(tRect, text);
else
{
Rect sRect = new Rect(rect.xMin + 2, rect.yMin, rect.width - 2, rect.height);
Widgets.Label(sRect, text);
}

if (Mouse.IsOver(rect))
{
GUI.DrawTexture(rect, TexUI.HighlightTex);
Expand Down
24 changes: 13 additions & 11 deletions Source/kNumbers/MainTabWindow_Numbers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public abstract class MainTabWindow_ThingWithComp: MainTabWindow

public const float buttonWidth = 160f;

public const float PawnRowHeight = 30f;
public const float PawnRowHeight = 35f;

protected const float NameColumnWidth = 175f;

Expand Down Expand Up @@ -74,14 +74,14 @@ public void Notify_PawnsChanged()

protected void DrawRows(Rect outRect)
{
Rect viewRect = new Rect(0f, 0f, outRect.width - 16f, (float)this.things.Count * 30f);
Rect viewRect = new Rect(0f, 0f, outRect.width - 16f, (float)this.things.Count * PawnRowHeight);
Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect);
float num = 0f;
for (int i = 0; i < this.things.Count; i++)
{
ThingWithComps p = this.things[i];
Rect rect = new Rect(0f, num, viewRect.width, 30f);
if (num - this.scrollPosition.y + 30f >= 0f && num - this.scrollPosition.y <= outRect.height)
Rect rect = new Rect(0f, num, viewRect.width, PawnRowHeight);
if (num - this.scrollPosition.y + PawnRowHeight >= 0f && num - this.scrollPosition.y <= outRect.height)
{
GUI.color = new Color(1f, 1f, 1f, 0.2f);
Widgets.DrawLineHorizontal(0f, num, viewRect.width);
Expand All @@ -90,20 +90,20 @@ protected void DrawRows(Rect outRect)
this.DrawPawnRow(rect, p);
this.PostDrawPawnRow(rect, p);
}
num += 30f;
num += PawnRowHeight;
}
Widgets.EndScrollView();
Text.Anchor = TextAnchor.UpperLeft;
}

private void PreDrawPawnRow(Rect rect, ThingWithComps p)
{
Rect rect2 = new Rect(0f, rect.y, rect.width, 30f);
Rect rect2 = new Rect(0f, rect.y, rect.width, PawnRowHeight);
if (Mouse.IsOver(rect2))
{
GUI.DrawTexture(rect2, TexUI.HighlightTex);
}
Rect rect3 = new Rect(0f, rect.y, 175f, 30f);
Rect rect3 = new Rect(0f, rect.y, 175f, PawnRowHeight);
Rect position = rect3.ContractedBy(3f);
if (p is Pawn)
{
Expand Down Expand Up @@ -573,6 +573,7 @@ public void OtherOptionsMaker()
list.Add(new FloatMenuOption("koisama.MedicalCare".Translate(), action, MenuOptionPriority.Medium, null, null));
}

if (! new[] { pawnType.Corpses, pawnType.AnimalCorpses }.Contains(chosenPawnType))
{
Action action = delegate
{
Expand All @@ -599,7 +600,7 @@ public override void DoWindowContents(Rect r)
UpdatePawnList();
}

Rect position = new Rect(0f, 0f, r.width, 110f);
Rect position = new Rect(0f, 0f, r.width, 115f);
GUI.BeginGroup(position);

float x = 0f;
Expand Down Expand Up @@ -688,6 +689,7 @@ public override void DoWindowContents(Rect r)
//TODO: better interface - auto width calculation
bool offset = true;
kListDesiredWidth = 175f;
Text.Anchor = TextAnchor.MiddleCenter;

for (int i=0;i<kList.Count; i++)
{
Expand All @@ -700,8 +702,8 @@ public override void DoWindowContents(Rect r)

kListDesiredWidth += colWidth;

Rect defLabel = new Rect(x-35, 20f + (offset ? 10f : 50f), colWidth+70 , 40f);
Widgets.DrawLine(new Vector2(x + colWidth/2 , 52f + (offset ? 15f : 55f)), new Vector2(x + colWidth/2 , 110f), Color.gray, 1);
Rect defLabel = new Rect(x-35, 25f + (offset ? 10f : 50f), colWidth+70 , 40f);
Widgets.DrawLine(new Vector2(x + colWidth/2 , 55f + (offset ? 15f : 55f)), new Vector2(x + colWidth/2 , 113f), Color.gray, 1);
Widgets.Label(defLabel, kList[i].label);

StringBuilder labelSB = new StringBuilder();
Expand Down Expand Up @@ -760,7 +762,7 @@ protected override void DrawPawnRow(Rect r, ThingWithComps p)
//soft break
break;
}
Rect capCell = new Rect(x, y, colWidth, 30f);
Rect capCell = new Rect(x, y, colWidth, PawnRowHeight);
kList[i].Draw(capCell, p);
x += colWidth;
}
Expand Down

0 comments on commit e67f68e

Please sign in to comment.