Skip to content

Commit

Permalink
Merge pull request #689 from zymex22/issue688
Browse files Browse the repository at this point in the history
#688 removed ITab_Bills2
  • Loading branch information
Sn1p3rr3c0n authored Mar 28, 2023
2 parents 19b656c + ccda0c5 commit defa9cb
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 209 deletions.
2 changes: 1 addition & 1 deletion Defs/ThingDefs_Buildings/Buildings_Miners.xml
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@
<drawPlaceWorkersWhileSelected>true</drawPlaceWorkersWhileSelected>
<inspectorTabs>
<li>ProjectRimFactory.Common.ITab_PowerSupply</li> <!-- Power boost -->
<li>ProjectRimFactory.AutoMachineTool.ITab_Bills2</li> <!-- AutomachineTool ITab not PRF -->
<li>ProjectRimFactory.SAL3.UI.ITab_SAL3Bills</li> <!-- ITab -->
</inspectorTabs>
<modExtensions>
<!-- <li Class="ProjectRimFactory.AutoMachineTool.ModExtension_EffectWorking">
Expand Down
7 changes: 2 additions & 5 deletions Source/ProjectRimFactory/AutoMachineTool/Building_MIner.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ProjectRimFactory.Common;
using ProjectRimFactory.SAL3.UI;
using RimWorld;
using System;
using System.Collections.Generic;
Expand All @@ -9,17 +10,13 @@

namespace ProjectRimFactory.AutoMachineTool
{
public class Building_Miner : Building_BaseMachine<Building_Miner>, IBillGiver, IRecipeProductWorker, ITabBillTable, IXMLThingDescription
public class Building_Miner : Building_BaseMachine<Building_Miner>, IBillGiver, IRecipeProductWorker, IXMLThingDescription, IBillTab
{

public BillStack BillStack => this.billStack;

public IEnumerable<IntVec3> IngredientStackCells => Enumerable.Empty<IntVec3>();

ThingDef ITabBillTable.def => this.def;

BillStack ITabBillTable.billStack => this.BillStack;

public IEnumerable<RecipeDef> AllRecipes => this.def.AllRecipes;

public IEnumerable<RecipeDef> GetAllRecipes()
Expand Down
183 changes: 0 additions & 183 deletions Source/ProjectRimFactory/AutoMachineTool/ITab_Bills2.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using HarmonyLib;
using ProjectRimFactory.SAL3.Things.Assemblers;
using ProjectRimFactory.SAL3.UI;
using RimWorld;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -112,10 +113,7 @@ static IEnumerable<CodeInstruction> Transpiler_IsWorkTable(IEnumerable<CodeInstr
/// <returns></returns>
public static bool IsValidBuilding(Building building)
{
var isworktable = (building as Building_WorkTable) != null;
var isRimfactory = ((building as ProjectRimFactory.AutoMachineTool.ITabBillTable) != null) || building is Building_DynamicBillGiver;

return isworktable || isRimfactory;
return (building as IBillTab) != null;
}

/// <summary>
Expand All @@ -127,10 +125,9 @@ public static BillStack GetBillstack(Building building)
{
Building_WorkTable building_WorkTable = building as Building_WorkTable;
if (building_WorkTable != null) return building_WorkTable.billStack;
ProjectRimFactory.AutoMachineTool.ITabBillTable tabBillTable = building as ProjectRimFactory.AutoMachineTool.ITabBillTable;
if (tabBillTable != null) return tabBillTable.billStack;
Building_DynamicBillGiver building_DynamicBillGiver = building as Building_DynamicBillGiver;
if (building_DynamicBillGiver != null) return building_DynamicBillGiver.BillStack;

IBillTab building_IBillTab = building as IBillTab;
if (building_IBillTab != null) return building_IBillTab.BillStack;

//This should never happen
Log.Error($"PRF Error GetBillstack returns null - {building}");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ProjectRimFactory.Common;
using ProjectRimFactory.SAL3.UI;
using RimWorld;
using System;
using System.Collections.Generic;
Expand All @@ -8,7 +9,7 @@
namespace ProjectRimFactory.SAL3.Things.Assemblers
{
[StaticConstructorOnStartup]
public abstract class Building_DynamicBillGiver : PRF_Building, IBillGiver
public abstract class Building_DynamicBillGiver : PRF_Building, IBillGiver, IBillTab
{
public abstract BillStack BillStack { get; }

Expand Down
31 changes: 20 additions & 11 deletions Source/ProjectRimFactory/SAL3/UI/ITab_SAL3Bills.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@

namespace ProjectRimFactory.SAL3.UI
{
public interface IBillTab
{
BillStack BillStack { get; }
Map Map { get; }
IEnumerable<RecipeDef> GetAllRecipes();
IntVec3 Position { get; }
}


[StaticConstructorOnStartup]
public class ITab_SAL3Bills : ITab
{
Expand All @@ -28,11 +37,11 @@ public class ITab_SAL3Bills : ITab

public static readonly FieldInfo PasteSizeField = typeof(ITab_Bills).GetField("PasteSize", BindingFlags.NonPublic | BindingFlags.Static);

protected Building_DynamicBillGiver SelAssembler
protected IBillTab SelBuilding
{
get
{
return (Building_DynamicBillGiver)SelThing;
return (IBillTab)SelThing;
}
}

Expand All @@ -42,7 +51,7 @@ public ITab_SAL3Bills()
labelKey = "SAL3_BillsTabLabel";
}

public override bool IsVisible => SelThing is Building_DynamicBillGiver;
public override bool IsVisible => SelThing is IBillTab;

protected override void FillTab()
{
Expand All @@ -58,14 +67,14 @@ protected override void FillTab()
GUI.color = Color.white;
TooltipHandler.TipRegion(rect, "PasteBillTip".Translate());
}
else if (!SelAssembler.GetAllRecipes().Contains(BillUtility.Clipboard.recipe) || !BillUtility.Clipboard.recipe.AvailableNow)
else if (!SelBuilding.GetAllRecipes().Contains(BillUtility.Clipboard.recipe) || !BillUtility.Clipboard.recipe.AvailableNow)
{
GUI.color = Color.gray;
Widgets.DrawTextureFitted(rect, Textures.Paste, 1f);
GUI.color = Color.white;
TooltipHandler.TipRegion(rect, "ClipboardBillNotAvailableHere".Translate());
}
else if (SelAssembler.BillStack.Count >= 15)
else if (SelBuilding.BillStack.Count >= 15)
{
GUI.color = Color.gray;
Widgets.DrawTextureFitted(rect, Textures.Paste, 1f);
Expand All @@ -78,7 +87,7 @@ protected override void FillTab()
{
Bill bill = BillUtility.Clipboard.Clone();
bill.InitializeAfterClone();
SelAssembler.BillStack.AddBill(bill);
SelBuilding.BillStack.AddBill(bill);
SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
}
TooltipHandler.TipRegion(rect, "PasteBillTip".Translate());
Expand All @@ -87,18 +96,18 @@ protected override void FillTab()
Func<List<FloatMenuOption>> recipeOptionsMaker = delegate ()
{
List<FloatMenuOption> list = new List<FloatMenuOption>();
foreach (RecipeDef recipe in SelAssembler.GetAllRecipes())
foreach (RecipeDef recipe in SelBuilding.GetAllRecipes())
{
if (recipe.AvailableNow)
{
list.Add(new FloatMenuOption(recipe.LabelCap, delegate ()
{
if (!SelAssembler.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
if (!SelBuilding.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
{
Bill.CreateNoPawnsWithSkillDialog(recipe);
}
Bill bill2 = recipe.MakeNewBill();
SelAssembler.BillStack.AddBill(bill2);
SelBuilding.BillStack.AddBill(bill2);
if (recipe.conceptLearned != null)
{
PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
Expand All @@ -112,7 +121,7 @@ protected override void FillTab()
}
return list;
};
mouseoverBill = SelAssembler.BillStack.DoListing(rect2, recipeOptionsMaker, ref scrollPosition, ref viewHeight);
mouseoverBill = SelBuilding.BillStack.DoListing(rect2, recipeOptionsMaker, ref scrollPosition, ref viewHeight);
//
//Rect rect = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f);
//Func<List<FloatMenuOption>> recipeOptionsMaker = delegate
Expand Down Expand Up @@ -142,7 +151,7 @@ public override void TabUpdate()
{
if (mouseoverBill != null)
{
mouseoverBill.TryDrawIngredientSearchRadiusOnMap(SelAssembler.Position);
mouseoverBill.TryDrawIngredientSearchRadiusOnMap(SelBuilding.Position);
mouseoverBill = null;
}
}
Expand Down

0 comments on commit defa9cb

Please sign in to comment.