Skip to content

Commit

Permalink
Merge pull request #37 from Aviuz/2.7.3
Browse files Browse the repository at this point in the history
2.7.3 release candidate
  • Loading branch information
Hazzer authored Nov 3, 2021
2 parents ac06791 + b611b30 commit 6a36daa
Show file tree
Hide file tree
Showing 13 changed files with 250 additions and 69 deletions.
Binary file modified 1.3/Assemblies/Locks.dll
Binary file not shown.
26 changes: 26 additions & 0 deletions 1.3/Patches/AddCompLockSoS2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<Patch>
<Operation Class="PatchOperationFindMod">
<mods>
<li>Save Our Ship 2</li>
</mods>
<match Class="PatchOperationConditional">
<xpath>/Defs/ThingDef[thingClass = "Building_ShipAirlock"]/comps</xpath>
<nomatch Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[thingClass = "Building_ShipAirlock"]</xpath>
<value>
<comps>
<li Class="Locks.CompProperties_Lock"/>
</comps>
</value>
</nomatch>
<match Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[thingClass = "Building_ShipAirlock"]/comps</xpath>
<value>
<li Class="Locks.CompProperties_Lock"/>
</value>
</match>
</match>
</Operation>

</Patch>
26 changes: 26 additions & 0 deletions 1.3/Patches/AddInspectTabSoS2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<Patch>
<Operation Class="PatchOperationFindMod">
<mods>
<li>Save Our Ship 2</li>
</mods>
<match Class="PatchOperationConditional">
<xpath>/Defs/ThingDef[thingClass = "Building_ShipAirlock"]/inspectorTabs</xpath>
<nomatch Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[thingClass = "Building_ShipAirlock"]</xpath>
<value>
<inspectorTabs>
<li>Locks.ITab_Lock</li>
</inspectorTabs>
</value>
</nomatch>
<match Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[thingClass = "Building_ShipAirlock"]/inspectorTabs</xpath>
<value>
<li>Locks.ITab_Lock</li>
</value>
</match>
</match>
</Operation>

</Patch>
6 changes: 5 additions & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<packageId>avius.locks</packageId>
<loadAfter>
<li>brrainz.harmony</li>
<li>haplo.miscellaneous.robots</li>
<li>kentington.saveourship2</li>
<li>linkolas.linkabledoors</li>
<li>jecrell.doorsexpanded</li>
</loadAfter>
<modDependencies>
<li>
Expand All @@ -20,5 +24,5 @@
<downloadUrl>https://github.com/pardeike/HarmonyRimWorld/releases/latest</downloadUrl>
</li>
</modDependencies>
<description>Version 2.7.2\nThis addon adds Lock command on every door.\n - Left-click to lock toggle.\n - Right click for more options\n - Alternatively you can use "Lock" inspector tab\n\nNote: Door lock must be flicked by colonist.</description>
<description>Version 2.7.3\nThis addon adds Lock command on every door.\n - Left-click to lock toggle.\n - Right click for more options\n - Alternatively you can use "Lock" inspector tab\n\nNote: Door lock must be flicked by colonist.</description>
</ModMetaData>
75 changes: 40 additions & 35 deletions Languages/English/Keyed/Keys.xml
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
<?xml version="1.0" encoding="utf-8" ?>
<LanguageData>
<Locks_Label>Lock</Locks_Label>
<Locks_Description>When unlocked all pawn will be allowed to use this door.\n[Right click for more options]</Locks_Description>
<Locks_Label>Lock</Locks_Label>
<Locks_Description>When unlocked all pawn will be allowed to use this door.\n[Right click for more options]</Locks_Description>

<Locks_StatePrefix>Door</Locks_StatePrefix>
<Locks_StateLocked>locked</Locks_StateLocked>
<Locks_StateUnlocked>unlocked</Locks_StateUnlocked>
<Locks_StateChanging>changing...</Locks_StateChanging>
<Locks_StatePrefix>Door</Locks_StatePrefix>
<Locks_StateLocked>locked</Locks_StateLocked>
<Locks_StateUnlocked>unlocked</Locks_StateUnlocked>
<Locks_StateChanging>changing...</Locks_StateChanging>

