Advertisement
Guest User

Untitled

a guest
Jun 13th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.34 KB | None | 0 0
  1. import chr
  2. import grp
  3. import app
  4. import net
  5. import snd
  6. import wndMgr
  7. import event
  8. import systemSetting
  9. import localeInfo
  10.  
  11. import ui
  12. import networkModule
  13. import math
  14. import snd
  15. import musicInfo
  16. import playerSettingModule
  17. import uiScriptLocale
  18. import uiToolTip
  19. import constInfo
  20.  
  21. LOCALE_PATH = "uiscript/"+uiScriptLocale.CODEPAGE+"_"
  22.  
  23. MAN = 0
  24. WOMAN = 1
  25. SHAPE0 = 0
  26. SHAPE1 = 1
  27. PAGE_COUNT = 2
  28. SLOT_COUNT = 4
  29. BASE_CHR_ID = 3
  30.  
  31. class CreateCharacterWindow(ui.Window):
  32.  
  33. SLOT_ROTATION = [135.0, 225.0, 315.0, 45.0]
  34.  
  35.  
  36. CREATE_STAT_POINT = 0
  37.  
  38. STAT_CON = 0
  39. STAT_INT = 1
  40. STAT_STR = 2
  41. STAT_DEX = 3
  42.  
  43. STAT_DESCRIPTION = {
  44. STAT_CON : localeInfo.STAT_TOOLTIP_CON,
  45. STAT_INT : localeInfo.STAT_TOOLTIP_INT,
  46. STAT_STR : localeInfo.STAT_TOOLTIP_STR,
  47. STAT_DEX : localeInfo.STAT_TOOLTIP_DEX,
  48. }
  49.  
  50. START_STAT = ( ## CON INT STR DEX
  51. [ 4, 3, 6, 3, ], ## Warrior
  52. [ 3, 3, 4, 6, ], ## Assassin
  53. [ 3, 5, 5, 3, ], ## Sura
  54. [ 4, 6, 3, 3, ], ## Shaman
  55. [ 4, 3, 6, 3, ], ## Warrior
  56. [ 3, 3, 4, 6, ], ## Assassin
  57. [ 3, 5, 5, 3, ], ## Sura
  58. [ 4, 6, 3, 3, ], ## Shaman
  59. )
  60.  
  61. DESCRIPTION_FILE_NAME = (
  62. uiScriptLocale.JOBDESC_WARRIOR_PATH,
  63. uiScriptLocale.JOBDESC_ASSASSIN_PATH,
  64. uiScriptLocale.JOBDESC_SURA_PATH,
  65. uiScriptLocale.JOBDESC_SHAMAN_PATH,
  66. uiScriptLocale.JOBDESC_WOLFMAN_PATH,
  67. )
  68.  
  69. class DescriptionBox(ui.Window):
  70. def __init__(self):
  71. ui.Window.__init__(self)
  72. self.descIndex = 0
  73. def __del__(self):
  74. ui.Window.__del__(self)
  75. def SetIndex(self, index):
  76. self.descIndex = index
  77. def OnRender(self):
  78. event.RenderEventSet(self.descIndex)
  79.  
  80. class CharacterRenderer(ui.Window):
  81. def OnRender(self):
  82. grp.ClearDepthBuffer()
  83. grp.SetGameRenderState()
  84. grp.PushState()
  85. grp.SetOmniLight()
  86.  
  87. screenWidth = wndMgr.GetScreenWidth()
  88. screenHeight = wndMgr.GetScreenHeight()
  89. newScreenWidth = float(screenWidth - 270)
  90. newScreenHeight = float(screenHeight)
  91.  
  92. grp.SetViewport(270.0/screenWidth, 0.0, newScreenWidth/screenWidth, newScreenHeight/screenHeight)
  93.  
  94. app.SetCenterPosition(0.0, 0.0, 13.0)
  95. app.SetCamera(1550.0, 15.0, 180.0, 95.0)
  96. grp.SetPerspective(11.0, newScreenWidth/newScreenHeight, 1000.0, 3000.0)
  97.  
  98. (x, y) = app.GetCursorPosition()
  99. grp.SetCursorPosition(x, y)
  100.  
  101. chr.Deform()
  102. chr.Render()
  103.  
  104. grp.RestoreViewport()
  105. grp.PopState()
  106. grp.SetInterfaceRenderState()
  107.  
  108. def __init__(self, stream):
  109. print "NEW CREATE WINDOW ----------------------------------------------------------------------------"
  110. ui.Window.__init__(self)
  111. net.SetPhaseWindow(net.PHASE_WINDOW_CREATE, self)
  112.  
  113. self.stream=stream
  114.  
  115. def __del__(self):
  116. print "---------------------------------------------------------------------------- DELETE CREATE WINDOW"
  117.  
  118. net.SetPhaseWindow(net.PHASE_WINDOW_CREATE, 0)
  119. ui.Window.__del__(self)
  120.  
  121. def Open(self):
  122. print "OPEN CREATE WINDOW ----------------------------------------------------------------------------"
  123.  
  124. playerSettingModule.LoadGameData("INIT")
  125.  
  126. self.reservingRaceIndex = -1
  127. self.reservingShapeIndex = -1
  128. self.reservingStartTime = 0
  129. self.stat = [0, 0, 0, 0]
  130.  
  131. self.gender = 0
  132. self.slot = -1
  133. self.shapeList = [
  134. [0, 0, 0, 0],
  135. [0, 0, 0, 0]]
  136.  
  137. self.descIndex = 0
  138.  
  139. try:
  140. dlgBoard = ui.ScriptWindow()
  141. pythonScriptLoader = ui.PythonScriptLoader()
  142. pythonScriptLoader.LoadScriptFile(dlgBoard, uiScriptLocale.LOCALE_UISCRIPT_PATH + "createcharacterwindow.py")
  143.  
  144. except:
  145. import exception
  146. exception.Abort("CreateCharacterWindow.Open.LoadObject")
  147.  
  148. try:
  149. getChild = dlgBoard.GetChild
  150.  
  151. self.Listimgjex = []
  152. self.Listimgjex.append(getChild("name_warriorimg"))
  153. self.Listimgjex.append(getChild("name_assassinimg"))
  154. self.Listimgjex.append(getChild("name_suraimg"))
  155. self.Listimgjex.append(getChild("name_shamanimg"))
  156. self.Listimgjex.append(getChild("name_lycanimg"))
  157.  
  158. self.Listdesjex = []
  159. self.Listdesjex.append(getChild("name_warriordes"))
  160. self.Listdesjex.append(getChild("name_assassindes"))
  161. self.Listdesjex.append(getChild("name_surades"))
  162. self.Listdesjex.append(getChild("name_shamandes"))
  163. self.Listdesjex.append(getChild("name_lycandes"))
  164.  
  165. self.GaugeList = []
  166. self.GaugeList.append(getChild("hth_gauge"))
  167. self.GaugeList.append(getChild("int_gauge"))
  168. self.GaugeList.append(getChild("str_gauge"))
  169. self.GaugeList.append(getChild("dex_gauge"))
  170.  
  171. self.btnCreate = getChild("create_button")
  172. self.btnCancel = getChild("cancel_button")
  173. self.btnPrev = getChild("prev_button")
  174. self.btnNext = getChild("next_button")
  175. self.btnLeft = getChild("left_button")
  176. self.btnRight = getChild("right_button")
  177. self.textBoard = getChild("text_board")
  178.  
  179. self.genderButtonList = []
  180. self.genderButtonList.append(getChild("gender_button_01"))
  181. self.genderButtonList.append(getChild("gender_button_02"))
  182.  
  183. self.shapeButtonList = []
  184. self.shapeButtonList.append(getChild("shape_button_01"))
  185. self.shapeButtonList.append(getChild("shape_button_02"))
  186.  
  187. self.editCharacterName = getChild("character_name_value")
  188.  
  189. self.statValue = []
  190. self.statValue.append(getChild("hth_value"))
  191. self.statValue.append(getChild("int_value"))
  192. self.statValue.append(getChild("str_value"))
  193. self.statValue.append(getChild("dex_value"))
  194.  
  195. getChild("hth_button").ShowToolTip = lambda arg=self.STAT_CON: self.OverInStatButton(arg)
  196. getChild("hth_button").HideToolTip = lambda arg=self.STAT_CON: self.OverOutStatButton()
  197. getChild("int_button").ShowToolTip = lambda arg=self.STAT_INT: self.OverInStatButton(arg)
  198. getChild("int_button").HideToolTip = lambda arg=self.STAT_INT: self.OverOutStatButton()
  199. getChild("str_button").ShowToolTip = lambda arg=self.STAT_STR: self.OverInStatButton(arg)
  200. getChild("str_button").HideToolTip = lambda arg=self.STAT_STR: self.OverOutStatButton()
  201. getChild("dex_button").ShowToolTip = lambda arg=self.STAT_DEX: self.OverInStatButton(arg)
  202. getChild("dex_button").HideToolTip = lambda arg=self.STAT_DEX: self.OverOutStatButton()
  203.  
  204. getChild("hth_button").Hide()
  205. getChild("int_button").Hide()
  206. getChild("str_button").Hide()
  207. getChild("dex_button").Hide()
  208.  
  209. self.backGround = getChild("BackGround")
  210.  
  211. except:
  212. import exception
  213. exception.Abort("CreateCharacterWindow.Open.BindObject")
  214.  
  215. self.btnCreate.SetEvent(ui.__mem_func__(self.CreateCharacter))
  216. self.btnCancel.SetEvent(ui.__mem_func__(self.CancelCreate))
  217. self.btnPrev.SetEvent(ui.__mem_func__(self.PrevDescriptionPage))
  218. self.btnNext.SetEvent(ui.__mem_func__(self.NextDescriptionPage))
  219. self.btnLeft.SetEvent(ui.__mem_func__(self.__DecreaseSlotIndex))
  220. self.btnRight.SetEvent(ui.__mem_func__(self.__IncreaseSlotIndex))
  221.  
  222. self.genderButtonList[0].SetEvent(ui.__mem_func__(self.__SelectGender), MAN)
  223. self.genderButtonList[1].SetEvent(ui.__mem_func__(self.__SelectGender), WOMAN)
  224.  
  225. self.shapeButtonList[0].SetEvent(ui.__mem_func__(self.__SelectShape), SHAPE0)
  226. self.shapeButtonList[1].SetEvent(ui.__mem_func__(self.__SelectShape), SHAPE1)
  227. self.editCharacterName.SetReturnEvent(ui.__mem_func__(self.CreateCharacter))
  228. self.editCharacterName.SetEscapeEvent(ui.__mem_func__(self.CancelCreate))
  229. self.dlgBoard = dlgBoard
  230.  
  231. self.curRotation = [] + self.SLOT_ROTATION
  232. self.destRotation = [] + self.SLOT_ROTATION
  233. self.curNameAlpha = [0.0, 0.0, 0.0, 0.0, 0.0]
  234. self.destNameAlpha = [0.0, 0.0, 0.0, 0.0, 0.0]
  235. self.curGauge = [0.0, 0.0, 0.0, 0.0]
  236. self.destGauge = [0.0, 0.0, 0.0, 0.0]
  237.  
  238. self.descriptionBox = self.DescriptionBox()
  239. self.descriptionBox.Show()
  240.  
  241. self.chrRenderer = self.CharacterRenderer()
  242. self.chrRenderer.SetParent(self.backGround)
  243. self.chrRenderer.Show()
  244.  
  245. self.toolTip = uiToolTip.ToolTip()
  246. self.toolTip.ClearToolTip()
  247.  
  248. self.editCharacterName.SetText("")
  249.  
  250. self.EnableWindow()
  251. self.__SelectSlot(0)
  252.  
  253. app.SetCamera(500.0, 10.0, 180.0, 95.0)
  254.  
  255. self.__MakeCharacter(0, 0, playerSettingModule.RACE_WARRIOR_M)
  256. self.__MakeCharacter(0, 1, playerSettingModule.RACE_ASSASSIN_M)
  257. self.__MakeCharacter(0, 2, playerSettingModule.RACE_SURA_M)
  258. self.__MakeCharacter(0, 3, playerSettingModule.RACE_SHAMAN_M)
  259. self.__MakeCharacter(0, 4, playerSettingModule.RACE_WOLFMAN_M)
  260.  
  261. self.__MakeCharacter(1, 0, playerSettingModule.RACE_WARRIOR_W)
  262. self.__MakeCharacter(1, 1, playerSettingModule.RACE_ASSASSIN_W)
  263. self.__MakeCharacter(1, 2, playerSettingModule.RACE_SURA_W)
  264. self.__MakeCharacter(1, 3, playerSettingModule.RACE_SHAMAN_W)
  265.  
  266. self.__SelectGender(MAN)
  267. self.__SelectShape(0)
  268.  
  269. chr.SelectInstance(self.__GetSlotChrID(0, 0))
  270. chr.Show()
  271. chr.SelectInstance(self.__GetSlotChrID(0, 1))
  272. chr.Hide()
  273. chr.SelectInstance(self.__GetSlotChrID(0, 2))
  274. chr.Hide()
  275. chr.SelectInstance(self.__GetSlotChrID(0, 3))
  276. chr.Hide()
  277. chr.SelectInstance(self.__GetSlotChrID(0, 4))
  278. chr.Hide()
  279. chr.SelectInstance(self.__GetSlotChrID(1, 0))
  280. chr.Hide()
  281. chr.SelectInstance(self.__GetSlotChrID(1, 1))
  282. chr.Hide()
  283. chr.SelectInstance(self.__GetSlotChrID(1, 2))
  284. chr.Hide()
  285. chr.SelectInstance(self.__GetSlotChrID(1, 3))
  286. chr.Hide()
  287.  
  288. self.__SelectSlot(0)
  289.  
  290. self.dlgBoard.Show()
  291. self.Show()
  292.  
  293. if musicInfo.createMusic != "":
  294. snd.SetMusicVolume(systemSetting.GetMusicVolume())
  295. snd.FadeInMusic("BGM/"+musicInfo.createMusic)
  296.  
  297. app.ShowCursor()
  298.  
  299. def Close(self):
  300. print "---------------------------------------------------------------------------- CLOSE CREATE WINDOW"
  301.  
  302. self.editCharacterName.Enable()
  303. self.dlgBoard.ClearDictionary()
  304. self.stream=0
  305. self.shapeButtonList = []
  306. self.genderButtonList = []
  307. self.btnCreate = 0
  308. self.btnCancel = 0
  309. self.btnPrev = 0
  310. self.btnNext = 0
  311. self.btnLeft = 0
  312. self.btnRight = 0
  313. self.textBoard = 0
  314. self.editCharacterName = 0
  315. self.backGround = None
  316.  
  317. if musicInfo.createMusic != "":
  318. snd.FadeOutMusic("BGM/"+musicInfo.createMusic)
  319.  
  320. for id in xrange(BASE_CHR_ID + SLOT_COUNT * PAGE_COUNT):
  321. chr.DeleteInstance(id)
  322.  
  323. self.dlgBoard.Hide()
  324. self.Hide()
  325.  
  326. app.HideCursor()
  327. event.Destroy()
  328.  
  329. def EnableWindow(self):
  330. self.reservingRaceIndex = -1
  331. self.reservingShapeIndex = -1
  332. self.btnCreate.Enable()
  333. self.btnCancel.Enable()
  334. self.btnPrev.Enable()
  335. self.btnNext.Enable()
  336. self.btnLeft.Enable()
  337. self.btnRight.Enable()
  338.  
  339. self.editCharacterName.SetFocus()
  340. self.editCharacterName.Enable()
  341.  
  342. for page in xrange(PAGE_COUNT):
  343. for slot in xrange(SLOT_COUNT):
  344. chr_id = self.__GetSlotChrID(page, slot)
  345. chr.SelectInstance(chr_id)
  346. chr.BlendLoopMotion(chr.MOTION_INTRO_WAIT, 0.1)
  347.  
  348. def DisableWindow(self):
  349. self.btnCreate.Disable()
  350. self.btnCancel.Disable()
  351. self.btnPrev.Disable()
  352. self.btnNext.Disable()
  353. self.btnLeft.Disable()
  354. self.btnRight.Disable()
  355. self.editCharacterName.Disable()
  356.  
  357. self.btnCreate.SetUp()
  358.  
  359. ## Manage Character
  360. def __GetSlotChrID(self, page, slot):
  361. return BASE_CHR_ID + page * SLOT_COUNT + slot
  362.  
  363. def __MakeCharacter(self, page, slot, race):
  364.  
  365. chr_id = self.__GetSlotChrID(page, slot)
  366.  
  367. chr.CreateInstance(chr_id)
  368. chr.SelectInstance(chr_id)
  369. chr.SetVirtualID(chr_id)
  370.  
  371. chr.SetRace(race)
  372. chr.SetArmor(0)
  373. chr.SetHair(0)
  374.  
  375. chr.Refresh()
  376. chr.SetMotionMode(chr.MOTION_MODE_GENERAL)
  377. chr.SetLoopMotion(chr.MOTION_INTRO_WAIT)
  378.  
  379. chr.SetRotation(0.0)
  380. chr.Hide()
  381.  
  382. def __SelectGender(self, gender):
  383. for button in self.genderButtonList:
  384. button.SetUp()
  385.  
  386. self.genderButtonList[gender].Down()
  387.  
  388. self.gender = gender
  389.  
  390. chr.SelectInstance(self.__GetSlotChrID(0, 0))
  391. chr.Hide()
  392. chr.SelectInstance(self.__GetSlotChrID(0, 1))
  393. chr.Hide()
  394. chr.SelectInstance(self.__GetSlotChrID(0, 2))
  395. chr.Hide()
  396. chr.SelectInstance(self.__GetSlotChrID(0, 3))
  397. chr.Hide()
  398. chr.SelectInstance(self.__GetSlotChrID(0, 4))
  399. chr.Hide()
  400. chr.SelectInstance(self.__GetSlotChrID(1, 0))
  401. chr.Hide()
  402. chr.SelectInstance(self.__GetSlotChrID(1, 1))
  403. chr.Hide()
  404. chr.SelectInstance(self.__GetSlotChrID(1, 2))
  405. chr.Hide()
  406. chr.SelectInstance(self.__GetSlotChrID(1, 3))
  407. chr.Hide()
  408.  
  409. if gender == MAN:
  410. if constInfo.SLOTCH == 0 :
  411. chr.SelectInstance(self.__GetSlotChrID(0, 0))
  412. chr.Show()
  413. elif constInfo.SLOTCH == 1 :
  414. chr.SelectInstance(self.__GetSlotChrID(0, 1))
  415. chr.Show()
  416. elif constInfo.SLOTCH == 2 :
  417. chr.SelectInstance(self.__GetSlotChrID(0, 2))
  418. chr.Show()
  419. elif constInfo.SLOTCH == 3 :
  420. chr.SelectInstance(self.__GetSlotChrID(0, 3))
  421. chr.Show()
  422. elif constInfo.SLOTCH == 4 :
  423. chr.SelectInstance(self.__GetSlotChrID(0, 4))
  424. chr.Show()
  425. else:
  426. if constInfo.SLOTCH == 0 :
  427. chr.SelectInstance(self.__GetSlotChrID(1, 0))
  428. chr.Show()
  429. elif constInfo.SLOTCH == 1 :
  430. chr.SelectInstance(self.__GetSlotChrID(1, 1))
  431. chr.Show()
  432. elif constInfo.SLOTCH == 2 :
  433. chr.SelectInstance(self.__GetSlotChrID(1, 2))
  434. chr.Show()
  435. elif constInfo.SLOTCH == 3 :
  436. chr.SelectInstance(self.__GetSlotChrID(1, 3))
  437. chr.Show()
  438.  
  439. def __SelectShape(self, shape):
  440. self.shapeList[self.gender][self.slot] = shape
  441.  
  442. for button in self.shapeButtonList:
  443. button.SetUp()
  444.  
  445. self.shapeButtonList[shape].Down()
  446.  
  447. chr_id = self.__GetSlotChrID(self.gender, self.slot)
  448. chr.SelectInstance(chr_id)
  449. chr.ChangeShape(shape)
  450. chr.SetMotionMode(chr.MOTION_MODE_GENERAL)
  451. chr.SetLoopMotion(chr.MOTION_INTRO_WAIT)
  452.  
  453. def GetSlotIndex(self):
  454. return self.slot
  455.  
  456. def RefreshStat(self):
  457. statSummary = self.stat[0] + self.stat[1] + self.stat[2] + self.stat[3]
  458. self.destGauge = (
  459. float(self.stat[0])/float(statSummary),
  460. float(self.stat[1])/float(statSummary),
  461. float(self.stat[2])/float(statSummary),
  462. float(self.stat[3])/float(statSummary),
  463. )
  464.  
  465. for i in xrange(4):
  466. self.statValue[i].SetText(str(self.stat[i]))
  467.  
  468. def __SelectSlot(self, slot):
  469.  
  470. if slot < 0:
  471. return
  472.  
  473. if slot >= SLOT_COUNT:
  474. return
  475.  
  476. if self.slot == slot:
  477. return
  478.  
  479. self.slot = slot
  480. constInfo.SLOTCH = slot
  481. self.ResetStat()
  482.  
  483. for i in xrange(SLOT_COUNT):
  484. self.destNameAlpha[i] = 0.0
  485.  
  486. self.destNameAlpha[slot] = 1.0
  487.  
  488. for i in xrange(SLOT_COUNT):
  489. self.destRotation[(i+self.slot)%SLOT_COUNT] = self.SLOT_ROTATION[i]
  490.  
  491. if self.IsShow():
  492. snd.PlaySound("sound/ui/click.wav")
  493.  
  494. event.ClearEventSet(self.descIndex)
  495. self.descIndex = event.RegisterEventSet(self.DESCRIPTION_FILE_NAME[self.slot])
  496.  
  497. if localeInfo.IsARABIC():
  498. event.SetEventSetWidth(self.descIndex, 170)
  499.  
  500. chr.SelectInstance(self.__GetSlotChrID(0, 0))
  501. chr.Hide()
  502. chr.SelectInstance(self.__GetSlotChrID(0, 1))
  503. chr.Hide()
  504. chr.SelectInstance(self.__GetSlotChrID(0, 2))
  505. chr.Hide()
  506. chr.SelectInstance(self.__GetSlotChrID(0, 3))
  507. chr.Hide()
  508. chr.SelectInstance(self.__GetSlotChrID(0, 4))
  509. chr.Hide()
  510. chr.SelectInstance(self.__GetSlotChrID(1, 0))
  511. chr.Hide()
  512. chr.SelectInstance(self.__GetSlotChrID(1, 1))
  513. chr.Hide()
  514. chr.SelectInstance(self.__GetSlotChrID(1, 2))
  515. chr.Hide()
  516. chr.SelectInstance(self.__GetSlotChrID(1, 3))
  517. chr.Hide()
  518.  
  519. chr_id = self.__GetSlotChrID(self.gender, slot)
  520. if chr.HasInstance(chr_id):
  521. chr.SelectInstance(chr_id)
  522. self.__SelectShape(self.shapeList[self.gender][slot])
  523. chr.Show()
  524.  
  525. def CreateCharacter(self):
  526.  
  527. if -1 != self.reservingRaceIndex:
  528. return
  529.  
  530. textName = self.editCharacterName.GetText()
  531. if FALSE == self.__CheckCreateCharacter(textName):
  532. return
  533.  
  534. if musicInfo.selectMusic != "":
  535. snd.FadeLimitOutMusic("BGM/"+musicInfo.selectMusic, systemSetting.GetMusicVolume()*0.05)
  536.  
  537. self.DisableWindow()
  538.  
  539.  
  540. chr_id = self.__GetSlotChrID(self.gender, self.slot)
  541.  
  542. chr.SelectInstance(chr_id)
  543.  
  544. self.reservingRaceIndex = chr.GetRace()
  545.  
  546. self.reservingShapeIndex = self.shapeList[self.gender][self.slot]
  547. self.reservingStartTime = app.GetTime()
  548.  
  549. for eachSlot in xrange(SLOT_COUNT):
  550.  
  551. sel_id = self.__GetSlotChrID(self.gender, eachSlot)
  552.  
  553. chr.SelectInstance(sel_id)
  554.  
  555. if eachSlot == self.slot:
  556. chr.PushOnceMotion(chr.MOTION_INTRO_SELECTED)
  557. else:
  558. chr.PushOnceMotion(chr.MOTION_INTRO_NOT_SELECTED)
  559.  
  560. def CancelCreate(self):
  561. self.stream.SetSelectCharacterPhase()
  562.  
  563. def __DecreaseSlotIndex(self):
  564. slotIndex = (self.GetSlotIndex() - 1 + SLOT_COUNT) % SLOT_COUNT
  565. self.__SelectSlot(slotIndex)
  566.  
  567. def __IncreaseSlotIndex(self):
  568. slotIndex = (self.GetSlotIndex() + 1) % SLOT_COUNT
  569. self.__SelectSlot(slotIndex)
  570.  
  571. def PrevDescriptionPage(self):
  572. if TRUE == event.IsWait(self.descIndex):
  573. if event.GetVisibleStartLine(self.descIndex)-5 >= 0:
  574. event.SetVisibleStartLine(self.descIndex, event.GetVisibleStartLine(self.descIndex)-5)
  575. event.Skip(self.descIndex)
  576. else:
  577. event.Skip(self.descIndex)
  578.  
  579. def NextDescriptionPage(self):
  580. if TRUE == event.IsWait(self.descIndex):
  581. event.SetVisibleStartLine(self.descIndex, event.GetVisibleStartLine(self.descIndex)+5)
  582. event.Skip(self.descIndex)
  583. else:
  584. event.Skip(self.descIndex)
  585.  
  586. def __CheckCreateCharacter(self, name):
  587. if len(name) == 0:
  588. self.PopupMessage(localeInfo.CREATE_INPUT_NAME, self.EnableWindow)
  589. return FALSE
  590.  
  591. if name.find(localeInfo.CREATE_GM_NAME)!=-1:
  592. self.PopupMessage(localeInfo.CREATE_ERROR_GM_NAME, self.EnableWindow)
  593. return FALSE
  594.  
  595. if net.IsInsultIn(name):
  596. self.PopupMessage(localeInfo.CREATE_ERROR_INSULT_NAME, self.EnableWindow)
  597. return FALSE
  598.  
  599. return TRUE
  600.  
  601. def ResetStat(self):
  602. for i in xrange(4):
  603. self.stat[i] = self.START_STAT[self.slot][i]
  604. self.lastStatPoint = self.CREATE_STAT_POINT
  605. self.RefreshStat()
  606.  
  607. ## Event
  608. def OnCreateSuccess(self):
  609. self.stream.SetSelectCharacterPhase()
  610.  
  611. def OnCreateFailure(self, type):
  612. if 1 == type:
  613. self.PopupMessage(localeInfo.CREATE_EXIST_SAME_NAME, self.EnableWindow)
  614. else:
  615. self.PopupMessage(localeInfo.CREATE_FAILURE, self.EnableWindow)
  616.  
  617.  
  618. def OnUpdate(self):
  619. chr.Update()
  620.  
  621. (xposEventSet, yposEventSet) = self.textBoard.GetGlobalPosition()
  622. event.UpdateEventSet(self.descIndex, xposEventSet+24, -(yposEventSet+16))
  623. self.descriptionBox.SetIndex(self.descIndex)
  624.  
  625. for i in xrange(4):
  626. self.curNameAlpha[i] += (self.destNameAlpha[i] - self.curNameAlpha[i]) / 10.0
  627. self.Listimgjex[i].SetAlpha(self.curNameAlpha[i])
  628.  
  629. for i in xrange(4):
  630. self.curNameAlpha[i] += (self.destNameAlpha[i] - self.curNameAlpha[i]) / 10.0
  631. self.Listdesjex[i].SetAlpha(self.curNameAlpha[i])
  632.  
  633. for i in xrange(4):
  634. self.curGauge[i] += (self.destGauge[i] - self.curGauge[i]) / 10.0
  635. if abs(self.curGauge[i] - self.destGauge[i]) < 0.005:
  636. self.curGauge[i] = self.destGauge[i]
  637. self.GaugeList[i].SetPercentage(self.curGauge[i], 1.0)
  638.  
  639. for page in xrange(PAGE_COUNT):
  640. for i in xrange(SLOT_COUNT):
  641. chr.SelectInstance(self.__GetSlotChrID(page, i))
  642.  
  643. distance = 1.0
  644. rotRadian = self.curRotation[i] * (math.pi*2) / 360.0
  645. x = distance*math.sin(rotRadian) + distance*math.cos(rotRadian)
  646. y = distance*math.cos(rotRadian) - distance*math.sin(rotRadian)
  647. chr.SetPixelPosition(int(x), int(y), 30)
  648.  
  649. if abs(self.destRotation[i] - self.curRotation[i]) < 1.0:
  650. self.curRotation[i] = self.destRotation[i]
  651.  
  652. dir = app.GetRotatingDirection(self.destRotation[i], self.curRotation[i])
  653. rot = app.GetDegreeDifference(self.destRotation[i], self.curRotation[i])
  654.  
  655. if app.DEGREE_DIRECTION_RIGHT == dir:
  656. self.curRotation[i] += rot / 10.0
  657. elif app.DEGREE_DIRECTION_LEFT == dir:
  658. self.curRotation[i] -= rot / 10.0
  659.  
  660. self.curRotation[i] = (self.curRotation[i] + 360.0) % 360.0
  661.  
  662. ###########################################################
  663. if -1 != self.reservingRaceIndex:
  664. if app.GetTime() - self.reservingStartTime >= 1.5:
  665.  
  666. chrSlot=self.stream.GetCharacterSlot()
  667. textName = self.editCharacterName.GetText()
  668. raceIndex = self.reservingRaceIndex
  669. shapeIndex = self.reservingShapeIndex
  670.  
  671. startStat = self.START_STAT[self.reservingRaceIndex]
  672. statCon = self.stat[0] - startStat[0]
  673. statInt = self.stat[1] - startStat[1]
  674. statStr = self.stat[2] - startStat[2]
  675. statDex = self.stat[3] - startStat[3]
  676.  
  677. net.SendCreateCharacterPacket(chrSlot, textName, raceIndex, shapeIndex, statCon, statInt, statStr, statDex)
  678.  
  679. self.reservingRaceIndex = -1
  680.  
  681. ###########################################################
  682.  
  683. def EmptyFunc(self):
  684. pass
  685.  
  686. def PopupMessage(self, msg, func=0):
  687. if not func:
  688. func=self.EmptyFunc
  689.  
  690. self.stream.popupWindow.Close()
  691. self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)
  692.  
  693. def OnPressExitKey(self):
  694. self.CancelCreate()
  695. return TRUE
  696.  
  697. def OverInStatButton(self, stat):
  698. if not self.STAT_DESCRIPTION.has_key(stat):
  699. return
  700.  
  701. self.toolTip.ClearToolTip()
  702. self.toolTip.AppendTextLine(self.STAT_DESCRIPTION[stat])
  703. self.toolTip.Show()
  704.  
  705. def OverOutStatButton(self):
  706. self.toolTip.Hide()
  707.  
  708. if __name__ == "__main__":
  709.  
  710. import app
  711. import wndMgr
  712. import systemSetting
  713. import mouseModule
  714. import networkModule
  715.  
  716. app.SetMouseHandler(mouseModule.mouseController)
  717. app.SetHairColorEnable(TRUE)
  718. wndMgr.SetMouseHandler(mouseModule.mouseController)
  719. wndMgr.SetScreenSize(systemSetting.GetWidth(), systemSetting.GetHeight())
  720. app.Create(localeInfo.APP_TITLE, systemSetting.GetWidth(), systemSetting.GetHeight(), 1)
  721. mouseModule.mouseController.Create()
  722.  
  723. mainStream = networkModule.MainStream()
  724. mainStream.Create()
  725.  
  726. test = CreateCharacterWindow(mainStream)
  727. test.Open()
  728.  
  729. app.Loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement