// PORT: native transport owns routing; Python displays status and handles pending-login cancellation. static const char* c_szMeshPortScript = R"PY(# -*- coding: utf-8 -*- import app import ui import wndMgr import player import introLogin import net import _mt_meshport as native class NetworkNotice(ui.Window): def __init__(self): ui.Window.__init__(self) self.label = ui.TextLine() self.label.SetHorizontalAlignCenter() self.hideAt = 0 self.Show() def OnUpdate(self): event = native.event() if event: messages = {1: '正在组网,等待动态分配 IP...', 2: '组网成功', 3: '组网连接失败,请检查网络后重试'} self.label.SetText(player.AutoHuntLocalize(messages[event])) self.label.SetPackedFontColor(0xff66ee88 if event == 2 else 0xffffdd77) self.label.SetPosition(wndMgr.GetScreenWidth() / 2, 32) self.label.Show() self.label.SetTop() self.hideAt = app.GetTime() + (65 if event == 1 else 6) if self.hideAt and app.GetTime() >= self.hideAt: self.label.Hide() self.hideAt = 0 notice = NetworkNotice() # Original login popup uses the focus callback for its Cancel button. Stop only # the account/game transports still preparing; leave established sessions and # background channel queries alone. No credentials or Connect methods are wrapped. def _wrap_cancel(method): def Cancel(self, *args): if net.CancelPendingLogin(): notice.label.Hide() notice.hideAt = 0 return method(self, *args) return Cancel introLogin.LoginWindow.SetPasswordEditLineFocus = _wrap_cancel(introLogin.LoginWindow.SetPasswordEditLineFocus) introLogin.LoginWindow.OnPressExitKey = _wrap_cancel(introLogin.LoginWindow.OnPressExitKey) introLogin.LoginWindow.Close = _wrap_cancel(introLogin.LoginWindow.Close) )PY";