feat(mobile): optimize touch skill layout and add auto-hunt HUD and combat entries

This commit is contained in:
shen
2026-10-18 18:23:28 -07:00
parent 82251cb524
commit 0558166243
5 changed files with 111 additions and 52 deletions
+66 -35
View File
@@ -423,12 +423,12 @@ public:
const uint32_t icon_col = 0xFFFFFFFF;
const float r = btn.radius;
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
if (btn.id == kAutoHuntButton) {
draw_auto_hunt_button(commands, btn);
continue;
}
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
if (is_quick_slot_button(btn.id)) {
std::string skill_icon;
float uv[4];
@@ -649,51 +649,82 @@ private:
static bool is_quick_slot_button(int id) { return (id >= 2 && id <= 7) || id == 9 || id == 10; }
static int quick_slot_index(int id) { return id >= 9 ? id - 3 : id - 2; }
// A circular arrow; green while the hunt runs.
// Clear "AUTO" vector button; green glow while the hunt runs.
static void draw_auto_hunt_button(std::vector<UIRenderCommand>& commands, const ButtonDef& btn) {
bool on = false;
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
on = PythonBoot::AutoHuntIsEnabled();
#endif
const uint32_t disc = btn.pressed ? btn.color_pressed : (on ? 0xC040C040 : btn.color_idle);
draw_filled_disc(commands, btn.x, btn.y, btn.radius, disc);
const uint32_t col = on ? 0xFFB0FFB0 : 0xDDFFFFFF;
const float r = btn.radius * 0.45f;
const float kPi = 3.14159265f;
const int segments = 12;
const float a0 = -kPi * 0.35f, a1 = a0 + kPi * 1.6f;
for (int i = 0; i < segments; ++i) {
const float t0 = a0 + (a1 - a0) * float(i) / float(segments);
const float t1 = a0 + (a1 - a0) * float(i + 1) / float(segments);
draw_line(commands, btn.x + std::cos(t0) * r, btn.y + std::sin(t0) * r,
btn.x + std::cos(t1) * r, btn.y + std::sin(t1) * r, col);
}
// Arrowhead at the arc's end, pointing along the direction of travel.
const float ex = btn.x + std::cos(a1) * r, ey = btn.y + std::sin(a1) * r;
const float tx = -std::sin(a1), ty = std::cos(a1);
const float nx = std::cos(a1), ny = std::sin(a1);
const float h = r * 0.55f;
draw_line(commands, ex, ey, ex - tx * h + nx * h * 0.6f, ey - ty * h + ny * h * 0.6f, col);
draw_line(commands, ex, ey, ex - tx * h - nx * h * 0.6f, ey - ty * h - ny * h * 0.6f, col);
const uint32_t disc = btn.pressed ? (on ? 0xEB257D32 : 0xEB16110C) : (on ? 0xDD1B5E20 : 0x8A16110C);
draw_filled_disc(commands, btn.x, btn.y, btn.radius * 0.88f, disc);
const uint32_t ring_col = on ? 0xFF80FF90 : (btn.pressed ? 0xFFB89545 : 0x8A997847);
draw_circle(commands, btn.x, btn.y, btn.radius * 0.90f, ring_col, 32);
if (on) {
// A play dot in the middle while running.
draw_rect_bar(commands, btn.x - 2.0f, btn.y - 2.0f, btn.x + 2.0f, btn.y + 2.0f, col);
draw_circle(commands, btn.x, btn.y, btn.radius * 0.72f, 0x6680FF90, 32);
}
const uint32_t text_col = on ? 0xFFFFFFFF : (btn.pressed ? 0xFFFFFFFF : 0xFFD8C49A);
const float h = std::round(btn.radius * 0.44f);
const float w = std::round(h * 0.52f);
const float gap = std::max(1.5f, std::round(h * 0.18f));
const float total_w = 4.0f * w + 3.0f * gap;
const float top = btn.y - h * 0.5f;
const float bot = top + h;
const float mid = top + h * 0.5f;
float x = btn.x - total_w * 0.5f;
// 'A'
draw_line(commands, x, bot, x + w * 0.5f, top, text_col);
draw_line(commands, x + 0.6f, bot, x + w * 0.5f + 0.6f, top, text_col);
draw_line(commands, x + w * 0.5f, top, x + w, bot, text_col);
draw_line(commands, x + w * 0.5f - 0.6f, top, x + w - 0.6f, bot, text_col);
draw_rect_bar(commands, x + w * 0.22f, mid + 0.3f, x + w * 0.78f, mid + 1.5f, text_col);
x += w + gap;
// 'U'
draw_rect_bar(commands, x, top, x + 1.3f, bot - 1.0f, text_col);
draw_rect_bar(commands, x + w - 1.3f, top, x + w, bot - 1.0f, text_col);
draw_rect_bar(commands, x + 1.0f, bot - 1.3f, x + w - 1.0f, bot, text_col);
draw_line(commands, x, bot - 1.0f, x + 1.0f, bot, text_col);
draw_line(commands, x + w - 1.0f, bot, x + w, bot - 1.0f, text_col);
x += w + gap;
// 'T'
draw_rect_bar(commands, x, top, x + w, top + 1.3f, text_col);
const float t_stem = x + (w - 1.3f) * 0.5f;
draw_rect_bar(commands, t_stem, top + 1.0f, t_stem + 1.3f, bot, text_col);
x += w + gap;
// 'O'
draw_rect_bar(commands, x + 1.0f, top, x + w - 1.0f, top + 1.3f, text_col);
draw_rect_bar(commands, x + 1.0f, bot - 1.3f, x + w - 1.0f, bot, text_col);
draw_rect_bar(commands, x, top + 1.0f, x + 1.3f, bot - 1.0f, text_col);
draw_rect_bar(commands, x + w - 1.3f, top + 1.0f, x + w, bot - 1.0f, text_col);
draw_line(commands, x, top + 1.0f, x + 1.0f, top, text_col);
draw_line(commands, x + w - 1.0f, top, x + w, top + 1.0f, text_col);
draw_line(commands, x, bot - 1.0f, x + 1.0f, bot, text_col);
draw_line(commands, x + w - 1.0f, bot, x + w, bot - 1.0f, text_col);
}
void init_buttons() {
buttons_.clear();
// Lower-right combat controls. All menus and status UI remain the original 40250 UI.
buttons_.push_back({1, 0x39, 0, 0, 42.0f, "ATK", 0xC04C2818, 0xE0A77832});
buttons_.push_back({2, 0x02, 0, 0, 26.0f, "S1", 0x803060C0, 0xD05080FF});
buttons_.push_back({3, 0x03, 0, 0, 26.0f, "S2", 0x80903090, 0xD0D050D0});
buttons_.push_back({4, 0x04, 0, 0, 26.0f, "S3", 0x80309060, 0xD050D080});
buttons_.push_back({5, 0x05, 0, 0, 26.0f, "S4", 0x80906030, 0xD0D08050});
buttons_.push_back({6, 0x06, 0, 0, 26.0f, "S5", 0x80603090, 0xD08050D0});
buttons_.push_back({7, 0x07, 0, 0, 26.0f, "S6", 0x80308090, 0xD050C0D0});
buttons_.push_back({kAutoHuntButton, 0, 0, 0, 24.0f, "AUTO", 0x80707070, 0xD0FFFFFF});
buttons_.push_back({9, 0x08, 0, 0, 28.0f, "7", 0xB032211B, 0xE0664B2D});
buttons_.push_back({10, 0x09, 0, 0, 28.0f, "8", 0xB032211B, 0xE0664B2D});
buttons_.push_back({2, 0x02, 0, 0, 22.0f, "S1", 0x803060C0, 0xD05080FF});
buttons_.push_back({3, 0x03, 0, 0, 22.0f, "S2", 0x80903090, 0xD0D050D0});
buttons_.push_back({4, 0x04, 0, 0, 22.0f, "S3", 0x80309060, 0xD050D080});
buttons_.push_back({5, 0x05, 0, 0, 22.0f, "S4", 0x80906030, 0xD0D08050});
buttons_.push_back({6, 0x06, 0, 0, 22.0f, "S5", 0x80603090, 0xD08050D0});
buttons_.push_back({7, 0x07, 0, 0, 22.0f, "S6", 0x80308090, 0xD050C0D0});
buttons_.push_back({kAutoHuntButton, 0, 0, 0, 22.0f, "AUTO", 0x80707070, 0xD0FFFFFF});
buttons_.push_back({9, 0x08, 0, 0, 24.0f, "7", 0xB032211B, 0xE0664B2D});
buttons_.push_back({10, 0x09, 0, 0, 24.0f, "8", 0xB032211B, 0xE0664B2D});
for (auto& btn : buttons_) {
if (is_quick_slot_button(btn.id)) {
btn.color_idle = 0xA032211B;
@@ -717,7 +748,7 @@ private:
int find_button(float x, float y) {
int nearest = -1;
float best = 1.25f;
float best = 1.15f;
for (size_t i = 0; i < buttons_.size(); ++i) {
const auto& btn = buttons_[i];
const float distance = std::hypot(x - btn.x, y - btn.y) / btn.radius;
+15 -14
View File
@@ -16,25 +16,26 @@ struct TouchLayout {
inline TouchLayout make_touch_layout(float width, float height, float safe_inset, float minimum_target) {
TouchLayout layout{};
layout.scale = std::max(minimum_target / 52.0f,
layout.scale = std::max(minimum_target / 44.0f,
std::clamp(std::min(height / 600.0f, (width - 2 * safe_inset) / 800.0f), 0.65f, 1.35f));
const float s = layout.scale;
const float ax = width - safe_inset - 78 * s;
// Leave the original status/menu strip clear below the lowest skill.
const float ay = height - 136 * s;
layout.buttons[0] = {ax, ay, 44 * s};
// PORT: D2R Mobile's main-button + single skill arc arrangement, extended to six slots.
// 24-degree spacing at radius 176 keeps even the expanded (1.25x) hit circles separate.
const float ax = width - safe_inset - 74 * s;
// Lowered attack button for thumb resting near the bottom edge.
const float ay = height - 88 * s;
layout.buttons[0] = {ax, ay, 42 * s};
// Compact single-layer skill arc in the upper-left of attack button:
// 20-degree spacing from 170 to 270 degrees at radius 140 keeps the skills tightly
// wrapped around the attack button without encroaching on the minimap or screen center.
for (int slot = 0; slot < 6; ++slot) {
const float angle = (160.0f + 24.0f * slot) * 3.14159265f / 180.0f;
layout.buttons[slot + 1] = {ax + std::cos(angle) * 176 * s,
ay + std::sin(angle) * 176 * s, 28 * s};
const float angle = (170.0f + 20.0f * slot) * 3.14159265f / 180.0f;
layout.buttons[slot + 1] = {ax + std::cos(angle) * 140 * s,
ay + std::sin(angle) * 140 * s, 22 * s};
}
// Keep the settings/toggle action outside the arc, away from repeated attack taps.
layout.buttons[7] = {ax - 246 * s, ay - 84 * s, 26 * s};
// Auto hunt button nestled compactly just outside the skill arc.
layout.buttons[7] = {ax - 195 * s, ay - 50 * s, 22 * s};
const float item_center = std::min(width / 2, layout.buttons[1].x - 114 * s);
layout.buttons[8] = {item_center - 36 * s, height - 38 * s, 28 * s};
layout.buttons[9] = {item_center + 36 * s, height - 38 * s, 28 * s};
layout.buttons[8] = {item_center - 36 * s, height - 38 * s, 24 * s};
layout.buttons[9] = {item_center + 36 * s, height - 38 * s, 24 * s};
return layout;
}