<Locks_ITabLocked>Locked</Locks_ITabLocked>
<Locks_ITabLockedDesc>When unlocked door settings do not apply, therefore all humanoids capable of opening doors can pass.</Locks_ITabLockedDesc>
<Locks_ITabVisitorsAllowed>Visitors allowed</Locks_ITabVisitorsAllowed>
<Locks_ITabVisitorsAllowedDesc>When disabled, allies and traders will not be allowed to pass through this door. This setting do not apply when owners are set.</Locks_ITabVisitorsAllowedDesc>
<Locks_ITabPetDoor>Pet door</Locks_ITabPetDoor>
<Locks_ITabPetDoorDesc>When enabled small animals, like dogs can pass through door. This setting is not required for doors without owners.</Locks_ITabPetDoorDesc>
<Locks_ITabPensDoor>Pens door</Locks_ITabPensDoor>
<Locks_ITabPensDoorDesc>When enabled, pens animals can't pass through the door. Some doors may not block animals (e.g. Animal Flap). Check "roamerCanOpen" in defs.</Locks_ITabPensDoorDesc>
<Locks_ITabOwners>Owners</Locks_ITabOwners>
<Locks_ITabChangeLocksNotification>Change lock in order to apply settings!</Locks_ITabChangeLocksNotification>

<Locks_LockToggle>Lock</Locks_LockToggle>
<Locks_UnlockToggle>Unlock</Locks_UnlockToggle>
<Locks_AllowVisitors>Allow visitors to use</Locks_AllowVisitors>
<Locks_ForbidVisitors>Forbid visitors from using</Locks_ForbidVisitors>
<Locks_AddPetDoor>Add pet door</Locks_AddPetDoor>
<Locks_RemovePetDoor>Remove pet door</Locks_RemovePetDoor>
<Locks_AddPensDoor>Set as pens door</Locks_AddPensDoor>
<Locks_RemovePensDoor>Remove pens door</Locks_RemovePensDoor>
<Locks_SetOwners>Set owners</Locks_SetOwners>
<Locks_ClearOwners>Clear owners</Locks_ClearOwners>

<Locks_FailOnWrongUser>Lock does not belong to {0}</Locks_FailOnWrongUser>
<Locks_ITabLocked>Locked</Locks_ITabLocked>
<Locks_ITabLockedDesc>When unlocked door settings do not apply, therefore all humanoids capable of opening doors can pass.</Locks_ITabLockedDesc>
<Locks_ITabVisitorsAllowed>Visitors allowed</Locks_ITabVisitorsAllowed>
<Locks_ITabVisitorsAllowedDesc>When disabled, allies and traders will not be allowed to pass through this door. This setting do not apply when owners are set.</Locks_ITabVisitorsAllowedDesc>
<Locks_ITabPetDoor>Pet door</Locks_ITabPetDoor>
<Locks_ITabPetDoorDesc>When enabled small animals, like dogs can pass through door. This setting is not required for doors without owners.</Locks_ITabPetDoorDesc>
<Locks_ITabPensDoor>Pens door</Locks_ITabPensDoor>
<Locks_ITabPensDoorDesc>When enabled, pens animals can't pass through the door. Some doors may not block animals (e.g. Animal Flap). Check "roamerCanOpen" in defs.</Locks_ITabPensDoorDesc>
<Locks_ITabSlaveDoors>Slaves allowed</Locks_ITabSlaveDoors>
<Locks_ITabSlaveDoorsDesc>When disabled slaves are not allowed to pass through this door. This setting do not apply when owners are set.</Locks_ITabSlaveDoorsDesc>
<Locks_ITabAnimalAllowed>Animals allowed</Locks_ITabAnimalAllowed>
<Locks_ITabAnimalAllowedDesc>When disabled all animals will not be allowed to pass through this door. This setting is checked after pens and pet door settings.</Locks_ITabAnimalAllowedDesc>

<Locks_AlertLocksCantBeChanged>Locks can't be changed</Locks_AlertLocksCantBeChanged>
<Locks_AlertLocksCantBeChangedDesc>Some locks can't be changed, because owners of those locks do not perform flick jobs:\n\n{0}</Locks_AlertLocksCantBeChangedDesc>
<Locks_AlertLocksCantBeChangedDefaultDesc>Some locks can't be changed, because owners of those locks do not perform flick jobs.</Locks_AlertLocksCantBeChangedDefaultDesc>
<Locks_ITabOwners>Owners</Locks_ITabOwners>
<Locks_ITabChangeLocksNotification>Change lock in order to apply settings!</Locks_ITabChangeLocksNotification>

<Locks_Cancel>Cancel</Locks_Cancel>
<Locks_Copy>Copy</Locks_Copy>
<Locks_Paste>Paste</Locks_Paste>
<Locks_LockToggle>Lock</Locks_LockToggle>
<Locks_UnlockToggle>Unlock</Locks_UnlockToggle>
<Locks_AllowVisitors>Allow visitors to use</Locks_AllowVisitors>
<Locks_ForbidVisitors>Forbid visitors from using</Locks_ForbidVisitors>
<Locks_AddPetDoor>Add pet door</Locks_AddPetDoor>
<Locks_RemovePetDoor>Remove pet door</Locks_RemovePetDoor>
<Locks_AddPensDoor>Set as pens door</Locks_AddPensDoor>
<Locks_RemovePensDoor>Remove pens door</Locks_RemovePensDoor>
<Locks_SetOwners>Set owners</Locks_SetOwners>
<Locks_ClearOwners>Clear owners</Locks_ClearOwners>

<Locks_FailOnWrongUser>Lock does not belong to {0}</Locks_FailOnWrongUser>

<Locks_AlertLocksCantBeChanged>Locks can't be changed</Locks_AlertLocksCantBeChanged>
<Locks_AlertLocksCantBeChangedDesc>Some locks can't be changed, because owners of those locks do not perform flick jobs:\n\n{0}</Locks_AlertLocksCantBeChangedDesc>
<Locks_AlertLocksCantBeChangedDefaultDesc>Some locks can't be changed, because owners of those locks do not perform flick jobs.</Locks_AlertLocksCantBeChangedDefaultDesc>

<Locks_Cancel>Cancel</Locks_Cancel>
<Locks_Copy>Copy</Locks_Copy>
<Locks_Paste>Paste</Locks_Paste>
</LanguageData>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</p>
<p align="center">
<a href="https://github.com/Aviuz/Locks/releases">
<img src="https://img.shields.io/badge/version-2.7.2-blue.svg?style=flat" alt="v2.7.2" />
<img src="https://img.shields.io/badge/version-2.7.3-blue.svg?style=flat" alt="v2.7.3" />
</a>
</p>

Expand Down
71 changes: 71 additions & 0 deletions Source/CompatibilityPatches/SoS2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using HarmonyLib;
using Locks.HarmonyPatches;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using Verse;

namespace Locks.CompatibilityPatches
{
class SoS2
{
public static void Init()
{
var mod = LoadedModManager.RunningMods.FirstOrDefault(m => m.Name == "Save Our Ship 2");
if (mod != null)
{
var doorDef = AccessTools.Method("Building_ShipAirlock:PawnCanOpen");
if (doorDef != null)
{
var harmony = new Harmony("Harmony_Locks_SoS2");
harmony.Patch(doorDef, transpiler: new HarmonyMethod(typeof(SoS2).GetMethod("AirLockTranspiler")));
Log.Message("Locks: SoS2 patched");
}
else
{
Log.Error("Locks: mod SoS2 found but cant find airlock to patch");
}
}
else
{
Log.Message("Locks: SoS2 not found ");
}
}

public static IEnumerable<CodeInstruction> AirLockTranspiler(ILGenerator gen, MethodBase mBase, IEnumerable<CodeInstruction> instr)
{
OpCode[] codeToFind =
{
OpCodes.Ldarg_1,
OpCodes.Call,
OpCodes.Stloc_0

};

string[] labelToFind =
{
"",
"Verse.AI.Group.Lord GetLord(Verse.Pawn)",
""
};
int step = 0;
foreach (CodeInstruction codeInst in instr)
{
yield return codeInst;
if (HPatcher.IsFragment(codeToFind, labelToFind, codeInst, ref step))
{
yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Ldarg_1);
yield return new CodeInstruction(OpCodes.Call, typeof(LockUtility).GetMethod("PawnCanOpen"));
yield return new CodeInstruction(OpCodes.Ret);
}
}

}

}
}
18 changes: 16 additions & 2 deletions Source/ITab_Lock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ITab_Lock : ITab
private static readonly Vector2 WinSize = new Vector2(310f + WindowGap, ButtonsHeight + OwnersWindowHeight + OwnersTitleHeight + MainSettingsHeight + WindowGap + 2 * Spacing + WarningHeight);
private const float ButtonsHeight = 25f;
private const float WindowGap = 15f;
private const float MainSettingsHeight = 4 * 32f;
private const float MainSettingsHeight = 6 * 32f;
private const float OwnersTitleHeight = 24f;
private const float OwnersWindowHeight = 200f;
private const float WarningHeight = 24f;
Expand All @@ -28,6 +28,8 @@ public class ITab_Lock : ITab
private bool vistitorsAllowed;
private bool petDoor;
private bool pensDoor;
private bool slaveDoor;
private bool animalsAllowed;

private Thing lastSelectedThing;

Expand Down Expand Up @@ -75,12 +77,20 @@ protected override void FillTab()
listing.Begin(upperSettingsRect);
if (Data.WantedState.IsVisible(nameof(LockState.locked)))
listing.CheckboxLabeled("Locks_ITabLocked".Translate(), ref locked, "Locks_ITabLockedDesc".Translate());
if (Data.WantedState.IsVisible(nameof(LockState.allowSlave)))
{
listing.CheckboxLabeled("Locks_ITabSlaveDoors".Translate(), ref slaveDoor, "Locks_ITabSlaveDoorsDesc".Translate());
}
if (Data.WantedState.IsVisible(nameof(LockState.mode)))
listing.CheckboxLabeled("Locks_ITabVisitorsAllowed".Translate(), ref vistitorsAllowed, "Locks_ITabVisitorsAllowedDesc".Translate());
if (Data.WantedState.IsVisible(nameof(LockState.petDoor)))
listing.CheckboxLabeled("Locks_ITabPetDoor".Translate(), ref petDoor, "Locks_ITabPetDoorDesc".Translate());
if (Data.WantedState.IsVisible(nameof(LockState.pensDoor)))
listing.CheckboxLabeled("Locks_ITabPensDoor".Translate(), ref pensDoor, "Locks_ITabPensDoorDesc".Translate());
if (Data.WantedState.IsVisible(nameof(LockState.allowAnimals)))
{
listing.CheckboxLabeled("Locks_ITabAnimalAllowed".Translate(), ref animalsAllowed, "Locks_ITabAnimalAllowedDesc".Translate());
}
listing.End();

if (Data.WantedState.IsVisible(nameof(LockState.owners)))
Expand Down Expand Up @@ -145,6 +155,8 @@ private void UpdateSettings()
Data.WantedState.mode = vistitorsAllowed ? LockMode.Allies : LockMode.Colony;
Data.WantedState.petDoor = petDoor;
Data.WantedState.pensDoor = pensDoor;
Data.WantedState.allowSlave = slaveDoor;
Data.WantedState.allowAnimals = animalsAllowed;
if (Data.NeedChange)
LockUtility.UpdateLockDesignation(SelDoor);
}
Expand All @@ -158,9 +170,11 @@ private void UpdateSettings()
public override void OnOpen()
{
locked = Data.WantedState.locked;
vistitorsAllowed = Data.WantedState.mode == LockMode.Allies ? true : false;
vistitorsAllowed = Data.WantedState.mode == LockMode.Allies;
petDoor = Data.WantedState.petDoor;
pensDoor = Data.WantedState.pensDoor;
slaveDoor = Data.WantedState.allowSlave;
animalsAllowed = Data.WantedState.allowAnimals;
}

private void OwnerCheckbox(Rect rect, Pawn pawn)
Expand Down
1 change: 1 addition & 0 deletions Source/Initialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ static Initialization()
HarmonyPatches.HPatcher.Init();
CompatibilityPatches.ClutterStructure.Init();
CompatibilityPatches.DoorsExpanded.Init();
CompatibilityPatches.SoS2.Init();
}
}
}
Loading

0 comments on commit 6a36daa

Please sign in to comment.