forked from fluffy-mods/RW_Outfitter
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
316e43f
commit e31df8c
Showing
8 changed files
with
232 additions
and
113 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace Outfitter.TabPatch | ||
{ | ||
using System.Collections.Generic; | ||
|
||
using Harmony; | ||
|
||
using JetBrains.Annotations; | ||
|
||
using UnityEngine; | ||
|
||
using Verse; | ||
|
||
public class FloatMenuColonists : FloatMenu | ||
{ | ||
public FloatMenuColonists([NotNull] List<FloatMenuOption> options, [CanBeNull] string label) | ||
: base(options, label) | ||
{ | ||
this.givesColonistOrders = true; | ||
this.vanishIfMouseDistant = true; | ||
this.closeOnClickedOutside = true; | ||
} | ||
|
||
public override void DoWindowContents(Rect rect) | ||
{ | ||
this.options.Do( | ||
o => | ||
{ | ||
// FloatMenuOptionSorting option = o as FloatMenuOptionSorting; | ||
// option.Label = PathInfo.GetJobReport(option.sortBy); | ||
o.SetSizeMode(FloatMenuSizeMode.Normal); | ||
}); | ||
this.windowRect = new Rect(this.windowRect.x, this.windowRect.y, this.InitialSize.x, this.InitialSize.y); | ||
base.DoWindowContents(this.windowRect); | ||
} | ||
|
||
public override void PostClose() | ||
{ | ||
base.PostClose(); | ||
|
||
Tools.CloseLabelMenu(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
namespace Outfitter.TabPatch | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using UnityEngine; | ||
|
||
using Verse; | ||
|
||
public class FloatMenuLabels : FloatMenu | ||
{ | ||
public FloatMenuLabels(List<FloatMenuOption> options) | ||
: base(options, null) | ||
{ | ||
this.givesColonistOrders = false; | ||
this.vanishIfMouseDistant = true; | ||
this.closeOnClickedOutside = false; | ||
} | ||
} | ||
|
||
public class FloatMenuOptionNoClose : FloatMenuOption | ||
{ | ||
public FloatMenuOptionNoClose(string label, Action action) | ||
: base(label, action) | ||
{ | ||
} | ||
|
||
public override bool DoGUI(Rect rect, bool colonistOrdering) | ||
{ | ||
base.DoGUI(rect, colonistOrdering); | ||
return false; // don't close after an item is selected | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
namespace Outfitter.TabPatch | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
|
||
using RimWorld; | ||
|
||
using UnityEngine; | ||
|
||
using Verse; | ||
|
||
public static class ITab_Bills_Patch | ||
{ | ||
private static float viewHeight = 1000f; | ||
|
||
private static Vector2 scrollPosition = default(Vector2); | ||
|
||
private static readonly Vector2 WinSize = new Vector2(420f, 480f); | ||
|
||
private static Bill mouseoverBill; | ||
|
||
// RimWorld.ITab_Bills | ||
|
||
public static bool DoListing(BillStack __instance, ref Bill __result, Rect rect, Func<List<FloatMenuOption>> recipeOptionsMaker, ref Vector2 scrollPosition, ref float viewHeight) | ||
{ | ||
Bill result = null; | ||
GUI.BeginGroup(rect); | ||
Text.Font = GameFont.Small; | ||
if (__instance.Count < 15) | ||
{ | ||
Rect rect2 = new Rect(0f, 0f, 150f, 29f); | ||
if (Widgets.ButtonText(rect2, "AddBill".Translate(), true, false, true)) | ||
{ | ||
Find.WindowStack.Add(new FloatMenu(recipeOptionsMaker())); | ||
} | ||
UIHighlighter.HighlightOpportunity(rect2, "AddBill"); | ||
} | ||
Text.Anchor = TextAnchor.UpperLeft; | ||
GUI.color = Color.white; | ||
Rect outRect = new Rect(0f, 35f, rect.width, (float)(rect.height - 35.0)); | ||
Rect viewRect = new Rect(0f, 0f, (float)(outRect.width - 16.0), viewHeight); | ||
Widgets.BeginScrollView(outRect, ref scrollPosition, viewRect, true); | ||
float num = 0f; | ||
for (int i = 0; i < __instance.Count; i++) | ||
{ | ||
Bill bill = __instance.Bills[i]; | ||
|
||
Rect rect3 = bill.DoInterface(0f, num, viewRect.width, i); | ||
if (!bill.DeletedOrDereferenced && Mouse.IsOver(rect3)) | ||
{ | ||
result = bill; | ||
} | ||
num = (float)(num + (rect3.height + 6.0)); | ||
} | ||
if (Event.current.type == EventType.Layout) | ||
{ | ||
viewHeight = (float)(num + 60.0); | ||
} | ||
Widgets.EndScrollView(); | ||
GUI.EndGroup(); | ||
__result= result; | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
namespace Outfitter.TabPatch | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
using Harmony; | ||
|
||
using JetBrains.Annotations; | ||
|
||
using Verse; | ||
|
||
public static class Tools | ||
{ | ||
public static FloatMenuLabels LabelMenu; | ||
|
||
private static FloatMenuColonists actionMenu; | ||
|
||
public static void CloseLabelMenu(bool sound) | ||
{ | ||
if (LabelMenu != null) | ||
{ | ||
Find.WindowStack.TryRemove(LabelMenu, sound); | ||
LabelMenu = null; | ||
} | ||
} | ||
|
||
public static FloatMenuOption MakeMenuItemForLabel([NotNull] string label, [NotNull] List<FloatMenuOption> fmo) | ||
{ | ||
// List<SortByWhat> sortByWhats = fmo.Keys.ToList(); | ||
List<FloatMenuOption> options = fmo.ToList(); | ||
string labelFixed = label; | ||
FloatMenuOptionNoClose option = new FloatMenuOptionNoClose( | ||
labelFixed, | ||
() => | ||
{ | ||
if (options.Count() == 1 && options[0].Disabled == false) | ||
{ | ||
Action action = options[0].action; | ||
if (action != null) | ||
{ | ||
CloseLabelMenu(true); | ||
action(); | ||
} | ||
} | ||
else | ||
{ | ||
int i = 0; | ||
List<FloatMenuOption> actions = new List<FloatMenuOption>(); | ||
fmo.Do( | ||
menuOption => | ||
{ | ||
FloatMenuOption floatMenuOption = | ||
new FloatMenuOption( | ||
menuOption.Label, | ||
() => | ||
{ | ||
FloatMenuOption pawnOption = | ||
menuOption; | ||
actionMenu.Close(); | ||
CloseLabelMenu(true); | ||
pawnOption.action(); | ||
}, | ||
(MenuOptionPriority)i++, | ||
() => | ||
{ | ||
// PathInfo.current = pawn; | ||
}); | ||
actions.Add(floatMenuOption); | ||
}); | ||
actionMenu = new FloatMenuColonists(actions, null); | ||
Find.WindowStack.Add(actionMenu); | ||
} | ||
}) | ||
{ | ||
Disabled = options.All(o => o.Disabled) | ||
}; | ||
return option; | ||
} | ||
} | ||
} |