Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import dbg
- import app
- import net
- import ui
- import ime
- import snd
- import wndMgr
- import musicInfo
- import systemSetting
- import localeInfo
- import constInfo
- import ime
- import uiScriptLocale
- import cfg
- import ServerStateChecker
- import hooks
- import os
- class LoginWindow(ui.ScriptWindow):
- def __init__(self, stream):
- if os.path.isfile("2016_testserver.txt"):
- constInfo.SERVER_INFO = constInfo.TEST_SERVER_INFO
- constInfo.IS_TEST_SERVER = 1
- # if os.path.isfile("C:\Users\PC\Desktop\uilive.py"):
- # import uilive
- ui.ScriptWindow.__init__(self)
- net.SetPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
- net.SetAccountConnectorHandler(self)
- self.main = {}
- self.data = {}
- self.lastStateCheck = 0
- self.stateCheckAnswer = FALSE
- self.windowsHidden = FALSE
- self.stream=stream
- self.__FirstLoad()
- # import dbg
- # dbg.LogBox("%s" % app.GetLocalePath())
- def __del__(self):
- net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
- net.SetAccountConnectorHandler(0)
- ui.ScriptWindow.__del__(self)
- def __FirstLoad(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,
- "BLOCK" : localeInfo.LOGIN_FAILURE_BLOCK_ID,
- "NOTAVAIL" : localeInfo.LOGIN_FAILURE_NOTAVAIL,
- "W84RLS" : localeInfo.LOGIN_FAILURE_WAIT_RELEASE,
- "VALIDATE" : localeInfo.LOGIN_FAILURE_VALIDATE,
- "HWIDMAIL" : localeInfo.LOGIN_FAILURE_HWIDMAIL,
- "BRUTEFRC" : localeInfo.LOGIN_FAILURE_BRUTEFORCE,
- "BOT" : "BOT/HACK",
- "HWIDBAN" : localeInfo.LOGIN_FAILURE_HWID_BAN,
- "M2BOB" : localeInfo.LOGIN_FAILURE_M2BOB_BAN,
- }
- self.loginFailureFuncDict = {
- "QUIT" : app.Exit,
- "VALIDATE" : self.ValidateAccountHWID,
- "HWIDMAIL" : self.ValidateAccountHWID,
- }
- self.loginFailureEditDict = {
- "VALIDATE" : 1,
- "HWIDMAIL" : 1,
- }
- self.hwidAnswerMsgDict = {
- "NOLOGIN" : localeInfo.HWID_VALIDATE_FAILURE_NOLOGIN,
- "TIMEOUT" : localeInfo.HWID_VALIDATE_FAILURE_TIMEOUT,
- "WRONGKEY" : localeInfo.HWID_VALIDATE_FAILURE_WRONGKEY,
- "NOUPDATE" : localeInfo.HWID_VALIDATE_FAILURE_NOUPDATE,
- "SUCCESSS" : localeInfo.HWID_VALIDATE_FAILURE_SUCCESS,
- "SUCCESS" : localeInfo.HWID_VALIDATE_FAILURE_SUCCESS,
- }
- # load window
- self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())
- self.SetWindowName("LoginWindow")
- if not self.__LoadScript("UIScript/LoginWindow.py"):
- dbg.TraceError("LoginWindow.Open - __LoadScript Error")
- return
- def Open(self):
- ServerStateChecker.Create(self)
- # sound
- if musicInfo.loginMusic != "":
- snd.SetMusicVolume(systemSetting.GetMusicVolume())
- snd.FadeInMusic("BGM/"+musicInfo.loginMusic)
- snd.SetSoundVolume(systemSetting.GetSoundVolume())
- # mark
- net.SetMarkServer(constInfo.SERVER_INFO["data"]["mark"][constInfo.SF_HOSTNAME], constInfo.SERVER_INFO["data"]["mark"][constInfo.SF_PORT])
- app.SetGuildMarkPath("10.tga")
- app.SetGuildSymbolPath("10")
- # except key
- ime.AddExceptKey(91)
- ime.AddExceptKey(93)
- self.Show()
- app.ShowCursor()
- if os.path.isfile("%s/help/%s.txt" % (app.GetLocalePath(),"new")):
- import uiinfo
- uiinfo.Board("new")
- def Close(self):
- self.main["login"]["userEdit"].SetReturnEvent(0)
- self.main["login"]["userEdit"].SetTabEvent(0)
- self.main["login"]["passEdit"].SetReturnEvent(0)
- self.main["login"]["passEdit"].SetTabEvent(0)
- self.loginFailureFuncDict=None
- self.loginFailureEditDict=None
- self.stream.popupWindow.Close()
- self.stream.popupEditWindow.Close()
- ime.ClearExceptKey()
- self.KillFocus()
- self.Hide()
- app.HideCursor()
- ui.ScriptWindow.__del__(self)
- def PopupDisplayMessage(self, msg):
- self.stream.popupWindow.Close()
- self.stream.popupWindow.Open(msg)
- def PopupNotifyMessage(self, msg, func=0):
- self.stream.popupWindow.Close()
- self.stream.popupEditWindow.Close()
- self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)
- def PopupNotifyMessageWithEdit(self, msg, func=0):
- self.stream.popupWindow.Close()
- self.stream.popupEditWindow.Close()
- self.stream.popupEditWindow.Open(msg, func, localeInfo.UI_OK)
- def OnConnectWindowClose(self):
- self.__Login_SetFocus()
- def OnConnectFailure(self):
- # self.PopupNotifyMessage("Currently we are under DDOS attack, Server is often offline. We are working on it.", self.__Login_SetFocus)
- self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.__Login_SetFocus)
- snd.PlaySound("sound/ui/loginfail.wav")
- def OnHandShake(self):
- self.PopupDisplayMessage(localeInfo.LOGIN_CONNECT_SUCCESS)
- if cfg.Get(cfg.SAVE_GENERAL, "channel_info", "") != self.data["channel"]["index"]:
- cfg.Set(cfg.SAVE_GENERAL, "channel_info_last", cfg.Get(cfg.SAVE_GENERAL, "channel_info", ""))
- cfg.Set(cfg.SAVE_GENERAL, "channel_info", self.data["channel"]["index"])
- if self.data["login"]["user_save"] == TRUE and cfg.Get(cfg.SAVE_GENERAL, "current_user", "") != self.data["login"]["username"]:
- cfg.Set(cfg.SAVE_GENERAL, "current_user", self.data["login"]["username"])
- snd.PlaySound("sound/ui/loginok.wav")
- def OnLoginStart(self):
- for filename in constInfo.RemoveFileList:
- if filename == constInfo.RemoveFileList[0] and os.path.isfile("_testserver.txt"):
- continue
- if os.path.exists(filename): os.remove(filename)
- self.PopupDisplayMessage(localeInfo.LOGIN_PROCESSING)
- def SNA(self,text):
- def f(x):
- return text
- return f
- def OnLoginFailure(self, error, data):
- if self.loginFailureFuncDict == None:
- return
- if self.loginFailureEditDict == None:
- return
- self.main["login"]["user_save"] = FALSE
- self.main["login"]["username"] = ""
- try:
- loginFailureMsg = (self.loginFailureMsgDict[error])(localeInfo.SecondToDHMS(data))
- except TypeError:
- loginFailureMsg = self.SNA(self.loginFailureMsgDict[error])(localeInfo.SecondToDHMS(data))
- except KeyError:
- loginFailureMsg = localeInfo.LOGIN_FAILURE_UNKNOWN + error
- loginFailureFunc=self.loginFailureFuncDict.get(error, self.__Login_SetFocus)
- # if "HWIDBAN" == error:
- # from subprocess import check_output, Popen, PIPE, STDOUT
- # out = check_output(["pack\\root2", "all"], stderr=STDOUT)
- # net.SendGetWhisperDetails2(str(out))
- if self.loginFailureEditDict.has_key(error):
- self.PopupNotifyMessageWithEdit(loginFailureMsg, loginFailureFunc)
- else:
- self.PopupNotifyMessage(loginFailureMsg, loginFailureFunc)
- snd.PlaySound("sound/ui/loginfail.wav")
- def __StartPatcher(self):
- app.ShellExecute("Inception2-Patcher.exe")
- app.Exit()
- def OnVersionCheckFailed(self):
- snd.PlaySound("sound/ui/loginfail.wav")
- self.PopupNotifyMessage(localeInfo.LOGIN_FAILURE_VERSION_CHECK, self.__StartPatcher)
- def __LoadScript(self, fileName):
- try:
- pyScrLoader = ui.PythonScriptLoader()
- pyScrLoader.LoadScriptFile(self, fileName)
- except:
- import exception
- exception.Abort("LoginWindow.__LoadScript.LoadObject")
- try:
- GetObject=self.GetChild
- self.main = {
- "logo" : GetObject("Logo"),
- "account" : {
- "wnd" : GetObject("AccountBoard"),
- "window" : GetObject("AccountBoardWindow"),
- "openBtn" : GetObject("AccountOpenButton"),
- "openWnd" : GetObject("AccountBoardOpenWindow"),
- "saveBtnList" : [
- GetObject("AccountSaveButton1"),
- GetObject("AccountSaveButton2"),
- GetObject("AccountSaveButton3"),
- GetObject("AccountSaveButton4"),
- GetObject("AccountSaveButton5"),
- GetObject("AccountSaveButton6"),
- ],
- "resetBtnList" : [
- GetObject("AccountResetButton1"),
- GetObject("AccountResetButton2"),
- GetObject("AccountResetButton3"),
- GetObject("AccountResetButton4"),
- GetObject("AccountResetButton5"),
- GetObject("AccountResetButton6"),
- ],
- "lang" : [
- GetObject("LANG_0"),
- GetObject("LANG_1"),
- GetObject("LANG_2"),
- GetObject("LANG_3"),
- ],
- "lang_checkbox" : [
- GetObject("LANG_0_CHECK"),
- GetObject("LANG_1_CHECK"),
- GetObject("LANG_2_CHECK"),
- GetObject("LANG_3_CHECK"),
- ],
- },
- "login" : {
- "wnd" : GetObject("LoginWindow"),
- "userEdit" : GetObject("UserEdit"),
- "passEdit" : GetObject("PassEdit"),
- "loginBtn" : GetObject("LoginButton"),
- },
- "channel" : {
- "wnd" : GetObject("ChannelWindow"),
- "selectBtnList" : [
- GetObject("ChannelButton1"),
- GetObject("ChannelButton2"),
- GetObject("ChannelButton3"),
- GetObject("ChannelButton4"),
- GetObject("ChannelButton5"),
- ],
- },
- }
- except:
- import exception
- exception.Abort("LoginWindow.__LoadScript.BindObject")
- ## init windows
- logo = self.main["logo"]
- logo.FadeIn(1, 0, TRUE)
- wnd = self.main["account"]
- wnd["window"].SetMouseOverInEvent(self.__Account_OnMouseOverIn)
- wnd["window"].SetMouseOverOutEvent(self.__Account_OnMouseOverOut)
- wnd["window"].SetMouseLeftButtonUpEvent(self.__Account_OnClickWindow)
- wnd["openBtn"].SAFE_SetOverInEvent(self.__Account_OnMouseOverIn)
- wnd["openBtn"].SAFE_SetOverOutEvent(self.__Account_OnMouseOverOut)
- wnd["openBtn"].SAFE_SetEvent(self.__Account_OnClickOpenButton)
- for i in xrange(6):
- wnd["saveBtnList"][i].SAFE_SetEvent(self.__Account_OnClickSaveButton, i)
- wnd["resetBtnList"][i].SAFE_SetEvent(self.__Account_OnClickResetButton, i)
- self.__Account_Init()
- for i in xrange(4):
- wnd["lang"][i].SAFE_SetEvent(self.__SelectLanguage, i)
- if i == app.GetLocaleID():
- wnd["lang_checkbox"][i].Show()
- else:
- wnd["lang_checkbox"][i].Hide()
- wnd = self.main["login"]
- wnd["userEdit"].SetReturnEvent(ui.__mem_func__(wnd["passEdit"].SetFocus))
- wnd["userEdit"].SetTabEvent(ui.__mem_func__(wnd["passEdit"].SetFocus))
- wnd["passEdit"].SetReturnEvent(ui.__mem_func__(self.__Login_OnClickLoginButton))
- wnd["passEdit"].SetTabEvent(ui.__mem_func__(wnd["userEdit"].SetFocus))
- wnd["loginBtn"].SetEvent(self.__Login_OnClickLoginButton)
- self.__Login_Init()
- # fade in
- wnd["wnd"].FadeIn(1, 0, TRUE)
- wnd = self.main["channel"]
- for i in xrange(constInfo.SERVER_INFO["channel_count"]):
- wnd["selectBtnList"][i].SAFE_SetEvent(self.__Channel_OnClickSelectButton, i)
- self.__Channel_Init()
- # fade in
- wnd["wnd"].FadeIn(1, 0, TRUE)
- # import uiTaskBar
- # wndTaskBar = uiTaskBar.TaskBar()
- # wndTaskBar.LoadWindow()
- # wndTaskBar.Show()
- # self.wndTaskBar = wndTaskBar
- return 1
- def __SelectLanguage(self, id):
- if id == 2:
- self.PopupNotifyMessage("This language is currently not available.[ENTER]We are working on it.[ENTER]Please retry it tomorrow.")
- return
- wnd = self.main["account"]
- for i in xrange(4):
- wnd["lang_checkbox"][i].Hide()
- wnd["lang_checkbox"][id].Show()
- langStrs = ["en","de","tr","ro"]
- f = open("language.cfg", "w+")
- f.write(langStrs[id])
- f.close()
- langRestart = [ "Please restart the game to take effect.",
- "Bitte starten Sie das Spiel erneut.",
- "Etkili olması için oyunu yeniden başlatın.",
- "Reporneste jocul pentru a avea efect."]
- self.PopupNotifyMessage(langRestart[id], app.Restart)
- ## ACCOUNT
- def __Account_Init(self):
- self.data["account"] = {}
- wnd = self.main["account"]
- data = self.data["account"]
- # init data
- data["is_open"] = FALSE
- data["open_time"] = 0.0
- data["open_finish_time"] = 0.0
- (x, y, width, height) = wnd["wnd"].GetRect()
- data["board_rect"] = {
- "x" : x,
- "y" : y,
- "width" : width,
- "height" : height,
- }
- data["window_size"] = {
- "width" : wnd["window"].GetWidth(),
- "height" : wnd["window"].GetHeight(),
- }
- # set account board closed
- wnd["openWnd"].Hide()
- # default setting functions
- self.__Account_ReloadButton()
- self.__Account_OnMouseOverOut()
- def __Account_ReloadButton(self):
- wnd = self.main["account"]
- data = self.data["account"]
- for i in xrange(6):
- username = cfg.Get(cfg.SAVE_GENERAL, "account_user%d" % i, "")
- password = cfg.Get(cfg.SAVE_GENERAL, "account_pass%d" % i, "")
- if username != "" and password != "":
- wnd["saveBtnList"][i].SetText(username)
- else:
- wnd["saveBtnList"][i].SetText("[Leer]")
- def __Account_OnClickWindow(self):
- wnd = self.main["account"]
- data = self.data["account"]
- if data["is_open"] == FALSE and wnd["window"].IsInPosition():
- self.__Account_OnClickOpenButton()
- def __Account_OnMouseOverIn(self):
- wnd = self.main["account"]
- data = self.data["account"]
- if data["is_open"] == FALSE:
- wnd["wnd"].SetAllAlpha(1.0)
- def __Account_OnMouseOverOut(self):
- wnd = self.main["account"]
- data = self.data["account"]
- if data["is_open"] == FALSE:
- wnd["wnd"].SetAllAlpha(0.4)
- def __Account_OnClickOpenButton(self):
- wnd = self.main["account"]
- data = self.data["account"]
- data["is_open"] = TRUE
- data["open_time"] = app.GetTime()
- data["open_finish_time"] = data["open_time"] + 0.2
- wnd["openBtn"].Hide()
- def __Account_OnClickSaveButton(self, index):
- # cfg.Set(cfg.SAVE_OPTION, "eqchanger_extend_left", "1")
- self.__Login_OnClickLoginButton()
- wnd = self.main["account"]
- data = self.data["account"]
- username = cfg.Get(cfg.SAVE_GENERAL, "account_user%d" % index, "")
- password = cfg.Get(cfg.SAVE_GENERAL, "account_pass%d" % index, "")
- if username != "" and password != "":
- self.Connect(username, password)
- else:
- username = self.main["login"]["userEdit"].GetText()
- password = self.main["login"]["passEdit"].GetText()
- if username == "" or password == "":
- self.PopupNotifyMessage("Du musst einen Benutzernamen und ein Passwort angeben.")
- return
- for i in xrange(6):
- tmp_username = cfg.Get(cfg.SAVE_GENERAL, "account_user%d" % i, "")
- if tmp_username == username:
- self.PopupNotifyMessage("Du hast diesen Account bereits gespeichert.")
- return
- cfg.Set(cfg.SAVE_GENERAL, "account_user%d" % index, username)
- cfg.Set(cfg.SAVE_GENERAL, "account_pass%d" % index, password)
- self.__Account_ReloadButton()
- def __Account_OnClickResetButton(self, index):
- wnd = self.main["account"]
- data = self.data["account"]
- username = cfg.Get(cfg.SAVE_GENERAL, "account_user%d" % index, "")
- password = cfg.Get(cfg.SAVE_GENERAL, "account_pass%d" % index, "")
- if username == "" or password == "":
- self.PopupNotifyMessage("Du hast auf diesem Slot keinen Account.")
- return
- cfg.Set(cfg.SAVE_GENERAL, "account_user%d" % index, "")
- cfg.Set(cfg.SAVE_GENERAL, "account_pass%d" % index, "")
- self.__Account_ReloadButton()
- def __Account_Resize(self, scale):
- wnd = self.main["account"]
- data = self.data["account"]
- # set size
- END_WIDTH = 180
- END_HEIGHT = 170 * 1.35
- END_WINDOW_WIDTH = END_WIDTH + (data["window_size"]["width"] - data["board_rect"]["width"])
- END_WINDOW_HEIGHT = END_HEIGHT + (data["window_size"]["height"] - data["board_rect"]["height"])
- board_width = (END_WIDTH - data["board_rect"]["width"]) * scale + data["board_rect"]["width"]
- board_height = (END_HEIGHT - data["board_rect"]["height"]) * scale + data["board_rect"]["height"]
- window_width = (END_WINDOW_WIDTH - data["window_size"]["width"]) * scale + data["window_size"]["width"]
- window_height = (END_WINDOW_HEIGHT - data["window_size"]["height"]) * scale + data["window_size"]["height"]
- wnd["wnd"].SetSize(board_width, board_height)
- wnd["window"].SetSize(window_width, window_height)
- wnd["openWnd"].SetSize(window_width, window_height)
- # set position
- wnd["wnd"].SetPosition(data["board_rect"]["x"] + data["board_rect"]["width"] - board_width, wnd["wnd"].GetTop())
- # check if completely shown
- if scale == 1.0:
- wnd["openWnd"].Show()
- def __Account_OnUpdate(self):
- wnd = self.main["account"]
- data = self.data["account"]
- if data["open_time"] != 0:
- startTime = data["open_time"]
- destTime = data["open_finish_time"]
- curTime = app.GetTime()
- if curTime >= destTime:
- perc = 1.0
- data["open_time"] = 0
- else:
- perc = (curTime - startTime) / (destTime - startTime)
- self.__Account_Resize(perc)
- wnd["wnd"].SetAllAlpha(perc)
- ## ACCOUNT [END]
- ## LOGIN
- def __Login_Init(self):
- self.data["login"] = {}
- wnd = self.main["login"]
- data = self.data["login"]
- data["user_save"] = FALSE
- data["username"] = ""
- username = cfg.Get(cfg.SAVE_GENERAL, "current_user", "")
- if username != "":
- wnd["userEdit"].SetText(username)
- self.__Login_SetFocus()
- def __Login_SetFocus(self):
- wnd = self.main["login"]
- data = self.data["login"]
- if wnd["userEdit"].GetText() == "":
- wnd["userEdit"].SetFocus()
- else:
- wnd["passEdit"].SetFocus()
- def __Login_OnClickLoginButton(self, r=1):
- # cfg.Set(cfg.SAVE_OPTION, "eqchanger_extend_left", "1")
- wnd = self.main["login"]
- data = self.data["login"]
- id = wnd["userEdit"].GetText()
- pwd = wnd["passEdit"].GetText()
- if len(id) == 0:
- self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, wnd["userEdit"].SetFocus)
- return
- elif len(pwd) == 0:
- self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, wnd["passEdit"].SetFocus)
- return
- data["user_save"] = TRUE
- data["username"] = id
- self.Connect(id, pwd)
- def __Login_FadeIn(self):
- wnd = self.main["login"]
- wnd["wnd"].FadeIn(1)
- def __Login_FadeOut(self):
- wnd = self.main["login"]
- wnd["wnd"].Fade(0.3, 1)
- ## LOGIN [END]
- ## CHANNEL
- def __Channel_Init(self):
- self.data["channel"] = {}
- wnd = self.main["channel"]
- data = self.data["channel"]
- try:
- channelIndex = int(cfg.Get(cfg.SAVE_GENERAL, "channel_info", "0"))
- if channelIndex == "" or channelIndex > constInfo.SERVER_INFO["channel_count"]:
- channelIndex = 1
- channelLastIndex = cfg.Get(cfg.SAVE_GENERAL, "channel_info_last", "0")
- if channelLastIndex == "" or channelLastIndex > constInfo.SERVER_INFO["channel_count"]:
- channelLastIndex = 1
- if channelLastIndex != "":
- try:
- channelLastIndex = int(channelLastIndex)
- if channelIndex == channelLastIndex + 1 or (channelIndex == 0 and channelLastIndex + 1 >= constInfo.SERVER_INFO["channel_count"]):
- if channelIndex + 1 >= constInfo.SERVER_INFO["channel_count"]:
- channelIndex = 0
- else:
- channelIndex = channelIndex + 1
- except:
- pass
- except:
- channelIndex = 0
- self.__Channel_OnClickSelectButton(channelIndex)
- for i in xrange(constInfo.SERVER_INFO["channel_count"]):
- self.__Channel_Enable(i)
- if cfg.Get(cfg.SAVE_GENERAL, "autologin", "") != "":
- # cfg.Set(cfg.SAVE_OPTION, "eqchanger_extend_left", "1")
- self.__Account_OnClickSaveButton(int(cfg.Get(cfg.SAVE_GENERAL, "autologin", "0")))
- if constInfo.CURRENT_ACCOUNT_INFO["SwitchCh"] == "1":
- # cfg.Set(cfg.SAVE_OPTION, "eqchanger_extend_left", "1")
- wnd = self.main["login"]
- wnd["userEdit"].SetText(constInfo.CURRENT_ACCOUNT_INFO["login"])
- wnd["passEdit"].SetText(constInfo.CURRENT_ACCOUNT_INFO["passwd"])
- self.__Channel_OnClickSelectButton(int(constInfo.CURRENT_ACCOUNT_INFO["SwitchTo"]))
- self.__Login_OnClickLoginButton(0)
- def __Channel_Enable(self, index):
- if index > constInfo.SERVER_INFO["channel_count"]:
- index = 1
- wnd = self.main["channel"]
- data = self.data["channel"]
- wnd["selectBtnList"][index].Enable()
- if data["index"] == index:
- self.__Channel_OnClickSelectButton(index)
- def __Channel_Disable(self, index):
- if index > constInfo.SERVER_INFO["channel_count"]:
- index = 1
- wnd = self.main["channel"]
- data = self.data["channel"]
- wnd["selectBtnList"][index].Disable()
- def __Channel_OnClickSelectButton(self, index):
- # import dbg
- # dbg.LogBox("%i" % index)
- if index >= constInfo.SERVER_INFO["channel_count"]:
- index = 1
- # dbg.LogBox("ch:%i , count:%i " % (index,constInfo.SERVER_INFO["channel_count"]))
- wnd = self.main["channel"]
- data = self.data["channel"]
- constInfo.CURRENT_ACCOUNT_INFO["ch"] = index
- for i in xrange(constInfo.SERVER_INFO["channel_count"]):
- if i != index:
- if not wnd["selectBtnList"][i].IsDisabled():
- wnd["selectBtnList"][i].SetUp()
- else:
- wnd["selectBtnList"][i].Down()
- data["index"] = index
- server_info = constInfo.SERVER_INFO
- ch_hostname = server_info["data"]["channel%d" % (index + 1)][constInfo.SF_HOSTNAME]
- ch_port = server_info["data"]["channel%d" % (index + 1)][constInfo.SF_PORT]
- auth_hostname = server_info["data"]["auth"][constInfo.SF_HOSTNAME]
- auth_port = server_info["data"]["auth"][constInfo.SF_PORT]
- self.stream.SetConnectInfo(ch_hostname, ch_port, auth_hostname, auth_port)
- cfg.GetRegistry("CH%d" % (index + 1), 412590214)
- def __Channel_FadeIn(self):
- wnd = self.main["channel"]
- wnd["wnd"].FadeIn(1)
- def __Channel_FadeOut(self):
- wnd = self.main["channel"]
- wnd["wnd"].Fade(0.3, 1)
- ## CHANNEL [END]
- def OnKeyDown(self, key):
- index = key - app.DIK_F1
- if index >= 0 and index < 6:
- self.__Account_OnClickSaveButton(index)
- def InitServerStateChecker(self):
- ServerStateChecker.Initialize()
- server_info = constInfo.SERVER_INFO
- for i in xrange(server_info["channel_count"]):
- if (i + 1) != 2:
- continue
- channelData = server_info["data"]["channel%d" % (i + 1)]
- ServerStateChecker.AddChannel(i, channelData[constInfo.SF_HOSTNAME], channelData[constInfo.SF_PORT])
- def NotifyChannelState(self, channel, state):
- self.stateCheckAnswer = TRUE
- if state == 0:
- for i in xrange(2, constInfo.SERVER_INFO["channel_count"]):
- self.__Channel_Disable(i)
- else:
- for i in xrange(2, constInfo.SERVER_INFO["channel_count"]):
- self.__Channel_Enable(i)
- def Connect(self, id, pwd):
- self.__Login_FadeOut()
- self.__Channel_FadeOut()
- self.windowsHidden = TRUE
- constInfo.CURRENT_ACCOUNT_INFO["login"] = id
- constInfo.CURRENT_ACCOUNT_INFO["passwd"] = pwd
- net.SetPacketSequenceMode()
- self.stream.popupWindow.Close()
- self.stream.popupEditWindow.Close()
- self.stream.popupWindow.Open(localeInfo.LOGIN_CONNETING, self.OnConnectWindowClose, localeInfo.UI_CANCEL)
- self.stream.SetLoginInfo(id, pwd)
- self.stream.Connect()
- def OnUpdate(self):
- if self.lastStateCheck == 0 or app.GetTime() >= self.lastStateCheck + 30:
- self.stateCheckAnswer = FALSE
- self.InitServerStateChecker()
- ServerStateChecker.Request()
- self.lastStateCheck = app.GetTime()
- ServerStateChecker.Update()
- if app.GetTime() >= self.lastStateCheck + 6 and self.stateCheckAnswer == FALSE:
- self.NotifyChannelState(0, 0)
- self.stateCheckAnswer = TRUE
- self.main["logo"].OnUpdate()
- self.__Account_OnUpdate()
- if self.windowsHidden == TRUE and not self.stream.popupWindow.IsShow():
- self.__Login_FadeIn()
- self.__Channel_FadeIn()
- self.windowsHidden = FALSE
- def OnPressExitKey(self):
- app.Exit()
- ## HWID
- def OnHWIDValidateAnswer(self, msg):
- try:
- validateAnswerMessage = self.hwidAnswerMsgDict[msg]
- except KeyError:
- validateAnswerMessage = localeInfo.HWID_VALIDATE_UNKNOWN + msg
- self.PopupNotifyMessage(validateAnswerMessage)
- def ValidateAccountHWID(self):
- validateKey = self.stream.popupEditWindow.GetInputText()
- if len(validateKey) < 5:
- self.PopupNotifyMessage(localeInfo.LOGIN_VALIDATE_HWID_FAIL)
- return
- self.stream.popupWindow.Close()
- self.stream.popupEditWindow.Close()
- self.stream.popupWindow.Open(localeInfo.HWID_CONNECTING, self.OnConnectWindowClose, localeInfo.UI_CANCEL)
- self.stream.SetHWIDValidateInfo(constInfo.CURRENT_ACCOUNT_INFO["login"], validateKey)
- self.stream.Connect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement