Skip to content

Commit

Permalink
B18
Browse files Browse the repository at this point in the history
  • Loading branch information
Killface1980 committed Nov 19, 2017
1 parent e31df8c commit b947eab
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 12 deletions.
2 changes: 1 addition & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ModMetaData>
<name>Outfitter A18</name>
<name>Outfitter 0.18.0</name>
<author>Killface</author>
<url></url>
<targetVersion>0.18.0</targetVersion>
Expand Down
Binary file modified Assemblies/Outfitter.dll
Binary file not shown.
3 changes: 2 additions & 1 deletion Languages/English/Keyed/Outfitter_Keyed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
<EquipmentAndInventory>Equipment and Inventory</EquipmentAndInventory>
<WornApparel>Worn Apparel</WornApparel>
<AddWorkStats>Add Work Stats</AddWorkStats>
<AddIndividualStats>Add Individual Stats</AddIndividualStats>
<AddIndividualStats><![CDATA[Add Individual Stats (traits & incidents)]]></AddIndividualStats>
<AddPersonalStats>Add Personal Stats (skills)</AddPersonalStats>
<DropThingHaul>Drop and Haul</DropThingHaul>
<MainJob>Set Prefered Gear</MainJob>
<PreferedGear>Prefered Gear:</PreferedGear>
Expand Down
14 changes: 9 additions & 5 deletions Source/Outfitter/HarmonyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@ static HarmonyPatches()
null,
new HarmonyMethod(typeof(HarmonyPatches), nameof(UpdatePriorities)));

harmony.Patch(
AccessTools.Method(typeof(BillStack), nameof(BillStack.DoListing)),
new HarmonyMethod(typeof(ITab_Bills_Patch), nameof(ITab_Bills_Patch.DoListing)),
null);

// harmony.Patch(
// AccessTools.Method(typeof(ITab_Bills), "FillTab"),
// new HarmonyMethod(typeof(ITab_Bills_Patch), nameof(ITab_Bills_Patch.FillTab_Prefix)),
// null);
//
// harmony.Patch(
// AccessTools.Method(typeof(ITab_Bills), "TabUpdate"),
// new HarmonyMethod(typeof(ITab_Bills_Patch), nameof(ITab_Bills_Patch.TabUpdate_Prefix)),
// null);

// harmony.Patch(
// AccessTools.Method(typeof(ThinkNode_JobGiver), nameof(ThinkNode_JobGiver.TryIssueJobPackage)),
Expand Down
2 changes: 1 addition & 1 deletion Source/Outfitter/Outfitter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<Compile Include="TabPatch\Tools.cs" />
<Compile Include="TabPatch\FloatMenuColonists.cs" />
<Compile Include="TabPatch\FloatMenuLabels.cs" />
<Compile Include="TabPatch\ITab_Bills_Patch.cs" />
<None Include="TabPatch\ITab_Bills_Patch.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="GameComponent_Outfitter.cs" />
<Compile Include="MainJob.cs" />
Expand Down
130 changes: 126 additions & 4 deletions Source/Outfitter/TabPatch/ITab_Bills_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

using RimWorld;

Expand All @@ -23,7 +22,111 @@ public static class ITab_Bills_Patch

// RimWorld.ITab_Bills

public static bool DoListing(BillStack __instance, ref Bill __result, Rect rect, Func<List<FloatMenuOption>> recipeOptionsMaker, ref Vector2 scrollPosition, ref float viewHeight)
public static bool FillTab_Prefix()
{
Building_WorkTable selTable = (Building_WorkTable)Find.Selector.SingleSelectedThing;
if (selTable.def != ThingDef.Named("HandTailoringBench")
|| selTable.def != ThingDef.Named("ElectricTailoringBench"))
{
return true;
}
PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed);
float x = WinSize.x;
Vector2 winSize2 = WinSize;
Rect rect2 = new Rect(0f, 0f, x, winSize2.y).ContractedBy(10f);
Func<List<FloatMenuOption>> recipeOptionsMaker = delegate
{
List<FloatMenuOption> list = new List<FloatMenuOption>();
for (int i = 0; i < selTable.def.AllRecipes.Count; i++)
{
if (selTable.def.AllRecipes[i].AvailableNow)
{
RecipeDef recipe = selTable.def.AllRecipes[i];
// Outfitter jump in here
{
for (int j = 0; j < recipe.products.Count; j++)
{
ThingCountClass rec = recipe.products[i];
for (int k = 0; k < rec.thingDef.apparel.bodyPartGroups.Count; k++)
{
list.Add(new FloatMenuOption(rec.thingDef.apparel.bodyPartGroups[k].label, null));

}

}
}
// Outfitter end
list.Add(
new FloatMenuOption(
recipe.LabelCap,
delegate
{
if (!selTable.Map.mapPawns.FreeColonists.Any(
col => recipe.PawnSatisfiesSkillRequirements(col)))
{
Bill.CreateNoPawnsWithSkillDialog(recipe);
}

Bill bill = recipe.MakeNewBill();
selTable.billStack.AddBill(bill);
if (recipe.conceptLearned != null)
{
PlayerKnowledgeDatabase.KnowledgeDemonstrated(
recipe.conceptLearned,
KnowledgeAmount.Total);
}

if (TutorSystem.TutorialMode)
{
TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap);
}
},
MenuOptionPriority.Default,
null,
null,
29f,
rect => Widgets.InfoCardButton(
(float)(rect.x + 5.0),
(float)(rect.y + (rect.height - 24.0) / 2.0),
recipe)));
}
}

if (!list.Any())
{
list.Add(
new FloatMenuOption(
"NoneBrackets".Translate(),
null));
}

return list;
};

mouseoverBill = DoListing(selTable.BillStack, rect2, recipeOptionsMaker, ref scrollPosition, ref viewHeight);

return false;

}

public static bool TabUpdate_Prefix()
{
Building_WorkTable selTable = (Building_WorkTable)Find.Selector.SingleSelectedThing;
if (selTable.def != ThingDef.Named("HandTailoringBench")
|| selTable.def != ThingDef.Named("ElectricTailoringBench"))
{
return true;
}

if (mouseoverBill != null)
{
mouseoverBill.TryDrawIngredientSearchRadiusOnMap(Find.Selector.SingleSelectedThing.Position);
mouseoverBill = null;
}
return false;
}

public static Bill DoListing(BillStack __instance, Rect rect, Func<List<FloatMenuOption>> recipeOptionsMaker, ref Vector2 scrollPosition, ref float viewHeight)
{
Bill result = null;
GUI.BeginGroup(rect);
Expand All @@ -33,6 +136,25 @@ public static bool DoListing(BillStack __instance, ref Bill __result, Rect rect,
Rect rect2 = new Rect(0f, 0f, 150f, 29f);
if (Widgets.ButtonText(rect2, "AddBill".Translate(), true, false, true))
{
// Outfitter Code

// for (int i = 0; i < __instance.Bills.Count; i++)
// {
// Bill bill = __instance.Bills[i];
// bill
// }
//
// List<FloatMenuOption> items = labeledSortingActions.Keys.Select(
// label =>
// {
// List<FloatMenuOption> fmo = labeledSortingActions[label];
// return Tools.MakeMenuItemForLabel(label, fmo);
// }).ToList();
//
// Tools.LabelMenu = new FloatMenuLabels(items);
// Find.WindowStack.Add(Tools.LabelMenu);

// Vanilla
Find.WindowStack.Add(new FloatMenu(recipeOptionsMaker()));
}
UIHighlighter.HighlightOpportunity(rect2, "AddBill");
Expand Down Expand Up @@ -60,8 +182,8 @@ public static bool DoListing(BillStack __instance, ref Bill __result, Rect rect,
}
Widgets.EndScrollView();
GUI.EndGroup();
__result= result;
return false;
return result;
}

}
}

0 comments on commit b947eab

Please sign in to comment.