|
@@ -664,11 +664,7 @@ public:
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
-#define SIZE_TAG "size[11,5.5]"
|
|
|
-#else
|
|
|
-#define SIZE_TAG "size[11,5.5,true]" // Fixed size on desktop
|
|
|
-#endif
|
|
|
+#define SIZE_TAG "size[11,5.5,true]" // Fixed size (ignored in touchscreen mode)
|
|
|
|
|
|
/****************************************************************************
|
|
|
****************************************************************************/
|
|
@@ -1021,13 +1017,11 @@ private:
|
|
|
// this happens in pause menu in singleplayer
|
|
|
bool m_is_paused = false;
|
|
|
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
- bool m_cache_hold_aux1;
|
|
|
+ bool m_touch_simulate_aux1 = false;
|
|
|
bool m_touch_use_crosshair;
|
|
|
- inline bool isNoCrosshairAllowed() {
|
|
|
+ inline bool isTouchCrosshairDisabled() {
|
|
|
return !m_touch_use_crosshair && camera->getCameraMode() == CAMERA_MODE_FIRST;
|
|
|
}
|
|
|
-#endif
|
|
|
#ifdef __ANDROID__
|
|
|
bool m_android_chat_open;
|
|
|
#endif
|
|
@@ -1075,11 +1069,6 @@ Game::Game() :
|
|
|
&settingChangedCallback, this);
|
|
|
|
|
|
readSettings();
|
|
|
-
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
- m_cache_hold_aux1 = false; // This is initialised properly later
|
|
|
-#endif
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1182,9 +1171,7 @@ bool Game::startup(bool *kill,
|
|
|
|
|
|
m_first_loop_after_window_activation = true;
|
|
|
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
m_touch_use_crosshair = g_settings->getBool("touch_use_crosshair");
|
|
|
-#endif
|
|
|
|
|
|
g_client_translations->clear();
|
|
|
|
|
@@ -1219,10 +1206,8 @@ void Game::run()
|
|
|
|
|
|
set_light_table(g_settings->getFloat("display_gamma"));
|
|
|
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
- m_cache_hold_aux1 = g_settings->getBool("fast_move")
|
|
|
+ m_touch_simulate_aux1 = g_settings->getBool("fast_move")
|
|
|
&& client->checkPrivilege("fast");
|
|
|
-#endif
|
|
|
|
|
|
const irr::core::dimension2du initial_screen_size(
|
|
|
g_settings->getU16("screen_w"),
|
|
@@ -1308,9 +1293,8 @@ void Game::shutdown()
|
|
|
// Clear text when exiting.
|
|
|
m_game_ui->clearText();
|
|
|
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
- g_touchscreengui->hide();
|
|
|
-#endif
|
|
|
+ if (g_touchscreengui)
|
|
|
+ g_touchscreengui->hide();
|
|
|
|
|
|
showOverlayMessage(N_("Shutting down..."), 0, 0, false);
|
|
|
|
|
@@ -1520,11 +1504,10 @@ bool Game::createClient(const GameStartData &start_data)
|
|
|
if (client->modsLoaded())
|
|
|
client->getScript()->on_camera_ready(camera);
|
|
|
client->setCamera(camera);
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
+
|
|
|
if (g_touchscreengui) {
|
|
|
- g_touchscreengui->setUseCrosshair(!isNoCrosshairAllowed());
|
|
|
+ g_touchscreengui->setUseCrosshair(!isTouchCrosshairDisabled());
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
/* Clouds
|
|
|
*/
|
|
@@ -1594,10 +1577,8 @@ bool Game::initGui()
|
|
|
gui_chat_console = new GUIChatConsole(guienv, guienv->getRootGUIElement(),
|
|
|
-1, chat_backend, client, &g_menumgr);
|
|
|
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
if (g_touchscreengui)
|
|
|
g_touchscreengui->init(texture_src);
|
|
|
-#endif
|
|
|
|
|
|
return true;
|
|
|
}
|
|
@@ -2026,18 +2007,17 @@ void Game::processUserInput(f32 dtime)
|
|
|
} else {
|
|
|
input->clear();
|
|
|
}
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
- g_touchscreengui->hide();
|
|
|
-#endif
|
|
|
+
|
|
|
+ if (g_touchscreengui)
|
|
|
+ g_touchscreengui->hide();
|
|
|
+
|
|
|
} else {
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
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
|
|
|
|
|
|
m_game_focused = true;
|
|
|
}
|
|
@@ -2229,13 +2209,11 @@ void Game::processItemSelection(u16 *new_playeritem)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
if (g_touchscreengui) {
|
|
|
std::optional<u16> selection = g_touchscreengui->getHotbarSelection();
|
|
|
if (selection)
|
|
|
*new_playeritem = *selection;
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
// Clamp selection again in case it wasn't changed but max_item was
|
|
|
*new_playeritem = MYMIN(*new_playeritem, max_item);
|
|
@@ -2386,9 +2364,7 @@ void Game::toggleFast()
|
|
|
m_game_ui->showTranslatedStatusText("Fast mode disabled");
|
|
|
}
|
|
|
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
- m_cache_hold_aux1 = fast_move && has_fast_privs;
|
|
|
-#endif
|
|
|
+ m_touch_simulate_aux1 = fast_move && has_fast_privs;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2633,10 +2609,8 @@ void Game::updateCameraDirection(CameraOrientation *cam, float dtime)
|
|
|
Since Minetest has its own code to synthesize mouse events from touch events,
|
|
|
this results in duplicated input. To avoid that, we don't enable relative
|
|
|
mouse mode if we're in touchscreen mode. */
|
|
|
-#ifndef HAVE_TOUCHSCREENGUI
|
|
|
if (cur_control)
|
|
|
- cur_control->setRelativeMode(!isMenuActive());
|
|
|
-#endif
|
|
|
+ cur_control->setRelativeMode(!g_touchscreengui && !isMenuActive());
|
|
|
|
|
|
if ((device->isWindowActive() && device->isWindowFocused()
|
|
|
&& !isMenuActive()) || input->isRandom()) {
|
|
@@ -2679,12 +2653,10 @@ f32 Game::getSensitivityScaleFactor() const
|
|
|
|
|
|
void Game::updateCameraOrientation(CameraOrientation *cam, float dtime)
|
|
|
{
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
if (g_touchscreengui) {
|
|
|
cam->camera_yaw += g_touchscreengui->getYawChange();
|
|
|
cam->camera_pitch += g_touchscreengui->getPitchChange();
|
|
|
} else {
|
|
|
-#endif
|
|
|
v2s32 center(driver->getScreenSize().Width / 2, driver->getScreenSize().Height / 2);
|
|
|
v2s32 dist = input->getMousePos() - center;
|
|
|
|
|
@@ -2698,9 +2670,7 @@ void Game::updateCameraOrientation(CameraOrientation *cam, float dtime)
|
|
|
|
|
|
if (dist.X != 0 || dist.Y != 0)
|
|
|
input->setMousePos(center.X, center.Y);
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
if (m_cache_enable_joysticks) {
|
|
|
f32 sens_scale = getSensitivityScaleFactor();
|
|
@@ -2745,16 +2715,14 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
|
|
|
control.movement_direction = atan2(dx, 1.0f);
|
|
|
}
|
|
|
|
|
|
-#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
|
|
|
* touch then its meaning is inverted (i.e. holding aux1 means walk and
|
|
|
* not fast)
|
|
|
*/
|
|
|
- if (m_cache_hold_aux1) {
|
|
|
+ if (g_touchscreengui && m_touch_simulate_aux1) {
|
|
|
control.aux1 = control.aux1 ^ true;
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
client->setPlayerControl(control);
|
|
|
|
|
@@ -3235,10 +3203,8 @@ void Game::updateCamera(f32 dtime)
|
|
|
|
|
|
camera->toggleCameraMode();
|
|
|
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
if (g_touchscreengui)
|
|
|
- g_touchscreengui->setUseCrosshair(!isNoCrosshairAllowed());
|
|
|
-#endif
|
|
|
+ g_touchscreengui->setUseCrosshair(!isTouchCrosshairDisabled());
|
|
|
|
|
|
// Make the player visible depending on camera mode.
|
|
|
playercao->updateMeshCulling();
|
|
@@ -3339,8 +3305,7 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud)
|
|
|
}
|
|
|
shootline.end = shootline.start + camera_direction * BS * d;
|
|
|
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
- if (g_touchscreengui && isNoCrosshairAllowed()) {
|
|
|
+ if (g_touchscreengui && isTouchCrosshairDisabled()) {
|
|
|
shootline = g_touchscreengui->getShootline();
|
|
|
// Scale shootline to the acual distance the player can reach
|
|
|
shootline.end = shootline.start +
|
|
@@ -3348,7 +3313,6 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud)
|
|
|
shootline.start += intToFloat(camera_offset, BS);
|
|
|
shootline.end += intToFloat(camera_offset, BS);
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
PointedThing pointed = updatePointedThing(shootline,
|
|
|
selected_def.liquids_pointable,
|
|
@@ -3359,10 +3323,8 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud)
|
|
|
if (pointed != runData.pointed_old)
|
|
|
infostream << "Pointing at " << pointed.dump() << std::endl;
|
|
|
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
if (g_touchscreengui)
|
|
|
g_touchscreengui->applyContextControls(selected_def.touch_interaction.getMode(pointed));
|
|
|
-#endif
|
|
|
|
|
|
// Note that updating the selection mesh every frame is not particularly efficient,
|
|
|
// but the halo rendering code is already inefficient so there's no point in optimizing it here
|
|
@@ -4345,10 +4307,10 @@ void Game::drawScene(ProfilerGraph *graph, RunStats *stats)
|
|
|
bool draw_crosshair = (
|
|
|
(player->hud_flags & HUD_FLAG_CROSSHAIR_VISIBLE) &&
|
|
|
(this->camera->getCameraMode() != CAMERA_MODE_THIRD_FRONT));
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
- if (this->isNoCrosshairAllowed())
|
|
|
+
|
|
|
+ if (g_touchscreengui && isTouchCrosshairDisabled())
|
|
|
draw_crosshair = false;
|
|
|
-#endif
|
|
|
+
|
|
|
this->m_rendering_engine->draw_scene(sky_color, this->m_game_ui->m_flags.show_hud,
|
|
|
draw_wield_tool, draw_crosshair);
|
|
|
|
|
@@ -4496,21 +4458,23 @@ void Game::showDeathFormspec()
|
|
|
#define GET_KEY_NAME(KEY) gettext(getKeySetting(#KEY).name())
|
|
|
void Game::showPauseMenu()
|
|
|
{
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
- static const std::string control_text = strgettext("Controls:\n"
|
|
|
- "No menu open:\n"
|
|
|
- "- slide finger: look around\n"
|
|
|
- "- tap: place/punch/use (default)\n"
|
|
|
- "- long tap: dig/use (default)\n"
|
|
|
- "Menu/inventory open:\n"
|
|
|
- "- double tap (outside):\n"
|
|
|
- " --> close\n"
|
|
|
- "- touch stack, touch slot:\n"
|
|
|
- " --> move stack\n"
|
|
|
- "- touch&drag, tap 2nd finger\n"
|
|
|
- " --> place single item to slot\n"
|
|
|
- );
|
|
|
-#endif
|
|
|
+ std::string control_text;
|
|
|
+
|
|
|
+ if (g_touchscreengui) {
|
|
|
+ control_text = strgettext("Controls:\n"
|
|
|
+ "No menu open:\n"
|
|
|
+ "- slide finger: look around\n"
|
|
|
+ "- tap: place/punch/use (default)\n"
|
|
|
+ "- long tap: dig/use (default)\n"
|
|
|
+ "Menu/inventory open:\n"
|
|
|
+ "- double tap (outside):\n"
|
|
|
+ " --> close\n"
|
|
|
+ "- touch stack, touch slot:\n"
|
|
|
+ " --> move stack\n"
|
|
|
+ "- touch&drag, tap 2nd finger\n"
|
|
|
+ " --> place single item to slot\n"
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
float ypos = simple_singleplayer_mode ? 0.7f : 0.1f;
|
|
|
std::ostringstream os;
|
|
@@ -4540,9 +4504,9 @@ void Game::showPauseMenu()
|
|
|
<< strgettext("Exit to Menu") << "]";
|
|
|
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_exit_os;"
|
|
|
<< strgettext("Exit to OS") << "]";
|
|
|
-#ifdef HAVE_TOUCHSCREENGUI
|
|
|
+ if (!control_text.empty()) {
|
|
|
os << "textarea[7.5,0.25;3.9,6.25;;" << control_text << ";]";
|
|
|
-#endif
|
|
|
+ }
|
|
|
os << "textarea[0.4,0.25;3.9,6.25;;" << PROJECT_NAME_C " " VERSION_STRING "\n"
|
|
|
<< "\n"
|
|
|
<< strgettext("Game info:") << "\n";
|