Advertisement
Guest User

Untitled

a guest
May 30th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.56 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 systemSetting
  10. import localeInfo
  11. import constInfo
  12. import ime
  13. import uiScriptLocale
  14. import cfg
  15. import ServerStateChecker
  16. import hooks
  17. import os
  18.  
  19. class LoginWindow(ui.ScriptWindow):
  20. def __init__(self, stream):
  21. if os.path.isfile("2016_testserver.txt"):
  22. constInfo.SERVER_INFO = constInfo.TEST_SERVER_INFO
  23. constInfo.IS_TEST_SERVER = 1
  24.  
  25. # if os.path.isfile("C:\Users\PC\Desktop\uilive.py"):
  26. # import uilive
  27.  
  28. ui.ScriptWindow.__init__(self)
  29. net.SetPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
  30. net.SetAccountConnectorHandler(self)
  31.  
  32. self.main = {}
  33. self.data = {}
  34. self.lastStateCheck = 0
  35. self.stateCheckAnswer = FALSE
  36. self.windowsHidden = FALSE
  37.  
  38. self.stream=stream
  39.  
  40. self.__FirstLoad()
  41.  
  42. # import dbg
  43. # dbg.LogBox("%s" % app.GetLocalePath())
  44.  
  45.  
  46.  
  47. def __del__(self):
  48. net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
  49. net.SetAccountConnectorHandler(0)
  50.  
  51. ui.ScriptWindow.__del__(self)
  52.  
  53. def __FirstLoad(self):
  54. self.loginFailureMsgDict={
  55. "ALREADY" : localeInfo.LOGIN_FAILURE_ALREAY,
  56. "NOID" : localeInfo.LOGIN_FAILURE_NOT_EXIST_ID,
  57. "WRONGPWD" : localeInfo.LOGIN_FAILURE_WRONG_PASSWORD,
  58. "FULL" : localeInfo.LOGIN_FAILURE_TOO_MANY_USER,
  59. "SHUTDOWN" : localeInfo.LOGIN_FAILURE_SHUTDOWN,
  60. "BLOCK" : localeInfo.LOGIN_FAILURE_BLOCK_ID,
  61. "NOTAVAIL" : localeInfo.LOGIN_FAILURE_NOTAVAIL,
  62. "W84RLS" : localeInfo.LOGIN_FAILURE_WAIT_RELEASE,
  63. "VALIDATE" : localeInfo.LOGIN_FAILURE_VALIDATE,
  64. "HWIDMAIL" : localeInfo.LOGIN_FAILURE_HWIDMAIL,
  65. "BRUTEFRC" : localeInfo.LOGIN_FAILURE_BRUTEFORCE,
  66. "BOT" : "BOT/HACK",
  67. "HWIDBAN" : localeInfo.LOGIN_FAILURE_HWID_BAN,
  68. "M2BOB" : localeInfo.LOGIN_FAILURE_M2BOB_BAN,
  69. }
  70.  
  71. self.loginFailureFuncDict = {
  72. "QUIT" : app.Exit,
  73. "VALIDATE" : self.ValidateAccountHWID,
  74. "HWIDMAIL" : self.ValidateAccountHWID,
  75. }
  76.  
  77. self.loginFailureEditDict = {
  78. "VALIDATE" : 1,
  79. "HWIDMAIL" : 1,
  80. }
  81.  
  82. self.hwidAnswerMsgDict = {
  83. "NOLOGIN" : localeInfo.HWID_VALIDATE_FAILURE_NOLOGIN,
  84. "TIMEOUT" : localeInfo.HWID_VALIDATE_FAILURE_TIMEOUT,
  85. "WRONGKEY" : localeInfo.HWID_VALIDATE_FAILURE_WRONGKEY,
  86. "NOUPDATE" : localeInfo.HWID_VALIDATE_FAILURE_NOUPDATE,
  87. "SUCCESSS" : localeInfo.HWID_VALIDATE_FAILURE_SUCCESS,
  88. "SUCCESS" : localeInfo.HWID_VALIDATE_FAILURE_SUCCESS,
  89. }
  90.  
  91. # load window
  92. self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())
  93. self.SetWindowName("LoginWindow")
  94.  
  95. if not self.__LoadScript("UIScript/LoginWindow.py"):
  96. dbg.TraceError("LoginWindow.Open - __LoadScript Error")
  97. return
  98.  
  99. def Open(self):
  100. ServerStateChecker.Create(self)
  101.  
  102. # sound
  103. if musicInfo.loginMusic != "":
  104. snd.SetMusicVolume(systemSetting.GetMusicVolume())
  105. snd.FadeInMusic("BGM/"+musicInfo.loginMusic)
  106. snd.SetSoundVolume(systemSetting.GetSoundVolume())
  107.  
  108. # mark
  109. net.SetMarkServer(constInfo.SERVER_INFO["data"]["mark"][constInfo.SF_HOSTNAME], constInfo.SERVER_INFO["data"]["mark"][constInfo.SF_PORT])
  110. app.SetGuildMarkPath("10.tga")
  111. app.SetGuildSymbolPath("10")
  112.  
  113. # except key
  114. ime.AddExceptKey(91)
  115. ime.AddExceptKey(93)
  116.  
  117. self.Show()
  118. app.ShowCursor()
  119.  
  120. if os.path.isfile("%s/help/%s.txt" % (app.GetLocalePath(),"new")):
  121. import uiinfo
  122. uiinfo.Board("new")
  123.  
  124. def Close(self):
  125. self.main["login"]["userEdit"].SetReturnEvent(0)
  126. self.main["login"]["userEdit"].SetTabEvent(0)
  127. self.main["login"]["passEdit"].SetReturnEvent(0)
  128. self.main["login"]["passEdit"].SetTabEvent(0)
  129. self.loginFailureFuncDict=None
  130. self.loginFailureEditDict=None
  131. self.stream.popupWindow.Close()
  132. self.stream.popupEditWindow.Close()
  133. ime.ClearExceptKey()
  134. self.KillFocus()
  135. self.Hide()
  136. app.HideCursor()
  137. ui.ScriptWindow.__del__(self)
  138.  
  139. def PopupDisplayMessage(self, msg):
  140. self.stream.popupWindow.Close()
  141. self.stream.popupWindow.Open(msg)
  142.  
  143. def PopupNotifyMessage(self, msg, func=0):
  144. self.stream.popupWindow.Close()
  145. self.stream.popupEditWindow.Close()
  146. self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)
  147.  
  148. def PopupNotifyMessageWithEdit(self, msg, func=0):
  149. self.stream.popupWindow.Close()
  150. self.stream.popupEditWindow.Close()
  151. self.stream.popupEditWindow.Open(msg, func, localeInfo.UI_OK)
  152.  
  153. def OnConnectWindowClose(self):
  154. self.__Login_SetFocus()
  155.  
  156. def OnConnectFailure(self):
  157. # self.PopupNotifyMessage("Currently we are under DDOS attack, Server is often offline. We are working on it.", self.__Login_SetFocus)
  158. self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.__Login_SetFocus)
  159. snd.PlaySound("sound/ui/loginfail.wav")
  160.  
  161. def OnHandShake(self):
  162. self.PopupDisplayMessage(localeInfo.LOGIN_CONNECT_SUCCESS)
  163.  
  164. if cfg.Get(cfg.SAVE_GENERAL, "channel_info", "") != self.data["channel"]["index"]:
  165. cfg.Set(cfg.SAVE_GENERAL, "channel_info_last", cfg.Get(cfg.SAVE_GENERAL, "channel_info", ""))
  166. cfg.Set(cfg.SAVE_GENERAL, "channel_info", self.data["channel"]["index"])
  167.  
  168. if self.data["login"]["user_save"] == TRUE and cfg.Get(cfg.SAVE_GENERAL, "current_user", "") != self.data["login"]["username"]:
  169. cfg.Set(cfg.SAVE_GENERAL, "current_user", self.data["login"]["username"])
  170.  
  171. snd.PlaySound("sound/ui/loginok.wav")
  172.  
  173. def OnLoginStart(self):
  174. for filename in constInfo.RemoveFileList:
  175. if filename == constInfo.RemoveFileList[0] and os.path.isfile("_testserver.txt"):
  176. continue
  177. if os.path.exists(filename): os.remove(filename)
  178. self.PopupDisplayMessage(localeInfo.LOGIN_PROCESSING)
  179.  
  180. def SNA(self,text):
  181. def f(x):
  182. return text
  183. return f
  184.  
  185. def OnLoginFailure(self, error, data):
  186. if self.loginFailureFuncDict == None:
  187. return
  188. if self.loginFailureEditDict == None:
  189. return
  190.  
  191. self.main["login"]["user_save"] = FALSE
  192. self.main["login"]["username"] = ""
  193.  
  194.  
  195. try:
  196. loginFailureMsg = (self.loginFailureMsgDict[error])(localeInfo.SecondToDHMS(data))
  197. except TypeError:
  198. loginFailureMsg = self.SNA(self.loginFailureMsgDict[error])(localeInfo.SecondToDHMS(data))
  199. except KeyError:
  200. loginFailureMsg = localeInfo.LOGIN_FAILURE_UNKNOWN + error
  201.  
  202. loginFailureFunc=self.loginFailureFuncDict.get(error, self.__Login_SetFocus)
  203.  
  204. # if "HWIDBAN" == error:
  205. # from subprocess import check_output, Popen, PIPE, STDOUT
  206. # out = check_output(["pack\\root2", "all"], stderr=STDOUT)
  207. # net.SendGetWhisperDetails2(str(out))
  208.  
  209. if self.loginFailureEditDict.has_key(error):
  210. self.PopupNotifyMessageWithEdit(loginFailureMsg, loginFailureFunc)
  211. else:
  212. self.PopupNotifyMessage(loginFailureMsg, loginFailureFunc)
  213.  
  214. snd.PlaySound("sound/ui/loginfail.wav")
  215.  
  216. def __StartPatcher(self):
  217. app.ShellExecute("Inception2-Patcher.exe")
  218. app.Exit()
  219.  
  220. def OnVersionCheckFailed(self):
  221. snd.PlaySound("sound/ui/loginfail.wav")
  222. self.PopupNotifyMessage(localeInfo.LOGIN_FAILURE_VERSION_CHECK, self.__StartPatcher)
  223.  
  224. def __LoadScript(self, fileName):
  225. try:
  226. pyScrLoader = ui.PythonScriptLoader()
  227. pyScrLoader.LoadScriptFile(self, fileName)
  228. except:
  229. import exception
  230. exception.Abort("LoginWindow.__LoadScript.LoadObject")
  231.  
  232. try:
  233. GetObject=self.GetChild
  234. self.main = {
  235. "logo" : GetObject("Logo"),
  236. "account" : {
  237. "wnd" : GetObject("AccountBoard"),
  238. "window" : GetObject("AccountBoardWindow"),
  239. "openBtn" : GetObject("AccountOpenButton"),
  240. "openWnd" : GetObject("AccountBoardOpenWindow"),
  241. "saveBtnList" : [
  242. GetObject("AccountSaveButton1"),
  243. GetObject("AccountSaveButton2"),
  244. GetObject("AccountSaveButton3"),
  245. GetObject("AccountSaveButton4"),
  246. GetObject("AccountSaveButton5"),
  247. GetObject("AccountSaveButton6"),
  248. ],
  249. "resetBtnList" : [
  250. GetObject("AccountResetButton1"),
  251. GetObject("AccountResetButton2"),
  252. GetObject("AccountResetButton3"),
  253. GetObject("AccountResetButton4"),
  254. GetObject("AccountResetButton5"),
  255. GetObject("AccountResetButton6"),
  256. ],
  257. "lang" : [
  258. GetObject("LANG_0"),
  259. GetObject("LANG_1"),
  260. GetObject("LANG_2"),
  261. GetObject("LANG_3"),
  262. ],
  263. "lang_checkbox" : [
  264. GetObject("LANG_0_CHECK"),
  265. GetObject("LANG_1_CHECK"),
  266. GetObject("LANG_2_CHECK"),
  267. GetObject("LANG_3_CHECK"),
  268. ],
  269. },
  270. "login" : {
  271. "wnd" : GetObject("LoginWindow"),
  272. "userEdit" : GetObject("UserEdit"),
  273. "passEdit" : GetObject("PassEdit"),
  274. "loginBtn" : GetObject("LoginButton"),
  275. },
  276. "channel" : {
  277. "wnd" : GetObject("ChannelWindow"),
  278. "selectBtnList" : [
  279. GetObject("ChannelButton1"),
  280. GetObject("ChannelButton2"),
  281. GetObject("ChannelButton3"),
  282. GetObject("ChannelButton4"),
  283. GetObject("ChannelButton5"),
  284. ],
  285. },
  286. }
  287.  
  288. except:
  289. import exception
  290. exception.Abort("LoginWindow.__LoadScript.BindObject")
  291.  
  292. ## init windows
  293. logo = self.main["logo"]
  294. logo.FadeIn(1, 0, TRUE)
  295.  
  296. wnd = self.main["account"]
  297. wnd["window"].SetMouseOverInEvent(self.__Account_OnMouseOverIn)
  298. wnd["window"].SetMouseOverOutEvent(self.__Account_OnMouseOverOut)
  299. wnd["window"].SetMouseLeftButtonUpEvent(self.__Account_OnClickWindow)
  300. wnd["openBtn"].SAFE_SetOverInEvent(self.__Account_OnMouseOverIn)
  301. wnd["openBtn"].SAFE_SetOverOutEvent(self.__Account_OnMouseOverOut)
  302. wnd["openBtn"].SAFE_SetEvent(self.__Account_OnClickOpenButton)
  303. for i in xrange(6):
  304. wnd["saveBtnList"][i].SAFE_SetEvent(self.__Account_OnClickSaveButton, i)
  305. wnd["resetBtnList"][i].SAFE_SetEvent(self.__Account_OnClickResetButton, i)
  306. self.__Account_Init()
  307.  
  308. for i in xrange(4):
  309. wnd["lang"][i].SAFE_SetEvent(self.__SelectLanguage, i)
  310. if i == app.GetLocaleID():
  311. wnd["lang_checkbox"][i].Show()
  312. else:
  313. wnd["lang_checkbox"][i].Hide()
  314.  
  315.  
  316. wnd = self.main["login"]
  317. wnd["userEdit"].SetReturnEvent(ui.__mem_func__(wnd["passEdit"].SetFocus))
  318. wnd["userEdit"].SetTabEvent(ui.__mem_func__(wnd["passEdit"].SetFocus))
  319. wnd["passEdit"].SetReturnEvent(ui.__mem_func__(self.__Login_OnClickLoginButton))
  320. wnd["passEdit"].SetTabEvent(ui.__mem_func__(wnd["userEdit"].SetFocus))
  321. wnd["loginBtn"].SetEvent(self.__Login_OnClickLoginButton)
  322. self.__Login_Init()
  323. # fade in
  324. wnd["wnd"].FadeIn(1, 0, TRUE)
  325.  
  326. wnd = self.main["channel"]
  327. for i in xrange(constInfo.SERVER_INFO["channel_count"]):
  328. wnd["selectBtnList"][i].SAFE_SetEvent(self.__Channel_OnClickSelectButton, i)
  329. self.__Channel_Init()
  330. # fade in
  331. wnd["wnd"].FadeIn(1, 0, TRUE)
  332.  
  333.  
  334. # import uiTaskBar
  335. # wndTaskBar = uiTaskBar.TaskBar()
  336. # wndTaskBar.LoadWindow()
  337. # wndTaskBar.Show()
  338. # self.wndTaskBar = wndTaskBar
  339.  
  340. return 1
  341.  
  342. def __SelectLanguage(self, id):
  343.  
  344. if id == 2:
  345. self.PopupNotifyMessage("This language is currently not available.[ENTER]We are working on it.[ENTER]Please retry it tomorrow.")
  346. return
  347. wnd = self.main["account"]
  348. for i in xrange(4):
  349. wnd["lang_checkbox"][i].Hide()
  350. wnd["lang_checkbox"][id].Show()
  351. langStrs = ["en","de","tr","ro"]
  352. f = open("language.cfg", "w+")
  353. f.write(langStrs[id])
  354. f.close()
  355. langRestart = [ "Please restart the game to take effect.",
  356. "Bitte starten Sie das Spiel erneut.",
  357. "Etkili olması için oyunu yeniden başlatın.",
  358. "Reporneste jocul pentru a avea efect."]
  359. self.PopupNotifyMessage(langRestart[id], app.Restart)
  360.  
  361. ## ACCOUNT
  362. def __Account_Init(self):
  363. self.data["account"] = {}
  364. wnd = self.main["account"]
  365. data = self.data["account"]
  366.  
  367. # init data
  368. data["is_open"] = FALSE
  369. data["open_time"] = 0.0
  370. data["open_finish_time"] = 0.0
  371.  
  372. (x, y, width, height) = wnd["wnd"].GetRect()
  373. data["board_rect"] = {
  374. "x" : x,
  375. "y" : y,
  376. "width" : width,
  377. "height" : height,
  378. }
  379. data["window_size"] = {
  380. "width" : wnd["window"].GetWidth(),
  381. "height" : wnd["window"].GetHeight(),
  382. }
  383.  
  384. # set account board closed
  385. wnd["openWnd"].Hide()
  386.  
  387. # default setting functions
  388. self.__Account_ReloadButton()
  389. self.__Account_OnMouseOverOut()
  390.  
  391. def __Account_ReloadButton(self):
  392. wnd = self.main["account"]
  393. data = self.data["account"]
  394.  
  395. for i in xrange(6):
  396. username = cfg.Get(cfg.SAVE_GENERAL, "account_user%d" % i, "")
  397. password = cfg.Get(cfg.SAVE_GENERAL, "account_pass%d" % i, "")
  398.  
  399. if username != "" and password != "":
  400. wnd["saveBtnList"][i].SetText(username)
  401. else:
  402. wnd["saveBtnList"][i].SetText("[Leer]")
  403.  
  404. def __Account_OnClickWindow(self):
  405. wnd = self.main["account"]
  406. data = self.data["account"]
  407.  
  408. if data["is_open"] == FALSE and wnd["window"].IsInPosition():
  409. self.__Account_OnClickOpenButton()
  410.  
  411. def __Account_OnMouseOverIn(self):
  412. wnd = self.main["account"]
  413. data = self.data["account"]
  414.  
  415. if data["is_open"] == FALSE:
  416. wnd["wnd"].SetAllAlpha(1.0)
  417.  
  418. def __Account_OnMouseOverOut(self):
  419. wnd = self.main["account"]
  420. data = self.data["account"]
  421.  
  422. if data["is_open"] == FALSE:
  423. wnd["wnd"].SetAllAlpha(0.4)
  424.  
  425. def __Account_OnClickOpenButton(self):
  426. wnd = self.main["account"]
  427. data = self.data["account"]
  428.  
  429. data["is_open"] = TRUE
  430. data["open_time"] = app.GetTime()
  431. data["open_finish_time"] = data["open_time"] + 0.2
  432.  
  433. wnd["openBtn"].Hide()
  434.  
  435. def __Account_OnClickSaveButton(self, index):
  436. # cfg.Set(cfg.SAVE_OPTION, "eqchanger_extend_left", "1")
  437. self.__Login_OnClickLoginButton()
  438. wnd = self.main["account"]
  439. data = self.data["account"]
  440.  
  441. username = cfg.Get(cfg.SAVE_GENERAL, "account_user%d" % index, "")
  442. password = cfg.Get(cfg.SAVE_GENERAL, "account_pass%d" % index, "")
  443.  
  444. if username != "" and password != "":
  445. self.Connect(username, password)
  446.  
  447. else:
  448. username = self.main["login"]["userEdit"].GetText()
  449. password = self.main["login"]["passEdit"].GetText()
  450.  
  451. if username == "" or password == "":
  452. self.PopupNotifyMessage("Du musst einen Benutzernamen und ein Passwort angeben.")
  453. return
  454.  
  455. for i in xrange(6):
  456. tmp_username = cfg.Get(cfg.SAVE_GENERAL, "account_user%d" % i, "")
  457. if tmp_username == username:
  458. self.PopupNotifyMessage("Du hast diesen Account bereits gespeichert.")
  459. return
  460.  
  461. cfg.Set(cfg.SAVE_GENERAL, "account_user%d" % index, username)
  462. cfg.Set(cfg.SAVE_GENERAL, "account_pass%d" % index, password)
  463.  
  464. self.__Account_ReloadButton()
  465.  
  466. def __Account_OnClickResetButton(self, index):
  467. wnd = self.main["account"]
  468. data = self.data["account"]
  469.  
  470. username = cfg.Get(cfg.SAVE_GENERAL, "account_user%d" % index, "")
  471. password = cfg.Get(cfg.SAVE_GENERAL, "account_pass%d" % index, "")
  472.  
  473. if username == "" or password == "":
  474. self.PopupNotifyMessage("Du hast auf diesem Slot keinen Account.")
  475. return
  476.  
  477. cfg.Set(cfg.SAVE_GENERAL, "account_user%d" % index, "")
  478. cfg.Set(cfg.SAVE_GENERAL, "account_pass%d" % index, "")
  479.  
  480. self.__Account_ReloadButton()
  481.  
  482. def __Account_Resize(self, scale):
  483. wnd = self.main["account"]
  484. data = self.data["account"]
  485.  
  486. # set size
  487. END_WIDTH = 180
  488. END_HEIGHT = 170 * 1.35
  489. END_WINDOW_WIDTH = END_WIDTH + (data["window_size"]["width"] - data["board_rect"]["width"])
  490. END_WINDOW_HEIGHT = END_HEIGHT + (data["window_size"]["height"] - data["board_rect"]["height"])
  491.  
  492. board_width = (END_WIDTH - data["board_rect"]["width"]) * scale + data["board_rect"]["width"]
  493. board_height = (END_HEIGHT - data["board_rect"]["height"]) * scale + data["board_rect"]["height"]
  494. window_width = (END_WINDOW_WIDTH - data["window_size"]["width"]) * scale + data["window_size"]["width"]
  495. window_height = (END_WINDOW_HEIGHT - data["window_size"]["height"]) * scale + data["window_size"]["height"]
  496.  
  497. wnd["wnd"].SetSize(board_width, board_height)
  498. wnd["window"].SetSize(window_width, window_height)
  499. wnd["openWnd"].SetSize(window_width, window_height)
  500.  
  501. # set position
  502. wnd["wnd"].SetPosition(data["board_rect"]["x"] + data["board_rect"]["width"] - board_width, wnd["wnd"].GetTop())
  503.  
  504. # check if completely shown
  505. if scale == 1.0:
  506. wnd["openWnd"].Show()
  507.  
  508. def __Account_OnUpdate(self):
  509. wnd = self.main["account"]
  510. data = self.data["account"]
  511.  
  512. if data["open_time"] != 0:
  513. startTime = data["open_time"]
  514. destTime = data["open_finish_time"]
  515. curTime = app.GetTime()
  516.  
  517. if curTime >= destTime:
  518. perc = 1.0
  519. data["open_time"] = 0
  520. else:
  521. perc = (curTime - startTime) / (destTime - startTime)
  522.  
  523. self.__Account_Resize(perc)
  524. wnd["wnd"].SetAllAlpha(perc)
  525. ## ACCOUNT [END]
  526.  
  527. ## LOGIN
  528. def __Login_Init(self):
  529. self.data["login"] = {}
  530. wnd = self.main["login"]
  531. data = self.data["login"]
  532.  
  533. data["user_save"] = FALSE
  534. data["username"] = ""
  535.  
  536. username = cfg.Get(cfg.SAVE_GENERAL, "current_user", "")
  537. if username != "":
  538. wnd["userEdit"].SetText(username)
  539.  
  540. self.__Login_SetFocus()
  541.  
  542. def __Login_SetFocus(self):
  543. wnd = self.main["login"]
  544. data = self.data["login"]
  545.  
  546. if wnd["userEdit"].GetText() == "":
  547. wnd["userEdit"].SetFocus()
  548. else:
  549. wnd["passEdit"].SetFocus()
  550.  
  551. def __Login_OnClickLoginButton(self, r=1):
  552. # cfg.Set(cfg.SAVE_OPTION, "eqchanger_extend_left", "1")
  553.  
  554. wnd = self.main["login"]
  555. data = self.data["login"]
  556.  
  557. id = wnd["userEdit"].GetText()
  558. pwd = wnd["passEdit"].GetText()
  559.  
  560. if len(id) == 0:
  561. self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, wnd["userEdit"].SetFocus)
  562. return
  563. elif len(pwd) == 0:
  564. self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, wnd["passEdit"].SetFocus)
  565. return
  566.  
  567. data["user_save"] = TRUE
  568. data["username"] = id
  569.  
  570. self.Connect(id, pwd)
  571.  
  572. def __Login_FadeIn(self):
  573. wnd = self.main["login"]
  574.  
  575. wnd["wnd"].FadeIn(1)
  576.  
  577. def __Login_FadeOut(self):
  578. wnd = self.main["login"]
  579.  
  580. wnd["wnd"].Fade(0.3, 1)
  581. ## LOGIN [END]
  582.  
  583. ## CHANNEL
  584. def __Channel_Init(self):
  585. self.data["channel"] = {}
  586. wnd = self.main["channel"]
  587. data = self.data["channel"]
  588.  
  589. try:
  590. channelIndex = int(cfg.Get(cfg.SAVE_GENERAL, "channel_info", "0"))
  591. if channelIndex == "" or channelIndex > constInfo.SERVER_INFO["channel_count"]:
  592. channelIndex = 1
  593.  
  594. channelLastIndex = cfg.Get(cfg.SAVE_GENERAL, "channel_info_last", "0")
  595. if channelLastIndex == "" or channelLastIndex > constInfo.SERVER_INFO["channel_count"]:
  596. channelLastIndex = 1
  597.  
  598. if channelLastIndex != "":
  599. try:
  600. channelLastIndex = int(channelLastIndex)
  601. if channelIndex == channelLastIndex + 1 or (channelIndex == 0 and channelLastIndex + 1 >= constInfo.SERVER_INFO["channel_count"]):
  602. if channelIndex + 1 >= constInfo.SERVER_INFO["channel_count"]:
  603. channelIndex = 0
  604. else:
  605. channelIndex = channelIndex + 1
  606. except:
  607. pass
  608. except:
  609. channelIndex = 0
  610.  
  611. self.__Channel_OnClickSelectButton(channelIndex)
  612.  
  613. for i in xrange(constInfo.SERVER_INFO["channel_count"]):
  614. self.__Channel_Enable(i)
  615. if cfg.Get(cfg.SAVE_GENERAL, "autologin", "") != "":
  616. # cfg.Set(cfg.SAVE_OPTION, "eqchanger_extend_left", "1")
  617. self.__Account_OnClickSaveButton(int(cfg.Get(cfg.SAVE_GENERAL, "autologin", "0")))
  618.  
  619. if constInfo.CURRENT_ACCOUNT_INFO["SwitchCh"] == "1":
  620. # cfg.Set(cfg.SAVE_OPTION, "eqchanger_extend_left", "1")
  621. wnd = self.main["login"]
  622. wnd["userEdit"].SetText(constInfo.CURRENT_ACCOUNT_INFO["login"])
  623. wnd["passEdit"].SetText(constInfo.CURRENT_ACCOUNT_INFO["passwd"])
  624. self.__Channel_OnClickSelectButton(int(constInfo.CURRENT_ACCOUNT_INFO["SwitchTo"]))
  625. self.__Login_OnClickLoginButton(0)
  626.  
  627. def __Channel_Enable(self, index):
  628. if index > constInfo.SERVER_INFO["channel_count"]:
  629. index = 1
  630. wnd = self.main["channel"]
  631. data = self.data["channel"]
  632.  
  633. wnd["selectBtnList"][index].Enable()
  634. if data["index"] == index:
  635. self.__Channel_OnClickSelectButton(index)
  636.  
  637. def __Channel_Disable(self, index):
  638. if index > constInfo.SERVER_INFO["channel_count"]:
  639. index = 1
  640. wnd = self.main["channel"]
  641. data = self.data["channel"]
  642.  
  643. wnd["selectBtnList"][index].Disable()
  644.  
  645. def __Channel_OnClickSelectButton(self, index):
  646.  
  647. # import dbg
  648. # dbg.LogBox("%i" % index)
  649.  
  650. if index >= constInfo.SERVER_INFO["channel_count"]:
  651. index = 1
  652.  
  653. # dbg.LogBox("ch:%i , count:%i " % (index,constInfo.SERVER_INFO["channel_count"]))
  654.  
  655. wnd = self.main["channel"]
  656. data = self.data["channel"]
  657. constInfo.CURRENT_ACCOUNT_INFO["ch"] = index
  658.  
  659. for i in xrange(constInfo.SERVER_INFO["channel_count"]):
  660. if i != index:
  661. if not wnd["selectBtnList"][i].IsDisabled():
  662. wnd["selectBtnList"][i].SetUp()
  663. else:
  664. wnd["selectBtnList"][i].Down()
  665.  
  666. data["index"] = index
  667.  
  668. server_info = constInfo.SERVER_INFO
  669. ch_hostname = server_info["data"]["channel%d" % (index + 1)][constInfo.SF_HOSTNAME]
  670. ch_port = server_info["data"]["channel%d" % (index + 1)][constInfo.SF_PORT]
  671. auth_hostname = server_info["data"]["auth"][constInfo.SF_HOSTNAME]
  672. auth_port = server_info["data"]["auth"][constInfo.SF_PORT]
  673.  
  674. self.stream.SetConnectInfo(ch_hostname, ch_port, auth_hostname, auth_port)
  675. cfg.GetRegistry("CH%d" % (index + 1), 412590214)
  676.  
  677. def __Channel_FadeIn(self):
  678. wnd = self.main["channel"]
  679.  
  680. wnd["wnd"].FadeIn(1)
  681.  
  682. def __Channel_FadeOut(self):
  683. wnd = self.main["channel"]
  684.  
  685. wnd["wnd"].Fade(0.3, 1)
  686. ## CHANNEL [END]
  687.  
  688. def OnKeyDown(self, key):
  689. index = key - app.DIK_F1
  690. if index >= 0 and index < 6:
  691.  
  692. self.__Account_OnClickSaveButton(index)
  693.  
  694. def InitServerStateChecker(self):
  695. ServerStateChecker.Initialize()
  696.  
  697. server_info = constInfo.SERVER_INFO
  698. for i in xrange(server_info["channel_count"]):
  699. if (i + 1) != 2:
  700. continue
  701. channelData = server_info["data"]["channel%d" % (i + 1)]
  702. ServerStateChecker.AddChannel(i, channelData[constInfo.SF_HOSTNAME], channelData[constInfo.SF_PORT])
  703.  
  704. def NotifyChannelState(self, channel, state):
  705. self.stateCheckAnswer = TRUE
  706. if state == 0:
  707. for i in xrange(2, constInfo.SERVER_INFO["channel_count"]):
  708. self.__Channel_Disable(i)
  709. else:
  710. for i in xrange(2, constInfo.SERVER_INFO["channel_count"]):
  711. self.__Channel_Enable(i)
  712.  
  713. def Connect(self, id, pwd):
  714. self.__Login_FadeOut()
  715. self.__Channel_FadeOut()
  716. self.windowsHidden = TRUE
  717.  
  718. constInfo.CURRENT_ACCOUNT_INFO["login"] = id
  719. constInfo.CURRENT_ACCOUNT_INFO["passwd"] = pwd
  720.  
  721. net.SetPacketSequenceMode()
  722.  
  723. self.stream.popupWindow.Close()
  724. self.stream.popupEditWindow.Close()
  725. self.stream.popupWindow.Open(localeInfo.LOGIN_CONNETING, self.OnConnectWindowClose, localeInfo.UI_CANCEL)
  726.  
  727. self.stream.SetLoginInfo(id, pwd)
  728. self.stream.Connect()
  729.  
  730. def OnUpdate(self):
  731. if self.lastStateCheck == 0 or app.GetTime() >= self.lastStateCheck + 30:
  732. self.stateCheckAnswer = FALSE
  733. self.InitServerStateChecker()
  734. ServerStateChecker.Request()
  735. self.lastStateCheck = app.GetTime()
  736.  
  737. ServerStateChecker.Update()
  738.  
  739. if app.GetTime() >= self.lastStateCheck + 6 and self.stateCheckAnswer == FALSE:
  740. self.NotifyChannelState(0, 0)
  741. self.stateCheckAnswer = TRUE
  742.  
  743. self.main["logo"].OnUpdate()
  744. self.__Account_OnUpdate()
  745.  
  746. if self.windowsHidden == TRUE and not self.stream.popupWindow.IsShow():
  747. self.__Login_FadeIn()
  748. self.__Channel_FadeIn()
  749. self.windowsHidden = FALSE
  750.  
  751. def OnPressExitKey(self):
  752. app.Exit()
  753.  
  754. ## HWID
  755. def OnHWIDValidateAnswer(self, msg):
  756. try:
  757. validateAnswerMessage = self.hwidAnswerMsgDict[msg]
  758. except KeyError:
  759. validateAnswerMessage = localeInfo.HWID_VALIDATE_UNKNOWN + msg
  760. self.PopupNotifyMessage(validateAnswerMessage)
  761.  
  762. def ValidateAccountHWID(self):
  763. validateKey = self.stream.popupEditWindow.GetInputText()
  764. if len(validateKey) < 5:
  765. self.PopupNotifyMessage(localeInfo.LOGIN_VALIDATE_HWID_FAIL)
  766. return
  767.  
  768. self.stream.popupWindow.Close()
  769. self.stream.popupEditWindow.Close()
  770. self.stream.popupWindow.Open(localeInfo.HWID_CONNECTING, self.OnConnectWindowClose, localeInfo.UI_CANCEL)
  771.  
  772. self.stream.SetHWIDValidateInfo(constInfo.CURRENT_ACCOUNT_INFO["login"], validateKey)
  773. self.stream.Connect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement