Guest User

Untitled

a guest
Apr 2nd, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.21 KB | None | 0 0
  1. import ui
  2. import localeInfo
  3. import player
  4. import item
  5. import uiToolTip
  6. import wndMgr
  7. import app
  8.  
  9. class CharacterDetailsUI(ui.ScriptWindow):
  10. def __init__(self, parent):
  11. self.uiCharacterStatus = parent
  12. ui.ScriptWindow.__init__(self)
  13. self.toolTip = uiToolTip.ToolTip()
  14. self.__LoadScript()
  15.  
  16. def __del__(self):
  17. self.uiCharacterStatus = None
  18. self.toolTip = None
  19. ui.ScriptWindow.__del__(self)
  20.  
  21. def __LoadScript(self):
  22.  
  23. try:
  24. pyScrLoader = ui.PythonScriptLoader()
  25. pyScrLoader.LoadScriptFile(self, "UIScript/CharacterDetailsWindow.py")
  26. except:
  27. import exception
  28. exception.Abort("CharacterDetailsUI.__LoadScript")
  29.  
  30. self.Width = 253 - 3
  31. self.GetChild("TitleBar").CloseButtonHide()
  32. self.ScrollBar = self.GetChild("ScrollBar")
  33. self.ScrollBar.SetScrollEvent(ui.__mem_func__(self.OnScroll))
  34.  
  35. self.UI_MAX_COUNT = 13
  36. self.UI_MAX_VIEW_COUNT = 6
  37.  
  38. self.INFO_TEXT = 0
  39. self.INFO_TOOLTIP = 1
  40. self.INFO_VALUE = 2
  41. self.CATEGORY_STARTLINE = -1
  42. self.CATEGORY_ENDLINE = -2
  43.  
  44. self.labelList = []
  45. self.labelValueList = []
  46. self.labelTextList = []
  47. self.horizonBarList = []
  48. self.horizonBarNameList = []
  49.  
  50. for i in xrange(self.UI_MAX_COUNT):
  51. self.labelList.append( self.GetChild("label%s"%i) )
  52. self.labelValueList.append( self.GetChild("labelvalue%s"%i) )
  53. self.labelTextList.append( self.GetChild("labelname%s"%i) )
  54. self.horizonBarList.append( self.GetChild("horizontalbar%s"%i) )
  55. self.horizonBarNameList.append( self.GetChild("horizontalbarName%s"%i) )
  56.  
  57. for i in xrange(self.UI_MAX_COUNT):
  58. self.labelTextList[i].SetOverEvent( ui.__mem_func__(self.__ButtonOverIn), i )
  59. self.labelTextList[i].SetOverOutEvent( ui.__mem_func__(self.__ButtonOverOut), i )
  60.  
  61. self.__Initialize()
  62.  
  63. def __Initialize(self):
  64. self.InfoList = []
  65. self.InfoList.append( [ localeInfo.DETAILS_CATE_1, "", self.CATEGORY_STARTLINE ] )
  66. self.InfoList.append( [ localeInfo.DETAILS_1, localeInfo.DETAILS_TOOLTIP_1, item.GetApplyPoint( item.APPLY_ATTBONUS_HUMAN ) ] )
  67. self.InfoList.append( [ localeInfo.DETAILS_3, localeInfo.DETAILS_TOOLTIP_3, item.GetApplyPoint( item.APPLY_ATTBONUS_ORC ) ] )
  68. self.InfoList.append( [ localeInfo.DETAILS_4, localeInfo.DETAILS_TOOLTIP_4, item.GetApplyPoint( item.APPLY_ATTBONUS_UNDEAD ) ] )
  69. self.InfoList.append( [ localeInfo.DETAILS_5, localeInfo.DETAILS_TOOLTIP_5, item.GetApplyPoint( item.APPLY_ATTBONUS_MONSTER ) ] )
  70. self.InfoList.append( [ localeInfo.DETAILS_7, localeInfo.DETAILS_TOOLTIP_7, item.GetApplyPoint( item.APPLY_ATTBONUS_ANIMAL ) ] )
  71. self.InfoList.append( [ localeInfo.DETAILS_8, localeInfo.DETAILS_TOOLTIP_8, item.GetApplyPoint( item.APPLY_ATTBONUS_MILGYO ) ] )
  72. self.InfoList.append( [ localeInfo.DETAILS_9, localeInfo.DETAILS_TOOLTIP_9, item.GetApplyPoint( item.APPLY_ATTBONUS_DEVIL ) ] )
  73. self.InfoList.append( [ localeInfo.DETAILS_12, localeInfo.DETAILS_TOOLTIP_12, item.GetApplyPoint( item.APPLY_ATT_GRADE_BONUS ) ] )
  74. self.InfoList.append( [ localeInfo.DETAILS_13, localeInfo.DETAILS_TOOLTIP_13, item.GetApplyPoint( item.APPLY_DEF_GRADE_BONUS ) ] )
  75. self.InfoList.append( [ localeInfo.DETAILS_14, localeInfo.DETAILS_TOOLTIP_14, item.GetApplyPoint( item.APPLY_NORMAL_HIT_DAMAGE_BONUS ) ] )
  76. self.InfoList.append( [ localeInfo.DETAILS_15, localeInfo.DETAILS_TOOLTIP_15, item.GetApplyPoint( item.APPLY_NORMAL_HIT_DEFEND_BONUS ) ] )
  77. self.InfoList.append( [ localeInfo.DETAILS_16, localeInfo.DETAILS_TOOLTIP_16, item.GetApplyPoint( item.APPLY_SKILL_DAMAGE_BONUS ) ] )
  78. self.InfoList.append( [ localeInfo.DETAILS_17, localeInfo.DETAILS_TOOLTIP_17, item.GetApplyPoint( item.APPLY_SKILL_DEFEND_BONUS ) ] )
  79. self.InfoList.append( [ localeInfo.DETAILS_18, localeInfo.DETAILS_TOOLTIP_18, item.GetApplyPoint( item.APPLY_MELEE_MAGIC_ATTBONUS_PER ) ] )
  80. self.InfoList.append( [ localeInfo.DETAILS_19, localeInfo.DETAILS_TOOLTIP_19, item.GetApplyPoint( item.APPLY_MAGIC_ATTBONUS_PER ) ] )
  81. self.InfoList.append( [ localeInfo.DETAILS_20, localeInfo.DETAILS_TOOLTIP_20, item.GetApplyPoint( item.APPLY_CRITICAL_PCT ) ] )
  82. self.InfoList.append( [ localeInfo.DETAILS_21, localeInfo.DETAILS_TOOLTIP_21, item.GetApplyPoint( item.APPLY_PENETRATE_PCT ) ] )
  83. self.InfoList.append( [ localeInfo.DETAILS_22, localeInfo.DETAILS_TOOLTIP_22, item.GetApplyPoint( item.APPLY_ANTI_CRITICAL_PCT ) ] )
  84. self.InfoList.append( [ localeInfo.DETAILS_23, localeInfo.DETAILS_TOOLTIP_23, item.GetApplyPoint( item.APPLY_ANTI_PENETRATE_PCT ) ] )
  85. self.InfoList.append( [ "", "", self.CATEGORY_ENDLINE ] )
  86.  
  87. self.InfoList.append( [ localeInfo.DETAILS_CATE_2, "", self.CATEGORY_STARTLINE ] )
  88. self.InfoList.append( [ localeInfo.DETAILS_76, localeInfo.DETAILS_TOOLTIP_76, item.GetApplyPoint( item.APPLY_RESIST_MAGIC ) ] )
  89. self.InfoList.append( [ localeInfo.DETAILS_24, localeInfo.DETAILS_TOOLTIP_24, item.GetApplyPoint( item.APPLY_RESIST_ELEC ) ] )
  90. self.InfoList.append( [ localeInfo.DETAILS_25, localeInfo.DETAILS_TOOLTIP_25, item.GetApplyPoint( item.APPLY_RESIST_ICE ) ] )
  91. self.InfoList.append( [ localeInfo.DETAILS_26, localeInfo.DETAILS_TOOLTIP_26, item.GetApplyPoint( item.APPLY_RESIST_DARK ) ] )
  92. self.InfoList.append( [ localeInfo.DETAILS_27, localeInfo.DETAILS_TOOLTIP_27, item.GetApplyPoint( item.APPLY_RESIST_FIRE ) ] )
  93. self.InfoList.append( [ localeInfo.DETAILS_28, localeInfo.DETAILS_TOOLTIP_28, item.GetApplyPoint( item.APPLY_RESIST_WIND ) ] )
  94. self.InfoList.append( [ localeInfo.DETAILS_29, localeInfo.DETAILS_TOOLTIP_29, item.GetApplyPoint( item.APPLY_RESIST_EARTH ) ] )
  95. #self.InfoList.append( [ localeInfo.DETAILS_77, localeInfo.DETAILS_TOOLTIP_77, item.GetApplyPoint( item.APPLY_RESIST_MAGIC_REDUCTION ) ] )
  96. self.InfoList.append( [ "", "", self.CATEGORY_ENDLINE ] )
  97.  
  98. self.InfoList.append( [ localeInfo.DETAILS_CATE_3, "", self.CATEGORY_STARTLINE ] )
  99. self.InfoList.append( [ localeInfo.DETAILS_36, localeInfo.DETAILS_TOOLTIP_36, item.GetApplyPoint( item.APPLY_ATTBONUS_WARRIOR ) ] )
  100. self.InfoList.append( [ localeInfo.DETAILS_37, localeInfo.DETAILS_TOOLTIP_37, item.GetApplyPoint( item.APPLY_ATTBONUS_ASSASSIN ) ] )
  101. self.InfoList.append( [ localeInfo.DETAILS_38, localeInfo.DETAILS_TOOLTIP_38, item.GetApplyPoint( item.APPLY_ATTBONUS_SURA ) ] )
  102. self.InfoList.append( [ localeInfo.DETAILS_39, localeInfo.DETAILS_TOOLTIP_39, item.GetApplyPoint( item.APPLY_ATTBONUS_SHAMAN ) ] )
  103. #self.InfoList.append( [ localeInfo.DETAILS_40, localeInfo.DETAILS_TOOLTIP_40, item.GetApplyPoint( item.APPLY_ATTBONUS_WOLFMAN ) ] )
  104. self.InfoList.append( [ localeInfo.DETAILS_41, localeInfo.DETAILS_TOOLTIP_41, item.GetApplyPoint( item.APPLY_RESIST_WARRIOR ) ] )
  105. self.InfoList.append( [ localeInfo.DETAILS_42, localeInfo.DETAILS_TOOLTIP_42, item.GetApplyPoint( item.APPLY_RESIST_ASSASSIN ) ] )
  106. self.InfoList.append( [ localeInfo.DETAILS_43, localeInfo.DETAILS_TOOLTIP_43, item.GetApplyPoint( item.APPLY_RESIST_SURA ) ] )
  107. self.InfoList.append( [ localeInfo.DETAILS_44, localeInfo.DETAILS_TOOLTIP_44, item.GetApplyPoint( item.APPLY_RESIST_SHAMAN ) ] )
  108. #self.InfoList.append( [ localeInfo.DETAILS_45, localeInfo.DETAILS_TOOLTIP_45, item.GetApplyPoint( item.APPLY_RESIST_WOLFMAN ) ] )
  109. self.InfoList.append( [ "", "", self.CATEGORY_ENDLINE ] )
  110.  
  111. self.InfoList.append( [ localeInfo.DETAILS_CATE_4, "", self.CATEGORY_STARTLINE ] )
  112. self.InfoList.append( [ localeInfo.DETAILS_46, localeInfo.DETAILS_TOOLTIP_46, item.GetApplyPoint( item.APPLY_RESIST_SWORD ) ] )
  113. self.InfoList.append( [ localeInfo.DETAILS_47, localeInfo.DETAILS_TOOLTIP_47, item.GetApplyPoint( item.APPLY_RESIST_TWOHAND ) ] )
  114. self.InfoList.append( [ localeInfo.DETAILS_48, localeInfo.DETAILS_TOOLTIP_48, item.GetApplyPoint( item.APPLY_RESIST_DAGGER ) ] )
  115. #self.InfoList.append( [ localeInfo.DETAILS_49, localeInfo.DETAILS_TOOLTIP_49, item.GetApplyPoint( item.APPLY_RESIST_CLAW ) ] )
  116. self.InfoList.append( [ localeInfo.DETAILS_50, localeInfo.DETAILS_TOOLTIP_50, item.GetApplyPoint( item.APPLY_RESIST_BELL ) ] )
  117. self.InfoList.append( [ localeInfo.DETAILS_51, localeInfo.DETAILS_TOOLTIP_51, item.GetApplyPoint( item.APPLY_RESIST_FAN ) ] )
  118. self.InfoList.append( [ localeInfo.DETAILS_52, localeInfo.DETAILS_TOOLTIP_52, item.GetApplyPoint( item.APPLY_RESIST_BOW ) ] )
  119. self.InfoList.append( [ "", "", self.CATEGORY_ENDLINE ] )
  120.  
  121. self.InfoList.append( [ localeInfo.DETAILS_CATE_5, "", self.CATEGORY_STARTLINE ] )
  122. self.InfoList.append( [ localeInfo.DETAILS_53, localeInfo.DETAILS_TOOLTIP_53, item.GetApplyPoint( item.APPLY_STUN_PCT ) ] )
  123. self.InfoList.append( [ localeInfo.DETAILS_54, localeInfo.DETAILS_TOOLTIP_54, item.GetApplyPoint( item.APPLY_SLOW_PCT ) ] )
  124. self.InfoList.append( [ localeInfo.DETAILS_55, localeInfo.DETAILS_TOOLTIP_55, item.GetApplyPoint( item.APPLY_POISON_PCT ) ] )
  125. self.InfoList.append( [ localeInfo.DETAILS_56, localeInfo.DETAILS_TOOLTIP_56, item.GetApplyPoint( item.APPLY_POISON_REDUCE) ] )
  126. #self.InfoList.append( [ localeInfo.DETAILS_57, localeInfo.DETAILS_TOOLTIP_57, item.GetApplyPoint( item.APPLY_BLEEDING_PCT ) ] )
  127. #self.InfoList.append( [ localeInfo.DETAILS_58, localeInfo.DETAILS_TOOLTIP_58, item.GetApplyPoint( item.APPLY_BLEEDING_REDUCE ) ] )
  128. self.InfoList.append( [ localeInfo.DETAILS_59, localeInfo.DETAILS_TOOLTIP_59, item.GetApplyPoint( item.APPLY_STEAL_HP ) ] )
  129. self.InfoList.append( [ localeInfo.DETAILS_60, localeInfo.DETAILS_TOOLTIP_60, item.GetApplyPoint( item.APPLY_STEAL_SP ) ] )
  130. self.InfoList.append( [ localeInfo.DETAILS_61, localeInfo.DETAILS_TOOLTIP_61, item.GetApplyPoint( item.APPLY_HP_REGEN ) ] )
  131. self.InfoList.append( [ localeInfo.DETAILS_62, localeInfo.DETAILS_TOOLTIP_62, item.GetApplyPoint( item.APPLY_SP_REGEN ) ] )
  132. self.InfoList.append( [ localeInfo.DETAILS_63, localeInfo.DETAILS_TOOLTIP_63, item.GetApplyPoint( item.APPLY_BLOCK ) ] )
  133. self.InfoList.append( [ localeInfo.DETAILS_64, localeInfo.DETAILS_TOOLTIP_64, item.GetApplyPoint( item.APPLY_DODGE ) ] )
  134. self.InfoList.append( [ localeInfo.DETAILS_65, localeInfo.DETAILS_TOOLTIP_65, item.GetApplyPoint( item.APPLY_REFLECT_MELEE ) ] )
  135. self.InfoList.append( [ localeInfo.DETAILS_66, localeInfo.DETAILS_TOOLTIP_66, item.GetApplyPoint( item.APPLY_KILL_HP_RECOVER ) ] )
  136. self.InfoList.append( [ localeInfo.DETAILS_67, localeInfo.DETAILS_TOOLTIP_67, item.GetApplyPoint( item.APPLY_KILL_SP_RECOVER ) ] )
  137. self.InfoList.append( [ localeInfo.DETAILS_68, localeInfo.DETAILS_TOOLTIP_68, item.GetApplyPoint( item.APPLY_EXP_DOUBLE_BONUS ) ] )
  138. self.InfoList.append( [ localeInfo.DETAILS_69, localeInfo.DETAILS_TOOLTIP_69, item.GetApplyPoint( item.APPLY_GOLD_DOUBLE_BONUS ) ] )
  139. self.InfoList.append( [ localeInfo.DETAILS_70, localeInfo.DETAILS_TOOLTIP_70, item.GetApplyPoint( item.APPLY_ITEM_DROP_BONUS ) ] )
  140. self.InfoList.append( [ "", "", self.CATEGORY_ENDLINE ] )
  141.  
  142. self.InfoList.append( [ localeInfo.DETAILS_CATE_6, "", self.CATEGORY_STARTLINE ] )
  143. self.InfoList.append( [ localeInfo.DETAILS_71, localeInfo.DETAILS_TOOLTIP_71, item.GetApplyPoint( item.APPLY_MALL_ATTBONUS ) ] )
  144. self.InfoList.append( [ localeInfo.DETAILS_72, localeInfo.DETAILS_TOOLTIP_72, item.GetApplyPoint( item.APPLY_MALL_DEFBONUS ) ] )
  145. self.InfoList.append( [ localeInfo.DETAILS_73, localeInfo.DETAILS_TOOLTIP_73, item.GetApplyPoint( item.APPLY_MALL_EXPBONUS ) ] )
  146. self.InfoList.append( [ localeInfo.DETAILS_74, localeInfo.DETAILS_TOOLTIP_74, item.GetApplyPoint( item.APPLY_MALL_ITEMBONUS ) ] )
  147. self.InfoList.append( [ localeInfo.DETAILS_75, localeInfo.DETAILS_TOOLTIP_75, item.GetApplyPoint( item.APPLY_MALL_GOLDBONUS ) ] )
  148. #self.InfoList.append( [ "", "", self.CATEGORY_ENDLINE ] )
  149.  
  150. self.Diff = len(self.InfoList) - (self.UI_MAX_VIEW_COUNT )
  151. stepSize = 1.0 / self.Diff
  152. self.ScrollBar.SetScrollStep( stepSize )
  153. self.ScollPos = 0
  154. self.RefreshLabel()
  155.  
  156. def Show(self):
  157. ui.ScriptWindow.Show(self)
  158. self.SetTop()
  159.  
  160. def Close(self):
  161. self.Hide()
  162.  
  163. def AdjustPosition(self, x, y):
  164. self.SetPosition(x + self.Width, y)
  165.  
  166. def OnScroll(self):
  167. self.RefreshLabel()
  168.  
  169. def RefreshLabel(self):
  170. self.ScollPos = int(self.ScrollBar.GetPos() * self.Diff)
  171. self.LabelLineCount = 0
  172. self.startline_endlinecount = 0
  173. for i in xrange(self.UI_MAX_COUNT) :
  174. idx = i + self.ScollPos
  175.  
  176. if idx < len(self.InfoList) :
  177. text = self.InfoList[idx][self.INFO_TEXT]
  178. type = self.InfoList[idx][self.INFO_VALUE]
  179.  
  180. if type == self.CATEGORY_STARTLINE:
  181. self.__LabelTitleLine(i+self.LabelLineCount, text)
  182. self.startline_endlinecount += 1
  183. elif type == self.CATEGORY_ENDLINE:
  184. self.__EmptyLine(i+self.LabelLineCount)
  185. self.startline_endlinecount += 1
  186. else:
  187. value = player.GetStatus(type)
  188. self.__LabelLine(i+self.LabelLineCount, text, value)
  189. if i+self.LabelLineCount < self.UI_MAX_COUNT:
  190. self.labelTextList[i+self.LabelLineCount].SetOverEvent( ui.__mem_func__(self.__ButtonOverIn), self.LabelLineCount + self.startline_endlinecount )
  191. self.labelTextList[i+self.LabelLineCount].SetOverOutEvent( ui.__mem_func__(self.__ButtonOverOut), self.LabelLineCount + self.startline_endlinecount )
  192. self.LabelLineCount += 1
  193. else:
  194. self.__EmptyLine(i+self.LabelLineCount)
  195.  
  196. def __LabelTitleLine(self, idx, text):
  197. if(idx < self.UI_MAX_COUNT):
  198. self.labelList[idx].Hide()
  199. self.labelTextList[idx].Hide()
  200. self.horizonBarList[idx].Show()
  201. self.horizonBarNameList[idx].SetText( text )
  202.  
  203. def __EmptyLine(self, idx):
  204. if(idx < self.UI_MAX_COUNT):
  205. self.labelList[idx].Hide()
  206. self.labelTextList[idx].Hide()
  207. self.horizonBarList[idx].Hide()
  208.  
  209. def __LabelLine(self, idx, text, value):
  210. if(idx < self.UI_MAX_COUNT):
  211. self.labelTextList[idx].Show()
  212. self.horizonBarList[idx].Hide()
  213. self.labelList[idx].Hide()
  214.  
  215. self.labelTextList[idx].SetText( text )
  216.  
  217. if(idx+1 < self.UI_MAX_COUNT):
  218. self.labelList[idx+1].Show()
  219. self.horizonBarList[idx+1].Hide()
  220. self.labelTextList[idx+1].Hide()
  221. self.labelValueList[idx+1].SetText( str(value) )
  222.  
  223. def __ButtonOverIn(self, i):
  224. idx = i + self.ScollPos
  225. tooltip = self.InfoList[idx][self.INFO_TOOLTIP]
  226.  
  227. arglen = len(str(tooltip))
  228. pos_x, pos_y = wndMgr.GetMousePosition()
  229.  
  230. self.toolTip.ClearToolTip()
  231. self.toolTip.SetThinBoardSize(11 * arglen)
  232. self.toolTip.SetToolTipPosition(pos_x + 50, pos_y + 50)
  233. self.toolTip.AppendTextLine(tooltip, 0xffffff00)
  234. self.toolTip.Show()
  235.  
  236. def __ButtonOverOut(self, idx):
  237. self.toolTip.Hide()
  238.  
  239. def OnTop(self):
  240. if self.uiCharacterStatus:
  241. self.uiCharacterStatus.SetTop()
Add Comment
Please, Sign In to add comment