1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +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:
Gregor Parzefall 2023-05-29 07:30:30 +02:00 committed by GitHub
parent 6832bf044e
commit fc3d6c1dd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 56 deletions

View file

@ -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;