Skip to content

Commit

Permalink
Tweak font settings and help menu layout
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeCrazyGuy committed May 16, 2024
1 parent c0ebb15 commit d0790c6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
18 changes: 2 additions & 16 deletions src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ static const struct simple_draw_t* const SimpleDraw{GetSimpleDrawAPI()};

extern void draw_gui() {
static ImGuiTabItemFlags ConsoleDefaultFlags = ImGuiTabItemFlags_SetSelected;
static int FontScalePercent = 100;
static bool initpos = false;


if (!initpos) {
initpos = true;

Expand All @@ -28,30 +26,18 @@ extern void draw_gui() {
//put the window in the middle of the screen at 50% game width and height
ImGui::SetNextWindowPos(ImVec2{ width / 2, height / 2 });
ImGui::SetNextWindowSize(ImVec2{ width, height });

//scale up the font based on 1920x1080 = 100%
float hf = size.y / 1080.f;
if (hf > 1.f) {
FontScalePercent = (int)(hf * FontScalePercent);
}
}

//force font size based on fontscaleoverride parameter if set
if (GetSettings()->FontScaleOverride) {
FontScalePercent = GetSettings()->FontScaleOverride;
}

auto imgui_context = ImGui::GetCurrentContext();
ImGui::Begin(BetterAPIName " Mod Menu");
ImGui::SetWindowFontScale(FontScalePercent / 100.f);
ImGui::BeginTabBar("mod tabs");

size_t infos_count = 0;
auto infos = GetModInfo(&infos_count);

//todo: make the help text always visible with font size override?
ImGui::SetWindowFontScale(1);
if (ImGui::TabItemButton("Help", ImGuiTabItemFlags_Trailing)) {
if (ImGui::TabItemButton("Help", ImGuiTabItemFlags_Leading)) {
ImGui::OpenPopup("HelpLinks");
}
if (ImGui::BeginPopup("HelpLinks")) {
Expand Down Expand Up @@ -85,7 +71,7 @@ extern void draw_gui() {
}
ImGui::EndPopup();
}
ImGui::SetWindowFontScale(GetSettings()->FontScaleOverride / 100);
ImGui::SetWindowFontScale((float) GetSettings()->FontScaleOverride / 100.f);


//TODO: the internal modmenu tab could be part of the internal plugin
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ static void SetupModMenu() {
auto s = GetSettingsMutable();
API.Config->Open(BetterAPIName);
API.Config->BindInt(BIND_INT_DEFAULT(s->ConsoleHotkey));
API.Config->BindInt(BIND_VALUE(s->FontScaleOverride), 50, 300, NULL);
API.Config->BindInt(BIND_INT_DEFAULT(s->FontScaleOverride));
API.Config->BindInt(BIND_INT_DEFAULT(s->HotkeyModifier));
API.Config->Close();
DEBUG("Settings Loaded");
Expand Down

0 comments on commit d0790c6

Please sign in to comment.