Advertisement
Guest User

Untitled

a guest
Dec 25th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.27 KB | None | 0 0
  1. import dbg
  2. import app
  3. import time
  4. import ui
  5. import wndMgr
  6. import net
  7. import introLogin
  8. import ServerStateChecker
  9. import musicInfo
  10. import snd
  11. import ime
  12. import systemSetting
  13. import constInfo
  14. import serverInfo
  15.  
  16. stream = None
  17. LOGIN_DELAY_SEC = 0.0
  18. NEW_BINARY = TRUE
  19.  
  20. if NEW_BINARY:
  21. import localeInfo
  22. locale = localeInfo
  23. else:
  24. import locale
  25.  
  26. CHANNEL_ONLINE = "ch-on.tga"
  27. CHANNEL_OFFLINE = "ch-off.tga"
  28.  
  29. CHANNEL_INFO = {
  30. 0 : {
  31. "KEY" : 10,
  32. "IP" : "",
  33. "NAME" : "Channel 1",
  34. "CONTRACTION" : "CH 1",
  35. "TCP_PORT" : 0,
  36. "UDP_PORT" : 0,
  37. "STATE" : CHANNEL_OFFLINE
  38. },
  39. 1 : {
  40. "KEY" : 11,
  41. "IP" : "",
  42. "NAME" : "Channel 2",
  43. "CONTRACTION" : "CH 2",
  44. "TCP_PORT" : 0,
  45. "UDP_PORT" : 0,
  46. "STATE" : CHANNEL_OFFLINE
  47. },
  48. 2 : {
  49. "KEY" : 12,
  50. "IP" : "",
  51. "NAME" : "Channel 3",
  52. "CONTRACTION" : "CH 3",
  53. "TCP_PORT" : 0,
  54. "UDP_PORT" : 0,
  55. "STATE" : CHANNEL_OFFLINE
  56. },
  57. 3 : {
  58. "KEY" : 13,
  59. "IP" : "",
  60. "NAME" : "Channel 4",
  61. "CONTRACTION" : "CH 4",
  62. "TCP_PORT" : 0,
  63. "UDP_PORT" : 0,
  64. "STATE" : CHANNEL_OFFLINE
  65. }
  66. }
  67.  
  68. SERVER_INFO = {
  69. "NAME" : "Dronys2",
  70. "IP" : "",
  71. "PORT" : 0,
  72. "CHANNELS" : CHANNEL_INFO
  73. }
  74.  
  75. MARKADDR_DICT = {
  76. "IP" : "",
  77. "TCP_PORT" : 13001,
  78. "MARK" : "10.tga",
  79. "SYMBOL_PATH" : "10"
  80. }
  81.  
  82. SETTINGS = {
  83. 0 : 0,
  84. 1 : {
  85. "ID" : "",
  86. "PWD" : "",
  87. },
  88. 2 : "FALSE",
  89. 3 : -1
  90. }
  91.  
  92. SETTINGS_FILE = "settings.txt"
  93. ACCOUNTS_FILE = "accounts.txt"
  94.  
  95. ACCOUNTS_REWRITER = None
  96. ACCOUNTS_READER = None
  97. SETTINGS_REWRITER = None
  98. SET_ACCOUNT = None
  99.  
  100. LOGIN_IS_PROCESSING = FALSE
  101.  
  102. ACCOUNTS = {
  103. 0 : {
  104. "ID" : "",
  105. "PWD" : "",
  106. "LEVEL" : "?",
  107. "LOGIN_IS_PROCESSING" : FALSE
  108. },
  109. 1 : {
  110. "ID" : "",
  111. "PWD" : "",
  112. "LEVEL" : "?",
  113. "LOGIN_IS_PROCESSING" : FALSE
  114. },
  115. 2 : {
  116. "ID" : "",
  117. "PWD" : "",
  118. "LEVEL" : "?",
  119. "LOGIN_IS_PROCESSING" : FALSE
  120. },
  121. "EMPTY" : " - EMPTY - "
  122. }
  123.  
  124. def IsLoginDelay():
  125. global LOGIN_DELAY_SEC
  126. if LOGIN_DELAY_SEC > 0.0:
  127. return TRUE
  128. else:
  129. return FALSE
  130.  
  131. def GetLoginDelay():
  132. global LOGIN_DELAY_SEC
  133. return LOGIN_DELAY_SEC
  134.  
  135. class SpecialBoard(ui.ImageBox):
  136.  
  137. timeToFade = 0.0
  138. interval = 1.0
  139. fadeIn = 0
  140. fadeOut = 0
  141. currentTime = 0
  142. intervallEndTime = 0
  143. currentAlphaValue = 0
  144.  
  145. def __init__(self):
  146. ui.ImageBox.__init__(self)
  147.  
  148. def __del__(self):
  149. ui.ImageBox.__del__(self)
  150.  
  151. def LoadImage(self, imageName):
  152. ui.ImageBox.LoadImage(self, imageName)
  153. self.SetAlpha(0.0)
  154.  
  155. def SetAlpha(self, alpha):
  156. self.currentAlphaValue = alpha
  157. ui.ImageBox.SetAlpha(self, alpha)
  158.  
  159. def OnUpdate(self):
  160. self.currentTime = time.clock()
  161. if self.fadeIn == 1 or self.fadeOut == 1:
  162. if self.currentAlphaValue < 1.0 and self.currentAlphaValue >= 0.0:
  163. if self.currentTime >= self.intervallEndTime:
  164. newAlphaValue = self.currentAlphaValue
  165. if self.fadeIn == 1:
  166. newAlphaValue += self.interval
  167. else:
  168. newAlphaValue -= self.interval
  169. self.SetAlpha(newAlphaValue)
  170. self.intervallEndTime = self.currentTime + self.timeToFade
  171. else:
  172. self.fadeIn = self.fadeOut = 0
  173.  
  174. def FadeIn(self):
  175. self.Show()
  176. self.SetAlpha(0.0)
  177. self.fadeOut = 0
  178. self.intervallEndTime = self.currentTime + self.timeToFade
  179. self.fadeIn = 1
  180.  
  181. def FadeOut(self):
  182. self.Show()
  183. self.SetAlpha(1.0)
  184. self.fadeIn = 0
  185. self.intervallEndTime = self.currentTime + self.timeToFade
  186. self.fadeOut = 1
  187.  
  188. def fadeProgressFinished(self):
  189. if self.fadeIn == 0 and self.fadeOut == 0:
  190. return 1
  191. else:
  192. return 0
  193.  
  194. class SpecialEditLine(ui.EditLine):
  195.  
  196. __placeHolderFontColor = 200
  197.  
  198. def __init__(self):
  199. ui.EditLine.__init__(self)
  200. self.placeHolder = ui.TextLine()
  201. self.placeHolder.SetFontColor(self.__placeHolderFontColor, self.__placeHolderFontColor, self.__placeHolderFontColor)
  202. self.placeHolder.Hide()
  203. self.__ShowPlaceHolder()
  204.  
  205. def SetParent(self, parent):
  206. self.placeHolder.SetParent(parent)
  207. ui.EditLine.SetParent(self, parent)
  208.  
  209. def SetSize(self, width, height):
  210. ui.EditLine.SetSize(self, width, height)
  211. self.placeHolder.SetSize(width, height)
  212.  
  213. def SetPosition(self, x, y):
  214. ui.EditLine.SetPosition(self, x, y)
  215. self.placeHolder.SetPosition(x, y)
  216.  
  217. def OnSetFocus(self):
  218. ui.EditLine.OnSetFocus(self)
  219. self.__HidePlaceHolder()
  220.  
  221. def OnKillFocus(self):
  222. ui.EditLine.OnKillFocus(self)
  223. if self.GetText() == "":
  224. self.__ShowPlaceHolder()
  225. else:
  226. self.__HidePlaceHolder()
  227.  
  228. def SetSecret(self, value=TRUE):
  229. ui.EditLine.SetSecret(self)
  230. self.__secret = value
  231.  
  232. def __ShowPlaceHolder(self):
  233. ui.EditLine.Hide(self)
  234. self.placeHolder.Show()
  235.  
  236. def __HidePlaceHolder(self):
  237. ui.EditLine.Show(self)
  238. self.placeHolder.Hide()
  239.  
  240. def SetPlaceHolderText(self, text):
  241. self.placeHolder.SetText(text)
  242. self.__ShowPlaceHolder()
  243.  
  244. def __del__(self):
  245. ui.EditLine.__del__(self)
  246.  
  247. class PopupDialog(SpecialBoard):
  248.  
  249. __background = "verbinden-bg.tga"
  250. __greyerBG = "dunklermacherbg.tga"
  251. __buttons = []
  252. __closeEvent = 0
  253.  
  254. def __init__(self):
  255. SpecialBoard.__init__(self)
  256. self.interval = 0.3
  257. self.LoadImage(self.__background)
  258. self.SetCenterPosition()
  259.  
  260. self.message = ui.TextLine()
  261. self.message.SetParent(self)
  262. self.message.SetPosition(0, 38)
  263. self.message.SetWindowHorizontalAlignCenter()
  264. self.message.SetHorizontalAlignCenter()
  265. self.message.SetVerticalAlignCenter()
  266. self.greyer = ui.ExpandedImageBox()
  267. self.greyer.Hide()
  268. self.greyer.OnMouseLeftButtonDown = lambda *x : self.Close()
  269. self.OnMouseLeftButtonDown = self.greyer.OnMouseLeftButtonDown
  270.  
  271. def FadeIn(self):
  272. SpecialBoard.FadeIn(self)
  273. self.SetParent(self.greyer)
  274. self.greyer.LoadImage(self.__greyerBG)
  275. self.greyer.SetScale(float(wndMgr.GetScreenWidth()) / float(self.greyer.GetWidth()), float(wndMgr.GetScreenHeight()) / float(self.greyer.GetHeight()))
  276. self.greyer.Show()
  277. self.SetTop()
  278.  
  279. def OnUpdate(self):
  280. SpecialBoard.OnUpdate(self)
  281. if self.fadeProgressFinished() == 1:
  282. self.message.Show()
  283. for i in xrange(len(self.__buttons)):
  284. self.__buttons[i].Show()
  285. if type(self.__buttons[i]) is TableLayout:
  286. self.__buttons[i].SetWindowHorizontalAlignCenter()
  287. self.__buttons[i].SetPosition(0, self.GetHeight() - self.__buttons[i].GetHeight() - 30)
  288. else:
  289. self.message.Hide()
  290. for i in xrange(len(self.__buttons)):
  291. self.__buttons[i].Hide()
  292.  
  293. def SetButtons(self, buttons):
  294. for i in xrange(len(buttons)):
  295. self.AddButton(buttons[i])
  296. #self.InsertChild("button%i" % (i), self.__buttons[i])
  297.  
  298. def AddButton(self, button):
  299. button.SetParent(self)
  300. self.__buttons.append(button)
  301.  
  302. def RemoveButton(self, buttonIndex):
  303. del self.__buttons[buttonIndex]
  304.  
  305. def SetMessage(self, message):
  306. self.message.SetText(message)
  307.  
  308. def SetCloseEvent(self, closeEvent):
  309. self.__closeEvent = closeEvent
  310.  
  311. def Close(self):
  312. if self.__closeEvent:
  313. self.__closeEvent()
  314. self.FadeOut()
  315. self.greyer.Hide()
  316.  
  317. def OnPressEscapeKey(self):
  318. self.Close()
  319. return TRUE
  320.  
  321. def OnIMEReturn(self):
  322. self.Close()
  323. return TRUE
  324.  
  325. def __del__(self):
  326. SpecialBoard.__del__(self)
  327.  
  328. class LoginInterface(ui.ScriptWindow):
  329.  
  330. __background = "bg.tga"
  331. __currentArea = None
  332.  
  333. def __init__(self, _stream):
  334. ui.ScriptWindow.__init__(self)
  335. global stream
  336. global SETTINGS_REWRITER
  337. global SETTINGS
  338. global ACCOUNTS_READER
  339. global ACCOUNTS_REWRITER
  340. stream = _stream
  341. self.backgroundImage = ui.ExpandedImageBox()
  342. self.backgroundImage.LoadImage(self.__background)
  343. self.backgroundImage.SetScale(float(wndMgr.GetScreenWidth()) / float(self.backgroundImage.GetWidth()), float(wndMgr.GetScreenHeight()) / float(self.backgroundImage.GetHeight()))
  344.  
  345. self.SettingsReader()
  346. SETTINGS_REWRITER = self.SettingsRewriter
  347. ACCOUNTS_REWRITER = self.AccountSettingsRewriter
  348. ACCOUNTS_READER = self.AccountSettingsReader
  349. ACCOUNTS_READER()
  350.  
  351. self.naviBar = NavigationBar()
  352. self.naviBar.SetParent(self)
  353. self.naviBar.SetWindowHorizontalAlignCenter()
  354. self.naviBar.SetWindowVerticalAlignCenter()
  355.  
  356. def SetCurrentArea(self, area):
  357. if self.__currentArea == area:
  358. return
  359.  
  360. try:
  361. self.__currentArea.Close()
  362. except Exception, e:
  363. pass
  364. self.__currentArea = area
  365. self.__currentArea.SetParent(self.backgroundImage)
  366. try:
  367. #self.__currentArea.FadeIn()
  368. self.__currentArea.Open()
  369. except Exception, e:
  370. pass
  371.  
  372. def OnUpdate(self):
  373. self.naviBar.OnUpdate()
  374. if SETTINGS[3] == -1:
  375. self.naviBar.SetPosition(0, self.__currentArea.GetHeight() / 2 + 10)
  376. self.__currentArea.furtherOptionsButton.SetParent(self.backgroundImage)#SetCenterPosition()
  377. self.__currentArea.furtherOptionsButton.SetWindowHorizontalAlignCenter()
  378. self.__currentArea.furtherOptionsButton.SetPosition(0, self.naviBar.GetGlobalPosition()[1] + self.naviBar.GetHeight() + 10)
  379. else:
  380. self.naviBar.SetPosition(0, -(self.__currentArea.GetHeight() / 2 + 50))
  381. self.__currentArea.SetStandardPosition()
  382.  
  383. def Open(self):
  384. if musicInfo.loginMusic != "":
  385. snd.SetMusicVolume(systemSetting.GetMusicVolume())
  386. snd.FadeInMusic("BGM/"+musicInfo.loginMusic)
  387.  
  388. snd.SetSoundVolume(systemSetting.GetSoundVolume())
  389.  
  390. ime.AddExceptKey(91)
  391. ime.AddExceptKey(93)
  392.  
  393. self.Show()
  394. self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())
  395. app.ShowCursor()
  396. self.backgroundImage.Show()
  397. self.naviBar.FadeIn()
  398. self.naviBar.SetTop()
  399.  
  400. def Close(self):
  401. global stream
  402. self.__currentArea.Close()
  403. self.Hide()
  404. stream.popupWindow.Close()
  405. ime.ClearExceptKey()
  406. app.HideCursor()
  407.  
  408. def SettingsReader(self):
  409. global SETTINGS
  410. global SETTINGS_FILE
  411. settingsStream = open(SETTINGS_FILE, "r")
  412. content = settingsStream.read()
  413. elements = content.split('\n')
  414. for i in xrange(len(elements)):
  415. item = elements[i]
  416. if item != "":
  417. if item.find(";") != -1:
  418. values = item.split(";")
  419. for j in xrange(len(values)):
  420. value = values[j]
  421. if value != "":
  422. SETTINGS[i][value.split(":")[0]] = value.split(":")[1]
  423. else:
  424. SETTINGS[i] = type(SETTINGS[i])(item)
  425. settingsStream.close()
  426.  
  427. def SettingsRewriter(self):
  428. global SETTINGS
  429. global SETTINGS_FILE
  430. settingsStream = open(SETTINGS_FILE, "w")
  431. for i in xrange(len(SETTINGS)):
  432. line = ""
  433. if type(SETTINGS[i]) is dict:
  434. for name in SETTINGS[i]:
  435. line += name + ":" + SETTINGS[i][name] + ";"
  436. else:
  437. line += str(SETTINGS[i])
  438. line += "\n"
  439. settingsStream.write(line)
  440. settingsStream.close()
  441.  
  442. def AccountSettingsReader(self):
  443. global ACCOUNTS
  444. global ACCOUNTS_FILE
  445. accountsStream = open(ACCOUNTS_FILE, "r")
  446. content = accountsStream.read()
  447. elements = content.split("\n")
  448. for i in xrange(len(elements)):
  449. item = elements[i]
  450. if item != "":
  451. for account in ACCOUNTS:
  452. index = 0
  453. account = ACCOUNTS[account]
  454. if index == i:
  455. if type(account) is dict:
  456. if item.find(";") != -1:
  457. values = item.split(";")
  458. for j in xrange(len(values)):
  459. value = values[j]
  460. if value != "":
  461. account[value.split(":")[0]] = value.split(":")[1]
  462. break
  463. accountsStream.close()
  464.  
  465. def AccountSettingsRewriter(self):
  466. global ACCOUNTS
  467. global ACCOUNTS_FILE
  468. accountsStream = open(ACCOUNTS_FILE, "w")
  469. for item in ACCOUNTS:
  470. item = ACCOUNTS[item]
  471. if type(item) is dict:
  472. line = ""
  473. for name in item:
  474. if type(item[name]) is str:
  475. line += name + ":" + item[name] + ";"
  476. line += "\n"
  477. accountsStream.write(line)
  478. accountsStream.close()
  479.  
  480. def OnPressExitKey(self):
  481. global stream
  482. stream.popupWindow.Close()
  483. stream.SetPhaseWindow(0)
  484. return TRUE
  485.  
  486. def __del__(self):
  487. ui.ScriptWindow.__del__(self)
  488.  
  489. class NavigationBar(SpecialBoard):
  490.  
  491. __navigationBarBackground = "navi-bg.tga"
  492. __loginButtonImages = ["login.tga", "login-hover-active.tga", "login.tga"]
  493. __accountManagementButtonImages = ["accverw.tga", "accverw-hover-active.tga", "accverw.tga"]
  494. __newsButtonImages = ["news.tga", "news-hover-active.tga", "news.tga"]
  495. __exitButtonImages = ["beenden.tga", "beenden-hover-active.tga", "beenden.tga"]
  496. __parent = None
  497. __buttons = []
  498. __closingDialogButtons = [
  499. [None, ["button-abbrechen.tga", "button-abbrechen-hover.tga", "button-abbrechen.tga"]],
  500. [None, ["button-beenden.tga", "button-beenden-hover.tga", "button-beenden.tga"]]
  501. ]
  502. __closeGameText = "Wollen sie das Spiel wirklich beenden?"
  503.  
  504. def __init__(self):
  505. SpecialBoard.__init__(self)
  506. self.LoadImage(self.__navigationBarBackground)
  507.  
  508. self.accountManagementArea = AccountManagementArea()
  509. self.loginArea = LoginArea()
  510. self.newsArea = NewsArea()
  511.  
  512. self.loginButton = ui.Button()
  513. self.loginButton.SetParent(self)
  514. self.loginButton.SetPosition(100, self.GetHeight() / 2 + 5)
  515. self.loginButton.SetEvent(ui.__mem_func__(self.__OnClickLogin))
  516. self.loginButton.Show()
  517.  
  518. self.accountManagementButton = ui.Button()
  519. self.accountManagementButton.SetParent(self)
  520. self.accountManagementButton.SetEvent(ui.__mem_func__(self.__OnClickAccountManagement))
  521. self.accountManagementButton.Show()
  522.  
  523. self.newsButton = ui.Button()
  524. self.newsButton.SetParent(self)
  525. self.newsButton.SetEvent(ui.__mem_func__(self.__OnClickNews))
  526. self.newsButton.Show()
  527.  
  528. self.exitButton = ui.Button()
  529. self.exitButton.SetParent(self)
  530. self.exitButton.Show()
  531. self.exitButton.SetEvent(lambda : self.__OnClickExit())
  532. self.__buttons.append([self.loginButton, self.__loginButtonImages])
  533. self.__buttons.append([self.accountManagementButton, self.__accountManagementButtonImages])
  534. self.__buttons.append([self.newsButton, self.__newsButtonImages])
  535. self.__buttons.append([self.exitButton, self.__exitButtonImages])
  536. self.__SetButtonImages()
  537.  
  538. self.__closingDialog = PopupDialog()
  539. self.__buttonTableLayout = TableLayout()
  540. self.__closingDialogButtons[0][0] = lambda : self.__closingDialog.Close()
  541. self.__closingDialogButtons[1][0] = lambda : app.Exit()
  542. for i in xrange(len(self.__closingDialogButtons)):
  543. button = ui.Button()
  544. button.SetUpVisual(self.__closingDialogButtons[i][1][0])
  545. button.SetOverVisual(self.__closingDialogButtons[i][1][1])
  546. button.SetDownVisual(self.__closingDialogButtons[i][1][2])
  547. button.SetEvent(self.__closingDialogButtons[i][0])
  548. button.Show()
  549. self.__buttonTableLayout.AddItem(button)
  550.  
  551. #self.__buttonTableLayout.SetWindowHorizontalAlignCenter()
  552. self.__buttonTableLayout.Show()
  553. self.__closingDialog.SetMessage(self.__closeGameText)
  554. self.__closingDialog.AddButton(self.__buttonTableLayout)
  555.  
  556. def OnUpdate(self):
  557. global SETTINGS
  558. SpecialBoard.OnUpdate(self)
  559. if SETTINGS[3] == 1:
  560. self.accountManagementArea.SetStandardPosition()
  561. self.loginArea.SetStandardPosition()
  562. self.newsArea.SetStandardPosition()
  563. #else:
  564. # if self.__parent:
  565.  
  566.  
  567. if self.__closingDialog:
  568. self.__closingDialog.OnUpdate()
  569.  
  570. def __SetButtonImages(self):
  571. for i in xrange(len(self.__buttons)):
  572. button = self.__buttons[i][0]
  573. button.SetUpVisual(self.__buttons[i][1][0])
  574. button.SetOverVisual(self.__buttons[i][1][1])
  575. button.SetDownVisual(self.__buttons[i][1][2])
  576. if i > 0:
  577. previousButton = self.__buttons[i - 1][0]
  578. x, y = previousButton.GetLocalPosition()
  579. button.SetPosition(x + previousButton.GetWidth() + 30, self.GetHeight() / 2 + 5)
  580.  
  581. def __SetButton(self, button, image):
  582. button.SetUpVisual(image)
  583. button.SetOverVisual(image)
  584. button.SetDownVisual(image)
  585.  
  586. def SetParent(self, parent):
  587. self.__parent = parent
  588. try:
  589. self.__OnClickLogin()
  590. SpecialBoard.SetParent(self, parent.backgroundImage)
  591. except Exception, e:
  592. pass
  593.  
  594. def __OnClickLogin(self):
  595. self.__SetButtonImages()
  596. try:
  597. self.__parent.SetCurrentArea(self.loginArea)
  598. self.__SetButton(self.loginButton, self.__loginButtonImages[1])
  599. net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self.loginArea.GetCurrentAreaBoard())
  600. net.SetAccountConnectorHandler(0)
  601. net.SetPhaseWindow(net.PHASE_WINDOW_LOGIN, self.loginArea.GetCurrentAreaBoard())
  602. net.SetAccountConnectorHandler(self.loginArea.GetCurrentAreaBoard())
  603. except Exception, e:
  604. pass
  605.  
  606. def __OnClickAccountManagement(self):
  607. self.__SetButtonImages()
  608. try:
  609. self.__parent.SetCurrentArea(self.accountManagementArea)
  610. self.__SetButton(self.accountManagementButton, self.__accountManagementButtonImages[1])
  611. net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self.loginArea.GetCurrentAreaBoard())
  612. net.SetAccountConnectorHandler(0)
  613. #net.SetPhaseWindow(net.PHASE_WINDOW_LOGIN, self.accountManagementArea.GetCurrentAreaBoard())
  614. #net.SetAccountConnectorHandler(self.accountManagementArea.GetCurrentAreaBoard())
  615. except Exception, e:
  616. pass
  617.  
  618. def __OnClickNews(self):
  619. self.__SetButtonImages()
  620. try:
  621. self.__parent.SetCurrentArea(self.newsArea)
  622. self.__SetButton(self.newsButton, self.__newsButtonImages[1])
  623. net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self.loginArea.GetCurrentAreaBoard())
  624. net.SetAccountConnectorHandler(0)
  625. except Exception, e:
  626. pass
  627.  
  628. def __OnClickExit(self):
  629. global SETTINGS
  630. global stream
  631. self.__SetButtonImages()
  632. if SETTINGS[2] == "TRUE":
  633. self.__closingDialog.FadeIn()
  634. net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self.loginArea.GetCurrentAreaBoard())
  635. net.SetAccountConnectorHandler(0)
  636. else:
  637. app.Exit()
  638.  
  639. def __del__(self):
  640. SpecialBoard.__del__(self)
  641.  
  642. class TableLayout(ui.ScriptWindow):
  643.  
  644. __horizontalLayout = TRUE
  645. __placeHolder = 10
  646.  
  647. def __init__(self):
  648. ui.ScriptWindow.__init__(self)
  649.  
  650. def OnUpdate(self):
  651. self.__Refresh()
  652.  
  653. def AddItem(self, item):
  654. item.SetParent(self)
  655. self.Children.append(item)
  656.  
  657. def RemoveItem(self, index):
  658. for i in xrange(len(self.Children)):
  659. if self.Children[i] == item:
  660. del self.Children[i]
  661. break
  662.  
  663. def GetItemCount(self):
  664. return len(self.Children)
  665.  
  666. def GetItems(self):
  667. return self.Children
  668.  
  669. def GetItemAt(self, index):
  670. try:
  671. return self.Children[index]
  672. except Exception, e:
  673. pass
  674.  
  675. def SetVerticalLayout(self):
  676. self.__horizontalLayout = FALSE
  677.  
  678. def SetHorizontalLayout(self):
  679. self.__horizontalLayout = TRUE
  680.  
  681. def __Refresh(self):
  682. if self.__horizontalLayout == TRUE:
  683. self.SetSize(0, 0)
  684. itemHeights = []
  685. for item in self.Children:
  686. itemHeights.append(item.GetHeight())
  687. self.SetSize(self.GetWidth() + item.GetWidth() + self.__placeHolder, max(itemHeights))
  688. else:
  689. self.SetSize(0, 0)
  690. itemWidths = []
  691. for item in self.Children:
  692. itemWidths.append(item.GetWidth())
  693. self.SetSize(max(itemWidths), self.GetHeight() + item.GetHeight() + self.__placeHolder)
  694. cells = len(self.Children)
  695. cellWidth = self.GetWidth() / cells
  696. cellHeight = self.GetHeight() / cells
  697. for i in xrange(len(self.Children)):
  698. if self.__horizontalLayout == TRUE:
  699. self.Children[i].SetWindowVerticalAlignCenter()
  700. self.Children[i].SetPosition(cellWidth / 2 + cellWidth * i - self.Children[i].GetWidth() / 2, 0)#-self.Children[i].GetHeight() / 2)
  701. else:
  702. self.Children[i].SetWindowHorizontalAlignCenter()
  703. self.Children[i].SetPosition(0, cellHeight / 2 + cellHeight * i - self.Children[i].GetHeight() / 2)
  704.  
  705. def __del__(self):
  706. ui.ScriptWindow.__del__(self)
  707.  
  708. class FurtherOptionsBoard(SpecialBoard):
  709.  
  710. class CheckBox(ui.Window):
  711.  
  712. __checkBoxImages = ["tickbox-ticked.tga", "tickbox-notTicked.tga"]
  713. __isChecked = FALSE
  714. __event = None
  715.  
  716. def __init__(self):
  717. ui.Window.__init__(self)
  718. self.__checkBox = ui.ImageBox()
  719. self.__checkBox.SetParent(self)
  720. self.__checkBox.LoadImage(self.__checkBoxImages[1])
  721. self.__event = lambda : self.EmptyFunc()
  722. self.__checkBox.OnMouseLeftButtonDown = lambda : (self.__event(), self.__ChangeState())
  723. self.__checkBox.Show()
  724. self.SetSize(self.__checkBox.GetWidth(), self.__checkBox.GetHeight())
  725. self.__checkBoxText = ui.TextLine()
  726. self.__checkBoxText.SetParent(self)
  727. self.__checkBox.SetWindowVerticalAlignCenter()
  728. self.__checkBoxText.SetPosition(self.__checkBox.GetWidth() + 10, 0)
  729. self.__checkBoxText.Show()
  730.  
  731. def SetText(self, text):
  732. self.__checkBoxText.SetText(text)
  733.  
  734. def OnUpdate(self):
  735. if self.__isChecked == TRUE:
  736. self.__checkBox.LoadImage(self.__checkBoxImages[0])
  737. else:
  738. self.__checkBox.LoadImage(self.__checkBoxImages[1])
  739.  
  740. def __ChangeState(self):
  741. if self.__isChecked == TRUE:
  742. self.__isChecked = FALSE
  743. else:
  744. self.__isChecked = TRUE
  745.  
  746. def SetState(self, state):
  747. if self.__isChecked == state:
  748. return
  749.  
  750. self.__isChecked = state
  751. if self.__event:
  752. self.__event(self.__isChecked)
  753.  
  754. def SetCheckEvent(self, event):
  755. if event:
  756. self.__event = event
  757. self.__checkBox.OnMouseLeftButtonDown = lambda : (self.__ChangeState(), self.__event(self.__isChecked))
  758.  
  759. def IsChecked(self):
  760. return self.__isChecked
  761.  
  762. def EmptyFunc(self):
  763. pass
  764.  
  765. def __del__(self):
  766. ui.Window.__del__(self)
  767.  
  768. class Channel(ui.Window):
  769.  
  770. __isPressed = FALSE
  771. __channelButtonImages = ["channel.tga" , "channel-hover.tga", "channel-active.tga"]
  772. __linkedChannel = None
  773.  
  774. def __init__(self):
  775. ui.Window.__init__(self)
  776. self.__channelState = ui.ImageBox()
  777. self.__channelState.SetParent(self)
  778. self.__channelState.Show()
  779. self.__channel = ui.Button()
  780. self.__channel.SetParent(self)
  781. self.__channel.Show()
  782. self.SetEvent(ui.__mem_func__(self.__EmptyFunc))
  783. self.SetChannelImages()
  784.  
  785. def __EmptyFunc(self):
  786. pass
  787.  
  788. def ExceuteEvent(self):
  789. self.__channel.eventFunc()
  790.  
  791. def SetEvent(self, event):
  792. self.__channel.SetEvent(lambda : (event(), self.SetClicked()))
  793.  
  794. def SetChannelName(self, text):
  795. self.__channel.SetText(text)
  796.  
  797. def SetClicked(self):
  798. global SERVER_INFO
  799. global MARKADDR_DICT
  800. global stream
  801.  
  802. try:
  803. stream.SetConnectInfo(SERVER_INFO["CHANNELS"][self.__linkedChannel]["IP"], SERVER_INFO["CHANNELS"][self.__linkedChannel]["TCP_PORT"], SERVER_INFO["CHANNELS"][self.__linkedChannel]["IP"], SERVER_INFO["PORT"])
  804.  
  805. net.SetServerInfo("%s - %s" & (SERVER_INFO["NAME"], SERVER_INFO["CHANNELS"][self.__linkedChannel]["CONTRACTION"]))
  806.  
  807. net.SetMarkServer(MARKADDR_DICT["IP"], MARKADDR_DICT["TCP_PORT"])
  808. app.SetGuildMarkPath(MARKADDR_DICT["MARK"])
  809. app.SetGuildSymbolPath(MARKADDR_DICT["SYMBOL_PATH"])
  810. except Exception, e:
  811. pass
  812.  
  813. self.__isPressed = TRUE
  814. self.__channel.SetUpVisual(self.__channelButtonImages[2])
  815. self.__channel.SetOverVisual(self.__channelButtonImages[2])
  816. self.__channel.SetDownVisual(self.__channelButtonImages[2])
  817.  
  818. def SetChannelImages(self):
  819. self.__isPressed = FALSE
  820. self.__channel.SetUpVisual(self.__channelButtonImages[0])
  821. self.__channel.SetOverVisual(self.__channelButtonImages[1])
  822. self.__channel.SetDownVisual(self.__channelButtonImages[2])
  823.  
  824. def IsPressed(self):
  825. return self.__isPressed
  826.  
  827. def GetLinkedChannel(self):
  828. return self.__linkedChannel
  829.  
  830. def OnUpdate(self):
  831. global SERVER_INFO
  832. self.__channelState.LoadImage(SERVER_INFO["CHANNELS"][self.__linkedChannel]["STATE"])
  833. self.SetSize(max(self.__channel.GetWidth(), self.__channelState.GetWidth()), self.__channel.GetHeight() + self.__channelState.GetHeight())
  834. self.__channel.SetWindowHorizontalAlignCenter()
  835. self.__channel.SetPosition(0, 0)
  836. self.__channelState.SetWindowHorizontalAlignCenter()
  837. self.__channelState.SetPosition(0, self.__channel.GetHeight())
  838.  
  839. def SetLinkedChannel(self, channel):
  840. self.__linkedChannel = channel
  841.  
  842. def __del__(self):
  843. self.__channel.Hide()
  844. self.__channel = None
  845. self.__channelState.Hide()
  846. self.__channelState = None
  847. ui.Window.__del__(self)
  848.  
  849. __background = "optionen-bg.tga"
  850. __channeksddf = 10
  851. __checkBoxes = [["Diesen Channel automatisch auswaehlen", None], ["Automatischer Login mit dem ersten gespeicherten Account", None], ["Meldung beim Beenden des Clients anzeigen", None]]
  852.  
  853. def __init__(self):
  854. SpecialBoard.__init__(self)
  855. global SETTINGS
  856. self.LoadImage(self.__background)
  857. self.tableLayout = TableLayout()
  858. self.tableLayout.SetParent(self)
  859. self.tableLayout.SetPosition(0, 10)
  860. self.tableLayout.SetSize(self.GetWidth(), 0)
  861. self.tableLayout.Show()
  862.  
  863. self.tableLayoutCheckBoxes = TableLayout()
  864. self.tableLayoutCheckBoxes.SetParent(self)
  865. self.tableLayoutCheckBoxes.SetPosition(20, 0)
  866. self.tableLayoutCheckBoxes.SetVerticalLayout()
  867. self.tableLayoutCheckBoxes.Show()
  868. self.__InitCheckBoxes()
  869.  
  870. self.InitChannels()
  871. self.tableLayout.GetItemAt(SETTINGS[0]).ExceuteEvent()
  872.  
  873. def __InitCheckBoxes(self):
  874. global SETTINGS
  875. self.__checkBoxes[0][1] = self.__StandardChannelChanged
  876. self.__checkBoxes[1][1] = self.__StandardAccountChanged
  877. self.__checkBoxes[2][1] = self.__ShowClosingWarningChanged
  878. for i in xrange(len(self.__checkBoxes)):
  879. checkBox = FurtherOptionsBoard.CheckBox()
  880. checkBox.SetText(self.__checkBoxes[i][0])
  881. checkBox.SetCheckEvent(self.__checkBoxes[i][1])
  882. if type(SETTINGS[i]) is not dict:
  883. if type(SETTINGS[i]) is int:
  884. checkBox.SetState(TRUE)
  885. elif type(SETTINGS[i]) is str:
  886. if SETTINGS[i] == "FALSE":
  887. checkBox.SetState(FALSE)
  888. elif SETTINGS[i] == "TRUE":
  889. checkBox.SetState(TRUE)
  890. else:
  891. for name in SETTINGS[i]:
  892. if SETTINGS[i][name] != "":
  893. checkBox.SetState(TRUE)
  894. else:
  895. checkBox.SetState(FALSE)
  896. checkBox.Show()
  897. self.tableLayoutCheckBoxes.AddItem(checkBox)
  898.  
  899. def __StandardChannelChanged(self, state):
  900. if state == TRUE:
  901. for item in self.tableLayout.GetItems():
  902. if item.IsPressed():
  903. SETTINGS[0] = item.GetLinkedChannel()
  904. else:
  905. SETTINGS[0] = 0
  906. self.__RewriteSettings()
  907.  
  908. def __StandardAccountChanged(self, state):
  909. if state == TRUE:
  910. global SET_ACCOUNT
  911. if SET_ACCOUNT:
  912. SET_ACCOUNT()
  913. else:
  914. SETTINGS[1] = { "ID" : "", "PWD" : ""}
  915. self.__RewriteSettings()
  916.  
  917. def __ShowClosingWarningChanged(self, state):
  918. if state == TRUE:
  919. SETTINGS[2] = "TRUE"
  920. else:
  921. SETTINGS[2] = "FALSE"
  922. self.__RewriteSettings()
  923.  
  924. def __ChannelClicked(self):
  925. for item in self.tableLayout.GetItems():
  926. item.SetChannelImages()
  927.  
  928. def __RewriteSettings(self):
  929. global SETTINGS_REWRITER
  930. if SETTINGS_REWRITER:
  931. SETTINGS_REWRITER()
  932.  
  933. def OnUpdate(self):
  934. SpecialBoard.OnUpdate(self)
  935. ServerStateChecker.Update()
  936. self.tableLayoutCheckBoxes.SetPosition(self.tableLayoutCheckBoxes.GetLocalPosition()[0], self.tableLayout.GetLocalPosition()[1] + self.tableLayout.GetHeight() + 10)
  937. self.tableLayout.SetWindowHorizontalAlignCenter()
  938.  
  939. def NotifyChannelState(self, addrKey, state):
  940. global SERVER_INFO
  941. try:
  942. stateName = serverInfo.STATE_DICT[state]
  943. stateName = CHANNEL_ONLINE
  944. except:
  945. stateName = CHANNEL_ONLINE
  946.  
  947. try:
  948. SERVER_INFO["CHANNELS"][addrKey % 10]["STATE"] = stateName
  949. except Exception, e:
  950. pass
  951.  
  952. def InitChannels(self):
  953. global SERVER_INFO
  954. global NEW_BINARY
  955.  
  956. ServerStateChecker.Create(self)
  957. if NEW_BINARY:
  958. ServerStateChecker.Initialize()
  959. for id, channelDataDict in SERVER_INFO["CHANNELS"].items():
  960. channel = FurtherOptionsBoard.Channel()
  961. channel.SetChannelName(channelDataDict["NAME"])
  962. channel.Show()
  963. channel.SetLinkedChannel(id)
  964. channel.SetEvent(ui.__mem_func__(self.__ChannelClicked))
  965. if not NEW_BINARY:
  966. ServerStateChecker.Request(channelDataDict["KEY"], channelDataDict["IP"], channelDataDict["UDP_PORT"])
  967. else:
  968. ServerStateChecker.AddChannel(channelDataDict["KEY"], channelDataDict["IP"], channelDataDict["UDP_PORT"])
  969. self.tableLayout.AddItem(channel)
  970.  
  971. if NEW_BINARY:
  972. ServerStateChecker.Request()
  973.  
  974. def __del__(self):
  975. if NEW_BINARY:
  976. ServerStateChecker.Initialize(self)
  977. else:
  978. ServerStateChecker.Destroy(self)
  979. self.tableLayout.Hide()
  980. self.tableLayout = None
  981. self.standardChannel.Hide()
  982. self.standardChannel = None
  983. self.standardAccount.Hide()
  984. self.standardAccount = None
  985. SpecialBoard.__del__(self)
  986.  
  987. class Area(ui.Window):
  988.  
  989. _currentAreaBoard = None
  990. _furtherOptionsButtonImages = ["weitere-ausgeklappt.tga", "weitere-eingeklappt.tga"]
  991. _furtherOptionsAreShown = 0
  992.  
  993. def __init__(self):
  994. ui.Window.__init__(self)
  995.  
  996. Area.furtherOptionsBoard = FurtherOptionsBoard()
  997. Area.furtherOptionsBoard.SetParent(self)
  998. Area.furtherOptionsBoard.Hide()
  999.  
  1000. self.furtherOptionsButton = ui.Button()
  1001. self.furtherOptionsButton.SetEvent(ui.__mem_func__(self._OnClickFurtherOptions))
  1002. self.furtherOptionsButton.Show()
  1003. self._SetFurtherOptionsButton()
  1004. self.SetStandardPosition()
  1005.  
  1006. def Open(self):
  1007. self.Show()
  1008. self.furtherOptionsButton.Show()
  1009. self.ShowBoard()
  1010.  
  1011. def Close(self):
  1012. Area.furtherOptionsBoard.Hide()
  1013. #self.furtherOptionsBoard = None
  1014. self._currentAreaBoard.Hide()
  1015. #self._currentAreaBoard = None
  1016. self.furtherOptionsButton.Hide()
  1017. #self.furtherOptionsButton = None
  1018. self.Hide()
  1019.  
  1020. def _OnClickFurtherOptions(self):
  1021. if self._furtherOptionsAreShown:
  1022. Area.furtherOptionsBoard.Hide()
  1023. self._currentAreaBoard.FadeIn()
  1024. self._furtherOptionsAreShown = 0
  1025. else:
  1026. self._currentAreaBoard.Hide()
  1027. Area.furtherOptionsBoard.FadeIn()
  1028. self._furtherOptionsAreShown = 1
  1029.  
  1030. self._SetFurtherOptionsButton()
  1031.  
  1032. def _SetFurtherOptionsButton(self):
  1033. if self._furtherOptionsAreShown == TRUE:
  1034. self.furtherOptionsButton.SetUpVisual(self._furtherOptionsButtonImages[1])
  1035. self.furtherOptionsButton.SetOverVisual(self._furtherOptionsButtonImages[1])
  1036. self.furtherOptionsButton.SetDownVisual(self._furtherOptionsButtonImages[1])
  1037. else:
  1038. self.furtherOptionsButton.SetUpVisual(self._furtherOptionsButtonImages[0])
  1039. self.furtherOptionsButton.SetOverVisual(self._furtherOptionsButtonImages[0])
  1040. self.furtherOptionsButton.SetDownVisual(self._furtherOptionsButtonImages[0])
  1041.  
  1042. def OnUpdate(self):
  1043. self.SetCenterPosition()
  1044.  
  1045. if self._currentAreaBoard:
  1046. self._currentAreaBoard.SetParent(self)
  1047. self._currentAreaBoard.SetPosition(0, 0)
  1048. self._currentAreaBoard.SetWindowHorizontalAlignCenter()
  1049. self._currentAreaBoard.SetPosition(0, 10)
  1050. self._currentAreaBoard.OnUpdate()
  1051.  
  1052. if Area.furtherOptionsBoard:
  1053. Area.furtherOptionsBoard.SetPosition(0, 0)
  1054. Area.furtherOptionsBoard.SetWindowHorizontalAlignCenter()
  1055. Area.furtherOptionsBoard.SetPosition(0, 10)
  1056. Area.furtherOptionsBoard.OnUpdate()
  1057.  
  1058. maxHeight = 0
  1059.  
  1060. if Area.furtherOptionsBoard and self._currentAreaBoard:
  1061. maxHeight = max(Area.furtherOptionsBoard.GetHeight(), self._currentAreaBoard.GetHeight())
  1062. else:
  1063. maxHeight = Area.furtherOptionsBoard.GetHeight()
  1064.  
  1065. self.SetSize(Area.furtherOptionsBoard.GetWidth() + 10, 10 + maxHeight + 5 + self.furtherOptionsButton.GetHeight() + 5)
  1066.  
  1067. def SetStandardPosition(self):
  1068. self.furtherOptionsButton.SetParent(self)
  1069. self.furtherOptionsButton.SetWindowHorizontalAlignCenter()
  1070. self.furtherOptionsButton.SetPosition(0, self.GetHeight() - self.furtherOptionsButton.GetHeight() - 5)
  1071.  
  1072. def ShowBoard(self):
  1073. if self._currentAreaBoard:
  1074. Area.furtherOptionsBoard.Hide()
  1075. self._currentAreaBoard.FadeIn()
  1076. self._furtherOptionsAreShown = 0
  1077. self._SetFurtherOptionsButton()
  1078. self.SetStandardPosition()
  1079.  
  1080. def GetCurrentAreaBoard(self):
  1081. return self._currentAreaBoard
  1082.  
  1083. def __del__(self):
  1084. ui.Window.__del__(self)
  1085.  
  1086. class LoginArea(Area):
  1087.  
  1088. class LoginBoard(SpecialBoard):
  1089.  
  1090. background = "login-bg.tga"
  1091. loginButtonNormal = "login-button.tga"
  1092. loginButtonHover = "login-button-hover.tga"
  1093. loginButtonDown = loginButtonNormal
  1094. loginFailureMsgDict = {}
  1095. loginFailureFuncDict = {}
  1096. __cancelButtonNormal = "button-abbrechen.tga"
  1097. __cancelButtonHover = "button-abbrechen-hover.tga"
  1098. __cancelButtonDown = __cancelButtonNormal
  1099. __loginOldIMEUpdate = None
  1100. __passwordOldIMEUpdate = None
  1101.  
  1102. def __init__(self):
  1103. SpecialBoard.__init__(self)
  1104. #net.SetPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
  1105. #net.SetAccountConnectorHandler(self)
  1106. self.LoadImage(self.background)
  1107. self.loginButton = ui.Button()
  1108. self.loginButton.SetParent(self)
  1109. self.loginButton.SetUpVisual(self.loginButtonNormal)
  1110. self.loginButton.SetOverVisual(self.loginButtonHover)
  1111. self.loginButton.SetDownVisual(self.loginButtonDown)
  1112. self.loginButton.SetPosition(45, 112)
  1113. self.loginButton.SetEvent(ui.__mem_func__(self.__OnClickLoginButton))
  1114. self.loginButton.Show()
  1115.  
  1116. self.loginEditLine = SpecialEditLine()
  1117. self.loginEditLine.SetParent(self)
  1118. self.loginEditLine.SetPlaceHolderText("Utilizador")
  1119. self.loginEditLine.SetPosition(40, 40)
  1120. self.loginEditLine.SetSize(210, 18)
  1121. self.loginEditLine.SetMax(16)
  1122.  
  1123. self.passwordEditLine = SpecialEditLine()
  1124. self.passwordEditLine.SetParent(self)
  1125. self.passwordEditLine.SetPlaceHolderText("Palavra-Senha")
  1126. self.passwordEditLine.SetSecret()
  1127. self.passwordEditLine.SetPosition(40, 80)
  1128. self.passwordEditLine.SetSize(210, 18)
  1129. self.passwordEditLine.SetMax(16)
  1130. self.passwordEditLine.SetReturnEvent(ui.__mem_func__(self.__OnClickLoginButton))
  1131. self.passwordEditLine.SetTabEvent(ui.__mem_func__(self.loginEditLine.SetFocus))
  1132. self.loginEditLine.SetReturnEvent(ui.__mem_func__(self.passwordEditLine.SetFocus))
  1133. self.loginEditLine.SetTabEvent(ui.__mem_func__(self.passwordEditLine.SetFocus))
  1134. self.__loginOldIMEUpdate = self.loginEditLine.OnIMEUpdate
  1135. self.loginEditLine.OnIMEUpdate = lambda : (self.__loginOldIMEUpdate(), stream.SetLoginInfo(self.loginEditLine.GetText(), self.passwordEditLine.GetText()))
  1136. self.__passwordOldIMEUpdate = self.passwordEditLine.OnIMEUpdate
  1137. self.passwordEditLine.OnIMEUpdate = lambda : (self.__passwordOldIMEUpdate(), stream.SetLoginInfo(self.loginEditLine.GetText(), self.passwordEditLine.GetText()))
  1138.  
  1139. self.popupDialog = PopupDialog()
  1140.  
  1141. def PopupNotifyMessage(self, message, closeEvent = 0, buttons = []):
  1142. if not self.popupDialog:
  1143. self.popupDialog = PopupDialog()
  1144. else:
  1145. self.popupDialog.Close()
  1146. self.popupDialog.SetCloseEvent(closeEvent)
  1147. self.popupDialog.SetMessage(message)
  1148. self.popupDialog.SetButtons(buttons)
  1149. self.popupDialog.FadeIn()
  1150.  
  1151. def __OnClickLoginButton(self):
  1152. id = self.loginEditLine.GetText()
  1153. pwd = self.passwordEditLine.GetText()
  1154.  
  1155. if len(id)==0:
  1156. self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, self.SetIDEditLineFocus)
  1157. return
  1158.  
  1159. if len(pwd)==0:
  1160. self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, self.SetPasswordEditLineFocus)
  1161. return
  1162.  
  1163. self.Connect(id, pwd)
  1164.  
  1165. def Connect(self, id, pwd):
  1166. global stream
  1167. if constInfo.SEQUENCE_PACKET_ENABLE:
  1168. net.SetPacketSequenceMode()
  1169.  
  1170. cancelButton = ui.Button()
  1171. cancelButton.SetEvent(lambda *x : self.popupDialog.Close())
  1172. cancelButton.SetUpVisual(self.__cancelButtonNormal)
  1173. cancelButton.SetOverVisual(self.__cancelButtonHover)
  1174. cancelButton.SetDownVisual(self.__cancelButtonDown)
  1175. cancelButton.SetPosition(0, 20)
  1176. cancelButton.SetWindowHorizontalAlignCenter()
  1177. cancelButton.SetWindowVerticalAlignCenter()
  1178. cancelButton.Show()
  1179. self.PopupNotifyMessage(localeInfo.LOGIN_CONNETING, 0, [cancelButton])
  1180.  
  1181. self.stream.SetLoginInfo(id, pwd)
  1182. stream.Connect()
  1183.  
  1184. def Open(self):
  1185. self.loginFailureMsgDict = {
  1186. #"DEFAULT" : localeInfo.LOGIN_FAILURE_UNKNOWN,
  1187.  
  1188. "ALREADY" : localeInfo.LOGIN_FAILURE_ALREAY,
  1189. "NOID" : localeInfo.LOGIN_FAILURE_NOT_EXIST_ID,
  1190. "WRONGPWD" : localeInfo.LOGIN_FAILURE_WRONG_PASSWORD,
  1191. "FULL" : localeInfo.LOGIN_FAILURE_TOO_MANY_USER,
  1192. "SHUTDOWN" : localeInfo.LOGIN_FAILURE_SHUTDOWN,
  1193. "REPAIR" : localeInfo.LOGIN_FAILURE_REPAIR_ID,
  1194. "BLOCK" : localeInfo.LOGIN_FAILURE_BLOCK_ID,
  1195. "WRONGMAT" : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER,
  1196. "QUIT" : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER_TRIPLE,
  1197. "BESAMEKEY" : localeInfo.LOGIN_FAILURE_BE_SAME_KEY,
  1198. "NOTAVAIL" : localeInfo.LOGIN_FAILURE_NOT_AVAIL,
  1199. "NOBILL" : localeInfo.LOGIN_FAILURE_NOBILL,
  1200. "BLKLOGIN" : localeInfo.LOGIN_FAILURE_BLOCK_LOGIN,
  1201. "WEBBLK" : localeInfo.LOGIN_FAILURE_WEB_BLOCK,
  1202. }
  1203.  
  1204. self.loginFailureFuncDict = {
  1205. "WRONGPWD" : self.__DisconnectAndInputPassword,
  1206. "WRONGMAT" : self.__DisconnectAndInputMatrix,
  1207. "QUIT" : app.Exit,
  1208. }
  1209.  
  1210. def Close(self):
  1211. self.loginButton = None
  1212. self.loginEditLine = None
  1213. self.passwordEditLine = None
  1214. self.FadeOut()
  1215. self.loginFailureFuncDict=None
  1216. if self.popupDialog:
  1217. self.popupDialog.Close()
  1218. self.popupDialog = None
  1219.  
  1220. def OnUpdate(self):
  1221. global stream
  1222. SpecialBoard.OnUpdate(self)
  1223. #stream.SetLoginInfo(self.loginEditLine.GetText(), self.passwordEditLine.GetText())
  1224.  
  1225. if self.popupDialog:
  1226. self.popupDialog.OnUpdate()
  1227.  
  1228. if self.fadeProgressFinished() == 1:
  1229. self.loginButton.Show()
  1230. self.loginEditLine.Show()
  1231. self.passwordEditLine.Show()
  1232. else:
  1233. self.loginButton.Hide()
  1234. self.loginEditLine.Hide()
  1235. self.passwordEditLine.Hide()
  1236.  
  1237. def OnConnectFailure(self):
  1238. snd.PlaySound("sound/ui/loginfail.wav")
  1239.  
  1240. if self.popupDialog:
  1241. self.popupDialog.Close()
  1242. self.popupDialog = None
  1243.  
  1244. self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.passwordEditLine.SetFocus)
  1245.  
  1246. def OnHandShake(self):
  1247. if not IsLoginDelay():
  1248. snd.PlaySound("sound/ui/loginok.wav")
  1249. self.PopupDisplayMessage(localeInfo.LOGIN_CONNECT_SUCCESS)
  1250.  
  1251. def OnLoginStart(self):
  1252. if not IsLoginDelay():
  1253. self.PopupDisplayMessage(localeInfo.LOGIN_PROCESSING)
  1254.  
  1255. def OnLoginFailure(self, error):
  1256. if self.popupDialog:
  1257. self.popupDialog.Close()
  1258. self.popupDialog = None
  1259.  
  1260. try:
  1261. loginFailureMsg = self.loginFailureMsgDict[error]
  1262. except KeyError:
  1263. loginFailureMsg = localeInfo.LOGIN_FAILURE_UNKNOWN + error
  1264.  
  1265. loginFailureFunc=self.loginFailureFuncDict.get(error, self.passwordEditLine.SetFocus)
  1266.  
  1267. self.PopupNotifyMessage(loginFailureMsg)#, loginFailureFunc)
  1268.  
  1269. snd.PlaySound("sound/ui/loginfail.wav")
  1270.  
  1271. def __del__(self):
  1272. #net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
  1273. #net.SetAccountConnectorHandler(0)
  1274. SpecialBoard.__del__(self)
  1275.  
  1276. def __init__(self):
  1277. Area.__init__(self)
  1278. self._currentAreaBoard = LoginArea.LoginBoard()
  1279.  
  1280. def Open(self):
  1281. Area.furtherOptionsBoard.SetParent(self)
  1282. Area.Open(self)
  1283.  
  1284. def __del__(self):
  1285. Area.__del__(self)
  1286.  
  1287. class AccountManagementArea(Area):
  1288.  
  1289. class AccountManagementSelectBoard(SpecialBoard):
  1290.  
  1291. class AccountBox(ui.ImageBox):
  1292.  
  1293. __background = "box.tga"
  1294. __instanceCount = 0
  1295. __linkedAccount = len(ACCOUNTS) - 1
  1296. __buttonImages = ["button-acc.tga", "button-acc-hover.tga", "button-acc.tga"]
  1297.  
  1298. def __init__(self):
  1299. ui.ImageBox.__init__(self)
  1300. global LOGIN_IS_PROCESSING
  1301. global ACCOUNTS
  1302. AccountManagementArea.AccountManagementSelectBoard.AccountBox.__instanceCount += 1
  1303. self.__instanceCount = AccountManagementArea.AccountManagementSelectBoard.AccountBox.__instanceCount
  1304. self.LoadImage(self.__background)
  1305.  
  1306. self.__accountLine = ui.TextLine()
  1307. self.__accountLine.SetParent(self)
  1308. self.__accountLine.SetText("Conta %i: %s" % (self.__instanceCount, self.__linkedAccount))
  1309. self.__accountLine.SetPosition(5, 10)
  1310. self.__accountLine.Show()
  1311.  
  1312. self.__loginButton = ui.Button()
  1313. self.__loginButton.SetParent(self)
  1314. self.__SetButtonImages(self.__loginButton, self.__buttonImages)
  1315. self.__loginButton.SetPosition(5, 30)
  1316. self.__loginButton.SetText("Entrar")
  1317. self.__loginButton.Show()
  1318.  
  1319. self.__editButton = ui.Button()
  1320. self.__editButton.SetParent(self)
  1321. self.__SetButtonImages(self.__editButton, self.__buttonImages)
  1322. self.__editButton.SetPosition(self.__loginButton.GetLocalPosition()[0] + self.__loginButton.GetWidth() + 5, 30)
  1323. self.__editButton.SetText("Guardar")
  1324. self.__editButton.Show()
  1325.  
  1326. self.__levelLine = ui.Button()
  1327. self.__levelLine.SetParent(self)
  1328. self.__levelLine.SetText("")
  1329. self.__levelLine.SetPosition(self.GetWidth() - 50, 13)
  1330. self.__levelLine.Show()
  1331.  
  1332. def __SetButtonImages(self, button, images):
  1333. button.SetUpVisual(images[0])
  1334. button.SetOverVisual(images[1])
  1335. button.SetDownVisual(images[2])
  1336.  
  1337. def OnUpdate(self):
  1338. global LOGIN_IS_PROCESSING
  1339. global ACCOUNTS
  1340. global stream
  1341. userCurrent = ACCOUNTS[self.__linkedAccount]
  1342. self.__accountLine.SetText("Conta %i: %s" % (self.__instanceCount, userCurrent["ID"]))
  1343. #hier kommt die automatische Level-Abfrage rein; auf NyBus Wunsch vorerst wieder entfernt
  1344.  
  1345. def SetLinkedAccount(self, index):
  1346. dbg.TraceError(str(index))
  1347. try:
  1348. self.__linkedAccount = index
  1349. except Exception, e:
  1350. pass
  1351.  
  1352. def __del__(self):
  1353. ui.ImageBox.__del__(self)
  1354.  
  1355. __background = "accverwaltung-bg.tga"
  1356. __accountsCount = 3
  1357.  
  1358. def __init__(self):
  1359. SpecialBoard.__init__(self)
  1360. self.LoadImage(self.__background)
  1361. self.__accountBoxesLayout = TableLayout()
  1362. self.__accountBoxesLayout.SetParent(self)
  1363. self.__accountBoxesLayout.SetVerticalLayout()
  1364. for i in xrange(self.__accountsCount):
  1365. accountBox = AccountManagementArea.AccountManagementSelectBoard.AccountBox()
  1366. accountBox.SetLinkedAccount(i)
  1367. accountBox.Show()
  1368. self.__accountBoxesLayout.AddItem(accountBox)
  1369. self.__accountBoxesLayout.SetWindowHorizontalAlignCenter()
  1370. self.__accountBoxesLayout.SetWindowVerticalAlignCenter()
  1371. self.__accountBoxesLayout.Show()
  1372.  
  1373. def OnConnectFailure(self):
  1374. dbg.TraceError("PENIS1")
  1375.  
  1376. def OnLoginStart(self):
  1377. dbg.TraceError("PENIS2")
  1378.  
  1379. def OnHandShake(self):
  1380. global LOGIN_IS_PROCESSING
  1381. global ACCOUNTS
  1382. #LOGIN_IS_PROCESSING = FALSE
  1383. level = net.GetAccountCharacterSlotDataInteger(0, net.ACCOUNT_CHARACTER_SLOT_LEVEL)
  1384.  
  1385. def OnLoginFailure(self, error):
  1386. dbg.TraceError(str(error))
  1387.  
  1388. def OnUpdate(self):
  1389. SpecialBoard.OnUpdate(self)
  1390. for item in self.__accountBoxesLayout.GetItems():
  1391. item.OnUpdate()
  1392.  
  1393. def __del__(self):
  1394. SpecialBoard.__del__(self)
  1395.  
  1396. class AccountManagementEditBoard(SpecialBoard):
  1397.  
  1398. def __init__(self):
  1399. SpecialBoard.__init__(self)
  1400.  
  1401. def __del__(self):
  1402. SpecialBoard.__del__(self)
  1403.  
  1404. def __init__(self):
  1405. global SET_ACCOUNT
  1406. SET_ACCOUNT = self.SetAutoAccount()
  1407. Area.__init__(self)
  1408. self._currentAreaBoard = AccountManagementArea.AccountManagementSelectBoard()
  1409. global ACCOUNTS_REWRITER
  1410. ACCOUNTS_REWRITER()
  1411.  
  1412. def SetAutoAccount(self):
  1413. pass
  1414.  
  1415. def Open(self):
  1416. Area.furtherOptionsBoard.SetParent(self)
  1417. Area.Open(self)
  1418.  
  1419. def __del__(self):
  1420. Area.__del__(self)
  1421.  
  1422. class NewsArea(Area):
  1423.  
  1424. class NewsBoard(SpecialBoard):
  1425.  
  1426. def __init__(self):
  1427. SpecialBoard.__init__(self)
  1428.  
  1429. def __del__(self):
  1430. SpecialBoard.__del__(self)
  1431.  
  1432. def __init__(self):
  1433. Area.__init__(self)
  1434. self._currentAreaBoard = NewsArea.NewsBoard()
  1435.  
  1436. def Open(self):
  1437. Area.furtherOptionsBoard.SetParent(self)
  1438. Area.Open(self)
  1439.  
  1440. def __del__(self):
  1441. Area.__del__(self)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement