From b7a313a574435474a503358a0e1d7126fb2f5c30 Mon Sep 17 00:00:00 2001 From: Deve Date: Mon, 14 Nov 2022 00:45:49 +0100 Subject: [PATCH] TouchScreenGUI: Better handle punch/interact --- src/client/game.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/client/game.cpp b/src/client/game.cpp index ac6d138d8..45dc2e52e 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -3627,11 +3627,17 @@ void Game::handlePointingAtObject(const PointedThing &pointed, tool_item.getDefinition(itemdef_manager); bool nohit_enabled = ((ItemGroupList) playeritem_def.groups)["nohit"] != 0; + bool should_punch = isKeyDown(KeyType::DIG) && !nohit_enabled; + bool should_interact = wasKeyPressed(KeyType::PLACE) || ((wasKeyPressed(KeyType::DIG) && nohit_enabled)); + #ifdef HAVE_TOUCHSCREENGUI - if (wasKeyPressed(KeyType::PLACE) && !nohit_enabled) { -#else - if (isKeyDown(KeyType::DIG) && !nohit_enabled) { + if (g_touchscreengui->isActive()) { + should_punch = wasKeyPressed(KeyType::PLACE) && !nohit_enabled; + should_interact = wasKeyPressed(KeyType::DIG) || ((wasKeyPressed(KeyType::PLACE) && nohit_enabled)); + } #endif + + if (should_punch) { bool do_punch = false; bool do_punch_damage = false; @@ -3661,11 +3667,7 @@ void Game::handlePointingAtObject(const PointedThing &pointed, if (!disable_send) client->interact(INTERACT_START_DIGGING, pointed); } -#ifdef HAVE_TOUCHSCREENGUI - } else if (wasKeyPressed(KeyType::DIG) || (wasKeyPressed(KeyType::PLACE) && nohit_enabled)) { -#else - } else if (wasKeyPressed(KeyType::PLACE) || (wasKeyPressed(KeyType::DIG) && nohit_enabled)) { -#endif + } else if (should_interact) { infostream << "Right-clicked object" << std::endl; client->interact(INTERACT_PLACE, pointed); // place }