Advertisement
Guest User

intrologin with channel switcher

a guest
Feb 20th, 2022
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 40.35 KB | None | 0 0
  1. import dbg
  2. import app
  3. import net
  4. import ui
  5. import ime
  6. import snd
  7. import wndMgr
  8. import musicInfo
  9. import serverInfo
  10. import systemSetting
  11. import ServerStateChecker
  12. import localeInfo
  13. import constInfo
  14. import uiCommon
  15. import time
  16. import serverCommandParser
  17. import ime
  18. import uiScriptLocale
  19.  
  20. RUNUP_MATRIX_AUTH = False
  21. NEWCIBN_PASSPOD_AUTH = False
  22.  
  23. LOGIN_DELAY_SEC = 0.0
  24. SKIP_LOGIN_PHASE = False
  25. SKIP_LOGIN_PHASE_SUPPORT_CHANNEL = False
  26. FULL_BACK_IMAGE = False
  27.  
  28. PASSPOD_MSG_DICT = {}
  29.  
  30. VIRTUAL_KEYBOARD_NUM_KEYS = 46
  31. VIRTUAL_KEYBOARD_RAND_KEY = True
  32.  
  33. def Suffle(src):
  34. if VIRTUAL_KEYBOARD_RAND_KEY:
  35. items = [item for item in src]
  36.  
  37. itemCount = len(items)
  38. for oldPos in xrange(itemCount):
  39. newPos = app.GetRandom(0, itemCount-1)
  40. items[newPos], items[oldPos] = items[oldPos], items[newPos]
  41.  
  42. return "".join(items)
  43. else:
  44. return src
  45.  
  46. if localeInfo.IsNEWCIBN() or localeInfo.IsCIBN10():
  47. LOGIN_DELAY_SEC = 20.0
  48. FULL_BACK_IMAGE = True
  49. NEWCIBN_PASSPOD_AUTH = True
  50. PASSPOD_MSG_DICT = {
  51. "PASERR1" : localeInfo.LOGIN_FAILURE_PASERR1,
  52. "PASERR2" : localeInfo.LOGIN_FAILURE_PASERR2,
  53. "PASERR3" : localeInfo.LOGIN_FAILURE_PASERR3,
  54. "PASERR4" : localeInfo.LOGIN_FAILURE_PASERR4,
  55. "PASERR5" : localeInfo.LOGIN_FAILURE_PASERR5,
  56. }
  57.  
  58. elif localeInfo.IsYMIR() or localeInfo.IsCHEONMA():
  59. FULL_BACK_IMAGE = True
  60.  
  61. elif localeInfo.IsHONGKONG():
  62. FULL_BACK_IMAGE = True
  63. RUNUP_MATRIX_AUTH = True
  64. PASSPOD_MSG_DICT = {
  65. "NOTELE" : localeInfo.LOGIN_FAILURE_NOTELEBLOCK,
  66. }
  67.  
  68. elif localeInfo.IsJAPAN():
  69. FULL_BACK_IMAGE = True
  70.  
  71. elif localeInfo.IsBRAZIL():
  72. LOGIN_DELAY_SEC = 60.0
  73.  
  74. def IsFullBackImage():
  75. global FULL_BACK_IMAGE
  76. return FULL_BACK_IMAGE
  77.  
  78. def IsLoginDelay():
  79. global LOGIN_DELAY_SEC
  80. if LOGIN_DELAY_SEC > 0.0:
  81. return True
  82. else:
  83. return False
  84.  
  85. def IsRunupMatrixAuth():
  86. global RUNUP_MATRIX_AUTH
  87. return RUNUP_MATRIX_AUTH
  88.  
  89. def IsNEWCIBNPassPodAuth():
  90. global NEWCIBN_PASSPOD_AUTH
  91. return NEWCIBN_PASSPOD_AUTH
  92.  
  93. def GetLoginDelay():
  94. global LOGIN_DELAY_SEC
  95. return LOGIN_DELAY_SEC
  96.  
  97. app.SetGuildMarkPath("test")
  98.  
  99. class ConnectingDialog(ui.ScriptWindow):
  100.  
  101. def __LoadChannelInfo(self):
  102. try:
  103. file=old_open("channel.inf")
  104. lines=file.readlines()
  105.  
  106. if len(lines)>0:
  107. tokens=lines[0].split()
  108.  
  109. selServerID=int(tokens[0])
  110. if app.ENABLE_CHANNEL_SWITCHER:
  111. if(int(tokens[1]) <= constInfo.CHANNELS):
  112. selChannelID=int(tokens[1])
  113. else:
  114. selChannelID=1
  115. else:
  116. selChannelID=int(tokens[1])
  117.  
  118. if len(tokens) == 3:
  119. regionID = int(tokens[2])
  120.  
  121. return regionID, selServerID, selChannelID
  122.  
  123. except:
  124. print "LoginWindow.__LoadChannelInfo - OpenError"
  125. return -1, -1, -1
  126.  
  127. def __init__(self):
  128. ui.ScriptWindow.__init__(self)
  129. self.__LoadDialog()
  130. self.eventTimeOver = lambda *arg: None
  131. self.eventExit = lambda *arg: None
  132.  
  133. def __del__(self):
  134. ui.ScriptWindow.__del__(self)
  135.  
  136. def __LoadDialog(self):
  137. try:
  138. PythonScriptLoader = ui.PythonScriptLoader()
  139. PythonScriptLoader.LoadScriptFile(self, "UIScript/ConnectingDialog.py")
  140.  
  141. self.board = self.GetChild("board")
  142. self.message = self.GetChild("message")
  143. self.countdownMessage = self.GetChild("countdown_message")
  144.  
  145. except:
  146. import exception
  147. exception.Abort("ConnectingDialog.LoadDialog.BindObject")
  148.  
  149. def Open(self, waitTime):
  150. curTime = time.clock()
  151. self.endTime = curTime + waitTime
  152.  
  153. self.Lock()
  154. self.SetCenterPosition()
  155. self.SetTop()
  156. self.Show()
  157.  
  158. def Close(self):
  159. self.Unlock()
  160. self.Hide()
  161.  
  162. def Destroy(self):
  163. self.Hide()
  164. self.ClearDictionary()
  165.  
  166. def SetText(self, text):
  167. self.message.SetText(text)
  168.  
  169. def SetCountDownMessage(self, waitTime):
  170. self.countdownMessage.SetText("%.0f%s" % (waitTime, localeInfo.SECOND))
  171.  
  172. def SAFE_SetTimeOverEvent(self, event):
  173. self.eventTimeOver = ui.__mem_func__(event)
  174.  
  175. def SAFE_SetExitEvent(self, event):
  176. self.eventExit = ui.__mem_func__(event)
  177.  
  178. def OnUpdate(self):
  179. lastTime = max(0, self.endTime - time.clock())
  180. if 0 == lastTime:
  181. self.Close()
  182. self.eventTimeOver()
  183. else:
  184. self.SetCountDownMessage(self.endTime - time.clock())
  185.  
  186. def OnPressExitKey(self):
  187. #self.eventExit()
  188. return True
  189.  
  190. class LoginWindow(ui.ScriptWindow):
  191.  
  192. IS_TEST = net.IsTest()
  193.  
  194. def __init__(self, stream):
  195. print "NEW LOGIN WINDOW ----------------------------------------------------------------------------"
  196. ui.ScriptWindow.__init__(self)
  197. net.SetPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
  198. net.SetAccountConnectorHandler(self)
  199.  
  200. self.matrixInputChanceCount = 0
  201. self.lastLoginTime = 0
  202. self.inputDialog = None
  203. self.connectingDialog = None
  204. self.stream=stream
  205. self.isNowCountDown=False
  206. self.isStartError=False
  207.  
  208. self.xServerBoard = 0
  209. self.yServerBoard = 0
  210.  
  211. self.loadingImage = None
  212.  
  213. self.virtualKeyboard = None
  214. self.virtualKeyboardMode = "ALPHABET"
  215. self.virtualKeyboardIsUpper = False
  216.  
  217. # @fixme001 BEGIN (timeOutMsg and timeOutOk undefined)
  218. self.timeOutMsg = False
  219. self.timeOutOk = False
  220. # @fixme001 END
  221.  
  222. def __del__(self):
  223. net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
  224. net.SetAccountConnectorHandler(0)
  225. ui.ScriptWindow.__del__(self)
  226. print "---------------------------------------------------------------------------- DELETE LOGIN WINDOW"
  227.  
  228. def Open(self):
  229. ServerStateChecker.Create(self)
  230.  
  231. print "LOGIN WINDOW OPEN ----------------------------------------------------------------------------"
  232.  
  233. self.loginFailureMsgDict={
  234. #"DEFAULT" : localeInfo.LOGIN_FAILURE_UNKNOWN,
  235.  
  236. "ALREADY" : localeInfo.LOGIN_FAILURE_ALREAY,
  237. "NOID" : localeInfo.LOGIN_FAILURE_NOT_EXIST_ID,
  238. "WRONGPWD" : localeInfo.LOGIN_FAILURE_WRONG_PASSWORD,
  239. "FULL" : localeInfo.LOGIN_FAILURE_TOO_MANY_USER,
  240. "SHUTDOWN" : localeInfo.LOGIN_FAILURE_SHUTDOWN,
  241. "REPAIR" : localeInfo.LOGIN_FAILURE_REPAIR_ID,
  242. "BLOCK" : localeInfo.LOGIN_FAILURE_BLOCK_ID,
  243. "WRONGMAT" : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER,
  244. "QUIT" : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER_TRIPLE,
  245. "BESAMEKEY" : localeInfo.LOGIN_FAILURE_BE_SAME_KEY,
  246. "NOTAVAIL" : localeInfo.LOGIN_FAILURE_NOT_AVAIL,
  247. "NOBILL" : localeInfo.LOGIN_FAILURE_NOBILL,
  248. "BLKLOGIN" : localeInfo.LOGIN_FAILURE_BLOCK_LOGIN,
  249. "WEBBLK" : localeInfo.LOGIN_FAILURE_WEB_BLOCK,
  250. "BADSCLID" : localeInfo.LOGIN_FAILURE_WRONG_SOCIALID,
  251. "AGELIMIT" : localeInfo.LOGIN_FAILURE_SHUTDOWN_TIME,
  252. }
  253.  
  254. self.loginFailureFuncDict = {
  255. "WRONGPWD" : self.__DisconnectAndInputPassword,
  256. "WRONGMAT" : self.__DisconnectAndInputMatrix,
  257. "QUIT" : app.Exit,
  258. }
  259.  
  260. self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())
  261. self.SetWindowName("LoginWindow")
  262.  
  263. if not self.__LoadScript(uiScriptLocale.LOCALE_UISCRIPT_PATH + "LoginWindow.py"):
  264. dbg.TraceError("LoginWindow.Open - __LoadScript Error")
  265. return
  266.  
  267. self.__LoadLoginInfo("loginInfo.xml")
  268.  
  269. if app.loggined:
  270. self.loginFailureFuncDict = {
  271. "WRONGPWD" : app.Exit,
  272. "WRONGMAT" : app.Exit,
  273. "QUIT" : app.Exit,
  274. }
  275.  
  276. if musicInfo.loginMusic != "":
  277. snd.SetMusicVolume(systemSetting.GetMusicVolume())
  278. snd.FadeInMusic("BGM/"+musicInfo.loginMusic)
  279.  
  280. snd.SetSoundVolume(systemSetting.GetSoundVolume())
  281.  
  282. # pevent key "[" "]"
  283. ime.AddExceptKey(91)
  284. ime.AddExceptKey(93)
  285.  
  286. self.Show()
  287.  
  288. global SKIP_LOGIN_PHASE
  289. if SKIP_LOGIN_PHASE:
  290. if self.isStartError:
  291. self.connectBoard.Hide()
  292. self.loginBoard.Hide()
  293. self.serverBoard.Hide()
  294. self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.__ExitGame)
  295. return
  296.  
  297. if self.loginInfo:
  298. self.serverBoard.Hide()
  299. else:
  300. self.__RefreshServerList()
  301. self.__OpenServerBoard()
  302. else:
  303. connectingIP = self.stream.GetConnectAddr()
  304. if connectingIP:
  305. if app.USE_OPENID and not app.OPENID_TEST :
  306. self.__RefreshServerList()
  307. self.__OpenServerBoard()
  308. else:
  309. self.__OpenLoginBoard()
  310. if IsFullBackImage():
  311. self.GetChild("bg1").Hide()
  312. self.GetChild("bg2").Show()
  313.  
  314. else:
  315. self.__RefreshServerList()
  316. self.__OpenServerBoard()
  317.  
  318. app.ShowCursor()
  319.  
  320. def Close(self):
  321.  
  322. if self.connectingDialog:
  323. self.connectingDialog.Close()
  324. self.connectingDialog = None
  325.  
  326. ServerStateChecker.Initialize(self)
  327.  
  328. print "---------------------------------------------------------------------------- CLOSE LOGIN WINDOW "
  329. #
  330. # selectMusic이 없으면 BGM이 끊기므로 두개 다 체크한다.
  331. #
  332. if musicInfo.loginMusic != "" and musicInfo.selectMusic != "":
  333. snd.FadeOutMusic("BGM/"+musicInfo.loginMusic)
  334.  
  335. ## NOTE : idEditLine와 pwdEditLine은 이벤트가 서로 연결 되어있어서
  336. ## Event를 강제로 초기화 해주어야만 합니다 - [levites]
  337. self.idEditLine.SetTabEvent(0)
  338. self.idEditLine.SetReturnEvent(0)
  339. self.pwdEditLine.SetReturnEvent(0)
  340. self.pwdEditLine.SetTabEvent(0)
  341.  
  342. self.connectBoard = None
  343. self.loginBoard = None
  344. self.idEditLine = None
  345. self.pwdEditLine = None
  346. self.inputDialog = None
  347. self.connectingDialog = None
  348. self.loadingImage = None
  349.  
  350. self.serverBoard = None
  351. self.serverList = None
  352. self.channelList = None
  353.  
  354. # RUNUP_MATRIX_AUTH
  355. self.matrixQuizBoard = None
  356. self.matrixAnswerInput = None
  357. self.matrixAnswerOK = None
  358. self.matrixAnswerCancel = None
  359. # RUNUP_MATRIX_AUTH_END
  360.  
  361. # NEWCIBN_PASSPOD_AUTH
  362. self.passpodBoard = None
  363. self.passpodAnswerInput = None
  364. self.passpodAnswerOK = None
  365. self.passpodAnswerCancel = None
  366. # NEWCIBN_PASSPOD_AUTH_END
  367.  
  368. self.VIRTUAL_KEY_ALPHABET_LOWERS = None
  369. self.VIRTUAL_KEY_ALPHABET_UPPERS = None
  370. self.VIRTUAL_KEY_SYMBOLS = None
  371. self.VIRTUAL_KEY_NUMBERS = None
  372.  
  373. # VIRTUAL_KEYBOARD_BUG_FIX
  374. if self.virtualKeyboard:
  375. for keyIndex in xrange(0, VIRTUAL_KEYBOARD_NUM_KEYS+1):
  376. key = self.GetChild2("key_%d" % keyIndex)
  377. if key:
  378. key.SetEvent(None)
  379.  
  380. self.GetChild("key_space").SetEvent(None)
  381. self.GetChild("key_backspace").SetEvent(None)
  382. self.GetChild("key_enter").SetEvent(None)
  383. self.GetChild("key_shift").SetToggleDownEvent(None)
  384. self.GetChild("key_shift").SetToggleUpEvent(None)
  385. self.GetChild("key_at").SetToggleDownEvent(None)
  386. self.GetChild("key_at").SetToggleUpEvent(None)
  387.  
  388. self.virtualKeyboard = None
  389.  
  390. self.KillFocus()
  391. self.Hide()
  392.  
  393. self.stream.popupWindow.Close()
  394. self.loginFailureFuncDict=None
  395.  
  396. ime.ClearExceptKey()
  397.  
  398. app.HideCursor()
  399.  
  400. def __SaveChannelInfo(self):
  401. try:
  402. file=old_open("channel.inf", "w")
  403. file.write("%d %d %d" % (self.__GetServerID(), self.__GetChannelID(), self.__GetRegionID()))
  404. except:
  405. print "LoginWindow.__SaveChannelInfo - SaveError"
  406.  
  407. def __LoadChannelInfo(self):
  408. try:
  409. file=old_open("channel.inf")
  410. lines=file.readlines()
  411.  
  412. if len(lines)>0:
  413. tokens=lines[0].split()
  414.  
  415. selServerID=int(tokens[0])
  416. selChannelID=int(tokens[1])
  417.  
  418. if len(tokens) == 3:
  419. regionID = int(tokens[2])
  420.  
  421. return regionID, selServerID, selChannelID
  422.  
  423. except:
  424. print "LoginWindow.__LoadChannelInfo - OpenError"
  425. return -1, -1, -1
  426.  
  427. def __ExitGame(self):
  428. app.Exit()
  429.  
  430. def SetIDEditLineFocus(self):
  431. if self.idEditLine != None:
  432. self.idEditLine.SetFocus()
  433.  
  434. def SetPasswordEditLineFocus(self):
  435. if constInfo.ENABLE_CLEAN_DATA_IF_FAIL_LOGIN:
  436. if self.idEditLine != None: #0000862: [M2EU] 로그인창 팝업 에러: 종료시 먼저 None 설정됨
  437. self.idEditLine.SetText("")
  438. self.idEditLine.SetFocus() #0000685: [M2EU] 아이디/비밀번호 유추 가능 버그 수정: 무조건 아이디로 포커스가 가게 만든다
  439.  
  440. if self.pwdEditLine != None: #0000862: [M2EU] 로그인창 팝업 에러: 종료시 먼저 None 설정됨
  441. self.pwdEditLine.SetText("")
  442. else:
  443. if self.pwdEditLine != None:
  444. self.pwdEditLine.SetFocus()
  445.  
  446. def OnEndCountDown(self):
  447. self.isNowCountDown = False
  448. if localeInfo.IsBRAZIL():
  449. self.timeOutMsg = True
  450. else:
  451. self.timeOutMsg = False
  452. self.OnConnectFailure()
  453.  
  454. def OnConnectFailure(self):
  455.  
  456. if self.isNowCountDown:
  457. return
  458.  
  459. snd.PlaySound("sound/ui/loginfail.wav")
  460.  
  461. if self.connectingDialog:
  462. self.connectingDialog.Close()
  463. self.connectingDialog = None
  464.  
  465. if app.loggined:
  466. self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.__ExitGame)
  467. elif self.timeOutMsg:
  468. self.PopupNotifyMessage(localeInfo.LOGIN_FAILURE_TIMEOUT, self.SetPasswordEditLineFocus)
  469. else:
  470. self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.SetPasswordEditLineFocus)
  471.  
  472. def OnHandShake(self):
  473. if not IsLoginDelay():
  474. snd.PlaySound("sound/ui/loginok.wav")
  475. self.PopupDisplayMessage(localeInfo.LOGIN_CONNECT_SUCCESS)
  476.  
  477. def OnLoginStart(self):
  478. if not IsLoginDelay():
  479. self.PopupDisplayMessage(localeInfo.LOGIN_PROCESSING)
  480.  
  481. def OnLoginFailure(self, error):
  482. if self.connectingDialog:
  483. self.connectingDialog.Close()
  484. self.connectingDialog = None
  485.  
  486. try:
  487. loginFailureMsg = self.loginFailureMsgDict[error]
  488. except KeyError:
  489. if PASSPOD_MSG_DICT:
  490. try:
  491. loginFailureMsg = PASSPOD_MSG_DICT[error]
  492. except KeyError:
  493. loginFailureMsg = localeInfo.LOGIN_FAILURE_UNKNOWN + error
  494. else:
  495. loginFailureMsg = localeInfo.LOGIN_FAILURE_UNKNOWN + error
  496.  
  497.  
  498. #0000685: [M2EU] 아이디/비밀번호 유추 가능 버그 수정: 무조건 패스워드로 포커스가 가게 만든다
  499. loginFailureFunc=self.loginFailureFuncDict.get(error, self.SetPasswordEditLineFocus)
  500.  
  501. if app.loggined:
  502. self.PopupNotifyMessage(loginFailureMsg, self.__ExitGame)
  503. else:
  504. self.PopupNotifyMessage(loginFailureMsg, loginFailureFunc)
  505.  
  506. snd.PlaySound("sound/ui/loginfail.wav")
  507.  
  508. def __DisconnectAndInputID(self):
  509. if self.connectingDialog:
  510. self.connectingDialog.Close()
  511. self.connectingDialog = None
  512.  
  513. self.SetIDEditLineFocus()
  514. net.Disconnect()
  515.  
  516. def __DisconnectAndInputPassword(self):
  517. if self.connectingDialog:
  518. self.connectingDialog.Close()
  519. self.connectingDialog = None
  520.  
  521. self.SetPasswordEditLineFocus()
  522. net.Disconnect()
  523.  
  524. def __DisconnectAndInputMatrix(self):
  525. if self.connectingDialog:
  526. self.connectingDialog.Close()
  527. self.connectingDialog = None
  528.  
  529. self.stream.popupWindow.Close()
  530. self.matrixInputChanceCount -= 1
  531.  
  532. if self.matrixInputChanceCount <= 0:
  533. self.__OnCloseInputDialog()
  534.  
  535. elif self.inputDialog:
  536. self.inputDialog.Show()
  537.  
  538. def __LoadScript(self, fileName):
  539. import dbg
  540. try:
  541. pyScrLoader = ui.PythonScriptLoader()
  542. pyScrLoader.LoadScriptFile(self, fileName)
  543. except:
  544. import exception
  545. exception.Abort("LoginWindow.__LoadScript.LoadObject")
  546. try:
  547. GetObject=self.GetChild
  548. self.serverBoard = GetObject("ServerBoard")
  549. self.serverList = GetObject("ServerList")
  550. self.channelList = GetObject("ChannelList")
  551. self.serverSelectButton = GetObject("ServerSelectButton")
  552. self.serverExitButton = GetObject("ServerExitButton")
  553. self.connectBoard = GetObject("ConnectBoard")
  554. self.loginBoard = GetObject("LoginBoard")
  555. self.idEditLine = GetObject("ID_EditLine")
  556. self.pwdEditLine = GetObject("Password_EditLine")
  557. self.serverInfo = GetObject("ConnectName")
  558. self.selectConnectButton = GetObject("SelectConnectButton")
  559. self.loginButton = GetObject("LoginButton")
  560. self.loginExitButton = GetObject("LoginExitButton")
  561.  
  562. if localeInfo.IsVIETNAM():
  563. self.checkButton = GetObject("CheckButton")
  564. self.checkButton.Down()
  565.  
  566. # RUNUP_MATRIX_AUTH
  567. if IsRunupMatrixAuth():
  568. self.matrixQuizBoard = GetObject("RunupMatrixQuizBoard")
  569. self.matrixAnswerInput = GetObject("RunupMatrixAnswerInput")
  570. self.matrixAnswerOK = GetObject("RunupMatrixAnswerOK")
  571. self.matrixAnswerCancel = GetObject("RunupMatrixAnswerCancel")
  572. # RUNUP_MATRIX_AUTH_END
  573.  
  574. # NEWCIBN_PASSPOD_AUTH
  575. if IsNEWCIBNPassPodAuth():
  576. self.passpodBoard = GetObject("NEWCIBN_PASSPOD_BOARD")
  577. self.passpodAnswerInput = GetObject("NEWCIBN_PASSPOD_INPUT")
  578. self.passpodAnswerOK = GetObject("NEWCIBN_PASSPOD_OK")
  579. self.passpodAnswerCancel= GetObject("NEWCIBN_PASSPOD_CANCEL")
  580. # NEWCIBN_PASSPOD_AUTH_END
  581.  
  582. self.virtualKeyboard = self.GetChild2("VirtualKeyboard")
  583.  
  584. if self.virtualKeyboard:
  585. self.VIRTUAL_KEY_ALPHABET_UPPERS = Suffle(localeInfo.VIRTUAL_KEY_ALPHABET_UPPERS)
  586. 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])
  587. if localeInfo.IsBRAZIL():
  588. self.VIRTUAL_KEY_SYMBOLS_BR = Suffle(localeInfo.VIRTUAL_KEY_SYMBOLS_BR)
  589. else:
  590. self.VIRTUAL_KEY_SYMBOLS = Suffle(localeInfo.VIRTUAL_KEY_SYMBOLS)
  591. self.VIRTUAL_KEY_NUMBERS = Suffle(localeInfo.VIRTUAL_KEY_NUMBERS)
  592. self.__VirtualKeyboard_SetAlphabetMode()
  593.  
  594. self.GetChild("key_space").SetEvent(lambda : self.__VirtualKeyboard_PressKey(' '))
  595. self.GetChild("key_backspace").SetEvent(lambda : self.__VirtualKeyboard_PressBackspace())
  596. self.GetChild("key_enter").SetEvent(lambda : self.__VirtualKeyboard_PressReturn())
  597. self.GetChild("key_shift").SetToggleDownEvent(lambda : self.__VirtualKeyboard_SetUpperMode())
  598. self.GetChild("key_shift").SetToggleUpEvent(lambda : self.__VirtualKeyboard_SetLowerMode())
  599. self.GetChild("key_at").SetToggleDownEvent(lambda : self.__VirtualKeyboard_SetSymbolMode())
  600. self.GetChild("key_at").SetToggleUpEvent(lambda : self.__VirtualKeyboard_SetAlphabetMode())
  601.  
  602. except:
  603. import exception
  604. exception.Abort("LoginWindow.__LoadScript.BindObject")
  605.  
  606. if self.IS_TEST:
  607. self.selectConnectButton.Hide()
  608. else:
  609. self.selectConnectButton.SetEvent(ui.__mem_func__(self.__OnClickSelectConnectButton))
  610.  
  611. self.serverBoard.OnKeyUp = ui.__mem_func__(self.__ServerBoard_OnKeyUp)
  612. self.xServerBoard, self.yServerBoard = self.serverBoard.GetLocalPosition()
  613.  
  614. self.serverSelectButton.SetEvent(ui.__mem_func__(self.__OnClickSelectServerButton))
  615. self.serverExitButton.SetEvent(ui.__mem_func__(self.__OnClickExitButton))
  616.  
  617. self.loginButton.SetEvent(ui.__mem_func__(self.__OnClickLoginButton))
  618. self.loginExitButton.SetEvent(ui.__mem_func__(self.__OnClickExitButton))
  619.  
  620. self.serverList.SetEvent(ui.__mem_func__(self.__OnSelectServer))
  621.  
  622. self.idEditLine.SetReturnEvent(ui.__mem_func__(self.pwdEditLine.SetFocus))
  623. self.idEditLine.SetTabEvent(ui.__mem_func__(self.pwdEditLine.SetFocus))
  624.  
  625. self.pwdEditLine.SetReturnEvent(ui.__mem_func__(self.__OnClickLoginButton))
  626. self.pwdEditLine.SetTabEvent(ui.__mem_func__(self.idEditLine.SetFocus))
  627.  
  628. # RUNUP_MATRIX_AUTH
  629. if IsRunupMatrixAuth():
  630. self.matrixAnswerOK.SAFE_SetEvent(self.__OnClickMatrixAnswerOK)
  631. self.matrixAnswerCancel.SAFE_SetEvent(self.__OnClickMatrixAnswerCancel)
  632. self.matrixAnswerInput.SAFE_SetReturnEvent(self.__OnClickMatrixAnswerOK)
  633. # RUNUP_MATRIX_AUTH_END
  634.  
  635. # NEWCIBN_PASSPOD_AUTH
  636. if IsNEWCIBNPassPodAuth():
  637. self.passpodAnswerOK.SAFE_SetEvent(self.__OnClickNEWCIBNPasspodAnswerOK)
  638. self.passpodAnswerCancel.SAFE_SetEvent(self.__OnClickNEWCIBNPasspodAnswerCancel)
  639. self.passpodAnswerInput.SAFE_SetReturnEvent(self.__OnClickNEWCIBNPasspodAnswerOK)
  640.  
  641. # NEWCIBN_PASSPOD_AUTH_END
  642.  
  643.  
  644. if IsFullBackImage():
  645. self.GetChild("bg1").Show()
  646. self.GetChild("bg2").Hide()
  647. return 1
  648.  
  649. def __VirtualKeyboard_SetKeys(self, keyCodes):
  650. uiDefFontBackup = localeInfo.UI_DEF_FONT
  651. localeInfo.UI_DEF_FONT = localeInfo.UI_DEF_FONT_LARGE
  652.  
  653. keyIndex = 1
  654. for keyCode in keyCodes:
  655. key = self.GetChild2("key_%d" % keyIndex)
  656. if key:
  657. key.SetEvent(lambda x=keyCode: self.__VirtualKeyboard_PressKey(x))
  658. key.SetText(keyCode)
  659. key.ButtonText.SetFontColor(0, 0, 0)
  660. keyIndex += 1
  661.  
  662. for keyIndex in xrange(keyIndex, VIRTUAL_KEYBOARD_NUM_KEYS+1):
  663. key = self.GetChild2("key_%d" % keyIndex)
  664. if key:
  665. key.SetEvent(lambda x=' ': self.__VirtualKeyboard_PressKey(x))
  666. key.SetText(' ')
  667.  
  668. localeInfo.UI_DEF_FONT = uiDefFontBackup
  669.  
  670. def __VirtualKeyboard_PressKey(self, code):
  671. ime.PasteString(code)
  672.  
  673. #if self.virtualKeyboardMode == "ALPHABET" and self.virtualKeyboardIsUpper:
  674. # self.__VirtualKeyboard_SetLowerMode()
  675.  
  676. def __VirtualKeyboard_PressBackspace(self):
  677. ime.PasteBackspace()
  678.  
  679. def __VirtualKeyboard_PressReturn(self):
  680. ime.PasteReturn()
  681.  
  682. def __VirtualKeyboard_SetUpperMode(self):
  683. self.virtualKeyboardIsUpper = True
  684.  
  685. if self.virtualKeyboardMode == "ALPHABET":
  686. self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_ALPHABET_UPPERS)
  687. elif self.virtualKeyboardMode == "NUMBER":
  688. if localeInfo.IsBRAZIL():
  689. self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS_BR)
  690. else:
  691. self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS)
  692. else:
  693. self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_NUMBERS)
  694.  
  695. def __VirtualKeyboard_SetLowerMode(self):
  696. self.virtualKeyboardIsUpper = False
  697.  
  698. if self.virtualKeyboardMode == "ALPHABET":
  699. self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_ALPHABET_LOWERS)
  700. elif self.virtualKeyboardMode == "NUMBER":
  701. self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_NUMBERS)
  702. else:
  703. if localeInfo.IsBRAZIL():
  704. self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS_BR)
  705. else:
  706. self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS)
  707.  
  708. def __VirtualKeyboard_SetAlphabetMode(self):
  709. self.virtualKeyboardIsUpper = False
  710. self.virtualKeyboardMode = "ALPHABET"
  711. self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_ALPHABET_LOWERS)
  712.  
  713. def __VirtualKeyboard_SetNumberMode(self):
  714. self.virtualKeyboardIsUpper = False
  715. self.virtualKeyboardMode = "NUMBER"
  716. self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_NUMBERS)
  717.  
  718. def __VirtualKeyboard_SetSymbolMode(self):
  719. self.virtualKeyboardIsUpper = False
  720. self.virtualKeyboardMode = "SYMBOL"
  721. if localeInfo.IsBRAZIL():
  722. self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS_BR)
  723. else:
  724. self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS)
  725.  
  726. def Connect(self, id, pwd):
  727.  
  728. if constInfo.SEQUENCE_PACKET_ENABLE:
  729. net.SetPacketSequenceMode()
  730.  
  731. if IsLoginDelay():
  732. loginDelay = GetLoginDelay()
  733. self.connectingDialog = ConnectingDialog()
  734. self.connectingDialog.Open(loginDelay)
  735. self.connectingDialog.SAFE_SetTimeOverEvent(self.OnEndCountDown)
  736. self.connectingDialog.SAFE_SetExitEvent(self.OnPressExitKey)
  737. self.isNowCountDown = True
  738.  
  739. else:
  740. self.stream.popupWindow.Close()
  741. self.stream.popupWindow.Open(localeInfo.LOGIN_CONNETING, self.SetPasswordEditLineFocus, localeInfo.UI_CANCEL)
  742.  
  743. self.stream.SetLoginInfo(id, pwd)
  744. self.stream.Connect()
  745.  
  746. def __OnClickExitButton(self):
  747. self.stream.SetPhaseWindow(0)
  748.  
  749. def __SetServerInfo(self, name):
  750. net.SetServerInfo(name.strip())
  751. self.serverInfo.SetText(name)
  752.  
  753. def __LoadLoginInfo(self, loginInfoFileName):
  754. def getValue(element, name, default):
  755. if [] != element.getElementsByTagName(name):
  756. return element.getElementsByTagName(name).item(0).firstChild.nodeValue
  757. else:
  758. return default
  759.  
  760. self.id = None
  761. self.pwd = None
  762. self.loginnedServer = None
  763. self.loginnedChannel = None
  764. app.loggined = False
  765.  
  766. self.loginInfo = True
  767.  
  768. from xml.dom.minidom import parse
  769. try:
  770. f = old_open(loginInfoFileName, "r")
  771. dom = parse(f)
  772. except:
  773. return
  774. serverLst = dom.getElementsByTagName("server")
  775. if [] != dom.getElementsByTagName("logininfo"):
  776. logininfo = dom.getElementsByTagName("logininfo")[0]
  777. else:
  778. return
  779.  
  780. try:
  781. server_name = logininfo.getAttribute("name")
  782. channel_idx = int(logininfo.getAttribute("channel_idx"))
  783. except:
  784. return
  785.  
  786. try:
  787. matched = False
  788.  
  789. for k, v in serverInfo.REGION_DICT[0].iteritems():
  790. if v["name"] == server_name:
  791. account_addr = serverInfo.REGION_AUTH_SERVER_DICT[0][k]["ip"]
  792. account_port = serverInfo.REGION_AUTH_SERVER_DICT[0][k]["port"]
  793.  
  794. channel_info = v["channel"][channel_idx]
  795. channel_name = channel_info["name"]
  796. addr = channel_info["ip"]
  797. port = channel_info["tcp_port"]
  798.  
  799. net.SetMarkServer(addr, port)
  800. self.stream.SetConnectInfo(addr, port, account_addr, account_port)
  801.  
  802. matched = True
  803. break
  804.  
  805. if False == matched:
  806. return
  807. except:
  808. return
  809.  
  810. self.__SetServerInfo("%s, %s " % (server_name, channel_name))
  811. id = getValue(logininfo, "id", "")
  812. pwd = getValue(logininfo, "pwd", "")
  813. self.idEditLine.SetText(id)
  814. self.pwdEditLine.SetText(pwd)
  815. slot = getValue(logininfo, "slot", "0")
  816. locale = getValue(logininfo, "locale", "")
  817. locale_dir = getValue(logininfo, "locale_dir", "")
  818. is_auto_login = int(getValue(logininfo, "auto_login", "0"))
  819.  
  820. self.stream.SetCharacterSlot(int(slot))
  821. self.stream.isAutoLogin=is_auto_login
  822. self.stream.isAutoSelect=is_auto_login
  823.  
  824. if locale and locale_dir:
  825. app.ForceSetLocale(locale, locale_dir)
  826.  
  827. if 0 != is_auto_login:
  828. self.Connect(id, pwd)
  829.  
  830. return
  831.  
  832.  
  833. def PopupDisplayMessage(self, msg):
  834. self.stream.popupWindow.Close()
  835. self.stream.popupWindow.Open(msg)
  836.  
  837. def PopupNotifyMessage(self, msg, func=0):
  838. if not func:
  839. func=self.EmptyFunc
  840.  
  841. self.stream.popupWindow.Close()
  842. self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)
  843.  
  844. # RUNUP_MATRIX_AUTH
  845. def BINARY_OnRunupMatrixQuiz(self, quiz):
  846. if not IsRunupMatrixAuth():
  847. return
  848.  
  849. id = self.GetChild("RunupMatrixID")
  850. id.SetText(self.idEditLine.GetText())
  851.  
  852. code = self.GetChild("RunupMatrixCode")
  853.  
  854. code.SetText("".join(["[%c,%c]" % (quiz[i], quiz[i+1]) for i in xrange(0, len(quiz), 2)]))
  855.  
  856. self.stream.popupWindow.Close()
  857. self.serverBoard.Hide()
  858. self.connectBoard.Hide()
  859. self.loginBoard.Hide()
  860. self.matrixQuizBoard.Show()
  861. self.matrixAnswerInput.SetFocus()
  862.  
  863. def __OnClickMatrixAnswerOK(self):
  864. answer = self.matrixAnswerInput.GetText()
  865.  
  866. print "matrix_quiz.ok"
  867. net.SendRunupMatrixCardPacket(answer)
  868. self.matrixQuizBoard.Hide()
  869.  
  870. self.stream.popupWindow.Close()
  871. self.stream.popupWindow.Open("WAITING FOR MATRIX AUTHENTICATION",
  872. self.__OnClickMatrixAnswerCancel,
  873. localeInfo.UI_CANCEL)
  874.  
  875. def __OnClickMatrixAnswerCancel(self):
  876. print "matrix_quiz.cancel"
  877.  
  878. if self.matrixQuizBoard:
  879. self.matrixQuizBoard.Hide()
  880.  
  881. if self.connectBoard:
  882. self.connectBoard.Show()
  883.  
  884. if self.loginBoard:
  885. self.loginBoard.Show()
  886.  
  887. # RUNUP_MATRIX_AUTH_END
  888.  
  889. # NEWCIBN_PASSPOD_AUTH
  890. def BINARY_OnNEWCIBNPasspodRequest(self):
  891. if not IsNEWCIBNPassPodAuth():
  892. return
  893.  
  894. if self.connectingDialog:
  895. self.connectingDialog.Close()
  896. self.connectingDialog = None
  897.  
  898. self.stream.popupWindow.Close()
  899. self.serverBoard.Hide()
  900. self.connectBoard.Hide()
  901. self.loginBoard.Hide()
  902. self.passpodBoard.Show()
  903. self.passpodAnswerInput.SetFocus()
  904.  
  905. def BINARY_OnNEWCIBNPasspodFailure(self):
  906. if not IsNEWCIBNPassPodAuth():
  907. return
  908.  
  909. def __OnClickNEWCIBNPasspodAnswerOK(self):
  910. answer = self.passpodAnswerInput.GetText()
  911.  
  912. print "passpod.ok"
  913. net.SendNEWCIBNPasspodAnswerPacket(answer)
  914. self.passpodAnswerInput.SetText("")
  915. self.passpodBoard.Hide()
  916.  
  917. self.stream.popupWindow.Close()
  918. self.stream.popupWindow.Open(localeInfo.WAIT_FOR_PASSPOD,
  919. self.__OnClickNEWCIBNPasspodAnswerCancel,
  920. localeInfo.UI_CANCEL)
  921.  
  922. def __OnClickNEWCIBNPasspodAnswerCancel(self):
  923. print "passpod.cancel"
  924.  
  925. if self.passpodBoard:
  926. self.passpodBoard.Hide()
  927.  
  928. if self.connectBoard:
  929. self.connectBoard.Show()
  930.  
  931. if self.loginBoard:
  932. self.loginBoard.Show()
  933.  
  934. # NEWCIBN_PASSPOD_AUTH_END
  935.  
  936.  
  937. def OnMatrixCard(self, row1, row2, row3, row4, col1, col2, col3, col4):
  938.  
  939. if self.connectingDialog:
  940. self.connectingDialog.Close()
  941. self.connectingDialog = None
  942.  
  943. self.matrixInputChanceCount = 3
  944.  
  945. self.stream.popupWindow.Close()
  946.  
  947. # CHINA_MATRIX_CARD_BUG_FIX
  948. ## A~Z 까지 26 이내의 값이 들어있어야만 한다.
  949. ## Python Exception Log 에서 그 이상의 값이 들어있어서 에러 방지
  950. ## 헌데 왜 한국쪽 로그에서 이게 활용되는지는 모르겠음
  951. row1 = min(30, row1)
  952. row2 = min(30, row2)
  953. row3 = min(30, row3)
  954. row4 = min(30, row4)
  955. # END_OF_CHINA_MATRIX_CARD_BUG_FIX
  956.  
  957. row1 = chr(row1 + ord('A'))
  958. row2 = chr(row2 + ord('A'))
  959. row3 = chr(row3 + ord('A'))
  960. row4 = chr(row4 + ord('A'))
  961. col1 = col1 + 1
  962. col2 = col2 + 1
  963. col3 = col3 + 1
  964. col4 = col4 + 1
  965.  
  966. inputDialog = uiCommon.InputDialogWithDescription2()
  967. inputDialog.SetMaxLength(8)
  968. inputDialog.SetAcceptEvent(ui.__mem_func__(self.__OnAcceptMatrixCardData))
  969. inputDialog.SetCancelEvent(ui.__mem_func__(self.__OnCancelMatrixCardData))
  970. inputDialog.SetTitle(localeInfo.INPUT_MATRIX_CARD_TITLE)
  971. inputDialog.SetDescription1(localeInfo.INPUT_MATRIX_CARD_NUMBER)
  972. inputDialog.SetDescription2("%c%d %c%d %c%d %c%d" % (row1, col1,
  973. row2, col2,
  974. row3, col3,
  975. row4, col4))
  976.  
  977. inputDialog.Open()
  978. self.inputDialog = inputDialog
  979.  
  980. def __OnAcceptMatrixCardData(self):
  981. text = self.inputDialog.GetText()
  982. net.SendChinaMatrixCardPacket(text)
  983. if self.inputDialog:
  984. self.inputDialog.Hide()
  985. self.PopupNotifyMessage(localeInfo.LOGIN_PROCESSING)
  986. return True
  987.  
  988. def __OnCancelMatrixCardData(self):
  989. self.SetPasswordEditLineFocus()
  990. self.__OnCloseInputDialog()
  991. self.__DisconnectAndInputPassword()
  992. return True
  993.  
  994. def __OnCloseInputDialog(self):
  995. if self.inputDialog:
  996. self.inputDialog.Close()
  997. self.inputDialog = None
  998. return True
  999.  
  1000. def OnPressExitKey(self):
  1001. self.stream.popupWindow.Close()
  1002. self.stream.SetPhaseWindow(0)
  1003. return True
  1004.  
  1005. def OnExit(self):
  1006. self.stream.popupWindow.Close()
  1007. self.stream.popupWindow.Open(localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER_TRIPLE, app.Exit, localeInfo.UI_OK)
  1008.  
  1009. def OnUpdate(self):
  1010. ServerStateChecker.Update()
  1011.  
  1012. def EmptyFunc(self):
  1013. pass
  1014.  
  1015. #####################################################################################
  1016.  
  1017. def __ServerBoard_OnKeyUp(self, key):
  1018. if self.serverBoard.IsShow():
  1019. if app.DIK_RETURN==key:
  1020. self.__OnClickSelectServerButton()
  1021. return True
  1022.  
  1023. def __GetRegionID(self):
  1024. return 0
  1025.  
  1026. def __GetServerID(self):
  1027. return self.serverList.GetSelectedItem()
  1028.  
  1029. def __GetChannelID(self):
  1030. return self.channelList.GetSelectedItem()
  1031.  
  1032. # SEVER_LIST_BUG_FIX
  1033. def __ServerIDToServerIndex(self, regionID, targetServerID):
  1034. try:
  1035. regionDict = serverInfo.REGION_DICT[regionID]
  1036. except KeyError:
  1037. return -1
  1038.  
  1039. retServerIndex = 0
  1040. for eachServerID, regionDataDict in regionDict.items():
  1041. if eachServerID == targetServerID:
  1042. return retServerIndex
  1043.  
  1044. retServerIndex += 1
  1045.  
  1046. return -1
  1047.  
  1048. def __ChannelIDToChannelIndex(self, channelID):
  1049. return channelID - 1
  1050. # END_OF_SEVER_LIST_BUG_FIX
  1051.  
  1052. def __OpenServerBoard(self):
  1053.  
  1054. loadRegionID, loadServerID, loadChannelID = self.__LoadChannelInfo()
  1055.  
  1056. serverIndex = self.__ServerIDToServerIndex(loadRegionID, loadServerID)
  1057. channelIndex = self.__ChannelIDToChannelIndex(loadChannelID)
  1058.  
  1059. # RUNUP_MATRIX_AUTH
  1060. if IsRunupMatrixAuth():
  1061. self.matrixQuizBoard.Hide()
  1062. # RUNUP_MATRIX_AUTH_END
  1063.  
  1064. # NEWCIBN_PASSPOD_AUTH
  1065. if IsNEWCIBNPassPodAuth():
  1066. self.passpodBoard.Hide()
  1067. # NEWCIBN_PASSPOD_AUTH_END
  1068.  
  1069.  
  1070. self.serverList.SelectItem(serverIndex)
  1071.  
  1072. if constInfo.ENABLE_RANDOM_CHANNEL_SEL:
  1073. self.channelList.SelectItem(app.GetRandom(0, self.channelList.GetItemCount()))
  1074. else:
  1075. if channelIndex >= 0:
  1076. self.channelList.SelectItem(channelIndex)
  1077.  
  1078. ## Show/Hide 코드에 문제가 있어서 임시 - [levites]
  1079. self.serverBoard.SetPosition(self.xServerBoard, self.yServerBoard)
  1080. self.serverBoard.Show()
  1081. self.connectBoard.Hide()
  1082. self.loginBoard.Hide()
  1083.  
  1084. if self.virtualKeyboard:
  1085. self.virtualKeyboard.Hide()
  1086.  
  1087. if app.loggined and not SKIP_LOGIN_PHASE_SUPPORT_CHANNEL:
  1088. self.serverList.SelectItem(self.loginnedServer-1)
  1089. self.channelList.SelectItem(self.loginnedChannel-1)
  1090. self.__OnClickSelectServerButton()
  1091.  
  1092. def __OpenLoginBoard(self):
  1093.  
  1094. self.serverExitButton.SetEvent(ui.__mem_func__(self.__OnClickExitServerButton))
  1095. self.serverExitButton.SetText(localeInfo.UI_CLOSE)
  1096.  
  1097. # RUNUP_MATRIX_AUTH
  1098. if IsRunupMatrixAuth():
  1099. self.matrixQuizBoard.Hide()
  1100. # RUNUP_MATRIX_AUTH_END
  1101.  
  1102. # NEWCIBN_PASSPOD_AUTH
  1103. if IsNEWCIBNPassPodAuth():
  1104. self.passpodBoard.Hide()
  1105. # NEWCIBN_PASSPOD_AUTH_END
  1106.  
  1107. self.serverBoard.SetPosition(self.xServerBoard, wndMgr.GetScreenHeight())
  1108. self.serverBoard.Hide()
  1109.  
  1110. if self.virtualKeyboard:
  1111. self.virtualKeyboard.Show()
  1112.  
  1113. if app.loggined:
  1114. self.Connect(self.id, self.pwd)
  1115. self.connectBoard.Hide()
  1116. self.loginBoard.Hide()
  1117. elif not self.stream.isAutoLogin:
  1118. self.connectBoard.Show()
  1119. self.loginBoard.Show()
  1120.  
  1121. ## if users have the login infomation, then don't initialize.2005.9 haho
  1122. if self.idEditLine == None:
  1123. self.idEditLine.SetText("")
  1124. if self.pwdEditLine == None:
  1125. self.pwdEditLine.SetText("")
  1126.  
  1127. self.idEditLine.SetFocus()
  1128.  
  1129. global SKIP_LOGIN_PHASE
  1130. if SKIP_LOGIN_PHASE:
  1131. if not self.loginInfo:
  1132. self.connectBoard.Hide()
  1133.  
  1134. def __OnSelectRegionGroup(self):
  1135. self.__RefreshServerList()
  1136.  
  1137. def __OnSelectSettlementArea(self):
  1138. # SEVER_LIST_BUG_FIX
  1139. regionID = self.__GetRegionID()
  1140. serverID = self.serverListOnRegionBoard.GetSelectedItem()
  1141.  
  1142. serverIndex = self.__ServerIDToServerIndex(regionID, serverID)
  1143. self.serverList.SelectItem(serverIndex)
  1144. # END_OF_SEVER_LIST_BUG_FIX
  1145.  
  1146. self.__OnSelectServer()
  1147.  
  1148. def __RefreshServerList(self):
  1149. regionID = self.__GetRegionID()
  1150.  
  1151. if not serverInfo.REGION_DICT.has_key(regionID):
  1152. return
  1153.  
  1154. self.serverList.ClearItem()
  1155.  
  1156. regionDict = serverInfo.REGION_DICT[regionID]
  1157.  
  1158. # SEVER_LIST_BUG_FIX
  1159. visible_index = 1
  1160. for id, regionDataDict in regionDict.items():
  1161. name = regionDataDict.get("name", "noname")
  1162. if localeInfo.IsBRAZIL() or localeInfo.IsCANADA():
  1163. self.serverList.InsertItem(id, "%s" % (name))
  1164. else:
  1165. if localeInfo.IsCIBN10():
  1166. if name[0] == "#":
  1167. self.serverList.InsertItem(-1, " %s" % (name[1:]))
  1168. else:
  1169. self.serverList.InsertItem(id, " %s" % (name))
  1170. visible_index += 1
  1171. else:
  1172. try:
  1173. server_id = serverInfo.SERVER_ID_DICT[id]
  1174. except:
  1175. server_id = visible_index
  1176.  
  1177. self.serverList.InsertItem(id, " %02d. %s" % (int(server_id), name))
  1178.  
  1179. visible_index += 1
  1180.  
  1181. # END_OF_SEVER_LIST_BUG_FIX
  1182.  
  1183. def __OnSelectServer(self):
  1184. self.__OnCloseInputDialog()
  1185. self.__RequestServerStateList()
  1186. self.__RefreshServerStateList()
  1187.  
  1188. def __RequestServerStateList(self):
  1189. regionID = self.__GetRegionID()
  1190. serverID = self.__GetServerID()
  1191.  
  1192. try:
  1193. channelDict = serverInfo.REGION_DICT[regionID][serverID]["channel"]
  1194. except:
  1195. print " __RequestServerStateList - serverInfo.REGION_DICT(%d, %d)" % (regionID, serverID)
  1196. return
  1197.  
  1198. ServerStateChecker.Initialize();
  1199. for id, channelDataDict in channelDict.items():
  1200. key=channelDataDict["key"]
  1201. ip=channelDataDict["ip"]
  1202. udp_port=channelDataDict["udp_port"]
  1203. ServerStateChecker.AddChannel(key, ip, udp_port)
  1204.  
  1205. ServerStateChecker.Request()
  1206.  
  1207. def __RefreshServerStateList(self):
  1208.  
  1209. regionID = self.__GetRegionID()
  1210. serverID = self.__GetServerID()
  1211. bakChannelID = self.channelList.GetSelectedItem()
  1212.  
  1213. self.channelList.ClearItem()
  1214.  
  1215. try:
  1216. channelDict = serverInfo.REGION_DICT[regionID][serverID]["channel"]
  1217. except:
  1218. print " __RequestServerStateList - serverInfo.REGION_DICT(%d, %d)" % (regionID, serverID)
  1219. return
  1220.  
  1221. for channelID, channelDataDict in channelDict.items():
  1222. channelName = channelDataDict["name"]
  1223. channelState = channelDataDict["state"]
  1224. self.channelList.InsertItem(channelID, " %s %s" % (channelName, channelState))
  1225.  
  1226. self.channelList.SelectItem(bakChannelID-1)
  1227.  
  1228. def __GetChannelName(self, regionID, selServerID, selChannelID):
  1229. try:
  1230. return serverInfo.REGION_DICT[regionID][selServerID]["channel"][selChannelID]["name"]
  1231. except KeyError:
  1232. if 9==selChannelID:
  1233. return localeInfo.CHANNEL_PVP
  1234. else:
  1235. return localeInfo.CHANNEL_NORMAL % (selChannelID)
  1236.  
  1237. def NotifyChannelState(self, addrKey, state):
  1238. try:
  1239. stateName=serverInfo.STATE_DICT[state]
  1240. except:
  1241. stateName=serverInfo.STATE_NONE
  1242.  
  1243. regionID=int(addrKey/1000)
  1244. serverID=int(addrKey/10) % 100
  1245. channelID=addrKey%10
  1246.  
  1247. try:
  1248. serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["state"] = stateName
  1249. self.__RefreshServerStateList()
  1250.  
  1251. except:
  1252. import exception
  1253. exception.Abort(localeInfo.CHANNEL_NOT_FIND_INFO)
  1254.  
  1255. def __OnClickExitServerButton(self):
  1256. print "exit server"
  1257. self.__OpenLoginBoard()
  1258.  
  1259. if IsFullBackImage():
  1260. self.GetChild("bg1").Hide()
  1261. self.GetChild("bg2").Show()
  1262.  
  1263.  
  1264. def __OnClickSelectRegionButton(self):
  1265. regionID = self.__GetRegionID()
  1266. serverID = self.__GetServerID()
  1267.  
  1268. if (not serverInfo.REGION_DICT.has_key(regionID)):
  1269. self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_REGION)
  1270. return
  1271.  
  1272. if (not serverInfo.REGION_DICT[regionID].has_key(serverID)):
  1273. self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_SERVER)
  1274. return
  1275.  
  1276. self.__SaveChannelInfo()
  1277.  
  1278. self.serverExitButton.SetEvent(ui.__mem_func__(self.__OnClickExitServerButton))
  1279. self.serverExitButton.SetText(localeInfo.UI_CLOSE)
  1280.  
  1281. self.__RefreshServerList()
  1282. self.__OpenServerBoard()
  1283.  
  1284. def __OnClickSelectServerButton(self):
  1285. if IsFullBackImage():
  1286. self.GetChild("bg1").Hide()
  1287. self.GetChild("bg2").Show()
  1288.  
  1289. regionID = self.__GetRegionID()
  1290. serverID = self.__GetServerID()
  1291. channelID = self.__GetChannelID()
  1292.  
  1293. if (not serverInfo.REGION_DICT.has_key(regionID)):
  1294. self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_REGION)
  1295. return
  1296.  
  1297. if (not serverInfo.REGION_DICT[regionID].has_key(serverID)):
  1298. self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_SERVER)
  1299. return
  1300.  
  1301. try:
  1302. channelDict = serverInfo.REGION_DICT[regionID][serverID]["channel"]
  1303. except KeyError:
  1304. return
  1305.  
  1306. try:
  1307. state = channelDict[channelID]["state"]
  1308. except KeyError:
  1309. self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_CHANNEL)
  1310. return
  1311.  
  1312. # 상태가 FULL 과 같으면 진입 금지
  1313. if state == serverInfo.STATE_DICT[3]:
  1314. self.PopupNotifyMessage(localeInfo.CHANNEL_NOTIFY_FULL)
  1315. return
  1316.  
  1317. self.__SaveChannelInfo()
  1318.  
  1319. try:
  1320. serverName = serverInfo.REGION_DICT[regionID][serverID]["name"]
  1321. channelName = serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["name"]
  1322. addrKey = serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["key"]
  1323.  
  1324. if "천마 서버" == serverName:
  1325. app.ForceSetLocale("ymir", "locale/ymir")
  1326. elif "쾌도 서버" == serverName:
  1327. app.ForceSetLocale("we_korea", "locale/we_korea")
  1328.  
  1329. except:
  1330. print " ERROR __OnClickSelectServerButton(%d, %d, %d)" % (regionID, serverID, channelID)
  1331. serverName = localeInfo.CHANNEL_EMPTY_SERVER
  1332. channelName = localeInfo.CHANNEL_NORMAL % channelID
  1333.  
  1334. self.__SetServerInfo("%s, %s " % (serverName, channelName))
  1335.  
  1336. try:
  1337. ip = serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["ip"]
  1338. tcp_port = serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["tcp_port"]
  1339. except:
  1340. import exception
  1341. exception.Abort("LoginWindow.__OnClickSelectServerButton - 서버 선택 실패")
  1342.  
  1343. try:
  1344. account_ip = serverInfo.REGION_AUTH_SERVER_DICT[regionID][serverID]["ip"]
  1345. account_port = serverInfo.REGION_AUTH_SERVER_DICT[regionID][serverID]["port"]
  1346. except:
  1347. account_ip = 0
  1348. account_port = 0
  1349.  
  1350. try:
  1351. markKey = regionID*1000 + serverID*10
  1352. markAddrValue=serverInfo.MARKADDR_DICT[markKey]
  1353. net.SetMarkServer(markAddrValue["ip"], markAddrValue["tcp_port"])
  1354. app.SetGuildMarkPath(markAddrValue["mark"])
  1355. # GUILD_SYMBOL
  1356. app.SetGuildSymbolPath(markAddrValue["symbol_path"])
  1357. # END_OF_GUILD_SYMBOL
  1358.  
  1359. except:
  1360. import exception
  1361. exception.Abort("LoginWindow.__OnClickSelectServerButton - 마크 정보 없음")
  1362.  
  1363.  
  1364. if app.USE_OPENID and not app.OPENID_TEST :
  1365. ## 2012.07.19 OpenID : 김용욱
  1366. # 채널 선택 화면에서 "확인"(SelectServerButton) 을 눌렀을때,
  1367. # 로그인 화면으로 넘어가지 않고 바로 서버에 OpenID 인증키를 보내도록 수정
  1368. self.stream.SetConnectInfo(ip, tcp_port, account_ip, account_port)
  1369. self.Connect(0, 0)
  1370. else :
  1371. self.stream.SetConnectInfo(ip, tcp_port, account_ip, account_port)
  1372. self.__OpenLoginBoard()
  1373.  
  1374.  
  1375. def __OnClickSelectConnectButton(self):
  1376. if IsFullBackImage():
  1377. self.GetChild("bg1").Show()
  1378. self.GetChild("bg2").Hide()
  1379. self.__RefreshServerList()
  1380. self.__OpenServerBoard()
  1381.  
  1382. def __OnClickLoginButton(self):
  1383. id = self.idEditLine.GetText()
  1384. pwd = self.pwdEditLine.GetText()
  1385.  
  1386. if len(id)==0:
  1387. self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, self.SetIDEditLineFocus)
  1388. return
  1389.  
  1390. if len(pwd)==0:
  1391. self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, self.SetPasswordEditLineFocus)
  1392. return
  1393.  
  1394. self.Connect(id, pwd)
  1395.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement