XiaoLinXiaoZhu / Mods-Manager-for-3Dmigoto

This is a mods manager for 3dmigoto design for ZZZ(which can also use on other mod base on 3dmigoto).I mainly update it on gamebanana)
https://gamebanana.com/tools/17889
GNU General Public License v3.0
16 stars 1 forks source link

Refresh in ZZZ #9

Closed soliddanii closed 1 month ago

soliddanii commented 1 month ago

I made two solutions in two different branches (named after the packages they use):

  1. Hmc-win32 (this merge request)
  2. Koffi

Both solutions use almost the same Windows libraries and APIs, and that's why they are fast, but the hmc-win32 solution has way simpler code as it abstracts a lot of the manual work. That's why I made the MR for that branch first, but I'll let you decide which solution you want, if any, as they both have their pros and cons. You could even combine both later.

Hmc-win32 can't send the keystrokes directly to the game. This is because it sends Virtual Keys, and in my experience ZZZ ignores them. It only works if you send Direct Input Keystrokes. Maybe in the future the package supports it, that would be ideal. To circumvent this issue, i thought of a trick to get the key in the game without sending it directly to the window, that way this solution does not require admin privileges either. In summary this is how it works:

  1. Press the key down in the manager
  2. Focus on the game window
  3. Wait for the input to register
  4. Focus on the manager window again
  5. Release the key
  6. Focus back on the game.

It's fast enough, but it's not the smoothest experience. Here I get the game window through the process name.

Now for the Koffi solution. This is a really amazing package. You have to manually call every Windows function, and define C++ structs and types, but the possibilities are endless. With this code, I actually send the Direct Input key to the game window, as it should be. The downside, you must run the manager as admin, or it doesn't work. This solution tries to get the game window from the process name first, and if it fails, it tries with the window name.

I would suggest to give both branches a test, see if they work for you (as I don't know how it will behave in other machines), and I will let you decide what to do with the code.

Maybe use one over the other, or even pick and choose the code to use a combination of the two (if that were the case, I would personally use the hmc-win32 way of getting the game window, and then, if the manager is running as admin, use the sendinput function from Koffi; if it's not, use the trick). Hmc has the useful function HMC.isAdmin().

Some additional notes:

  1. I did not remove any extra code related to the previous solution. I you end up merging one of these, I'll leave that task to you.
  2. This will only work on windows, for obvious reasons. Having a way to hide the related settings in other platforms would be great. That's why I included some code to hide html components depending on the platform. This is how you use it. Just add a data-platform attribute with the allowed platforms separated by commas (that is win32, linux and darwin).
  3. I personally liked the simpler design for the side panels, but that totally comes down to personal preference. You could maybe have the top panel reach both sides and have the side panels below it. That way you could have the buttons in a more traditional position in the top right for example. Just an idea.
  4. The dedicated mod url field is great! I was actually saving the urls in the description before 🤣 .

Anyway, I hope some of this is useful to you, and congrats on the manager progress! 😄

XiaoLinXiaoZhu commented 1 month ago

Is there a more direct way I could contact you? It seems a bit cumbersome to discuss these matters within a pull request, and the notification system isn't very timely. This means I often can't respond to your messages promptly, as I only notice them when I remember to check GitHub.


Refresh in ZZZ

Regarding the two methods you mentioned, I prefer the first one, as it is more "seamless" for the user. To be honest, the ZZZ launcher asking for permission to start with administrative privileges every time is quite annoying.

Your method to bypass DirectInput is really a genius solution; apart from some flickering that might occur during its application, it has virtually no downsides!

Starting the manager in administrator mode causes the drag-and-drop image setting feature to fail. I'm not sure about the reason (I don't think the same code should behave differently in admin and non-admin modes, which leads me to believe this could be an Electron bug).

As for the other approach, thank you very much for exploring multiple directions! I took a look at Koffi, and it seems to allow running C code within JavaScript. Although I know several programming languages, working across languages always adds complexity. While it does support Linux, well, let's leave those concerns to Wine 😊

Hmc-win32

Regarding the library you mentioned, I had a quick look, and it seems to support a wide range of system-related functionalities. Moreover, it even has documentation in Chinese, which is incredibly convenient for me!

Using the features provided by this library, it might become easier to implement some of the future functionalities, such as: file selection, preventing the Manager from starting multiple times...

UI Design

UI design has always been a headache for me, as I'm not a professional in this area. I just adjust the interface based on what I consider to be "more aesthetically pleasing."

For the new UI design, I mainly drew inspiration from the UI elements in ZZZ games and attempted to imitate them, albeit poorly... The overly simplistic side panel was the reason for the changes. It's certainly not perfect, and whether someone likes it or not is subjective, but I plan to make it more consistent with ZZZ, which I think is the right direction.

Regarding the top panel extending to both sides and placing the side panel underneath, I can imagine the kind of design you're describing. I've also considered something similar before, but there are a few issues with it:

  1. It would squeeze the display space for mod cards from above. The cards are vertical rectangles, which means they need a taller viewport for better presentation.
  2. When displayed alongside the filter list, it wouldn't look very appealing.
  3. When showing detailed information about a mod on the right side of the page and nothing on the left, it would create a visual imbalance, making the left side appear too empty.
  4. Displaying presets horizontally wouldn't look great, and if placed vertically, reading the text would become somewhat difficult... (If you're interested, you can check out this version: ZZZModManager v1.5 In this version, I tried using a cassette tape style for the presets, but the final result wasn't as good as I imagined, so I abandoned the idea.)