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
14 changes: 7 additions & 7 deletions src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,25 @@ void Menu::Init()

// Enhanced font configuration for sharper text rendering
ImFontConfig font_config;
font_config.OversampleH = Constants::FCONF_OVERSAMPLE_H;
font_config.OversampleV = Constants::FCONF_OVERSAMPLE_V;
font_config.PixelSnapH = Constants::FCONF_PIXELSNAP_H;
font_config.RasterizerMultiply = Constants::FCONF_RASTERIZER_MULTIPLY;
font_config.OversampleH = ThemeManager::Constants::FCONF_OVERSAMPLE_H;
font_config.OversampleV = ThemeManager::Constants::FCONF_OVERSAMPLE_V;
font_config.PixelSnapH = ThemeManager::Constants::FCONF_PIXELSNAP_H;
font_config.RasterizerMultiply = ThemeManager::Constants::FCONF_RASTERIZER_MULTIPLY;

DXGI_SWAP_CHAIN_DESC desc{};
globals::d3d::swapChain->GetDesc(&desc);

float fontSize = settings.Theme.FontSize;

if (std::round(fontSize) != std::round(Constants::DEFAULT_FONT_SIZE)) {
if (std::round(fontSize) != std::round(ThemeManager::Constants::DEFAULT_FONT_SIZE)) {
if (globals::state->screenSize.y > 0) {
fontSize = globals::state->screenSize.y * Constants::DEFAULT_FONT_RATIO;
fontSize = globals::state->screenSize.y * ThemeManager::Constants::DEFAULT_FONT_RATIO;
} else {
logger::warn("Menu::Init() - Failed to get game resolution from globals::state->screenSize.");
}
}

fontSize = std::clamp(fontSize, Constants::MIN_FONT_SIZE, Constants::MAX_FONT_SIZE);
fontSize = std::clamp(fontSize, ThemeManager::Constants::MIN_FONT_SIZE, ThemeManager::Constants::MAX_FONT_SIZE);

if (!imgui_io.Fonts->AddFontFromFileTTF("Data\\Interface\\CommunityShaders\\Fonts\\Jost-Regular.ttf",
std::round(fontSize), &font_config)) {
Expand Down
13 changes: 2 additions & 11 deletions src/Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,6 @@ class Menu
struct Constants
{
static constexpr std::uint16_t KEY_PRESSED_MASK = 0x8000;
static constexpr float DEFAULT_SCREEN_HEIGHT = 1080.0f; // Default screen resolution to use for subsequent calculations
static constexpr float DEFAULT_FONT_RATIO = 0.025f; // Default 2.5% of screen height
static constexpr float MIN_FONT_SIZE = 16.0f; // ~1.5% @ 1080px height
static constexpr float MAX_FONT_SIZE = 108.0f; // 5.0% @ 2160px height
static constexpr float DEFAULT_FONT_SIZE = 27.0f;
static constexpr int FCONF_OVERSAMPLE_H = 3; // ImGui default = 2
static constexpr int FCONF_OVERSAMPLE_V = 2; // ImGui default = 1
static constexpr bool FCONF_PIXELSNAP_H = true; // ImGui default = false
static constexpr float FCONF_RASTERIZER_MULTIPLY = 1.1f; // ImGui default = 1.0f. "Linearly brighten (>1.0f) or darken (<1.0f) font output."
};

// UI icon textures
Expand Down Expand Up @@ -103,7 +94,7 @@ class Menu

struct ThemeSettings
{
float FontSize = Constants::DEFAULT_FONT_SIZE;
float FontSize = ThemeManager::Constants::DEFAULT_FONT_SIZE;
float GlobalScale = REL::Module::IsVR() ? -0.5f : 0.f; // exponential

bool UseSimplePalette = true; // simple palette or full customization
Expand Down Expand Up @@ -279,7 +270,7 @@ class Menu
private:
Settings settings;

float cachedFontSize = Constants::DEFAULT_FONT_SIZE; // Tracks whether font has been modified and may require reloading
float cachedFontSize = ThemeManager::Constants::DEFAULT_FONT_SIZE; // Tracks whether font has been modified and may require reloading

// Menu navigation
std::string pendingFeatureSelection; // Feature to select on next frame
Expand Down
2 changes: 1 addition & 1 deletion src/Menu/SettingsTabRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void SettingsTabRenderer::RenderSizesTab()
auto& io = ImGui::GetIO();
io.FontGlobalScale = trueScale;
}
ImGui::SliderFloat("Font Size", &themeSettings.FontSize, Menu::Constants::MIN_FONT_SIZE, Menu::Constants::MAX_FONT_SIZE, "%.0f");
ImGui::SliderFloat("Font Size", &themeSettings.FontSize, ThemeManager::Constants::MIN_FONT_SIZE, ThemeManager::Constants::MAX_FONT_SIZE, "%.0f");
ImGui::SliderFloat2("Window Padding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f");
ImGui::SliderFloat2("Frame Padding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f");
ImGui::SliderFloat2("Item Spacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f");
Expand Down
8 changes: 4 additions & 4 deletions src/Menu/ThemeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ void ThemeManager::SetupImGuiStyle(const Menu& menu)

colors[ImGuiCol_CheckMark] = themeSettings.Palette.Text;

colors[ImGuiCol_Tab] = ImVec4();
colors[ImGuiCol_TabActive] = ImVec4();
colors[ImGuiCol_Tab] = themeSettings.FullPalette[ImGuiCol_Tab];
colors[ImGuiCol_TabActive] = themeSettings.FullPalette[ImGuiCol_TabActive];
colors[ImGuiCol_TabHovered] = tabHovered;
colors[ImGuiCol_TabUnfocused] = colors[ImGuiCol_Tab];
colors[ImGuiCol_TabUnfocusedActive] = colors[ImGuiCol_TabActive];
colors[ImGuiCol_TabUnfocused] = themeSettings.FullPalette[ImGuiCol_TabUnfocused];
colors[ImGuiCol_TabUnfocusedActive] = themeSettings.FullPalette[ImGuiCol_TabUnfocusedActive];

colors[ImGuiCol_PopupBg] = themeSettings.Palette.Background;

Expand Down
17 changes: 11 additions & 6 deletions src/Menu/ThemeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ class ThemeManager

struct Constants
{
// Font size constants
static constexpr float DEFAULT_SCREEN_HEIGHT = 1080.0f; // Default screen resolution to use for subsequent calculations
static constexpr float DEFAULT_FONT_RATIO = 0.025f; // Default 2.5% of screen height
static constexpr float MIN_FONT_SIZE = 16.0f; // ~1.5% @ 1080px height
static constexpr float MAX_FONT_SIZE = 108.0f; // 5.0% @ 2160px height
static constexpr float DEFAULT_FONT_SIZE = 27.0f;

// Font configuration constants
static constexpr float MIN_FONT_SIZE = 8.0f;
static constexpr float MAX_FONT_SIZE = 32.0f;
static constexpr int FCONF_OVERSAMPLE_H = 3;
static constexpr int FCONF_OVERSAMPLE_V = 1;
static constexpr bool FCONF_PIXELSNAP_H = true;
static constexpr float FCONF_RASTERIZER_MULTIPLY = 1.1f;
static constexpr int FCONF_OVERSAMPLE_H = 3; // ImGui default = 2
static constexpr int FCONF_OVERSAMPLE_V = 2; // ImGui default = 1
static constexpr bool FCONF_PIXELSNAP_H = true; // ImGui default = false
static constexpr float FCONF_RASTERIZER_MULTIPLY = 1.1f; // ImGui default = 1.0f

// Header rendering constants
static constexpr float HEADER_BASE_TEXT_SCALE = 1.7f;
Expand Down