Greater Rift: invading act bosses from level 80 (second segment of #26), Guardian count on the top bar, boss-summoned units keep original strength; touch: floating stick measured from the touch-down point, item descriptions move beside the inventory; rewriter output r43

This commit is contained in:
jhaizhou
2026-10-14 13:46:32 +08:00
parent 5bc5a01087
commit cfa70b3d02
15 changed files with 234 additions and 38 deletions
+2 -1
View File
@@ -75,7 +75,8 @@ void dm_rift_hud_draw(UIView *host, CGRect wr, BOOL hide) {
NSString *st = h.done ? (h.inc ? [NSString stringWithFormat:@(dm_ui("dmRiftHudDone")), h.tier] : [NSString stringWithFormat:@(dm_ui("dmRiftHudLate")), h.tier]) : g ? @(dm_ui("dmRiftHudGuard")) : [NSString stringWithFormat:@(dm_ui("dmRiftTierN")), h.tier];
set_text(sub, st, d2font(14 * u), white, CGRectMake(48 * u, 9 * u, 130 * u, 19 * u), kCAAlignmentLeft);
set_text(timer, [NSString stringWithFormat:@"%d:%02d", s / 60, s % 60], d2font(17 * u), (s <= 60 && !h.done) ? red : gold, CGRectMake(W - 90 * u, 6 * u, 80 * u, 22 * u), kCAAlignmentRight);
NSString *gl = h.done ? (!h.inc ? @(dm_ui("dmRiftHudSame")) : h.next > h.tier ? [NSString stringWithFormat:@(dm_ui("dmRiftHudNext")), h.next] : @(dm_ui("dmRiftHudTop"))) : h.overtime ? @(dm_ui("dmRiftHudOver")) : g ? @(dm_ui("dmRiftHudKill")) : [NSString stringWithFormat:@(dm_ui("dmRiftHudGoal")), (int)(h.progress * 100)]; // 已超时:第二行换成这一句,优先于「击败守护者」/ 进度目标(第一行照旧写第几层 / 守护者现身) | overtime: the second line becomes this sentence, taking priority over "Slay the Rift Guardian" / the progress goal (the first line still says which level / that the Guardian has appeared)
NSString *gl = h.done ? (!h.inc ? @(dm_ui("dmRiftHudSame")) : h.next > h.tier ? [NSString stringWithFormat:@(dm_ui("dmRiftHudNext")), h.next] : @(dm_ui("dmRiftHudTop"))) : h.goal == 5 ? [NSString stringWithFormat:@(dm_ui("dmRiftHudOverKillN")), h.gdead, h.gtotal] : h.goal == 4 ? @(dm_ui("dmRiftHudOverKill")) : h.goal == 3 ? @(dm_ui("dmRiftHudOver"))
: h.goal == 2 ? [NSString stringWithFormat:@(dm_ui("dmRiftHudKillN")), h.gdead, h.gtotal] : h.goal == 1 ? @(dm_ui("dmRiftHudKill")) : [NSString stringWithFormat:@(dm_ui("dmRiftHudGoal")), (int)(h.progress * 100)]; // 已超时:第二行换成这一句,优先于「击败守护者」/ 进度目标(第一行照旧写第几层 / 守护者现身) | overtime: the second line becomes this sentence, taking priority over "Slay the Rift Guardian" / the progress goal (the first line still says which level / that the Guardian has appeared)
set_text(goal, gl, d2font(12 * u), grey, CGRectMake(10 * u, 32 * u, W - 20 * u, 17 * u), kCAAlignmentLeft);
CGRect tr = CGRectMake(11 * u, 55 * u, W - 22 * u, 10 * u); // 含 1 单位外框(条 8 + 外框各 1) // 进度条:外框暗边 + 深底,填充金褐(守护者转暗红),每 10% 一道刻痕,两端菱形钉 | Includes the 1-unit outer frame (bar 8 + frame 1 on each side) // Progress bar: dark-edged outer frame + deep background, golden-brown fill (turns dark red for the guardian), a notch every 10%, diamond studs at both ends
track.frame = tr; track.backgroundColor = rgb(25, 20, 14, 1).CGColor; track.borderColor = rgb(95, 78, 48, 1).CGColor; track.borderWidth = MAX(1, u);
+12 -9
View File
@@ -79,16 +79,18 @@ void dm_tc_layout_make(dm_tc_layout *l, float width, float height) {
/* 左摇杆是浮动底盘:左下「起摇杆区」里手指落在哪,底盘圆心就落在哪,松手回静止位。
静止位:圆心离安全区左界 90(底盘半径 60 + 30)、不小于 120,离屏幕底 115——只是没按时画在哪。
起摇杆区:屏宽的左 40% × 屏高的下 55%(左与下到屏幕边:拇指压在刘海那一条上也算);区里我们的圆钮 / 腰带格、原版界面上可点的东西各自优先。
夹回:落点贴边时圆心挪回来,整个底盘留在安全区左界以右、底盘下沿离屏幕底不少于 25(不撞系统横条)
夹回:只为底盘整圈画在屏内——落点离左沿 / 底沿不到「半径 + 8」时底盘圆心挪回到那条线上;只影响画,轴值仍按手指相对落点算(摇杆头 = 底盘圆心 + 轴值 × 半径)。不让安全区(原先左界取「安全区 + 半径」,刘海机型约 122 点:
拇指自然落在离左边 60–120 点的人一落指就带明显的向左分量;左下角没有刘海也没有系统横条)。静止位仍让安全区,那只是没按时画在哪
The left stick is a floating base: wherever the finger lands inside the bottom-left "stick-start zone", the base centre goes there, and it returns to the rest position on release.
Rest position: centre 90 from the left edge of the safe area (base radius 60 + 30), not less than 120, and 115 from the bottom of the screen - only where it is drawn while not pressed.
Stick-start zone: the left 40% of the screen width x the lower 55% of the screen height (reaching the screen edges on the left and bottom: a thumb on the notch strip counts too); inside the zone our round buttons / belt cells and the clickable things of the original UI each take priority.
Clamping: when the touch point is near an edge the centre is moved back so that the whole base stays to the right of the safe area's left edge and its lower rim is at least 25 from the bottom of the screen (clear of the system bar) */
Clamping: only so that the whole base is drawn on screen - when the touch point is closer than "radius + 8" to the left / bottom edge the base centre is moved back onto that line; it only affects drawing, and the axes are still computed from the finger relative to the touch point (stick knob = base centre + axes x radius). The safe area is not respected (the left bound used to be "safe area + radius", about 122 points on notched devices:
a thumb landing naturally 60–120 points from the left edge got a clear leftward component the moment it touched down; the bottom-left corner has neither a notch nor the system bar). The rest position still respects the safe area, which is only where it is drawn while not pressed */
l->joy_radius = 60*k;
l->joy_x = fmaxf(90*k, g_safe_l + 60*k) + 30*k;
l->joy_y = l->height - 115*k;
l->joy_zone_r = l->width*0.40f; l->joy_zone_t = l->height*0.45f;
l->joy_min_x = g_safe_l + l->joy_radius; l->joy_max_y = l->height - 25*k - l->joy_radius;
l->joy_min_x = l->joy_radius + 8*k; l->joy_max_y = l->height - l->joy_radius - 8*k;
}
int dm_tc_hit(const dm_tc_layout *l, float x, float y) {
@@ -214,7 +216,7 @@ static void update(dm_tc_state *s) {
s->lx = s->ly = 0;
if (s->joy_slot < 0) return;
dm_tc_finger *f = &s->finger[s->joy_slot];
float dx = f->x-s->joy_origin_x, dy = s->joy_origin_y-f->y;
float dx = f->x-s->joy_touch_x, dy = s->joy_touch_y-f->y; /* 相对落点,不相对底盘圆心:夹回只影响底盘画在哪,不进算法(贴角落指时圆心在手指右上方,按圆心算会出现手指往右、人往下) | relative to the touch point, not the base centre: clamping only affects where the base is drawn and does not enter the computation (touching down in a corner puts the centre to the upper right of the finger, and computing from the centre would make the character move down while the finger moves right) */
/* 输入行程不跟大屏的视觉放大走:拇指不随屏幕变大。满偏 60 点、死区 6 点,手机与 iPad 一致
(原先乘视觉倍数,12.9 寸 iPad 要推 105 点 ≈ 20 mm 才满偏,是手机的两倍)。底盘和摇杆头的大小仍按视觉倍数画。
Input travel does not follow the visual enlargement on large screens: the thumb does not grow with the screen. Full deflection 60 points, dead zone 6 points, same on phone and iPad
@@ -388,7 +390,7 @@ void dm_tc_cancel_finger(dm_tc_state *s, int slot) {
if (slot < 0 || slot >= DM_TC_MAX_TOUCH) return;
++s->gesture_epoch;
if (s->finger[slot].active && s->finger[slot].target == DM_TC_PORTAL) { dm_tc_cancel_portal(s); }
if (slot == s->joy_slot && s->finger[slot].active) { s->joy_lost_s = s->last_time_s; s->joy_lost_x = s->finger[slot].x; s->joy_lost_y = s->finger[slot].y; s->joy_lost_ox = s->joy_origin_x; s->joy_lost_oy = s->joy_origin_y; } /* 系统取消了摇杆那根手指:记下,紧接着在附近重新落下的接着当摇杆 | the system cancelled the joystick finger: record it, and a finger landing again nearby right afterwards continues as the joystick */
if (slot == s->joy_slot && s->finger[slot].active) { s->joy_lost_s = s->last_time_s; s->joy_lost_x = s->finger[slot].x; s->joy_lost_y = s->finger[slot].y; s->joy_lost_ox = s->joy_origin_x; s->joy_lost_oy = s->joy_origin_y; s->joy_lost_tx = s->joy_touch_x; s->joy_lost_ty = s->joy_touch_y; } /* 系统取消了摇杆那根手指:记下,紧接着在附近重新落下的接着当摇杆 | the system cancelled the joystick finger: record it, and a finger landing again nearby right afterwards continues as the joystick */
s->finger[slot] = (dm_tc_finger){.target=DM_TC_NONE};
if (slot == s->joy_slot) { s->joy_slot = DM_TC_NONE; s->joy_origin_x = s->joy_origin_y = 0; }
if (slot == s->aim_slot) s->aim_slot = DM_TC_NONE;
@@ -505,14 +507,14 @@ void dm_tc_begin_at(dm_tc_state *s, int slot, float x, float y, double now_s) {
} else if (!s->navigation_mode && !s->joy_block && hit == DM_TC_NONE && s->joy_slot == DM_TC_NONE && x >= 0 && y <= s->layout.height &&
((x < s->layout.joy_zone_r && y > s->layout.joy_zone_t) ||
(x < s->layout.width*0.43f && y > s->layout.height*0.25f && s->joy_lost_s > 0 && now_s - s->joy_lost_s <= DM_TC_JOY_RESUME_S && hypotf(x - s->joy_lost_x, y - s->joy_lost_y) <= DM_TC_JOY_GRAB_K * s->layout.joy_radius))) {
/* 浮动底盘:落在起摇杆区里就起摇杆,底盘圆心 = 落点(贴边时夹回,见布局处),方向与幅度按「手指相对底盘圆心」算,按住后拖到多远都照样识别,
/* 浮动底盘:落在起摇杆区里就起摇杆,底盘圆心 = 落点(贴边时夹回,见布局处),方向与幅度按「手指相对落点」算,按住后拖到多远都照样识别,
底盘不跟手走;落在区外照旧是点地。这一下若很快原地松开,仍兼作一次点击(dm_tc_end_at):区里的怪、掉落物、NPC 要点得到。
摇杆那根手指刚被系统取消(通知横幅、系统手势;dm_tc_cancel_finger 记下时刻与位置),DM_TC_JOY_RESUME_S 内在原处附近重新落下的手指接着当摇杆,
哪怕落点已拖出起摇杆区。只开着讲话文字框 / 对话菜单时不起摇杆(joy_block):夹回会让落点 ≠ 圆心、一落下就有方向,那一下只该关框
Floating base: a touch inside the stick-start zone starts the stick with the base centre = the touch point (clamped back near the edges, see the layout), direction and magnitude are computed from "finger relative to base centre", and once held, dragging any distance is still recognised;
哪怕落点已拖出起摇杆区。只开着讲话文字框 / 对话菜单时不起摇杆(joy_block):那一下只该关框、人不走(落指位移为零本来也不出方向,但手指稍一滑就会走,照旧整根挡掉)
Floating base: a touch inside the stick-start zone starts the stick with the base centre = the touch point (clamped near the edges, see the layout), direction and magnitude are computed from "finger relative to the touch point", and once held, dragging any distance is still recognised;
the base does not follow the finger; a touch outside the zone is a ground tap as before. If this touch is released quickly in place it still doubles as a tap (dm_tc_end_at): monsters, dropped items and NPCs inside the zone must remain tappable.
When the stick finger has just been cancelled by the system (notification banner, system gesture; dm_tc_cancel_finger records the time and position), a finger touching down again near the same place within DM_TC_JOY_RESUME_S continues as the stick,
even if the touch point has been dragged out of the stick-start zone. The stick does not start while only a speech text box / dialogue menu is open (joy_block): clamping would make touch point != centre and give a direction the moment it lands, when that touch should only close the box */
even if the touch point has been dragged out of the stick-start zone. The stick does not start while only a speech text box / dialogue menu is open (joy_block): that touch should only close the box without moving the character (zero displacement on touch-down gives no direction anyway, but a slight slide would walk, so the whole finger is still blocked) */
int resume = s->joy_lost_s > 0 && now_s - s->joy_lost_s <= DM_TC_JOY_RESUME_S && hypotf(x - s->joy_lost_x, y - s->joy_lost_y) <= DM_TC_JOY_GRAB_K * s->layout.joy_radius;
s->joy_lost_s = 0;
f->target = DM_TC_JOYSTICK;
@@ -520,6 +522,7 @@ void dm_tc_begin_at(dm_tc_state *s, int slot, float x, float y, double now_s) {
/* 接续的沿用取消前的圆心,不按新落点重定:触摸被系统反复打断又重来的机器上,每重来一次底盘就跳到手指当前位置,看着像底盘追着手指跑 | a continuation keeps the centre from before the cancel instead of re-centring on the new touch point: on devices where touches are repeatedly interrupted by the system and restarted, the base would jump to the finger's current position on every restart and look as if it were chasing the finger */
s->joy_origin_x = resume ? s->joy_lost_ox : fmaxf(x, s->layout.joy_min_x);
s->joy_origin_y = resume ? s->joy_lost_oy : fminf(y, s->layout.joy_max_y);
s->joy_touch_x = resume ? s->joy_lost_tx : x; s->joy_touch_y = resume ? s->joy_lost_ty : y; /* 接续的沿用取消前的落点,同样不按新落点重定 | a continuation keeps the touch point from before the cancel, likewise not re-centred on the new touch point */
}
update(s);
}
+2 -1
View File
@@ -19,7 +19,7 @@ typedef struct {
float width, height;
dm_tc_target target[DM_TC_COUNT];
float joy_x, joy_y, joy_radius; /* 没按时底盘的显示位置(静止位)与底盘半径 | where the base is shown while not pressed (rest position), and the base radius */
float joy_zone_r, joy_zone_t, joy_min_x, joy_max_y; /* 起摇杆区的右界与上界(左与下到屏幕边);按下后底盘圆心的夹回界:x 不小于、y 不大于 | right and upper bounds of the stick-start zone (left and bottom reach the screen edges); clamp bounds for the base centre once pressed: x not less than, y not greater than */
float joy_zone_r, joy_zone_t, joy_min_x, joy_max_y; /* 起摇杆区的右界与上界(左与下到屏幕边);按下后底盘圆心的夹回界:x 不小于、y 不大于(只为底盘整圈画在屏内:屏幕边 + 半径 + 8) | right and upper bounds of the stick-start zone (left and bottom reach the screen edges); clamp bounds for the base centre once pressed: x not less than, y not greater than (only so that the whole base is drawn on screen: screen edge + radius + 8) */
dm_tc_target swap; /* 技能组切换键:本地开关,不直接发按键 | Skill set switch key: a local toggle; does not send a key directly */
dm_tc_target diff; /* 底部 UI v4 第 0 格难度:点开 / 收起 1–8 选择条,不发按键 | Bottom UI v4 cell 0 difficulty: tap to open / collapse the 1–8 selector bar; sends no key */
dm_tc_target pick[8]; /* 选择条 8 格(第 i 格 = 人数档 i+1),在七格上方 | The selector bar's 8 cells (cell i = player-count level i+1), above the seven cells */
@@ -125,6 +125,7 @@ typedef struct {
int belt_gap_cell; double belt_gap_at; /* 按着第二组技能时要喝药:先把 ZL 和技能键松开、空出 DM_TC_ZL_LEAD_S,到 belt_gap_at 才按腰带键(belt_gap_cell = 等着的那一格,0 = 没有) | to drink a potion while a skill of the second skill set is held: first release ZL and the skill key and leave a gap of DM_TC_ZL_LEAD_S, and only at belt_gap_at press the belt key (belt_gap_cell = the cell that is waiting, 0 = none) */
double joy_lost_s; float joy_lost_x, joy_lost_y, joy_lost_ox, joy_lost_oy; /* 摇杆手指被系统取消的时刻与当时的位置(0 = 没有):紧接着在附近重新落下的手指接着当摇杆 | time and position at which the joystick finger was cancelled by the system (0 = none): a finger landing again nearby right afterwards continues as the joystick */
int joy_block; /* 讲话文字框单独开着(前端不进面板态):这时落在底座上的手指不起摇杆,照旧只当一次点击(关讲话框)。前端按面板栈写 | speech text box open on its own (the front end does not enter panel state): a finger on the base starts no stick and is still just one click (closes the speech box). Written by the front end from the panel stack */
float joy_touch_x, joy_touch_y, joy_lost_tx, joy_lost_ty; /* 摇杆那根手指的落点(方向与幅度一律按「手指相对落点」算;joy_origin 只是底盘画在哪 = 落点夹回屏内之后);被系统取消时记下的落点 | touch point of the stick finger (direction and magnitude are always computed from "finger relative to the touch point"; joy_origin is only where the base is drawn = the touch point clamped onto the screen); the touch point recorded when it was cancelled by the system */
double belt_pulse_s; /* 最近一次「给玩家喝」的腰带脉冲还在发的时刻:其间按着的第二组技能连同 ZL 一起让开,收回后 ZL 重新领先 DM_TC_ZL_LEAD_S 技能键才回来 | Time until which the most recent "player drinks" belt pulse is still being sent: during it the held second-set skill gives way together with ZL, and after the release ZL again leads by DM_TC_ZL_LEAD_S before the skill key comes back */
int belt_q; /* 此刻有别的脉冲在发 / 别的补发在等:排着,空了再落地(不互相盖掉)。值 = 格 | another pulse is being sent / another resend is pending: queue and fire when free (they never overwrite each other). Value = cell */
} dm_tc_state;
+35 -10
View File
@@ -118,11 +118,11 @@ static void two_fingers_same_key(void) {
}
static void joystick_deadzone(void) {
/* 浮动底盘。667×375(k = 1、安全区 0)手算:静止位 (max(90, 0+60)+30, 375−115) = (120, 260);起摇杆区 x < 667×0.40 = 266.8 且 y > 375×0.45 = 168.75;
夹回 x ≥ 0+60 = 60、y ≤ 375−25−60 = 290。落在区里起手:圆心 = 落点,位移为零
夹回只为底盘整圈在屏内:x ≥ 60+8 = 68、y ≤ 375−60−8 = 307(不让安全区)。落在区里起手:圆心 = 落点,位移为零
Floating base. Worked by hand for 667x375 (k = 1, safe area 0): rest position (max(90, 0+60)+30, 375-115) = (120, 260); stick-start zone x < 667x0.40 = 266.8 and y > 375x0.45 = 168.75;
clamp x >= 0+60 = 60, y <= 375-25-60 = 290. Starting inside the zone: centre = touch point, zero displacement */
clamping only keeps the whole base on screen: x >= 60+8 = 68, y <= 375-60-8 = 307 (not respecting the safe area). Starting inside the zone: centre = touch point, zero displacement */
dm_tc_state s; dm_tc_init(&s,667,375); NEAR(s.layout.joy_x,120,0.001); NEAR(s.layout.joy_y,260,0.001);
NEAR(s.layout.joy_zone_r,266.8,0.001); NEAR(s.layout.joy_zone_t,168.75,0.001); NEAR(s.layout.joy_min_x,60,0.001); NEAR(s.layout.joy_max_y,290,0.001);
NEAR(s.layout.joy_zone_r,266.8,0.001); NEAR(s.layout.joy_zone_t,168.75,0.001); NEAR(s.layout.joy_min_x,68,0.001); NEAR(s.layout.joy_max_y,307,0.001);
dm_tc_begin(&s,0,90,275);
CHECK(s.joy_slot==0); NEAR(s.joy_origin_x,90,0); NEAR(s.joy_origin_y,275,0);
CHECK(s.lx==0 && s.ly==0);
@@ -135,8 +135,15 @@ static void joystick_deadzone(void) {
dm_tc_move(&s,0,600,200); CHECK(s.lx==DM_STICK_MAX && s.ly==0); NEAR(s.joy_origin_x,200,0);
dm_tc_move(&s,0,200,25); CHECK(s.lx==0 && s.ly==DM_STICK_MAX); NEAR(s.joy_origin_y,200,0);
dm_tc_end(&s,0); CHECK(s.joy_slot==-1 && s.lx==0 && s.ly==0); NEAR(s.layout.joy_x,120,0.001);
/* 贴左下角落指 (10,370):圆心夹回 (60,290),手指在圆心左下 (−50,−80),一落下就是左下满偏 | touching down against the bottom-left corner (10,370): the centre is clamped back to (60,290), the finger is at (-50,-80) to the lower left of the centre, so it is at full lower-left deflection the moment it lands */
dm_tc_begin(&s,0,10,370); CHECK(s.joy_slot==0); NEAR(s.joy_origin_x,60,0); NEAR(s.joy_origin_y,290,0); CHECK(s.lx<0 && s.ly<0); dm_tc_end(&s,0);
/* 贴左下角落指 (10,370):底盘画在夹回后的 (68,307),轴值按手指相对落点算——落指那一下为 0;向右挪 6 点仍在死区;7 点起出值 (7−6)/54 × 32767 = 607;
向右拖满 60 点 = 向右满偏(不是按底盘圆心算出来的「左下」)。底盘不跟手走
touching down against the bottom-left corner (10,370): the base is drawn at the clamped (68,307), and the axes are computed from the finger relative to the touch point - 0 on touch-down; moving 6 points right is still inside the dead zone; from 7 points the output is (7-6)/54 x 32767 = 607;
dragging the full 60 points right = full right deflection (not the "down-left" one would get by computing from the base centre). The base does not follow the finger */
dm_tc_begin(&s,0,10,370); CHECK(s.joy_slot==0); NEAR(s.joy_origin_x,68,0); NEAR(s.joy_origin_y,307,0); CHECK(s.lx==0 && s.ly==0);
dm_tc_move(&s,0,16,370); CHECK(s.lx==0 && s.ly==0);
dm_tc_move(&s,0,17,370); CHECK(abs(s.lx-607)<=1 && s.ly==0);
dm_tc_move(&s,0,70,370); CHECK(s.lx==DM_STICK_MAX && s.ly==0); NEAR(s.joy_origin_x,68,0); NEAR(s.joy_origin_y,307,0);
dm_tc_end(&s,0);
dm_tc_begin(&s,0,266,169); CHECK(s.joy_slot==0); NEAR(s.joy_origin_x,266,0); NEAR(s.joy_origin_y,169,0); dm_tc_end(&s,0); /* 区的右上角以内 | just inside the zone's top-right corner */
/* 区外:不起摇杆,拖也不变成摇杆 | outside the zone: no stick starts, and dragging does not turn into a stick either */
dm_tc_begin(&s,0,267,275); CHECK(s.joy_slot==-1 && s.lx==0); dm_tc_end(&s,0);
@@ -145,13 +152,31 @@ static void joystick_deadzone(void) {
/* 区里很快原地松开的那一下兼作点击(落点记成点世界),按久了 / 拖开了的不算 | a quick release in place inside the zone doubles as a tap (the touch point is recorded as a world tap); held long / dragged away does not count */
{ unsigned q = s.world_tap_seq; dm_tc_begin_at(&s,0,150,250,40.0); dm_tc_end_at(&s,0,40.1); CHECK(s.world_tap_seq==q+1); NEAR(s.world_tap_x,150,0); NEAR(s.world_tap_y,250,0);
dm_tc_begin_at(&s,0,150,250,41.0); dm_tc_move_at(&s,0,200,250,41.05); dm_tc_end_at(&s,0,41.1); CHECK(s.world_tap_seq==q+1); }
/* 拖远了的摇杆手指被系统取消,0.2 秒后在离取消处 40 点的 (236,128) 重新落下((260,160) 偏 (−24,−32);已在起摇杆区上界 168.75 之外):接着当摇杆,圆心沿用取消前的 (90,275)、方向按旧圆心算;超时:不接 | the stick finger, dragged far away, is cancelled by the system and 0.2 s later touches down again at (236,128), 40 points from where it was cancelled ((260,160) offset by (-24,-32); already above the zone's upper bound 168.75): it continues as the stick, the centre stays at (90,275) from before the cancel and the direction is computed from the old centre; after the timeout: not continued */
/* 拖远了的摇杆手指被系统取消,0.2 秒后在离取消处 40 点的 (236,128) 重新落下((260,160) 偏 (−24,−32);已在起摇杆区上界 168.75 之外):接着当摇杆,落点与底盘沿用取消前的 (90,275)、方向按旧落点算;超时:不接 | the stick finger, dragged far away, is cancelled by the system and 0.2 s later touches down again at (236,128), 40 points from where it was cancelled ((260,160) offset by (-24,-32); already above the zone's upper bound 168.75): it continues as the stick, the touch point and base stay at (90,275) from before the cancel and the direction is computed from the old touch point; after the timeout: not continued */
dm_tc_begin_at(&s,0,90,275,50.0); dm_tc_move_at(&s,0,260,160,50.2); CHECK(s.lx>0 && s.ly>0); dm_tc_cancel_finger(&s,0); CHECK(s.joy_slot==-1 && s.lx==0);
dm_tc_begin_at(&s,1,236,128,50.4); CHECK(s.joy_slot==1 && s.lx>0 && s.ly>0); NEAR(s.joy_origin_x,90,0); NEAR(s.joy_origin_y,275,0); dm_tc_cancel_finger(&s,1);
dm_tc_begin_at(&s,2,236,128,50.4+0.36); CHECK(s.joy_slot==-1); dm_tc_end_at(&s,2,51.5); /* 超过 0.35 秒、落点在区外 | beyond 0.35 s, touch point outside the zone */
/* 取消后在区里别处重落(离取消处 140 点,不算接续):按新落点起一个新的,圆心 (265, min(300,290)) | after a cancel, touching down elsewhere in the zone (140 points from where it was cancelled, not a continuation): a new stick starts at the new touch point, centre (265, min(300,290)) */
/* 取消后在区里别处重落(离取消处 140 点,不算接续):按新落点起一个新的,圆心 (265, min(300,307)) = (265,300),落指那一下轴为 0 | after a cancel, touching down elsewhere in the zone (140 points from where it was cancelled, not a continuation): a new stick starts at the new touch point, centre (265, min(300,307)) = (265,300), axes 0 on touch-down */
dm_tc_begin_at(&s,0,90,275,52.0); dm_tc_move_at(&s,0,260,160,52.2); dm_tc_cancel_finger(&s,0);
dm_tc_begin_at(&s,1,265,300,52.3); CHECK(s.joy_slot==1); NEAR(s.joy_origin_x,265,0); NEAR(s.joy_origin_y,290,0); dm_tc_end_at(&s,1,53.5);
dm_tc_begin_at(&s,1,265,300,52.3); CHECK(s.joy_slot==1); NEAR(s.joy_origin_x,265,0); NEAR(s.joy_origin_y,300,0); CHECK(s.lx==0 && s.ly==0); dm_tc_end_at(&s,1,53.5);
}
/* 956×440(k = 1)手算:夹回界 x ≥ 60+8 = 68、y ≤ 440−68 = 372,只决定底盘画在哪:(6,434) → (68,372);(60,400) → (68,372);(150,330) → 不夹。
三处落指那一下轴都为 0;各自向右、向上、向左上(45°)拖 60 点,轴值只看手指相对落点,三处完全相同:
向右 (60,0) → (32767, 0);向上 (0,60) → (0, 32767);向左上 (−42.43, 42.43) → 斜向预修正后 (−1, 2)/√5 × 32767 = (−14654, 29308)(走出来的屏幕方向 = 手指方向,同 joystick_axes 那例)。
贴左下角时向左 / 向下拖不出 60 点(手指到屏幕边了)是物理限制,不在这里测
Worked by hand for 956x440 (k = 1): clamp bounds x >= 60+8 = 68, y <= 440-68 = 372, which only decide where the base is drawn: (6,434) -> (68,372); (60,400) -> (68,372); (150,330) -> not clamped.
At all three touch points the axes are 0 on touch-down; dragging 60 points right, up and up-left (45 degrees) from each, the axes depend only on the finger relative to the touch point and are identical for all three:
right (60,0) -> (32767, 0); up (0,60) -> (0, 32767); up-left (-42.43, 42.43) -> after the diagonal pre-correction (-1, 2)/sqrt(5) x 32767 = (-14654, 29308) (the screen direction walked = the finger direction, as in the joystick_axes example).
Near the bottom-left corner a drag of 60 points to the left / downwards is not possible (the finger reaches the screen edge); that is a physical limit and not tested here */
static void joystick_clamp_956(void) {
static const float at[3][4] = {{6, 434, 68, 372}, {60, 400, 68, 372}, {150, 330, 150, 330}};
dm_tc_state s; dm_tc_init(&s,956,440); NEAR(s.layout.joy_min_x,68,0.001); NEAR(s.layout.joy_max_y,372,0.001);
for (int i = 0; i < 3; i++) { float x = at[i][0], y = at[i][1];
dm_tc_begin(&s,0,x,y); NEAR(s.joy_origin_x,at[i][2],0); NEAR(s.joy_origin_y,at[i][3],0); CHECK(s.lx==0 && s.ly==0);
dm_tc_move(&s,0,x+60,y); CHECK(s.lx==DM_STICK_MAX && s.ly==0);
dm_tc_move(&s,0,x,y-60); CHECK(s.lx==0 && s.ly==DM_STICK_MAX);
dm_tc_move(&s,0,x-42.4264f,y-42.4264f); CHECK(abs(s.lx+14654)<=2 && abs(s.ly-29308)<=2);
NEAR(s.joy_origin_x,at[i][2],0); NEAR(s.joy_origin_y,at[i][3],0); dm_tc_end(&s,0); }
}
static void joystick_axes(void) {
dm_tc_state s; dm_tc_init(&s,667,375); dm_tc_begin(&s,0,90,275); /* 圆心 90,275;下面各点 = 原用例整体平移 (−10, +75) | center 90,275; the points below = the original cases shifted as a whole by (−10, +75) */
@@ -437,7 +462,7 @@ static void safe_insets(void) {
dm_tc_set_safe_insets(62, 62); dm_tc_layout_make(&b, 956, 440); dm_tc_set_safe_insets(0, 0);
NEAR(a.target[DM_TC_MAIN].x, 900, 0.001); NEAR(b.target[DM_TC_MAIN].x, 854, 0.001); NEAR(b.target[DM_TC_MAIN].y, a.target[DM_TC_MAIN].y, 0.001);
for (int i = DM_TC_SKILL1; i <= DM_TC_SKILL4; ++i) { NEAR(a.target[i].x - b.target[i].x, 46, 0.001); NEAR(a.target[i].y, b.target[i].y, 0.001); CHECK(b.target[i].x + b.target[i].r <= 894.001f); }
NEAR(a.swap.x - b.swap.x, 46, 0.001); NEAR(a.joy_x, 120, 0.001); NEAR(b.joy_x, 152, 0.001); NEAR(b.joy_min_x, 122, 0.001); NEAR(a.joy_y, 325, 0.001); NEAR(a.joy_max_y, 355, 0.001); /* 静止位 max(90, 安全区 + 60) + 30、440 − 115;夹回界 安全区 + 60、440 − 25 − 60 | rest position max(90, safe area + 60) + 30, 440 - 115; clamp bounds safe area + 60, 440 - 25 - 60 */
NEAR(a.swap.x - b.swap.x, 46, 0.001); NEAR(a.joy_x, 120, 0.001); NEAR(b.joy_x, 152, 0.001); NEAR(b.joy_min_x, 68, 0.001); NEAR(a.joy_y, 325, 0.001); NEAR(a.joy_max_y, 372, 0.001); /* 静止位 max(90, 安全区 + 60) + 30、440 − 115(让安全区);夹回界 60 + 8、440 − 60 − 8(不让安全区) | rest position max(90, safe area + 60) + 30, 440 - 115 (respecting the safe area); clamp bounds 60 + 8, 440 - 60 - 8 (not respecting the safe area) */
dm_tc_layout c; dm_tc_layout_make(&c, 956, 440); NEAR(c.target[DM_TC_MAIN].x, 900, 0.001);
}
/* 换组键:956×440 下主键中心 (900,358),换组键在技能一正下方 (900−112, 358+52) = (788,410),半径 22;不与技能一(中心 (788,358) 半径 26)重叠、不出屏 | Set-switch button: at 956×440 the main button center is (900,358), the set-switch button is directly below skill one at (900−112, 358+52) = (788,410), radius 22; it does not overlap skill one (center (788,358), radius 26) and does not go off screen */
@@ -556,7 +581,7 @@ static void belt_single_double(void) {
}
int main(void) {
RUN(layout_667); RUN(layout_812); RUN(layout_956); RUN(layout_1024); RUN(layout_ipad169); RUN(layout_pixels); RUN(small_layout); RUN(difficulty_picker);
RUN(hit_edges); RUN(key_hold_and_ownership); RUN(two_fingers_same_key); RUN(joystick_deadzone);
RUN(hit_edges); RUN(key_hold_and_ownership); RUN(two_fingers_same_key); RUN(joystick_deadzone); RUN(joystick_clamp_956);
RUN(joystick_axes); RUN(joystick_plus_skills); RUN(no_auto_handoff); RUN(background_no_key);
RUN(circles_before_joystick); RUN(cancel_and_resize); RUN(deferred_skill_vs_belt); RUN(held_skill2_vs_belt); RUN(belt_single_double); RUN(no_ui_drag_outside_modal); RUN(invalid_slots_and_repeated_begin); RUN(all_slots_hold); RUN(enabled_targets); RUN(ui_scene_messages);
RUN(pointer_tap); RUN(world_tap); RUN(pointer_outside_close); RUN(scene_dialog_only); RUN(pointer_item_tap); RUN(pointer_stack_tap); RUN(pointer_over_disabled_target); RUN(ui_drag_typing); RUN(pointer_drag_out); RUN(pointer_drag); RUN(pointer_long); RUN(pointer_long_then_drag); RUN(pointer_long_seq); RUN(pointer_shop_drag); RUN(pointer_control_hit); RUN(pointer_game_mode); RUN(pointer_pulse_queue); RUN(safe_insets); RUN(swap_key);