Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package/SKSE/Plugins/CommunityShaders/Themes/Default.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
"Style": "Regular",
"File": "Jost/Jost-Regular.ttf",
"SizeScale": 1.0
},
{
"Family": "Jost",
"Style": "Regular",
"File": "Jost/Jost-Regular.ttf",
"SizeScale": 0.9
}
],
"UseSimplePalette": false,
Expand Down
6 changes: 6 additions & 0 deletions package/SKSE/Plugins/CommunityShaders/Themes/DragonBlood.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
"Style": "Light",
"File": "CrimsonPro/CrimsonPro-Light.ttf",
"SizeScale": 1.0
},
{
"Family": "Crimson Pro",
"Style": "Light",
"File": "CrimsonPro/CrimsonPro-Light.ttf",
"SizeScale": 0.9
}
],
"UseSimplePalette": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
"File": "RobotoSlab/RobotoSlab-Light.ttf",
"SizeScale": 1.0,
"Style": "Light"
},
{
"Family": "RobotoSlab",
"File": "RobotoSlab/RobotoSlab-Light.ttf",
"SizeScale": 0.9,
"Style": "Light"
}
],
"UseSimplePalette": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
"Style": "Light",
"File": "Inter/Inter-Light.ttf",
"SizeScale": 1.0
},
{
"Family": "Inter",
"Style": "Light",
"File": "Inter/Inter-Light.ttf",
"SizeScale": 0.9
}
],
"UseSimplePalette": false,
Expand Down
6 changes: 6 additions & 0 deletions package/SKSE/Plugins/CommunityShaders/Themes/Light.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
"Style": "Light",
"File": "IBMPlexSerif/IBMPlexSerif-Light.ttf",
"SizeScale": 1.0
},
{
"Family": "IBMPlex Sans",
"Style": "Condensed Light",
"File": "IBMPlexSans/IBMPlexSans_Condensed-Light.ttf",
"SizeScale": 0.9
}
],
"UseSimplePalette": false,
Expand Down
6 changes: 6 additions & 0 deletions package/SKSE/Plugins/CommunityShaders/Themes/NordicFrost.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
"Style": "Regular",
"File": "CrimsonPro/CrimsonPro-Regular.ttf",
"SizeScale": 1.0
},
{
"Family": "Crimson Pro",
"Style": "Light",
"File": "CrimsonPro/CrimsonPro-Light.ttf",
"SizeScale": 0.9
}
],
"UseSimplePalette": false,
Expand Down
21 changes: 21 additions & 0 deletions src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,24 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
bool IsEnabled = false;
std::unordered_map<std::string, int> Menu::categoryCounts;

// Pad FontRoles JSON array with defaults if shorter than FontRole::Count.
// Prevents deserialization failure when loading old settings with fewer font roles.
static void SanitizeFontRolesJson(json& themeJson)
{
if (!themeJson.contains("FontRoles") || !themeJson["FontRoles"].is_array())
return;

auto& fontRoles = themeJson["FontRoles"];
const size_t expected = static_cast<size_t>(Menu::FontRole::Count);

if (fontRoles.size() < expected) {
auto defaults = Menu::ThemeSettings{}.FontRoles;
for (size_t i = fontRoles.size(); i < expected; ++i) {
fontRoles.push_back(defaults[i]);
}
}
}

std::optional<Menu::FontRole> Menu::ResolveFontRole(std::string_view key)
{
for (size_t i = 0; i < FontRoleDescriptors.size(); ++i) {
Expand Down Expand Up @@ -228,6 +246,7 @@ void Menu::Load(json& o_json)
// Legacy support: If old config has Theme data and no SelectedThemePreset, load it
if (o_json.contains("Theme") && o_json["Theme"].is_object() && settings.SelectedThemePreset.empty()) {
bool hasFontRoles = o_json["Theme"].contains("FontRoles");
SanitizeFontRolesJson(o_json["Theme"]);
settings.Theme = o_json["Theme"];
MenuFonts::NormalizeFontRoles(settings.Theme, hasFontRoles);

Expand Down Expand Up @@ -283,6 +302,7 @@ void Menu::LoadTheme(json& o_json)
{
if (o_json["Theme"].is_object()) {
bool hasFontRoles = o_json["Theme"].contains("FontRoles");
SanitizeFontRolesJson(o_json["Theme"]);
settings.Theme = o_json["Theme"];
MenuFonts::NormalizeFontRoles(settings.Theme, hasFontRoles);

Expand Down Expand Up @@ -367,6 +387,7 @@ bool Menu::LoadThemePreset(const std::string& themeName)
}
if (themeSettings.contains("FontRoles")) {
try {
SanitizeFontRolesJson(themeSettings);
settings.Theme.FontRoles = themeSettings["FontRoles"];
} catch (...) {}
}
Expand Down
7 changes: 6 additions & 1 deletion src/Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Menu
Title, // Large title text (e.g., "Community Shaders" header)
Heading, // Section headers (tabs, category labels)
Subheading, // Subsection headers (feature names, separators)
Subtext, // Smaller secondary text (descriptions, about content)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

random side thought for follow up pr, could probably update tooltips to use this text type so they smol

Count // Total number of roles
};

Expand All @@ -72,7 +73,8 @@ class Menu
FontRoleDescriptor{ "Body", "Body Text", 1.0f },
FontRoleDescriptor{ "Title", "Title", 1.0f },
FontRoleDescriptor{ "Heading", "Headings", 1.0f },
FontRoleDescriptor{ "Subheading", "Subheadings", 1.0f }
FontRoleDescriptor{ "Subheading", "Subheadings", 1.0f },
FontRoleDescriptor{ "Subtext", "Subtext", 0.9f }
};

static constexpr std::string_view GetFontRoleKey(FontRole role)
Expand Down Expand Up @@ -147,8 +149,10 @@ class Menu
files[static_cast<size_t>(role)] = std::move(value);
};
setFile(FontRole::Body, "Jost/Jost-Regular.ttf");
setFile(FontRole::Title, "Jost/Jost-Regular.ttf");
setFile(FontRole::Heading, "Jost/Jost-Regular.ttf");
setFile(FontRole::Subheading, "Jost/Jost-Regular.ttf");
setFile(FontRole::Subtext, "Jost/Jost-Regular.ttf");
return files;
}();
mutable std::array<float, static_cast<size_t>(FontRole::Count)> cachedFontPixelSizesByRole = {};
Expand Down Expand Up @@ -238,6 +242,7 @@ class Menu
setRole(FontRole::Title, "Jost", "Regular", "Jost/Jost-Regular.ttf", 1.0f);
setRole(FontRole::Heading, "Jost", "Regular", "Jost/Jost-Regular.ttf", 1.0f);
setRole(FontRole::Subheading, "Jost", "Regular", "Jost/Jost-Regular.ttf", 1.0f);
setRole(FontRole::Subtext, "Jost", "Regular", "Jost/Jost-Regular.ttf", 0.9f);

return roles;
}();
Expand Down
Loading