Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config system and the ability to disable mods #3

Closed
wants to merge 4 commits into from

Conversation

thearst3rd
Copy link
Member

This adds the ability to enable/disable mods through the Mods menu, as well as a basic xml-based configuration system for HAT. I plan on expanding this to add the ability for mods to create custom config menus and/or store configuration data inside the HatConfig file (potentially removing the need for files like FezugBinds).

Feel free to pick apart and destroy my code here lmao, I'm not confident about some things and definitely felt like some stuff I did were hacks

Copy link
Member

@Krzyhau Krzyhau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are you planning to add additional mod data? More importantly, how would it be accessed from the mods themselves? This would require some sort of API exposed by the HAT itself, which requires some small planning and refactor to prevent unwanted access to structures we don't want mods to see.

Comment on lines +147 to +155
private void DisableMods()
{
foreach (Mod mod in Mods)
{
ModConfig config = ConfigHelper.GetModConfig(mod.Info.Name, mod.Info.Version);
if (config.Disabled.HasValue && config.Disabled.Value == true)
mod.IsEnabled = false;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not only the name of the method is not clear to what function it has, but I think this behaviour (handling configuration) should be done by the Mod class.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, sounds reasonable to me. I wasn't quite sure the best place to put this

}
}

private void DisableDuplicates()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to consider how having multiple versions of the same mod in the game's directory will affect the mod loader, and how it should be communicated properly to the end user. Something like a slide field for version for mods with multiple versions might be appreciated. It could still use the "enabled/disabled" system but it's best not to clutter the mod menu.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about having the version act as a slider as well, and you can choose which version of the mod is active (or choose none of them, disabling the mod). This solution seemed easier to implement which is why I did it this way for now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing. Also, I revert my previous statement and I think that actually having something like SelectedVersion as an optional parameter would be a nice alternative to storing a separate record for each installed version of the mod - this way it can default to the newest one when the option is not present or it points to non-existing version of the mod.

@thearst3rd
Copy link
Member Author

Indeed I want there to be some sort of minimal API exposed by HAT which mods can make use of. Since mods aren't currently aware of HAT, there wouldn't be an easy way to add things to a global config or create easy in-game menus. Something like the hollow knight modding api would be ideal but I don't think we need to make it as complex as that for an MVP. I think exposing a config and easy menu system would be a good starting point.

I don't know much about how the HK api (or any other modding api) works, and it raises some questions for me about versioning:
* Presumably mods would need to target a specific version of the API, how do we make it so mods don't break when that api updates?
* A new dependency will be needed for any mods using the API, how much will be exposed in there and how will we make that interact with HAT?

I'm happy to take a stab at working on this but I'm realizing that if I try and make it by myself it will probably suck cuz I don't know what I'm doing LUL, my way usually involves writing prototypes and throwing code at the project and seeing what sticks but I'm happy to take a step back and trying to plan things out more thoroughly

@Krzyhau
Copy link
Member

Krzyhau commented Jan 30, 2023

HAT already supports minimum version requirement for a mod loader through dependency metadata. We'll probably have to ensure API is backwards-compatible, so it's best to get it mostly right from the very beginning to minimize the amount of needed changes without dropping the compatibility.
In terms of making custom menus, 0x0ade mentioned that some structures can be forced to be public on patching process. It's worth considering doing that for all menu-related structures.
For both of these cases - API and patched structures - modders would have to reference MONOMODDED_FEZ.exe instead (it's really nothing too important, just something to keep in mind).
But these topics should really be moved into separate issue posts if needed to be discussed further.

In terms of configs, there's a suggestion: I think it would be nice to have a "global" HAT config, which contains basic information, like the list of disabled mods, list of prioritized mods etc, and everything mod-specific should be contained within isolated directory (%appdata%/FEZ/HAT/ directory maybe. I'm a sucker in terms of having stuff organized). Global config could also contain stuff like custom logo data (referring to #4).

@thearst3rd
Copy link
Member Author

This XML based system wasn't that great. I might try it again, either with some sort of JSON based system, but we also might go with an external dependency management system with a HAT installer/mod manager akin to Hollow Knight's Scarab or Celeste's Olympus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants