diff --git a/docs/PORT-PLAN.md b/docs/PORT-PLAN.md index 3235098c..1806396c 100644 --- a/docs/PORT-PLAN.md +++ b/docs/PORT-PLAN.md @@ -117,7 +117,8 @@ PORT 扩展(40250 没有对应物,只为移动端/平台而加;不能改 4 - 由 `PythonBoot::RunMainScript` 注入的 Python 模块:`mt_autohunt`(自动狩猎,`AutoHuntScript.inc`)、`mt_register` (客户端内账号注册)、`mt_framerate`(系统选项里的"画面帧率"行)、`mt_uiscale`(系统选项里的"界面大小"行)、`mt_inventory`(5 页背包:改写 `InventoryWindow.py` 的装备格起点和页签, - 泛化翻页、自动药水高亮和选宝石窗口的格子扫描)。它们包装 40250 窗口类的方法,不修改脚本文件。 + 泛化翻页、自动药水高亮和选宝石窗口的格子扫描)、`mt_mallhint`(系统菜单"商城"按钮和服务端 `mall` 命令改为 + 提示去各村杂货店旁的 NPC 9010 百店老板娘购买,见 `tools/server/item-mall-shop/`;203 没有网页商城)。它们包装 40250 窗口类的方法,不修改脚本文件。 - 界面大小(`platform/EterBase/UIScaleMode.h` + `src/host/ui_scale.cpp`):Android 上 40250 界面按 600 / 700 / 800 逻辑像素高排版(默认 600,最低就是 600:背包窗口 565 高),宽度随屏幕比例;选择存在 `ui_height.cfg`,下次启动生效。 桌面按窗口大小排版,`MT_UI_HEIGHT=600` 可在桌面上测试这一设置。 diff --git a/src/platform/ScriptLib/MallHintScript.inc b/src/platform/ScriptLib/MallHintScript.inc new file mode 100644 index 00000000..f8d27f47 --- /dev/null +++ b/src/platform/ScriptLib/MallHintScript.inc @@ -0,0 +1,44 @@ +// The system menu's 商城 button (PORT), run by PythonBoot::RunMainScript as module mt_mallhint. In 40250 it +// sends /in_game_mall and the server answers `mall `, which game.GameWindow opens in the web window; +// 203 has no web shop and the port has no web view, so the window stayed empty. The mall items are sold by +// NPC 9010 百店老板娘 next to each village's general store instead (tools/server/item-mall-shop), so the +// button, and a `mall` command from the server, show where to find her. Both are replaced on the classes +// before the system dialog and the game window are created, which bind them. +// Strings are UTF-8 here and go through player.AutoHuntLocalize into the locale's code page. +static const char c_szMallHintScript[] = R"PY(# -*- coding: utf-8 -*- +import chat +import game +import player +import uiCommon +import uiSystem + +L = player.AutoHuntLocalize + +HINT = "商城物品请到各村杂货店旁的百店老板娘处购买" +POPUP_WIDTH = 330 + +_popup = [] + + +def _ShowHint(): + chat.AppendChat(chat.CHAT_TYPE_INFO, L(HINT)) + if not _popup: + popup = uiCommon.PopupDialog() + popup.SetWidth(POPUP_WIDTH) + popup.SetText(L(HINT)) + _popup.append(popup) + _popup[0].Open() + + +def _ClickInGameShopButton(self): + self.Close() + _ShowHint() + + +def _InGameShop_Show(self, url): + _ShowHint() + + +uiSystem.SystemDialog._SystemDialog__ClickInGameShopButton = _ClickInGameShopButton +game.GameWindow._GameWindow__InGameShop_Show = _InGameShop_Show +)PY"; diff --git a/src/platform/ScriptLib/PythonBoot.cpp b/src/platform/ScriptLib/PythonBoot.cpp index 16a70b2f..9bd8576a 100644 --- a/src/platform/ScriptLib/PythonBoot.cpp +++ b/src/platform/ScriptLib/PythonBoot.cpp @@ -879,6 +879,7 @@ namespace PythonBoot #include "FrameRateOptionScript.inc" #include "UIScaleOptionScript.inc" #include "InventoryPagesScript.inc" +#include "MallHintScript.inc" static void install_script_module(const char* c_szModule, const char* c_szScript) { @@ -937,6 +938,7 @@ bool RunMainScript(const char* lpCmdLine, std::string* error) install_script_module("mt_framerate", c_szFrameRateOptionScript); install_script_module("mt_uiscale", c_szUIScaleOptionScript); install_script_module("mt_inventory", c_szInventoryPagesScript); + install_script_module("mt_mallhint", c_szMallHintScript); } return true; }