Files
AVA2/runtime/login_view.py
T
shenandshen 281418f351 Fix cross-platform rendering and optimize frame performance
Correct selection orientation, game-entry lifecycle, mounted NPCs, labels and skill panels. Add the native GPU scene path, resident geometry, bounded texture and Python caches, and collision broad phase.

Pin the independently maintained Metin2 SDK through a submodule and document reproducible setup. Include rendering regressions and macOS packaging improvements.

Validation: client Debug build and 12 targeted client tests passed; SDK build and all 14 SDK tests passed.
2026-10-11 17:55:53 -07:00

118 lines
4.3 KiB
Python

# -*- coding: utf-8 -*-
# Developer view for the AVA2 port. Uses the original net extension names/callbacks.
# Original UI uses its separate script bootstrap; this controller is for transport verification.
import net
class LoginView(object):
def __init__(self):
self.phase = 'login'
self.message = 'Configure an isolated auth and game endpoint, then connect.'
self.selected = -1
self.login_starts = 0
self.handshakes = 0
self.refreshes = 0
self.inventory_refreshes = 0
self.status_refreshes = 0
net.SetHandler(self)
net.SetAccountConnectorHandler(self)
net.SetPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
net.SetPhaseWindow(net.PHASE_WINDOW_SELECT, self)
net.SetPhaseWindow(net.PHASE_WINDOW_LOAD, self)
net.SetPhaseWindow(net.PHASE_WINDOW_GAME, self)
def Connect(self, game_host, game_port, auth_host, auth_port, account, password):
net.SetLoginInfo(account, password)
net.SetPacketSequenceMode()
net.ConnectToAccountServer(game_host, game_port, auth_host, auth_port)
self.phase = 'connecting'
self.message = 'Connecting...'
self.selected = -1
def Cancel(self):
net.Disconnect()
self.phase = 'login'
self.message = 'Connection cancelled. You can retry.'
self.selected = -1
def OnHandShake(self):
self.handshakes += 1
def SetLoginPhase(self):
self.phase = 'login'
self.selected = -1
self.message = 'Game connection closed. You can reconnect.'
def OnLoginStart(self):
self.login_starts += 1
self.message = 'Authentication accepted. Reading character slots...'
def OnConnectFailure(self):
self.phase = 'login'
self.message = 'Cannot connect. Check the endpoint and retry.'
def OnLoginFailure(self, reason):
self.phase = 'login'
self.message = 'Login failed: ' + reason
self.selected = -1
def SetSelectCharacterPhase(self):
self.phase = 'select'
self.message = 'Choose an occupied character slot.'
def SetSelectEmpirePhase(self):
self.phase = 'empire'
self.message = 'Empire creation is pending in this development view.'
def Refresh(self):
self.refreshes += 1
def SetLoadingPhase(self):
self.phase = 'loading'
self.message = 'Server accepted selection. Loading game...'
def LoadData(self, playerX, playerY):
self.phase = 'loading'
self.message = 'Character loaded at (%d, %d). Starting game...' % (playerX, playerY)
net.StartGame()
def SetGamePhase(self):
self.phase = 'game'
self.message = 'In game phase.'
def RefreshInventory(self):
self.inventory_refreshes += 1
def RefreshStatus(self):
self.status_refreshes += 1
def Choose(self, slot):
if self.phase != 'select':
raise ValueError('Character list is not ready')
if not net.GetAccountCharacterSlotDataInteger(slot, net.ACCOUNT_CHARACTER_SLOT_ID):
raise ValueError('This character slot is empty')
self.selected = slot
def Enter(self):
if self.selected < 0:
raise ValueError('Choose an occupied character slot first')
port = net.GetAccountCharacterSlotDataInteger(self.selected, net.ACCOUNT_CHARACTER_SLOT_PORT)
addr = net.GetAccountCharacterSlotDataInteger(self.selected, net.ACCOUNT_CHARACTER_SLOT_ADDR)
if port != 0 and addr != 0:
net.DirectEnter(self.selected)
self.message = "DirectEnter sent. Reconnecting to map server and loading..."
else:
net.SendSelectCharacterPacket(self.selected)
self.message = "Selection sent. Waiting for server loading phase..."
self.phase = 'entering'
def Snapshot(self):
slots = []
for slot in xrange(5):
slots.append((net.GetAccountCharacterSlotDataInteger(slot, net.ACCOUNT_CHARACTER_SLOT_ID),
net.GetAccountCharacterSlotDataString(slot, net.ACCOUNT_CHARACTER_SLOT_NAME),
net.GetAccountCharacterSlotDataInteger(slot, net.ACCOUNT_CHARACTER_SLOT_LEVEL),
net.GetAccountCharacterSlotDataInteger(slot, net.ACCOUNT_CHARACTER_SLOT_RACE)))
return self.phase, self.message, self.selected, slots
view = LoginView()