移动端界面大小设置:默认 600 逻辑高,系统选项可选 600/700/800

Android 上 40250 界面原先固定按 800 逻辑像素高排版,弹窗文字在手机上只有约 1 mm 高。
- UIScaleMode.h + host ui_scale.cpp:逻辑高度来自保存的设置(默认 600),ui_height.cfg 保存,下次启动生效;
  桌面可用 MT_UI_HEIGHT 测试
- app.GetUIHeight/GetAppliedUIHeight/SetUIHeight
- mt_uiscale PORT 模块:系统选项对话框加高一行,"界面大小 大/中/小",修改后聊天提示重启生效

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-29 23:10:51 +09:00
co-authored by Claude Opus 5.5
parent e33e41c12b
commit 71d8f8c6e7
10 changed files with 248 additions and 9 deletions
@@ -0,0 +1,92 @@
// The UI-size row of the system option dialog (PORT; 40250 has no counterpart, its UI pixels were screen
// pixels), run by PythonBoot::RunMainScript as module mt_uiscale after mt_framerate. It wraps
// uiSystemOption.OptionDialog's __Load, grows the dialog by one row below the frame-rate row and fills it
// in the same style. The value is app.Get/SetUIHeight (platform/EterBase/UIScaleMode.h): the logical
// height the host lays the UI out at, saved by the host and applied at the next start. The row is only
// added where the setting exists (Android, or MT_UI_HEIGHT on the desktop).
// Strings are UTF-8 here and go through player.AutoHuntLocalize into the locale's code page.
static const char c_szUIScaleOptionScript[] = R"PY(# -*- coding: utf-8 -*-
import app
import chat
import player
import ui
import uiSystemOption
L = player.AutoHuntLocalize
SMALL_BUTTON = "d:/ymir work/ui/public/small_button_%02d.sub"
ROW_Y = 235
ROW_H = 25
HEIGHTS = (600, 700, 800)
HEIGHT_TEXTS = ("大", "中", "小")
def _Refresh(buttons):
height = app.GetUIHeight()
for i in xrange(len(buttons)):
if HEIGHTS[i] == height:
buttons[i].Down()
else:
buttons[i].SetUp()
def _Select(buttons, height):
changed = height != app.GetUIHeight()
app.SetUIHeight(height)
_Refresh(buttons)
if changed:
if height == app.GetAppliedUIHeight():
chat.AppendChat(chat.CHAT_TYPE_INFO, L("界面大小已恢复为当前设置"))
else:
chat.AppendChat(chat.CHAT_TYPE_INFO, L("界面大小将在重新启动游戏后生效"))
def _Attach(dialog):
if not app.GetAppliedUIHeight():
return
board = dialog.GetChild("board")
width = dialog.GetWidth()
height = dialog.GetHeight() + ROW_H
dialog.SetSize(width, height)
board.SetSize(width, height)
dialog.SetCenterPosition()
label = ui.TextLine()
label.SetParent(board)
label.SetPosition(30, ROW_Y + 2)
label.SetText(L("界面大小"))
label.Show()
buttons = []
for i in xrange(len(HEIGHTS)):
button = ui.RadioButton()
button.SetParent(board)
button.SetUpVisual(SMALL_BUTTON % 1)
button.SetOverVisual(SMALL_BUTTON % 2)
button.SetDownVisual(SMALL_BUTTON % 3)
button.SetPosition(110 + 50 * i, ROW_Y)
button.SetText(L(HEIGHT_TEXTS[i]))
button.SetEvent(lambda height=HEIGHTS[i]: _Select(buttons, height))
button.Show()
buttons.append(button)
_Refresh(buttons)
dialog.mtUIScaleLabel = label
dialog.mtUIScaleButtons = buttons
def __Install():
load = uiSystemOption.OptionDialog._OptionDialog__Load
def Load(self):
load(self)
try:
_Attach(self)
except:
import dbg
dbg.TraceError("mt_uiscale: cannot add the UI size row")
uiSystemOption.OptionDialog._OptionDialog__Load = Load
__Install()
)PY";