mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-18 10:45:27 +02:00
Touch UI support for desktop builds (#10729)
This commit is contained in:
@@ -38,9 +38,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#if USE_SOUND
|
||||
#include "sound_openal.h"
|
||||
#endif
|
||||
#ifdef __ANDROID__
|
||||
#include "porting.h"
|
||||
#endif
|
||||
|
||||
/* mainmenumanager.h
|
||||
*/
|
||||
@@ -147,8 +144,8 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
|
||||
skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255, 0, 0, 0));
|
||||
skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255, 70, 120, 50));
|
||||
skin->setColor(gui::EGDC_HIGH_LIGHT_TEXT, video::SColor(255, 255, 255, 255));
|
||||
#ifdef __ANDROID__
|
||||
float density = porting::getDisplayDensity();
|
||||
#ifdef HAVE_TOUCHSCREENGUI
|
||||
float density = RenderingEngine::getDisplayDensity();
|
||||
skin->setSize(gui::EGDS_CHECK_BOX_WIDTH, (s32)(17.0f * density));
|
||||
skin->setSize(gui::EGDS_SCROLLBAR_SIZE, (s32)(14.0f * density));
|
||||
skin->setSize(gui::EGDS_WINDOW_BUTTON_WIDTH, (s32)(15.0f * density));
|
||||
|
@@ -566,7 +566,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#ifdef HAVE_TOUCHSCREENGUI
|
||||
#define SIZE_TAG "size[11,5.5]"
|
||||
#else
|
||||
#define SIZE_TAG "size[11,5.5,true]" // Fixed size on desktop
|
||||
@@ -901,8 +901,10 @@ private:
|
||||
bool m_does_lost_focus_pause_game = false;
|
||||
|
||||
int m_reset_HW_buffer_counter = 0;
|
||||
#ifdef __ANDROID__
|
||||
#ifdef HAVE_TOUCHSCREENGUI
|
||||
bool m_cache_hold_aux1;
|
||||
#endif
|
||||
#ifdef __ANDROID__
|
||||
bool m_android_chat_open;
|
||||
#endif
|
||||
};
|
||||
@@ -940,7 +942,7 @@ Game::Game() :
|
||||
|
||||
readSettings();
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#ifdef HAVE_TOUCHSCREENGUI
|
||||
m_cache_hold_aux1 = false; // This is initialised properly later
|
||||
#endif
|
||||
|
||||
@@ -1065,7 +1067,7 @@ void Game::run()
|
||||
|
||||
set_light_table(g_settings->getFloat("display_gamma"));
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#ifdef HAVE_TOUCHSCREENGUI
|
||||
m_cache_hold_aux1 = g_settings->getBool("fast_move")
|
||||
&& client->checkPrivilege("fast");
|
||||
#endif
|
||||
@@ -1845,6 +1847,7 @@ void Game::processUserInput(f32 dtime)
|
||||
else if (g_touchscreengui) {
|
||||
/* on touchscreengui step may generate own input events which ain't
|
||||
* what we want in case we just did clear them */
|
||||
g_touchscreengui->show();
|
||||
g_touchscreengui->step(dtime);
|
||||
}
|
||||
#endif
|
||||
@@ -2157,7 +2160,7 @@ void Game::toggleFast()
|
||||
m_game_ui->showTranslatedStatusText("Fast mode disabled");
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#ifdef HAVE_TOUCHSCREENGUI
|
||||
m_cache_hold_aux1 = fast_move && has_fast_privs;
|
||||
#endif
|
||||
}
|
||||
@@ -2495,10 +2498,10 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
|
||||
control.movement_direction = 0.0f;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
/* For Android, simulate holding down AUX1 (fast move) if the user has
|
||||
#ifdef HAVE_TOUCHSCREENGUI
|
||||
/* For touch, simulate holding down AUX1 (fast move) if the user has
|
||||
* the fast_move setting toggled on. If there is an aux1 key defined for
|
||||
* Android then its meaning is inverted (i.e. holding aux1 means walk and
|
||||
* touch then its meaning is inverted (i.e. holding aux1 means walk and
|
||||
* not fast)
|
||||
*/
|
||||
if (m_cache_hold_aux1) {
|
||||
@@ -4184,7 +4187,7 @@ void Game::showDeathFormspec()
|
||||
#define GET_KEY_NAME(KEY) gettext(getKeySetting(#KEY).name())
|
||||
void Game::showPauseMenu()
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
#ifdef HAVE_TOUCHSCREENGUI
|
||||
static const std::string control_text = strgettext("Default Controls:\n"
|
||||
"No menu visible:\n"
|
||||
"- single tap: button activate\n"
|
||||
|
@@ -598,7 +598,7 @@ static float calcDisplayDensity()
|
||||
float RenderingEngine::getDisplayDensity()
|
||||
{
|
||||
static float cached_display_density = calcDisplayDensity();
|
||||
return cached_display_density;
|
||||
return cached_display_density * g_settings->getFloat("display_density_factor");
|
||||
}
|
||||
|
||||
#elif defined(_WIN32)
|
||||
@@ -626,14 +626,14 @@ float RenderingEngine::getDisplayDensity()
|
||||
display_density = calcDisplayDensity(get_video_driver());
|
||||
cached = true;
|
||||
}
|
||||
return display_density;
|
||||
return display_density * g_settings->getFloat("display_density_factor");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
float RenderingEngine::getDisplayDensity()
|
||||
{
|
||||
return g_settings->getFloat("screen_dpi") / 96.0;
|
||||
return (g_settings->getFloat("screen_dpi") / 96.0) * g_settings->getFloat("display_density_factor");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user