Allow to use bigger fonts on desktop version for easier debugging

This commit is contained in:
Deve
2018-04-11 21:39:34 +02:00
parent c8c390cdaa
commit 4abdb14a4c
4 changed files with 34 additions and 20 deletions

View File

@@ -500,6 +500,11 @@ namespace UserConfigParams
PARAM_DEFAULT( BoolUserConfigParam(false, "screen_keyboard",
&m_multitouch_group,
"Enable screen keyboard.") );
PARAM_PREFIX BoolUserConfigParam m_hidpi_enabled
PARAM_DEFAULT( BoolUserConfigParam(false, "hidpi_enabled",
&m_multitouch_group,
"Enable high-DPI support.") );
// ---- GP start order
PARAM_PREFIX GroupUserConfigParam m_gp_start_order

View File

@@ -18,6 +18,7 @@
#include "font/font_with_face.hpp"
#include "config/user_config.hpp"
#include "font/face_ttf.hpp"
#include "font/font_manager.hpp"
#include "font/font_settings.hpp"
@@ -331,23 +332,24 @@ void FontWithFace::setDPI()
const int screen_width = irr_driver->getFrameSize().Width;
const int screen_height = irr_driver->getFrameSize().Height;
#ifdef ANDROID
float scale = screen_height / 480.0f;
m_face_dpi = getScalingFactorTwo() * getScalingFactorOne() * scale;
#else
float scale = std::max(0, screen_width - 640) / 564.0f;
// attempt to compensate for small screens
if (screen_width < 1200)
scale = std::max(0, screen_width - 640) / 750.0f;
if (screen_width < 900 || screen_height < 700)
scale = std::min(scale, 0.05f);
m_face_dpi = unsigned((getScalingFactorOne() + 0.2f * scale) *
getScalingFactorTwo());
#endif
if (UserConfigParams::m_hidpi_enabled)
{
float scale = screen_height / 480.0f;
m_face_dpi = getScalingFactorTwo() * getScalingFactorOne() * scale;
}
else
{
float scale = std::max(0, screen_width - 640) / 564.0f;
// attempt to compensate for small screens
if (screen_width < 1200)
scale = std::max(0, screen_width - 640) / 750.0f;
if (screen_width < 900 || screen_height < 700)
scale = std::min(scale, 0.05f);
m_face_dpi = unsigned((getScalingFactorOne() + 0.2f * scale) *
getScalingFactorTwo());
}
} // setDPI
// ----------------------------------------------------------------------------

View File

@@ -15,6 +15,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "config/user_config.hpp"
#include "font/font_manager.hpp"
#include "font/regular_face.hpp"
#include "graphics/irr_driver.hpp"
@@ -151,9 +152,12 @@ void DynamicRibbonWidget::add()
unsigned int screen_height = irr_driver->getActualScreenSize().Height;
m_arrows_w = (int)(screen_height / 15);
m_arrows_w = std::max(m_arrows_w, 40);
#ifdef ANDROID
m_arrows_w *= 1.5f;
#endif
if (UserConfigParams::m_hidpi_enabled)
{
m_arrows_w *= 1.5f;
}
const int button_h = m_arrows_w;
// right arrow

View File

@@ -49,6 +49,9 @@ void override_default_params()
UserConfigParams::m_screen_keyboard = true;
}
// Set bigger fonts and buttons
UserConfigParams::m_hidpi_enabled = true;
// It shouldn't matter, but STK is always run in fullscreen on android
UserConfigParams::m_fullscreen = true;