移动端界面大小设置:默认 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:
co-authored by
Claude Opus 5.5
parent
e33e41c12b
commit
71d8f8c6e7
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
// PORT: the player's UI size setting (system option dialog, app.Get/SetUIHeight), shared between the
|
||||
// script thread and the host (src/host/ui_scale.cpp), which lays the 40250 UI out that many logical
|
||||
// pixels high and scales it onto the screen, and saves the choice. 40250 has no counterpart: the PC
|
||||
// client's UI pixels were screen pixels. A lower height draws every window and text larger.
|
||||
|
||||
#include <atomic>
|
||||
|
||||
namespace MtUIScale {
|
||||
|
||||
// The choices, lowest (largest UI) first. 600 is the 40250 minimum resolution's height: the inventory
|
||||
// and character windows need about that much.
|
||||
inline constexpr int c_aiHeights[] = {600, 700, 800};
|
||||
inline constexpr int c_iDefaultHeight = 600;
|
||||
|
||||
inline bool IsValid(int height)
|
||||
{
|
||||
for (int choice : c_aiHeights)
|
||||
if (choice == height)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// The height the running client lays out at (0 = the setting is unavailable: a desktop window lays
|
||||
// out at its own size). Set once by the host at startup; a new choice applies at the next start.
|
||||
inline std::atomic<int>& Applied()
|
||||
{
|
||||
static std::atomic<int> height{0};
|
||||
return height;
|
||||
}
|
||||
|
||||
// The player's choice, saved by the host when it changes.
|
||||
inline std::atomic<int>& Chosen()
|
||||
{
|
||||
static std::atomic<int> height{0};
|
||||
return height;
|
||||
}
|
||||
|
||||
inline void Set(int height)
|
||||
{
|
||||
if (IsValid(height) && Applied().load(std::memory_order_relaxed))
|
||||
Chosen().store(height, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
} // namespace MtUIScale
|
||||
@@ -877,6 +877,7 @@ namespace PythonBoot
|
||||
#include "AutoHuntScript.inc"
|
||||
#include "RegisterScript.inc"
|
||||
#include "FrameRateOptionScript.inc"
|
||||
#include "UIScaleOptionScript.inc"
|
||||
#include "InventoryPagesScript.inc"
|
||||
|
||||
static void install_script_module(const char* c_szModule, const char* c_szScript)
|
||||
@@ -934,6 +935,7 @@ bool RunMainScript(const char* lpCmdLine, std::string* error)
|
||||
install_script_module("mt_autohunt", c_szAutoHuntScript);
|
||||
install_script_module("mt_register", c_szRegisterScript);
|
||||
install_script_module("mt_framerate", c_szFrameRateOptionScript);
|
||||
install_script_module("mt_uiscale", c_szUIScaleOptionScript);
|
||||
install_script_module("mt_inventory", c_szInventoryPagesScript);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -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";
|
||||
Reference in New Issue
Block a user