Skip to content

Commit

Permalink
Add Ravenhearst 8.5 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed Aug 8, 2022
1 parent 6c4f4e7 commit 3155b85
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Config/XUi/controls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,11 @@

</modif>

<modelsif condition="Z_Ravenhearst_ResizedBackpack">

<setattribute xpath="/controls/kh60_backpack_item_stack" name="on_scroll">true</setattribute>
<setattribute xpath="/controls/kh60_backpack_item_stack" name="controller">WheelItemStack, InventoryMouseWheel</setattribute>

</modelsif>

</configs>
47 changes: 46 additions & 1 deletion Harmony/InventoryMouseWheel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,57 @@

public class InventoryMouseWheel : IModApi
{
static readonly Type TypeItemStack = AccessTools.TypeByName("Quartz.ItemStack");

public void InitMod(Mod mod)
{
Debug.Log("Loading OCB Inventory Mouse Wheel Patch: " + GetType());
var harmony = new Harmony(GetType().ToString());
harmony.PatchAll(Assembly.GetExecutingAssembly());
}


// ****************************************************
// Implementation to postpone our xml patching.
// Allows us to run after our dependencies :-)
// ****************************************************

// Return in our load order
[HarmonyPatch(typeof(ModManager))]
[HarmonyPatch("GetLoadedMods")]
public class ModManager_GetLoadedMods
{
static void Postfix(ref List<Mod> __result)
{
int myPos = -1, depPos = -1;
if (__result == null) return;
// Find position of mods we depend on
for (int i = 0; i < __result.Count; i += 1)
{
switch (__result[i].ModInfo.Name.Value)
{
// case "SMXui":
case "Z_Ravenhearst_ResizedBackpack":
depPos = Mathf.Max(depPos, i + 1);
break;
case "OcbInventoryMouseWheel":
myPos = i;
break;
}
}
// Didn't detect ourself?
if (myPos == -1)
{
Log.Error("Did not detect our own Mod?");
return;
}
// Detected no dependencies?
if (depPos == -1) return;
// Move our mod after deps
var item = __result[myPos];
__result.RemoveAt(myPos);
if (depPos > myPos) depPos--;
__result.Insert(depPos, item);
}
}

}
1 change: 0 additions & 1 deletion InventoryMouseWheel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
<ItemGroup>
<Compile Include="Harmony\AssemblyInfo.cs" />
<Compile Include="Harmony\WheelItemStack.cs" />
<Compile Include="Harmony\XUiC_WheelQuartzItemStack.cs" />
<Compile Include="Harmony\XUiC_WheelRequiredItemStack.cs" />
<Compile Include="Harmony\XUiC_WheelItemStack.cs" />
<Compile Include="Harmony\InventoryMouseWheel.cs" />
Expand Down
Binary file modified InventoryMouseWheel.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion ModInfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<Description value="Use mouse scroll wheel to move inventory items." />
<Website value="https://github.com/OCB7D2D/OcbInventoryMouseWheel" />
<Author value="ocbMaurice" />
<Version value="0.1.0" compat="A20"/>
<Version value="0.1.1" compat="A20"/>
</ModInfo>
</xml>
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Simply [download here from GitHub][1] and put into your A20 Mods folder:

## Changelog

### Version 0.1.1

- Add Ravenhearst 8.5 compatibility

### Version 0.1.0

- Add Darkness Falls compatibility
Expand Down
Binary file modified SmxCompat/InventoryMouseWheelSMX.dll
Binary file not shown.

0 comments on commit 3155b85

Please sign in to comment.