mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-17 10:25:21 +02:00
Only apply "touch_punch_gesture" when wielded item has no on_use callback (#15098)
This commit is contained in:
@@ -3357,7 +3357,7 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud)
|
||||
infostream << "Pointing at " << pointed.dump() << std::endl;
|
||||
|
||||
if (g_touchcontrols) {
|
||||
auto mode = selected_def.touch_interaction.getMode(pointed.type);
|
||||
auto mode = selected_def.touch_interaction.getMode(selected_def, pointed.type);
|
||||
g_touchcontrols->applyContextControls(mode);
|
||||
// applyContextControls may change dig/place input.
|
||||
// Update again so that TOSERVER_INTERACT packets have the correct controls set.
|
||||
|
@@ -45,7 +45,8 @@ TouchInteraction::TouchInteraction()
|
||||
pointed_object = TouchInteractionMode_USER;
|
||||
}
|
||||
|
||||
TouchInteractionMode TouchInteraction::getMode(PointedThingType pointed_type) const
|
||||
TouchInteractionMode TouchInteraction::getMode(const ItemDefinition &selected_def,
|
||||
PointedThingType pointed_type) const
|
||||
{
|
||||
TouchInteractionMode result;
|
||||
switch (pointed_type) {
|
||||
@@ -63,7 +64,9 @@ TouchInteractionMode TouchInteraction::getMode(PointedThingType pointed_type) co
|
||||
}
|
||||
|
||||
if (result == TouchInteractionMode_USER) {
|
||||
if (pointed_type == POINTEDTHING_OBJECT)
|
||||
if (pointed_type == POINTEDTHING_OBJECT && !selected_def.usable)
|
||||
// Only apply when we're actually able to punch the object, i.e. when
|
||||
// the selected item has no on_use callback defined.
|
||||
result = g_settings->get("touch_punch_gesture") == "long_tap" ?
|
||||
LONG_DIG_SHORT_PLACE : SHORT_DIG_LONG_PLACE;
|
||||
else
|
||||
|
@@ -71,7 +71,8 @@ struct TouchInteraction
|
||||
TouchInteraction();
|
||||
// Returns the right mode for the pointed thing and resolves any occurrence
|
||||
// of TouchInteractionMode_USER into an actual mode.
|
||||
TouchInteractionMode getMode(PointedThingType pointed_type) const;
|
||||
TouchInteractionMode getMode(const ItemDefinition &selected_def,
|
||||
PointedThingType pointed_type) const;
|
||||
void serialize(std::ostream &os) const;
|
||||
void deSerialize(std::istream &is);
|
||||
};
|
||||
|
Reference in New Issue
Block a user