// The frame-rate row of the system option dialog (PORT; 40250 has no counterpart, the PC client ran at // the monitor's rate), run by PythonBoot::RunMainScript as module mt_framerate. It wraps // uiSystemOption.OptionDialog's __Load and fills the row the original layout leaves empty at y 210 (its // shadow slider is commented out), in the style of the fog buttons above it. The value is // app.Get/SetFrameRateMode (platform/EterBase/FrameRateMode.h); the host paces frames by it and saves it. // Strings are UTF-8 here and go through player.AutoHuntLocalize into the locale's code page. static const char c_szFrameRateOptionScript[] = R"PY(# -*- coding: utf-8 -*- import app import player import ui import uiSystemOption L = player.AutoHuntLocalize SMALL_BUTTON = "d:/ymir work/ui/public/small_button_%02d.sub" ROW_Y = 210 MODE_TEXTS = ("30帧", "60帧", "最高") def _Refresh(buttons): mode = app.GetFrameRateMode() for i in xrange(len(buttons)): if i == mode: buttons[i].Down() else: buttons[i].SetUp() def _Select(buttons, mode): app.SetFrameRateMode(mode) _Refresh(buttons) def _Attach(dialog): board = dialog.GetChild("board") label = ui.TextLine() label.SetParent(board) label.SetPosition(30, ROW_Y + 2) label.SetText(L("画面帧率")) label.Show() buttons = [] for i in xrange(len(MODE_TEXTS)): 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(MODE_TEXTS[i])) button.SetEvent(lambda mode=i: _Select(buttons, mode)) button.Show() buttons.append(button) _Refresh(buttons) dialog.mtFrameRateLabel = label dialog.mtFrameRateButtons = buttons def __Install(): load = uiSystemOption.OptionDialog._OptionDialog__Load def Load(self): load(self) try: _Attach(self) except: import dbg dbg.TraceError("mt_framerate: cannot add the frame-rate row") uiSystemOption.OptionDialog._OptionDialog__Load = Load __Install() )PY";