Refine mobile HUD navigation, status readability and bounded chat preview

This commit is contained in:
shen
2026-10-19 12:23:27 -07:00
parent 0fcb0dcaa4
commit 60c66b7ba7
10 changed files with 305 additions and 42 deletions
@@ -0,0 +1,52 @@
{
"date": "2026-10-19",
"primary_entries": [
"inventory",
"shop",
"more"
],
"drawer_entries": 7,
"status_labels": "life and mana with 14px font, outlined text and contrasting background",
"chat_preview": {
"maximum_lines": 3,
"bounded_width": true,
"history_preserved": true,
"render_scissor_restored": true
},
"network_notice": {
"position": "below status and buffs",
"success_timeout_seconds": 6,
"same_state_does_not_extend": true
},
"auto_hunt": "lower edge of combat area; dim idle artwork; unchanged touch target",
"skill_layout": "same compact arc and button sizes; extra7/8 remain absent",
"checks": {
"python_tests": 158,
"network_notice_tests": 9,
"native_mobile_flow": "PASS",
"menu_and_chat_width_viewports": [
[
640,
360
],
[
800,
600
],
[
1169,
600
]
],
"combat_layout_scenarios": 6,
"macos_build": "PASS",
"android_build": "PASS",
"apk_install": "PASS",
"device_visual": "PENDING_UNLOCK",
"drawer_widget_picking_and_blank_panel_hit_test": "PASS"
},
"preview": "build/mobile-hud-refine-20261019/default.png",
"preview_scope": "macOS-hosted mobile layout with in-process server and explicit offline HP/SP/chat fixtures",
"production_changed": false,
"drawer_placement": "under the three primary entries, clear of centered map announcements"
}
+1
View File
@@ -664,3 +664,4 @@
{"time": "2026-10-19T14:13:41.385041+00:00", "event": "authorized_mobile_ui_fix", "unit": "ScriptLib/MobileHUD and host/TouchController", "finding": "Fix UTF-8 minimap tooltip boundaries. Retain original skill arc per user feedback; smaller secondary menu artwork with 48dp hit targets, compact menus with drawer and native shop entry. Proportional two-finger camera zoom, stationary-stick fix and gesture cancellation.", "evidence": ["tests/wiki/test_minimap_buttons.py", "tests/port/port_login_flow_test.cpp", "audit/evidence/mobile-ui/acceptance.json", "audit/evidence/itemshop/minimap-tooltips.json", "docs/ANDROID-TESTING.md"], "result": "158 Python tests; focused real TouchController/camera offline flow; Mi 8 Lite Android multi-pointer and menu checks. No production deployment or aggregate parity upgrade."}
{"time": "2026-10-19T14:22:27.432875+00:00", "event": "authorized_mobile_ui_refinement", "unit": "host/TouchController", "finding": "Shrink AUTO artwork to 72% while preserving hit target; tighten the single six-skill arc from radius140 to120 with 25-degree spacing and preserved clockwise order. Strengthen all-button overlap checks to actual 1.15 expanded hit radius.", "evidence": ["audit/evidence/mobile-ui/compact-controls.json", "tests/host/touch_layout_test.cpp", "docs/ANDROID-TESTING.md"], "result": "Six layout scenarios PASS; macOS and Android builds PASS, installed and visually checked on connected Mi 8 Lite. No production server change."}
{"time": "2026-10-19T14:24:36.040212+00:00", "event": "authorized_mobile_ui_refinement", "unit": "host/TouchController", "finding": "Remove mobile quick-slot buttons 7/8 from the button list and eight-control geometry; remove their render and pointer assignment branches. Keep attack, six-skill arc and AUTO.", "evidence": ["src/host/touch_controller.h", "src/host/touch_layout.h", "tests/host/touch_layout_test.cpp", "docs/ANDROID-TESTING.md"], "result": "Layout checks PASS across six screen/safe-area/target configurations. Android and macOS builds PASS. Updated APK installed on Mi 8 Lite; no server changes."}
{"time": "2026-10-19T19:10:33.466877+00:00", "event": "authorized_mobile_ui_refinement", "unit": "ScriptLib/MobileHUD, MeshPort notice and chat preview", "finding": "Three named primary entries with seven-action collapsing drawer; contrasting HP/SP numbers, lower/dim AUTO, bounded three-line chat preview using platform render scissor without modifying chat history, network status below buffs with duplicate-state suppression.", "evidence": ["audit/evidence/mobile-ui/hud-refinement.json", "tests/port/port_login_flow_test.cpp", "tests/meshport/test_login.py", "docs/ANDROID-TESTING.md"], "result": "158 Python tests, nine notice tests, native mobile menu/chat/scissor/gesture flow, six combat layouts and macOS/Android builds passed. APK installed on locked Mi 8 Lite; new on-device visual acceptance remains pending unlock. No server deployment or aggregate parity upgrade."}
+10 -1
View File
@@ -54,8 +54,12 @@ ANDROID_SERIAL=<serial> python3 tools/perf/run_render_isolation.py build/qa/devi
根据本轮用户反馈,六个技能保留围绕右下攻击键的弧形排列;自动狩猎放在外侧,底部7/8两个额外快捷按钮已移除。
菜单和自动狩猎按钮图形缩小28%,同时保留至少48dp触摸区域;头像和技能按钮保持原尺寸。
六个技能的弧半径从140缩到120(约14%),角间距从20°调整为25°,按原顺序排列,含15%扩展点击区也不重叠。
角色、背包、好友、设置及商城/更多沿屏幕上缘排列在小地图左侧;较窄画面自动换行。任务、挂机设置、帮助、聊天在“更多”中展开。
顶部仅保留带名称的背包、商城、更多。角色、好友、设置、任务、挂机设置、帮助和聊天在“更多”的三列面板中展开,点击功能后自动收起;HUD隐藏时也收起。
左侧保留移动摇杆和主要视野,副本/战令/生物学家入口继续在小地图外环。
自动狩猎移到战斗区下缘,未开启时淡化底色和边框,技能弧形、按钮大小和顺序保持。
生命/法力数字以14号字和独立深色底板显示;组网提示放在状态/增益下方,成功6秒后消失,重复状态不延长提示。
聊天预览最多显示三行并限制宽度,消息按原方式渐隐;打开输入或完整聊天记录沿用原界面。
裁剪通过 `chat.RenderPreview` 的平台绘制剪裁完成,消息和历史列表不做删减,绘制后恢复剪裁范围。
场景空白处双指张开拉近、收拢拉远;左右手先后落下均可,界面和战斗按钮优先接收各自手势。
已经推动的摇杆不会被新落下的右手抢作缩放。缩放直接按指距比例改变镜头距离,原镜头距离上限和地形碰撞仍有效。
@@ -71,3 +75,8 @@ MT_TEST_MOBILE=1 MT_TEST_PINCH=1 MT_TEST_WIKI=1 \
`MT_TEST_PINCH`只运行加载及移动端镜头/折叠菜单验收,跳过无关的频道状态探测和后续经典交互测试。
布局边界和按钮不重叠由 `tests/host/touch_layout_test.cpp` 覆盖不同屏宽、刘海留白和最小触摸尺寸。
本轮布局验收包含640×360、800×600、1169×600下的常驻入口/完整菜单/聊天编辑区边界,
以及聊天预览剪裁、完整历史保留、绘制剪裁恢复、菜单点击后收起和原双指缩放。
2026-10-19本轮新版APK已安装到Mi 8 Lite;安装时手机锁屏,当前视觉证据为macOS宿主的移动布局离线预览,
手机新版实机视觉与手指操作验收待解锁补做,不计为已通过。
+4 -5
View File
@@ -455,8 +455,6 @@ public:
for (const auto& btn : buttons_) {
// Auto hunt is a secondary action: smaller art, unchanged accessible hit radius.
const float r = btn.radius * (btn.id == kAutoHuntButton ? 0.72f : 1.0f);
draw_control_disc(commands, btn.x, btn.y, r, btn.pressed);
const uint32_t icon_col = 0xFFFFFFFF;
if (btn.id == kAutoHuntButton) {
auto visual = btn;
@@ -464,6 +462,7 @@ public:
draw_auto_hunt_button(commands, visual);
continue;
}
draw_control_disc(commands, btn.x, btn.y, r, btn.pressed);
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
if (is_quick_slot_button(btn.id)) {
@@ -694,16 +693,16 @@ private:
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
on = PythonBoot::AutoHuntIsEnabled();
#endif
const uint32_t disc = btn.pressed ? (on ? 0xEB257D32 : 0xEB16110C) : (on ? 0xDD1B5E20 : 0x8A16110C);
const uint32_t disc = btn.pressed ? (on ? 0xEB257D32 : 0xEB16110C) : (on ? 0xDD1B5E20 : 0x4416110C);
draw_filled_disc(commands, btn.x, btn.y, btn.radius * 0.88f, disc);
const uint32_t ring_col = on ? 0xFF80FF90 : (btn.pressed ? 0xFFB89545 : 0x8A997847);
const uint32_t ring_col = on ? 0xFF80FF90 : (btn.pressed ? 0xFFB89545 : 0x55997847);
draw_circle(commands, btn.x, btn.y, btn.radius * 0.90f, ring_col, 32);
if (on) {
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 uint32_t text_col = on ? 0xFFFFFFFF : (btn.pressed ? 0xFFFFFFFF : 0xBBD8C49A);
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));
+2 -2
View File
@@ -31,8 +31,8 @@ inline TouchLayout make_touch_layout(float width, float height, float safe_inset
layout.buttons[slot + 1] = {ax + std::cos(angle) * 120 * s,
ay + std::sin(angle) * 120 * s, 22 * s};
}
// Auto hunt button nestled compactly just outside the skill arc.
layout.buttons[7] = {ax - 166 * s, ay - 42 * 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;
}
+21 -3
View File
@@ -1,6 +1,7 @@
// PORT: native transport owns routing; Python displays status and handles pending-login cancellation.
static const char* c_szMeshPortScript = R"PY(# -*- coding: utf-8 -*-
import app
import sys
import ui
import wndMgr
import player
@@ -14,20 +15,36 @@ class NetworkNotice(ui.Window):
ui.Window.__init__(self)
self.label = ui.TextLine()
self.label.SetHorizontalAlignCenter()
self.label.SetOutline()
self.label.SetFontName("Tahoma:14")
self.label.AddFlag("not_pick")
self.lastEvent = 0
self.hideAt = 0
self.Show()
def OnUpdate(self):
event = native.event()
if event:
if event and event != self.lastEvent:
self.lastEvent = event
messages = {1: '正在组网,等待动态分配 IP...',
2: '组网成功', 3: '组网连接失败,请检查网络后重试'}
self.label.SetText(player.AutoHuntLocalize(messages[event]))
self.label.SetPackedFontColor(0xff66ee88 if event == 2 else 0xffffdd77)
self.label.SetPosition(wndMgr.GetScreenWidth() / 2, 32)
self.label.Show()
self.label.SetTop()
self.hideAt = app.GetTime() + (65 if event == 1 else 6)
mobile = sys.modules.get('mt_mobile_hud')
inGame = bool(mobile and getattr(mobile, 'g_hud', None))
self.hideAt = app.GetTime() + (5 if event == 1 and inGame else 65 if event == 1 else 6)
# In-game notices live below status/buffs, outside menus, FPS and map announcements.
mobile = sys.modules.get('mt_mobile_hud')
hud = getattr(mobile, 'g_hud', None) if mobile else None
if hud:
self.label.SetHorizontalAlignLeft()
self.label.SetPosition(*hud.networkNoticePosition)
else:
self.label.SetHorizontalAlignCenter()
self.label.SetPosition(wndMgr.GetScreenWidth() / 2,
min(72, max(52, int(wndMgr.GetScreenHeight()*.12))))
if self.hideAt and app.GetTime() >= self.hideAt:
self.label.Hide()
self.hideAt = 0
@@ -43,6 +60,7 @@ def _wrap_cancel(method):
if net.CancelPendingLogin():
notice.label.Hide()
notice.hideAt = 0
notice.lastEvent = 0
return method(self, *args)
return Cancel
+118 -30
View File
@@ -1,6 +1,8 @@
// PORT: mobile presentation; menu actions and player data use the existing client APIs.
static const char c_szMobileHUDScript[] = R"PY(# -*- coding: utf-8 -*-
import app
import chat
import systemSetting
import game
import grp
import math
@@ -30,10 +32,12 @@ class RoundAction(ui.Window):
def __init__(self, parent, text, action, icon=None):
ui.Window.__init__(self)
self.SetParent(parent)
self.AddFlag("float")
self.action = action
self.down = False
self.active = False
self.visualScale = 1.0
self.hasCaption = bool(text)
self.label = _Text(self, text)
self.label.SetHorizontalAlignCenter()
self.label.SetVerticalAlignCenter()
@@ -52,9 +56,11 @@ class RoundAction(ui.Window):
self.SetSize(int(size), int(size))
self.label.SetPosition(int(size/2), int(size/2))
if self.icon:
edge = size * .62 * self.visualScale
edge = size * (.48 if self.hasCaption else .62) * self.visualScale
self.icon.SetScale(edge / max(1, self.iconSize[0]), edge / max(1, self.iconSize[1]))
self.icon.SetPosition(int((size-edge)/2), int((size-edge)/2))
self.icon.SetPosition(int((size-edge)/2), int(size*(.39 if self.hasCaption else .5)-edge/2))
if self.hasCaption:
self.label.SetPosition(int(size/2), int(size*.72))
def OnRender(self):
x, y = self.GetGlobalPosition()
@@ -121,11 +127,18 @@ class Status(ui.Window):
taskbar.GetChild(name).Hide()
self.face = RoundAction(self, "", action, uiCharacter.FACE_IMAGE_DICT.get(net.GetMainActorRace()))
self.name = _Text(self, "")
self.numbersBack = ui.Bar()
self.numbersBack.SetParent(self)
self.numbersBack.AddFlag("not_pick")
self.numbersBack.SetColor(0x99131619)
self.numbersBack.Show()
self.hp = _Text(self, "")
self.sp = _Text(self, "")
self.energy = _Text(self, "")
self.hp.SetHorizontalAlignCenter()
self.sp.SetHorizontalAlignCenter()
self.hp.SetFontName("Tahoma:14")
self.sp.SetFontName("Tahoma:14")
self.hp.SetPackedFontColor(0xFFFFE9E4)
self.sp.SetPackedFontColor(0xFFD7ECFF)
self.values = (0, 1, 0, 1, 0, 1)
self.lastStatus = None
self.Show()
@@ -133,7 +146,7 @@ class Status(ui.Window):
def Place(self, scale):
self.scale = scale
self.SetPosition(int(12*scale), int(10*scale))
self.SetSize(int(290*scale), int(88*scale))
self.SetSize(int(300*scale), int(110*scale))
# The original three bars are native-size: their outer frame is 34 pixels tall.
self.face.Place(18*scale, 14*scale+12, 34)
self.name.SetPosition(int(66*scale), 0)
@@ -143,9 +156,12 @@ class Status(ui.Window):
self.frame.SetPosition(bar_x, int(14*scale))
self.hp.SetHorizontalAlignLeft()
self.sp.SetHorizontalAlignLeft()
self.hp.SetPosition(bar_x+166, int(24*scale))
self.sp.SetPosition(bar_x+166, int(42*scale))
self.energy.SetPosition(int(66*scale), int(68*scale))
text_x = int(66*scale)
self.numbersBack.SetPosition(text_x-5, int(51*scale))
self.numbersBack.SetSize(int(224*scale), int(37*scale))
self.hp.SetPosition(text_x, int(53*scale))
self.sp.SetPosition(text_x, int(71*scale))
self.energy.SetPosition(text_x, int(92*scale))
def Refresh(self):
hp, mh = player.GetStatus(player.HP), player.GetStatus(player.MAX_HP)
@@ -158,8 +174,8 @@ class Status(ui.Window):
self.taskbar.RefreshStatus()
self.lastStatus = status
self.name.SetText("%s Lv.%d" % (player.GetName(), player.GetStatus(player.LEVEL)))
self.hp.SetText("%d / %d" % (hp, mh) if mh > 0 else "--")
self.sp.SetText("%d / %d" % (sp, ms) if ms > 0 else "--")
self.hp.SetText(L("生命 %d / %d") % (hp, mh) if mh > 0 else L("生命 --"))
self.sp.SetText(L("法力 %d / %d") % (sp, ms) if ms > 0 else L("法力 --"))
energy = player.GetStatus(player.ENERGY)
remaining = player.GetStatus(player.ENERGY_END_TIME) - app.GetGlobalTimeStamp()
if energy > 0 and remaining > 0:
@@ -191,7 +207,13 @@ class HUD(ui.Window):
self.taskbar.IsShow = self.IsShow
self.chat = weakref.proxy(interface.wndChat)
self.chatColors = (self.chat.BOARD_START_COLOR, self.chat.BOARD_END_COLOR, self.chat.BOARD_MIDDLE_COLOR)
self.chat.BOARD_START_COLOR = self.chat.BOARD_END_COLOR = self.chat.BOARD_MIDDLE_COLOR = 0
self.chat.BOARD_MIDDLE_COLOR = 0xCC141719
self.chatRenderOriginal = self.chat.OnRender
self.chat.OnRender = self.RenderChatPreview
self.chatWidthOriginal = self.chat.CHAT_WINDOW_WIDTH
self.chatInputSizeOriginal = (self.chat.chatInputSet.GetWidth(), self.chat.chatInputSet.GetHeight())
self.chatPositionOriginal = self.chat.GetLocalPosition()
self.chatPlacement = None
self.status = Status(self, interface.wndTaskBar, interface.ToggleCharacterWindowStatusPage)
self.experience = self.taskbar.expGaugeBoard
self.experiencePosition = self.experience.GetLocalPosition()
@@ -202,10 +224,10 @@ class HUD(ui.Window):
point.AddFlag("not_pick")
self.experienceText = _Text(self.experience, "")
self.top = []
for text, index, action in (("", 0, interface.ToggleCharacterWindowStatusPage),
("", 1, interface.ToggleInventoryWindow),
("", 2, interface.ToggleMessenger),
("", 3, interface.ToggleSystemDialog)):
for text, index, action in (("角色", 0, interface.ToggleCharacterWindowStatusPage),
("背包", 1, interface.ToggleInventoryWindow),
("好友", 2, interface.ToggleMessenger),
("设置", 3, interface.ToggleSystemDialog)):
self.top.append(RoundAction(self, text, action, self.taskbar.toggleButtonDict[index].GetUpVisualFileName()))
def _OnAutoHuntAction():
try:
@@ -225,8 +247,19 @@ class HUD(ui.Window):
# Secondary menu art is 28% smaller; hit rectangles remain comfortably tappable.
for button in self.top + self.side + [self.shop, self.more]:
button.visualScale = .72
for button in self.side:
self.drawer = [self.top[0], self.top[2], self.top[3]] + self.side
self.menuBackdrop = ui.Bar()
self.menuBackdrop.SetParent(self)
self.menuBackdrop.SetWindowName("MobileMenuPanel")
self.menuBackdrop.AddFlag("float")
self.menuBackdrop.SetColor(0xD0181715)
self.menuBackdrop.Hide()
for button in self.drawer:
button.Hide()
# Close the drawer before handing off to the original window actions.
for button in self.top + self.side + [self.shop]:
action = button.action
button.action = lambda action=action: self.RunMenuAction(action)
self.dimensions = None
self.OnUpdate()
self.Show()
@@ -235,14 +268,48 @@ class HUD(ui.Window):
self.menuExpanded = not self.menuExpanded
self.more.label.SetText(L("收起" if self.menuExpanded else "更多"))
self.more.active = self.menuExpanded
for button in self.side:
if self.menuExpanded: button.Show()
if self.menuExpanded:
self.menuBackdrop.Show()
self.menuBackdrop.SetTop()
else:
self.menuBackdrop.Hide()
for button in self.drawer:
if self.menuExpanded:
button.Show()
button.SetTop()
else: button.Hide()
def RunMenuAction(self, action):
if self.menuExpanded:
self.ToggleMore()
action()
def RenderChatPreview(self):
if self.chat.IsEditMode():
return self.chatRenderOriginal()
if not systemSetting.IsViewChat():
return
lines = min(3, chat.GetVisibleLineCount(self.chat.chatID))
if not lines:
return
x, y = self.chat.GetGlobalPosition()
base = y+self.chat.EDIT_LINE_HEIGHT
step = chat.GetLineStep(self.chat.chatID)
top = base-lines*step-1
grp.SetColor(0x66141619)
grp.RenderBar(x, top-3, self.chatPreviewWidth, lines*step+7)
chat.RenderPreview(self.chat.chatID, int(x+6), int(top),
int(self.chatPreviewWidth-12), int(lines*step+1))
def Show(self):
ui.Window.Show(self)
self.SetTop()
def Hide(self):
if getattr(self, 'menuExpanded', False):
self.ToggleMore()
ui.Window.Hide(self)
def OnUpdate(self):
w, h = wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight()
target = max(48, mt_mobile_inventory.touch_target)
@@ -260,19 +327,33 @@ class HUD(ui.Window):
minimap.SetWindowHorizontalAlignLeft()
minimap.SetWindowVerticalAlignTop()
minimap.SetPosition(int(w-minimap.GetWidth()-12*s), int(10*s))
# Wide phones keep secondary menus in one top-edge row, clear of the skill arc.
menus = self.top + [self.shop, self.more]
columns = 6 if w >= 980 else 3
menuX = w-minimap.GetWidth()-30*s-columns*size-(columns-1)*gap
# Three named primary entries; the remaining actions live in a temporary drawer.
menus = [self.top[1], self.shop, self.more]
menuX = w-minimap.GetWidth()-30*s-3*size-2*gap
for i, button in enumerate(menus):
button.Place(menuX+(i%columns)*(size+gap), 10*s+(i//columns)*(size+gap), size)
drawerY = 10*s+((len(menus)+columns-1)//columns)*(size+gap)
for i, button in enumerate(self.side):
button.Place(menuX+(i%2)*(size+gap), drawerY+(i//2)*(size+gap), size)
self.window.affectShower.SetPosition(int(18*s), int(104*s))
chat = self.window.interface.wndChat
chat.SetPosition(int(180*s), int(h-86*s))
chat.Refresh()
button.Place(menuX+i*(size+gap), 10*s, size)
drawerX = max(12*s, menuX)
drawerY = 20*s+size
rows = (len(self.drawer)+2)//3
self.menuBackdrop.SetPosition(int(drawerX-6*s), int(drawerY-6*s))
self.menuBackdrop.SetSize(int(3*size+2*gap+12*s), int(rows*(size+gap)-gap+12*s))
for i, button in enumerate(self.drawer):
button.Place(drawerX+(i%3)*(size+gap), drawerY+(i//3)*(size+gap), size)
self.window.affectShower.SetPosition(int(18*s), int(124*s))
self.networkNoticePosition = (int(18*s), int(156*s))
self.chatPreviewWidth = min(310*s, w*.32)
self.chat.CHAT_WINDOW_WIDTH = int(min(600, w-24*s))
self.chat.chatInputSet.SetSize(self.chat.CHAT_WINDOW_WIDTH-50, 25)
self.chat.chatInputSet.RefreshPosition()
self.chatPlacement = None
edit = self.chat.IsEditMode()
placement = (w, h, target, edit)
if self.chatPlacement != placement:
self.chatPlacement = placement
s = min(1.1, max(.65, min(h/600.0, w/800.0)))
x = max(12*s, (w-self.chat.CHAT_WINDOW_WIDTH)/2) if edit else max(192*s, w*.23)
self.chat.SetPosition(int(x), int(h-64*s))
self.chat.Refresh()
# The original help prompt would duplicate the touch-sized left-side entry.
self.window.interface.wndGameButton.gameButtonDict["HELP"].Hide()
energy = self.window.interface.wndEnergyBar
@@ -293,6 +374,13 @@ class HUD(ui.Window):
def Destroy(self):
self.Hide()
self.chat.OnRender = self.chatRenderOriginal
self.chat.CHAT_WINDOW_WIDTH = self.chatWidthOriginal
self.chat.chatInputSet.SetSize(*self.chatInputSizeOriginal)
self.chat.chatInputSet.RefreshPosition()
self.chat.SetPosition(*self.chatPositionOriginal)
self.chat.Refresh()
self.chatRenderOriginal = None
self.chat.BOARD_START_COLOR, self.chat.BOARD_END_COLOR, self.chat.BOARD_MIDDLE_COLOR = self.chatColors
self.taskbar.Show, self.taskbar.Hide, self.taskbar.IsShow = self.original
self.status.Restore()
@@ -1,5 +1,6 @@
#include "StdAfx.h"
#include "PythonChat.h"
#include "../../platform/EterLib/UIRenderCommands.h" // PORT mobile preview scissor, no chat-history changes.
#include "PythonItem.h"
#include "../GameLib/ItemManager.h"
@@ -66,6 +67,22 @@ PyObject * chatRender(PyObject* poSelf, PyObject* poArgs)
return Py_BuildNone();
}
// PORT: draw the existing fading chat through a bounded mobile preview rectangle.
// The chat list, history, text layout and edit/log render paths remain owned by CPythonChat.
PyObject* chatRenderPreview(PyObject*, PyObject* args)
{
int id, x, y, width, height;
if (!PyArg_ParseTuple(args, "iiiii", &id, &x, &y, &width, &height)) return nullptr;
if (width <= 0 || height <= 0 || width > 4096 || height > 4096) {
PyErr_SetString(PyExc_ValueError, "invalid chat preview rectangle");
return nullptr;
}
UIRenderSetClip(float(x), float(y), float(width), float(height));
CPythonChat::Instance().Render(id);
UIRenderRestoreClip();
return Py_BuildNone();
}
PyObject * chatSetBoardState(PyObject* poSelf, PyObject* poArgs)
{
int iID;
@@ -459,6 +476,7 @@ void initChat()
{ "CreateChatSet", chatCreateChatSet, METH_VARARGS },
{ "Update", chatUpdate, METH_VARARGS },
{ "Render", chatRender, METH_VARARGS },
{ "RenderPreview", chatRenderPreview, METH_VARARGS },
{ "SetBoardState", chatSetBoardState, METH_VARARGS },
{ "SetPosition", chatSetPosition, METH_VARARGS },
+23 -1
View File
@@ -9,6 +9,7 @@ class Widget:
def Show(self):self.shown=True
def Hide(self):self.shown=False
def SetText(self,text):self.text=text
def SetPosition(self,x,y):self.pos=(x,y)
def __getattr__(self,name):return lambda *args:None
class Tests(unittest.TestCase):
def setUp(self):
@@ -16,7 +17,9 @@ class Tests(unittest.TestCase):
modules={n:types.ModuleType(n) for n in ['app','ui','wndMgr','player','_mt_meshport','introLogin','net']}
modules['app'].GetTime=lambda:self.now
modules['ui'].Window=modules['ui'].TextLine=Widget
modules['wndMgr'].GetScreenWidth=lambda:1280
self.width,self.height=1280,600
modules['wndMgr'].GetScreenWidth=lambda:self.width
modules['wndMgr'].GetScreenHeight=lambda:self.height
modules['player'].AutoHuntLocalize=lambda value:value
self.cancelled=False
modules['net'].CancelPendingLogin=lambda:self.cancelled
@@ -43,6 +46,25 @@ class Tests(unittest.TestCase):
self.events=[3,1,2]
self.notice.OnUpdate();self.assertIn('失败',self.notice.label.text)
self.notice.OnUpdate();self.notice.OnUpdate();self.assertEqual(self.notice.label.text,'组网成功')
def test_repeated_progress_does_not_extend_notice(self):
self.events=[1];self.notice.OnUpdate();deadline=self.notice.hideAt
self.now=10;self.events=[1];self.notice.OnUpdate()
self.assertEqual(self.notice.hideAt,deadline)
self.now=66;self.notice.OnUpdate();self.assertFalse(self.notice.label.shown)
def test_ingame_progress_is_brief_and_does_not_reset_on_same_state(self):
old=sys.modules.get('mt_mobile_hud')
try:
sys.modules['mt_mobile_hud']=types.SimpleNamespace(g_hud=types.SimpleNamespace(networkNoticePosition=(18,156)))
self.events=[1];self.notice.OnUpdate();self.assertEqual(self.notice.hideAt,5)
self.assertEqual(self.notice.label.pos,(18,156))
self.now=6;self.events=[1];self.notice.OnUpdate();self.assertFalse(self.notice.label.shown)
finally:
if old is None:sys.modules.pop('mt_mobile_hud',None)
else:sys.modules['mt_mobile_hud']=old
def test_notice_repositions_below_top_controls_after_resize(self):
self.events=[2];self.notice.OnUpdate();self.assertEqual(self.notice.label.pos,(640,72))
self.width,self.height=800,360;self.notice.OnUpdate()
self.assertEqual(self.notice.label.pos,(400,52))
def test_no_login_hooks_or_password_capture(self):
self.assertNotIn('LoginWindow.Connect =',SOURCE);self.assertNotIn('password',SOURCE)
def test_cancel_login_hides_only_its_pending_notice(self):
+56
View File
@@ -511,6 +511,62 @@ int main(int argc, char** argv)
"assert _hud.menuExpanded and all(b.IsShow() for b in _hud.side)\n"
"_hud.ToggleMore()\n"
"assert not _hud.menuExpanded and all(not b.IsShow() for b in _hud.side)"));
CHECK(py("import player\nassert _hud.top[1].IsShow() and not any(b.IsShow() for b in [_hud.top[0],_hud.top[2],_hud.top[3]])\n"
"_hud.ToggleMore()\n"
"assert all(b.IsShow() for b in _hud.drawer) and _hud.menuBackdrop.IsShow()\n"
"_hud.top[1].action()\n"
"assert not _hud.menuExpanded and not _hud.menuBackdrop.IsShow()\n"
"assert _hud.window.interface.wndInventory.IsShow()\n"
"_hud.window.interface.wndInventory.Hide()\n"
"assert player.FeatureLocaleToUTF8(_hud.status.hp.GetText()).decode('utf-8').startswith(u'\\u751f\\u547d ')\n"
"assert player.FeatureLocaleToUTF8(_hud.status.sp.GetText()).decode('utf-8').startswith(u'\\u6cd5\\u529b ')"));
CHECK(py("_hud.ToggleMore()\n_menu_b=_hud.drawer[0]"));
std::string drawerXY;
CHECK(PythonBoot::Evaluate("'%d %d' % _menu_b.GetGlobalPosition()", &drawerXY, nullptr));
int drawerX=0,drawerY=0;
CHECK(std::sscanf(drawerXY.c_str(), "'%d %d'", &drawerX, &drawerY)==2 ||
std::sscanf(drawerXY.c_str(), "%d %d", &drawerX, &drawerY)==2);
PythonBoot::UIMouseMove(drawerX+24,drawerY+24);
CHECK(py_true("__import__('wndMgr').IsPickedWindow(_menu_b.hWnd)"));
CHECK(PythonBoot::IsPointInsideActiveUI(drawerX-3,drawerY-3));
CHECK(py("_hud.ToggleMore()"));
// Main entries, the complete drawer and the editing window fit narrow/wide layouts.
for (const auto dimensions : {std::pair{640,360}, std::pair{800,600}, std::pair{1169,600}}) {
PythonBoot::SetUISize(dimensions.first, dimensions.second);
CHECK(py("import wndMgr\n_hud.OnUpdate()\n"
"_hud.ToggleMore()\n"
"for b in [_hud.top[1],_hud.shop,_hud.more]+_hud.drawer:\n"
" x,y=b.GetGlobalPosition(); assert x>=0 and y>=0 and x+b.GetWidth()<=wndMgr.GetScreenWidth() and y+b.GetHeight()<=wndMgr.GetScreenHeight()\n"
"_hud.ToggleMore()\n"
"_hud.chat.OpenChat(); _hud.OnUpdate()\n"
"assert _hud.chat.GetGlobalPosition()[0]+_hud.chat.GetWidth()<=wndMgr.GetScreenWidth()\n"
"_hud.chat.CloseChat(); _hud.OnUpdate()"));
}
PythonBoot::SetUISize(800,600);
CHECK(py("_hud.OnUpdate()"));
// Preview only clips rendering: preserve complete chat history and restore full-screen scissor.
CHECK(py("import chat\n"
"_preview_id=20261019\n"
"chat.CreateChatSet(_preview_id)\n"
"chat.SetPosition(_preview_id,20,200)\n"
"chat.SetHeight(_preview_id,300)\n"
"for i in range(8): chat.AppendChat(chat.CHAT_TYPE_INFO, 'PREVIEW_%d_'%i+'long message '*40)\n"
"chat.Update(_preview_id)\n"
"_history_count=chat.GetLineCount(_preview_id)"));
UIRenderSetSize(800,600);
UIRenderBeginFrame();
CHECK(py("chat.RenderPreview(_preview_id,10,150,100,45)"));
const auto previewCommands = UIRenderCommands();
CHECK(!previewCommands.empty());
for (const auto& command : previewCommands) {
CHECK(command.clip_x1 == 10 && command.clip_y1 == 150);
CHECK(command.clip_x2 == 110 && command.clip_y2 == 195);
}
UIRenderBeginFrame();
CHECK(py("chat.Render(_preview_id)\nassert chat.GetLineCount(_preview_id)==_history_count"));
CHECK(!UIRenderCommands().empty());
for (const auto& command : UIRenderCommands())
CHECK(command.clip_x1==0 && command.clip_x2==800 && command.clip_y1==0 && command.clip_y2==600);
TouchController touch;
touch.set_enabled(true);
touch.update_screen_size(800, 600);