// 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";