1. Hey Guest! We've announced our new game Wargroove, check out the new forums!
    Dismiss Notice

RELEASED [SMAPI] Chests Anywhere

Discussion in 'Mods' started by Pathoschild, Aug 17, 2016.

  1. Pathoschild

    Pathoschild Big Damn Hero

    Yep, sorry for not replying sooner. I've been focused on figuring out crossplatform modding for the last few days. :)

    Your log indicates you have no controller buttons configured. The config.json file is part of the mod package, so you probably overwrote your settings from the updated files. Try editing the file and reconfiguring your controller buttons.

    This one I'm not sure of. Try re-adding your settings and let me know if this still happens.
    • Luzzifus

      Luzzifus Seal Broken

      I tried again with 1.6 and double checked that I edited my controller settings in the correct file. Here's my exact ChestsAnywhere folder including my edited config, from Steam\SteamApps\common\Stardew Valley\Mods\:

      It still does not work.
      Further, I tried to disable (remove) all other mods and run the game with only ChestsAnywhere, but nothing changes.
      I also tried creating a new savegame where I did nothing but get 50 wood and build one chest. Same behaviour: Works with 1.5, doesn't work with 1.6.

      I wrote in my private message that the configured controller toggle button is able to close the ChestsAnywhere window, but not open it. That does not work if the toggle button is not configured at all. In that case, Y (controller) toggles the normal game menu/inventory. From my point of view, that indicates that the controller config is at least partially loaded.

      For reference, I'm using the latest SMAPI from here:
      -> SMAPI-

      Also no change, neither with or without other addons.
        Last edited: Oct 21, 2016
      • Luzzifus

        Luzzifus Seal Broken

        I dug a little bit deeper. The default behaviour of Y (controller) without mods is to toggle the crafting window. B and Start both toggle the inventory. One thing to note here is that each of those button closes the game menu if it is already open, regardless which tab is displayed. So I suspect all of those buttons to somehow be mapped to Game1.options.menuButton, at least when exiting the menu.

        According to my testing, B and Y don't work (can't open the ChestAnywhere window), but e.g. the shoulder buttons do (probably because they're not used by the default game config). X works too, but using that obviously overrides its default function (tool use / secondary action). So why does it work in 1.5, but not in 1.6? I took a quick glance at your code, and found the following:

        ChestsAnywhere/Menus/Overlays/ManageChestOverlay.cs : 317
                        case Element.Menu:
                            if (input.Equals(config.Toggle) || input.Equals(Keys.Escape) || input.Equals(Game1.options.menuButton))
        It seems that in 1.6, you added the last condition to exit the ChestsAnywhere window with ESC or the respective controller button. This works, but maybe a bit too well. ^^ This function returns true or false as an indicator that a button/key press was handled by the function or not. However, the function which actually opens the ChestsAnywhere window does not do that:

        ChestsAnywhere/ChestsAnywhereMod.cs : 180
                private void ReceiveKeyPress<TKey>(TKey key, InputMapConfiguration<TKey> map)
                        if (!map.IsValidKey(key))
                        // open menu
                        if (key.Equals(map.Toggle) && Game1.activeClickableMenu == null)
                    catch (Exception ex)
                        this.HandleError(ex, "handling key input");
        What I suspect to happen is: When I press Y (controller), the ChestsAnywhere window will be opened. That's why I hear the sound. But right after that, the exit code triggers too, because the function opening the window did not mark the button press event as handled and because Y seems to trigger the exit function. So what you would need to fix this is a global button/key press handled state.

        Since you wrote that the chest switch with LeftTrigger/RightTrigger will be fixed in 1.7, this only leaves the problem of not being able to click the chest selection with A (controller) or any other controller button. That includes the selection of chests in that menu too. So when I open the chest selection dropdown with the mouse I can't select a chest with A (controller). This also worked in 1.5, but doesn't anymore in 1.6. Maybe there are just some unhandled button events?
        • Pathoschild

          Pathoschild Big Damn Hero

          Thanks for digging into it! I don't have a controller to test, so that was really helpful. I'll need to buy a controller to look into this properly for the next release.

          By the way, sorry for the slow responses. I usually do one release at a time, and right now is Lookup Anything's turn. I'll be back on this mod after that to start a new cycle.

          On that note:

          In 1.5 and earlier, the mod replaced the chest menu with its own custom menu. This has some advantages (like using the game's menu input logic), but a lot of disadvantages too (like incompatibility with all other inventory mods, and needing to reimplement a lot of the core inventory logic).

          Starting with 1.6, the mod instead hooks into the game events and overlays itself on top of the game's normal chest menu. This is a much cleaner approach, but it's also a bit experimental. Things will become more stable over time as we iron out the bugs. This has a disproportionate effect on controller input, since that's the one thing I can't test myself.

          That's a good theory. There are safeguards which should prevent what you describe from happening, but I can't test whether they're working for controller input.

          First, here's what happens when you press Y to open the chest:
          1. SMAPI fires the ControllerButtonPressed event.
          2. ChestsAnywhereMod::ReceiveKeyPress receives the event. It opens an ItemGrabMenu (the game's normal chest menu). At this point only the standard menu is open, with none of the Chests Anywhere UI.
          3. SMAPI fires the MenuChanged event.
          4. ChestsAnywhereMod::ReceiveMenuChanged receives the event. It detects that an ItemGrabMenu was just opened, and launches a ManageChestOverlay linked to the menu.
          5. The ManageChestOverlay hooks itself into the game events, and draws its components to the screen.
          There are two factors which should prevent what you describe:
          • The menu overlay (which handles the menu-close button) doesn't start listening for events until after the button press event has already been raised.
          • The overlay performs an IsInitialising() check when it receives input, and ignores input within a short time of the menu opening to prevent exactly what you described.
          However, your theory could be right; I'll need to debug the code when I get a controller and see what happens.

          Yep, the game has some special logic (in Game1::update) which converts various controller input into left clicks and right clicks. That just needs to be replicated in the BaseOverlay in the next release.
          • Pathoschild

            Pathoschild Big Damn Hero

            @Kithio fixed controller support in the upcoming 1.7 release. Thanks for the contribution!
              foghorn, Luzzifus and Kithio like this.
            • Pathoschild

              Pathoschild Big Damn Hero

              Some players don't see the chest UI when they zoom out. This is a SMAPI bug that affects all mods for a small subset of users. If you're affected:
              1. Please comment on the SMAPI bug report (or here if you don't have a GitHub account, and I'll forward your message).
              2. Mention your Stardew Valley version, SMAPI version, and platform (Linux, Mac, or Windows).
              3. Optionally (but very helpful):
                1. Install this custom mod.
                2. Load a saved game.
                3. Slowly zoom all the way in and all the way out (keeping it at each zoom level for a couple of seconds).
                4. Exit the game.
                5. Attach a copy of the log file at %appdata%\StardewValley\ErrorLogs\MODDED_ProgramLog.Log_LATEST.txt to your message.

              We may need more information to solve the issue, so the more confirmed users the better. :)
                Acerbicon likes this.
              • Luzzifus

                Luzzifus Seal Broken

                Thanks for the explanation. It seems I was wrong though, it's not the addon code getting triggered to exit the menu. I had other ideas, but was unable to test them in a short time since I didn't find any documentation on SMAPI.

                I tested your latest master and it fixes all the other issues I had with 1.6, thank you! Other than that I have more or less settled on not using Y but one of the shoulder buttons to toggle it.
                • Pathoschild

                  Pathoschild Big Damn Hero

                  Version 1.7 is now available on Linux, Mac, and Windows!

                  This is the first mod launched on all platforms using the new crossplatform mod framework. If you play on Linux and Mac, try it out and let me know how it goes.

                  Changes in this release:
                  • Added support for Linux and Mac.
                  • Added support for opening chest overlay from inventory (mostly to allow more controller bindings).
                  • Added hotkeys to navigate categories.
                  • Added hotkey to edit chest.
                  • Added default controller bindings for chest UI navigation.
                  • Added location tile on edit screen.
                  • Updated minimum game and SMAPI versions.
                  • Fixed B controller button not cancelling like ESC key.
                  • Fixed various controller issues in 1.6.
                  • Fixed list scrolling broken in 1.6.
                  • Fixed navigate-chest hotkeys ignoring category.
                  • Fixed group list being unsorted.
                  • Fixed update-check error on startup adding scary error text in console.
                  Feedback, suggestions, and bug reports are welcome here. :)
                    Luzzifus, Acerbicon and foghorn like this.
                  • SpringsSong

                    SpringsSong Void-Bound Voyager

                    I got this error when I launched Stardew this morning:

                    [08:16:48.160 AM] [ERROR] The Chests Anywhere mod requires a newer version of the game. Please update Stardew Valley from 1.1 to 1.11.
                    The thing that baffles me is the fact that my Stardew is up-to-date--I have it set to the beta, even--and it still functions just fine, despite the error. Running absolute latest version of Stardew (which still calls itself 1.1), SMAPI, all mods function as anticipated, including this one.
                    • Pathoschild

                      Pathoschild Big Damn Hero

                      @SpringsSong The latest version should be 1.11 (1.1.1). Steam sometimes stops updating the game; you can try forcing an update by...
                      1. verifying the game cache;
                      2. opting out of the beta channel (which might not get non-beta updates);
                      3. or reinstalling it.
                      You don't have to update if you don't want to; the mod will probably still work despite the warning. However it hasn't been tested with older versions and they aren't officially supported.
                      • SpringsSong

                        SpringsSong Void-Bound Voyager

                        Opting out of the beta fixed the issue and brought me up to 1.1.1. It's slightly annoying that Steam doesn't have a "Check For Updates" button; in the past, verifying the game cache has reverted some of my XNB mods, so I am hesitant to do it that way unless I deleted a file on purpose. I also have limited internet data, so full-on reinstalling is a last-resort thing.
                        • Pathoschild

                          Pathoschild Big Damn Hero

                        • EnderHDMC

                          EnderHDMC Poptop Tamer

                          I tested the Linux version on Kali Linux Rolling 2016.3.1 and I have confirmed that it does work.

                          PS: The Linux and Mac versions are identical (MD5=0c137af1c7278a1266ab36c108548b51), both Linux and Mac use Mono and SMAPI is installed in pretty much the same way on both so it is probably safe to assume that they both work. I tested two other Linux SMAPI mods and they were also identical to their corresponding Mac versions.

                            Attached Files:

                            Pathoschild likes this.
                          • Pathoschild

                            Pathoschild Big Damn Hero

                            Version 1.8.1 is now available on Linux, Mac, and Windows. This updates the mod to SMAPI 1.3, which improves crossplatform support.

                            • This version requires the latest SMAPI 1.3.
                            • If you play on Linux or Mac, there's no longer a separate version for you. The one package is compatible with Linux, Mac, and Windows.
                            Feedback, suggestions, and bug reports are welcome here. :)
                            • Eieio

                              Eieio Space Hobo

                              This actually doesn't work for me. :( Pressing B does nothing. I was so looking forward to using this mod.
                              • Pathoschild

                                Pathoschild Big Damn Hero

                                Hi @Eieio. No worries, I'm sure we can fix it for you. Can you reply with your error log attached?
                                • QbMoto

                                  QbMoto Orbital Explorer

                                  i have the same problem as Eieio. I do not have a error log because nothing happens. ive installed the mod as i have with all others, same process and same folder. Yet nothing happens when i press B. any help would be appreciated
                                  • Pathoschild

                                    Pathoschild Big Damn Hero

                                    Hi @QbMoto. Can you post your error log anyway? It includes relevant information like your game version, SMAPI version, whether the mod was loaded, etc.
                                    • QbMoto

                                      QbMoto Orbital Explorer

                                      here you go....thanks

                                        Attached Files:

                                      • Pathoschild

                                        Pathoschild Big Damn Hero

                                        @QbMoto You have SMAPI 0.40, which is very old and won't work with many newer mods. Updating to the latest SMAPI 1.5 should fix it.

                                        Share This Page