Skip to content

Commit

Permalink
Apply DPI Scaling to GUIModalMenu (minetest#12693)
Browse files Browse the repository at this point in the history
Co-authored-by: sfan5 <[email protected]>
  • Loading branch information
ElliottLester and sfan5 committed Aug 15, 2022
1 parent adc89f7 commit 7c5e3ca
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/gui/modalMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/

#include <cstdlib>
#include "client/renderingengine.h"
#include "modalMenu.h"
#include "gettext.h"
#include "porting.h"
#include "settings.h"

#ifdef HAVE_TOUCHSCREENGUI
#include "touchscreengui.h"
#include "client/renderingengine.h"
#endif

// clang-format off
Expand All @@ -41,10 +41,13 @@ GUIModalMenu::GUIModalMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent,
m_remap_dbl_click(remap_dbl_click)
{
m_gui_scale = std::max(g_settings->getFloat("gui_scaling"), 0.5f);
const float screen_dpi_scale = RenderingEngine::getDisplayDensity();
#ifdef HAVE_TOUCHSCREENGUI
float d = RenderingEngine::getDisplayDensity();
m_gui_scale *= 1.1 - 0.3 * d + 0.2 * d * d;
m_gui_scale *= 1.1f - 0.3f * screen_dpi_scale + 0.2f * screen_dpi_scale * screen_dpi_scale;
#else
m_gui_scale *= screen_dpi_scale;
#endif

setVisible(true);
Environment->setFocus(this);
m_menumgr->createdMenu(this);
Expand Down

0 comments on commit 7c5e3ca

Please sign in to comment.