Skip to content

Commit

Permalink
Merge pull request #11 from NoImageAvailable/fluffy-pr-merge
Browse files Browse the repository at this point in the history
Fluffy pr merge
  • Loading branch information
NoImageAvailable committed Apr 26, 2016
2 parents dd81a7a + 9ddcacb commit 22860de
Show file tree
Hide file tree
Showing 14 changed files with 341 additions and 205 deletions.
1 change: 1 addition & 0 deletions Defs/ThingDefs/Races_Mechanoid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<li>ITab_Pawn_Gear</li>
<li>ITab_Pawn_Guest</li>
<li>ITab_Pawn_Prisoner</li>
<li>ITab_Pawn_Social</li>
</inspectorTabs>
<comps>
<li>
Expand Down
6 changes: 4 additions & 2 deletions Languages/English/Keyed/BulkAndWeight.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
<CR.Bulk>Bulk</CR.Bulk>
<CR.outfit>outfit</CR.outfit>
<CR.loadout>loadout</CR.loadout>
<CR.ITabWeightTip>Current weight: {1}\nCapacity: {0}\n\nMove speed factor: {2}\nEncumbrance penalty: {3}</CR.ITabWeightTip>
<CR.ITabBulkTip>Current bulk: {1}\nCapacity: {0}\n\nWork speed factor: {2}</CR.ITabBulkTip>
<CR.DetailedWeightTip>Current weight: {1}\nCapacity: {0}\n\nMove speed factor: {2}\nEncumbrance penalty: {3}</CR.DetailedWeightTip>
<CR.DetailedBulkTip>Current bulk: {1}\nCapacity: {0}\n\nWork speed factor: {2}</CR.DetailedBulkTip>
<CR.DetailedBaseWeightTip>Current weight: {1}\nBase capacity: {0}\n\nMove speed factor: {2}\nEncumbrance penalty: {3}</CR.DetailedBaseWeightTip>
<CR.DetailedBaseBulkTip>Current bulk: {1}\nBase capacity: {0}\n\nWork speed factor: {2}</CR.DetailedBaseBulkTip>
<CR.EmptyLoadoutName>Nothing</CR.EmptyLoadoutName>
<CR.SelectLoadout>Select loadout...</CR.SelectLoadout>
<CR.NewLoadout>New loadout</CR.NewLoadout>
Expand Down
24 changes: 12 additions & 12 deletions Source/CombatRealism/Combat_Realism.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\..\..\Documents\Visual Studio 2013\Source-DLLs\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\..\..\RimWorld1135Win_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Community Core Library">
<HintPath>..\..\..\..\..\..\Documents\Visual Studio 2013\Source-DLLs\Community Core Library.dll</HintPath>
<HintPath>..\..\..\Community Core Library\Assemblies\Community Core Library.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
Expand All @@ -63,7 +63,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>..\..\..\..\..\..\Documents\Visual Studio 2013\Source-DLLs\UnityEngine.dll</HintPath>
<HintPath>..\..\..\..\RimWorld1135Win_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
Expand All @@ -74,24 +74,24 @@
<Compile Include="Combat_Realism\Defs\DamageDef_CR.cs" />
<Compile Include="Combat_Realism\Defs\LoadoutGeneratorDef.cs" />
<Compile Include="Combat_Realism\Jobs\JobGiver_UpdateLoadout.cs" />
<Compile Include="Combat_Realism\LoadoutAssignment.cs" />
<Compile Include="Combat_Realism\Loadouts\LoadoutAssignment.cs" />
<Compile Include="Combat_Realism\Things\AmmoThing.cs" />
<Compile Include="Combat_Realism\Things\Apparel_Backpack.cs" />
<Compile Include="Combat_Realism\Things\Apparel_TacVest.cs" />
<Compile Include="Combat_Realism\Things\LoadoutGeneratorThing.cs" />
<Compile Include="Combat_Realism\Dialog_ManageLoadouts.cs" />
<Compile Include="Combat_Realism\Loadouts\Dialog_ManageLoadouts.cs" />
<Compile Include="Combat_Realism\Gizmos\Command_Reload.cs" />
<Compile Include="Combat_Realism\ITabInjector.cs" />
<Compile Include="Combat_Realism\ITab_Inventory.cs" />
<Compile Include="Combat_Realism\Loadout.cs" />
<Compile Include="Combat_Realism\Loadouts\ITabInjector.cs" />
<Compile Include="Combat_Realism\Loadouts\ITab_Inventory.cs" />
<Compile Include="Combat_Realism\Loadouts\Loadout.cs" />
<Compile Include="Combat_Realism\LoadoutGen\LoadoutGenerator.cs" />
<Compile Include="Combat_Realism\LoadoutGen\LoadoutGenerator_AmmoPrimary.cs" />
<Compile Include="Combat_Realism\LoadoutGen\LoadoutGenerator_AmmoSecondary.cs" />
<Compile Include="Combat_Realism\LoadoutGen\LoadoutGenerator_WeaponByTag.cs" />
<Compile Include="Combat_Realism\LoadoutGen\LoadoutGenerator_List.cs" />
<Compile Include="Combat_Realism\LoadoutSlot.cs" />
<Compile Include="Combat_Realism\MainTabWindow_OutfitsAndLoadouts.cs" />
<Compile Include="Combat_Realism\MapComp_LoadoutManager.cs" />
<Compile Include="Combat_Realism\Loadouts\LoadoutSlot.cs" />
<Compile Include="Combat_Realism\Loadouts\MainTabWindow_OutfitsAndLoadouts.cs" />
<Compile Include="Combat_Realism\Loadouts\MapComp_LoadoutManager.cs" />
<Compile Include="Combat_Realism\Things\Apparel_VisibleAccessory.cs" />
<Compile Include="Combat_Realism\Things\IncendiaryFuel.cs" />
<Compile Include="Combat_Realism\Things\Plant_Blazebulb.cs" />
Expand All @@ -109,7 +109,7 @@
<Compile Include="Combat_Realism\Comps\CompProperties_Charges.cs" />
<Compile Include="Combat_Realism\DamageWorkers\DamageWorker_AddInjuryCR.cs" />
<Compile Include="Combat_Realism\Defs\AmmoCategoryDef.cs" />
<Compile Include="Combat_Realism\Utility_Loadouts.cs" />
<Compile Include="Combat_Realism\Loadouts\Utility_Loadouts.cs" />
<Compile Include="Detours\DetourInjector.cs" />
<Compile Include="Combat_Realism\FireMode.cs" />
<Compile Include="Combat_Realism\Projectiles\BulletCR.cs" />
Expand Down
37 changes: 0 additions & 37 deletions Source/CombatRealism/Combat_Realism/ITabInjector.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ public override void DoWindowContents( Rect canvas )
// bars
if ( CurrentLoadout != null )
{
Utility_Loadouts.DrawBar( weightBarRect, CurrentLoadout.Weight, StatDef.Named( "CarryWeight" ).defaultBaseValue, "CR.Weight".Translate() );
Utility_Loadouts.DrawBar( bulkBarRect, CurrentLoadout.Bulk, StatDef.Named( "CarryBulk" ).defaultBaseValue, "CR.Bulk".Translate() );
Utility_Loadouts.DrawBar( weightBarRect, CurrentLoadout.Weight, StatDef.Named( "CarryWeight" ).defaultBaseValue, "CR.Weight".Translate(), CurrentLoadout.GetWeightTip() );
Utility_Loadouts.DrawBar( bulkBarRect, CurrentLoadout.Bulk, StatDef.Named( "CarryBulk" ).defaultBaseValue, "CR.Bulk".Translate(), CurrentLoadout.GetBulkTip() );
}

