Advertisement
Guest User

new intrologin

a guest
Feb 20th, 2022
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.24 KB | None | 0 0
  1. ######################################## AICI INCEPE TREABA ######################################## ORA: 21:36
  2. import app, net, ui, snd, wndMgr, musicInfo, systemSetting, localeInfo, constInfo, ime
  3. from _weakref import proxy
  4.  
  5. SERVER_IP = "192.168.1.5"
  6. CH1_PORT = 21000
  7. CH2_PORT = 22000
  8. CH3_PORT = 23000
  9. CH4_PORT = 24000
  10. PORT_AUTH = 31009
  11. NUME_SERVER = "Andy"
  12.  
  13. class LoginWindow(ui.ScriptWindow):
  14. def __init__(self, stream):
  15. ui.ScriptWindow.__init__(self)
  16.  
  17. net.SetPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
  18. net.SetAccountConnectorHandler(self)
  19.  
  20. self.stream = stream
  21.  
  22. def __del__(self):
  23. ui.ScriptWindow.__del__(self)
  24.  
  25. net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
  26. net.SetAccountConnectorHandler(0)
  27.  
  28. def Open(self):
  29. self.loginFailureMsgDict={
  30.  
  31. "ALREADY" : localeInfo.LOGIN_FAILURE_ALREAY,
  32. "NOID" : localeInfo.LOGIN_FAILURE_NOT_EXIST_ID,
  33. "WRONGPWD" : localeInfo.LOGIN_FAILURE_WRONG_PASSWORD,
  34. "FULL" : localeInfo.LOGIN_FAILURE_TOO_MANY_USER,
  35. "SHUTDOWN" : localeInfo.LOGIN_FAILURE_SHUTDOWN,
  36. "REPAIR" : localeInfo.LOGIN_FAILURE_REPAIR_ID,
  37. "BLOCK" : localeInfo.LOGIN_FAILURE_BLOCK_ID,
  38. "WRONGMAT" : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER,
  39. "QUIT" : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER_TRIPLE,
  40. "BESAMEKEY" : localeInfo.LOGIN_FAILURE_BE_SAME_KEY,
  41. "NOTAVAIL" : localeInfo.LOGIN_FAILURE_NOT_AVAIL,
  42. "NOBILL" : localeInfo.LOGIN_FAILURE_NOBILL,
  43. "BLKLOGIN" : localeInfo.LOGIN_FAILURE_BLOCK_LOGIN,
  44. "WEBBLK" : localeInfo.LOGIN_FAILURE_WEB_BLOCK,
  45. }
  46.  
  47. self.loginFailureFuncDict = {
  48. "WRONGPWD" : localeInfo.LOGIN_FAILURE_WRONG_PASSWORD,
  49. "WRONGMAT" : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER,
  50. "QUIT" : app.Exit,
  51. }
  52.  
  53. self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())
  54. self.SetWindowName("LoginWindow")
  55.  
  56. self.__LoadScript("loginwindow_new/loginwindow.py")
  57.  
  58. if musicInfo.loginMusic != "":
  59. snd.SetMusicVolume(systemSetting.GetMusicVolume())
  60. snd.FadeInMusic("BGM/" + musicInfo.loginMusic)
  61.  
  62. snd.SetSoundVolume(systemSetting.GetSoundVolume())
  63.  
  64. ime.AddExceptKey(91)
  65. ime.AddExceptKey(93)
  66. self.SetChannel(0)
  67.  
  68. self.Show()
  69. app.ShowCursor()
  70.  
  71. def Close(self):
  72. if musicInfo.loginMusic != "" and musicInfo.selectMusic != "":
  73. snd.FadeOutMusic("BGM/"+musicInfo.loginMusic)
  74.  
  75. if self.stream.popupWindow:
  76. self.stream.popupWindow.Close()
  77.  
  78. self.Hide()
  79. app.HideCursor()
  80. ime.ClearExceptKey()
  81.  
  82. def OnConnectFailure(self):
  83. snd.PlaySound("sound/ui/loginfail.wav")
  84. self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.EmptyFunc)
  85.  
  86. def OnHandShake(self):
  87. snd.PlaySound("sound/ui/loginok.wav")
  88. self.PopupDisplayMessage(localeInfo.LOGIN_CONNECT_SUCCESS)
  89.  
  90. def OnLoginStart(self):
  91. self.PopupDisplayMessage(localeInfo.LOGIN_PROCESSING)
  92.  
  93. def OnLoginFailure(self, error):
  94. try:
  95. loginFailureMsg = self.loginFailureMsgDict[error]
  96. except KeyError:
  97.  
  98. loginFailureMsg = localeInfo.LOGIN_FAILURE_UNKNOWN + error
  99.  
  100. loginFailureFunc = self.loginFailureFuncDict.get(error, self.EmptyFunc)
  101.  
  102. self.PopupNotifyMessage(loginFailureMsg, loginFailureFunc)
  103.  
  104. snd.PlaySound("sound/ui/loginfail.wav")
  105.  
  106. def __LoadScript(self, fileName):
  107. try:
  108. pyScrLoader = ui.PythonScriptLoader()
  109. pyScrLoader.LoadScriptFile(self, fileName)
  110. except:
  111. import exception
  112. exception.Abort("LoginWindow.__LoadScript.LoadObject")
  113.  
  114. try:
  115. self.idEditLine = self.GetChild("id")
  116. self.pwdEditLine = self.GetChild("pwd")
  117. self.loginButton = self.GetChild("login_button")
  118. self.exitButton = self.GetChild("exit_button")
  119. self.websiteButton = self.GetChild("website_button")
  120. self.parolauitataButton = self.GetChild("parolauitata_button")
  121. self.registerButton = self.GetChild("register_button")
  122.  
  123. self.channelButton = {
  124. 0 : self.GetChild("ch1"),
  125. 1 : self.GetChild("ch2"),
  126. 2 : self.GetChild("ch3"),
  127. 3 : self.GetChild("ch4")}
  128.  
  129.  
  130. except:
  131. import exception
  132. exception.Abort("LoginWindow.__LoadScript.BindObject")
  133.  
  134.  
  135. for (channelID, channelButtons) in self.channelButton.items():
  136. channelButtons.SetEvent(ui.__mem_func__(self.SetChannel), channelID)
  137.  
  138. self.loginButton.SetEvent(ui.__mem_func__(self.__OnClickLoginButton))
  139. self.exitButton.SetEvent(ui.__mem_func__(self.OnPressExitKey))
  140. self.websiteButton.SetEvent(ui.__mem_func__(self.GoWebSite))
  141. self.parolauitataButton.SetEvent(ui.__mem_func__(self.GoParolaUitata))
  142. self.registerButton.SetEvent(ui.__mem_func__(self.GoRegister))
  143.  
  144. self.idEditLine.SetReturnEvent(ui.__mem_func__(self.pwdEditLine.SetFocus))
  145. self.idEditLine.SetTabEvent(ui.__mem_func__(self.pwdEditLine.SetFocus))
  146. self.pwdEditLine.SetReturnEvent(ui.__mem_func__(self.__OnClickLoginButton))
  147. self.pwdEditLine.SetTabEvent(ui.__mem_func__(self.idEditLine.SetFocus))
  148. self.idEditLine.SetFocus()
  149.  
  150.  
  151. def SetChannel(self, ch):
  152. for key, button in self.channelButton.items():
  153. button.SetUp()
  154.  
  155. self.channelButton[ch].Down()
  156.  
  157. self.stream.SetConnectInfo(SERVER_IP, self.ChannelPort(ch, 0), SERVER_IP, self.ChannelPort("LOGIN"))
  158. net.SetMarkServer(SERVER_IP, self.ChannelPort("LOGO"))
  159. app.SetGuildMarkPath("10.tga")
  160. app.SetGuildSymbolPath("10")
  161. net.SetServerInfo(self.ChannelPort(ch, 2))
  162.  
  163. def ChannelPort(self, ch, value=0):
  164. channel = {
  165.  
  166. 0 : CH1_PORT,
  167. 1 : CH2_PORT,
  168. 2 : CH3_PORT,
  169. 3 : CH4_PORT,}
  170.  
  171. if ch == "LOGIN":
  172. return PORT_AUTH
  173. elif ch == "LOGO":
  174. return channel[0]
  175. elif value == 2:
  176. return NUME_SERVER + ", CH%s" % (ch+1)
  177. else:
  178. return channel[ch]
  179.  
  180. def Connect(self, id, pwd):
  181. if constInfo.SEQUENCE_PACKET_ENABLE:
  182. net.SetPacketSequenceMode()
  183.  
  184. constInfo.LastAccount = id.lower()
  185.  
  186. self.stream.popupWindow.Close()
  187. self.stream.popupWindow.Open(localeInfo.LOGIN_CONNETING, self.EmptyFunc, localeInfo.UI_CANCEL)
  188.  
  189. self.stream.SetLoginInfo(id, pwd)
  190. self.stream.Connect()
  191.  
  192. def PopupDisplayMessage(self, msg):
  193. self.stream.popupWindow.Close()
  194. self.stream.popupWindow.Open(msg)
  195.  
  196. def PopupNotifyMessage(self, msg, func=0):
  197. if not func:
  198. func = self.EmptyFunc
  199.  
  200. self.stream.popupWindow.Close()
  201. self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)
  202.  
  203. def OnPressExitKey(self):
  204. if self.stream.popupWindow:
  205. self.stream.popupWindow.Close()
  206. self.stream.SetPhaseWindow(0)
  207. return TRUE
  208.  
  209. ## BUTOANE PENTRU LINKURI ##
  210. def GoWebSite(self):
  211. import os
  212. os.system('@echo off && explorer "https://metin2.pw/"')
  213. return TRUE
  214.  
  215. def GoParolaUitata(self):
  216. import os
  217. os.system('@echo off && explorer "https://metin2.pw/index.php?s=passwordlost"')
  218. return TRUE
  219.  
  220. def GoRegister(self):
  221. import os
  222. os.system('@echo off && explorer "https://metin2.pw/?s=Inregistrare"')
  223. return TRUE
  224. ############################
  225.  
  226. def EmptyFunc(self):
  227. pass
  228.  
  229. def __OnClickLoginButton(self):
  230. id = self.idEditLine.GetText()
  231. pwd = self.pwdEditLine.GetText()
  232.  
  233. if len(id)==0:
  234. self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, self.EmptyFunc)
  235. return
  236.  
  237. if len(pwd)==0:
  238. self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, self.EmptyFunc)
  239. return
  240.  
  241. self.Connect(id, pwd)
  242.  
  243.  
  244. ######################################## INSFARIST GATA ######################################## ORA: 01:45
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement