• 🎉 Hey there! I've just launched my brand new server voting platform — Metin2 P Servers 🚀

Not answered Changing the login interface

Member
Nov
Threads
1
52
0
6

AD: Mt2009 - Mobile & PC - 30 January 2026 CHECK THE PRESENTATION!

Sorry for my English.
I have a client from Martysamy 5.7 files from the forum. In the client, I replace the "intrologin.py" file in root. Everything works but after the loading screen it doesn't start the game.

I have this error.
Code:
1112 00:32:14928 :: File "networkModule.py", line 236, in SetGamePhase
1112 00:32:14928 :: File "game.py", line 86, in __init__
1112 00:32:14928 :: File "interfaceModule.py", line 310, in MakeInterface
1112 00:32:14929 :: File "interfaceModule.py", line 212, in __MakeWindows
1112 00:32:14929 :: File "uiMoveChannel.py", line 23, in __init__
1112 00:32:14929 :: File "uiMoveChannel.py", line 90, in __LoadWindow
1112 00:32:14929 :: File "uiMoveChannel.py", line 97, in __AddChannelButtons
1112 00:32:14929 :: File "uiMoveChannel.py", line 93, in GetChannelCount
1112 00:32:14929 :: KeyError
1112 00:32:14929 :: :
1112 00:32:14929 :: 0
1112 00:32:14929 ::

my original intrologin.py file from the client.
Code:
import dbg
import app
import net
import ui
import ime
import snd
import wndMgr
import musicInfo
import serverInfo
import systemSetting
import ServerStateChecker
import localeInfo
import constInfo
import uiCommon
import time
import serverCommandParser
import ime
import uiScriptLocale

LOGIN_DELAY_SEC = 0.0
SKIP_LOGIN_PHASE = False
SKIP_LOGIN_PHASE_SUPPORT_CHANNEL = False
FULL_BACK_IMAGE = False

VIRTUAL_KEYBOARD_NUM_KEYS = 46
VIRTUAL_KEYBOARD_RAND_KEY = True

def Suffle(src):
    if VIRTUAL_KEYBOARD_RAND_KEY:
        items = [item for item in src]

        itemCount = len(items)
        for oldPos in xrange(itemCount):
            newPos = app.GetRandom(0, itemCount-1)
            items[newPos], items[oldPos] = items[oldPos], items[newPos]

        return "".join(items)
    else:
        return src

def IsFullBackImage():
    global FULL_BACK_IMAGE
    return FULL_BACK_IMAGE

def IsLoginDelay():
    global LOGIN_DELAY_SEC
    if LOGIN_DELAY_SEC > 0.0:
        return True
    else:
        return False

def GetLoginDelay():
    global LOGIN_DELAY_SEC
    return LOGIN_DELAY_SEC

app.SetGuildMarkPath("test")

class ConnectingDialog(ui.ScriptWindow):

    def __init__(self):
        ui.ScriptWindow.__init__(self)
        self.__LoadDialog()
        self.eventTimeOver = lambda *arg: None
        self.eventExit = lambda *arg: None

    def __del__(self):
        ui.ScriptWindow.__del__(self)

    def __LoadDialog(self):
        try:
            PythonScriptLoader = ui.PythonScriptLoader()
            PythonScriptLoader.LoadScriptFile(self, "UIScript/ConnectingDialog.py")

            self.board = self.GetChild("board")
            self.message = self.GetChild("message")
            self.countdownMessage = self.GetChild("countdown_message")

        except:
            import exception
            exception.Abort("ConnectingDialog.LoadDialog.BindObject")

    def Open(self, waitTime):
        curTime = time.clock()
        self.endTime = curTime + waitTime

        self.Lock()
        self.SetCenterPosition()
        self.SetTop()
        self.Show()

    def Close(self):
        self.Unlock()
        self.Hide()

    def Destroy(self):
        self.Hide()
        self.ClearDictionary()

    def SetText(self, text):
        self.message.SetText(text)

    def SetCountDownMessage(self, waitTime):
        self.countdownMessage.SetText("%.0f%s" % (waitTime, localeInfo.SECOND))

    def SAFE_SetTimeOverEvent(self, event):
        self.eventTimeOver = ui.__mem_func__(event)

    def SAFE_SetExitEvent(self, event):
        self.eventExit = ui.__mem_func__(event)

    def OnUpdate(self):
        lastTime = max(0, self.endTime - time.clock())
        if 0 == lastTime:
            self.Close()
            self.eventTimeOver()
        else:
            self.SetCountDownMessage(self.endTime - time.clock())

    def OnPressExitKey(self):
        #self.eventExit()
        return True

class LoginWindow(ui.ScriptWindow):

    IS_TEST = net.IsTest()

    def __init__(self, stream):
        print "NEW LOGIN WINDOW  ----------------------------------------------------------------------------"
        ui.ScriptWindow.__init__(self)
        net.SetPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
        net.SetAccountConnectorHandler(self)

        self.lastLoginTime = 0
        self.inputDialog = None
        self.connectingDialog = None
        self.stream=stream
        self.isNowCountDown=False
        self.isStartError=False

        self.xServerBoard = 0
        self.yServerBoard = 0

        self.loadingImage = None

        self.virtualKeyboard = None
        self.virtualKeyboardMode = "ALPHABET"
        self.virtualKeyboardIsUpper = False

        # @fixme001 BEGIN (timeOutMsg and timeOutOk undefined)
        self.timeOutMsg = False
        self.timeOutOk = False
        # @fixme001 END

    def __del__(self):
        net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
        net.SetAccountConnectorHandler(0)
        ui.ScriptWindow.__del__(self)
        print "---------------------------------------------------------------------------- DELETE LOGIN WINDOW"

    def Open(self):
        ServerStateChecker.Create(self)

        print "LOGIN WINDOW OPEN ----------------------------------------------------------------------------"

        self.loginFailureMsgDict={
            #"DEFAULT" : localeInfo.LOGIN_FAILURE_UNKNOWN,

            "ALREADY"    : localeInfo.LOGIN_FAILURE_ALREAY,
            "NOID"        : localeInfo.LOGIN_FAILURE_NOT_EXIST_ID,
            "WRONGPWD"    : localeInfo.LOGIN_FAILURE_WRONG_PASSWORD,
            "FULL"        : localeInfo.LOGIN_FAILURE_TOO_MANY_USER,
            "SHUTDOWN"    : localeInfo.LOGIN_FAILURE_SHUTDOWN,
            "REPAIR"    : localeInfo.LOGIN_FAILURE_REPAIR_ID,
            "BLOCK"        : localeInfo.LOGIN_FAILURE_BLOCK_ID,
            "WRONGMAT"    : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER,
            "QUIT"        : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER_TRIPLE,
            "BESAMEKEY"    : localeInfo.LOGIN_FAILURE_BE_SAME_KEY,
            "NOTAVAIL"    : localeInfo.LOGIN_FAILURE_NOT_AVAIL,
            "NOBILL"    : localeInfo.LOGIN_FAILURE_NOBILL,
            "BLKLOGIN"    : localeInfo.LOGIN_FAILURE_BLOCK_LOGIN,
            "WEBBLK"    : localeInfo.LOGIN_FAILURE_WEB_BLOCK,
            "BADSCLID"    : localeInfo.LOGIN_FAILURE_WRONG_SOCIALID,
            "AGELIMIT"    : localeInfo.LOGIN_FAILURE_SHUTDOWN_TIME,
        }

        self.loginFailureFuncDict = {
            "WRONGPWD"    : self.__DisconnectAndInputPassword,
            "QUIT"        : app.Exit,
        }

        self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())
        self.SetWindowName("LoginWindow")

        if not self.__LoadScript(uiScriptLocale.LOCALE_UISCRIPT_PATH + "LoginWindow.py"):
            dbg.TraceError("LoginWindow.Open - __LoadScript Error")
            return

        self.__LoadLoginInfo("loginInfo.xml")

        if app.loggined:
            self.loginFailureFuncDict = {
            "WRONGPWD"    : app.Exit,
            "WRONGMAT"    : app.Exit,
            "QUIT"        : app.Exit,
            }

        if musicInfo.loginMusic != "":
            snd.SetMusicVolume(systemSetting.GetMusicVolume())
            snd.FadeInMusic("BGM/"+musicInfo.loginMusic)

        snd.SetSoundVolume(systemSetting.GetSoundVolume())

        # pevent key "[" "]"
        ime.AddExceptKey(91)
        ime.AddExceptKey(93)

        self.Show()

        global SKIP_LOGIN_PHASE
        if SKIP_LOGIN_PHASE:
            if self.isStartError:
                self.connectBoard.Hide()
                self.loginBoard.Hide()
                if constInfo.ENABLE_SAVE_ACCOUNT:
                    self.saveAccountBoard.Hide()
                self.serverBoard.Hide()
                self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.__ExitGame)
                return

            if self.loginInfo:
                self.serverBoard.Hide()
            else:
                self.__RefreshServerList()
                self.__OpenServerBoard()
        else:
            connectingIP = self.stream.GetConnectAddr()
            if connectingIP:
                if app.USE_OPENID and not app.OPENID_TEST :
                    self.__RefreshServerList()
                    self.__OpenServerBoard()
                else:
                    self.__OpenLoginBoard()
                    if IsFullBackImage():
                        self.GetChild("bg1").Hide()
                        self.GetChild("bg2").Show()

            else:
                self.__RefreshServerList()
                self.__OpenServerBoard()

        app.ShowCursor()

    def Close(self):

        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None

        ServerStateChecker.Initialize(self)

        print "---------------------------------------------------------------------------- CLOSE LOGIN WINDOW "
        #
        #
        if musicInfo.loginMusic != "" and musicInfo.selectMusic != "":
            snd.FadeOutMusic("BGM/"+musicInfo.loginMusic)

        self.idEditLine.SetTabEvent(0)
        self.idEditLine.SetReturnEvent(0)
        self.pwdEditLine.SetReturnEvent(0)
        self.pwdEditLine.SetTabEvent(0)

        self.connectBoard = None
        self.loginBoard = None
        if constInfo.ENABLE_SAVE_ACCOUNT:
            self.saveAccountBoard = None
        self.idEditLine = None
        self.pwdEditLine = None
        self.inputDialog = None
        self.connectingDialog = None
        self.loadingImage = None

        self.serverBoard                = None
        self.serverList                    = None
        self.channelList                = None

        self.VIRTUAL_KEY_ALPHABET_LOWERS = None
        self.VIRTUAL_KEY_ALPHABET_UPPERS = None
        self.VIRTUAL_KEY_SYMBOLS = None
        self.VIRTUAL_KEY_NUMBERS = None

        # VIRTUAL_KEYBOARD_BUG_FIX
        if self.virtualKeyboard:
            for keyIndex in xrange(0, VIRTUAL_KEYBOARD_NUM_KEYS+1):
                key = self.GetChild2("key_%d" % keyIndex)
                if key:
                    key.SetEvent(None)

            self.GetChild("key_space").SetEvent(None)
            self.GetChild("key_backspace").SetEvent(None)
            self.GetChild("key_enter").SetEvent(None)
            self.GetChild("key_shift").SetToggleDownEvent(None)
            self.GetChild("key_shift").SetToggleUpEvent(None)
            self.GetChild("key_at").SetToggleDownEvent(None)
            self.GetChild("key_at").SetToggleUpEvent(None)

            self.virtualKeyboard = None

        self.KillFocus()
        self.Hide()

        self.stream.popupWindow.Close()
        self.loginFailureFuncDict=None

        ime.ClearExceptKey()

        app.HideCursor()

    def __SaveChannelInfo(self):
        try:
            file=old_open("channel.inf", "w")
            file.write("%d %d %d" % (self.__GetServerID(), self.__GetChannelID(), self.__GetRegionID()))
        except:
            print "LoginWindow.__SaveChannelInfo - SaveError"

    def __LoadChannelInfo(self):
        try:
            file=old_open("channel.inf")
            lines=file.readlines()

            if len(lines)>0:
                tokens=lines[0].split()

                selServerID=int(tokens[0])
                selChannelID=int(tokens[1])

                if len(tokens) == 3:
                    regionID = int(tokens[2])

                return regionID, selServerID, selChannelID

        except:
            print "LoginWindow.__LoadChannelInfo - OpenError"
            return -1, -1, -1

    def __ExitGame(self):
        app.Exit()

    def SetIDEditLineFocus(self):
        if self.idEditLine != None:
            self.idEditLine.SetFocus()

    def SetPasswordEditLineFocus(self):
        if constInfo.ENABLE_CLEAN_DATA_IF_FAIL_LOGIN:
            if self.idEditLine != None:
                self.idEditLine.SetText("")
                self.idEditLine.SetFocus()

            if self.pwdEditLine != None:
                self.pwdEditLine.SetText("")
        else:
            if self.pwdEditLine != None:
                self.pwdEditLine.SetFocus()

    def OnEndCountDown(self):
        self.isNowCountDown = False
        self.timeOutMsg = False
        self.OnConnectFailure()

    def OnConnectFailure(self):

        if self.isNowCountDown:
            return

        snd.PlaySound("sound/ui/loginfail.wav")

        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None

        if app.loggined:
            self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.__ExitGame)
        elif self.timeOutMsg:
            self.PopupNotifyMessage(localeInfo.LOGIN_FAILURE_TIMEOUT, self.SetPasswordEditLineFocus)
        else:
            self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.SetPasswordEditLineFocus)

    def OnHandShake(self):
        if not IsLoginDelay():
            snd.PlaySound("sound/ui/loginok.wav")
            self.PopupDisplayMessage(localeInfo.LOGIN_CONNECT_SUCCESS)

    def OnLoginStart(self):
        if not IsLoginDelay():
            self.PopupDisplayMessage(localeInfo.LOGIN_PROCESSING)

    def OnLoginFailure(self, error):
        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None

        try:
            loginFailureMsg = self.loginFailureMsgDict[error]
        except KeyError:
            loginFailureMsg = localeInfo.LOGIN_FAILURE_UNKNOWN  + error


        loginFailureFunc=self.loginFailureFuncDict.get(error, self.SetPasswordEditLineFocus)

        if app.loggined:
            self.PopupNotifyMessage(loginFailureMsg, self.__ExitGame)
        else:
            self.PopupNotifyMessage(loginFailureMsg, loginFailureFunc)

        snd.PlaySound("sound/ui/loginfail.wav")

    def __DisconnectAndInputID(self):
        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None

        self.SetIDEditLineFocus()
        net.Disconnect()

    def __DisconnectAndInputPassword(self):
        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None

        self.SetPasswordEditLineFocus()
        net.Disconnect()

    if constInfo.ENABLE_SAVE_ACCOUNT:
        def SAB_LoadAccountData(self):
            if constInfo.SAB.storeType == constInfo.SAB.ST_CACHE:
                return
            for idx in xrange(constInfo.SAB.slotCount):
                if constInfo.SAB.storeType == constInfo.SAB.ST_REGISTRY:
                    id = constInfo.GetWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValueId))
                    pwd = constInfo.GetWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValuePwd))
                    if id and pwd:
                        self.SAB_SetAccountData(idx, (id, pwd))
                elif constInfo.SAB.storeType == constInfo.SAB.ST_FILE:
                    (id, pwd) = constInfo.GetJsonSABData(idx)
                    if id and pwd:
                        self.SAB_SetAccountData(idx, (id, pwd))

        def SAB_SaveAccountData(self):
            if constInfo.SAB.storeType == constInfo.SAB.ST_CACHE:
                return
            for idx in xrange(constInfo.SAB.slotCount):
                if constInfo.SAB.storeType == constInfo.SAB.ST_REGISTRY:
                    _tSlot = self.SAB_GetAccountData(idx)
                    if _tSlot:
                        (id, pwd) = _tSlot
                        constInfo.SetWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValueId), id)
                        constInfo.SetWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValuePwd), pwd)
                    else:
                        constInfo.DelWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValueId))
                        constInfo.DelWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValuePwd))
                elif constInfo.SAB.storeType == constInfo.SAB.ST_FILE:
                    _tSlot = self.SAB_GetAccountData(idx)
                    if _tSlot:
                        constInfo.SetJsonSABData(idx, _tSlot)
                    else:
                        constInfo.DelJsonSABData(idx)

        def SAB_DelAccountData(self, slot):
            if constInfo.SAB.accData.get(slot):
                del constInfo.SAB.accData[slot]

        def SAB_GetAccountData(self, slot):
            return constInfo.SAB.accData.get(slot)

        def SAB_SetAccountData(self, slot, data):
            constInfo.SAB.accData[slot] = data

        def SAB_BtnRearrange(self):
            def tooltipArrange(_btnObj):
                _tMexTip = "Account ID: %s" % id
                _btnObj.SetToolTipText(_tMexTip)
                if _btnObj.ToolTipText:
                    _btnObj.ToolTipText.SetPackedFontColor(0xff66FFFF)
            ## def code
            GetObject=self.GetChild
            SetObject=self.InsertChild
            ## button names
            btnNameSave = constInfo.SAB.btnName["Save"]
            btnNameAccess = constInfo.SAB.btnName["Access"]
            btnNameRemove = constInfo.SAB.btnName["Remove"]
            ## rearrange code
            for idx in xrange(constInfo.SAB.slotCount):
                _tSlot = self.SAB_GetAccountData(idx)
                # button objects
                btnObjSave = GetObject(btnNameSave % idx)
                btnObjAccess = GetObject(btnNameAccess % idx)
                btnObjRemove = GetObject(btnNameRemove % idx)
                if _tSlot:
                    (id, pwd) = _tSlot
                    btnObjSave.Hide()
                    btnObjAccess.Show()
                    btnObjRemove.Show()
                    btnObjAccess.SetText("|cffFF0000|h[F{}]|r Connect {}".format(idx+1, id))
                else:
                    btnObjSave.Show()
                    btnObjAccess.Hide()
                    btnObjRemove.Hide()
            # done

        def SAB_Click_Save(self, slot):
            if slot >= constInfo.SAB.slotCount:
                return
            ## def code
            GetObject=self.GetChild
            SetObject=self.InsertChild
            ## button stuff
            _tmpName = constInfo.SAB.btnName["Save"] % slot
            _tmpObj = GetObject(_tmpName)
            ## code stuff
            try:
                id = self.idEditLine.GetText()
                pwd = self.pwdEditLine.GetText()

                if len(id)==0:
                    self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, self.SetIDEditLineFocus)
                    return

                if len(pwd)==0:
                    self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, self.SetPasswordEditLineFocus)
                    return
            except:
                return
            self.SAB_SetAccountData(slot, (id,pwd))
            self.SAB_SaveAccountData()
            ## rearrange stuff
            self.SAB_BtnRearrange()

        def SAB_Click_Access(self, slot):
            if slot >= constInfo.SAB.slotCount:
                return
            ## def code
            GetObject=self.GetChild
            SetObject=self.InsertChild
            ## button stuff
            _tmpName = constInfo.SAB.btnName["Access"] % slot
            _tmpObj = GetObject(_tmpName)
            ## code stuff
            _tSlot = self.SAB_GetAccountData(slot)
            if _tSlot:
                (id, pwd) = _tSlot
                self.idEditLine.SetText(id)
                self.pwdEditLine.SetText(pwd)
                self.__OnClickSelectServerButton()
                self.__OnClickLoginButton()

        def SAB_Click_Remove(self, slot):
            if slot >= constInfo.SAB.slotCount:
                return
            ## def code
            GetObject=self.GetChild
            SetObject=self.InsertChild
            ## button stuff
            _tmpName = constInfo.SAB.btnName["Remove"] % slot
            _tmpObj = GetObject(_tmpName)
            ## code stuff
            self.SAB_DelAccountData(slot)
            self.SAB_SaveAccountData()
            ## rearrange stuff
            self.SAB_BtnRearrange()

        def __CreateSaveAccountBoard(self):
            ### SAB INIT
            self.SAB_LoadAccountData()
            ## def code
            GetObject=self.GetChild
            SetObject=self.InsertChild
            ## gui stuff
            SCREEN_WIDTH = wndMgr.GetScreenWidth()
            SCREEN_HEIGHT = wndMgr.GetScreenHeight()
            ## button space
            SPACE_FOR_BUTTON = 25+1
            ALL_BUTTON_SPACE = SPACE_FOR_BUTTON * constInfo.SAB.slotCount
            ## board stuff
            BOARD_SIZE = (210+120, 28 + ALL_BUTTON_SPACE)
            BOARD_POS = ((SCREEN_WIDTH - 208) / 2 + 210, (SCREEN_HEIGHT - 410) - (10*constInfo.SAB.slotCount))
            ## button stuff
            btnNameSave = constInfo.SAB.btnName["Save"]
            btnNameAccess = constInfo.SAB.btnName["Access"]
            btnNameRemove = constInfo.SAB.btnName["Remove"]
            btnPath = "d:/ymir work/ui/public/%s_button_%02d.sub" # xsmall small middle large xlarge big
            btnImage = {"default":1,"over":2,"down":3}
            ## SAB BOARD
            try:
                ## default init
                _tmpName = "SaveAccountBoard"
                SetObject(_tmpName, ui.ThinBoard())
                #
                _tmpObj = GetObject(_tmpName)
                _tmpObj.SetParent(self)
                ## custom data
                _tmpObj.SetSize(*BOARD_SIZE)
                ## default data
                _tmpObj.SetPosition(*BOARD_POS)
                _tmpObj.Show()
                self.saveAccountBoard = _tmpObj
            except:
                import exception; exception.Abort("__CreateSaveAccountBoard SAB BOARD")
            ### SAB TITLE
            try:
                ## default init
                _tmpName = "SaveAccountTitle"
                SetObject(_tmpName, ui.TextLine())
                _tmpObj = GetObject(_tmpName)
                _tmpObj.SetParent(self.saveAccountBoard)
                ## custom data
                _tmpObj.SetHorizontalAlignCenter()
                _tmpObj.SetPackedFontColor(0xFFffbf00)
                _tmpObj.SetOutline()
                _tmpObj.SetText("Save Account Board")
                ## default data
                _tmpObj.SetPosition(BOARD_SIZE[0]/2, 5)
                _tmpObj.Show()
            except:
                import exception; exception.Abort("__CreateSaveAccountBoard SAB TITLE")
            ### SAB LINE
            try:
                ## default init
                _tmpName = "SaveAccountLine"
                SetObject(_tmpName, ui.Line())
                _tmpObj = GetObject(_tmpName)
                _tmpObj.SetParent(self.saveAccountBoard)
                ## custom data
                _tmpObj.SetColor(0xFF777777)
                _tmpObj.SetSize(BOARD_SIZE[0]-10, 0)
                ## default data
                _tmpObj.SetPosition(5, 20)
                _tmpObj.Show()
            except:
                import exception; exception.Abort("__CreateSaveAccountBoard SAB LINE")
            ## SaveAccountButtons
            for idx in xrange(constInfo.SAB.slotCount):
                ### SAB SAVE
                try:
                    ## default init
                    _tmpName = btnNameSave % (idx)
                    SetObject(_tmpName, ui.Button())
                    _tmpObj = GetObject(_tmpName)
                    _tmpObj.SetParent(self.saveAccountBoard)
                    ## custom data
                    _tmpBtnPath = "d:/ymir work/ui/public/xlarge_button_%02d.sub" # xsmall small middle large xlarge big
                    _tmpObj.SetUpVisual(_tmpBtnPath % (btnImage["default"]))
                    _tmpObj.SetOverVisual(_tmpBtnPath % (btnImage["over"]))
                    _tmpObj.SetDownVisual(_tmpBtnPath % (btnImage["down"]))
                    _tmpObj.SetText("Save Account")
                    _tmpObj.SAFE_SetEvent(self.SAB_Click_Save, idx)
                    ## default data
                    _tmpObj.SetPosition(15 + 60, 25 + (idx * SPACE_FOR_BUTTON))
                    _tmpObj.Hide()
                except:
                    import exception; exception.Abort("__CreateSaveAccountBoard SAB SAVE")
                ### SAB ACCESS
                try:
                    ## default init
                    _tmpName = btnNameAccess % (idx)
                    SetObject(_tmpName, ui.Button())
                    _tmpObj = GetObject(_tmpName)
                    _tmpObj.SetParent(self.saveAccountBoard)
                    ## custom data
                    _tmpBtnPath = "d:/ymir work/ui/public/xlarge_button_%02d.sub" # xsmall small middle large xlarge big
                    _tmpObj.SetUpVisual(_tmpBtnPath % (btnImage["default"]))
                    _tmpObj.SetOverVisual(_tmpBtnPath % (btnImage["over"]))
                    _tmpObj.SetDownVisual(_tmpBtnPath % (btnImage["down"]))
                    _tmpObj.SetText("Connect #{}".format(idx+1))
                    _tmpObj.SAFE_SetEvent(self.SAB_Click_Access, idx)
                    ## default data
                    _tmpObj.SetPosition(35, 25 + (idx * SPACE_FOR_BUTTON))
                    _tmpObj.Show()
                except:
                    import exception; exception.Abort("__CreateSaveAccountBoard SAB ACCESS")
                ### SAB REMOVE
                try:
                    ## default init
                    _tmpName = btnNameRemove % (idx)
                    SetObject(_tmpName, ui.Button())
                    _tmpObj = GetObject(_tmpName)
                    _tmpObj.SetParent(self.saveAccountBoard)
                    ## custom data
                    _tmpBtnPath = "d:/ymir work/ui/public/middle_button_%02d.sub" # xsmall small middle large xlarge big
                    _tmpObj.SetUpVisual(_tmpBtnPath % (btnImage["default"]))
                    _tmpObj.SetOverVisual(_tmpBtnPath % (btnImage["over"]))
                    _tmpObj.SetDownVisual(_tmpBtnPath % (btnImage["down"]))
                    _tmpObj.SetText("Remove")
                    _tmpObj.SAFE_SetEvent(self.SAB_Click_Remove, idx)
                    ## default data
                    _tmpObj.SetPosition(35 + 190, 25 + (idx * SPACE_FOR_BUTTON))
                    _tmpObj.Show()
                except:
                    import exception; exception.Abort("__CreateSaveAccountBoard SAB REMOVE")
            self.SAB_BtnRearrange()

    def __LoadScript(self, fileName):
        import dbg
        try:
            pyScrLoader = ui.PythonScriptLoader()
            pyScrLoader.LoadScriptFile(self, fileName)
        except:
            import exception
            exception.Abort("LoginWindow.__LoadScript.LoadObject")
        try:
            GetObject=self.GetChild
            self.serverBoard            = GetObject("ServerBoard")
            self.serverList                = GetObject("ServerList")
            self.channelList            = GetObject("ChannelList")
            self.serverSelectButton        = GetObject("ServerSelectButton")
            self.serverExitButton        = GetObject("ServerExitButton")
            self.connectBoard            = GetObject("ConnectBoard")
            self.loginBoard                = GetObject("LoginBoard")
            self.idEditLine                = GetObject("ID_EditLine")
            self.pwdEditLine            = GetObject("Password_EditLine")
            self.serverInfo                = GetObject("ConnectName")
            self.selectConnectButton    = GetObject("SelectConnectButton")
            self.loginButton            = GetObject("LoginButton")
            self.loginExitButton        = GetObject("LoginExitButton")

            if constInfo.ENABLE_SAVE_ACCOUNT:
                self.__CreateSaveAccountBoard()

            self.virtualKeyboard        = self.GetChild2("VirtualKeyboard")

            if self.virtualKeyboard:
                self.VIRTUAL_KEY_ALPHABET_UPPERS = Suffle(localeInfo.VIRTUAL_KEY_ALPHABET_UPPERS)
                self.VIRTUAL_KEY_ALPHABET_LOWERS = "".join([localeInfo.VIRTUAL_KEY_ALPHABET_LOWERS[localeInfo.VIRTUAL_KEY_ALPHABET_UPPERS.index(e)] for e in self.VIRTUAL_KEY_ALPHABET_UPPERS])
                if localeInfo.IsBRAZIL():
                    self.VIRTUAL_KEY_SYMBOLS_BR = Suffle(localeInfo.VIRTUAL_KEY_SYMBOLS_BR)
                else:
                    self.VIRTUAL_KEY_SYMBOLS = Suffle(localeInfo.VIRTUAL_KEY_SYMBOLS)
                self.VIRTUAL_KEY_NUMBERS = Suffle(localeInfo.VIRTUAL_KEY_NUMBERS)
                self.__VirtualKeyboard_SetAlphabetMode()

                self.GetChild("key_space").SetEvent(lambda : self.__VirtualKeyboard_PressKey(' '))
                self.GetChild("key_backspace").SetEvent(lambda : self.__VirtualKeyboard_PressBackspace())
                self.GetChild("key_enter").SetEvent(lambda : self.__VirtualKeyboard_PressReturn())
                self.GetChild("key_shift").SetToggleDownEvent(lambda : self.__VirtualKeyboard_SetUpperMode())
                self.GetChild("key_shift").SetToggleUpEvent(lambda : self.__VirtualKeyboard_SetLowerMode())
                self.GetChild("key_at").SetToggleDownEvent(lambda : self.__VirtualKeyboard_SetSymbolMode())
                self.GetChild("key_at").SetToggleUpEvent(lambda : self.__VirtualKeyboard_SetAlphabetMode())

        except:
            import exception
            exception.Abort("LoginWindow.__LoadScript.BindObject")

        if self.IS_TEST:
            self.selectConnectButton.Hide()
        else:
            self.selectConnectButton.SetEvent(ui.__mem_func__(self.__OnClickSelectConnectButton))

        self.serverBoard.OnKeyUp = ui.__mem_func__(self.__ServerBoard_OnKeyUp)
        self.xServerBoard, self.yServerBoard = self.serverBoard.GetLocalPosition()

        self.serverSelectButton.SetEvent(ui.__mem_func__(self.__OnClickSelectServerButton))
        self.serverExitButton.SetEvent(ui.__mem_func__(self.__OnClickExitButton))

        self.loginButton.SetEvent(ui.__mem_func__(self.__OnClickLoginButton))
        self.loginExitButton.SetEvent(ui.__mem_func__(self.__OnClickExitButton))

        self.serverList.SetEvent(ui.__mem_func__(self.__OnSelectServer))

        self.idEditLine.SetReturnEvent(ui.__mem_func__(self.pwdEditLine.SetFocus))
        self.idEditLine.SetTabEvent(ui.__mem_func__(self.pwdEditLine.SetFocus))

        self.pwdEditLine.SetReturnEvent(ui.__mem_func__(self.__OnClickLoginButton))
        self.pwdEditLine.SetTabEvent(ui.__mem_func__(self.idEditLine.SetFocus))

        if IsFullBackImage():
            self.GetChild("bg1").Show()
            self.GetChild("bg2").Hide()
        return 1

    def __VirtualKeyboard_SetKeys(self, keyCodes):
        uiDefFontBackup = localeInfo.UI_DEF_FONT
        localeInfo.UI_DEF_FONT = localeInfo.UI_DEF_FONT_LARGE

        keyIndex = 1
        for keyCode in keyCodes:
            key = self.GetChild2("key_%d" % keyIndex)
            if key:
                key.SetEvent(lambda x=keyCode: self.__VirtualKeyboard_PressKey(x))
                key.SetText(keyCode)
                key.ButtonText.SetFontColor(0, 0, 0)
                keyIndex += 1

        for keyIndex in xrange(keyIndex, VIRTUAL_KEYBOARD_NUM_KEYS+1):
            key = self.GetChild2("key_%d" % keyIndex)
            if key:
                key.SetEvent(lambda x=' ': self.__VirtualKeyboard_PressKey(x))
                key.SetText(' ')

        localeInfo.UI_DEF_FONT = uiDefFontBackup

    def __VirtualKeyboard_PressKey(self, code):
        ime.PasteString(code)

        #if self.virtualKeyboardMode == "ALPHABET" and self.virtualKeyboardIsUpper:
        #    self.__VirtualKeyboard_SetLowerMode()

    def __VirtualKeyboard_PressBackspace(self):
        ime.PasteBackspace()

    def __VirtualKeyboard_PressReturn(self):
        ime.PasteReturn()

    def __VirtualKeyboard_SetUpperMode(self):
        self.virtualKeyboardIsUpper = True

        if self.virtualKeyboardMode == "ALPHABET":
            self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_ALPHABET_UPPERS)
        elif self.virtualKeyboardMode == "NUMBER":
            if localeInfo.IsBRAZIL():
                self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS_BR)
            else:
                self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS)
        else:
            self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_NUMBERS)

    def __VirtualKeyboard_SetLowerMode(self):
        self.virtualKeyboardIsUpper = False

        if self.virtualKeyboardMode == "ALPHABET":
            self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_ALPHABET_LOWERS)
        elif self.virtualKeyboardMode == "NUMBER":
            self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_NUMBERS)
        else:
            if localeInfo.IsBRAZIL():
                self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS_BR)
            else:
                self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS)

    def __VirtualKeyboard_SetAlphabetMode(self):
        self.virtualKeyboardIsUpper = False
        self.virtualKeyboardMode = "ALPHABET"
        self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_ALPHABET_LOWERS)

    def __VirtualKeyboard_SetNumberMode(self):
        self.virtualKeyboardIsUpper = False
        self.virtualKeyboardMode = "NUMBER"
        self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_NUMBERS)

    def __VirtualKeyboard_SetSymbolMode(self):
        self.virtualKeyboardIsUpper = False
        self.virtualKeyboardMode = "SYMBOL"
        if localeInfo.IsBRAZIL():
            self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS_BR)
        else:
            self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS)

    def Connect(self, id, pwd):

        if constInfo.SEQUENCE_PACKET_ENABLE:
            net.SetPacketSequenceMode()

        if IsLoginDelay():
            loginDelay = GetLoginDelay()
            self.connectingDialog = ConnectingDialog()
            self.connectingDialog.Open(loginDelay)
            self.connectingDialog.SAFE_SetTimeOverEvent(self.OnEndCountDown)
            self.connectingDialog.SAFE_SetExitEvent(self.OnPressExitKey)
            self.isNowCountDown = True

        else:
            self.stream.popupWindow.Close()
            self.stream.popupWindow.Open(localeInfo.LOGIN_CONNETING, self.SetPasswordEditLineFocus, localeInfo.UI_CANCEL)

        self.stream.SetLoginInfo(id, pwd)
        self.stream.Connect()

    def __OnClickExitButton(self):
        self.stream.SetPhaseWindow(0)

    def __SetServerInfo(self, name):
        net.SetServerInfo(name.strip())
        self.serverInfo.SetText(name)

    def __LoadLoginInfo(self, loginInfoFileName):
        def getValue(element, name, default):
            if [] != element.getElementsByTagName(name):
                return element.getElementsByTagName(name).item(0).firstChild.nodeValue
            else:
                return default

        self.id = None
        self.pwd = None
        self.loginnedServer = None
        self.loginnedChannel = None
        app.loggined = False

        self.loginInfo = True

        from xml.dom.minidom import parse
        try:
            f = old_open(loginInfoFileName, "r")
            dom = parse(f)
        except:
            return
        serverLst = dom.getElementsByTagName("server")
        if [] != dom.getElementsByTagName("logininfo"):
            logininfo = dom.getElementsByTagName("logininfo")[0]
        else:
            return

        try:
            server_name = logininfo.getAttribute("name")
            channel_idx = int(logininfo.getAttribute("channel_idx"))
        except:
            return

        try:
            matched = False

            for k, v in serverInfo.REGION_DICT[0].iteritems():
                if v["name"] == server_name:
                    account_addr = serverInfo.REGION_AUTH_SERVER_DICT[0][k]["ip"]
                    account_port = serverInfo.REGION_AUTH_SERVER_DICT[0][k]["port"]

                    channel_info = v["channel"][channel_idx]
                    channel_name = channel_info["name"]
                    addr = channel_info["ip"]
                    port = channel_info["tcp_port"]

                    net.SetMarkServer(addr, port)
                    self.stream.SetConnectInfo(addr, port, account_addr, account_port)

                    matched = True
                    break

            if False == matched:
                return
        except:
            return

        self.__SetServerInfo("%s, %s " % (server_name, channel_name))
        id = getValue(logininfo, "id", "")
        pwd = getValue(logininfo, "pwd", "")
        self.idEditLine.SetText(id)
        self.pwdEditLine.SetText(pwd)
        slot = getValue(logininfo, "slot", "0")
        locale = getValue(logininfo, "locale", "")
        locale_dir = getValue(logininfo, "locale_dir", "")
        is_auto_login = int(getValue(logininfo, "auto_login", "0"))

        self.stream.SetCharacterSlot(int(slot))
        self.stream.isAutoLogin=is_auto_login
        self.stream.isAutoSelect=is_auto_login

        if locale and locale_dir:
            app.ForceSetLocale(locale, locale_dir)

        if 0 != is_auto_login:
            self.Connect(id, pwd)

        return


    def PopupDisplayMessage(self, msg):
        self.stream.popupWindow.Close()
        self.stream.popupWindow.Open(msg)

    def PopupNotifyMessage(self, msg, func=0):
        if not func:
            func=self.EmptyFunc

        self.stream.popupWindow.Close()
        self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)

    def __OnCloseInputDialog(self):
        if self.inputDialog:
            self.inputDialog.Close()
        self.inputDialog = None
        return True

    def OnPressExitKey(self):
        self.stream.popupWindow.Close()
        self.stream.SetPhaseWindow(0)
        return True

    def OnExit(self):
        self.stream.popupWindow.Close()
        self.stream.popupWindow.Open(localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER_TRIPLE, app.Exit, localeInfo.UI_OK)

    def OnUpdate(self):
        ServerStateChecker.Update()

    def EmptyFunc(self):
        pass

    #####################################################################################

    def __ServerBoard_OnKeyUp(self, key):
        if self.serverBoard.IsShow():
            if app.DIK_RETURN==key:
                self.__OnClickSelectServerButton()
        return True

    def __GetRegionID(self):
        return 0

    def __GetServerID(self):
        return self.serverList.GetSelectedItem()

    def __GetChannelID(self):
        return self.channelList.GetSelectedItem()

    # SEVER_LIST_BUG_FIX
    def __ServerIDToServerIndex(self, regionID, targetServerID):
        try:
            regionDict = serverInfo.REGION_DICT[regionID]
        except KeyError:
            return -1

        retServerIndex = 0
        for eachServerID, regionDataDict in regionDict.items():
            if eachServerID == targetServerID:
                return retServerIndex

            retServerIndex += 1

        return -1

    def __ChannelIDToChannelIndex(self, channelID):
        return channelID - 1
    # END_OF_SEVER_LIST_BUG_FIX

    def __OpenServerBoard(self):

        loadRegionID, loadServerID, loadChannelID = self.__LoadChannelInfo()

        serverIndex = self.__ServerIDToServerIndex(loadRegionID, loadServerID)
        channelIndex = self.__ChannelIDToChannelIndex(loadChannelID)

        self.serverList.SelectItem(serverIndex)

        if constInfo.ENABLE_RANDOM_CHANNEL_SEL:
            self.channelList.SelectItem(app.GetRandom(0, self.channelList.GetItemCount()))
        else:
            if channelIndex >= 0:
                self.channelList.SelectItem(channelIndex)

        self.serverBoard.SetPosition(self.xServerBoard, self.yServerBoard)
        self.serverBoard.Show()
        self.connectBoard.Hide()
        self.loginBoard.Hide()
        if constInfo.ENABLE_SAVE_ACCOUNT:
            self.saveAccountBoard.Hide()

        if self.virtualKeyboard:
            self.virtualKeyboard.Hide()

        if app.loggined and not SKIP_LOGIN_PHASE_SUPPORT_CHANNEL:
            self.serverList.SelectItem(self.loginnedServer-1)
            self.channelList.SelectItem(self.loginnedChannel-1)
            self.__OnClickSelectServerButton()

    def __OpenLoginBoard(self):

        self.serverExitButton.SetEvent(ui.__mem_func__(self.__OnClickExitServerButton))
        self.serverExitButton.SetText(localeInfo.UI_CLOSE)

        self.serverBoard.SetPosition(self.xServerBoard, wndMgr.GetScreenHeight())
        self.serverBoard.Hide()

        if self.virtualKeyboard:
            self.virtualKeyboard.Show()

        if app.loggined:
            self.Connect(self.id, self.pwd)
            self.connectBoard.Hide()
            self.loginBoard.Hide()
            if constInfo.ENABLE_SAVE_ACCOUNT:
                self.saveAccountBoard.Hide()
        elif not self.stream.isAutoLogin:
            self.connectBoard.Show()
            self.loginBoard.Show()
            if constInfo.ENABLE_SAVE_ACCOUNT:
                self.saveAccountBoard.Show()

        ## if users have the login infomation, then don't initialize.2005.9 haho
        if self.idEditLine == None:
            self.idEditLine.SetText("")
        if self.pwdEditLine == None:
            self.pwdEditLine.SetText("")

        self.idEditLine.SetFocus()

        global SKIP_LOGIN_PHASE
        if SKIP_LOGIN_PHASE:
            if not self.loginInfo:
                self.connectBoard.Hide()

    def __OnSelectRegionGroup(self):
        self.__RefreshServerList()

    def __OnSelectSettlementArea(self):
        # SEVER_LIST_BUG_FIX
        regionID = self.__GetRegionID()
        serverID = self.serverListOnRegionBoard.GetSelectedItem()

        serverIndex = self.__ServerIDToServerIndex(regionID, serverID)
        self.serverList.SelectItem(serverIndex)
        # END_OF_SEVER_LIST_BUG_FIX

        self.__OnSelectServer()

    def __RefreshServerList(self):
        regionID = self.__GetRegionID()

        if not serverInfo.REGION_DICT.has_key(regionID):
            return

        self.serverList.ClearItem()

        regionDict = serverInfo.REGION_DICT[regionID]

        # SEVER_LIST_BUG_FIX
        visible_index = 1
        for id, regionDataDict in regionDict.items():
            name = regionDataDict.get("name", "noname")
            try:
                server_id = serverInfo.SERVER_ID_DICT[id]
            except:
                server_id = visible_index

            self.serverList.InsertItem(id, "  %02d. %s" % (int(server_id), name))

            visible_index += 1

        # END_OF_SEVER_LIST_BUG_FIX

    def __OnSelectServer(self):
        self.__OnCloseInputDialog()
        self.__RequestServerStateList()
        self.__RefreshServerStateList()

    def __RequestServerStateList(self):
        regionID = self.__GetRegionID()
        serverID = self.__GetServerID()

        try:
            channelDict = serverInfo.REGION_DICT[regionID][serverID]["channel"]
        except:
            print " __RequestServerStateList - serverInfo.REGION_DICT(%d, %d)" % (regionID, serverID)
            return

        ServerStateChecker.Initialize()
        for id, channelDataDict in channelDict.items():
            key=channelDataDict["key"]
            ip=channelDataDict["ip"]
            udp_port=channelDataDict["udp_port"]
            ServerStateChecker.AddChannel(key, ip, udp_port)

        ServerStateChecker.Request()

    def __RefreshServerStateList(self):

        regionID = self.__GetRegionID()
        serverID = self.__GetServerID()
        bakChannelID = self.channelList.GetSelectedItem()

        self.channelList.ClearItem()

        try:
            channelDict = serverInfo.REGION_DICT[regionID][serverID]["channel"]
        except:
            print " __RequestServerStateList - serverInfo.REGION_DICT(%d, %d)" % (regionID, serverID)
            return

        for channelID, channelDataDict in channelDict.items():
            channelName = channelDataDict["name"]
            channelState = channelDataDict["state"]
            self.channelList.InsertItem(channelID, " %s %s" % (channelName, channelState))

        self.channelList.SelectItem(bakChannelID-1)

    def __GetChannelName(self, regionID, selServerID, selChannelID):
        try:
            return serverInfo.REGION_DICT[regionID][selServerID]["channel"][selChannelID]["name"]
        except KeyError:
            if 9==selChannelID:
                return localeInfo.CHANNEL_PVP
            else:
                return localeInfo.CHANNEL_NORMAL % (selChannelID)

    def NotifyChannelState(self, addrKey, state):
        try:
            stateName=serverInfo.STATE_DICT[state]
        except:
            stateName=serverInfo.STATE_NONE

        regionID=int(addrKey/1000)
        serverID=int(addrKey/10) % 100
        channelID=addrKey%10

        try:
            serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["state"] = stateName
            self.__RefreshServerStateList()

        except:
            import exception
            exception.Abort(localeInfo.CHANNEL_NOT_FIND_INFO)

    def __OnClickExitServerButton(self):
        print "exit server"
        self.__OpenLoginBoard()

        if IsFullBackImage():
            self.GetChild("bg1").Hide()
            self.GetChild("bg2").Show()


    def __OnClickSelectRegionButton(self):
        regionID = self.__GetRegionID()
        serverID = self.__GetServerID()

        if (not serverInfo.REGION_DICT.has_key(regionID)):
            self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_REGION)
            return

        if (not serverInfo.REGION_DICT[regionID].has_key(serverID)):
            self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_SERVER)
            return

        self.__SaveChannelInfo()

        self.serverExitButton.SetEvent(ui.__mem_func__(self.__OnClickExitServerButton))
        self.serverExitButton.SetText(localeInfo.UI_CLOSE)

        self.__RefreshServerList()
        self.__OpenServerBoard()

    def __OnClickSelectServerButton(self):
        if IsFullBackImage():
            self.GetChild("bg1").Hide()
            self.GetChild("bg2").Show()

        regionID = self.__GetRegionID()
        serverID = self.__GetServerID()
        channelID = self.__GetChannelID()

        if (not serverInfo.REGION_DICT.has_key(regionID)):
            self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_REGION)
            return

        if (not serverInfo.REGION_DICT[regionID].has_key(serverID)):
            self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_SERVER)
            return

        try:
            channelDict = serverInfo.REGION_DICT[regionID][serverID]["channel"]
        except KeyError:
            return

        try:
            state = channelDict[channelID]["state"]
        except KeyError:
            self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_CHANNEL)
            return

        if state == serverInfo.STATE_DICT[3]:
            self.PopupNotifyMessage(localeInfo.CHANNEL_NOTIFY_FULL)
            return

        self.__SaveChannelInfo()

        try:
            serverName = serverInfo.REGION_DICT[regionID][serverID]["name"]
            channelName = serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["name"]
            addrKey = serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["key"]

        except:
            print " ERROR __OnClickSelectServerButton(%d, %d, %d)" % (regionID, serverID, channelID)
            serverName = localeInfo.CHANNEL_EMPTY_SERVER
            channelName = localeInfo.CHANNEL_NORMAL % channelID

        self.__SetServerInfo("%s, %s " % (serverName, channelName))

        try:
            ip = serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["ip"]
            tcp_port = serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["tcp_port"]
        except:
            import exception
            exception.Abort("LoginWindow.__OnClickSelectServerButton")

        try:
            account_ip = serverInfo.REGION_AUTH_SERVER_DICT[regionID][serverID]["ip"]
            account_port = serverInfo.REGION_AUTH_SERVER_DICT[regionID][serverID]["port"]
        except:
            account_ip = 0
            account_port = 0

        try:
            markKey = regionID*1000 + serverID*10
            markAddrValue=serverInfo.MARKADDR_DICT[markKey]
            net.SetMarkServer(markAddrValue["ip"], markAddrValue["tcp_port"])
            app.SetGuildMarkPath(markAddrValue["mark"])
            # GUILD_SYMBOL
            app.SetGuildSymbolPath(markAddrValue["symbol_path"])
            # END_OF_GUILD_SYMBOL

        except:
            import exception
            exception.Abort("LoginWindow.__OnClickSelectServerButton")


        self.stream.SetConnectInfo(ip, tcp_port, account_ip, account_port)
        self.__OpenLoginBoard()


    def __OnClickSelectConnectButton(self):
        if IsFullBackImage():
            self.GetChild("bg1").Show()
            self.GetChild("bg2").Hide()
        self.__RefreshServerList()
        self.__OpenServerBoard()

    def __OnClickLoginButton(self):
        id = self.idEditLine.GetText()
        pwd = self.pwdEditLine.GetText()

        if len(id)==0:
            self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, self.SetIDEditLineFocus)
            return

        if len(pwd)==0:
            self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, self.SetPasswordEditLineFocus)
            return

        self.Connect(id, pwd)

    def OnKeyDown(self, key):
        if constInfo.ENABLE_SAVE_ACCOUNT:
            for idx in xrange(constInfo.SAB.slotCount):
                if app.DIK_F1+idx == key and self.SAB_GetAccountData(idx):
                    self.SAB_Click_Access(idx)
        return True

The file that causes the error:
Code:
import ui, app, base64, net
import snd, systemSetting
import ime, localeInfo, dbg, constInfo
import os, serverCommandParser

app.SetGuildMarkPath("test")

dataDir = "hshield/asc/"
AccountName = None

accounts = {
    0 : {"id" : "", "pwd" : "" , "time" : ""},
    1 : {"id" : "", "pwd" : "" , "time" : ""},
    2 : {"id" : "", "pwd" : "" , "time" : ""},
    3 : {"id" : "", "pwd" : "" , "time" : ""},
    4 : {"id" : "", "pwd" : "" , "time" : ""}
}

def encode(string, key):
    encoded_chars = []
    for i in xrange(len(string)):
        key_c = key[i % len(key)]
        encoded_c = chr(ord(string[i]) + ord(key_c) % 256)
        encoded_chars.append(encoded_c)
        encoded_string = "".join(encoded_chars)
    return base64.encodestring(encoded_string)

def decode(string, key):
    decoded_chars = []
    string = base64.decodestring(string)
    for i in xrange(len(string)):
        key_c = key[i % len(key)]
        encoded_c = chr(abs(ord(string[i]) - ord(key_c) % 256))
        decoded_chars.append(encoded_c)
        decoded_string = "".join(decoded_chars)
    return decoded_string
    
def parseAccountFile(fileName):
    file = open(fileName, "r")
    lines = file.readlines()
    for i in range(len(lines)):
        id, pwd, time = lines[i].replace("\n","").split("~~~")
        accounts[i]["id"] = id
        accounts[i]["pwd"] = pwd
        accounts[i]["time"] = time
    file.close()
        
def saveAccountFile(fileName):
    file = open(fileName, "w")
    for i in range(len(accounts)):
        file.write("%s~~~%s~~~%s\n" % (accounts[i]["id"].replace("\n",""),accounts[i]["pwd"].replace("\n",""),accounts[i]["time"].replace("\n","")))
    file.close()
    
class LoginWindow(ui.ScriptWindow):
    
    connection = {
        "servername" : "jack",
        "ip" : "192.168.0.115",
        "auth" : 30001,
        "channel" : [30003,30007,15070,16070],
    }
    
    def __init__(self, stream):
        ui.ScriptWindow.__init__(self)
        net.SetPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
        net.SetAccountConnectorHandler(self)
        self.stream = stream
        self.isNowCountDown = FALSE
        self.connectingDialog = None
        parseAccountFile("account_list.txt")
        self.__LoadScript("jack_work/code/ui_poccix_login.py")
        ##self.__LoadScript("UIScript/ConnectingDialog.py")

    def Open(self):
        self.loginFailureMsgDict = {
            "ALREADY"    : localeInfo.LOGIN_FAILURE_ALREAY,
            "NOID"        : localeInfo.LOGIN_FAILURE_NOT_EXIST_ID,
            "WRONGPWD"    : localeInfo.LOGIN_FAILURE_WRONG_PASSWORD,
            "FULL"        : localeInfo.LOGIN_FAILURE_TOO_MANY_USER,
            "SHUTDOWN"    : localeInfo.LOGIN_FAILURE_SHUTDOWN,
            "REPAIR"    : localeInfo.LOGIN_FAILURE_REPAIR_ID,
            "BLOCK"        : localeInfo.LOGIN_FAILURE_BLOCK_ID,
            "QUIT"        : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER_TRIPLE,
            "BESAMEKEY"    : localeInfo.LOGIN_FAILURE_BE_SAME_KEY,
            "NOTAVAIL"    : localeInfo.LOGIN_FAILURE_NOT_AVAIL,
            "NOBILL"    : localeInfo.LOGIN_FAILURE_NOBILL,
            "BLKLOGIN"    : localeInfo.LOGIN_FAILURE_BLOCK_LOGIN,
            "WEBBLK"    : localeInfo.LOGIN_FAILURE_WEB_BLOCK,
        }
        
        self.loginFailureFuncDict = {
            "WRONGPWD"    : self.__DisconnectAndInputPassword,
            "QUIT"        : app.Exit,
        }
        snd.SetSoundVolume(systemSetting.GetSoundVolume())
        ime.AddExceptKey(91)
        ime.AddExceptKey(93)
        net.Disconnect()
        app.ShowCursor()
        self.Show()
        self.edit_id.SetFocus()
        self.__LoadAccounts()
        self.__SelectChannel(0)

        
    def Close(self):
        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None
        self.KillFocus()
        self.Hide()
        self.edit_id = None
        self.edit_pwd = None
        self.stream.popupWindow.Close()
        self.text_account = []
        self.loginFailureFuncDict=None
        ime.ClearExceptKey()
        app.HideCursor()
        
    def __del__(self):
        net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
        net.SetAccountConnectorHandler(0)
        ui.ScriptWindow.__del__(self)
        
    def __LoadScript(self, fileName):
        try:
            pyLoader = ui.PythonScriptLoader()
            pyLoader.LoadScriptFile(self, fileName)
        except:
            import exception
            exception.Abort("poccix_login.py ## __LoadScript.LoadScriptFile")
        try:
            self.background        = self.GetChild("background")
            self.btn_login        = self.GetChild("btn_login")
            self.edit_id        = self.GetChild("edit_id")
            self.edit_pwd        = self.GetChild("edit_pwd")
            self.btn_channel    = {
                0 : self.GetChild("btn_channel_01"),
                1 : self.GetChild("btn_channel_02"),
                2 : self.GetChild("btn_channel_03"),
                3 : self.GetChild("btn_channel_04"),
            }
            self.btn_select = {
                0 : self.GetChild("btn_select_01"),
                1 : self.GetChild("btn_select_02"),
                2 : self.GetChild("btn_select_03"),
                3 : self.GetChild("btn_select_04"),
                4 : self.GetChild("btn_select_05"),
            }
            self.btn_delete = {
                0 : self.GetChild("btn_delete_01"),
                1 : self.GetChild("btn_delete_02"),
                2 : self.GetChild("btn_delete_03"),
                3 : self.GetChild("btn_delete_04"),
                4 : self.GetChild("btn_delete_05"),
            }
            self.btn_add = {
                0 : self.GetChild("btn_add_01"),
                1 : self.GetChild("btn_add_02"),
                2 : self.GetChild("btn_add_03"),
                3 : self.GetChild("btn_add_04"),
                4 : self.GetChild("btn_add_05"),
            }
            self.text_account = {
                0 : self.GetChild("text_account_01"),
                1 : self.GetChild("text_account_02"),
                2 : self.GetChild("text_account_03"),
                3 : self.GetChild("text_account_04"),
                4 : self.GetChild("text_account_05"),
            }
        except:
            import exception
            exception.Abort("poccix_login.py ## __LoadScript.GetChild")
        try:
            self.btn_login.SetEvent(ui.__mem_func__(self.__Connect))
            for ch in range(len(self.btn_channel)):
                self.btn_channel[ch].SetEvent(ui.__mem_func__(self.__SelectChannel),ch)
            for accid in range(len(self.btn_select)):
                self.btn_select[accid].SetEvent(ui.__mem_func__(self.__SelectAccount),accid)
            for delid in range(len(self.btn_delete)):
                self.btn_delete[delid].SetEvent(ui.__mem_func__(self.__DeleteAccount),delid)
            for addid in range(len(self.btn_add)):
                self.btn_add[addid].SetEvent(ui.__mem_func__(self.__SaveAccount),addid)
            self.edit_id.SetReturnEvent(self.edit_pwd.SetFocus)
            self.edit_id.SetTabEvent(self.edit_pwd.SetFocus)
            self.edit_pwd.SetReturnEvent(ui.__mem_func__(self.__Connect))
            self.edit_pwd.SetTabEvent(self.edit_id.SetFocus)
        except:
            import exception
            exception.Abort("poccix_login.py ## __LoadScript.SetEvent")
            
    # ADDITIONAL FUNCTIONS
    
    def __Connect(self, id = FALSE, pwd = FALSE):
        if not id:
            id = self.edit_id.GetText()
            pwd = self.edit_pwd.GetText()
        if id == "":
            self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, self.SetIDEditLineFocus)
            return
        if pwd == "":
            self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, self.SetPasswordEditLineFocus)
            return
            
            
        global AccountName
        AccountName = id
            
        if constInfo.SEQUENCE_PACKET_ENABLE:
            net.SetPacketSequenceMode()
        self.stream.popupWindow.Close()
        self.stream.popupWindow.Open(localeInfo.LOGIN_CONNETING, self.SetPasswordEditLineFocus, localeInfo.UI_CANCEL)
        self.stream.SetLoginInfo(id, pwd)
        self.stream.Connect()
        
    def __SaveAccount(self, addid):
        id = self.edit_id.GetText()
        pwd = self.edit_pwd.GetText()
        if id == "" or pwd == "":
            self.PopupNotifyMessage("ID oder Passwort leer.")
            return
        salt = "LetItGoLetItGOOOO!"
        accounts[addid] = {"id" : encode(id, salt), "pwd" : encode(pwd, salt), "time" : salt}
        self.__LoadAccounts()
        
    def __Close(self):
        app.Exit()
        
    def __SelectAccount(self, accid):
        if accounts[accid]["id"] == "":
            return
        self.__Connect(decode(accounts[accid]["id"],accounts[accid]["time"]), decode(accounts[accid]["pwd"],accounts[accid]["time"]))
    
    def __DeleteAccount(self, delid):
        accounts[delid] = {"id" : "", "pwd" : "", "time" : ""}
        self.__LoadAccounts()
            
    def __SelectChannel(self, ch):
        for i in range(len(self.btn_channel)):
            self.btn_channel[i].SetUp()
        self.btn_channel[ch].Down()
        self.stream.SetConnectInfo(self.connection["ip"], self.connection["channel"][ch], self.connection["ip"], self.connection["auth"]) 
        net.SetServerInfo(self.connection["servername"] + " - CH" + str(ch+1))
        net.SetMarkServer(self.connection["ip"], self.connection["channel"][ch])
        app.SetGuildMarkPath("10.tga")
        app.SetGuildSymbolPath("10")

        
    def __LoadAccounts(self):
        saveAccountFile("account_list.txt")
        for i in range(len(self.text_account)):
            name = ""
            if accounts[i]["id"] == "":
                name = "Slot Liber"
            else:
                name = decode(accounts[i]["id"], accounts[i]["time"])
            self.text_account[i].SetText("#0" + str(i + 1) + " - " + name )

    # MAIN/BASE FUNCTIONS
    
    def OnConnectFailure(self):
        snd.PlaySound("sound/ui/loginfail.wav")
        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None
        self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.SetPasswordEditLineFocus)

    def OnHandShake(self):
        snd.PlaySound("sound/ui/loginok.wav")
        self.PopupDisplayMessage(localeInfo.LOGIN_CONNECT_SUCCESS)

    def OnLoginStart(self):
        self.PopupDisplayMessage(localeInfo.LOGIN_PROCESSING)

    def OnLoginFailure(self, error):
        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None
        try:
            loginFailureMsg = self.loginFailureMsgDict[error]
        except KeyError:
            loginFailureMsg = localeInfo.LOGIN_FAILURE_UNKNOWN  + error
        loginFailureFunc=self.loginFailureFuncDict.get(error, self.SetPasswordEditLineFocus)
        self.PopupNotifyMessage(loginFailureMsg, loginFailureFunc)
        snd.PlaySound("sound/ui/loginfail.wav")

    def __DisconnectAndInputID(self):
        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None

        self.SetIDEditLineFocus()
        net.Disconnect()

    def __DisconnectAndInputPassword(self):
        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None
        self.SetPasswordEditLineFocus()
        net.Disconnect()
    
    def PopupDisplayMessage(self, msg):
        self.stream.popupWindow.Close()
        self.stream.popupWindow.Open(msg)
        return

    def PopupNotifyMessage(self, msg, func=0):
        if not func:
            func=self.EmptyFunc

        self.stream.popupWindow.Close()
        self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)
    
    def SetIDEditLineFocus(self):
        if self.edit_id != None:
            self.edit_id.SetFocus()

    def SetPasswordEditLineFocus(self):
        if localeInfo.IsEUROPE():
            if self.edit_id != None:
                self.edit_id.SetText("")
                self.edit_id.SetFocus()
            if self.edit_pwd != None:
                self.edit_pwd.SetText("")
        else:
            if self.edit_pwd != None:
                self.edit_pwd.SetFocus()                               
        
    def EmptyFunc(self):
        pass
        
    def TestOutput(self, txt):
        import dbg
        dbg.TraceError("TESTOUTPUT :::: %s" % (txt))
    
    def OnPressExitKey(self):
        app.Exit()
        
class ConnectingDialog(ui.ScriptWindow):

    def __init__(self):
        ui.ScriptWindow.__init__(self)
        self.__LoadDialog()
        self.eventTimeOver = lambda *arg: None
        self.eventExit = lambda *arg: None

    def __del__(self):
        ui.ScriptWindow.__del__(self)

    def __LoadDialog(self):
        try:
            PythonScriptLoader = ui.PythonScriptLoader()
            PythonScriptLoader.LoadScriptFile(self, "UIScript/ConnectingDialog.py")
            self.board = self.GetChild("board")
            self.message = self.GetChild("message")
            self.countdownMessage = self.GetChild("countdown_message")
        except:
            import exception
            exception.Abort("ConnectingDialog.LoadDialog.BindObject")

    def Open(self, waitTime):
        curTime = time.clock()
        self.endTime = curTime + waitTime
        self.Lock()
        self.SetCenterPosition()
        self.SetTop()
        self.Show()       

    def Close(self):
        self.Unlock()
        self.Hide()

    def Destroy(self):
        self.Hide()
        self.ClearDictionary()

    def SetText(self, text):
        self.message.SetText(text)

    def SetCountDownMessage(self, waitTime):
        self.countdownMessage.SetText("%.0f%s" % (waitTime, localeInfo.SECOND))

    def SAFE_SetTimeOverEvent(self, event):
        self.eventTimeOver = ui.__mem_func__(event)

    def SAFE_SetExitEvent(self, event):
        self.eventExit = ui.__mem_func__(event)

    def OnUpdate(self):
        lastTime = max(0, self.endTime - time.clock())
        if 0 == lastTime:
            self.Close()
            self.eventTimeOver()
        else:
            self.SetCountDownMessage(self.endTime - time.clock())

    def OnPressExitKey(self):
        return TRUE
 
Metin2Hub Bot
M2Hub Bot
Feb
Threads
66
2,381
2
1,308
113
Sorry for my English.
I have a client from Martysamy 5.7 files from the forum. In the client, I replace the "intrologin.py" file in root. Everything works but after the loading screen it doesn't start the game.

