valheimPlus / ValheimPlus

A HarmonyX Mod aimed at improving the gameplay and quality of life of the game Valheim.
http://valheim.plus
GNU Affero General Public License v3.0
967 stars 237 forks source link

[FEATURE REQUEST] V+ Inventory Compatibility with Project Auga #695

Open rabrunos opened 2 years ago

rabrunos commented 2 years ago

It would be great if the Valheim Plus inventory was compatible with the Auga inventory! As it is, the inventory is left with a scroll even leaving the default (4).

The Auga inventory without the mod is the right size: image

But when you activate the Valheim Plus inventory, it decreases the size of the container and adds the scroll: image

I tried to change the value of the inventory lines configuration to 3, but the minimum is 4 so I was unsuccessful!

Hope this can be fixed one day! The scroll just bothers me and I only activated the inventory setting to modify the chests!

snips86x commented 2 years ago

The issue there is that 2 mods are potentially trying to use the same inventory elements so finding a happy medium is what you get.

rabrunos commented 2 years ago

I understood! In that case, I thought of something that could be done! (Sorry for my ignorance if I'm wrong)

Add a boolean option just for the player's inventory. That way, if the user would configure it like this:

True: Valheim Plus is allowed to use the player's inventory element. False: Valheim Plus is not allowed to use the player's inventory element.

If the user sets it to True (assuming he doesn't care about the problem), after that it would set the value of the inventory row. But if he sets it to False, the problem would go away!

So you wouldn't need to disable the entire inventory section (like chests and etc)

ttimasdf commented 2 years ago

You are definitely using EAQS, I see the equipment slots on the right. EAQS causes the main compatibility issue with all other mods tampering with player inventory, it hooks and modified too much methods (more than needed!). It's very hard to make any mod compatible with it. I read the source code and did not even try.

image

(EPI for Extended Player Inventory, which is functional equivalent to EAQS, by another developer)

Project Auga and EAQS is developed by the same developer. You'd better ask for support by open an issue on his Github.

Although Project Auga exposed an API, I've not seen any third party developers interested in it. For all the mods (doing modifications to GUI) I've been using, none of them is compatible with it.

Also,

The issue there is that 2 mods are potentially trying to use the same inventory elements so finding a happy medium is what you get.

That's it! the elements they are using is InventoryGui.Show method.

I've gathered up a list. The following mods tamper InventoryGui.Show method to add elements to inventory window BUT the modification is conflicted so only one of them is actually applied, or may lead to unpredictable behaviour. You have to make the choice, that only one of them could be enabled.

personally, I use dnSpy to patch Valheim Plus with an additional option to skip the hook of InventoryGui.Show, so that it becomes compatible with Extended Player Inventory. Since you are using EAQS, the same patch could be applied as well. But be careful that you must set the same inventory size in Valheim Plus AND EAQS, on every client and dedicated server (if any), or you may lose items when you die! I'm only sure this trick works with EPI, but for EAQS, you have to read V+ and EAQS codes by yourself, mainly on patches to Inventory, Tomestone and InventoryGui. See which methods are hooked and how they works, see any hooks conflict with each other.

My modification to V+:

namespace ValheimPlus.Configurations.Sections
{
    public class InventoryConfiguration : ServerSyncConfig<InventoryConfiguration>
    {
        // ...
        public bool handleShowExternally { get; internal set; } = false;
namespace ValheimPlus.GameClasses
{
    // Token: 0x020000B9 RID: 185
    [HarmonyPatch(typeof(InventoryGui), "Show")]
    public class InventoryGui_Show_Patch
    {
        // Token: 0x06000174 RID: 372 RVA: 0x00013A64 File Offset: 0x00011C64
        public static void Postfix(ref InventoryGui __instance)
        {
            // MOD HERE!!!
            if (Configuration.Current.Inventory.IsEnabled && !Configuration.Current.Inventory.handleShowExternally)
            {
                RectTransform container = __instance.m_container;
                RectTransform player = __instance.m_player;