Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.06 KB | None | 0 0
  1. import grp
  2. import pythonApi
  3. app = __import__(pythonApi.GetModuleName("app"))
  4. chr = __import__(pythonApi.GetModuleName("chr"))
  5. net = __import__(pythonApi.GetModuleName("net"))
  6. import math
  7. import wndMgr
  8. import snd
  9. import systemSetting
  10. import localeInfo
  11. import constInfo
  12. import ui
  13. import uiScriptLocale
  14. import networkModule
  15. import musicInfo
  16. import playerSettingModule
  17. import dbg
  18. import uiCommon
  19. import uiMapNameShower
  20. import uiAffectShower
  21. import uiPlayerGauge
  22. import uiCharacter
  23. import uiTarget
  24. import consoleModule
  25. import interfaceModule
  26. import uiTaskBar
  27. import uiInventory
  28. import nano_interface
  29. ###################################
  30.  
  31. LEAVE_BUTTON_FOR_POTAL = FALSE
  32. NOT_NEED_DELETE_CODE = FALSE
  33. ENABLE_ENGNUM_DELETE_CODE = TRUE
  34.  
  35. ###################################
  36.  
  37. class SelectCharacterWindow(ui.Window):
  38. SLOT_ROTATION = [144.0,216.0,288.0, 0.0, 72.0, 0,0,0]
  39. SLOT_COUNT = 5
  40. CHARACTER_TYPE_COUNT = 5
  41.  
  42. SLOTS = [0,1,2,3,4]
  43.  
  44. EMPIRE_NAME = {
  45. net.EMPIRE_A : localeInfo.EMPIRE_A,
  46. net.EMPIRE_B : localeInfo.EMPIRE_B
  47. }
  48.  
  49. EMPIRE_NAME_FLAGS_BIG = {
  50. net.EMPIRE_A : nano_interface.CHAR_SELECT + "blue_slot.png",
  51. net.EMPIRE_B : nano_interface.CHAR_SELECT + "green_slot.png",
  52. }
  53.  
  54. EMPIRE_NAME_FLAGS_SMALL = {
  55. net.EMPIRE_A : nano_interface.CHAR_SELECT + "blue_slot_small.png",
  56. net.EMPIRE_B : nano_interface.CHAR_SELECT + "green_slot_small.png",
  57. }
  58.  
  59. class CharacterRenderer(ui.Window):
  60. def OnRender(self):
  61. grp.ClearDepthBuffer()
  62.  
  63. grp.SetGameRenderState()
  64. grp.PushState()
  65. grp.SetOmniLight()
  66.  
  67. screenWidth = wndMgr.GetScreenWidth()
  68. screenHeight = wndMgr.GetScreenHeight()
  69. newScreenWidth = float(screenWidth - 70)
  70. newScreenHeight = float(screenHeight)
  71.  
  72. grp.SetViewport(70.0/screenWidth, 0.0, newScreenWidth/screenWidth, newScreenHeight/screenHeight)
  73.  
  74. app.SetCenterPosition(-10.0, 120.0, 20.0) #p0zitia caracterului
  75. app.SetCamera(1550.0, 15.0, 180.0, 95.0) #p0zitia camerei
  76. grp.SetPerspective(11.0, newScreenWidth/newScreenHeight, 1000.0, 3000.0)
  77.  
  78. (x, y) = app.GetCursorPosition()
  79. grp.SetCursorPosition(x, y)
  80.  
  81. chr.Deform()
  82. chr.Render()
  83.  
  84. grp.RestoreViewport()
  85. grp.PopState()
  86. grp.SetInterfaceRenderState()
  87.  
  88. def __init__(self, stream):
  89. ui.Window.__init__(self)
  90. net.SetPhaseWindow(net.PHASE_WINDOW_SELECT, self)
  91.  
  92. self.stream=stream
  93. self.slot = self.stream.GetCharacterSlot()
  94.  
  95. self.openLoadingFlag = FALSE
  96. self.startIndex = -1
  97. self.startReservingTime = 0
  98.  
  99. self.flagDict = {}
  100. self.curRotation = []
  101. self.destRotation = []
  102. for rot in self.SLOT_ROTATION:
  103. self.curRotation.append(rot)
  104. self.destRotation.append(rot)
  105.  
  106. self.curNameAlpha = []
  107. self.destNameAlpha = []
  108. for i in xrange(self.CHARACTER_TYPE_COUNT):
  109. self.curNameAlpha.append(0.0)
  110. self.destNameAlpha.append(0.0)
  111.  
  112. self.curGauge = [0.0, 0.0, 0.0, 0.0]
  113. self.destGauge = [0.0, 0.0, 0.0, 0.0]
  114.  
  115. self.dlgBoard = 0
  116. self.changeNameFlag = FALSE
  117. self.nameInputBoard = None
  118. self.sendedChangeNamePacket = FALSE
  119. self.notification = 1
  120. self.startIndex = -1
  121. self.isLoad = 0
  122. self.changeSlot = 0
  123. import constInfo
  124. constInfo.BANK_PIN = 0
  125.  
  126. def __del__(self):
  127. ui.Window.__del__(self)
  128. net.SetPhaseWindow(net.PHASE_WINDOW_SELECT, 0)
  129.  
  130. def Open(self):
  131. if not self.__LoadBoardDialog("nano_scripts/selectcharacterwindow.py"):
  132. dbg.TraceError("SelectCharacterWindow.Open - __LoadScript Error")
  133. return
  134.  
  135. if not self.__LoadQuestionDialog("uiscript/questiondialog.py"):
  136. return
  137. self.Rotation = 0
  138. playerSettingModule.LoadGameData("INIT")
  139.  
  140. self.InitCharacterBoard()
  141.  
  142. for objEnable in (self.board["start"],self.board["exit"],self.board["switch_main"][0],self.board["switch_main"][1],self.board["switch_main"][2],self.board["switch_main"][3],self.board["switch_main"][4],self.mainActor["swapSlots"],self.mainActor["startMain"]):
  143. objEnable.Enable()
  144.  
  145. self.dlgBoard.Show()
  146. self.SetWindowName("SelectCharacterWindow")
  147. self.Show()
  148.  
  149. if self.slot>=0:
  150. self.SelectSlot(self.slot)
  151.  
  152. if musicInfo.selectMusic != "":
  153. snd.SetMusicVolume(systemSetting.GetMusicVolume())
  154. snd.FadeInMusic("BGM/"+musicInfo.selectMusic)
  155.  
  156. app.SetCenterPosition(0.0, 0.0, 0.0)
  157. app.SetCamera(1550.0, 15.0, 180.0, 95.0)
  158.  
  159. self.isLoad=1
  160. self.Refresh()
  161.  
  162. if self.stream.isAutoSelect:
  163. chrSlot=self.stream.GetCharacterSlot()
  164. self.SelectSlot(chrSlot)
  165. self.StartGame()
  166.  
  167. self.SetEmpire(net.GetEmpireID())
  168.  
  169. app.ShowCursor()
  170. self.onClickKeyDict = {}
  171. self.onClickKeyDict[app.DIK_RETURN] = lambda : self.StartGame()
  172. self.SetFocus()
  173.  
  174. def Close(self):
  175. if musicInfo.selectMusic != "":
  176. snd.FadeOutMusic("BGM/"+musicInfo.selectMusic)
  177.  
  178. self.stream.popupWindow.Close()
  179.  
  180. if self.dlgBoard:
  181. self.dlgBoard.ClearDictionary()
  182.  
  183. self.empireName = None
  184. self.flagDict = {}
  185. self.dlgBoard = None
  186.  
  187. self.dlgQuestion.ClearDictionary()
  188. self.dlgQuestion = None
  189. self.dlgQuestionText = None
  190. self.dlgQuestionAcceptButton = None
  191. self.dlgQuestionCancelButton = None
  192. self.privateInputBoard = None
  193. self.nameInputBoard = None
  194.  
  195. self.board["start"] = None
  196. self.board["background"] = None
  197.  
  198. self.mainActor["nameMain"] = None
  199. self.mainActor["faceMain"] = None
  200. self.mainActor["guildMain"] = None
  201. self.mainActor["guildSymbolMain"] = None
  202. self.mainActor["levelMain"] = None
  203. self.mainActor["levelSymbolMain"] = None
  204.  
  205. self.mainActor["deleteMain"] = None
  206. self.mainActor["createMain"] = None
  207.  
  208. self.mainActor["startMain"] = None
  209. self.mainActor["swapSlots"] = None
  210. ## Main
  211.  
  212. chr.DeleteInstance(0)
  213. chr.DeleteInstance(1)
  214. chr.DeleteInstance(2)
  215. chr.DeleteInstance(3)
  216. chr.DeleteInstance(4)
  217.  
  218. self.Hide()
  219. self.KillFocus()
  220.  
  221. app.HideCursor()
  222.  
  223. def Refresh(self):
  224. if not self.isLoad:
  225. return
  226.  
  227. indexArray = (4, 3, 2, 1, 0)
  228. for index in indexArray:
  229. id=net.GetAccountCharacterSlotDataInteger(index, net.ACCOUNT_CHARACTER_SLOT_ID)
  230. race=net.GetAccountCharacterSlotDataInteger(index, net.ACCOUNT_CHARACTER_SLOT_RACE)
  231. form=net.GetAccountCharacterSlotDataInteger(index, net.ACCOUNT_CHARACTER_SLOT_FORM)
  232. name=net.GetAccountCharacterSlotDataString(index, net.ACCOUNT_CHARACTER_SLOT_NAME)
  233. hair=net.GetAccountCharacterSlotDataInteger(index, net.ACCOUNT_CHARACTER_SLOT_HAIR)
  234.  
  235. if id:
  236. self.MakeCharacter(index, id, name, race, form, hair)
  237.  
  238. self.SelectSlot(index)
  239.  
  240. self.SelectSlot(self.slot)
  241.  
  242. def RefreshSingleSlot(self):
  243. if not self.isLoad:
  244. return
  245. indexArray = (4, 3, 2, 1, 0)
  246. for i in xrange(8):
  247. if chr.HasInstance(i):
  248. chr.DeleteInstance(i)
  249. # SLOT4
  250.  
  251. id=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_ID)
  252. race=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_RACE)
  253. form=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_FORM)
  254. name=net.GetAccountCharacterSlotDataString(self.slot, net.ACCOUNT_CHARACTER_SLOT_NAME)
  255. hair=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_HAIR)
  256.  
  257. if id:
  258. self.MakeCharacter(self.slot, id, name, race, form, hair)
  259.  
  260. def GetCharacterSlotID(self, slotIndex):
  261. return net.GetAccountCharacterSlotDataInteger(slotIndex, net.ACCOUNT_CHARACTER_SLOT_ID)
  262.  
  263. def __LoadQuestionDialog(self, fileName):
  264. self.dlgQuestion = ui.ScriptWindow()
  265.  
  266. try:
  267. pyScrLoader = ui.PythonScriptLoader()
  268. pyScrLoader.LoadScriptFile(self.dlgQuestion, fileName)
  269. except:
  270. import exception
  271. exception.Abort("SelectCharacterWindow.LoadQuestionDialog.LoadScript")
  272.  
  273. try:
  274. GetObject=self.dlgQuestion.GetChild
  275. self.dlgQuestionText=GetObject("message")
  276. self.dlgQuestionAcceptButton=GetObject("accept")
  277. self.dlgQuestionCancelButton=GetObject("cancel")
  278. except:
  279. import exception
  280. exception.Abort("SelectCharacterWindow.LoadQuestionDialog.BindObject")
  281.  
  282. self.dlgQuestionText.SetText(localeInfo.SELECT_DO_YOU_DELETE_REALLY)
  283. self.dlgQuestionAcceptButton.SetEvent(ui.__mem_func__(self.RequestDeleteCharacter))
  284. self.dlgQuestionCancelButton.SetEvent(ui.__mem_func__(self.dlgQuestion.Hide))
  285. return 1
  286.  
  287. def __LoadBoardDialog(self, fileName):
  288. self.dlgBoard = ui.ScriptWindow()
  289.  
  290. try:
  291. pyScrLoader = ui.PythonScriptLoader()
  292. pyScrLoader.LoadScriptFile(self.dlgBoard, fileName)
  293. except:
  294. import exception
  295. exception.Abort("SelectCharacterWindow.LoadBoardDialog.LoadScript")
  296.  
  297. try:
  298. GetObject=self.dlgBoard.GetChild
  299.  
  300. self.board = {
  301. "proview" : GetObject("proviewBoard"),
  302. "boardExit" : GetObject("Exit_Board"),
  303. "slot" : [GetObject("Slot_%d" % (i)) for i in xrange(5)],
  304. "create" : [GetObject("create_slot_%d" % (i)) for i in xrange(5)],
  305. "delete" : [GetObject("delete_slot_%d" % (i)) for i in xrange(5)],
  306. "select" : [GetObject("Select_slot_%d" % (i)) for i in xrange(5)],
  307.  
  308. "face" : [GetObject("face_small_%d" % (i)) for i in xrange(5)],
  309.  
  310. "guild" : [GetObject("guild_text_small_%d" % (i)) for i in xrange(5)],
  311. "name" : [GetObject("name_small_%d" % (i)) for i in xrange(5)],
  312. "level" : [GetObject("level_value_%d" % (i)) for i in xrange(5)],
  313.  
  314. "levelSym" : [GetObject("level_decoration_%d" % (i)) for i in xrange(5)],
  315. "guildSym" : [GetObject("guild_symbol_small_%d" % (i)) for i in xrange(5)],
  316.  
  317. "ghostFlag" : [GetObject("effect_%d" % (i)) for i in xrange(5)],
  318.  
  319. "start" : GetObject("confirm_button"),
  320. "exit" : GetObject("exit_button"),
  321.  
  322. "switch_main" : [GetObject("switch_main_%d" % (i)) for i in xrange(5)],
  323.  
  324. "exitBoard" : GetObject("Exit_Board"),
  325. "notification_board" : GetObject("Notification"),
  326. "notification_btn" : GetObject("notification_btn"),
  327.  
  328. }
  329.  
  330. self.mainActor = {
  331. "mainActorBoard" : GetObject("Main_Actor"),
  332. "backGround" : GetObject("Shad_BackGround"),
  333. ## Buttons
  334. "startMain" : GetObject("confirm_button_mainActor"),
  335. "exitMain" : GetObject("exit_button_mainActor"),
  336. "swapSlots" : GetObject("switch_MainSlots"),
  337. "deleteMain" : GetObject("deleteSlot_fromMainActor"),
  338. "createMain" : GetObject("createSlot_fromMainActor"),
  339. "flagMain" : GetObject("flag_main_actor"),
  340.  
  341. ## Texts
  342. "nameMain" : GetObject("name_mainActor"),
  343. "faceMain" : GetObject("face_race_mainActor"),
  344. "guildSymbolMain" : GetObject("guild_symbol_mainActor"),
  345. "guildMain" : GetObject("guild_name_mainActor"),
  346. "levelSymbolMain" : GetObject("level_symbol_fromMainActor"),
  347. "levelMain" : GetObject("level_name_fromMainActor"),
  348.  
  349. "exitMainBoard" : GetObject("Exit_MainActor_Board"),
  350.  
  351. }
  352. self.Status = {
  353. ## Status
  354. 0 : GetObject("gauge_hth"),
  355. 1 : GetObject("gauge_int"),
  356. 2 : GetObject("gauge_str"),
  357. 3 : GetObject("gauge_dex"),
  358. }
  359. self.CharacterHTH = GetObject("character_hth")
  360. self.CharacterINT = GetObject("character_int")
  361. self.CharacterSTR = GetObject("character_str")
  362. self.CharacterDEX = GetObject("character_dex")
  363.  
  364. self.NameList = []
  365.  
  366. except:
  367. import exception
  368. exception.Abort("SelectCharacterWindow.LoadBoardDialog.BindObject")
  369.  
  370. [name.SetAlpha(0.0) for name in self.NameList]
  371. self.__CloseMainActor()
  372. ## Board
  373. self.board["start"].SetEvent(ui.__mem_func__(self.StartGame))
  374. self.board["exit"].SetEvent(ui.__mem_func__(self.OnPressExitKey))
  375.  
  376. self.board["notification_btn"].SetEvent(ui.__mem_func__(self.Notification))
  377.  
  378.  
  379. for i in xrange(5):
  380. if NOT_NEED_DELETE_CODE:
  381. self.mainActor["deleteMain"].SetEvent(ui.__mem_func__(self.PopupDeleteQuestion))
  382. self.board["delete"][i].SetEvent(ui.__mem_func__(self.PopupDeleteQuestionMulti),i)
  383. else:
  384. self.mainActor["deleteMain"].SetEvent(ui.__mem_func__(self.InputPrivateCode))
  385. self.board["delete"][i].SetEvent(ui.__mem_func__(self.InputPrivateCodeMulty),i)
  386.  
  387. self.board["select"][i].SetEvent(ui.__mem_func__(self.SelectSlot),i)
  388. self.board["create"][i].SetEvent(ui.__mem_func__(self.CreateCharacterMulti),i)
  389. self.board["switch_main"][i].SetEvent(ui.__mem_func__(self.__ShowMainActor),i)
  390.  
  391. self.mainActor["startMain"].SetEvent(ui.__mem_func__(self.StartGame))
  392. self.mainActor["createMain"].SetEvent(ui.__mem_func__(self.CreateCharacter))
  393.  
  394. self.mainActor["swapSlots"].SetEvent(ui.__mem_func__(self.__SwitchSlotButton))
  395. self.mainActor["exitMain"].SetEvent(ui.__mem_func__(self.__CloseMainActor))
  396.  
  397. self.chrRenderer = self.CharacterRenderer()
  398. self.chrRenderer.SetParent(self.mainActor["backGround"])
  399. self.chrRenderer.Show()
  400.  
  401. self.Slots(0)
  402. return 1
  403.  
  404. def MakeCharacter(self, index, id, name, race, form, hair):
  405. if 0 == id:
  406. return
  407.  
  408. chr.CreateInstance(index)
  409. chr.SelectInstance(index)
  410. chr.SetVirtualID(index)
  411. chr.SetNameString(name)
  412.  
  413. chr.SetRace(race)
  414. chr.SetArmor(form)
  415. chr.SetHair(hair)
  416.  
  417. chr.Refresh()
  418. chr.SetMotionMode(chr.MOTION_MODE_GENERAL)
  419. chr.SetLoopMotion(chr.MOTION_INTRO_WAIT)
  420.  
  421. chr.SetRotation(0.0)
  422.  
  423. def Notification(self):
  424. if self.notification == 0:
  425. self.board["notification_board"].Show()
  426. self.notification += 1
  427. else:
  428. self.board["notification_board"].Hide()
  429. self.notification -= 1
  430.  
  431. def Slots(self, slot):
  432. def CreateSlot(key):
  433. id=net.GetAccountCharacterSlotDataInteger(key, net.ACCOUNT_CHARACTER_SLOT_ID)
  434. if 0 != id:
  435. self.board["start"].Enable()
  436. self.SetEmpire(net.GetEmpireID())
  437. name=net.GetAccountCharacterSlotDataString(key, net.ACCOUNT_CHARACTER_SLOT_NAME)
  438. level=net.GetAccountCharacterSlotDataInteger(key, net.ACCOUNT_CHARACTER_SLOT_LEVEL)
  439. race=net.GetAccountCharacterSlotDataInteger(key, net.ACCOUNT_CHARACTER_SLOT_RACE)
  440. guildID=net.GetAccountCharacterSlotDataInteger(key, net.ACCOUNT_CHARACTER_SLOT_GUILD_ID)
  441. guildName=net.GetAccountCharacterSlotDataString(key, net.ACCOUNT_CHARACTER_SLOT_GUILD_NAME)
  442. job = chr.RaceToJob(race)
  443. if job >= 0 and job < self.CHARACTER_TYPE_COUNT:
  444. self.destNameAlpha[job] = 1.0
  445.  
  446. self.board["name"][key].SetText(name)
  447. self.board["level"][key].SetText(str(level))
  448. self.board["create"][key].Hide()
  449. self.board["ghostFlag"][key].Hide()
  450. for showObj in (self.board["name"][key],self.board["slot"][key],self.board["levelSym"][key],self.board["guildSym"][key]):
  451. showObj.Show()
  452. if key == 0:
  453. self.board["face"][key].LoadImage(nano_interface.FACE_IMAGE_SELECT_BIG[race])
  454. else:
  455. self.board["face"][key].LoadImage(nano_interface.FACE_IMAGE_SELECT_SMALLER[race])
  456. if 0 != guildID:
  457. self.board["guild"][key].SetText(guildName)
  458. self.board["guildSym"][key].Show()
  459. else:
  460. self.board["guildSym"][key].Hide()
  461. else:
  462. self.InitChanges(key)
  463.  
  464. for i in xrange(5):
  465. CreateSlot(i)
  466. if i == slot:
  467. self.board["select"][i].Down()
  468. else:
  469. self.board["select"][i].SetUp()
  470.  
  471. def InitChanges(self,key):
  472. self.board["create"][key].Show()
  473. self.board["delete"][key].Hide()
  474. self.board["ghostFlag"][key].Show()
  475. self.board["face"][key].Show()
  476.  
  477. for emptyList in (self.board["name"][key],self.board["level"][key]):
  478. emptyList.SetText("")
  479.  
  480. for hideListas in (self.board["levelSym"][key],self.board["slot"][key]):
  481. hideListas.Hide()
  482.  
  483. def __CloseMainActor(self):
  484. for hideObj in (self.mainActor["mainActorBoard"],self.mainActor["exitMainBoard"],self.mainActor["backGround"]):
  485. hideObj.Hide()
  486. self.board["exitBoard"].Show()
  487.  
  488. def __ShowMainActor(self, index):
  489. self.SelectSlot(index)
  490. for hideObj in (self.mainActor["mainActorBoard"],self.mainActor["exitMainBoard"],self.mainActor["backGround"]):
  491. hideObj.Show()
  492. self.board["exitBoard"].Hide()
  493.  
  494. def __SwitchSlotButton(self):
  495. slotIndex = (self.GetSlotIndex() + 1) % self.SLOT_COUNT
  496. self.SelectSlot(slotIndex)
  497.  
  498. ## Manage Character
  499. def StartGame(self):
  500. if self.sendedChangeNamePacket:
  501. return
  502.  
  503. if self.changeNameFlag:
  504. self.OpenChangeNameDialog()
  505. return
  506.  
  507. if -1 != self.startIndex:
  508. return
  509.  
  510. if musicInfo.selectMusic != "":
  511. snd.FadeLimitOutMusic("BGM/"+musicInfo.selectMusic, systemSetting.GetMusicVolume()*0.05)
  512.  
  513. for setUpObjects in [self.board["start"], self.mainActor["swapSlots"],self.mainActor["startMain"]]:
  514. setUpObjects.SetUp()
  515.  
  516. for disableObjects in [self.board["start"], self.mainActor["swapSlots"],self.mainActor["startMain"]]:
  517. disableObjects.Disable()
  518.  
  519. for btn in (self.board["create"][:]+self.board["delete"][:]):
  520. btn.SetUp(),btn.Disable()
  521.  
  522. self.dlgQuestion.Hide()
  523.  
  524. self.stream.SetCharacterSlot(self.slot)
  525.  
  526. self.startIndex = self.slot
  527. self.startReservingTime = app.GetTime()
  528.  
  529. for i in xrange(self.SLOT_COUNT):
  530. if FALSE == chr.HasInstance(i):
  531. continue
  532. chr.SelectInstance(i)
  533. if i == self.slot:
  534. chr.PushOnceMotion(chr.MOTION_INTRO_SELECTED, 0.1)
  535. continue
  536. chr.PushOnceMotion(chr.MOTION_INTRO_NOT_SELECTED, 0.1)
  537.  
  538. def OpenChangeNameDialog(self):
  539. import uiCommon
  540. nameInputBoard = uiCommon.InputDialogWithDescription()
  541. nameInputBoard.SetAcceptEvent(ui.__mem_func__(self.AcceptInputName))
  542. nameInputBoard.SetCancelEvent(ui.__mem_func__(self.CancelInputName))
  543. nameInputBoard.SetDescription(localeInfo.SELECT_INPUT_CHANGING_NAME)
  544. nameInputBoard.Open()
  545. nameInputBoard.slot = self.slot
  546. self.nameInputBoard = nameInputBoard
  547.  
  548. def OnChangeName(self, id, name):
  549. self.SelectSlot(id)
  550. self.sendedChangeNamePacket = FALSE
  551. self.PopupMessage(localeInfo.SELECT_CHANGED_NAME)
  552.  
  553. def AcceptInputName(self):
  554. changeName = self.nameInputBoard.GetText()
  555. if not changeName:
  556. return
  557.  
  558. self.sendedChangeNamePacket = TRUE
  559. net.SendChangeNamePacket(self.nameInputBoard.slot, changeName)
  560. return self.CancelInputName()
  561.  
  562. def CancelInputName(self):
  563. self.nameInputBoard.Close()
  564. self.nameInputBoard = None
  565. return TRUE
  566.  
  567. def OnCreateFailure(self, type):
  568. self.sendedChangeNamePacket = FALSE
  569. if 0 == type:
  570. self.PopupMessage(localeInfo.SELECT_CHANGE_FAILURE_STRANGE_NAME)
  571. elif 1 == type:
  572. self.PopupMessage(localeInfo.SELECT_CHANGE_FAILURE_ALREADY_EXIST_NAME)
  573. elif 2 == type:
  574. self.PopupMessage(localeInfo.CREATE_FAILURE_5RAZA)
  575. elif 100 == type:
  576. self.PopupMessage(localeInfo.SELECT_CHANGE_FAILURE_STRANGE_INDEX)
  577.  
  578. def CreateCharacter(self):
  579. id = self.GetCharacterSlotID(self.slot)
  580. if 0==id:
  581. self.stream.SetCharacterSlot(self.slot)
  582.  
  583. EMPIRE_MODE = 1
  584.  
  585. if EMPIRE_MODE:
  586. if self.__AreAllSlotEmpty():
  587. self.stream.SetReselectEmpirePhase()
  588. else:
  589. self.stream.SetCreateCharacterPhase()
  590. else:
  591. self.stream.SetCreateCharacterPhase()
  592.  
  593. def CreateCharacterMulti(self,slot):
  594. id = self.GetCharacterSlotID(slot)
  595. if 0==id:
  596. self.stream.SetCharacterSlot(slot)
  597. EMPIRE_MODE = 1
  598.  
  599. if EMPIRE_MODE:
  600. if self.__AreAllSlotEmpty():
  601. self.stream.SetReselectEmpirePhase()
  602. else:
  603. self.stream.SetCreateCharacterPhase()
  604. else:
  605. self.stream.SetCreateCharacterPhase()
  606.  
  607. def __AreAllSlotEmpty(self):
  608. for iSlot in xrange(self.SLOT_COUNT):
  609. if 0!=net.GetAccountCharacterSlotDataInteger(iSlot, net.ACCOUNT_CHARACTER_SLOT_ID):
  610. return 0
  611. return 1
  612.  
  613. def PopupDeleteQuestion(self):
  614. id = self.GetCharacterSlotID(self.slot)
  615. self.SelectSlot(self.slot)
  616. if 0 == id:
  617. return
  618.  
  619. self.dlgQuestion.Show()
  620. self.dlgQuestion.SetTop()
  621.  
  622. def PopupDeleteQuestionMulti(self,slot):
  623. id = self.GetCharacterSlotID(slot)
  624. if 0 == id:
  625. return
  626.  
  627. self.dlgQuestion.Show()
  628. self.dlgQuestion.SetTop()
  629. #dbg.LogBox("%d" % slot)
  630. def RequestDeleteCharacter(self):
  631. self.dlgQuestion.Hide()
  632.  
  633. id = self.GetCharacterSlotID(self.slot)
  634. if 0 == id:
  635. self.PopupMessage(localeInfo.SELECT_EMPTY_SLOT)
  636. return
  637.  
  638. net.SendDestroyCharacterPacket(self.slot, "1234567")
  639. self.PopupMessage(localeInfo.SELECT_DELEING)
  640.  
  641. def InputPrivateCode(self):
  642. import uiCommon
  643. privateInputBoard = uiCommon.InputDialogWithDescription()
  644. privateInputBoard.SetAcceptEvent(ui.__mem_func__(self.AcceptInputPrivateCode))
  645. privateInputBoard.SetCancelEvent(ui.__mem_func__(self.CancelInputPrivateCode))
  646.  
  647. if not ENABLE_ENGNUM_DELETE_CODE:
  648. privateInputBoard.SetNumberMode()
  649.  
  650. privateInputBoard.SetSecretMode()
  651. privateInputBoard.SetMaxLength(7)
  652.  
  653. privateInputBoard.SetDescription("CODE:")
  654. privateInputBoard.Open()
  655. self.privateInputBoard = privateInputBoard
  656.  
  657. def InputPrivateCodeMulty(self, slot):
  658. self.SelectSlot(slot)
  659. import uiCommon
  660. privateInputBoard = uiCommon.InputDialogWithDescription()
  661. privateInputBoard.SetAcceptEvent(ui.__mem_func__(self.AcceptInputPrivateCode))
  662. privateInputBoard.SetCancelEvent(ui.__mem_func__(self.CancelInputPrivateCode))
  663.  
  664. if not ENABLE_ENGNUM_DELETE_CODE:
  665. privateInputBoard.SetNumberMode()
  666.  
  667. privateInputBoard.SetSecretMode()
  668. privateInputBoard.SetMaxLength(7)
  669.  
  670. privateInputBoard.SetDescription("CODE:")
  671. privateInputBoard.Open()
  672. self.privateInputBoard = privateInputBoard
  673.  
  674. def AcceptInputPrivateCodeMulty(self,slot):
  675. privateCode = self.privateInputBoard.GetText()
  676. if not privateCode:
  677. return
  678.  
  679. id = self.GetCharacterSlotID(slot)
  680. self.SelectSlot(self.slot)
  681. if 0 == id:
  682. self.PopupMessage(localeInfo.SELECT_EMPTY_SLOT)
  683. return
  684.  
  685. net.SendDestroyCharacterPacket(slot, privateCode)
  686. self.PopupMessage(localeInfo.SELECT_DELEING)
  687.  
  688. self.CancelInputPrivateCode()
  689. return TRUE
  690.  
  691. def AcceptInputPrivateCode(self):
  692. privateCode = self.privateInputBoard.GetText()
  693. if not privateCode:
  694. return
  695.  
  696. id = self.GetCharacterSlotID(self.slot)
  697. self.SelectSlot(self.slot)
  698. if 0 == id:
  699. self.PopupMessage(localeInfo.SELECT_EMPTY_SLOT)
  700. return
  701.  
  702. net.SendDestroyCharacterPacket(self.slot, privateCode)
  703. self.PopupMessage(localeInfo.SELECT_DELEING)
  704.  
  705. self.CancelInputPrivateCode()
  706. return TRUE
  707.  
  708. def CancelInputPrivateCode(self):
  709. self.privateInputBoard = None
  710. return TRUE
  711.  
  712. def OnDeleteSuccess(self, slot):
  713. self.PopupMessage(localeInfo.SELECT_DELETED)
  714. self.DeleteCharacter(slot)
  715.  
  716. def OnDeleteFailure(self):
  717. self.PopupMessage(localeInfo.SELECT_CAN_NOT_DELETE)
  718.  
  719. def DeleteCharacter(self, index):
  720. chr.DeleteInstance(index)
  721. self.SelectSlot(self.slot)
  722.  
  723. def ExitSelect(self):
  724. self.dlgQuestion.Hide()
  725.  
  726. if LEAVE_BUTTON_FOR_POTAL:
  727. if app.loggined:
  728. self.stream.SetPhaseWindow(0)
  729. else:
  730. self.stream.setloginphase()
  731. else:
  732. self.stream.SetLoginPhase()
  733.  
  734. self.Hide()
  735.  
  736. def GetSlotIndex(self):
  737. return self.slot
  738.  
  739. def SetEmpire(self, id):
  740. for wnd in self.board["slot"][1:]:
  741. wnd.LoadImage(self.EMPIRE_NAME_FLAGS_SMALL[id])
  742. self.board["slot"][0].LoadImage(self.EMPIRE_NAME_FLAGS_BIG[id])
  743. self.mainActor["flagMain"].LoadImage(self.EMPIRE_NAME_FLAGS_BIG[id])
  744.  
  745. def SelectSlot(self, index):
  746. if index < 0:
  747. return
  748. if index >= self.SLOT_COUNT:
  749. return
  750. self.slot = index
  751. self.RefreshSingleSlot()
  752. chr.SelectInstance(self.slot)
  753.  
  754. for i in xrange(self.CHARACTER_TYPE_COUNT):
  755. self.destNameAlpha[i] = 0.0
  756.  
  757. for i in xrange(self.SLOT_COUNT):
  758. self.destRotation[(i+self.slot)%self.SLOT_COUNT] = self.SLOT_ROTATION[i]
  759.  
  760. self.destGauge = [0.0, 0.0, 0.0, 0.0, 0.0]
  761.  
  762. id=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_ID)
  763. if index == id:
  764. self.board["delete"][index].Hide()
  765. self.board["start"].Disable()
  766. else:
  767. self.board["delete"][index].Show()
  768. self.board["start"].Enable()
  769. self.Slots(index)
  770.  
  771. if 0 != id:
  772. self.SetEmpire(net.GetEmpireID())
  773.  
  774. self.board["start"].Enable()
  775. self.mainActor["startMain"].Enable()
  776.  
  777. playTime=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_PLAYTIME)
  778. level=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_LEVEL)
  779. race=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_RACE)
  780. valueHTH=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_HTH)
  781. valueINT=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_INT)
  782. valueSTR=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_STR)
  783. valueDEX=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_DEX)
  784. name=net.GetAccountCharacterSlotDataString(self.slot, net.ACCOUNT_CHARACTER_SLOT_NAME)
  785. guildID=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_GUILD_ID)
  786. guildName=net.GetAccountCharacterSlotDataString(self.slot, net.ACCOUNT_CHARACTER_SLOT_GUILD_NAME)
  787. self.changeNameFlag=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_CHANGE_NAME_FLAG)
  788.  
  789. job = chr.RaceToJob(race)
  790. if job >= 0 and job < self.CHARACTER_TYPE_COUNT:
  791. self.destNameAlpha[job] = 1.0
  792.  
  793. self.mainActor["nameMain"].SetText(name)
  794. self.mainActor["levelMain"].SetText(str(level))
  795. self.mainActor["faceMain"].LoadImage(nano_interface.FACE_IMAGE_SELECT_BIG[race])
  796. self.mainActor["levelSymbolMain"].Show()
  797. self.mainActor["createMain"].Hide()
  798. self.mainActor["deleteMain"].Show()
  799.  
  800. if guildName:
  801. self.mainActor["guildMain"].SetText(guildName)
  802. self.mainActor["guildSymbolMain"].Show()
  803. else:
  804. self.mainActor["guildSymbolMain"].Hide()
  805.  
  806. self.destGauge = [0.0, 0.0, 0.0, 0.0, 0.0]
  807. self.destGauge = [
  808. ((float(valueHTH) * 10) / 150) / 10,
  809. ((float(valueINT) * 10) / 150) / 10,
  810. ((float(valueSTR) * 10) / 150) / 10,
  811. ((float(valueDEX) * 10) / 150) / 10
  812. ]
  813.  
  814. else:
  815. self.InitCharacterBoard()
  816.  
  817. ### Problemaaa
  818. def InitCharacterBoard(self):
  819. self.board["start"].Disable()
  820. self.mainActor["startMain"].Disable()
  821.  
  822. for emptyObjects in [self.mainActor["nameMain"], self.mainActor["levelMain"], self.CharacterHTH, self.CharacterINT, self.CharacterSTR, self.CharacterDEX]:
  823. emptyObjects.SetText("")
  824.  
  825. for hideObjects in [self.mainActor["guildSymbolMain"], self.mainActor["levelSymbolMain"], self.mainActor["deleteMain"]]:
  826. hideObjects.Hide()
  827.  
  828. for showObjects in [self.mainActor["createMain"]]:
  829. showObjects.Show()
  830.  
  831. self.mainActor["faceMain"].LoadImage(nano_interface.PATCH + "faces/select_big_face/icon_mwarrior.png")
  832.  
  833. ## Event
  834. def OnKeyDown(self, key):
  835. if 1 == key:
  836. self.ExitSelect()
  837. if 2 == key:
  838. self.SelectSlot(0)
  839. if 3 == key:
  840. self.SelectSlot(1)
  841. if 4 == key:
  842. self.SelectSlot(2)
  843. if 5 == key:
  844. self.SelectSlot(3)
  845. if 6 == key:
  846. self.SelectSlot(4)
  847.  
  848. if 28 == key:
  849. id = net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_ID)
  850. if 0 == id:
  851. self.CreateCharacter()
  852. else:
  853. self.StartGame()
  854.  
  855. if 203 == key:
  856. self.slot = (self.GetSlotIndex() - 1 + self.SLOT_COUNT) % self.SLOT_COUNT
  857. self.SelectSlot(self.slot)
  858. if 205 == key:
  859. self.slot = (self.GetSlotIndex() + 1) % self.SLOT_COUNT
  860. self.SelectSlot(self.slot)
  861.  
  862. return TRUE
  863.  
  864. def OnUpdate(self):
  865. chr.Update()
  866. self.Rotation = self.Rotation - 0.5
  867. chr.SetRotation(self.Rotation)
  868. ## If slot 0 is deleted
  869. id=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_ID)
  870. if self.slot == 0 and id == 0:
  871. self.board["slot"][0].Hide()
  872. self.board["create"][0].Show()
  873. self.board["ghostFlag"][0].Show()
  874.  
  875. for i in xrange(4):
  876. self.curGauge[i] += (self.destGauge[i] - self.curGauge[i]) / 10.0
  877. if abs(self.curGauge[i] - self.destGauge[i]) < 0.005:
  878. self.curGauge[i] = self.destGauge[i]
  879. self.Status[i].SetPercentage(self.curGauge[i], 1.0)
  880.  
  881. for i in xrange(self.CHARACTER_TYPE_COUNT):
  882. self.curNameAlpha[i] += (self.destNameAlpha[i] - self.curNameAlpha[i]) / 10.0
  883. if len(self.NameList) > i:
  884. self.NameList[i].SetAlpha(self.curNameAlpha[i])
  885.  
  886. if -1 != self.startIndex:
  887.  
  888. if app.GetTime() - self.startReservingTime > 3.0:
  889. if FALSE == self.openLoadingFlag:
  890. chrSlot=self.stream.GetCharacterSlot()
  891. net.DirectEnter(chrSlot)
  892. self.openLoadingFlag = TRUE
  893.  
  894. playTime=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_PLAYTIME)
  895.  
  896. import pythonApi
  897. player = __import__(pythonApi.GetModuleName("player"))
  898. player.SetPlayTime(playTime)
  899. import chat
  900. chat.Clear()
  901. ## Temporary
  902. #######################################################
  903.  
  904. def EmptyFunc(self):
  905. pass
  906.  
  907. def PopupMessage(self, msg, func=0):
  908. if not func:
  909. func=self.EmptyFunc
  910.  
  911. self.stream.popupWindow.Close()
  912. self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)
  913.  
  914. def OnPressExitKey(self):
  915. self.ExitSelect()
  916. return TRUE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement