mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-26 18:21:04 +00:00
Place nodes with single tap on Android (+ bugfix) (#13187)
Don't place nodes when closing button bars. Update docs (also in-game). Rename "Default controls" -> "Controls" in Android pause menu since players can't change them (normally), so calling them "default" doesn't make sense.
This commit is contained in:
parent
6832bf044e
commit
fc3d6c1dd9
4 changed files with 23 additions and 56 deletions
|
@ -4335,14 +4335,14 @@ void Game::showDeathFormspec()
|
|||
void Game::showPauseMenu()
|
||||
{
|
||||
#ifdef HAVE_TOUCHSCREENGUI
|
||||
static const std::string control_text = strgettext("Default Controls:\n"
|
||||
"No menu visible:\n"
|
||||
"- single tap: button activate\n"
|
||||
"- double tap: place/use\n"
|
||||
static const std::string control_text = strgettext("Controls:\n"
|
||||
"No menu open:\n"
|
||||
"- slide finger: look around\n"
|
||||
"Menu/Inventory visible:\n"
|
||||
"- tap: place/use\n"
|
||||
"- long tap: dig/punch/use\n"
|
||||
"Menu/inventory open:\n"
|
||||
"- double tap (outside):\n"
|
||||
" -->close\n"
|
||||
" --> close\n"
|
||||
"- touch stack, touch slot:\n"
|
||||
" --> move stack\n"
|
||||
"- touch&drag, tap 2nd finger\n"
|
||||
|
|
|
@ -692,9 +692,8 @@ void TouchScreenGUI::handleReleaseEvent(size_t evt_id)
|
|||
}
|
||||
m_receiver->OnEvent(*translated);
|
||||
delete translated;
|
||||
} else {
|
||||
// do double tap detection
|
||||
doubleTapDetection();
|
||||
} else if (!m_move_has_really_moved) {
|
||||
doRightClick();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -773,8 +772,11 @@ void TouchScreenGUI::translateEvent(const SEvent &event)
|
|||
// already handled in isSettingsBarButton()
|
||||
} else {
|
||||
// handle non button events
|
||||
m_settingsbar.deactivate();
|
||||
m_rarecontrolsbar.deactivate();
|
||||
if (m_settingsbar.active() || m_rarecontrolsbar.active()) {
|
||||
m_settingsbar.deactivate();
|
||||
m_rarecontrolsbar.deactivate();
|
||||
return;
|
||||
}
|
||||
|
||||
s32 dxj = event.TouchInput.X - button_size * 5.0f / 2.0f;
|
||||
s32 dyj = event.TouchInput.Y - (s32)m_screensize.Y + button_size * 5.0f / 2.0f;
|
||||
|
@ -999,29 +1001,9 @@ void TouchScreenGUI::handleChangedButton(const SEvent &event)
|
|||
event.TouchInput.ID, true);
|
||||
}
|
||||
|
||||
bool TouchScreenGUI::doubleTapDetection()
|
||||
bool TouchScreenGUI::doRightClick()
|
||||
{
|
||||
m_key_events[0].down_time = m_key_events[1].down_time;
|
||||
m_key_events[0].x = m_key_events[1].x;
|
||||
m_key_events[0].y = m_key_events[1].y;
|
||||
m_key_events[1].down_time = m_move_downtime;
|
||||
m_key_events[1].x = m_move_downlocation.X;
|
||||
m_key_events[1].y = m_move_downlocation.Y;
|
||||
|
||||
u64 delta = porting::getDeltaMs(m_key_events[0].down_time, porting::getTimeMs());
|
||||
if (delta > 400)
|
||||
return false;
|
||||
|
||||
double distance = sqrt(
|
||||
(m_key_events[0].x - m_key_events[1].x) *
|
||||
(m_key_events[0].x - m_key_events[1].x) +
|
||||
(m_key_events[0].y - m_key_events[1].y) *
|
||||
(m_key_events[0].y - m_key_events[1].y));
|
||||
|
||||
if (distance > (20 + m_touchscreen_threshold))
|
||||
return false;
|
||||
|
||||
v2s32 mPos = v2s32(m_key_events[0].x, m_key_events[0].y);
|
||||
v2s32 mPos = v2s32(m_move_downlocation.X, m_move_downlocation.Y);
|
||||
if (m_draw_crosshair) {
|
||||
mPos.X = m_screensize.X / 2;
|
||||
mPos.Y = m_screensize.Y / 2;
|
||||
|
@ -1111,10 +1093,6 @@ void TouchScreenGUI::step(float dtime)
|
|||
if (!button.ids.empty()) {
|
||||
button.repeatcounter += dtime;
|
||||
|
||||
// in case we're moving around digging does not happen
|
||||
if (m_has_move_id)
|
||||
m_move_has_really_moved = true;
|
||||
|
||||
if (button.repeatcounter < button.repeatdelay)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -130,6 +130,9 @@ public:
|
|||
// step handler
|
||||
void step(float dtime);
|
||||
|
||||
// return whether the button bar is active
|
||||
bool active() { return m_active; }
|
||||
|
||||
// deactivate button bar
|
||||
void deactivate();
|
||||
|
||||
|
@ -284,8 +287,8 @@ private:
|
|||
// handle pressed hud buttons
|
||||
bool isHUDButton(const SEvent &event);
|
||||
|
||||
// handle double taps
|
||||
bool doubleTapDetection();
|
||||
// do a right-click
|
||||
bool doRightClick();
|
||||
|
||||
// handle release event
|
||||
void handleReleaseEvent(size_t evt_id);
|
||||
|
@ -293,20 +296,9 @@ private:
|
|||
// apply joystick status
|
||||
void applyJoystickStatus();
|
||||
|
||||
// double-click detection variables
|
||||
struct key_event
|
||||
{
|
||||
u64 down_time;
|
||||
s32 x;
|
||||
s32 y;
|
||||
};
|
||||
|
||||
// array for saving last known position of a pointer
|
||||
std::map<size_t, v2s32> m_pointerpos;
|
||||
|
||||
// array for double tap detection
|
||||
key_event m_key_events[2];
|
||||
|
||||
// settings bar
|
||||
AutoHideButtonBar m_settingsbar;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue