Rename TouchScreenGUI -> TouchControls

to avoid confusion between touchscreen-related settings that affect GUIs
(formspecs) and touchscreen-related settings that affect the touch controls
(TouchControls / formerly TouchScreenGUI)
This commit is contained in:
Gregor Parzefall 2024-05-15 21:11:16 +02:00 committed by grorp
parent bf4d31227b
commit 1977517d7a
10 changed files with 83 additions and 83 deletions

@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "gui/mainmenumanager.h" #include "gui/mainmenumanager.h"
#include "clouds.h" #include "clouds.h"
#include "gui/touchscreengui.h" #include "gui/touchcontrols.h"
#include "server.h" #include "server.h"
#include "filesys.h" #include "filesys.h"
#include "gui/guiMainMenu.h" #include "gui/guiMainMenu.h"
@ -230,9 +230,9 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
m_rendering_engine->get_scene_manager()->clear(); m_rendering_engine->get_scene_manager()->clear();
if (g_touchscreengui) { if (g_touchcontrols) {
delete g_touchscreengui; delete g_touchcontrols;
g_touchscreengui = NULL; g_touchcontrols = NULL;
} }
/* Save the settings when leaving the game. /* Save the settings when leaving the game.

@ -40,7 +40,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content/subgames.h" #include "content/subgames.h"
#include "client/event_manager.h" #include "client/event_manager.h"
#include "fontengine.h" #include "fontengine.h"
#include "gui/touchscreengui.h" #include "gui/touchcontrols.h"
#include "itemdef.h" #include "itemdef.h"
#include "log.h" #include "log.h"
#include "filesys.h" #include "filesys.h"
@ -1245,8 +1245,8 @@ void Game::shutdown()
// Clear text when exiting. // Clear text when exiting.
m_game_ui->clearText(); m_game_ui->clearText();
if (g_touchscreengui) if (g_touchcontrols)
g_touchscreengui->hide(); g_touchcontrols->hide();
// only if the shutdown progress bar isn't shown yet // only if the shutdown progress bar isn't shown yet
if (m_shutdown_progress == 0.0f) if (m_shutdown_progress == 0.0f)
@ -1510,8 +1510,8 @@ bool Game::createClient(const GameStartData &start_data)
client->getScript()->on_camera_ready(camera); client->getScript()->on_camera_ready(camera);
client->setCamera(camera); client->setCamera(camera);
if (g_touchscreengui) { if (g_touchcontrols) {
g_touchscreengui->setUseCrosshair(!isTouchCrosshairDisabled()); g_touchcontrols->setUseCrosshair(!isTouchCrosshairDisabled());
} }
/* Clouds /* Clouds
@ -1579,7 +1579,7 @@ bool Game::initGui()
-1, chat_backend, client, &g_menumgr); -1, chat_backend, client, &g_menumgr);
if (g_settings->getBool("enable_touch")) if (g_settings->getBool("enable_touch"))
g_touchscreengui = new TouchScreenGUI(device, texture_src); g_touchcontrols = new TouchControls(device, texture_src);
return true; return true;
} }
@ -2027,15 +2027,15 @@ void Game::processUserInput(f32 dtime)
input->clear(); input->clear();
} }
if (g_touchscreengui) if (g_touchcontrols)
g_touchscreengui->hide(); g_touchcontrols->hide();
} else { } else {
if (g_touchscreengui) { if (g_touchcontrols) {
/* on touchscreengui step may generate own input events which ain't /* on touchcontrols step may generate own input events which ain't
* what we want in case we just did clear them */ * what we want in case we just did clear them */
g_touchscreengui->show(); g_touchcontrols->show();
g_touchscreengui->step(dtime); g_touchcontrols->step(dtime);
} }
m_game_focused = true; m_game_focused = true;
@ -2230,8 +2230,8 @@ void Game::processItemSelection(u16 *new_playeritem)
} }
} }
if (g_touchscreengui) { if (g_touchcontrols) {
std::optional<u16> selection = g_touchscreengui->getHotbarSelection(); std::optional<u16> selection = g_touchcontrols->getHotbarSelection();
if (selection) if (selection)
*new_playeritem = *selection; *new_playeritem = *selection;
} }
@ -2636,7 +2636,7 @@ void Game::updateCameraDirection(CameraOrientation *cam, float dtime)
this results in duplicated input. To avoid that, we don't enable relative this results in duplicated input. To avoid that, we don't enable relative
mouse mode if we're in touchscreen mode. */ mouse mode if we're in touchscreen mode. */
if (cur_control) if (cur_control)
cur_control->setRelativeMode(!g_touchscreengui && !isMenuActive()); cur_control->setRelativeMode(!g_touchcontrols && !isMenuActive());
if ((device->isWindowActive() && device->isWindowFocused() if ((device->isWindowActive() && device->isWindowFocused()
&& !isMenuActive()) || input->isRandom()) { && !isMenuActive()) || input->isRandom()) {
@ -2679,9 +2679,9 @@ f32 Game::getSensitivityScaleFactor() const
void Game::updateCameraOrientation(CameraOrientation *cam, float dtime) void Game::updateCameraOrientation(CameraOrientation *cam, float dtime)
{ {
if (g_touchscreengui) { if (g_touchcontrols) {
cam->camera_yaw += g_touchscreengui->getYawChange(); cam->camera_yaw += g_touchcontrols->getYawChange();
cam->camera_pitch += g_touchscreengui->getPitchChange(); cam->camera_pitch += g_touchcontrols->getPitchChange();
} else { } else {
v2s32 center(driver->getScreenSize().Width / 2, driver->getScreenSize().Height / 2); v2s32 center(driver->getScreenSize().Width / 2, driver->getScreenSize().Height / 2);
v2s32 dist = input->getMousePos() - center; v2s32 dist = input->getMousePos() - center;
@ -2746,7 +2746,7 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
* touch 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) * not fast)
*/ */
if (g_touchscreengui && m_touch_simulate_aux1) { if (g_touchcontrols && m_touch_simulate_aux1) {
control.aux1 = control.aux1 ^ true; control.aux1 = control.aux1 ^ true;
} }
@ -3235,8 +3235,8 @@ void Game::updateCamera(f32 dtime)
camera->toggleCameraMode(); camera->toggleCameraMode();
if (g_touchscreengui) if (g_touchcontrols)
g_touchscreengui->setUseCrosshair(!isTouchCrosshairDisabled()); g_touchcontrols->setUseCrosshair(!isTouchCrosshairDisabled());
// Make the player visible depending on camera mode. // Make the player visible depending on camera mode.
playercao->updateMeshCulling(); playercao->updateMeshCulling();
@ -3337,8 +3337,8 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud)
} }
shootline.end = shootline.start + camera_direction * BS * d; shootline.end = shootline.start + camera_direction * BS * d;
if (g_touchscreengui && isTouchCrosshairDisabled()) { if (g_touchcontrols && isTouchCrosshairDisabled()) {
shootline = g_touchscreengui->getShootline(); shootline = g_touchcontrols->getShootline();
// Scale shootline to the acual distance the player can reach // Scale shootline to the acual distance the player can reach
shootline.end = shootline.start + shootline.end = shootline.start +
shootline.getVector().normalize() * BS * d; shootline.getVector().normalize() * BS * d;
@ -3355,9 +3355,9 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud)
if (pointed != runData.pointed_old) if (pointed != runData.pointed_old)
infostream << "Pointing at " << pointed.dump() << std::endl; infostream << "Pointing at " << pointed.dump() << std::endl;
if (g_touchscreengui) { if (g_touchcontrols) {
auto mode = selected_def.touch_interaction.getMode(pointed.type); auto mode = selected_def.touch_interaction.getMode(pointed.type);
g_touchscreengui->applyContextControls(mode); g_touchcontrols->applyContextControls(mode);
} }
// Note that updating the selection mesh every frame is not particularly efficient, // Note that updating the selection mesh every frame is not particularly efficient,
@ -4348,7 +4348,7 @@ void Game::drawScene(ProfilerGraph *graph, RunStats *stats)
(player->hud_flags & HUD_FLAG_CROSSHAIR_VISIBLE) && (player->hud_flags & HUD_FLAG_CROSSHAIR_VISIBLE) &&
(this->camera->getCameraMode() != CAMERA_MODE_THIRD_FRONT)); (this->camera->getCameraMode() != CAMERA_MODE_THIRD_FRONT));
if (g_touchscreengui && isTouchCrosshairDisabled()) if (g_touchcontrols && isTouchCrosshairDisabled())
draw_crosshair = false; draw_crosshair = false;
this->m_rendering_engine->draw_scene(sky_color, this->m_game_ui->m_flags.show_hud, this->m_rendering_engine->draw_scene(sky_color, this->m_game_ui->m_flags.show_hud,
@ -4459,7 +4459,7 @@ void Game::showPauseMenu()
{ {
std::string control_text; std::string control_text;
if (g_touchscreengui) { if (g_touchcontrols) {
control_text = strgettext("Controls:\n" control_text = strgettext("Controls:\n"
"No menu open:\n" "No menu open:\n"
"- slide finger: look around\n" "- slide finger: look around\n"

@ -39,7 +39,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "wieldmesh.h" #include "wieldmesh.h"
#include "client/renderingengine.h" #include "client/renderingengine.h"
#include "client/minimap.h" #include "client/minimap.h"
#include "gui/touchscreengui.h" #include "gui/touchcontrols.h"
#include "util/enriched_string.h" #include "util/enriched_string.h"
#include "irrlicht_changes/CGUITTFont.h" #include "irrlicht_changes/CGUITTFont.h"
@ -322,8 +322,8 @@ void Hud::drawItems(v2s32 upperleftpos, v2s32 screen_offset, s32 itemcount,
drawItem(mainlist->getItem(i), item_rect, (i + 1) == selectitem); drawItem(mainlist->getItem(i), item_rect, (i + 1) == selectitem);
if (is_hotbar && g_touchscreengui) if (is_hotbar && g_touchcontrols)
g_touchscreengui->registerHotbarRect(i, item_rect); g_touchcontrols->registerHotbarRect(i, item_rect);
} }
} }
@ -787,8 +787,8 @@ void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir,
void Hud::drawHotbar(u16 playeritem) void Hud::drawHotbar(u16 playeritem)
{ {
if (g_touchscreengui) if (g_touchcontrols)
g_touchscreengui->resetHotbarRects(); g_touchcontrols->resetHotbarRects();
InventoryList *mainlist = inventory->getList("main"); InventoryList *mainlist = inventory->getList("main");
if (mainlist == NULL) { if (mainlist == NULL) {

@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/numeric.h" #include "util/numeric.h"
#include "inputhandler.h" #include "inputhandler.h"
#include "gui/mainmenumanager.h" #include "gui/mainmenumanager.h"
#include "gui/touchscreengui.h" #include "gui/touchcontrols.h"
#include "hud.h" #include "hud.h"
void KeyCache::populate_nonchanging() void KeyCache::populate_nonchanging()
@ -143,8 +143,8 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
// Let the menu handle events, if one is active. // Let the menu handle events, if one is active.
if (isMenuActive()) { if (isMenuActive()) {
if (g_touchscreengui) if (g_touchcontrols)
g_touchscreengui->setVisible(false); g_touchcontrols->setVisible(false);
return g_menumgr.preprocessEvent(event); return g_menumgr.preprocessEvent(event);
} }
@ -168,9 +168,9 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
return true; return true;
} }
} else if (g_touchscreengui && event.EventType == irr::EET_TOUCH_INPUT_EVENT) { } else if (g_touchcontrols && event.EventType == irr::EET_TOUCH_INPUT_EVENT) {
// In case of touchscreengui, we have to handle different events // In case of touchcontrols, we have to handle different events
g_touchscreengui->translateEvent(event); g_touchcontrols->translateEvent(event);
return true; return true;
} else if (event.EventType == irr::EET_JOYSTICK_INPUT_EVENT) { } else if (event.EventType == irr::EET_JOYSTICK_INPUT_EVENT) {
// joystick may be nullptr if game is launched with '--random-input' parameter // joystick may be nullptr if game is launched with '--random-input' parameter
@ -237,8 +237,8 @@ float RealInputHandler::getMovementSpeed()
return 0.0f; return 0.0f;
return 1.0f; // If there is a keyboard event, assume maximum speed return 1.0f; // If there is a keyboard event, assume maximum speed
} }
if (g_touchscreengui && g_touchscreengui->getMovementSpeed()) if (g_touchcontrols && g_touchcontrols->getMovementSpeed())
return g_touchscreengui->getMovementSpeed(); return g_touchcontrols->getMovementSpeed();
return joystick.getMovementSpeed(); return joystick.getMovementSpeed();
} }
@ -260,8 +260,8 @@ float RealInputHandler::getMovementDirection()
return std::atan2(x, z); return std::atan2(x, z);
// `getMovementDirection() == 0` means forward, so we cannot use // `getMovementDirection() == 0` means forward, so we cannot use
// `getMovementDirection()` as a condition. // `getMovementDirection()` as a condition.
else if (g_touchscreengui && g_touchscreengui->getMovementSpeed()) else if (g_touchcontrols && g_touchcontrols->getMovementSpeed())
return g_touchscreengui->getMovementDirection(); return g_touchcontrols->getMovementDirection();
return joystick.getMovementDirection(); return joystick.getMovementDirection();
} }

@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h" #include "settings.h"
#include "client/renderingengine.h" #include "client/renderingengine.h"
#include "gui/touchscreengui.h" #include "gui/touchcontrols.h"
ClientDynamicInfo ClientDynamicInfo::getCurrent() ClientDynamicInfo ClientDynamicInfo::getCurrent()
{ {
@ -33,7 +33,7 @@ ClientDynamicInfo ClientDynamicInfo::getCurrent()
f32 hud_scaling = g_settings->getFloat("hud_scaling", 0.5f, 20.0f); f32 hud_scaling = g_settings->getFloat("hud_scaling", 0.5f, 20.0f);
f32 real_gui_scaling = gui_scaling * density; f32 real_gui_scaling = gui_scaling * density;
f32 real_hud_scaling = hud_scaling * density; f32 real_hud_scaling = hud_scaling * density;
bool touch_controls = g_touchscreengui; bool touch_controls = g_touchcontrols;
return { return {
screen_size, real_gui_scaling, real_hud_scaling, screen_size, real_gui_scaling, real_hud_scaling,

@ -25,6 +25,6 @@ set(gui_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/guiVolumeChange.cpp ${CMAKE_CURRENT_SOURCE_DIR}/guiVolumeChange.cpp
${CMAKE_CURRENT_SOURCE_DIR}/modalMenu.cpp ${CMAKE_CURRENT_SOURCE_DIR}/modalMenu.cpp
${CMAKE_CURRENT_SOURCE_DIR}/profilergraph.cpp ${CMAKE_CURRENT_SOURCE_DIR}/profilergraph.cpp
${CMAKE_CURRENT_SOURCE_DIR}/touchscreengui.cpp ${CMAKE_CURRENT_SOURCE_DIR}/touchcontrols.cpp
PARENT_SCOPE PARENT_SCOPE
) )

@ -377,7 +377,7 @@ void GUIKeyChangeMenu::add_key(int id, std::wstring button_name, const std::stri
key_settings.push_back(k); key_settings.push_back(k);
} }
// compare with button_titles in touchscreengui.cpp // compare with button_titles in touchcontrols.cpp
void GUIKeyChangeMenu::init_keys() void GUIKeyChangeMenu::init_keys()
{ {
this->add_key(GUI_ID_KEY_FORWARD_BUTTON, wstrgettext("Forward"), "keymap_forward"); this->add_key(GUI_ID_KEY_FORWARD_BUTTON, wstrgettext("Forward"), "keymap_forward");

@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "gui/guiInventoryList.h" #include "gui/guiInventoryList.h"
#include "porting.h" #include "porting.h"
#include "settings.h" #include "settings.h"
#include "touchscreengui.h" #include "touchcontrols.h"
PointerAction PointerAction::fromEvent(const SEvent &event) { PointerAction PointerAction::fromEvent(const SEvent &event) {
switch (event.EventType) { switch (event.EventType) {
@ -111,8 +111,8 @@ void GUIModalMenu::quitMenu()
Environment->removeFocus(this); Environment->removeFocus(this);
m_menumgr->deletingMenu(this); m_menumgr->deletingMenu(this);
this->remove(); this->remove();
if (g_touchscreengui) if (g_touchcontrols)
g_touchscreengui->show(); g_touchcontrols->show();
} }
static bool isChild(gui::IGUIElement *tocheck, gui::IGUIElement *parent) static bool isChild(gui::IGUIElement *tocheck, gui::IGUIElement *parent)

@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include "touchscreengui.h" #include "touchcontrols.h"
#include "gettime.h" #include "gettime.h"
#include "irr_v2d.h" #include "irr_v2d.h"
@ -39,7 +39,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
TouchScreenGUI *g_touchscreengui; TouchControls *g_touchcontrols;
static const char *button_image_names[] = { static const char *button_image_names[] = {
"jump_btn.png", "jump_btn.png",
@ -266,14 +266,14 @@ static EKEY_CODE id_to_keycode(touch_gui_button_id id)
code = keyname_to_keycode(resolved.c_str()); code = keyname_to_keycode(resolved.c_str());
} catch (UnknownKeycode &e) { } catch (UnknownKeycode &e) {
code = KEY_UNKNOWN; code = KEY_UNKNOWN;
warningstream << "TouchScreenGUI: Unknown key '" << resolved warningstream << "TouchControls: Unknown key '" << resolved
<< "' for '" << key << "', hiding button." << std::endl; << "' for '" << key << "', hiding button." << std::endl;
} }
return code; return code;
} }
TouchScreenGUI::TouchScreenGUI(IrrlichtDevice *device, ISimpleTextureSource *tsrc): TouchControls::TouchControls(IrrlichtDevice *device, ISimpleTextureSource *tsrc):
m_device(device), m_device(device),
m_guienv(device->getGUIEnvironment()), m_guienv(device->getGUIEnvironment()),
m_receiver(device->getEventReceiver()), m_receiver(device->getEventReceiver()),
@ -413,7 +413,7 @@ TouchScreenGUI::TouchScreenGUI(IrrlichtDevice *device, ISimpleTextureSource *tsr
} }
} }
void TouchScreenGUI::addButton(std::vector<button_info> &buttons, touch_gui_button_id id, void TouchControls::addButton(std::vector<button_info> &buttons, touch_gui_button_id id,
const std::string &image, const recti &rect, bool visible) const std::string &image, const recti &rect, bool visible)
{ {
IGUIImage *btn_gui_button = m_guienv->addImage(rect, nullptr, id); IGUIImage *btn_gui_button = m_guienv->addImage(rect, nullptr, id);
@ -426,7 +426,7 @@ void TouchScreenGUI::addButton(std::vector<button_info> &buttons, touch_gui_butt
btn.gui_button = grab_gui_element<IGUIImage>(btn_gui_button); btn.gui_button = grab_gui_element<IGUIImage>(btn_gui_button);
} }
void TouchScreenGUI::addToggleButton(std::vector<button_info> &buttons, touch_gui_button_id id, void TouchControls::addToggleButton(std::vector<button_info> &buttons, touch_gui_button_id id,
const std::string &image_1, const std::string &image_2, const recti &rect, bool visible) const std::string &image_1, const std::string &image_2, const recti &rect, bool visible)
{ {
addButton(buttons, id, image_1, rect, visible); addButton(buttons, id, image_1, rect, visible);
@ -436,7 +436,7 @@ void TouchScreenGUI::addToggleButton(std::vector<button_info> &buttons, touch_gu
btn.toggle_textures[1] = image_2; btn.toggle_textures[1] = image_2;
} }
IGUIImage *TouchScreenGUI::makeButtonDirect(touch_gui_button_id id, IGUIImage *TouchControls::makeButtonDirect(touch_gui_button_id id,
const recti &rect, bool visible) const recti &rect, bool visible)
{ {
IGUIImage *btn_gui_button = m_guienv->addImage(rect, nullptr, id); IGUIImage *btn_gui_button = m_guienv->addImage(rect, nullptr, id);
@ -447,7 +447,7 @@ IGUIImage *TouchScreenGUI::makeButtonDirect(touch_gui_button_id id,
return btn_gui_button; return btn_gui_button;
} }
bool TouchScreenGUI::isHotbarButton(const SEvent &event) bool TouchControls::isHotbarButton(const SEvent &event)
{ {
const v2s32 touch_pos = v2s32(event.TouchInput.X, event.TouchInput.Y); const v2s32 touch_pos = v2s32(event.TouchInput.X, event.TouchInput.Y);
// check if hotbar item is pressed // check if hotbar item is pressed
@ -462,14 +462,14 @@ bool TouchScreenGUI::isHotbarButton(const SEvent &event)
return false; return false;
} }
std::optional<u16> TouchScreenGUI::getHotbarSelection() std::optional<u16> TouchControls::getHotbarSelection()
{ {
auto selection = m_hotbar_selection; auto selection = m_hotbar_selection;
m_hotbar_selection = std::nullopt; m_hotbar_selection = std::nullopt;
return selection; return selection;
} }
void TouchScreenGUI::handleReleaseEvent(size_t pointer_id) void TouchControls::handleReleaseEvent(size_t pointer_id)
{ {
// By the way: Android reuses pointer IDs, so m_pointer_pos[pointer_id] // By the way: Android reuses pointer IDs, so m_pointer_pos[pointer_id]
// will be overwritten soon anyway. // will be overwritten soon anyway.
@ -516,15 +516,15 @@ void TouchScreenGUI::handleReleaseEvent(size_t pointer_id)
m_joystick_btn_bg->setVisible(false); m_joystick_btn_bg->setVisible(false);
m_joystick_btn_center->setVisible(false); m_joystick_btn_center->setVisible(false);
} else { } else {
infostream << "TouchScreenGUI::translateEvent released unknown button: " infostream << "TouchControls::translateEvent released unknown button: "
<< pointer_id << std::endl; << pointer_id << std::endl;
} }
} }
void TouchScreenGUI::translateEvent(const SEvent &event) void TouchControls::translateEvent(const SEvent &event)
{ {
if (!m_visible) { if (!m_visible) {
infostream << "TouchScreenGUI::translateEvent got event but is not visible!" infostream << "TouchControls::translateEvent got event but is not visible!"
<< std::endl; << std::endl;
return; return;
} }
@ -702,7 +702,7 @@ void TouchScreenGUI::translateEvent(const SEvent &event)
} }
} }
void TouchScreenGUI::applyJoystickStatus() void TouchControls::applyJoystickStatus()
{ {
if (m_joystick_triggers_aux1) { if (m_joystick_triggers_aux1) {
SEvent translated{}; SEvent translated{};
@ -718,7 +718,7 @@ void TouchScreenGUI::applyJoystickStatus()
} }
} }
void TouchScreenGUI::step(float dtime) void TouchControls::step(float dtime)
{ {
if (m_overflow_open) { if (m_overflow_open) {
buttons_step(m_overflow_buttons, dtime, m_device->getVideoDriver(), m_receiver, m_texturesource); buttons_step(m_overflow_buttons, dtime, m_device->getVideoDriver(), m_receiver, m_texturesource);
@ -757,17 +757,17 @@ void TouchScreenGUI::step(float dtime)
m_had_move_id = false; m_had_move_id = false;
} }
void TouchScreenGUI::resetHotbarRects() void TouchControls::resetHotbarRects()
{ {
m_hotbar_rects.clear(); m_hotbar_rects.clear();
} }
void TouchScreenGUI::registerHotbarRect(u16 index, const recti &rect) void TouchControls::registerHotbarRect(u16 index, const recti &rect)
{ {
m_hotbar_rects[index] = rect; m_hotbar_rects[index] = rect;
} }
void TouchScreenGUI::setVisible(bool visible) void TouchControls::setVisible(bool visible)
{ {
if (m_visible == visible) if (m_visible == visible)
return; return;
@ -781,14 +781,14 @@ void TouchScreenGUI::setVisible(bool visible)
updateVisibility(); updateVisibility();
} }
void TouchScreenGUI::toggleOverflowMenu() void TouchControls::toggleOverflowMenu()
{ {
releaseAll(); // must be done first releaseAll(); // must be done first
m_overflow_open = !m_overflow_open; m_overflow_open = !m_overflow_open;
updateVisibility(); updateVisibility();
} }
void TouchScreenGUI::updateVisibility() void TouchControls::updateVisibility()
{ {
bool regular_visible = m_visible && !m_overflow_open; bool regular_visible = m_visible && !m_overflow_open;
for (auto &button : m_buttons) for (auto &button : m_buttons)
@ -804,7 +804,7 @@ void TouchScreenGUI::updateVisibility()
text->setVisible(overflow_visible); text->setVisible(overflow_visible);
} }
void TouchScreenGUI::releaseAll() void TouchControls::releaseAll()
{ {
while (!m_pointer_pos.empty()) while (!m_pointer_pos.empty())
handleReleaseEvent(m_pointer_pos.begin()->first); handleReleaseEvent(m_pointer_pos.begin()->first);
@ -821,17 +821,17 @@ void TouchScreenGUI::releaseAll()
} }
} }
void TouchScreenGUI::hide() void TouchControls::hide()
{ {
setVisible(false); setVisible(false);
} }
void TouchScreenGUI::show() void TouchControls::show()
{ {
setVisible(true); setVisible(true);
} }
v2s32 TouchScreenGUI::getPointerPos() v2s32 TouchControls::getPointerPos()
{ {
if (m_draw_crosshair) if (m_draw_crosshair)
return v2s32(m_screensize.X / 2, m_screensize.Y / 2); return v2s32(m_screensize.X / 2, m_screensize.Y / 2);
@ -840,7 +840,7 @@ v2s32 TouchScreenGUI::getPointerPos()
return m_move_pos; return m_move_pos;
} }
void TouchScreenGUI::emitMouseEvent(EMOUSE_INPUT_EVENT type) void TouchControls::emitMouseEvent(EMOUSE_INPUT_EVENT type)
{ {
v2s32 pointer_pos = getPointerPos(); v2s32 pointer_pos = getPointerPos();
@ -855,7 +855,7 @@ void TouchScreenGUI::emitMouseEvent(EMOUSE_INPUT_EVENT type)
m_receiver->OnEvent(event); m_receiver->OnEvent(event);
} }
void TouchScreenGUI::applyContextControls(const TouchInteractionMode &mode) void TouchControls::applyContextControls(const TouchInteractionMode &mode)
{ {
// Since the pointed thing has already been determined when this function // Since the pointed thing has already been determined when this function
// is called, we cannot use this function to update the shootline. // is called, we cannot use this function to update the shootline.

@ -128,10 +128,10 @@ struct button_info
}; };
class TouchScreenGUI class TouchControls
{ {
public: public:
TouchScreenGUI(IrrlichtDevice *device, ISimpleTextureSource *tsrc); TouchControls(IrrlichtDevice *device, ISimpleTextureSource *tsrc);
void translateEvent(const SEvent &event); void translateEvent(const SEvent &event);
void applyContextControls(const TouchInteractionMode &mode); void applyContextControls(const TouchInteractionMode &mode);
@ -182,7 +182,7 @@ private:
s32 m_button_size; s32 m_button_size;
double m_touchscreen_threshold; double m_touchscreen_threshold;
u16 m_long_tap_delay; u16 m_long_tap_delay;
bool m_visible = true; // is the whole touch screen gui visible bool m_visible = true;
std::unordered_map<u16, recti> m_hotbar_rects; std::unordered_map<u16, recti> m_hotbar_rects;
std::optional<u16> m_hotbar_selection = std::nullopt; std::optional<u16> m_hotbar_selection = std::nullopt;
@ -273,4 +273,4 @@ private:
u64 m_place_pressed_until = 0; u64 m_place_pressed_until = 0;
}; };
extern TouchScreenGUI *g_touchscreengui; extern TouchControls *g_touchcontrols;