port 4-a: text input through CPythonIME (login typed, in-game chat)
- UserInterface/PythonIME(+Module) ported verbatim; ime module stubs removed, initime() after initdbg() - EterLib/IME.cpp in platform/: 40250 buffer/WMChar bodies, IMM/TSF processors no-op; committed multi-byte text via PythonBoot::UIChar emulating GCS_RESULTSTR - GameApplicationAdapter RunIME* -> CWindowManager; Godot keys -> ui_ime_key/ui_char - port.login_flow/login_live type the account through the IME; chat CG_CHAT round-trip on the fake server - python_game_render_test logs in with Godot key events Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
1bda4390d6
commit
6ea0fa9889
@@ -29,6 +29,25 @@ func _check(ok: bool, message: String) -> void:
|
||||
func _py(source: String) -> bool:
|
||||
return Metin2PythonHost.run_line(source) == ""
|
||||
|
||||
func _key(keycode: Key, unicode: int, pressed: bool) -> void:
|
||||
var event := InputEventKey.new()
|
||||
event.keycode = keycode
|
||||
event.physical_keycode = keycode
|
||||
event.unicode = unicode
|
||||
event.pressed = pressed
|
||||
root.push_input(event)
|
||||
|
||||
func _press(keycode: Key) -> void:
|
||||
_key(keycode, 0, true)
|
||||
_key(keycode, 0, false)
|
||||
|
||||
func _type(text: String) -> void:
|
||||
for i in text.length():
|
||||
var ch := text.unicode_at(i)
|
||||
var keycode := OS.find_keycode_from_string(text[i].to_upper())
|
||||
_key(keycode, ch, true)
|
||||
_key(keycode, ch, false)
|
||||
|
||||
func _pump_until(seconds: float, condition: Callable) -> bool:
|
||||
var deadline := Time.get_ticks_msec() + int(seconds * 1000.0)
|
||||
while Time.get_ticks_msec() < deadline:
|
||||
@@ -83,13 +102,24 @@ func run() -> void:
|
||||
"assert isinstance(_stream.curPhaseWindow, introLogin.LoginWindow)"))
|
||||
_check(at_login, "login window")
|
||||
|
||||
# LoginWindow.Connect with the account from the environment.
|
||||
# The account from the environment is typed into the login board as key events (WM_KEYDOWN/WM_CHAR
|
||||
# through PythonUISurface → CPythonIME); Return runs __OnClickLoginButton → LoginWindow.Connect.
|
||||
_check(_py("_env = os.environ\n"
|
||||
+ "_slot = int(_env.get('MT_LIVE_SLOT', '0'))\n"
|
||||
+ "_stream.SetConnectInfo(_env['MT_LIVE_HOST'], int(_env.get('MT_LIVE_GAME_PORT', '13000')), "
|
||||
+ "_env['MT_LIVE_HOST'], int(_env.get('MT_LIVE_AUTH_PORT', '11000')))\n"
|
||||
+ "_stream.curPhaseWindow.Connect(_env['MT_LIVE_LOGIN'], _env['MT_LIVE_PASSWORD'])\n"
|
||||
+ "del _env"), "LoginWindow.Connect")
|
||||
+ "_w = _stream.curPhaseWindow\n"
|
||||
+ "_w._LoginWindow__OpenLoginBoard()\n"
|
||||
+ "_w.idEditLine.SetText('')\n"
|
||||
+ "_w.pwdEditLine.SetText('')\n"
|
||||
+ "_w.idEditLine.SetFocus()"), "login board open")
|
||||
_type(OS.get_environment("MT_LIVE_LOGIN"))
|
||||
_press(KEY_TAB)
|
||||
_type(OS.get_environment("MT_LIVE_PASSWORD"))
|
||||
_check(_py("assert _w.idEditLine.GetText() == _env['MT_LIVE_LOGIN']\n"
|
||||
+ "assert _w.pwdEditLine.GetText() == _env['MT_LIVE_PASSWORD']"), "account typed through the IME")
|
||||
_check(_py("del _env, _w"), "login locals dropped")
|
||||
_press(KEY_ENTER)
|
||||
var selecting := await _pump_until(30, func(): return _py(
|
||||
"assert isinstance(_stream.curPhaseWindow, introSelect.SelectCharacterWindow)"))
|
||||
_check(selecting, "character select")
|
||||
|
||||
Reference in New Issue
Block a user