1. import app
  2. import ui
  3. import uiScriptLocale
  4. import uiToolTip
  5. import mouseModule
  6. import constInfo
  7. import localeInfo
  8. import skill
  9. import net
  10. import player
  11. import item
  12. import chr
  13. import effect
  14. import dbg
  15. import background
  16. from _weakref import proxy
  17. from itertools import islice
  18. import math
  19. import constInfo
  20. class DungeonTimer(ui.ScriptWindow):
  21. class SearchResultItem(ui.Window):
  22. def __init__(self, parent, index):
  23. ui.Window.__init__(self)
  24. self.parent = parent
  25. self.isLoad = True
  26. self.isSelected = False
  27. self.index = index
  28. self.SetParent(parent)
  29. self.InitItem()
  30. def InitItem(self):
  31. startX = 18
  32. yPos = 3
  33. self.dungeonImage = ui.MakeImageBox(self, "dungeontimer/normal.tga", 3, yPos+2)
  34. self.dungeonImage.SAFE_SetStringEvent("MOUSE_LEFT_BUTTON_UP",self.__OnSelect)
  35. self.dungeonImage.SetTop()
  36. self.dungeonImage.Show()
  37. self.text = ui.TextLine()
  38. self.text.SetParent(self)
  39. self.text.SetPosition(startX+67-40, yPos+12)
  40. # self.text.SetHorizontalAlignCenter()
  41. self.text.Show()
  42. self.count = ui.TextLine()
  43. self.count.SetParent(self)
  44. self.count.SetPosition(startX+303-90, yPos+12)
  45. self.count.SetHorizontalAlignCenter()
  46. self.count.Show()
  47. self.bossImage = ui.ImageBox()
  48. self.bossImage.SetParent(self.dungeonImage)
  49. self.bossImage.SetPosition(1, 1)
  50. self.bossImage.Show()
  51. self.SetSize(self.dungeonImage.GetWidth(), self.dungeonImage.GetHeight())
  52. def SetDungeonName(self, name):
  53. self.text.SetText(name)
  54. def SetDungeonTime(self, count):
  55. self.count.SetText(count)
  56. def SetBossImage(self, boss):
  57. self.bossImage.LoadImage(boss)
  58. def __OnSelect(self):
  59. self.parent.OnSearchResultItemSelect(self.index)
  60. def Select(self):
  61. self.isSelected = True
  62. self.isLoad = True
  63. def UnSelect(self):
  64. self.isSelected = False
  65. self.isLoad = True
  66. def OnUpdate(self):
  67. if player.GetStatus(player.LEVEL) < int(constInfo.dungeontimerinfo[int(self.index)][3]):
  68. self.SetDungeonTime(constInfo.kirmizirenk + localeInfo.DUNGEON_INFO_TEXT10)
  69. elif player.GetStatus(player.LEVEL) > int(constInfo.dungeontimerinfo[int(self.index)][4]):
  70. self.SetDungeonTime(constInfo.kirmizirenk + localeInfo.DUNGEON_INFO_TEXT11)
  71. else:
  72. if int(constInfo.dungeontimerinfo[int(self.index)][13]) > app.GetGlobalTimeStamp():
  73. self.SetDungeonTime(constInfo.sarirenk + localeInfo.sureverdungeon(int(constInfo.dungeontimerinfo[int(self.index)][13])-app.GetGlobalTimeStamp()))
  74. else:
  75. self.SetDungeonTime(constInfo.yesilrenk + "Uygun")
  76. def OnRender(self):
  77. if self.isLoad:
  78. if self.isSelected:
  79. self.dungeonImage.LoadImage("dungeontimer/active.tga")
  80. else:
  81. self.dungeonImage.LoadImage("dungeontimer/normal.tga")
  82. self.isLoad = False
  83. def __init__(self):
  84. ui.ScriptWindow.__init__(self)
  85. self.selectedItemIndex = -1
  86. self.board = None
  87. self.secilen = None
  88. self.searchResultItems = []
  89. self.itemDataList = []
  90. self.currentPage = 1
  91. self.pageCount = 1
  92. self.perPage = 10
  93. self.itemCount = 0
  94. self.LoadWindow()
  95. def __del__(self):
  96. self.Destroy()
  97. ui.ScriptWindow.__del__(self)
  98. def LoadWindow(self):
  99. try:
  100. pyScrLoader = ui.PythonScriptLoader()
  101. pyScrLoader.LoadScriptFile(self, "UIScript/dungeontimer.py")
  102. except:
  103. import exception
  104. exception.Abort("DungeonTimer.LoadDialog.LoadScript")
  105. try:
  106. GetObject=self.GetChild
  107. self.board = GetObject("board")
  108. self.dungeontype = GetObject("dungeontype")
  109. self.dungeontype2 = GetObject("dungeontype2")
  110. self.dungeonlevel = GetObject("dungeonlevel")
  111. self.dungeongroup = GetObject("dungeongroup")
  112. self.dungeoncd = GetObject("dungeoncd")
  113. self.dungeoncd2 = GetObject("dungeoncd2")
  114. self.dungeongiris = GetObject("dungeongiris")
  115. self.dungeonguclu = GetObject("dungeonguclu")
  116. self.dungeondirenc = GetObject("dungeondirenc")
  117. self.mapname = GetObject("mapname")
  118. self.girisslot = GetObject("girisslot")
  119. self.questScrollBar = self.GetChild("info_ScrollBar")
  120. self.tpbutton = self.GetChild("tp_button")
  121. self.girisitemtext = self.GetChild("girisitemtext")
  122. self.questShowingStartIndex = 0
  123. self.tpbutton.SetEvent(ui.__mem_func__(self.OnTpButton))
  124. self.questScrollBar.SetScrollEvent(ui.__mem_func__(self.OnQuestScroll))
  125. self.board.SetCloseEvent(ui.__mem_func__(self.__OnCloseButtonClick))
  126. except:
  127. import exception
  128. exception.Abort("DungeonTimer.LoadDialog.BindObject")
  129. def Destroy(self):
  130. self.ClearDictionary()
  131. self.searchResultItems[:] = []
  132. self.titleBar = None
  133. self.questScrollBar = None
  134. self.questShowingStartIndex = None
  135. def OnQuestScroll(self):
  136. questCount = len(constInfo.dungeontimerinfo)
  137. scrollLineCount = max(0, questCount - 8)
  138. startIndex = int(scrollLineCount * self.questScrollBar.GetPos())
  139. if startIndex != self.questShowingStartIndex:
  140. self.questShowingStartIndex = startIndex
  141. self.RefreshInfo()
  142. def RefreshInfo(self):
  143. questCount = len(constInfo.dungeontimerinfo)
  144. questRange = range(8)
  145. self.searchResultItems[:] = []
  146. if questCount > 8:
  147. self.questScrollBar.Show()
  148. else:
  149. self.questScrollBar.Hide()
  150. basePos = 38
  151. for i in range(0+self.questShowingStartIndex, 8+self.questShowingStartIndex):
  152. resultItem = DungeonTimer.SearchResultItem(self, i)
  153. resultItem.SetPosition(136-112, basePos+((i-self.questShowingStartIndex)*36))
  154. resultItem.SetDungeonName(constInfo.dungeontimerinfo[i][0])
  155. resultItem.SetDungeonTime(localeInfo.sureverdungeon(app.GetGlobalTimeStamp()-int(constInfo.dungeontimerinfo[i][13])))
  156. resultItem.SetBossImage(constInfo.dungeontimerinfo[i][12])
  157. resultItem.Show()
  158. self.searchResultItems.append(resultItem)
  159. self.Children.append(self.searchResultItems)
  160. # self.OnSearchResultItemSelect(0+self.questShowingStartIndex)
  161. def Open(self):
  162. self.selectedItemIndex = -1
  163. self.Show()
  164. self.SetCenterPosition()
  165. basePos = 38
  166. for i in range(0, 8):
  167. #for i in xrange(len(constInfo.dungeontimerinfo)):
  168. resultItem = DungeonTimer.SearchResultItem(self, i)
  169. resultItem.SetPosition(136-112, basePos+(i*36))
  170. resultItem.SetDungeonName(constInfo.dungeontimerinfo[i][0])
  171. resultItem.SetDungeonTime(localeInfo.sureverdungeon(app.GetGlobalTimeStamp()-int(constInfo.dungeontimerinfo[i][13])))
  172. resultItem.SetBossImage(constInfo.dungeontimerinfo[i][12])
  173. resultItem.Show()
  174. self.searchResultItems.append(resultItem)
  175. self.Children.append(self.searchResultItems)
  176. self.OnSearchResultItemSelect(0+self.questShowingStartIndex)
  177. if len(constInfo.dungeontimerinfo) > 8:
  178. self.questScrollBar.Show()
  179. else:
  180. self.questScrollBar.Hide()
  181. self.questScrollBar.SetPos(0)
  182. self.RefreshInfo()
  183. self.OnSearchResultItemSelect(0+self.questShowingStartIndex)
  184. def OnUpdate(self):
  185. pass
  186. def OnTpButton(self):
  187. net.SendChatPacket("/dungeontp "+str(self.secilen))
  188. self.Close()
  189. def OnSearchResultItemSelect(self, index):
  190. if self.questShowingStartIndex > 0:
  191. self.selectedItemIndex = index - self.questShowingStartIndex
  192. else:
  193. self.selectedItemIndex = index
  194. self.secilen = index
  195. self.tpbutton.SetText(localeInfo.DUNGEON_INFO_WARP)
  196. self.girisslot.Show()
  197. self.girisitemtext.Show()
  198. map(DungeonTimer.SearchResultItem.UnSelect, self.searchResultItems)
  199. self.searchResultItems[self.selectedItemIndex].Select()
  200. self.dungeontype.SetText(localeInfo.DUNGEON_INFO_TEXT1+str(constInfo.dungeontimerinfo[index][1]))
  201. self.dungeontype2.SetText(localeInfo.DUNGEON_INFO_TEXT2+str(constInfo.dungeontimerinfo[index][2]))
  202. if int(constInfo.dungeontimerinfo[index][15]) > 0:
  203. self.dungeonlevel.SetText(localeInfo.DUNGEON_INFO_TEXT3+str(constInfo.dungeontimerinfo[index][3]) + " + R" + str(constInfo.dungeontimerinfo[index][15]) + " - " + str(constInfo.dungeontimerinfo[index][4]) + " + R" + str(50))
  204. else:
  205. self.dungeonlevel.SetText(localeInfo.DUNGEON_INFO_TEXT3+str(constInfo.dungeontimerinfo[index][3]))
  206. self.dungeongroup.SetText(localeInfo.DUNGEON_INFO_TEXT4+str(constInfo.dungeontimerinfo[index][5]))
  207. self.dungeoncd.SetText(localeInfo.DUNGEON_INFO_TEXT5+str(constInfo.dungeontimerinfo[index][6]))
  208. self.dungeoncd2.SetText(localeInfo.DUNGEON_INFO_TEXT6+str(constInfo.dungeontimerinfo[index][7]))
  209. self.dungeongiris.SetText(localeInfo.DUNGEON_INFO_TEXT7+str(constInfo.dungeontimerinfo[index][8]))
  210. self.dungeonguclu.SetText(localeInfo.DUNGEON_INFO_TEXT8+str(constInfo.dungeontimerinfo[index][9]))
  211. self.dungeondirenc.SetText(localeInfo.DUNGEON_INFO_TEXT9+str(constInfo.dungeontimerinfo[index][10]))
  212. self.mapname.SetText(str(constInfo.dungeontimerinfo[index][0]))
  213. if int(constInfo.dungeontimerinfo[index][11]) == 0:
  214. self.girisslot.SetItemSlot(0, 0)
  215. else:
  216. self.girisslot.SetItemSlot(0, int(constInfo.dungeontimerinfo[index][11]),int(constInfo.dungeontimerinfo[index][14]))
  217. self.girisslot.RefreshSlot()
  218. def Close(self):
  219. map(DungeonTimer.SearchResultItem.Hide, self.searchResultItems)
  220. self.Hide()
  221. def Clear(self):
  222. self.Refresh()
  223. def Refresh(self):
  224. pass
  225. def __OnCloseButtonClick(self):
  226. self.Hide()
  227. def OnPressEscapeKey(self):
  228. self.Close()