mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Touchscreen: Allow mods to swap the meaning of short and long taps (punch with single tap) (#14087)
This works through a new field "touch_interaction" in item definitions. The two most important use cases are: - Punching players/entities with short tap instead of long tap (enabled by default) - Making items usable that require holding the place button (e.g. bows and shields in MC-like games)
This commit is contained in:
parent
8cbd629010
commit
404a063fdf
10 changed files with 288 additions and 108 deletions
|
@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
class IGameDef;
|
||||
class Client;
|
||||
struct ToolCapabilities;
|
||||
struct PointedThing;
|
||||
#ifndef SERVER
|
||||
#include "client/tile.h"
|
||||
struct ItemMesh;
|
||||
|
@ -50,6 +51,25 @@ enum ItemType : u8
|
|||
ItemType_END // Dummy for validity check
|
||||
};
|
||||
|
||||
enum TouchInteractionMode : u8
|
||||
{
|
||||
LONG_DIG_SHORT_PLACE,
|
||||
SHORT_DIG_LONG_PLACE,
|
||||
TouchInteractionMode_END, // Dummy for validity check
|
||||
};
|
||||
|
||||
struct TouchInteraction
|
||||
{
|
||||
TouchInteractionMode pointed_nothing;
|
||||
TouchInteractionMode pointed_node;
|
||||
TouchInteractionMode pointed_object;
|
||||
|
||||
TouchInteraction();
|
||||
TouchInteractionMode getMode(const PointedThing &pointed) const;
|
||||
void serialize(std::ostream &os) const;
|
||||
void deSerialize(std::istream &is);
|
||||
};
|
||||
|
||||
struct ItemDefinition
|
||||
{
|
||||
/*
|
||||
|
@ -92,6 +112,8 @@ struct ItemDefinition
|
|||
std::optional<u8> place_param2;
|
||||
bool wallmounted_rotate_vertical;
|
||||
|
||||
TouchInteraction touch_interaction;
|
||||
|
||||
/*
|
||||
Some helpful methods
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue