40 lines
1.5 KiB
C++
40 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <algorithm>
|
|
#include <array>
|
|
#include <cmath>
|
|
|
|
namespace mt_host {
|
|
|
|
struct TouchCircle { float x, y, radius; };
|
|
|
|
struct TouchLayout {
|
|
// Attack, six skills and auto hunt.
|
|
std::array<TouchCircle, 8> buttons;
|
|
float scale;
|
|
};
|
|
|
|
inline TouchLayout make_touch_layout(float width, float height, float safe_inset, float minimum_target) {
|
|
TouchLayout layout{};
|
|
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 - 74 * s;
|
|
// Lowered attack button for thumb resting near the bottom edge.
|
|
const float ay = height - 94 * s;
|
|
layout.buttons[0] = {ax, ay, 42 * s};
|
|
// A tighter single skill arc retains full touch targets: widening angular spacing
|
|
// to 25 degrees lets the radius shrink from 140 to 120 without overlapping even
|
|
// the 15% expanded hit circles. Keep the existing clockwise skill order.
|
|
for (int slot = 0; slot < 6; ++slot) {
|
|
const float angle = (165.0f + 25.0f * slot) * 3.14159265f / 180.0f;
|
|
layout.buttons[slot + 1] = {ax + std::cos(angle) * 120 * s,
|
|
ay + std::sin(angle) * 120 * s, 22 * s};
|
|
}
|
|
// Secondary action at the lower edge of combat controls, away from the central view.
|
|
layout.buttons[7] = {ax - 60 * s, ay + 60 * s, 22 * s};
|
|
return layout;
|
|
}
|
|
|
|
} // namespace mt_host
|