immortius / chunkbychunk

Minecraft mod in which you unlock the world chunk by chunk
Other
17 stars 5 forks source link

Trying to achieve an in-menu activate/deactivate shortcut (idk if you can help here) #81

Closed xFirefalconx closed 1 year ago

xFirefalconx commented 1 year ago

Hi! I've been pondering about this since a while now. I was thinking about adding a button somewhere in my UI and link it to FancyMenu so that I have a pretty window with "Choose your playstyle: Petrified vs Wilderness" Where I then customize it with two actions: One button will activate CBC petrification if not active, and the other will deactivate it if not inactive.

My problem is a mod incompatibility now. I use Configured, but the window where the CBC config is, is scrollable. Scrollable interfaces cannot display buttons when using FancyMenu. I can't even try see if the buttons work because of the scrolling. The FM dev told me that this is an issue but then told me this other way:

So there's a different approach, but I might need your help here. I could use a batch script file and run it via button click to alter the mod config from the main menu. Now the make it or break it question: Is it somehow possible to reload the CBC config on runtime (or say in the main menu, world creation menu or the sort) without hassle when changing it via such a method?

Or alternatively: Do you have an idea of how else this could be made possible? Could you add such a button/shortcut functionality as a toggle button to the main menu perhaps so I could in theory edit and customize that? Or is that out of scope (which I would understand)?

Thank you in advance. Also, thank you for all the cool new features and fixes. I'm happy that I as a user am heard so much.

immortius commented 1 year ago

Hmmm, tricky. Given the constraint of not changing or interacting with any code, I don't think there is a solution. Making a companion mod providing a custom button action to change the config would be trivial except the whole bit about making a companion mod. :) Certainly CBC config can be reloaded at runtime or even modified and saved at runtime with just a couple of lines of code, but that couple of lines is within the modding context so isn't much help.

I guess if code needs to be changed on my end then I could think about creating a better, non-scrolling config screen. Or perhaps I simply need to reload the config when starting to create a new world instead of just when minecraft starts.

xFirefalconx commented 1 year ago

Thanks for your reply. So the exact words of the Fm dev regarding the situation were: "nope, sorry. well yes and no. it would be possible by running a batch script to edit the file, but you probably need to restart the game after manually changing configs in most cases.", "uhm yes you can emulate button presses of vanilla buttons, but that doesn't work if they are in a scroll view or implemented in a wrong (non-vanilla) way"

Given that, maybe, if it's not too much work for you, I would like to try out whether using a non-scrollable interface for the config would solve the problem, given that the button works likely enough compared to a vanilla one. I have no clue how exactly you implemented that all so I can just assume things here. I could also alpha test regarding that, if that's a feasible way, so we can still scrap things if the button is not working in an emulatable way.

The other solution I see is when pressing the singleplayer or multiplayer button (though the latter is probably optional) to simply reload the config (though I have no clue how to write a batch script file just yet so haha a lot of room for error and screwing with the config).

I would try figure out how to write such a batch file, given which one you would rather do - if it's in scope/fasible of course. Just let me know so I can start to try figure things out. If all fails the batch file is possibly the most stable option, since it's not guaranteed the button emulation will work in case the scroll view were replaced.

An unrelated question regarding multiplayer (because I am curious): If one of two players got CBC petrification deactivated, does that make them be unable to connect to a world with the opposite setting, or does simply the host world define what will happen?

immortius commented 1 year ago

An unrelated question regarding multiplayer (because I am curious): If one of two players got CBC petrification deactivated, does that make them be unable to connect to a world with the opposite setting, or does simply the host world define what will happen?

Configuration is applied server-side and after a world is created on the individual worlds, so the latter.

I would try figure out how to write such a batch file, given which one you would rather do - if it's in scope/fasible of course. Just let me know so I can start to try figure things out. If all fails the batch file is possibly the most stable option, since it's not guaranteed the button emulation will work in case the scroll view were replaced.

I'm not really familiar enough with FancyMenu to be sure whether changes I make will be usable by it or not... so when I make a change it would be to reload the config when creating a world in the first instance. Assuming there is a good way to determine when a world is being created for the first time. If I change the config menu that would be in addition to that change.

xFirefalconx commented 1 year ago

Okay, that sounds most feasible, yeah. If you happen to get to this, could you let me know? I would appreciate that a lot. No rush to do it right then and there, as I plan to work on said feature/setup in the future somewhen, for my running modpack.

immortius commented 1 year ago

Addressed in 2.1.0 by reloading the default config when a new world is created.

xFirefalconx commented 9 months ago

Thanks for the hard work. I need a bit of info on my side so other OS besides mine will work. Is the mod config always called "chunkbychunk.toml" and always in a folder called "defaultconfigs", even in Linux or macOS? I can't really test these as I don't have 'em so I thought I ask before I just do the guessing game. Maybe you know.

immortius commented 9 months ago

Well I don't have them either, so 🤷

That should be the case through, the java code just gets the relative defaultconfigs chunkbychunk.toml file and that should should be cross platform.