Pathoschild / StardewMods

Mods for Stardew Valley using SMAPI.
MIT License
706 stars 376 forks source link

[Lookup Anything] make UI color theme configurable #436

Open Pathoschild opened 5 years ago

Pathoschild commented 5 years ago

Make all colors configurable to support mods like Dark User Interface, enable high-contrast colors for accessibility, etc.

KhloeLeclair commented 2 years ago

While I was looking at issues finding one talking about Lookup Anything's API, I happened across this and it interests me. You probably aren't aware, but I've written a project I call ThemeManager that's intended to be a single file that you can drop into a Stardew Valley C# mod to easily add support for UI themes. My own mods Almanac and Better Crafting both use it, and I'm eager to get more mods using it to improve the experience of UI theme mods. (I'm also eager for more feedback on how it could be improved.)

If you're interested, I could look at making a pull request that adds theme support. It should be easy enough to go through the code and look for all the hard-coded colors that shouldn't be hard-coded.

Pathoschild commented 2 years ago

Hi! Theme management sounds great, but I'd rather not paste the entire ThemeManager code into the repo and update it manually. Have you thought about making ThemeManager a framework mod players could install instead?

For example, mods like Lookup Anything could use a simple API to manage themes using a data model:


// load the default theme fields (POCO with no base class)
this.Theme = helper.Data.ReadJsonFile<ModColorTheme>("assets/themes/default/theme.json");

// hook up ThemeManager if it's installed
IThemeManagerApi themeManager = modRegistry.GetApi<IThemeManagerApi>("leclair.ThemeManager");
if (themeManager != null)
{
    themeManager.ManageTheme(this, this.Theme, onThemeChanged: this.UpdateTheme);
}
KhloeLeclair commented 2 years ago

I had thought about it before I first wrote it, but given the limitations in SMAPI 3.14 with how APIs work and the barrier of getting players to install another mod I ended up thinking that a single file to drop in might be better. Though, I'm thinking about it more now that you've asked this and 3.14's proxy improvements are coming.

A ThemeManager framework mod could probably take care of adding theme selection to GMCM menu for mods that don't want to do it themselves, and maybe even patch some parts of the base game that traditional UI theme content packs can't handle due to hard-coded colors. Plus, providing a sort of default set of text color, text shadow color, etc. for other mods to use without redefining the wheel.

I'll definitely look into it. I think my only concern is how pintail will handle proxying a call like T Load<T>(string path) for loading assets like textures. It is supposed to support generics, I just haven't messed with it yet.