Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ######################################## AICI INCEPE TREABA ######################################## ORA: 21:36
- import app, net, ui, snd, wndMgr, musicInfo, systemSetting, localeInfo, constInfo, ime
- from _weakref import proxy
- SERVER_IP = "192.168.1.5"
- CH1_PORT = 21000
- CH2_PORT = 22000
- CH3_PORT = 23000
- CH4_PORT = 24000
- PORT_AUTH = 31009
- NUME_SERVER = "Andy"
- class LoginWindow(ui.ScriptWindow):
- def __init__(self, stream):
- ui.ScriptWindow.__init__(self)
- net.SetPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
- net.SetAccountConnectorHandler(self)
- self.stream = stream
- def __del__(self):
- ui.ScriptWindow.__del__(self)
- net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
- net.SetAccountConnectorHandler(0)
- def Open(self):
- self.loginFailureMsgDict={
- "ALREADY" : localeInfo.LOGIN_FAILURE_ALREAY,
- "NOID" : localeInfo.LOGIN_FAILURE_NOT_EXIST_ID,
- "WRONGPWD" : localeInfo.LOGIN_FAILURE_WRONG_PASSWORD,
- "FULL" : localeInfo.LOGIN_FAILURE_TOO_MANY_USER,
- "SHUTDOWN" : localeInfo.LOGIN_FAILURE_SHUTDOWN,
- "REPAIR" : localeInfo.LOGIN_FAILURE_REPAIR_ID,
- "BLOCK" : localeInfo.LOGIN_FAILURE_BLOCK_ID,
- "WRONGMAT" : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER,
- "QUIT" : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER_TRIPLE,
- "BESAMEKEY" : localeInfo.LOGIN_FAILURE_BE_SAME_KEY,
- "NOTAVAIL" : localeInfo.LOGIN_FAILURE_NOT_AVAIL,
- "NOBILL" : localeInfo.LOGIN_FAILURE_NOBILL,
- "BLKLOGIN" : localeInfo.LOGIN_FAILURE_BLOCK_LOGIN,
- "WEBBLK" : localeInfo.LOGIN_FAILURE_WEB_BLOCK,
- }
- self.loginFailureFuncDict = {
- "WRONGPWD" : localeInfo.LOGIN_FAILURE_WRONG_PASSWORD,
- "WRONGMAT" : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER,
- "QUIT" : app.Exit,
- }
- self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())
- self.SetWindowName("LoginWindow")
- self.__LoadScript("loginwindow_new/loginwindow.py")
- if musicInfo.loginMusic != "":
- snd.SetMusicVolume(systemSetting.GetMusicVolume())
- snd.FadeInMusic("BGM/" + musicInfo.loginMusic)
- snd.SetSoundVolume(systemSetting.GetSoundVolume())
- ime.AddExceptKey(91)
- ime.AddExceptKey(93)
- self.SetChannel(0)
- self.Show()
- app.ShowCursor()
- def Close(self):
- if musicInfo.loginMusic != "" and musicInfo.selectMusic != "":
- snd.FadeOutMusic("BGM/"+musicInfo.loginMusic)
- if self.stream.popupWindow:
- self.stream.popupWindow.Close()
- self.Hide()
- app.HideCursor()
- ime.ClearExceptKey()
- def OnConnectFailure(self):
- snd.PlaySound("sound/ui/loginfail.wav")
- self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.EmptyFunc)
- def OnHandShake(self):
- snd.PlaySound("sound/ui/loginok.wav")
- self.PopupDisplayMessage(localeInfo.LOGIN_CONNECT_SUCCESS)
- def OnLoginStart(self):
- self.PopupDisplayMessage(localeInfo.LOGIN_PROCESSING)
- def OnLoginFailure(self, error):
- try:
- loginFailureMsg = self.loginFailureMsgDict[error]
- except KeyError:
- loginFailureMsg = localeInfo.LOGIN_FAILURE_UNKNOWN + error
- loginFailureFunc = self.loginFailureFuncDict.get(error, self.EmptyFunc)
- self.PopupNotifyMessage(loginFailureMsg, loginFailureFunc)
- snd.PlaySound("sound/ui/loginfail.wav")
- def __LoadScript(self, fileName):
- try:
- pyScrLoader = ui.PythonScriptLoader()
- pyScrLoader.LoadScriptFile(self, fileName)
- except:
- import exception
- exception.Abort("LoginWindow.__LoadScript.LoadObject")
- try:
- self.idEditLine = self.GetChild("id")
- self.pwdEditLine = self.GetChild("pwd")
- self.loginButton = self.GetChild("login_button")
- self.exitButton = self.GetChild("exit_button")
- self.websiteButton = self.GetChild("website_button")
- self.parolauitataButton = self.GetChild("parolauitata_button")
- self.registerButton = self.GetChild("register_button")
- self.channelButton = {
- 0 : self.GetChild("ch1"),
- 1 : self.GetChild("ch2"),
- 2 : self.GetChild("ch3"),
- 3 : self.GetChild("ch4")}
- except:
- import exception
- exception.Abort("LoginWindow.__LoadScript.BindObject")
- for (channelID, channelButtons) in self.channelButton.items():
- channelButtons.SetEvent(ui.__mem_func__(self.SetChannel), channelID)
- self.loginButton.SetEvent(ui.__mem_func__(self.__OnClickLoginButton))
- self.exitButton.SetEvent(ui.__mem_func__(self.OnPressExitKey))
- self.websiteButton.SetEvent(ui.__mem_func__(self.GoWebSite))
- self.parolauitataButton.SetEvent(ui.__mem_func__(self.GoParolaUitata))
- self.registerButton.SetEvent(ui.__mem_func__(self.GoRegister))
- self.idEditLine.SetReturnEvent(ui.__mem_func__(self.pwdEditLine.SetFocus))
- self.idEditLine.SetTabEvent(ui.__mem_func__(self.pwdEditLine.SetFocus))
- self.pwdEditLine.SetReturnEvent(ui.__mem_func__(self.__OnClickLoginButton))
- self.pwdEditLine.SetTabEvent(ui.__mem_func__(self.idEditLine.SetFocus))
- self.idEditLine.SetFocus()
- def SetChannel(self, ch):
- for key, button in self.channelButton.items():
- button.SetUp()
- self.channelButton[ch].Down()
- self.stream.SetConnectInfo(SERVER_IP, self.ChannelPort(ch, 0), SERVER_IP, self.ChannelPort("LOGIN"))
- net.SetMarkServer(SERVER_IP, self.ChannelPort("LOGO"))
- app.SetGuildMarkPath("10.tga")
- app.SetGuildSymbolPath("10")
- net.SetServerInfo(self.ChannelPort(ch, 2))
- def ChannelPort(self, ch, value=0):
- channel = {
- 0 : CH1_PORT,
- 1 : CH2_PORT,
- 2 : CH3_PORT,
- 3 : CH4_PORT,}
- if ch == "LOGIN":
- return PORT_AUTH
- elif ch == "LOGO":
- return channel[0]
- elif value == 2:
- return NUME_SERVER + ", CH%s" % (ch+1)
- else:
- return channel[ch]
- def Connect(self, id, pwd):
- if constInfo.SEQUENCE_PACKET_ENABLE:
- net.SetPacketSequenceMode()
- constInfo.LastAccount = id.lower()
- self.stream.popupWindow.Close()
- self.stream.popupWindow.Open(localeInfo.LOGIN_CONNETING, self.EmptyFunc, localeInfo.UI_CANCEL)
- self.stream.SetLoginInfo(id, pwd)
- self.stream.Connect()
- def PopupDisplayMessage(self, msg):
- self.stream.popupWindow.Close()
- self.stream.popupWindow.Open(msg)
- def PopupNotifyMessage(self, msg, func=0):
- if not func:
- func = self.EmptyFunc
- self.stream.popupWindow.Close()
- self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)
- def OnPressExitKey(self):
- if self.stream.popupWindow:
- self.stream.popupWindow.Close()
- self.stream.SetPhaseWindow(0)
- return TRUE
- ## BUTOANE PENTRU LINKURI ##
- def GoWebSite(self):
- import os
- os.system('@echo off && explorer "https://metin2.pw/"')
- return TRUE
- def GoParolaUitata(self):
- import os
- os.system('@echo off && explorer "https://metin2.pw/index.php?s=passwordlost"')
- return TRUE
- def GoRegister(self):
- import os
- os.system('@echo off && explorer "https://metin2.pw/?s=Inregistrare"')
- return TRUE
- ############################
- def EmptyFunc(self):
- pass
- def __OnClickLoginButton(self):
- id = self.idEditLine.GetText()
- pwd = self.pwdEditLine.GetText()
- if len(id)==0:
- self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, self.EmptyFunc)
- return
- if len(pwd)==0:
- self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, self.EmptyFunc)
- return
- self.Connect(id, pwd)
- ######################################## INSFARIST GATA ######################################## ORA: 01:45
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement