Integrate AVA2 native shop and refine mobile controls and locale tooltips
This commit is contained in:
@@ -261,7 +261,10 @@ bool VulkanWindow::poll(bool forward_to_live_client) {
|
||||
} else if (event.type == SDL_EVENT_FINGER_MOTION) {
|
||||
touch_controller.on_finger_motion(event.tfinger.fingerID, event.tfinger.x, event.tfinger.y);
|
||||
continue;
|
||||
} else if (event.type == SDL_EVENT_FINGER_UP || event.type == SDL_EVENT_FINGER_CANCELED) {
|
||||
} else if (event.type == SDL_EVENT_FINGER_CANCELED) {
|
||||
touch_controller.cancel_gestures();
|
||||
continue;
|
||||
} else if (event.type == SDL_EVENT_FINGER_UP) {
|
||||
touch_controller.on_finger_up(event.tfinger.fingerID, event.tfinger.x, event.tfinger.y);
|
||||
continue;
|
||||
}
|
||||
@@ -275,6 +278,7 @@ bool VulkanWindow::poll(bool forward_to_live_client) {
|
||||
SDL_HideCursor();
|
||||
os_cursor_hidden_ = true;
|
||||
} else if (event.type == SDL_EVENT_WINDOW_FOCUS_LOST) {
|
||||
touch_controller.cancel_gestures();
|
||||
SDL_CaptureMouse(false);
|
||||
PythonBoot::UIMouseButton(2, false, last_mx_, last_my_);
|
||||
PythonBoot::UIMouseButton(3, false, last_mx_, last_my_);
|
||||
|
||||
+63
-17
@@ -33,12 +33,24 @@ public:
|
||||
}
|
||||
|
||||
void set_enabled(bool enabled) {
|
||||
if (enabled_ && !enabled) cancel_gestures();
|
||||
enabled_ = enabled;
|
||||
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
|
||||
PythonBoot::SetTouchInput(enabled);
|
||||
#endif
|
||||
}
|
||||
bool is_enabled() const { return enabled_; }
|
||||
// OS cancellation/focus loss must discard gestures without synthesizing a world tap.
|
||||
void cancel_gestures() {
|
||||
release_gameplay_controls();
|
||||
ui_touch_finger_id_ = -1;
|
||||
ui_gesture_ = UiGesture::None;
|
||||
tap_stage_ = 0;
|
||||
keyboard_requested_ = false;
|
||||
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
|
||||
PythonBoot::SetInventoryDrag(false);
|
||||
#endif
|
||||
}
|
||||
void set_minimum_touch_target(float logicalSize) { minimum_touch_target_ = std::max(48.0f, logicalSize); }
|
||||
// Short vibration when a long press fires (the host wires it to the platform).
|
||||
void set_haptic(void (*haptic)()) { haptic_ = haptic; }
|
||||
@@ -110,7 +122,8 @@ public:
|
||||
controls_were_visible_ = true;
|
||||
if (joystick_active_) {
|
||||
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
|
||||
PythonBoot::SetMoveDirection(move_angle_, true);
|
||||
PythonBoot::SetMoveDirection(move_angle_,
|
||||
std::hypot(joystick_last_x_ - joystick_base_x_, joystick_last_y_ - joystick_base_y_) > 8.0f);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -165,12 +178,38 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
// PORT: two scene fingers own a pinch before the second can become a joystick.
|
||||
// A stationary new left thumb may join the pinch; an established moving stick stays movement.
|
||||
if (controls_visible && pinch_finger_id_ >= 0)
|
||||
return true; // Additional scene fingers cannot steal an ongoing pinch.
|
||||
if (controls_visible) {
|
||||
if (look_finger_id_ == finger_id) return true;
|
||||
if (look_finger_id_ >= 0) {
|
||||
begin_pinch(finger_id, px, py);
|
||||
return true;
|
||||
}
|
||||
if (joystick_active_ && !joystick_moved_) {
|
||||
look_finger_id_ = joystick_finger_id_;
|
||||
look_last_x_ = joystick_last_x_;
|
||||
look_last_y_ = joystick_last_y_;
|
||||
look_can_rotate_ = true;
|
||||
joystick_active_ = false;
|
||||
joystick_finger_id_ = -1;
|
||||
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
|
||||
PythonBoot::SetMoveDirection(0.0f, false);
|
||||
#endif
|
||||
begin_pinch(finger_id, px, py);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Mobile-game layout: the left half moves (floating stick), the right half looks.
|
||||
if (controls_visible && norm_x < kMoveZoneRight && norm_y > kMoveZoneTop && !joystick_active_) {
|
||||
joystick_active_ = true;
|
||||
joystick_finger_id_ = finger_id;
|
||||
joystick_base_x_ = px;
|
||||
joystick_base_y_ = py;
|
||||
joystick_base_x_ = joystick_last_x_ = px;
|
||||
joystick_base_y_ = joystick_last_y_ = py;
|
||||
joystick_moved_ = false;
|
||||
joystick_knob_x_ = px;
|
||||
joystick_knob_y_ = py;
|
||||
update_joystick_motion(px, py);
|
||||
@@ -195,15 +234,6 @@ public:
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
if (pinch_finger_id_ < 0 && look_can_rotate_ && in_look_zone) {
|
||||
pinch_finger_id_ = finger_id;
|
||||
pinch_x_ = px;
|
||||
pinch_y_ = py;
|
||||
pinch_last_dist_ = std::hypot(px - look_last_x_, py - look_last_y_);
|
||||
look_rotating_ = false;
|
||||
look_moved_ = true; // a pinch never ends as a tap
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -234,6 +264,10 @@ public:
|
||||
|
||||
// 2. Virtual Joystick finger
|
||||
if (joystick_active_ && finger_id == joystick_finger_id_) {
|
||||
joystick_last_x_ = px;
|
||||
joystick_last_y_ = py;
|
||||
if (std::hypot(px - joystick_base_x_, py - joystick_base_y_) > kLookDeadZone)
|
||||
joystick_moved_ = true;
|
||||
update_joystick_motion(px, py);
|
||||
return true;
|
||||
}
|
||||
@@ -253,7 +287,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Two-finger pinch zoom (look finger + second right-half finger)
|
||||
// 4. Two-finger scene pinch: scale camera distance, without wheel inertia or UI scrolling.
|
||||
if (pinch_finger_id_ >= 0 && (finger_id == pinch_finger_id_ || finger_id == look_finger_id_)) {
|
||||
if (finger_id == pinch_finger_id_) {
|
||||
pinch_x_ = px;
|
||||
@@ -263,13 +297,13 @@ public:
|
||||
look_last_y_ = py;
|
||||
}
|
||||
const float cur_dist = std::hypot(pinch_x_ - look_last_x_, pinch_y_ - look_last_y_);
|
||||
const float delta_d = cur_dist - pinch_last_dist_;
|
||||
if (std::abs(delta_d) > 2.0f) {
|
||||
// Rebase very close/crossed fingers instead of dividing by a near-zero span.
|
||||
if (cur_dist >= 24.0f && pinch_last_dist_ >= 24.0f) {
|
||||
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
|
||||
PythonBoot::UIMouseWheel(int(delta_d * 8.0f));
|
||||
PythonBoot::CameraZoomBy(pinch_last_dist_ / cur_dist);
|
||||
#endif
|
||||
pinch_last_dist_ = cur_dist;
|
||||
}
|
||||
pinch_last_dist_ = cur_dist;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -615,6 +649,16 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void begin_pinch(int64_t finger_id, float px, float py) {
|
||||
pinch_finger_id_ = finger_id;
|
||||
pinch_x_ = px;
|
||||
pinch_y_ = py;
|
||||
pinch_last_dist_ = std::hypot(px - look_last_x_, py - look_last_y_);
|
||||
look_rotating_ = false;
|
||||
look_can_rotate_ = true;
|
||||
look_moved_ = true; // Neither finger may turn into a tap after pinching.
|
||||
}
|
||||
|
||||
bool gameplay_controls_visible() const {
|
||||
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
|
||||
return PythonBoot::InGamePhase() && !PythonBoot::CurrentMapName().empty();
|
||||
@@ -904,6 +948,8 @@ private:
|
||||
float joystick_radius_ = 65.0f;
|
||||
float joystick_knob_radius_ = 23.0f;
|
||||
float move_angle_ = 0.0f;
|
||||
float joystick_last_x_ = 0.0f, joystick_last_y_ = 0.0f;
|
||||
bool joystick_moved_ = false;
|
||||
|
||||
// Zones are fractions of the screen; distances are logical UI pixels.
|
||||
static constexpr float kMoveZoneRight = 0.5f;
|
||||
|
||||
Reference in New Issue
Block a user