Refine mobile HUD navigation, status readability and bounded chat preview
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user