Skip to content

Commit

Permalink
Add a scale factor for the console/dm text (#796)
Browse files Browse the repository at this point in the history
* Try scaling dungeon master font

* Try doing it correctly

* Try scaling console

* Console scale was probably too early.

* Try setting ImGui global font scale

* Revert "Try setting ImGui global font scale"

This reverts commit 80e26d3.

* Use a config item for dm scale. Try scaling more of the console ui

* Try to scale tig console menus

* Try to read dm scale from config file
  • Loading branch information
dolio authored Dec 17, 2024
1 parent 571348e commit e3f64a9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions TemplePlus/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ static ConfigSetting configSettings[] = {
CONF_STRING(defaultModule),
CONF_INT(windowWidth),
CONF_INT(windowHeight),
CONF_DOUBLE(dmGuiScale),
CONF_BOOL(enlargeDialogFonts),
CONF_BOOL(windowedLockCursor),
CONF_BOOL(dungeonMaster),
Expand Down
1 change: 1 addition & 0 deletions TemplePlus/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct TemplePlusConfig
bool debugClipping = false;
bool drawObjCylinders = false;
bool newAnimSystem = false;
float dmGuiScale = 1.0f;

bool autoUpdate = true;
std::string autoUpdateFeed = "https://templeplus.org/update-feeds/stable/";
Expand Down
1 change: 1 addition & 0 deletions TemplePlus/dungeon_master.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ void DungeonMaster::Render() {
}
auto wndPos = ImGui::GetWindowPos();
auto wndWidth = ImGui::GetWindowWidth();
ImGui::SetWindowFontScale(config.dmGuiScale);
dmPortraitRect.x = (int)(wndPos.x + wndWidth / 2 - dmPortraitRect.width / 2); dmPortraitRect.y = (int)(wndPos.y - dmPortraitRect.height);

auto blyat = gameView->MapToScene(dmPortraitRect.x, dmPortraitRect.y);//gameView->MapFromScene(config.renderWidth - dmPortraitRect.x , config.renderHeight - -dmPortraitRect.y);
Expand Down
6 changes: 6 additions & 0 deletions TemplePlus/tig/tig_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ void Console::Render()
ImGui::End();
return;
}
ImGui::SetWindowFontScale(config.dmGuiScale);

RenderCheatsMenu();

ImGui::BeginChild("ScrollingRegion", ImVec2(0, -ImGui::GetItemsLineHeightWithSpacing()), false, ImGuiWindowFlags_HorizontalScrollbar);
ImGui::SetWindowFontScale(config.dmGuiScale);
if (ImGui::BeginPopupContextWindow())
{
if (ImGui::Selectable("Clear")) Clear();
Expand Down Expand Up @@ -251,6 +253,7 @@ void Console::RenderCheatsMenu()
{
if (ImGui::BeginMenu("Cheats"))
{
ImGui::SetWindowFontScale(config.dmGuiScale);
if (ImGui::MenuItem("Level Up")) {
for (auto i = 0u; i < party.GroupListGetLen(); i++) {
auto handle = party.GroupListGetMemberN(i);
Expand Down Expand Up @@ -391,6 +394,7 @@ void Console::RenderCheatsMenu()
}

if (ImGui::BeginMenu("Speedup")){
ImGui::SetWindowFontScale(config.dmGuiScale);
auto speedupCb = [](int speedupVal) {
auto N_party = party.GroupListGetLen();
auto speedRun = 1.0f;
Expand Down Expand Up @@ -433,6 +437,7 @@ void Console::RenderCheatsMenu()
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Debug")) {
ImGui::SetWindowFontScale(config.dmGuiScale);
if (ImGui::MenuItem("Debug Console")) {
UIShowDebug();
}
Expand All @@ -458,6 +463,7 @@ void Console::RenderCheatsMenu()
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Edit")){
ImGui::SetWindowFontScale(config.dmGuiScale);

static char dialogHandleInput[256] = { 0, };
static std::string dialogFilename;
Expand Down

0 comments on commit e3f64a9

Please sign in to comment.