// done!
Expand Down Expand Up @@ -399,7 +399,7 @@ private void DrawSlot( Rect row, LoadoutSlot slot, bool slotDraggable = true )
if ( !Mouse.IsOver( deleteRect ) )
{
Widgets.DrawHighlightIfMouseover( row );
TooltipHandler.TipRegion( row, slot.Def.LabelCap );
TooltipHandler.TipRegion( row, slot.Def.GetWeightAndBulkTip( slot.Count ) );
}

// label
Expand Down Expand Up @@ -543,6 +543,7 @@ private void DrawSlotSelection( Rect canvas )
{
Rect row = new Rect( 0f, i * _rowHeight, canvas.width, _rowHeight );
Rect labelRect = new Rect( row );
TooltipHandler.TipRegion( row, _source[i].GetWeightAndBulkTip() );

labelRect.xMin += _margin;
if ( i % 2 == 0 )
Expand Down
53 changes: 53 additions & 0 deletions Source/CombatRealism/Combat_Realism/Loadouts/ITabInjector.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using CommunityCoreLibrary;
using RimWorld;
using Verse;

namespace Combat_Realism
{
public class ITabInjector : SpecialInjector
{
#region Methods

public override bool Inject()
{
// get reference to lists of itabs
var itabs = ThingDefOf.Human.inspectorTabs;
var itabsResolved = ThingDefOf.Human.inspectorTabsResolved;

#if DEBUG
Log.Message( "Inspector tab types on humans:" );
foreach ( var tab in itabs )
{
Log.Message( "\t" + tab.Name );
}
Log.Message( "Resolved tab instances on humans:" );
foreach ( var tab in itabsResolved )
{
Log.Message( "\t" + tab.labelKey.Translate() );
}
#endif

// replace ITab in the unresolved list
var index = itabs.IndexOf( typeof( ITab_Pawn_Gear ) );
if ( index != -1 )
{
itabs.Remove( typeof( ITab_Pawn_Gear ) );
itabs.Insert( index, typeof( ITab_Inventory ) );
}

// replace resolved ITab, if needed.
var oldGearTab = ITabManager.GetSharedInstance( typeof( ITab_Pawn_Gear ) );
var newGearTab = ITabManager.GetSharedInstance( typeof( ITab_Inventory ) );
if ( !itabsResolved.NullOrEmpty() && itabsResolved.Contains( oldGearTab ) )
{
int resolvedIndex = itabsResolved.IndexOf( oldGearTab );
itabsResolved.Insert( resolvedIndex, newGearTab );
itabsResolved.Remove( oldGearTab );
}

return true;
}

#endregion Methods
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ protected override void FillTab()
Rect weightRect = new Rect( _margin, listRect.yMax + _margin, listRect.width, _barHeight );
Rect bulkRect = new Rect( _margin, weightRect.yMax + _margin, listRect.width, _barHeight );

Utility_Loadouts.DrawBar( bulkRect, comp.currentBulk, comp.capacityBulk, "CR.Bulk".Translate(), "CR.ITabBulkTip".Translate( comp.capacityBulk, comp.currentBulk, comp.workSpeedFactor ) );
Utility_Loadouts.DrawBar( weightRect, comp.currentWeight, comp.capacityWeight, "CR.Weight".Translate(), "CR.ITabWeightTip".Translate( comp.capacityWeight, comp.currentWeight, comp.moveSpeedFactor, comp.encumberPenalty ) );
Utility_Loadouts.DrawBar( bulkRect, comp.currentBulk, comp.capacityBulk, "CR.Bulk".Translate(), SelPawn.GetBulkTip() );
Utility_Loadouts.DrawBar( weightRect, comp.currentWeight, comp.capacityWeight, "CR.Weight".Translate(), SelPawn.GetWeightTip() );
}

// start drawing list (rip from ITab_Pawn_Gear)
Expand Down Expand Up @@ -135,6 +135,7 @@ orderby ap.def.apparel.bodyPartGroups[0].listOrder descending
private void DrawThingRow( ref float y, float width, Thing thing )
{
Rect rect = new Rect( 0f, y, width, 28f );
TooltipHandler.TipRegion( rect, thing.GetWeightAndBulkTip() );
if ( Mouse.IsOver( rect ) )
{
GUI.color = _highlightColor;
Expand All @@ -151,46 +152,46 @@ private void DrawThingRow( ref float y, float width, Thing thing )
{
// Equip option
ThingWithComps eq = thing as ThingWithComps;
if (eq != null && eq.TryGetComp<CompEquippable>() != null)
if ( eq != null && eq.TryGetComp<CompEquippable>() != null )
{
CompInventory compInventory = SelPawnForGear.TryGetComp<CompInventory>();
if (compInventory != null)
if ( compInventory != null )
{
FloatMenuOption equipOption;
string eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1);
if (SelPawnForGear.equipment.AllEquipment.Contains(eq) && SelPawnForGear.inventory != null)
string eqLabel = GenLabel.ThingLabel( eq.def, eq.Stuff, 1 );
if ( SelPawnForGear.equipment.AllEquipment.Contains( eq ) && SelPawnForGear.inventory != null )
{
equipOption = new FloatMenuOption("CR_PutAway".Translate(new object[] { eqLabel }),
new Action(delegate
{
ThingWithComps oldEq;
SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.container, out oldEq);
}));
equipOption = new FloatMenuOption( "CR_PutAway".Translate( new object[] { eqLabel } ),
new Action( delegate
{
ThingWithComps oldEq;
SelPawnForGear.equipment.TryTransferEquipmentToContainer( SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.container, out oldEq );
} ) );
}
else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
else if ( !SelPawnForGear.health.capacities.CapableOf( PawnCapacityDefOf.Manipulation ) )
{
equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }), null);
equipOption = new FloatMenuOption( "CannotEquip".Translate( new object[] { eqLabel } ), null );
}
else
{
string equipOptionLabel = "Equip".Translate(new object[] { eqLabel });
if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler))
string equipOptionLabel = "Equip".Translate( new object[] { eqLabel } );
if ( eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait( TraitDefOf.Brawler ) )
{
equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate();
}
equipOption = new FloatMenuOption(equipOptionLabel, new Action(delegate
{
compInventory.TrySwitchToWeapon(eq);
}));
equipOption = new FloatMenuOption( equipOptionLabel, new Action( delegate
{
compInventory.TrySwitchToWeapon( eq );
} ) );
}
floatOptionList.Add(equipOption);
floatOptionList.Add( equipOption );
}
}

// Drop option
Action action = null;
Apparel ap = thing as Apparel;
if ( ap != null && SelPawnForGear.apparel.WornApparel.Contains(ap))
if ( ap != null && SelPawnForGear.apparel.WornApparel.Contains( ap ) )
{
Apparel unused;
action = delegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ public class LoadoutAssignment : IExposable

#endregion Fields

public bool Valid
{
get
{
return pawn != null && loadout != null;
}
}

#region Methods

public void ExposeData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ protected override void DrawPawnRow( Rect rect, Pawn p )

if ( comp != null )
{
Utility_Loadouts.DrawBar( bulkRect, comp.currentBulk, comp.capacityBulk, "", "CR.ITabBulkTip".Translate( comp.capacityBulk, comp.currentBulk, comp.workSpeedFactor ) );
Utility_Loadouts.DrawBar( weightRect, comp.currentWeight, comp.capacityWeight, "", "CR.ITabWeightTip".Translate( comp.capacityWeight, comp.currentWeight, comp.moveSpeedFactor, comp.encumberPenalty ) );
Utility_Loadouts.DrawBar( bulkRect, comp.currentBulk, comp.capacityBulk, "", p.GetBulkTip() );
Utility_Loadouts.DrawBar( weightRect, comp.currentWeight, comp.capacityWeight, "", p.GetWeightTip() );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ public override void ExposeData()

// convert back into useable dictionary
if ( Scribe.mode == LoadSaveMode.PostLoadInit )
Instance._assignedLoadouts = Instance._assignedLoadoutsScribeHelper.ToDictionary( k => k.pawn, v => v.loadout );
Instance._assignedLoadouts = Instance
._assignedLoadoutsScribeHelper
.Where( a => a.Valid ) // removes assignments that for some reason have a null value.
.ToDictionary( k => k.pawn, v => v.loadout );
}

internal static int GetUniqueID()
Expand Down
Loading

0 comments on commit 22860de

Please sign in to comment.