diff --git a/build/android/icons/camera_btn.svg b/build/android/icons/camera_btn.svg deleted file mode 100644 index a91a7fcf8..000000000 --- a/build/android/icons/camera_btn.svg +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/chat_btn.svg b/build/android/icons/chat_btn.svg deleted file mode 100644 index 41dc6f8c7..000000000 --- a/build/android/icons/chat_btn.svg +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/down.svg b/build/android/icons/down.svg deleted file mode 100644 index 190e7e875..000000000 --- a/build/android/icons/down.svg +++ /dev/null @@ -1,542 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/drop_btn.svg b/build/android/icons/drop_btn.svg deleted file mode 100644 index 7cb0e8532..000000000 --- a/build/android/icons/drop_btn.svg +++ /dev/null @@ -1,173 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/joystick_bg.svg b/build/android/icons/joystick_bg.svg deleted file mode 100644 index d8836b358..000000000 --- a/build/android/icons/joystick_bg.svg +++ /dev/null @@ -1,876 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/joystick_center.svg b/build/android/icons/joystick_center.svg deleted file mode 100644 index 17202290a..000000000 --- a/build/android/icons/joystick_center.svg +++ /dev/null @@ -1,877 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/joystick_off.svg b/build/android/icons/joystick_off.svg deleted file mode 100644 index 58e1acf22..000000000 --- a/build/android/icons/joystick_off.svg +++ /dev/null @@ -1,882 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/jump_btn.svg b/build/android/icons/jump_btn.svg deleted file mode 100644 index 882c49ed7..000000000 --- a/build/android/icons/jump_btn.svg +++ /dev/null @@ -1,547 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/minimap_btn.svg b/build/android/icons/minimap_btn.svg deleted file mode 100644 index deda32717..000000000 --- a/build/android/icons/minimap_btn.svg +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/rangeview_btn.svg b/build/android/icons/rangeview_btn.svg deleted file mode 100644 index f9319e0b5..000000000 --- a/build/android/icons/rangeview_btn.svg +++ /dev/null @@ -1,456 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/touchscreengui.cpp b/src/gui/touchscreengui.cpp index 6e59e2b40..e326d5b91 100644 --- a/src/gui/touchscreengui.cpp +++ b/src/gui/touchscreengui.cpp @@ -2,6 +2,7 @@ Copyright (C) 2014 sapier Copyright (C) 2018 srifqi, Muhammad Rifqi Priyo Susanto +Copyright (C) 2014-2020 Maksim Gamarnik [MoNTE48] MoNTE48@mail.ua This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -38,9 +39,16 @@ using namespace irr::core; const char **button_imagenames = (const char *[]) { "jump_btn.png", - "down.png", - "zoom.png", - "aux_btn.png" + "drop_btn.png", + "down_btn.png", + //"zoom.png", + //"aux_btn.png", + "inventory_btn.png", + "escape_btn.png", + "minimap_btn.png", + "rangeview_btn.png", + "camera_btn.png", + "chat_btn.png" }; const char **joystick_imagenames = (const char *[]) { @@ -77,12 +85,12 @@ static irr::EKEY_CODE id2keycode(touch_gui_button_id id) case crunch_id: key = "sneak"; break; - case zoom_id: + /*case zoom_id: key = "zoom"; break; case special1_id: key = "special1"; - break; + break;*/ case fly_id: key = "freemove"; break; @@ -110,6 +118,8 @@ static irr::EKEY_CODE id2keycode(touch_gui_button_id id) case range_id: key = "rangeselect"; break; + case escape_id: + return irr::KEY_ESCAPE; default: break; } @@ -475,46 +485,62 @@ void TouchScreenGUI::init(ISimpleTextureSource *tsrc) */ if (m_fixed_joystick) { m_joystick_btn_off = initJoystickButton(joystick_off_id, - rect(button_size, - m_screensize.Y - button_size * 4, - button_size * 4, - m_screensize.Y - button_size), 0); + rect(button_size / 2, + m_screensize.Y - button_size * 4.5, + button_size * 4.5, + m_screensize.Y - button_size / 2), 0); } else { m_joystick_btn_off = initJoystickButton(joystick_off_id, - rect(button_size, - m_screensize.Y - button_size * 3, - button_size * 3, - m_screensize.Y - button_size), 0); + rect(button_size / 2, + m_screensize.Y - button_size * 3.5, + button_size * 3.5, + m_screensize.Y - button_size / 2), 0); } m_joystick_btn_bg = initJoystickButton(joystick_bg_id, - rect(button_size, - m_screensize.Y - button_size * 4, - button_size * 4, - m_screensize.Y - button_size), + rect(button_size / 2, + m_screensize.Y - button_size * 4.5, + button_size * 4.5, + m_screensize.Y - button_size / 2), 1, false); m_joystick_btn_center = initJoystickButton(joystick_center_id, - rect(0, 0, button_size, button_size), 2, false); + rect(0, 0, button_size * 1.5, button_size * 1.5), 2, false); // init jump button initButton(jump_id, - rect(m_screensize.X - (1.75 * button_size), - m_screensize.Y - button_size, - m_screensize.X - (0.25 * button_size), - m_screensize.Y), + rect(m_screensize.X - button_size * 3, + m_screensize.Y - button_size * 3, + m_screensize.X - button_size * 1.5, + m_screensize.Y - button_size * 1.5), L"x", false); + // init drop button + initButton(drop_id, + rect(m_screensize.X - button_size, + m_screensize.Y / 2 - button_size * 1.5, + m_screensize.X, + m_screensize.Y / 2 - button_size / 2), + L"drop", false); + // init crunch button initButton(crunch_id, - rect(m_screensize.X - (3.25 * button_size), - m_screensize.Y - button_size, - m_screensize.X - (1.75 * button_size), - m_screensize.Y), + rect(m_screensize.X - button_size * 3, + m_screensize.Y - button_size / 1.5, + m_screensize.X - button_size * 1.5, + m_screensize.Y), L"H", false); + // init inventory button + initButton(inventory_id, + rect(m_screensize.X - button_size * 1.5, + m_screensize.Y - button_size * 1.5, + m_screensize.X, + m_screensize.Y), + L"inv", false); + // init zoom button - initButton(zoom_id, +/* initButton(zoom_id, rect(m_screensize.X - (1.25 * button_size), m_screensize.Y - (4 * button_size), m_screensize.X - (0.25 * button_size), @@ -543,9 +569,6 @@ void TouchScreenGUI::init(ISimpleTextureSource *tsrc) m_settingsbar.addButton(noclip_id, L"noclip", "noclip_btn.png"); m_settingsbar.addButton(fast_id, L"fast", "fast_btn.png"); m_settingsbar.addButton(debug_id, L"debug", "debug_btn.png"); - m_settingsbar.addButton(camera_id, L"camera", "camera_btn.png"); - m_settingsbar.addButton(range_id, L"rangeview", "rangeview_btn.png"); - m_settingsbar.addButton(minimap_id, L"minimap", "minimap_btn.png"); // Chat is shown by default, so chat_hide_btn.png is shown first. m_settingsbar.addToggleButton(toggle_chat_id, L"togglechat", @@ -563,7 +586,60 @@ void TouchScreenGUI::init(ISimpleTextureSource *tsrc) m_rarecontrolsbar.addButton(chat_id, L"Chat", "chat_btn.png"); m_rarecontrolsbar.addButton(inventory_id, L"inv", "inventory_btn.png"); - m_rarecontrolsbar.addButton(drop_id, L"drop", "drop_btn.png"); + m_rarecontrolsbar.addButton(drop_id, L"drop", "drop_btn.png");*/ + + const bool minimap = g_settings->getBool("enable_minimap"); + + double button_075 = 1; + s32 button_05 = 1; + double button_05b = 0; + if (!minimap) { + button_075 = 0.75; + button_05 = 2; + button_05b = button_size * 0.5; + } + + // init pause button [1] + initButton(escape_id, + rect(m_screensize.X / 2 - button_size * 2 * button_075, + 0, + m_screensize.X / 2 - button_size / button_05, + button_size), + L"Exit", false); + + // init minimap button [2] + if (minimap) { + initButton(minimap_id, + rect(m_screensize.X / 2 - button_size, + 0, + m_screensize.X / 2, + button_size), + L"minimap", false); + } + + // init rangeselect button [3] + initButton(range_id, + rect(m_screensize.X / 2 - button_05b, + 0, + m_screensize.X / 2 + button_size / button_05, + button_size), + L"rangeview", false); + + // init camera button [4] + initButton(camera_id, + rect(m_screensize.X / 2 + button_size / button_05, + 0, + m_screensize.X / 2 + button_size * 2 * button_075, + button_size), + L"camera", false); + + // init chat button + initButton(chat_id, + rect(m_screensize.X - button_size * 1.25, + 0, + m_screensize.X, + button_size), + L"Chat", false); } touch_gui_button_id TouchScreenGUI::getButtonID(s32 x, s32 y) @@ -666,7 +742,6 @@ void TouchScreenGUI::handleReleaseEvent(size_t evt_id) { touch_gui_button_id button = getButtonID(evt_id); - if (button != after_last_element_id) { // handle button events handleButtonEvent(button, evt_id, false); @@ -687,9 +762,24 @@ void TouchScreenGUI::handleReleaseEvent(size_t evt_id) translated->MouseInput.Event = EMIE_LMOUSE_LEFT_UP; m_receiver->OnEvent(*translated); delete translated; - } else { - // do double tap detection - doubleTapDetection(); + } else if (!m_move_has_really_moved) { + auto *translated = new SEvent; + memset(translated, 0, sizeof(SEvent)); + translated->EventType = EET_MOUSE_INPUT_EVENT; + translated->MouseInput.X = m_move_downlocation.X; + translated->MouseInput.Y = m_move_downlocation.Y; + translated->MouseInput.Shift = false; + translated->MouseInput.Control = false; + translated->MouseInput.ButtonStates = 0; + translated->MouseInput.Event = EMIE_LMOUSE_LEFT_UP; + m_receiver->OnEvent(*translated); + delete translated; + quickTapDetection(); + m_shootline = m_device + ->getSceneManager() + ->getSceneCollisionManager() + ->getRayFromScreenCoordinates( + v2s32(m_move_downlocation.X, m_move_downlocation.Y)); } } @@ -720,6 +810,66 @@ void TouchScreenGUI::handleReleaseEvent(size_t evt_id) } } +void TouchScreenGUI::moveJoystick(const SEvent &event, float dx, float dy) { + m_joystick_has_really_moved = true; + double distance = sqrt(dx * dx + dy * dy); + + // angle in degrees + double angle = acos(dx / distance) * 180 / M_PI; + if (dy < 0) + angle *= -1; + // rotate to make comparing easier + angle = fmod(angle + 180 + 22.5, 360); + + // reset state before applying + for (bool & joystick_status : m_joystick_status) + joystick_status = false; + + if (distance <= m_touchscreen_threshold) { + // do nothing + } else if (angle < 45) + m_joystick_status[j_left] = true; + else if (angle < 90) { + m_joystick_status[j_forward] = true; + m_joystick_status[j_left] = true; + } else if (angle < 135) + m_joystick_status[j_forward] = true; + else if (angle < 180) { + m_joystick_status[j_forward] = true; + m_joystick_status[j_right] = true; + } else if (angle < 225) + m_joystick_status[j_right] = true; + else if (angle < 270) { + m_joystick_status[j_backward] = true; + m_joystick_status[j_right] = true; + } else if (angle < 315) + m_joystick_status[j_backward] = true; + else if (angle <= 360) { + m_joystick_status[j_backward] = true; + m_joystick_status[j_left] = true; + } + + if (distance > button_size * 1.5) { + m_joystick_status[j_special1] = true; + // move joystick "button" + s32 ndx = button_size * dx / distance * 1.5f - button_size / 2.0f * 1.5f; + s32 ndy = button_size * dy / distance * 1.5f - button_size / 2.0f * 1.5f; + if (m_fixed_joystick) { + m_joystick_btn_center->guibutton->setRelativePosition(v2s32( + button_size * 5 / 2 + ndx, + m_screensize.Y - button_size * 5 / 2 + ndy)); + } else { + m_joystick_btn_center->guibutton->setRelativePosition(v2s32( + m_pointerpos[event.TouchInput.ID].X + ndx, + m_pointerpos[event.TouchInput.ID].Y + ndy)); + } + } else { + m_joystick_btn_center->guibutton->setRelativePosition(v2s32( + event.TouchInput.X - button_size / 2.0f * 1.5f, + event.TouchInput.Y - button_size / 2.0f * 1.5f)); + } +} + void TouchScreenGUI::translateEvent(const SEvent &event) { if (!m_visible) { @@ -752,22 +902,22 @@ void TouchScreenGUI::translateEvent(const SEvent &event) // handle button events if (button != after_last_element_id) { handleButtonEvent(button, eventID, true); - m_settingsbar.deactivate(); - m_rarecontrolsbar.deactivate(); + //m_settingsbar.deactivate(); + //m_rarecontrolsbar.deactivate(); } else if (isHUDButton(event)) { - m_settingsbar.deactivate(); - m_rarecontrolsbar.deactivate(); + //m_settingsbar.deactivate(); + //m_rarecontrolsbar.deactivate(); // already handled in isHUDButton() } else if (m_settingsbar.isButton(event)) { - m_rarecontrolsbar.deactivate(); + //m_rarecontrolsbar.deactivate(); // already handled in isSettingsBarButton() } else if (m_rarecontrolsbar.isButton(event)) { - m_settingsbar.deactivate(); + //m_settingsbar.deactivate(); // already handled in isSettingsBarButton() } else { // handle non button events - m_settingsbar.deactivate(); - m_rarecontrolsbar.deactivate(); + //m_settingsbar.deactivate(); + //m_rarecontrolsbar.deactivate(); s32 dxj = event.TouchInput.X - button_size * 5.0f / 2.0f; s32 dyj = event.TouchInput.Y - m_screensize.Y + button_size * 5.0f / 2.0f; @@ -775,8 +925,11 @@ void TouchScreenGUI::translateEvent(const SEvent &event) /* Select joystick when left 1/3 of screen dragged or * when joystick tapped (fixed joystick position) */ - if ((m_fixed_joystick && dxj * dxj + dyj * dyj <= button_size * button_size * 1.5 * 1.5) || - (!m_fixed_joystick && event.TouchInput.X < m_screensize.X / 3.0f)) { + bool inside_joystick = + m_fixed_joystick + ? dxj * dxj + dyj * dyj <= button_size * button_size * 1.5 * 1.5 + : event.TouchInput.X < m_screensize.X / 3.0f; + if (inside_joystick) { // If we don't already have a starting point for joystick make this the one. if (m_joystick_id == -1) { m_joystick_id = event.TouchInput.ID; @@ -787,14 +940,16 @@ void TouchScreenGUI::translateEvent(const SEvent &event) m_joystick_btn_center->guibutton->setVisible(true); // If it's a fixed joystick, don't move the joystick "button". - if (!m_fixed_joystick) + if (m_fixed_joystick) { + moveJoystick(event, dxj, dyj); + } else { m_joystick_btn_bg->guibutton->setRelativePosition(v2s32( - event.TouchInput.X - button_size * 3.0f / 2.0f, - event.TouchInput.Y - button_size * 3.0f / 2.0f)); - - m_joystick_btn_center->guibutton->setRelativePosition(v2s32( - event.TouchInput.X - button_size / 2.0f, - event.TouchInput.Y - button_size / 2.0f)); + event.TouchInput.X - button_size * 3.0f / 1.5f, + event.TouchInput.Y - button_size * 3.0f / 1.5f)); + m_joystick_btn_center->guibutton->setRelativePosition(v2s32( + event.TouchInput.X - button_size / 2.0f * 1.5f, + event.TouchInput.Y - button_size / 2.0f * 1.5f)); + } } } else { // If we don't already have a moving point make this the moving one. @@ -842,7 +997,7 @@ void TouchScreenGUI::translateEvent(const SEvent &event) s32 dy = Y - m_pointerpos[event.TouchInput.ID].Y; // adapt to similar behaviour as pc screen - double d = g_settings->getFloat("mouse_sensitivity") * 3.0f; + double d = g_settings->getFloat("mouse_sensitivity"); m_camera_yaw_change -= dx * d; m_camera_pitch = MYMIN(MYMAX(m_camera_pitch + (dy * d), -180), 180); @@ -875,8 +1030,6 @@ void TouchScreenGUI::translateEvent(const SEvent &event) dy = Y - m_screensize.Y + button_size * 5 / 2; } - double distance_sq = dx * dx + dy * dy; - s32 dxj = event.TouchInput.X - button_size * 5.0f / 2.0f; s32 dyj = event.TouchInput.Y - m_screensize.Y + button_size * 5.0f / 2.0f; bool inside_joystick = (dxj * dxj + dyj * dyj <= button_size * button_size * 1.5 * 1.5); @@ -884,63 +1037,8 @@ void TouchScreenGUI::translateEvent(const SEvent &event) if (m_joystick_has_really_moved || (!m_joystick_has_really_moved && inside_joystick) || (!m_fixed_joystick && - distance_sq > m_touchscreen_threshold * m_touchscreen_threshold)) { - m_joystick_has_really_moved = true; - double distance = sqrt(distance_sq); - - // angle in degrees - double angle = acos(dx / distance) * 180 / M_PI; - if (dy < 0) - angle *= -1; - // rotate to make comparing easier - angle = fmod(angle + 180 + 22.5, 360); - - // reset state before applying - for (bool & joystick_status : m_joystick_status) - joystick_status = false; - - if (distance <= m_touchscreen_threshold) { - // do nothing - } else if (angle < 45) - m_joystick_status[j_left] = true; - else if (angle < 90) { - m_joystick_status[j_forward] = true; - m_joystick_status[j_left] = true; - } else if (angle < 135) - m_joystick_status[j_forward] = true; - else if (angle < 180) { - m_joystick_status[j_forward] = true; - m_joystick_status[j_right] = true; - } else if (angle < 225) - m_joystick_status[j_right] = true; - else if (angle < 270) { - m_joystick_status[j_backward] = true; - m_joystick_status[j_right] = true; - } else if (angle < 315) - m_joystick_status[j_backward] = true; - else if (angle <= 360) { - m_joystick_status[j_backward] = true; - m_joystick_status[j_left] = true; - } - - if (distance > button_size) { - m_joystick_status[j_special1] = true; - // move joystick "button" - s32 ndx = button_size * dx / distance - button_size / 2.0f; - s32 ndy = button_size * dy / distance - button_size / 2.0f; - if (m_fixed_joystick) { - m_joystick_btn_center->guibutton->setRelativePosition(v2s32( - button_size * 5 / 2 + ndx, - m_screensize.Y - button_size * 5 / 2 + ndy)); - } else { - m_joystick_btn_center->guibutton->setRelativePosition(v2s32( - m_pointerpos[event.TouchInput.ID].X + ndx, - m_pointerpos[event.TouchInput.ID].Y + ndy)); - } - } else { - m_joystick_btn_center->guibutton->setRelativePosition( - v2s32(X - button_size / 2, Y - button_size / 2)); - } + dx * dx + dy * dy > m_touchscreen_threshold * m_touchscreen_threshold)) { + moveJoystick(event, dx, dy); } } @@ -988,26 +1086,16 @@ void TouchScreenGUI::handleChangedButton(const SEvent &event) event.TouchInput.ID, true); } -bool TouchScreenGUI::doubleTapDetection() +// Punch or left click +bool TouchScreenGUI::quickTapDetection() { 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)) + // ignore the occasional touch + u64 delta = porting::getDeltaMs(m_move_downtime, porting::getTimeMs()); + if (delta < 50) return false; auto *translated = new SEvent(); @@ -1088,10 +1176,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_move_id != -1) - m_move_has_really_moved = true; - if (button.repeatcounter < button.repeatdelay) continue; @@ -1120,7 +1204,6 @@ void TouchScreenGUI::step(float dtime) if ((m_move_id != -1) && (!m_move_has_really_moved) && (!m_move_sent_as_mouse_event)) { - u64 delta = porting::getDeltaMs(m_move_downtime, porting::getTimeMs()); if (delta > MIN_DIG_TIME_MS) { @@ -1128,7 +1211,7 @@ void TouchScreenGUI::step(float dtime) ->getSceneManager() ->getSceneCollisionManager() ->getRayFromScreenCoordinates( - v2s32(m_move_downlocation.X,m_move_downlocation.Y)); + v2s32(m_move_downlocation.X, m_move_downlocation.Y)); SEvent translated; memset(&translated, 0, sizeof(SEvent)); @@ -1145,8 +1228,8 @@ void TouchScreenGUI::step(float dtime) } } - m_settingsbar.step(dtime); - m_rarecontrolsbar.step(dtime); + //m_settingsbar.step(dtime); + //m_rarecontrolsbar.step(dtime); } void TouchScreenGUI::resetHud() @@ -1175,11 +1258,11 @@ void TouchScreenGUI::Toggle(bool visible) while (!m_known_ids.empty()) handleReleaseEvent(m_known_ids.begin()->id); - m_settingsbar.hide(); - m_rarecontrolsbar.hide(); + //m_settingsbar.hide(); + //m_rarecontrolsbar.hide(); } else { - m_settingsbar.show(); - m_rarecontrolsbar.show(); + //m_settingsbar.show(); + //m_rarecontrolsbar.show(); } } @@ -1201,9 +1284,8 @@ void TouchScreenGUI::show() void TouchScreenGUI::handleReleaseAll() { - m_known_ids.clear(); - if (m_move_id != -1) - handleReleaseEvent(m_move_id); - for (auto & m_button : m_buttons) - m_button.ids.clear(); + while (!m_known_ids.empty()) + handleReleaseEvent(m_known_ids.back().id); + for (auto &button : m_buttons) + button.ids.clear(); // should do nothing } diff --git a/src/gui/touchscreengui.h b/src/gui/touchscreengui.h index 27929bcc5..ea079ba7e 100644 --- a/src/gui/touchscreengui.h +++ b/src/gui/touchscreengui.h @@ -1,5 +1,6 @@ /* Copyright (C) 2014 sapier +Copyright (C) 2014-2020 Maksim Gamarnik [MoNTE48] MoNTE48@mail.ua This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -36,23 +37,24 @@ using namespace irr::gui; typedef enum { jump_id = 0, + drop_id, crunch_id, - zoom_id, - special1_id, + inventory_id, + // zoom_id, + // special1_id, + escape_id, + minimap_id, + range_id, + camera_id, + chat_id, after_last_element_id, - settings_starter_id, - rare_controls_starter_id, + // settings_starter_id, + // rare_controls_starter_id, fly_id, noclip_id, fast_id, debug_id, - camera_id, - range_id, - minimap_id, toggle_chat_id, - chat_id, - inventory_id, - drop_id, forward_id, backward_id, left_id, @@ -219,7 +221,7 @@ private: // forward, backward, left, right touch_gui_button_id m_joystick_names[5] = { - forward_id, backward_id, left_id, right_id, special1_id}; + forward_id, backward_id, left_id, right_id, /*special1_id*/}; bool m_joystick_status[5] = {false, false, false, false, false}; /* @@ -230,13 +232,13 @@ private: */ line3d m_shootline; - int m_move_id = -1; + size_t m_move_id = -1; bool m_move_has_really_moved = false; u64 m_move_downtime = 0; bool m_move_sent_as_mouse_event = false; v2s32 m_move_downlocation = v2s32(-10000, -10000); - int m_joystick_id = -1; + size_t m_joystick_id = -1; bool m_joystick_has_really_moved = false; bool m_fixed_joystick = false; bool m_joystick_triggers_special1 = false; @@ -258,13 +260,15 @@ private: // initialize a button void initButton(touch_gui_button_id id, const rect &button_rect, const std::wstring &caption, bool immediate_release, - float repeat_delay = BUTTON_REPEAT_DELAY); + float repeat_delay = SLOW_BUTTON_REPEAT); // initialize a joystick button button_info *initJoystickButton(touch_gui_button_id id, const rect &button_rect, int texture_id, bool visible = true); + void moveJoystick(const SEvent &event, float dx, float dy); + struct id_status { size_t id; @@ -281,8 +285,8 @@ private: // handle pressed hud buttons bool isHUDButton(const SEvent &event); - // handle double taps - bool doubleTapDetection(); + // handle quick taps + bool quickTapDetection(); // handle release event void handleReleaseEvent(size_t evt_id); @@ -290,7 +294,7 @@ private: // apply joystick status void applyJoystickStatus(); - // double-click detection variables + // long-click detection variables struct key_event { u64 down_time; @@ -301,7 +305,7 @@ private: // array for saving last known position of a pointer std::map m_pointerpos; - // array for double tap detection + // array for long-click detection key_event m_key_events[2]; // settings bar diff --git a/textures/base/pack/camera_btn.png b/textures/base/pack/camera_btn.png index 9327dc4a6..82beaa791 100644 Binary files a/textures/base/pack/camera_btn.png and b/textures/base/pack/camera_btn.png differ diff --git a/textures/base/pack/chat_btn.png b/textures/base/pack/chat_btn.png index be4477d3e..ee9289d21 100644 Binary files a/textures/base/pack/chat_btn.png and b/textures/base/pack/chat_btn.png differ diff --git a/textures/base/pack/down.png b/textures/base/pack/down.png deleted file mode 100644 index c290d3a45..000000000 Binary files a/textures/base/pack/down.png and /dev/null differ diff --git a/textures/base/pack/down_btn.png b/textures/base/pack/down_btn.png new file mode 100644 index 000000000..208b7d16d Binary files /dev/null and b/textures/base/pack/down_btn.png differ diff --git a/textures/base/pack/drop_btn.png b/textures/base/pack/drop_btn.png index 4403ce67b..e3dd57461 100644 Binary files a/textures/base/pack/drop_btn.png and b/textures/base/pack/drop_btn.png differ diff --git a/textures/base/pack/escape_btn.png b/textures/base/pack/escape_btn.png new file mode 100644 index 000000000..ae9d4669a Binary files /dev/null and b/textures/base/pack/escape_btn.png differ diff --git a/textures/base/pack/fly_btn.png b/textures/base/pack/fly_btn.png deleted file mode 100644 index 641d0fa6e..000000000 Binary files a/textures/base/pack/fly_btn.png and /dev/null differ diff --git a/textures/base/pack/inventory_btn.png b/textures/base/pack/inventory_btn.png index 278ce39c7..c42c624a6 100644 Binary files a/textures/base/pack/inventory_btn.png and b/textures/base/pack/inventory_btn.png differ diff --git a/textures/base/pack/joystick_bg.png b/textures/base/pack/joystick_bg.png index 406193998..90f7a9048 100644 Binary files a/textures/base/pack/joystick_bg.png and b/textures/base/pack/joystick_bg.png differ diff --git a/textures/base/pack/joystick_center.png b/textures/base/pack/joystick_center.png index 1e4754d24..956268758 100644 Binary files a/textures/base/pack/joystick_center.png and b/textures/base/pack/joystick_center.png differ diff --git a/textures/base/pack/joystick_off.png b/textures/base/pack/joystick_off.png index 6dfbc7a46..23d3f0ea0 100644 Binary files a/textures/base/pack/joystick_off.png and b/textures/base/pack/joystick_off.png differ diff --git a/textures/base/pack/jump_btn.png b/textures/base/pack/jump_btn.png index d21b4a9f8..a91250f8c 100644 Binary files a/textures/base/pack/jump_btn.png and b/textures/base/pack/jump_btn.png differ diff --git a/textures/base/pack/minimap_btn.png b/textures/base/pack/minimap_btn.png index 727ba1e9d..372d76d6e 100644 Binary files a/textures/base/pack/minimap_btn.png and b/textures/base/pack/minimap_btn.png differ diff --git a/textures/base/pack/rangeview_btn.png b/textures/base/pack/rangeview_btn.png index e49a1b636..0c1b97840 100644 Binary files a/textures/base/pack/rangeview_btn.png and b/textures/base/pack/rangeview_btn.png differ