I have this error.
Code:
1112 00:32:14928 :: File "networkModule.py", line 236, in SetGamePhase
1112 00:32:14928 :: File "game.py", line 86, in __init__
1112 00:32:14928 :: File "interfaceModule.py", line 310, in MakeInterface
1112 00:32:14929 :: File "interfaceModule.py", line 212, in __MakeWindows
1112 00:32:14929 :: File "uiMoveChannel.py", line 23, in __init__
1112 00:32:14929 :: File "uiMoveChannel.py", line 90, in __LoadWindow
1112 00:32:14929 :: File "uiMoveChannel.py", line 97, in __AddChannelButtons
1112 00:32:14929 :: File "uiMoveChannel.py", line 93, in GetChannelCount
1112 00:32:14929 :: KeyError
1112 00:32:14929 :: :
1112 00:32:14929 :: 0
1112 00:32:14929 ::

my original intrologin.py file from the client.
Code:
import dbg
import app
import net
import ui
import ime
import snd
import wndMgr
import musicInfo
import serverInfo
import systemSetting
import ServerStateChecker
import localeInfo
import constInfo
import uiCommon
import time
import serverCommandParser
import ime
import uiScriptLocale

LOGIN_DELAY_SEC = 0.0
SKIP_LOGIN_PHASE = False
SKIP_LOGIN_PHASE_SUPPORT_CHANNEL = False
FULL_BACK_IMAGE = False

VIRTUAL_KEYBOARD_NUM_KEYS = 46
VIRTUAL_KEYBOARD_RAND_KEY = True

def Suffle(src):
    if VIRTUAL_KEYBOARD_RAND_KEY:
        items = [item for item in src]

        itemCount = len(items)
        for oldPos in xrange(itemCount):
            newPos = app.GetRandom(0, itemCount-1)
            items[newPos], items[oldPos] = items[oldPos], items[newPos]

        return "".join(items)
    else:
        return src

def IsFullBackImage():
    global FULL_BACK_IMAGE
    return FULL_BACK_IMAGE

def IsLoginDelay():
    global LOGIN_DELAY_SEC
    if LOGIN_DELAY_SEC > 0.0:
        return True
    else:
        return False

def GetLoginDelay():
    global LOGIN_DELAY_SEC
    return LOGIN_DELAY_SEC

app.SetGuildMarkPath("test")

class ConnectingDialog(ui.ScriptWindow):

    def __init__(self):
        ui.ScriptWindow.__init__(self)
        self.__LoadDialog()
        self.eventTimeOver = lambda *arg: None
        self.eventExit = lambda *arg: None

    def __del__(self):
        ui.ScriptWindow.__del__(self)

    def __LoadDialog(self):
        try:
            PythonScriptLoader = ui.PythonScriptLoader()
            PythonScriptLoader.LoadScriptFile(self, "UIScript/ConnectingDialog.py")

            self.board = self.GetChild("board")
            self.message = self.GetChild("message")
            self.countdownMessage = self.GetChild("countdown_message")

        except:
            import exception
            exception.Abort("ConnectingDialog.LoadDialog.BindObject")

    def Open(self, waitTime):
        curTime = time.clock()
        self.endTime = curTime + waitTime

        self.Lock()
        self.SetCenterPosition()
        self.SetTop()
        self.Show()

    def Close(self):
        self.Unlock()
        self.Hide()

    def Destroy(self):
        self.Hide()
        self.ClearDictionary()

    def SetText(self, text):
        self.message.SetText(text)

    def SetCountDownMessage(self, waitTime):
        self.countdownMessage.SetText("%.0f%s" % (waitTime, localeInfo.SECOND))

    def SAFE_SetTimeOverEvent(self, event):
        self.eventTimeOver = ui.__mem_func__(event)

    def SAFE_SetExitEvent(self, event):
        self.eventExit = ui.__mem_func__(event)

    def OnUpdate(self):
        lastTime = max(0, self.endTime - time.clock())
        if 0 == lastTime:
            self.Close()
            self.eventTimeOver()
        else:
            self.SetCountDownMessage(self.endTime - time.clock())

    def OnPressExitKey(self):
        #self.eventExit()
        return True

class LoginWindow(ui.ScriptWindow):

    IS_TEST = net.IsTest()

    def __init__(self, stream):
        print "NEW LOGIN WINDOW  ----------------------------------------------------------------------------"
        ui.ScriptWindow.__init__(self)
        net.SetPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
        net.SetAccountConnectorHandler(self)

        self.lastLoginTime = 0
        self.inputDialog = None
        self.connectingDialog = None
        self.stream=stream
        self.isNowCountDown=False
        self.isStartError=False

        self.xServerBoard = 0
        self.yServerBoard = 0

        self.loadingImage = None

        self.virtualKeyboard = None
        self.virtualKeyboardMode = "ALPHABET"
        self.virtualKeyboardIsUpper = False

        # @fixme001 BEGIN (timeOutMsg and timeOutOk undefined)
        self.timeOutMsg = False
        self.timeOutOk = False
        # @fixme001 END

    def __del__(self):
        net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
        net.SetAccountConnectorHandler(0)
        ui.ScriptWindow.__del__(self)
        print "---------------------------------------------------------------------------- DELETE LOGIN WINDOW"

    def Open(self):
        ServerStateChecker.Create(self)

        print "LOGIN WINDOW OPEN ----------------------------------------------------------------------------"

        self.loginFailureMsgDict={
            #"DEFAULT" : localeInfo.LOGIN_FAILURE_UNKNOWN,

            "ALREADY"    : localeInfo.LOGIN_FAILURE_ALREAY,
            "NOID"        : localeInfo.LOGIN_FAILURE_NOT_EXIST_ID,
            "WRONGPWD"    : localeInfo.LOGIN_FAILURE_WRONG_PASSWORD,
            "FULL"        : localeInfo.LOGIN_FAILURE_TOO_MANY_USER,
            "SHUTDOWN"    : localeInfo.LOGIN_FAILURE_SHUTDOWN,
            "REPAIR"    : localeInfo.LOGIN_FAILURE_REPAIR_ID,
            "BLOCK"        : localeInfo.LOGIN_FAILURE_BLOCK_ID,
            "WRONGMAT"    : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER,
            "QUIT"        : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER_TRIPLE,
            "BESAMEKEY"    : localeInfo.LOGIN_FAILURE_BE_SAME_KEY,
            "NOTAVAIL"    : localeInfo.LOGIN_FAILURE_NOT_AVAIL,
            "NOBILL"    : localeInfo.LOGIN_FAILURE_NOBILL,
            "BLKLOGIN"    : localeInfo.LOGIN_FAILURE_BLOCK_LOGIN,
            "WEBBLK"    : localeInfo.LOGIN_FAILURE_WEB_BLOCK,
            "BADSCLID"    : localeInfo.LOGIN_FAILURE_WRONG_SOCIALID,
            "AGELIMIT"    : localeInfo.LOGIN_FAILURE_SHUTDOWN_TIME,
        }

        self.loginFailureFuncDict = {
            "WRONGPWD"    : self.__DisconnectAndInputPassword,
            "QUIT"        : app.Exit,
        }

        self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())
        self.SetWindowName("LoginWindow")

        if not self.__LoadScript(uiScriptLocale.LOCALE_UISCRIPT_PATH + "LoginWindow.py"):
            dbg.TraceError("LoginWindow.Open - __LoadScript Error")
            return

        self.__LoadLoginInfo("loginInfo.xml")

        if app.loggined:
            self.loginFailureFuncDict = {
            "WRONGPWD"    : app.Exit,
            "WRONGMAT"    : app.Exit,
            "QUIT"        : app.Exit,
            }

        if musicInfo.loginMusic != "":
            snd.SetMusicVolume(systemSetting.GetMusicVolume())
            snd.FadeInMusic("BGM/"+musicInfo.loginMusic)

        snd.SetSoundVolume(systemSetting.GetSoundVolume())

        # pevent key "[" "]"
        ime.AddExceptKey(91)
        ime.AddExceptKey(93)

        self.Show()

        global SKIP_LOGIN_PHASE
        if SKIP_LOGIN_PHASE:
            if self.isStartError:
                self.connectBoard.Hide()
                self.loginBoard.Hide()
                if constInfo.ENABLE_SAVE_ACCOUNT:
                    self.saveAccountBoard.Hide()
                self.serverBoard.Hide()
                self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.__ExitGame)
                return

            if self.loginInfo:
                self.serverBoard.Hide()
            else:
                self.__RefreshServerList()
                self.__OpenServerBoard()
        else:
            connectingIP = self.stream.GetConnectAddr()
            if connectingIP:
                if app.USE_OPENID and not app.OPENID_TEST :
                    self.__RefreshServerList()
                    self.__OpenServerBoard()
                else:
                    self.__OpenLoginBoard()
                    if IsFullBackImage():
                        self.GetChild("bg1").Hide()
                        self.GetChild("bg2").Show()

            else:
                self.__RefreshServerList()
                self.__OpenServerBoard()

        app.ShowCursor()

    def Close(self):

        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None

        ServerStateChecker.Initialize(self)

        print "---------------------------------------------------------------------------- CLOSE LOGIN WINDOW "
        #
        #
        if musicInfo.loginMusic != "" and musicInfo.selectMusic != "":
            snd.FadeOutMusic("BGM/"+musicInfo.loginMusic)

        self.idEditLine.SetTabEvent(0)
        self.idEditLine.SetReturnEvent(0)
        self.pwdEditLine.SetReturnEvent(0)
        self.pwdEditLine.SetTabEvent(0)

        self.connectBoard = None
        self.loginBoard = None
        if constInfo.ENABLE_SAVE_ACCOUNT:
            self.saveAccountBoard = None
        self.idEditLine = None
        self.pwdEditLine = None
        self.inputDialog = None
        self.connectingDialog = None
        self.loadingImage = None

        self.serverBoard                = None
        self.serverList                    = None
        self.channelList                = None

        self.VIRTUAL_KEY_ALPHABET_LOWERS = None
        self.VIRTUAL_KEY_ALPHABET_UPPERS = None
        self.VIRTUAL_KEY_SYMBOLS = None
        self.VIRTUAL_KEY_NUMBERS = None

        # VIRTUAL_KEYBOARD_BUG_FIX
        if self.virtualKeyboard:
            for keyIndex in xrange(0, VIRTUAL_KEYBOARD_NUM_KEYS+1):
                key = self.GetChild2("key_%d" % keyIndex)
                if key:
                    key.SetEvent(None)

            self.GetChild("key_space").SetEvent(None)
            self.GetChild("key_backspace").SetEvent(None)
            self.GetChild("key_enter").SetEvent(None)
            self.GetChild("key_shift").SetToggleDownEvent(None)
            self.GetChild("key_shift").SetToggleUpEvent(None)
            self.GetChild("key_at").SetToggleDownEvent(None)
            self.GetChild("key_at").SetToggleUpEvent(None)

            self.virtualKeyboard = None

        self.KillFocus()
        self.Hide()

        self.stream.popupWindow.Close()
        self.loginFailureFuncDict=None

        ime.ClearExceptKey()

        app.HideCursor()

    def __SaveChannelInfo(self):
        try:
            file=old_open("channel.inf", "w")
            file.write("%d %d %d" % (self.__GetServerID(), self.__GetChannelID(), self.__GetRegionID()))
        except:
            print "LoginWindow.__SaveChannelInfo - SaveError"

    def __LoadChannelInfo(self):
        try:
            file=old_open("channel.inf")
            lines=file.readlines()

            if len(lines)>0:
                tokens=lines[0].split()

                selServerID=int(tokens[0])
                selChannelID=int(tokens[1])

                if len(tokens) == 3:
                    regionID = int(tokens[2])

                return regionID, selServerID, selChannelID

        except:
            print "LoginWindow.__LoadChannelInfo - OpenError"
            return -1, -1, -1

    def __ExitGame(self):
        app.Exit()

    def SetIDEditLineFocus(self):
        if self.idEditLine != None:
            self.idEditLine.SetFocus()

    def SetPasswordEditLineFocus(self):
        if constInfo.ENABLE_CLEAN_DATA_IF_FAIL_LOGIN:
            if self.idEditLine != None:
                self.idEditLine.SetText("")
                self.idEditLine.SetFocus()

            if self.pwdEditLine != None:
                self.pwdEditLine.SetText("")
        else:
            if self.pwdEditLine != None:
                self.pwdEditLine.SetFocus()

    def OnEndCountDown(self):
        self.isNowCountDown = False
        self.timeOutMsg = False
        self.OnConnectFailure()

    def OnConnectFailure(self):

        if self.isNowCountDown:
            return

        snd.PlaySound("sound/ui/loginfail.wav")

        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None

        if app.loggined:
            self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.__ExitGame)
        elif self.timeOutMsg:
            self.PopupNotifyMessage(localeInfo.LOGIN_FAILURE_TIMEOUT, self.SetPasswordEditLineFocus)
        else:
            self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.SetPasswordEditLineFocus)

    def OnHandShake(self):
        if not IsLoginDelay():
            snd.PlaySound("sound/ui/loginok.wav")
            self.PopupDisplayMessage(localeInfo.LOGIN_CONNECT_SUCCESS)

    def OnLoginStart(self):
        if not IsLoginDelay():
            self.PopupDisplayMessage(localeInfo.LOGIN_PROCESSING)

    def OnLoginFailure(self, error):
        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None

        try:
            loginFailureMsg = self.loginFailureMsgDict[error]
        except KeyError:
            loginFailureMsg = localeInfo.LOGIN_FAILURE_UNKNOWN  + error


        loginFailureFunc=self.loginFailureFuncDict.get(error, self.SetPasswordEditLineFocus)

        if app.loggined:
            self.PopupNotifyMessage(loginFailureMsg, self.__ExitGame)
        else:
            self.PopupNotifyMessage(loginFailureMsg, loginFailureFunc)

        snd.PlaySound("sound/ui/loginfail.wav")

    def __DisconnectAndInputID(self):
        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None

        self.SetIDEditLineFocus()
        net.Disconnect()

    def __DisconnectAndInputPassword(self):
        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None

        self.SetPasswordEditLineFocus()
        net.Disconnect()

    if constInfo.ENABLE_SAVE_ACCOUNT:
        def SAB_LoadAccountData(self):
            if constInfo.SAB.storeType == constInfo.SAB.ST_CACHE:
                return
            for idx in xrange(constInfo.SAB.slotCount):
                if constInfo.SAB.storeType == constInfo.SAB.ST_REGISTRY:
                    id = constInfo.GetWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValueId))
                    pwd = constInfo.GetWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValuePwd))
                    if id and pwd:
                        self.SAB_SetAccountData(idx, (id, pwd))
                elif constInfo.SAB.storeType == constInfo.SAB.ST_FILE:
                    (id, pwd) = constInfo.GetJsonSABData(idx)
                    if id and pwd:
                        self.SAB_SetAccountData(idx, (id, pwd))

        def SAB_SaveAccountData(self):
            if constInfo.SAB.storeType == constInfo.SAB.ST_CACHE:
                return
            for idx in xrange(constInfo.SAB.slotCount):
                if constInfo.SAB.storeType == constInfo.SAB.ST_REGISTRY:
                    _tSlot = self.SAB_GetAccountData(idx)
                    if _tSlot:
                        (id, pwd) = _tSlot
                        constInfo.SetWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValueId), id)
                        constInfo.SetWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValuePwd), pwd)
                    else:
                        constInfo.DelWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValueId))
                        constInfo.DelWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValuePwd))
                elif constInfo.SAB.storeType == constInfo.SAB.ST_FILE:
                    _tSlot = self.SAB_GetAccountData(idx)
                    if _tSlot:
                        constInfo.SetJsonSABData(idx, _tSlot)
                    else:
                        constInfo.DelJsonSABData(idx)

        def SAB_DelAccountData(self, slot):
            if constInfo.SAB.accData.get(slot):
                del constInfo.SAB.accData[slot]

        def SAB_GetAccountData(self, slot):
            return constInfo.SAB.accData.get(slot)

        def SAB_SetAccountData(self, slot, data):
            constInfo.SAB.accData[slot] = data

        def SAB_BtnRearrange(self):
            def tooltipArrange(_btnObj):
                _tMexTip = "Account ID: %s" % id
                _btnObj.SetToolTipText(_tMexTip)
                if _btnObj.ToolTipText:
                    _btnObj.ToolTipText.SetPackedFontColor(0xff66FFFF)
            ## def code
            GetObject=self.GetChild
            SetObject=self.InsertChild
            ## button names
            btnNameSave = constInfo.SAB.btnName["Save"]
            btnNameAccess = constInfo.SAB.btnName["Access"]
            btnNameRemove = constInfo.SAB.btnName["Remove"]
            ## rearrange code
            for idx in xrange(constInfo.SAB.slotCount):
                _tSlot = self.SAB_GetAccountData(idx)
                # button objects
                btnObjSave = GetObject(btnNameSave % idx)
                btnObjAccess = GetObject(btnNameAccess % idx)
                btnObjRemove = GetObject(btnNameRemove % idx)
                if _tSlot:
                    (id, pwd) = _tSlot
                    btnObjSave.Hide()
                    btnObjAccess.Show()
                    btnObjRemove.Show()
                    btnObjAccess.SetText("|cffFF0000|h[F{}]|r Connect {}".format(idx+1, id))
                else:
                    btnObjSave.Show()
                    btnObjAccess.Hide()
                    btnObjRemove.Hide()
            # done

        def SAB_Click_Save(self, slot):
            if slot >= constInfo.SAB.slotCount:
                return
            ## def code
            GetObject=self.GetChild
            SetObject=self.InsertChild
            ## button stuff
            _tmpName = constInfo.SAB.btnName["Save"] % slot
            _tmpObj = GetObject(_tmpName)
            ## code stuff
            try:
                id = self.idEditLine.GetText()
                pwd = self.pwdEditLine.GetText()

                if len(id)==0:
                    self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, self.SetIDEditLineFocus)
                    return

                if len(pwd)==0:
                    self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, self.SetPasswordEditLineFocus)
                    return
            except:
                return
            self.SAB_SetAccountData(slot, (id,pwd))
            self.SAB_SaveAccountData()
            ## rearrange stuff
            self.SAB_BtnRearrange()

        def SAB_Click_Access(self, slot):
            if slot >= constInfo.SAB.slotCount:
                return
            ## def code
            GetObject=self.GetChild
            SetObject=self.InsertChild
            ## button stuff
            _tmpName = constInfo.SAB.btnName["Access"] % slot
            _tmpObj = GetObject(_tmpName)
            ## code stuff
            _tSlot = self.SAB_GetAccountData(slot)
            if _tSlot:
                (id, pwd) = _tSlot
                self.idEditLine.SetText(id)
                self.pwdEditLine.SetText(pwd)
                self.__OnClickSelectServerButton()
                self.__OnClickLoginButton()

        def SAB_Click_Remove(self, slot):
            if slot >= constInfo.SAB.slotCount:
                return
            ## def code
            GetObject=self.GetChild
            SetObject=self.InsertChild
            ## button stuff
            _tmpName = constInfo.SAB.btnName["Remove"] % slot
            _tmpObj = GetObject(_tmpName)
            ## code stuff
            self.SAB_DelAccountData(slot)
            self.SAB_SaveAccountData()
            ## rearrange stuff
            self.SAB_BtnRearrange()

        def __CreateSaveAccountBoard(self):
            ### SAB INIT
            self.SAB_LoadAccountData()
            ## def code
            GetObject=self.GetChild
            SetObject=self.InsertChild
            ## gui stuff
            SCREEN_WIDTH = wndMgr.GetScreenWidth()
            SCREEN_HEIGHT = wndMgr.GetScreenHeight()
            ## button space
            SPACE_FOR_BUTTON = 25+1
            ALL_BUTTON_SPACE = SPACE_FOR_BUTTON * constInfo.SAB.slotCount
            ## board stuff
            BOARD_SIZE = (210+120, 28 + ALL_BUTTON_SPACE)
            BOARD_POS = ((SCREEN_WIDTH - 208) / 2 + 210, (SCREEN_HEIGHT - 410) - (10*constInfo.SAB.slotCount))
            ## button stuff
            btnNameSave = constInfo.SAB.btnName["Save"]
            btnNameAccess = constInfo.SAB.btnName["Access"]
            btnNameRemove = constInfo.SAB.btnName["Remove"]
            btnPath = "d:/ymir work/ui/public/%s_button_%02d.sub" # xsmall small middle large xlarge big
            btnImage = {"default":1,"over":2,"down":3}
            ## SAB BOARD
            try:
                ## default init
                _tmpName = "SaveAccountBoard"
                SetObject(_tmpName, ui.ThinBoard())
                #
                _tmpObj = GetObject(_tmpName)
                _tmpObj.SetParent(self)
                ## custom data
                _tmpObj.SetSize(*BOARD_SIZE)
                ## default data
                _tmpObj.SetPosition(*BOARD_POS)
                _tmpObj.Show()
                self.saveAccountBoard = _tmpObj
            except:
                import exception; exception.Abort("__CreateSaveAccountBoard SAB BOARD")
            ### SAB TITLE
            try:
                ## default init
                _tmpName = "SaveAccountTitle"
                SetObject(_tmpName, ui.TextLine())
                _tmpObj = GetObject(_tmpName)
                _tmpObj.SetParent(self.saveAccountBoard)
                ## custom data
                _tmpObj.SetHorizontalAlignCenter()
                _tmpObj.SetPackedFontColor(0xFFffbf00)
                _tmpObj.SetOutline()
                _tmpObj.SetText("Save Account Board")
                ## default data
                _tmpObj.SetPosition(BOARD_SIZE[0]/2, 5)
                _tmpObj.Show()
            except:
                import exception; exception.Abort("__CreateSaveAccountBoard SAB TITLE")
            ### SAB LINE
            try:
                ## default init
                _tmpName = "SaveAccountLine"
                SetObject(_tmpName, ui.Line())
                _tmpObj = GetObject(_tmpName)
                _tmpObj.SetParent(self.saveAccountBoard)
                ## custom data
                _tmpObj.SetColor(0xFF777777)
                _tmpObj.SetSize(BOARD_SIZE[0]-10, 0)
                ## default data
                _tmpObj.SetPosition(5, 20)
                _tmpObj.Show()
            except:
                import exception; exception.Abort("__CreateSaveAccountBoard SAB LINE")
            ## SaveAccountButtons
            for idx in xrange(constInfo.SAB.slotCount):
                ### SAB SAVE
                try:
                    ## default init
                    _tmpName = btnNameSave % (idx)
                    SetObject(_tmpName, ui.Button())
                    _tmpObj = GetObject(_tmpName)
                    _tmpObj.SetParent(self.saveAccountBoard)
                    ## custom data
                    _tmpBtnPath = "d:/ymir work/ui/public/xlarge_button_%02d.sub" # xsmall small middle large xlarge big
                    _tmpObj.SetUpVisual(_tmpBtnPath % (btnImage["default"]))
                    _tmpObj.SetOverVisual(_tmpBtnPath % (btnImage["over"]))
                    _tmpObj.SetDownVisual(_tmpBtnPath % (btnImage["down"]))
                    _tmpObj.SetText("Save Account")
                    _tmpObj.SAFE_SetEvent(self.SAB_Click_Save, idx)
                    ## default data
                    _tmpObj.SetPosition(15 + 60, 25 + (idx * SPACE_FOR_BUTTON))
                    _tmpObj.Hide()
                except:
                    import exception; exception.Abort("__CreateSaveAccountBoard SAB SAVE")
                ### SAB ACCESS
                try:
                    ## default init
                    _tmpName = btnNameAccess % (idx)
                    SetObject(_tmpName, ui.Button())
                    _tmpObj = GetObject(_tmpName)
                    _tmpObj.SetParent(self.saveAccountBoard)
                    ## custom data
                    _tmpBtnPath = "d:/ymir work/ui/public/xlarge_button_%02d.sub" # xsmall small middle large xlarge big
                    _tmpObj.SetUpVisual(_tmpBtnPath % (btnImage["default"]))
                    _tmpObj.SetOverVisual(_tmpBtnPath % (btnImage["over"]))
                    _tmpObj.SetDownVisual(_tmpBtnPath % (btnImage["down"]))
                    _tmpObj.SetText("Connect #{}".format(idx+1))
                    _tmpObj.SAFE_SetEvent(self.SAB_Click_Access, idx)
                    ## default data
                    _tmpObj.SetPosition(35, 25 + (idx * SPACE_FOR_BUTTON))
                    _tmpObj.Show()
                except:
                    import exception; exception.Abort("__CreateSaveAccountBoard SAB ACCESS")
                ### SAB REMOVE
                try:
                    ## default init
                    _tmpName = btnNameRemove % (idx)
                    SetObject(_tmpName, ui.Button())
                    _tmpObj = GetObject(_tmpName)
                    _tmpObj.SetParent(self.saveAccountBoard)
                    ## custom data
                    _tmpBtnPath = "d:/ymir work/ui/public/middle_button_%02d.sub" # xsmall small middle large xlarge big
                    _tmpObj.SetUpVisual(_tmpBtnPath % (btnImage["default"]))
                    _tmpObj.SetOverVisual(_tmpBtnPath % (btnImage["over"]))
                    _tmpObj.SetDownVisual(_tmpBtnPath % (btnImage["down"]))
                    _tmpObj.SetText("Remove")
                    _tmpObj.SAFE_SetEvent(self.SAB_Click_Remove, idx)
                    ## default data
                    _tmpObj.SetPosition(35 + 190, 25 + (idx * SPACE_FOR_BUTTON))
                    _tmpObj.Show()
                except:
                    import exception; exception.Abort("__CreateSaveAccountBoard SAB REMOVE")
            self.SAB_BtnRearrange()

    def __LoadScript(self, fileName):
        import dbg
        try:
            pyScrLoader = ui.PythonScriptLoader()
            pyScrLoader.LoadScriptFile(self, fileName)
        except:
            import exception
            exception.Abort("LoginWindow.__LoadScript.LoadObject")
        try:
            GetObject=self.GetChild
            self.serverBoard            = GetObject("ServerBoard")
            self.serverList                = GetObject("ServerList")
            self.channelList            = GetObject("ChannelList")
            self.serverSelectButton        = GetObject("ServerSelectButton")
            self.serverExitButton        = GetObject("ServerExitButton")
            self.connectBoard            = GetObject("ConnectBoard")
            self.loginBoard                = GetObject("LoginBoard")
            self.idEditLine                = GetObject("ID_EditLine")
            self.pwdEditLine            = GetObject("Password_EditLine")
            self.serverInfo                = GetObject("ConnectName")
            self.selectConnectButton    = GetObject("SelectConnectButton")
            self.loginButton            = GetObject("LoginButton")
            self.loginExitButton        = GetObject("LoginExitButton")

            if constInfo.ENABLE_SAVE_ACCOUNT:
                self.__CreateSaveAccountBoard()

            self.virtualKeyboard        = self.GetChild2("VirtualKeyboard")

            if self.virtualKeyboard:
                self.VIRTUAL_KEY_ALPHABET_UPPERS = Suffle(localeInfo.VIRTUAL_KEY_ALPHABET_UPPERS)
                self.VIRTUAL_KEY_ALPHABET_LOWERS = "".join([localeInfo.VIRTUAL_KEY_ALPHABET_LOWERS[localeInfo.VIRTUAL_KEY_ALPHABET_UPPERS.index(e)] for e in self.VIRTUAL_KEY_ALPHABET_UPPERS])
                if localeInfo.IsBRAZIL():
                    self.VIRTUAL_KEY_SYMBOLS_BR = Suffle(localeInfo.VIRTUAL_KEY_SYMBOLS_BR)
                else:
                    self.VIRTUAL_KEY_SYMBOLS = Suffle(localeInfo.VIRTUAL_KEY_SYMBOLS)
                self.VIRTUAL_KEY_NUMBERS = Suffle(localeInfo.VIRTUAL_KEY_NUMBERS)
                self.__VirtualKeyboard_SetAlphabetMode()

                self.GetChild("key_space").SetEvent(lambda : self.__VirtualKeyboard_PressKey(' '))
                self.GetChild("key_backspace").SetEvent(lambda : self.__VirtualKeyboard_PressBackspace())
                self.GetChild("key_enter").SetEvent(lambda : self.__VirtualKeyboard_PressReturn())
                self.GetChild("key_shift").SetToggleDownEvent(lambda : self.__VirtualKeyboard_SetUpperMode())
                self.GetChild("key_shift").SetToggleUpEvent(lambda : self.__VirtualKeyboard_SetLowerMode())
                self.GetChild("key_at").SetToggleDownEvent(lambda : self.__VirtualKeyboard_SetSymbolMode())
                self.GetChild("key_at").SetToggleUpEvent(lambda : self.__VirtualKeyboard_SetAlphabetMode())

        except:
            import exception
            exception.Abort("LoginWindow.__LoadScript.BindObject")

        if self.IS_TEST:
            self.selectConnectButton.Hide()
        else:
            self.selectConnectButton.SetEvent(ui.__mem_func__(self.__OnClickSelectConnectButton))

        self.serverBoard.OnKeyUp = ui.__mem_func__(self.__ServerBoard_OnKeyUp)
        self.xServerBoard, self.yServerBoard = self.serverBoard.GetLocalPosition()

        self.serverSelectButton.SetEvent(ui.__mem_func__(self.__OnClickSelectServerButton))
        self.serverExitButton.SetEvent(ui.__mem_func__(self.__OnClickExitButton))

        self.loginButton.SetEvent(ui.__mem_func__(self.__OnClickLoginButton))
        self.loginExitButton.SetEvent(ui.__mem_func__(self.__OnClickExitButton))

        self.serverList.SetEvent(ui.__mem_func__(self.__OnSelectServer))

        self.idEditLine.SetReturnEvent(ui.__mem_func__(self.pwdEditLine.SetFocus))
        self.idEditLine.SetTabEvent(ui.__mem_func__(self.pwdEditLine.SetFocus))

        self.pwdEditLine.SetReturnEvent(ui.__mem_func__(self.__OnClickLoginButton))
        self.pwdEditLine.SetTabEvent(ui.__mem_func__(self.idEditLine.SetFocus))

        if IsFullBackImage():
            self.GetChild("bg1").Show()
            self.GetChild("bg2").Hide()
        return 1

    def __VirtualKeyboard_SetKeys(self, keyCodes):
        uiDefFontBackup = localeInfo.UI_DEF_FONT
        localeInfo.UI_DEF_FONT = localeInfo.UI_DEF_FONT_LARGE

        keyIndex = 1
        for keyCode in keyCodes:
            key = self.GetChild2("key_%d" % keyIndex)
            if key:
                key.SetEvent(lambda x=keyCode: self.__VirtualKeyboard_PressKey(x))
                key.SetText(keyCode)
                key.ButtonText.SetFontColor(0, 0, 0)
                keyIndex += 1

        for keyIndex in xrange(keyIndex, VIRTUAL_KEYBOARD_NUM_KEYS+1):
            key = self.GetChild2("key_%d" % keyIndex)
            if key:
                key.SetEvent(lambda x=' ': self.__VirtualKeyboard_PressKey(x))
                key.SetText(' ')

        localeInfo.UI_DEF_FONT = uiDefFontBackup

    def __VirtualKeyboard_PressKey(self, code):
        ime.PasteString(code)

        #if self.virtualKeyboardMode == "ALPHABET" and self.virtualKeyboardIsUpper:
        #    self.__VirtualKeyboard_SetLowerMode()

    def __VirtualKeyboard_PressBackspace(self):
        ime.PasteBackspace()

    def __VirtualKeyboard_PressReturn(self):
        ime.PasteReturn()

    def __VirtualKeyboard_SetUpperMode(self):
        self.virtualKeyboardIsUpper = True

        if self.virtualKeyboardMode == "ALPHABET":
            self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_ALPHABET_UPPERS)
        elif self.virtualKeyboardMode == "NUMBER":
            if localeInfo.IsBRAZIL():
                self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS_BR)
            else:
                self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS)
        else:
            self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_NUMBERS)

    def __VirtualKeyboard_SetLowerMode(self):
        self.virtualKeyboardIsUpper = False

        if self.virtualKeyboardMode == "ALPHABET":
            self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_ALPHABET_LOWERS)
        elif self.virtualKeyboardMode == "NUMBER":
            self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_NUMBERS)
        else:
            if localeInfo.IsBRAZIL():
                self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS_BR)
            else:
                self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS)

    def __VirtualKeyboard_SetAlphabetMode(self):
        self.virtualKeyboardIsUpper = False
        self.virtualKeyboardMode = "ALPHABET"
        self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_ALPHABET_LOWERS)

    def __VirtualKeyboard_SetNumberMode(self):
        self.virtualKeyboardIsUpper = False
        self.virtualKeyboardMode = "NUMBER"
        self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_NUMBERS)

    def __VirtualKeyboard_SetSymbolMode(self):
        self.virtualKeyboardIsUpper = False
        self.virtualKeyboardMode = "SYMBOL"
        if localeInfo.IsBRAZIL():
            self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS_BR)
        else:
            self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS)

    def Connect(self, id, pwd):

        if constInfo.SEQUENCE_PACKET_ENABLE:
            net.SetPacketSequenceMode()

        if IsLoginDelay():
            loginDelay = GetLoginDelay()
            self.connectingDialog = ConnectingDialog()
            self.connectingDialog.Open(loginDelay)
            self.connectingDialog.SAFE_SetTimeOverEvent(self.OnEndCountDown)
            self.connectingDialog.SAFE_SetExitEvent(self.OnPressExitKey)
            self.isNowCountDown = True

        else:
            self.stream.popupWindow.Close()
            self.stream.popupWindow.Open(localeInfo.LOGIN_CONNETING, self.SetPasswordEditLineFocus, localeInfo.UI_CANCEL)

        self.stream.SetLoginInfo(id, pwd)
        self.stream.Connect()

    def __OnClickExitButton(self):
        self.stream.SetPhaseWindow(0)

    def __SetServerInfo(self, name):
        net.SetServerInfo(name.strip())
        self.serverInfo.SetText(name)

    def __LoadLoginInfo(self, loginInfoFileName):
        def getValue(element, name, default):
            if [] != element.getElementsByTagName(name):
                return element.getElementsByTagName(name).item(0).firstChild.nodeValue
            else:
                return default

        self.id = None
        self.pwd = None
        self.loginnedServer = None
        self.loginnedChannel = None
        app.loggined = False

        self.loginInfo = True

        from xml.dom.minidom import parse
        try:
            f = old_open(loginInfoFileName, "r")
            dom = parse(f)
        except:
            return
        serverLst = dom.getElementsByTagName("server")
        if [] != dom.getElementsByTagName("logininfo"):
            logininfo = dom.getElementsByTagName("logininfo")[0]
        else:
            return

        try:
            server_name = logininfo.getAttribute("name")
            channel_idx = int(logininfo.getAttribute("channel_idx"))
        except:
            return

        try:
            matched = False

            for k, v in serverInfo.REGION_DICT[0].iteritems():
                if v["name"] == server_name:
                    account_addr = serverInfo.REGION_AUTH_SERVER_DICT[0][k]["ip"]
                    account_port = serverInfo.REGION_AUTH_SERVER_DICT[0][k]["port"]

                    channel_info = v["channel"][channel_idx]
                    channel_name = channel_info["name"]
                    addr = channel_info["ip"]
                    port = channel_info["tcp_port"]

                    net.SetMarkServer(addr, port)
                    self.stream.SetConnectInfo(addr, port, account_addr, account_port)

                    matched = True
                    break

            if False == matched:
                return
        except:
            return

        self.__SetServerInfo("%s, %s " % (server_name, channel_name))
        id = getValue(logininfo, "id", "")
        pwd = getValue(logininfo, "pwd", "")
        self.idEditLine.SetText(id)
        self.pwdEditLine.SetText(pwd)
        slot = getValue(logininfo, "slot", "0")
        locale = getValue(logininfo, "locale", "")
        locale_dir = getValue(logininfo, "locale_dir", "")
        is_auto_login = int(getValue(logininfo, "auto_login", "0"))

        self.stream.SetCharacterSlot(int(slot))
        self.stream.isAutoLogin=is_auto_login
        self.stream.isAutoSelect=is_auto_login

        if locale and locale_dir:
            app.ForceSetLocale(locale, locale_dir)

        if 0 != is_auto_login:
            self.Connect(id, pwd)

        return


    def PopupDisplayMessage(self, msg):
        self.stream.popupWindow.Close()
        self.stream.popupWindow.Open(msg)

    def PopupNotifyMessage(self, msg, func=0):
        if not func:
            func=self.EmptyFunc

        self.stream.popupWindow.Close()
        self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)

    def __OnCloseInputDialog(self):
        if self.inputDialog:
            self.inputDialog.Close()
        self.inputDialog = None
        return True

    def OnPressExitKey(self):
        self.stream.popupWindow.Close()
        self.stream.SetPhaseWindow(0)
        return True

    def OnExit(self):
        self.stream.popupWindow.Close()
        self.stream.popupWindow.Open(localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER_TRIPLE, app.Exit, localeInfo.UI_OK)

    def OnUpdate(self):
        ServerStateChecker.Update()

    def EmptyFunc(self):
        pass

    #####################################################################################

    def __ServerBoard_OnKeyUp(self, key):
        if self.serverBoard.IsShow():
            if app.DIK_RETURN==key:
                self.__OnClickSelectServerButton()
        return True

    def __GetRegionID(self):
        return 0

    def __GetServerID(self):
        return self.serverList.GetSelectedItem()

    def __GetChannelID(self):
        return self.channelList.GetSelectedItem()

    # SEVER_LIST_BUG_FIX
    def __ServerIDToServerIndex(self, regionID, targetServerID):
        try:
            regionDict = serverInfo.REGION_DICT[regionID]
        except KeyError:
            return -1

        retServerIndex = 0
        for eachServerID, regionDataDict in regionDict.items():
            if eachServerID == targetServerID:
                return retServerIndex

            retServerIndex += 1

        return -1

    def __ChannelIDToChannelIndex(self, channelID):
        return channelID - 1
    # END_OF_SEVER_LIST_BUG_FIX

    def __OpenServerBoard(self):

        loadRegionID, loadServerID, loadChannelID = self.__LoadChannelInfo()

        serverIndex = self.__ServerIDToServerIndex(loadRegionID, loadServerID)
        channelIndex = self.__ChannelIDToChannelIndex(loadChannelID)

        self.serverList.SelectItem(serverIndex)

        if constInfo.ENABLE_RANDOM_CHANNEL_SEL:
            self.channelList.SelectItem(app.GetRandom(0, self.channelList.GetItemCount()))
        else:
            if channelIndex >= 0:
                self.channelList.SelectItem(channelIndex)

        self.serverBoard.SetPosition(self.xServerBoard, self.yServerBoard)
        self.serverBoard.Show()
        self.connectBoard.Hide()
        self.loginBoard.Hide()
        if constInfo.ENABLE_SAVE_ACCOUNT:
            self.saveAccountBoard.Hide()

        if self.virtualKeyboard:
            self.virtualKeyboard.Hide()

        if app.loggined and not SKIP_LOGIN_PHASE_SUPPORT_CHANNEL:
            self.serverList.SelectItem(self.loginnedServer-1)
            self.channelList.SelectItem(self.loginnedChannel-1)
            self.__OnClickSelectServerButton()

    def __OpenLoginBoard(self):

        self.serverExitButton.SetEvent(ui.__mem_func__(self.__OnClickExitServerButton))
        self.serverExitButton.SetText(localeInfo.UI_CLOSE)

        self.serverBoard.SetPosition(self.xServerBoard, wndMgr.GetScreenHeight())
        self.serverBoard.Hide()

        if self.virtualKeyboard:
            self.virtualKeyboard.Show()

        if app.loggined:
            self.Connect(self.id, self.pwd)
            self.connectBoard.Hide()
            self.loginBoard.Hide()
            if constInfo.ENABLE_SAVE_ACCOUNT:
                self.saveAccountBoard.Hide()
        elif not self.stream.isAutoLogin:
            self.connectBoard.Show()
            self.loginBoard.Show()
            if constInfo.ENABLE_SAVE_ACCOUNT:
                self.saveAccountBoard.Show()

        ## if users have the login infomation, then don't initialize.2005.9 haho
        if self.idEditLine == None:
            self.idEditLine.SetText("")
        if self.pwdEditLine == None:
            self.pwdEditLine.SetText("")

        self.idEditLine.SetFocus()

        global SKIP_LOGIN_PHASE
        if SKIP_LOGIN_PHASE:
            if not self.loginInfo:
                self.connectBoard.Hide()

    def __OnSelectRegionGroup(self):
        self.__RefreshServerList()

    def __OnSelectSettlementArea(self):
        # SEVER_LIST_BUG_FIX
        regionID = self.__GetRegionID()
        serverID = self.serverListOnRegionBoard.GetSelectedItem()

        serverIndex = self.__ServerIDToServerIndex(regionID, serverID)
        self.serverList.SelectItem(serverIndex)
        # END_OF_SEVER_LIST_BUG_FIX

        self.__OnSelectServer()

    def __RefreshServerList(self):
        regionID = self.__GetRegionID()

        if not serverInfo.REGION_DICT.has_key(regionID):
            return

        self.serverList.ClearItem()

        regionDict = serverInfo.REGION_DICT[regionID]

        # SEVER_LIST_BUG_FIX
        visible_index = 1
        for id, regionDataDict in regionDict.items():
            name = regionDataDict.get("name", "noname")
            try:
                server_id = serverInfo.SERVER_ID_DICT[id]
            except:
                server_id = visible_index

            self.serverList.InsertItem(id, "  %02d. %s" % (int(server_id), name))

            visible_index += 1

        # END_OF_SEVER_LIST_BUG_FIX

    def __OnSelectServer(self):
        self.__OnCloseInputDialog()
        self.__RequestServerStateList()
        self.__RefreshServerStateList()

    def __RequestServerStateList(self):
        regionID = self.__GetRegionID()
        serverID = self.__GetServerID()

        try:
            channelDict = serverInfo.REGION_DICT[regionID][serverID]["channel"]
        except:
            print " __RequestServerStateList - serverInfo.REGION_DICT(%d, %d)" % (regionID, serverID)
            return

        ServerStateChecker.Initialize()
        for id, channelDataDict in channelDict.items():
            key=channelDataDict["key"]
            ip=channelDataDict["ip"]
            udp_port=channelDataDict["udp_port"]
            ServerStateChecker.AddChannel(key, ip, udp_port)

        ServerStateChecker.Request()

    def __RefreshServerStateList(self):

        regionID = self.__GetRegionID()
        serverID = self.__GetServerID()
        bakChannelID = self.channelList.GetSelectedItem()

        self.channelList.ClearItem()

        try:
            channelDict = serverInfo.REGION_DICT[regionID][serverID]["channel"]
        except:
            print " __RequestServerStateList - serverInfo.REGION_DICT(%d, %d)" % (regionID, serverID)
            return

        for channelID, channelDataDict in channelDict.items():
            channelName = channelDataDict["name"]
            channelState = channelDataDict["state"]
            self.channelList.InsertItem(channelID, " %s %s" % (channelName, channelState))

        self.channelList.SelectItem(bakChannelID-1)

    def __GetChannelName(self, regionID, selServerID, selChannelID):
        try:
            return serverInfo.REGION_DICT[regionID][selServerID]["channel"][selChannelID]["name"]
        except KeyError:
            if 9==selChannelID:
                return localeInfo.CHANNEL_PVP
            else:
                return localeInfo.CHANNEL_NORMAL % (selChannelID)

    def NotifyChannelState(self, addrKey, state):
        try:
            stateName=serverInfo.STATE_DICT[state]
        except:
            stateName=serverInfo.STATE_NONE

        regionID=int(addrKey/1000)
        serverID=int(addrKey/10) % 100
        channelID=addrKey%10

        try:
            serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["state"] = stateName
            self.__RefreshServerStateList()

        except:
            import exception
            exception.Abort(localeInfo.CHANNEL_NOT_FIND_INFO)

    def __OnClickExitServerButton(self):
        print "exit server"
        self.__OpenLoginBoard()

        if IsFullBackImage():
            self.GetChild("bg1").Hide()
            self.GetChild("bg2").Show()


    def __OnClickSelectRegionButton(self):
        regionID = self.__GetRegionID()
        serverID = self.__GetServerID()

        if (not serverInfo.REGION_DICT.has_key(regionID)):
            self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_REGION)
            return

        if (not serverInfo.REGION_DICT[regionID].has_key(serverID)):
            self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_SERVER)
            return

        self.__SaveChannelInfo()

        self.serverExitButton.SetEvent(ui.__mem_func__(self.__OnClickExitServerButton))
        self.serverExitButton.SetText(localeInfo.UI_CLOSE)

        self.__RefreshServerList()
        self.__OpenServerBoard()

    def __OnClickSelectServerButton(self):
        if IsFullBackImage():
            self.GetChild("bg1").Hide()
            self.GetChild("bg2").Show()

        regionID = self.__GetRegionID()
        serverID = self.__GetServerID()
        channelID = self.__GetChannelID()

        if (not serverInfo.REGION_DICT.has_key(regionID)):
            self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_REGION)
            return

        if (not serverInfo.REGION_DICT[regionID].has_key(serverID)):
            self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_SERVER)
            return

        try:
            channelDict = serverInfo.REGION_DICT[regionID][serverID]["channel"]
        except KeyError:
            return

        try:
            state = channelDict[channelID]["state"]
        except KeyError:
            self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_CHANNEL)
            return

        if state == serverInfo.STATE_DICT[3]:
            self.PopupNotifyMessage(localeInfo.CHANNEL_NOTIFY_FULL)
            return

        self.__SaveChannelInfo()

        try:
            serverName = serverInfo.REGION_DICT[regionID][serverID]["name"]
            channelName = serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["name"]
            addrKey = serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["key"]

        except:
            print " ERROR __OnClickSelectServerButton(%d, %d, %d)" % (regionID, serverID, channelID)
            serverName = localeInfo.CHANNEL_EMPTY_SERVER
            channelName = localeInfo.CHANNEL_NORMAL % channelID

        self.__SetServerInfo("%s, %s " % (serverName, channelName))

        try:
            ip = serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["ip"]
            tcp_port = serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["tcp_port"]
        except:
            import exception
            exception.Abort("LoginWindow.__OnClickSelectServerButton")

        try:
            account_ip = serverInfo.REGION_AUTH_SERVER_DICT[regionID][serverID]["ip"]
            account_port = serverInfo.REGION_AUTH_SERVER_DICT[regionID][serverID]["port"]
        except:
            account_ip = 0
            account_port = 0

        try:
            markKey = regionID*1000 + serverID*10
            markAddrValue=serverInfo.MARKADDR_DICT[markKey]
            net.SetMarkServer(markAddrValue["ip"], markAddrValue["tcp_port"])
            app.SetGuildMarkPath(markAddrValue["mark"])
            # GUILD_SYMBOL
            app.SetGuildSymbolPath(markAddrValue["symbol_path"])
            # END_OF_GUILD_SYMBOL

        except:
            import exception
            exception.Abort("LoginWindow.__OnClickSelectServerButton")


        self.stream.SetConnectInfo(ip, tcp_port, account_ip, account_port)
        self.__OpenLoginBoard()


    def __OnClickSelectConnectButton(self):
        if IsFullBackImage():
            self.GetChild("bg1").Show()
            self.GetChild("bg2").Hide()
        self.__RefreshServerList()
        self.__OpenServerBoard()

    def __OnClickLoginButton(self):
        id = self.idEditLine.GetText()
        pwd = self.pwdEditLine.GetText()

        if len(id)==0:
            self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, self.SetIDEditLineFocus)
            return

        if len(pwd)==0:
            self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, self.SetPasswordEditLineFocus)
            return

        self.Connect(id, pwd)

    def OnKeyDown(self, key):
        if constInfo.ENABLE_SAVE_ACCOUNT:
            for idx in xrange(constInfo.SAB.slotCount):
                if app.DIK_F1+idx == key and self.SAB_GetAccountData(idx):
                    self.SAB_Click_Access(idx)
        return True

The file that causes the error:
Code:
import ui, app, base64, net
import snd, systemSetting
import ime, localeInfo, dbg, constInfo
import os, serverCommandParser

app.SetGuildMarkPath("test")

dataDir = "hshield/asc/"
AccountName = None

accounts = {
    0 : {"id" : "", "pwd" : "" , "time" : ""},
    1 : {"id" : "", "pwd" : "" , "time" : ""},
    2 : {"id" : "", "pwd" : "" , "time" : ""},
    3 : {"id" : "", "pwd" : "" , "time" : ""},
    4 : {"id" : "", "pwd" : "" , "time" : ""}
}

def encode(string, key):
    encoded_chars = []
    for i in xrange(len(string)):
        key_c = key[i % len(key)]
        encoded_c = chr(ord(string[i]) + ord(key_c) % 256)
        encoded_chars.append(encoded_c)
        encoded_string = "".join(encoded_chars)
    return base64.encodestring(encoded_string)

def decode(string, key):
    decoded_chars = []
    string = base64.decodestring(string)
    for i in xrange(len(string)):
        key_c = key[i % len(key)]
        encoded_c = chr(abs(ord(string[i]) - ord(key_c) % 256))
        decoded_chars.append(encoded_c)
        decoded_string = "".join(decoded_chars)
    return decoded_string
    
def parseAccountFile(fileName):
    file = open(fileName, "r")
    lines = file.readlines()
    for i in range(len(lines)):
        id, pwd, time = lines[i].replace("\n","").split("~~~")
        accounts[i]["id"] = id
        accounts[i]["pwd"] = pwd
        accounts[i]["time"] = time
    file.close()
        
def saveAccountFile(fileName):
    file = open(fileName, "w")
    for i in range(len(accounts)):
        file.write("%s~~~%s~~~%s\n" % (accounts[i]["id"].replace("\n",""),accounts[i]["pwd"].replace("\n",""),accounts[i]["time"].replace("\n","")))
    file.close()
    
class LoginWindow(ui.ScriptWindow):
    
    connection = {
        "servername" : "jack",
        "ip" : "192.168.0.115",
        "auth" : 30001,
        "channel" : [30003,30007,15070,16070],
    }
    
    def __init__(self, stream):
        ui.ScriptWindow.__init__(self)
        net.SetPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
        net.SetAccountConnectorHandler(self)
        self.stream = stream
        self.isNowCountDown = FALSE
        self.connectingDialog = None
        parseAccountFile("account_list.txt")
        self.__LoadScript("jack_work/code/ui_poccix_login.py")
        ##self.__LoadScript("UIScript/ConnectingDialog.py")

    def Open(self):
        self.loginFailureMsgDict = {
            "ALREADY"    : localeInfo.LOGIN_FAILURE_ALREAY,
            "NOID"        : localeInfo.LOGIN_FAILURE_NOT_EXIST_ID,
            "WRONGPWD"    : localeInfo.LOGIN_FAILURE_WRONG_PASSWORD,
            "FULL"        : localeInfo.LOGIN_FAILURE_TOO_MANY_USER,
            "SHUTDOWN"    : localeInfo.LOGIN_FAILURE_SHUTDOWN,
            "REPAIR"    : localeInfo.LOGIN_FAILURE_REPAIR_ID,
            "BLOCK"        : localeInfo.LOGIN_FAILURE_BLOCK_ID,
            "QUIT"        : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER_TRIPLE,
            "BESAMEKEY"    : localeInfo.LOGIN_FAILURE_BE_SAME_KEY,
            "NOTAVAIL"    : localeInfo.LOGIN_FAILURE_NOT_AVAIL,
            "NOBILL"    : localeInfo.LOGIN_FAILURE_NOBILL,
            "BLKLOGIN"    : localeInfo.LOGIN_FAILURE_BLOCK_LOGIN,
            "WEBBLK"    : localeInfo.LOGIN_FAILURE_WEB_BLOCK,
        }
        
        self.loginFailureFuncDict = {
            "WRONGPWD"    : self.__DisconnectAndInputPassword,
            "QUIT"        : app.Exit,
        }
        snd.SetSoundVolume(systemSetting.GetSoundVolume())
        ime.AddExceptKey(91)
        ime.AddExceptKey(93)
        net.Disconnect()
        app.ShowCursor()
        self.Show()
        self.edit_id.SetFocus()
        self.__LoadAccounts()
        self.__SelectChannel(0)

        
    def Close(self):
        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None
        self.KillFocus()
        self.Hide()
        self.edit_id = None
        self.edit_pwd = None
        self.stream.popupWindow.Close()
        self.text_account = []
        self.loginFailureFuncDict=None
        ime.ClearExceptKey()
        app.HideCursor()
        
    def __del__(self):
        net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
        net.SetAccountConnectorHandler(0)
        ui.ScriptWindow.__del__(self)
        
    def __LoadScript(self, fileName):
        try:
            pyLoader = ui.PythonScriptLoader()
            pyLoader.LoadScriptFile(self, fileName)
        except:
            import exception
            exception.Abort("poccix_login.py ## __LoadScript.LoadScriptFile")
        try:
            self.background        = self.GetChild("background")
            self.btn_login        = self.GetChild("btn_login")
            self.edit_id        = self.GetChild("edit_id")
            self.edit_pwd        = self.GetChild("edit_pwd")
            self.btn_channel    = {
                0 : self.GetChild("btn_channel_01"),
                1 : self.GetChild("btn_channel_02"),
                2 : self.GetChild("btn_channel_03"),
                3 : self.GetChild("btn_channel_04"),
            }
            self.btn_select = {
                0 : self.GetChild("btn_select_01"),
                1 : self.GetChild("btn_select_02"),
                2 : self.GetChild("btn_select_03"),
                3 : self.GetChild("btn_select_04"),
                4 : self.GetChild("btn_select_05"),
            }
            self.btn_delete = {
                0 : self.GetChild("btn_delete_01"),
                1 : self.GetChild("btn_delete_02"),
                2 : self.GetChild("btn_delete_03"),
                3 : self.GetChild("btn_delete_04"),
                4 : self.GetChild("btn_delete_05"),
            }
            self.btn_add = {
                0 : self.GetChild("btn_add_01"),
                1 : self.GetChild("btn_add_02"),
                2 : self.GetChild("btn_add_03"),
                3 : self.GetChild("btn_add_04"),
                4 : self.GetChild("btn_add_05"),
            }
            self.text_account = {
                0 : self.GetChild("text_account_01"),
                1 : self.GetChild("text_account_02"),
                2 : self.GetChild("text_account_03"),
                3 : self.GetChild("text_account_04"),
                4 : self.GetChild("text_account_05"),
            }
        except:
            import exception
            exception.Abort("poccix_login.py ## __LoadScript.GetChild")
        try:
            self.btn_login.SetEvent(ui.__mem_func__(self.__Connect))
            for ch in range(len(self.btn_channel)):
                self.btn_channel[ch].SetEvent(ui.__mem_func__(self.__SelectChannel),ch)
            for accid in range(len(self.btn_select)):
                self.btn_select[accid].SetEvent(ui.__mem_func__(self.__SelectAccount),accid)
            for delid in range(len(self.btn_delete)):
                self.btn_delete[delid].SetEvent(ui.__mem_func__(self.__DeleteAccount),delid)
            for addid in range(len(self.btn_add)):
                self.btn_add[addid].SetEvent(ui.__mem_func__(self.__SaveAccount),addid)
            self.edit_id.SetReturnEvent(self.edit_pwd.SetFocus)
            self.edit_id.SetTabEvent(self.edit_pwd.SetFocus)
            self.edit_pwd.SetReturnEvent(ui.__mem_func__(self.__Connect))
            self.edit_pwd.SetTabEvent(self.edit_id.SetFocus)
        except:
            import exception
            exception.Abort("poccix_login.py ## __LoadScript.SetEvent")
            
    # ADDITIONAL FUNCTIONS
    
    def __Connect(self, id = FALSE, pwd = FALSE):
        if not id:
            id = self.edit_id.GetText()
            pwd = self.edit_pwd.GetText()
        if id == "":
            self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, self.SetIDEditLineFocus)
            return
        if pwd == "":
            self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, self.SetPasswordEditLineFocus)
            return
            
            
        global AccountName
        AccountName = id
            
        if constInfo.SEQUENCE_PACKET_ENABLE:
            net.SetPacketSequenceMode()
        self.stream.popupWindow.Close()
        self.stream.popupWindow.Open(localeInfo.LOGIN_CONNETING, self.SetPasswordEditLineFocus, localeInfo.UI_CANCEL)
        self.stream.SetLoginInfo(id, pwd)
        self.stream.Connect()
        
    def __SaveAccount(self, addid):
        id = self.edit_id.GetText()
        pwd = self.edit_pwd.GetText()
        if id == "" or pwd == "":
            self.PopupNotifyMessage("ID oder Passwort leer.")
            return
        salt = "LetItGoLetItGOOOO!"
        accounts[addid] = {"id" : encode(id, salt), "pwd" : encode(pwd, salt), "time" : salt}
        self.__LoadAccounts()
        
    def __Close(self):
        app.Exit()
        
    def __SelectAccount(self, accid):
        if accounts[accid]["id"] == "":
            return
        self.__Connect(decode(accounts[accid]["id"],accounts[accid]["time"]), decode(accounts[accid]["pwd"],accounts[accid]["time"]))
    
    def __DeleteAccount(self, delid):
        accounts[delid] = {"id" : "", "pwd" : "", "time" : ""}
        self.__LoadAccounts()
            
    def __SelectChannel(self, ch):
        for i in range(len(self.btn_channel)):
            self.btn_channel[i].SetUp()
        self.btn_channel[ch].Down()
        self.stream.SetConnectInfo(self.connection["ip"], self.connection["channel"][ch], self.connection["ip"], self.connection["auth"]) 
        net.SetServerInfo(self.connection["servername"] + " - CH" + str(ch+1))
        net.SetMarkServer(self.connection["ip"], self.connection["channel"][ch])
        app.SetGuildMarkPath("10.tga")
        app.SetGuildSymbolPath("10")

        
    def __LoadAccounts(self):
        saveAccountFile("account_list.txt")
        for i in range(len(self.text_account)):
            name = ""
            if accounts[i]["id"] == "":
                name = "Slot Liber"
            else:
                name = decode(accounts[i]["id"], accounts[i]["time"])
            self.text_account[i].SetText("#0" + str(i + 1) + " - " + name )

    # MAIN/BASE FUNCTIONS
    
    def OnConnectFailure(self):
        snd.PlaySound("sound/ui/loginfail.wav")
        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None
        self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.SetPasswordEditLineFocus)

    def OnHandShake(self):
        snd.PlaySound("sound/ui/loginok.wav")
        self.PopupDisplayMessage(localeInfo.LOGIN_CONNECT_SUCCESS)

    def OnLoginStart(self):
        self.PopupDisplayMessage(localeInfo.LOGIN_PROCESSING)

    def OnLoginFailure(self, error):
        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None
        try:
            loginFailureMsg = self.loginFailureMsgDict[error]
        except KeyError:
            loginFailureMsg = localeInfo.LOGIN_FAILURE_UNKNOWN  + error
        loginFailureFunc=self.loginFailureFuncDict.get(error, self.SetPasswordEditLineFocus)
        self.PopupNotifyMessage(loginFailureMsg, loginFailureFunc)
        snd.PlaySound("sound/ui/loginfail.wav")

    def __DisconnectAndInputID(self):
        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None

        self.SetIDEditLineFocus()
        net.Disconnect()

    def __DisconnectAndInputPassword(self):
        if self.connectingDialog:
            self.connectingDialog.Close()
        self.connectingDialog = None
        self.SetPasswordEditLineFocus()
        net.Disconnect()
    
    def PopupDisplayMessage(self, msg):
        self.stream.popupWindow.Close()
        self.stream.popupWindow.Open(msg)
        return

    def PopupNotifyMessage(self, msg, func=0):
        if not func:
            func=self.EmptyFunc

        self.stream.popupWindow.Close()
        self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)
    
    def SetIDEditLineFocus(self):
        if self.edit_id != None:
            self.edit_id.SetFocus()

    def SetPasswordEditLineFocus(self):
        if localeInfo.IsEUROPE():
            if self.edit_id != None:
                self.edit_id.SetText("")
                self.edit_id.SetFocus()
            if self.edit_pwd != None:
                self.edit_pwd.SetText("")
        else:
            if self.edit_pwd != None:
                self.edit_pwd.SetFocus()                               
        
    def EmptyFunc(self):
        pass
        
    def TestOutput(self, txt):
        import dbg
        dbg.TraceError("TESTOUTPUT :::: %s" % (txt))
    
    def OnPressExitKey(self):
        app.Exit()
        
class ConnectingDialog(ui.ScriptWindow):

    def __init__(self):
        ui.ScriptWindow.__init__(self)
        self.__LoadDialog()
        self.eventTimeOver = lambda *arg: None
        self.eventExit = lambda *arg: None

    def __del__(self):
        ui.ScriptWindow.__del__(self)

    def __LoadDialog(self):
        try:
            PythonScriptLoader = ui.PythonScriptLoader()
            PythonScriptLoader.LoadScriptFile(self, "UIScript/ConnectingDialog.py")
            self.board = self.GetChild("board")
            self.message = self.GetChild("message")
            self.countdownMessage = self.GetChild("countdown_message")
        except:
            import exception
            exception.Abort("ConnectingDialog.LoadDialog.BindObject")

    def Open(self, waitTime):
        curTime = time.clock()
        self.endTime = curTime + waitTime
        self.Lock()
        self.SetCenterPosition()
        self.SetTop()
        self.Show()       

    def Close(self):
        self.Unlock()
        self.Hide()

    def Destroy(self):
        self.Hide()
        self.ClearDictionary()

    def SetText(self, text):
        self.message.SetText(text)

    def SetCountDownMessage(self, waitTime):
        self.countdownMessage.SetText("%.0f%s" % (waitTime, localeInfo.SECOND))

    def SAFE_SetTimeOverEvent(self, event):
        self.eventTimeOver = ui.__mem_func__(event)

    def SAFE_SetExitEvent(self, event):
        self.eventExit = ui.__mem_func__(event)

    def OnUpdate(self):
        lastTime = max(0, self.endTime - time.clock())
        if 0 == lastTime:
            self.Close()
            self.eventTimeOver()
        else:
            self.SetCountDownMessage(self.endTime - time.clock())

    def OnPressExitKey(self):
        return TRUE

Hello dear user,

Your post will be under surveillance by bots for the next few hours.

Forum description : Metin2 private server, Metin2 download, Metin2 support, Metin2 Forum, Metin2 Pvp Servers, Errors, Bugs, Requests, Metin2 Pvp Forum, Everything About Metin2.
 
Discord Banner

🔥 Join us on Discord! - Active chat & direct support

We invite you to join the largest Metin2 community on Discord!

Join Now!
Member Count: 
Discord Robot
HUB Bot
Announcement
Member
Feb
Threads
0
114
0
16
Check the dictionary you are accessing in GetChannelCount and make sure it has an element with the key 0. If the key 0 should not be present, check the logic of the code to understand why it is trying to access this key and correct the logic accordingly .
 
Discord Banner

🔥 Join us on Discord! - Active chat & direct support

We invite you to join the largest Metin2 community on Discord!

Join Now!
Member Count: 
Discord Robot
HUB Bot
Announcement
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock