Skip to content

Commit

Permalink
"enum class TouchControlMode" -> "enum TouchControlMode : u8"
Browse files Browse the repository at this point in the history
  • Loading branch information
grorp committed Jan 2, 2024
1 parent 857b367 commit 951129b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/gui/touchscreengui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ void TouchScreenGUI::applyContextControls(const TouchInteractionMode &mode)

switch (m_tap_state) {
case TapState::ShortTap:
if (mode == TouchInteractionMode::ShortDigLongPlace) {
if (mode == SHORT_DIG_LONG_PLACE) {
if (!m_dig_pressed) {
// The button isn't currently pressed, we can press it.
m_dig_pressed_until = now + SIMULATED_CLICK_DURATION_MS;
Expand Down Expand Up @@ -1118,7 +1118,7 @@ void TouchScreenGUI::applyContextControls(const TouchInteractionMode &mode)
break;

case TapState::LongTap:
if (mode == TouchInteractionMode::ShortDigLongPlace)
if (mode == SHORT_DIG_LONG_PLACE)
target_place_pressed = true;
else
target_dig_pressed = true;
Expand Down
1 change: 0 additions & 1 deletion src/gui/touchscreengui.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "itemdef.h"
#include "client/tile.h"
#include "client/game.h"
#include "util/pointedthing.h"

using namespace irr;
using namespace irr::core;
Expand Down
12 changes: 6 additions & 6 deletions src/itemdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,

TouchInteraction::TouchInteraction()
{
pointed_nothing = TouchInteractionMode::LongDigShortPlace;
pointed_node = TouchInteractionMode::LongDigShortPlace;
pointed_nothing = LONG_DIG_SHORT_PLACE;
pointed_node = LONG_DIG_SHORT_PLACE;
// Map punching to single tap by default.
pointed_object = TouchInteractionMode::ShortDigLongPlace;
pointed_object = SHORT_DIG_LONG_PLACE;
}

TouchInteractionMode TouchInteraction::getMode(const PointedThing &pointed) const
Expand All @@ -63,9 +63,9 @@ TouchInteractionMode TouchInteraction::getMode(const PointedThing &pointed) cons

void TouchInteraction::serialize(std::ostream &os) const
{
writeU8(os, (u8)pointed_nothing);
writeU8(os, (u8)pointed_node);
writeU8(os, (u8)pointed_object);
writeU8(os, pointed_nothing);
writeU8(os, pointed_node);
writeU8(os, pointed_object);
}

void TouchInteraction::deSerialize(std::istream &is)
Expand Down
6 changes: 3 additions & 3 deletions src/itemdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ enum ItemType
ITEM_TOOL,
};

enum class TouchInteractionMode
enum TouchInteractionMode : u8
{
LongDigShortPlace,
ShortDigLongPlace,
LONG_DIG_SHORT_PLACE,
SHORT_DIG_LONG_PLACE,
};

struct TouchInteraction
Expand Down
12 changes: 6 additions & 6 deletions src/script/common/c_content.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ void read_item_definition(lua_State* L, int index,

TouchInteraction &inter = def.touch_interaction;
inter.pointed_nothing = (TouchInteractionMode)getenumfield(L, -1, "pointed_nothing",
es_TouchControlMode, (int)inter.pointed_nothing);
es_TouchControlMode, inter.pointed_nothing);
inter.pointed_node = (TouchInteractionMode)getenumfield(L, -1, "pointed_node",
es_TouchControlMode, (int)inter.pointed_node);
es_TouchControlMode, inter.pointed_node);
inter.pointed_object = (TouchInteractionMode)getenumfield(L, -1, "pointed_object",
es_TouchControlMode, (int)inter.pointed_object);
es_TouchControlMode, inter.pointed_object);
}
lua_pop(L, 1);
}
Expand Down Expand Up @@ -212,11 +212,11 @@ void push_item_definition_full(lua_State *L, const ItemDefinition &i)

lua_createtable(L, 0, 3);
const TouchInteraction &inter = i.touch_interaction;
lua_pushstring(L, es_TouchControlMode[(int)inter.pointed_nothing].str);
lua_pushstring(L, es_TouchControlMode[inter.pointed_nothing].str);
lua_setfield(L, -2,"pointed_nothing");
lua_pushstring(L, es_TouchControlMode[(int)inter.pointed_node].str);
lua_pushstring(L, es_TouchControlMode[inter.pointed_node].str);
lua_setfield(L, -2,"pointed_node");
lua_pushstring(L, es_TouchControlMode[(int)inter.pointed_object].str);
lua_pushstring(L, es_TouchControlMode[inter.pointed_object].str);
lua_setfield(L, -2,"pointed_object");
lua_setfield(L, -2, "touch_interaction");
}
Expand Down
4 changes: 2 additions & 2 deletions src/script/common/c_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct EnumString es_ItemType[] =

struct EnumString es_TouchControlMode[] =
{
{(int)TouchInteractionMode::LongDigShortPlace, "long_dig_short_place"},
{(int)TouchInteractionMode::ShortDigLongPlace, "short_dig_long_place"},
{LONG_DIG_SHORT_PLACE, "long_dig_short_place"},
{SHORT_DIG_LONG_PLACE, "short_dig_long_place"},
{0, NULL},
};

0 comments on commit 951129b

Please sign in to comment.