1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-05 19:31:04 +00:00

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

View file

@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "gui/mainmenumanager.h"
#include "clouds.h"
#include "gui/touchscreengui.h"
#include "gui/touchcontrols.h"
#include "server.h"
#include "filesys.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();
if (g_touchscreengui) {
delete g_touchscreengui;
g_touchscreengui = NULL;
if (g_touchcontrols) {
delete g_touchcontrols;
g_touchcontrols = NULL;
}
/* Save the settings when leaving the game.

View file

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

View file

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

View file

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