1. import ui, player, item, net, app, localeInfo
  2. from uitooltip import ItemToolTip
  3. import interfaceModule
  4. import constInfo
  5. IMG_DIR = "d:/ymir work/ui/game/characterdetails/"
  6. # only need setting here bro do u have question?
  7. bonus_list = [
  8. ["PvM",
  9. [
  10. [item.APPLY_ATTBONUS_MONSTER,53],
  11. # [item.APPLY_RESIST_MONSTER, 163],
  12. # [item.APPLY_ATTBONUS_BOSS,162],
  13. # [item.APPLY_RESIST_BOSS, 164],
  14. # [item.APPLY_ATTBONUS_STONE, 167],
  15. # [item.APPLY_ATTBONUS_DUNGEON, 168],
  16. [item.APPLY_ATTBONUS_UNDEAD,47],
  17. [item.APPLY_ATTBONUS_DEVIL,48],
  18. [item.APPLY_ATTBONUS_ORC,45],
  19. [item.APPLY_ATTBONUS_ANIMAL,44],
  20. # [item.APPLY_ATTBONUS_MILGYO,46],
  21. # [item.APPLY_ATTBONUS_CZ, 154],
  22. # [item.APPLY_CRITICAL_DAMAGE_PVM, 165],
  23. ]
  24. ],
  25. ["PvP",
  26. [
  27. [item.APPLY_ATTBONUS_HUMAN, 43],
  28. [item.APPLY_ATTBONUS_WARRIOR, 54],
  29. [item.APPLY_ATTBONUS_ASSASSIN, 55],
  30. [item.APPLY_ATTBONUS_SURA, 56],
  31. [item.APPLY_ATTBONUS_SHAMAN, 57],
  32. [item.APPLY_RESIST_WARRIOR, 59],
  33. [item.APPLY_RESIST_ASSASSIN, 60],
  34. [item.APPLY_RESIST_SURA, 61],
  35. [item.APPLY_RESIST_SHAMAN, 62],
  36. # [item.APPLY_RESIST_HUMAN,147],
  37. [item.APPLY_RESIST_SWORD, 69],
  38. [item.APPLY_RESIST_TWOHAND, 70],
  39. [item.APPLY_RESIST_DAGGER, 71],
  40. [item.APPLY_RESIST_BELL, 72],
  41. [item.APPLY_RESIST_FAN, 73],
  42. [item.APPLY_RESIST_BOW, 74],
  43. [item.APPLY_RESIST_MAGIC, 77],
  44. # [item.APPLY_RESIST_RACES, 166],
  45. ]
  46. ],
  47. [localeInfo.DETAILS_12,
  48. [
  49. [item.APPLY_SKILL_DAMAGE_BONUS,121],
  50. [item.APPLY_NORMAL_HIT_DAMAGE_BONUS,122],
  51. [item.APPLY_CRITICAL_PCT,40],
  52. [item.APPLY_PENETRATE_PCT,41],
  53. [item.APPLY_POISON_PCT,37],
  54. [item.APPLY_SLOW_PCT,39],
  55. [item.APPLY_STUN_PCT,38],
  56. [item.APPLY_MELEE_MAGIC_ATTBONUS_PER,132],
  57. ]
  58. ],
  59. [localeInfo.DETAILS_13,
  60. [
  61. [item.APPLY_SKILL_DEFEND_BONUS,123],
  62. [item.APPLY_NORMAL_HIT_DEFEND_BONUS,124],
  63. [item.APPLY_ANTI_CRITICAL_PCT,136],
  64. [item.APPLY_ANTI_PENETRATE_PCT,137],
  65. [item.APPLY_BLOCK,67],
  66. [item.APPLY_REFLECT_MELEE,79],
  67. [item.APPLY_DODGE,68],
  68. [item.APPLY_POISON_REDUCE,81],
  69. ]
  70. ],
  71. [localeInfo.DETAILS_CATE_2,
  72. [
  73. # [item.APPLY_ENCHANT_ELECT,148],
  74. # [item.APPLY_ENCHANT_FIRE,149],
  75. # [item.APPLY_ENCHANT_ICE,150],
  76. # [item.APPLY_ENCHANT_WIND,151],
  77. # [item.APPLY_ENCHANT_EARTH,152],
  78. # [item.APPLY_ENCHANT_DARK,153],
  79. # [item.APPLY_RESIST_ELEC,76],
  80. # [item.APPLY_RESIST_FIRE,75],
  81. # [item.APPLY_RESIST_ICE,133],
  82. # [item.APPLY_RESIST_WIND,78],
  83. # [item.APPLY_RESIST_EARTH,134],
  84. # [item.APPLY_RESIST_DARK,135],
  85. ]
  86. ],
  87. ["Status",
  88. [
  89. [item.APPLY_STEAL_HP,63],
  90. [item.APPLY_STEAL_SP,64],
  91. [item.APPLY_HP_REGEN,32],
  92. [item.APPLY_SP_REGEN,33],
  93. [item.APPLY_MALL_EXPBONUS, 116],
  94. [item.APPLY_EXP_DOUBLE_BONUS,83],
  95. [item.APPLY_GOLD_DOUBLE_BONUS,84],
  96. [item.APPLY_ITEM_DROP_BONUS,85],
  97. ]
  98. ],
  99. [localeInfo.CATEGORY_POTION_ETC,
  100. [
  101. # [item.APPLY_ATTBONUS_SWORD,155],
  102. # [item.APPLY_ATTBONUS_TWOHAND,156],
  103. # [item.APPLY_ATTBONUS_DAGGER,157],
  104. # [item.APPLY_ATTBONUS_BELL,158],
  105. # [item.APPLY_ATTBONUS_FAN,159],
  106. # [item.APPLY_ATTBONUS_BOW,160],
  107. ]
  108. ],
  109. ]
  110. bonus_list_2 = [
  111. ["PVM",
  112. [
  113. [localeInfo.STATISTICS_1,213],
  114. [localeInfo.STATISTICS_2,215],
  115. [localeInfo.STATISTICS_3,214],
  116. [localeInfo.STATISTICS_4,208],
  117. [localeInfo.STATISTICS_5,221],
  118. ]
  119. ],
  120. [localeInfo.TARGET_BUTTON_FIGHT,
  121. [
  122. [localeInfo.STATISTICS_6,216],
  123. [localeInfo.STATISTICS_7, 217],
  124. [localeInfo.STATISTICS_8,218],
  125. [localeInfo.STATISTICS_9, 219],
  126. [localeInfo.STATISTICS_10, 220],
  127. [localeInfo.STATISTICS_24,222],
  128. [localeInfo.STATISTICS_25,223],
  129. ]
  130. ],
  131. # [localeInfo.CHAT_GUILD,
  132. # [
  133. # [localeInfo.STATISTICS_11,224],
  134. # [localeInfo.STATISTICS_12,225],
  135. # [localeInfo.STATISTICS_13,226],
  136. # ]
  137. # ],
  138. [localeInfo.CATEGORY_COSTUMES_ETC,
  139. [
  140. [localeInfo.STATISTICS_14,205],
  141. [localeInfo.STATISTICS_15, 206],
  142. [localeInfo.STATISTICS_16, 207],
  143. [localeInfo.STATISTICS_17, 209],
  144. [localeInfo.STATISTICS_18, 210],
  145. [localeInfo.STATISTICS_19, 211],
  146. [localeInfo.STATISTICS_20, 212],
  147. [localeInfo.STATISTICS_21, 227],
  148. [localeInfo.STATISTICS_22, 228],
  149. [localeInfo.STATISTICS_23, 229],
  150. ]
  151. ],
  152. ]
  153. #stat_list = [
  154. # [localeInfo.BONUS_TABLE_1, player.KILL_JINNO],
  155. # [localeInfo.BONUS_TABLE_2, player.KILL_SHINSO],
  156. # [localeInfo.BONUS_TABLE_4, player.KILL_ALLPLAYER],
  157. # [localeInfo.BONUS_TABLE_5, player.KILL_DUELWON],
  158. # [localeInfo.BONUS_TABLE_6, player.KILL_DUELLOST],
  159. # [localeInfo.BONUS_TABLE_7, player.KILL_MONSTER],
  160. # [localeInfo.BONUS_TABLE_8, player.KILL_BOSSES ],
  161. # [localeInfo.BONUS_TABLE_9, player.KILL_METINSTONE]
  162. #]
  163. class CharacterDetailsUI(ui.ScriptWindow):
  164. def __del__(self):
  165. ui.ScriptWindow.__del__(self)
  166. def Destroy(self):
  167. self.ClearDictionary()
  168. self.btnIndex = 0
  169. self.isPacketLoaded = False
  170. def Show(self):
  171. ui.ScriptWindow.Show(self)
  172. self.SetTop()
  173. self.Refresh()
  174. def Close(self):
  175. self.Hide()
  176. def OnPressEscapeKey(self):
  177. self.Close()
  178. return True
  179. def AdjustPosition(self, x, y):
  180. self.SetPosition(x + self.GetWidth() -52, y)
  181. def __ClickRadioButton(self, buttonList, buttonIndex):
  182. try:
  183. radioBtn = buttonList[buttonIndex]
  184. except IndexError:
  185. return
  186. for eachButton in buttonList:
  187. eachButton.SetUp()
  188. radioBtn.Down()
  189. def __init__(self, parent):
  190. self.uiCharacterStatus = parent
  191. ui.ScriptWindow.__init__(self)
  192. self.Destroy()
  193. self.__LoadScript()
  194. def SetStatistics(self, button):
  195. interface = constInfo.GetInterfaceInstance()
  196. interface.wndCharacter.ExpandBtn2.CallEvent()
  197. def __LoadScript(self):
  198. try:
  199. pyScrLoader = ui.PythonScriptLoader()
  200. pyScrLoader.LoadScriptFile(self, "UIScript/CharacterDetailsWindow.py")
  201. self.GetChild("stat_button").SAFE_SetEvent(self.SetStatistics,0)
  202. except:
  203. import exception
  204. exception.Abort("CharacterDetailsUI.__LoadScript")
  205. #self.ScrollBar = self.GetChild("ScrollBar")
  206. #self.ScrollBar.SetScrollEvent(ui.__mem_func__(self.OnScroll))
  207. elementList = self.ElementDictionary
  208. statWindow = self.GetChild("stat_window")
  209. # for i in xrange(len(stat_list)):
  210. # statName = ui.TextLine()
  211. # statName.SetParent(statWindow)
  212. # statName.AddFlag("not_pick")
  213. # statName.SetPosition(70,15+(i*40))
  214. # statName.SetFontName("Tahoma:13")
  215. # statName.SetHorizontalAlignCenter()
  216. # statName.SetText(stat_list[i][0])
  217. # statName.Show()
  218. # elementList["%d_stat_name"%i] = statName
  219. # statValue = ui.TextLine()
  220. # statValue.AddFlag("not_pick")
  221. # statValue.SetParent(statWindow)
  222. # statValue.SetPosition(180,15+(i*40))
  223. # statValue.SetFontName("Tahoma:13")
  224. # statValue.SetHorizontalAlignCenter()
  225. # statValue.Show()
  226. # elementList["%d_stat"%i] = statValue
  227. bonusWindow = self.GetChild("bonus_window")
  228. searchBoard = SearchSlotBoard()
  229. searchBoard.SetParent(bonusWindow)
  230. searchBoard.SetPosition((bonusWindow.GetWidth()/2)-(129/2),11)
  231. searchBoard.SetSize(129,23)
  232. searchBoard.Show()
  233. elementList["searchBoard"] = searchBoard
  234. itemSearch = ui.EditLine()
  235. itemSearch.SetParent(searchBoard)
  236. itemSearch.SetMax(40)
  237. itemSearch.SetPosition(5,5)
  238. itemSearch.SetSize(searchBoard.GetWidth(), searchBoard.GetHeight())
  239. itemSearch.OnIMEUpdate = ui.__mem_func__(self.__OnValueUpdate)
  240. itemSearch.Show()
  241. elementList["itemSearch"] = itemSearch
  242. searchBtn = ui.Button()
  243. searchBtn.SetParent(searchBoard)
  244. searchBtn.SetUpVisual(IMG_DIR+"search_btn_0.tga")
  245. searchBtn.SetOverVisual(IMG_DIR+"search_btn_1.tga")
  246. searchBtn.SetDownVisual(IMG_DIR+"search_btn_2.tga")
  247. searchBtn.SetEvent(self.__OnValueUpdate)
  248. searchBtn.SetPosition(itemSearch.GetWidth()-searchBtn.GetWidth(),2)
  249. searchBtn.Show()
  250. elementList["searchBtn"] = searchBtn
  251. #bonusWindow.OnMouseWheel = ui.__mem_func__(self.OnMouseWheel)
  252. scrollBar = ScrollBarNew()
  253. scrollBar.SetParent(bonusWindow)
  254. scrollBar.SetPosition((bonusWindow.GetWidth()-scrollBar.GetWidth())-3,43)
  255. scrollBar.SetScrollBarSize((bonusWindow.GetHeight()-46)-5)
  256. scrollBar.SetScrollEvent(ui.__mem_func__(self.Refresh))
  257. scrollBar.Show()
  258. elementList["scrollBar"] = scrollBar
  259. for i in xrange(len(bonus_list)):
  260. bonus_data = bonus_list[i][1]
  261. category = ui.ExpandedImageBox()
  262. category.SetParent(bonusWindow)
  263. category.LoadImage(IMG_DIR+"category_item.tga")
  264. category.buttonStatus = 0
  265. category.SetEvent(ui.__mem_func__(self.SetBonusCategory),"mouse_click", i)
  266. category.Show()
  267. elementList["%d_category"%i] = category
  268. categoryText = ui.TextLine()
  269. categoryText.SetParent(category)
  270. categoryText.SetHorizontalAlignLeft()
  271. categoryText.SetPosition(8,3)
  272. categoryText.SetText("|Eemoji/plus|e "+bonus_list[i][0])
  273. categoryText.Show()
  274. elementList["%d_categoryText"%i] = categoryText
  275. for j in xrange(len(bonus_data)):
  276. bonusImage = ui.ExpandedImageBox()
  277. #bonusImage.AddFlag("not_pick")
  278. bonusImage.SetParent(bonusWindow)
  279. bonusImage.LoadImage(IMG_DIR+"bonus_item.tga")
  280. bonusImage.Show()
  281. elementList["%d_%d_image"%(i,j)] = bonusImage
  282. bonusText = ItemToolTip.AFFECT_DICT[bonus_data[j][0]](0)
  283. disabledStr = ["%","+"]
  284. newText = ""
  285. for x in bonusText:
  286. if x in disabledStr:
  287. continue
  288. if x.isdigit():
  289. continue
  290. newText+=x
  291. bonusText=newText
  292. bonusImage.SAFE_SetStringEvent("MOUSE_OVER_IN",self.OverInBonus, bonusText)
  293. bonusImage.SAFE_SetStringEvent("MOUSE_OVER_OUT",self.OverOutBonus)
  294. #bonusText = bonusText.replace(":","")
  295. #index = bonusText.find("+")
  296. #if index == -1:
  297. # index = bonusText.find("%")
  298. # if index == -1:
  299. # index =0
  300. #if not index <= 0:
  301. # bonusText = bonusText[:index]
  302. bonusName = ui.TextLine()
  303. bonusName.AddFlag("not_pick")
  304. bonusName.SetParent(bonusImage)
  305. bonusName.SetHorizontalAlignCenter()
  306. bonusName.SetPosition(72+52-23,3)
  307. bonusName.SetFontName(localeInfo.UI_DEF_FONT)
  308. bonusName.SetText(bonusText)
  309. bonusName.Show()
  310. elementList["%d_%d_name"%(i,j)] = bonusName
  311. bonusValue = ui.TextLine()
  312. bonusValue.AddFlag("not_pick")
  313. bonusValue.SetParent(bonusImage)
  314. bonusValue.SetHorizontalAlignCenter()
  315. bonusValue.SetPosition(170+52,3)
  316. bonusValue.SetFontName(localeInfo.UI_DEF_FONT)
  317. bonusValue.SetText("|cFFD3936F0|r")
  318. bonusValue.Show()
  319. elementList["%d_%d_value"%(i,j)] = bonusValue
  320. self.SetCategory(0)
  321. def OverOutBonus(self):
  322. interface = constInfo.GetInterfaceInstance()
  323. if interface:
  324. if interface.tooltipItem:
  325. interface.tooltipItem.HideToolTip()
  326. def OverInBonus(self, bonusName):
  327. interface = constInfo.GetInterfaceInstance()
  328. if interface:
  329. if interface.tooltipItem:
  330. interface.tooltipItem.ClearToolTip()
  331. interface.tooltipItem.AppendTextLine(bonusName)
  332. interface.tooltipItem.ShowToolTip()
  333. def OnMouseWheel(self, nLen):
  334. if self.btnIndex == 0:
  335. if self.ElementDictionary.has_key("scrollBar"):
  336. scrollBar = self.ElementDictionary["scrollBar"]
  337. if scrollBar.IsShow():
  338. if nLen > 0:
  339. scrollBar.OnUp()
  340. else:
  341. scrollBar.OnDown()
  342. return True
  343. return False
  344. def __OnValueUpdate(self):
  345. elementList = self.ElementDictionary
  346. itemSearch = elementList["itemSearch"]
  347. ui.EditLine.OnIMEUpdate(itemSearch)
  348. bonusWindow = self.GetChild("bonus_window")
  349. searchText = itemSearch.GetText()
  350. board = elementList["searchBoard"]
  351. totalWidth = 129
  352. if len(searchText) > 0:
  353. self.ElementDictionary["scrollBar"].SetPos(0, True)
  354. totalWidth-=25
  355. windowHeight = bonusWindow.GetWidth()-15
  356. textSize = itemSearch.GetTextSize()[0]
  357. if textSize >= totalWidth:
  358. if textSize >= windowHeight:
  359. totalWidth = windowHeight
  360. else:
  361. totalWidth = textSize
  362. totalWidth+=25
  363. if totalWidth >= windowHeight:
  364. totalWidth = windowHeight
  365. board.SetSize(totalWidth,23)
  366. itemSearch.SetSize(totalWidth,23)
  367. board.SetPosition((bonusWindow.GetWidth()/2)-(board.GetWidth()/2),11)
  368. searchBtn = elementList["searchBtn"]
  369. searchBtn.SetPosition(itemSearch.GetWidth()-searchBtn.GetWidth(),2)
  370. self.Refresh()
  371. def SetBonusCategory(self, emptyArg, categoryIndex):
  372. category = self.ElementDictionary["%d_category"%categoryIndex]
  373. category.buttonStatus = not category.buttonStatus
  374. if category.buttonStatus == 0:
  375. self.ElementDictionary["%d_categoryText"%categoryIndex].SetText("|Eemoji/plus|e "+bonus_list[categoryIndex][0])
  376. else:
  377. self.ElementDictionary["%d_categoryText"%categoryIndex].SetText("|Eemoji/negative|e "+bonus_list[categoryIndex][0])
  378. self.Refresh()
  379. def Refresh(self):
  380. elementList = self.ElementDictionary
  381. (X_POS,Y_POS) = (3,43)
  382. CATEGORY_Y_RANGE = 25
  383. CATEGORY_Y_FIRST_BONUS_RANGE = 29
  384. BONUS_X = 13
  385. if self.btnIndex == 0:
  386. bonusWindow = self.GetChild("bonus_window")
  387. scrollBar = self.GetChild("scrollBar")
  388. (basePos,windowHeight) = (0,bonusWindow.GetHeight()-46)
  389. searchText = elementList["itemSearch"].GetText().lower()
  390. maxHeight = 0
  391. if len(searchText) > 0:
  392. for i in xrange(len(bonus_list)):
  393. bonus_data = bonus_list[i][1]
  394. for j in xrange(len(bonus_data)):
  395. text = elementList["%d_%d_name"%(i,j)].GetText().lower()
  396. if text.find(searchText) != -1:
  397. #if len(text) >= len(searchText):
  398. # if text[:len(searchText)] == searchText:
  399. maxHeight += CATEGORY_Y_FIRST_BONUS_RANGE
  400. else:
  401. for i in xrange(len(bonus_list)):
  402. bonus_data = bonus_list[i][1]
  403. if elementList.has_key("%d_category"%i):
  404. categoryBtn = elementList["%d_category"%i]
  405. if categoryBtn.buttonStatus == 0:
  406. maxHeight += CATEGORY_Y_RANGE
  407. else:
  408. maxHeight += CATEGORY_Y_FIRST_BONUS_RANGE
  409. for j in xrange(len(bonus_data)):
  410. maxHeight += CATEGORY_Y_FIRST_BONUS_RANGE
  411. if maxHeight > windowHeight:
  412. scrollLen = maxHeight-windowHeight
  413. basePos = int(scrollBar.GetPos()*scrollLen)
  414. stepSize = 1.0 / (scrollLen/100.0)
  415. scrollBar.SetScrollStep(stepSize)
  416. scrollBar.SetMiddleBarSize(float(windowHeight-5)/float(maxHeight))
  417. scrollBar.Show()
  418. else:
  419. scrollBar.Hide()
  420. textLines = []
  421. images = []
  422. _wy = bonusWindow.GetGlobalPosition()[1]+43
  423. if len(searchText) > 0:
  424. for i in xrange(len(bonus_list)):
  425. bonus_data = bonus_list[i][1]
  426. if elementList.has_key("%d_category"%i):
  427. elementList["%d_category"%i].Hide()
  428. for j in xrange(len(bonus_data)):
  429. text = elementList["%d_%d_name"%(i,j)].GetText().lower()
  430. if text.find(searchText) != -1:
  431. elementList["%d_%d_image"%(i,j)].Show()
  432. elementList["%d_%d_image"%(i,j)].SetPosition(BONUS_X, Y_POS - basePos)
  433. elementList["%d_%d_value"%(i,j)].SetText("|cFFD3936F"+str(player.GetStatus(bonus_data[j][1]))+"|r")
  434. Y_POS += CATEGORY_Y_FIRST_BONUS_RANGE
  435. images.append(elementList["%d_%d_image"%(i,j)])
  436. textLines.append(elementList["%d_%d_name"%(i,j)])
  437. textLines.append(elementList["%d_%d_value"%(i,j)])
  438. else:
  439. elementList["%d_%d_image"%(i,j)].Hide()
  440. else:
  441. for i in xrange(len(bonus_list)):
  442. bonus_data = bonus_list[i][1]
  443. if elementList.has_key("%d_category"%i):
  444. categoryBtn = elementList["%d_category"%i]
  445. categoryBtn.SetPosition(X_POS, Y_POS - basePos)
  446. categoryBtn.Show()
  447. images.append(categoryBtn)
  448. textLines.append(elementList["%d_categoryText"%i])
  449. if categoryBtn.buttonStatus == 0:
  450. Y_POS += CATEGORY_Y_RANGE
  451. for j in xrange(len(bonus_data)):
  452. elementList["%d_%d_image"%(i,j)].Hide()
  453. else:
  454. Y_POS += CATEGORY_Y_FIRST_BONUS_RANGE
  455. for j in xrange(len(bonus_data)):
  456. elementList["%d_%d_image"%(i,j)].Show()
  457. elementList["%d_%d_image"%(i,j)].SetPosition(BONUS_X, Y_POS - basePos)
  458. elementList["%d_%d_value"%(i,j)].SetText("|cFFD3936F"+str(player.GetStatus(bonus_data[j][1]))+"|r")
  459. Y_POS += CATEGORY_Y_FIRST_BONUS_RANGE
  460. images.append(elementList["%d_%d_image"%(i,j)])
  461. textLines.append(elementList["%d_%d_name"%(i,j)])
  462. textLines.append(elementList["%d_%d_value"%(i,j)])
  463. for childItem in textLines:
  464. (_x,_y) = childItem.GetGlobalPosition()
  465. if _y < _wy:
  466. if childItem.IsShow():
  467. childItem.Hide()
  468. elif _y > (_wy+windowHeight-20):
  469. if childItem.IsShow():
  470. childItem.Hide()
  471. else:
  472. if not childItem.IsShow():
  473. childItem.Show()
  474. for childItem in images:
  475. childHeight = childItem.GetHeight()
  476. (_x,_y) = childItem.GetGlobalPosition()
  477. if _y < _wy:
  478. childItem.SetRenderingRect(0,ui.calculateRect(childHeight-abs(_y-_wy),childHeight),0,0)
  479. elif _y+childHeight > (_wy+windowHeight-4):
  480. calculate = (_wy+windowHeight-4) - (_y+childHeight)
  481. if calculate == 0:
  482. return
  483. f = ui.calculateRect(childHeight-abs(calculate),childHeight)
  484. childItem.SetRenderingRect(0,0,0,f)
  485. else:
  486. childItem.SetRenderingRect(0,0,0,0)
  487. # elif self.btnIndex == 1:
  488. # for i in xrange(len(stat_list)):
  489. # if elementList.has_key("%d_stat"%i):
  490. # elementList["%d_stat"%i].SetText(localeInfo.DottedNumber(player.GetKillLOG(stat_list[i][1])))
  491. #def OnUpdate(self):
  492. # self.Refresh()
  493. def SetCategory(self, categoryIndex):
  494. self.btnIndex = categoryIndex
  495. self.ElementDictionary["itemSearch"].KillFocus()
  496. self.GetChild("bonus_window").Show()
  497. self.GetChild("stat_window").Hide()
  498. self.Refresh()
  499. def OnScroll(self):
  500. pass
  501. class NewStatistics(ui.ScriptWindow):
  502. def __del__(self):
  503. ui.ScriptWindow.__del__(self)
  504. def Destroy(self):
  505. self.ClearDictionary()
  506. self.btnIndex = 0
  507. self.isPacketLoaded = False
  508. def Show(self):
  509. ui.ScriptWindow.Show(self)
  510. self.SetTop()
  511. self.Refresh()
  512. def Close(self):
  513. self.Hide()
  514. def OnPressEscapeKey(self):
  515. self.Close()
  516. return True
  517. def AdjustPosition(self, x, y):
  518. self.SetPosition(x + self.GetWidth() -52, y)
  519. def __ClickRadioButton(self, buttonList, buttonIndex):
  520. try:
  521. radioBtn = buttonList[buttonIndex]
  522. except IndexError:
  523. return
  524. for eachButton in buttonList:
  525. eachButton.SetUp()
  526. radioBtn.Down()
  527. def __init__(self, parent):
  528. self.uiCharacterStatus = parent
  529. ui.ScriptWindow.__init__(self)
  530. self.Destroy()
  531. self.__LoadScript()
  532. def SetStatistics(self, button):
  533. interface = constInfo.GetInterfaceInstance()
  534. interface.wndcharacter.ExpandBtn2.CallEvent()
  535. def __LoadScript(self):
  536. try:
  537. pyScrLoader = ui.PythonScriptLoader()
  538. pyScrLoader.LoadScriptFile(self, "UIScript/CharacterDetailsWindow.py")
  539. self.GetChild("bonus_button").SAFE_SetEvent(self.SetStatistics,0)
  540. except:
  541. import exception
  542. exception.Abort("CharacterDetailsUI.__LoadScript")
  543. #self.ScrollBar = self.GetChild("ScrollBar")
  544. #self.ScrollBar.SetScrollEvent(ui.__mem_func__(self.OnScroll))
  545. elementList = self.ElementDictionary
  546. statWindow = self.GetChild("stat_window")
  547. # for i in xrange(len(stat_list)):
  548. # statName = ui.TextLine()
  549. # statName.SetParent(statWindow)
  550. # statName.AddFlag("not_pick")
  551. # statName.SetPosition(70,15+(i*40))
  552. # statName.SetFontName("Tahoma:13")
  553. # statName.SetHorizontalAlignCenter()
  554. # statName.SetText(stat_list[i][0])
  555. # statName.Show()
  556. # elementList["%d_stat_name"%i] = statName
  557. # statValue = ui.TextLine()
  558. # statValue.AddFlag("not_pick")
  559. # statValue.SetParent(statWindow)
  560. # statValue.SetPosition(180,15+(i*40))
  561. # statValue.SetFontName("Tahoma:13")
  562. # statValue.SetHorizontalAlignCenter()
  563. # statValue.Show()
  564. # elementList["%d_stat"%i] = statValue
  565. bonusWindow = self.GetChild("bonus_window")
  566. searchBoard = SearchSlotBoard()
  567. searchBoard.SetParent(bonusWindow)
  568. searchBoard.SetPosition((bonusWindow.GetWidth()/2)-(129/2),11)
  569. searchBoard.SetSize(129,23)
  570. searchBoard.Show()
  571. elementList["searchBoard"] = searchBoard
  572. itemSearch = ui.EditLine()
  573. itemSearch.SetParent(searchBoard)
  574. itemSearch.SetMax(40)
  575. itemSearch.SetPosition(5,5)
  576. itemSearch.SetSize(searchBoard.GetWidth(), searchBoard.GetHeight())
  577. itemSearch.OnIMEUpdate = ui.__mem_func__(self.__OnValueUpdate)
  578. itemSearch.Show()
  579. elementList["itemSearch"] = itemSearch
  580. searchBtn = ui.Button()
  581. searchBtn.SetParent(searchBoard)
  582. searchBtn.SetUpVisual(IMG_DIR+"search_btn_0.tga")
  583. searchBtn.SetOverVisual(IMG_DIR+"search_btn_1.tga")
  584. searchBtn.SetDownVisual(IMG_DIR+"search_btn_2.tga")
  585. searchBtn.SetEvent(self.__OnValueUpdate)
  586. searchBtn.SetPosition(itemSearch.GetWidth()-searchBtn.GetWidth(),2)
  587. searchBtn.Show()
  588. elementList["searchBtn"] = searchBtn
  589. #bonusWindow.OnMouseWheel = ui.__mem_func__(self.OnMouseWheel)
  590. scrollBar = ScrollBarNew()
  591. scrollBar.SetParent(bonusWindow)
  592. scrollBar.SetPosition((bonusWindow.GetWidth()-scrollBar.GetWidth())-3,43)
  593. scrollBar.SetScrollBarSize((bonusWindow.GetHeight()-46)-5)
  594. scrollBar.SetScrollEvent(ui.__mem_func__(self.Refresh))
  595. scrollBar.Show()
  596. elementList["scrollBar"] = scrollBar
  597. for i in xrange(len(bonus_list_2)):
  598. bonus_data = bonus_list_2[i][1]
  599. category = ui.ExpandedImageBox()
  600. category.SetParent(bonusWindow)
  601. category.LoadImage(IMG_DIR+"category_item2.tga")
  602. category.buttonStatus = 0
  603. category.SetEvent(ui.__mem_func__(self.SetBonusCategory),"mouse_click", i)
  604. category.Show()
  605. elementList["%d_category"%i] = category
  606. categoryText = ui.TextLine()
  607. categoryText.SetParent(category)
  608. categoryText.SetHorizontalAlignLeft()
  609. categoryText.SetPosition(8,3)
  610. categoryText.SetText("|Eemoji/plus|e "+bonus_list_2[i][0])
  611. categoryText.Show()
  612. elementList["%d_categoryText"%i] = categoryText
  613. for j in xrange(len(bonus_data)):
  614. bonusImage = ui.ExpandedImageBox()
  615. #bonusImage.AddFlag("not_pick")
  616. bonusImage.SetParent(bonusWindow)
  617. bonusImage.LoadImage(IMG_DIR+"bonus_item2.tga")
  618. bonusImage.Show()
  619. elementList["%d_%d_image"%(i,j)] = bonusImage
  620. bonusText = [bonus_data[j][0]]
  621. disabledStr = ["%","+"]
  622. newText = ""
  623. for x in bonusText:
  624. if x in disabledStr:
  625. continue
  626. if x.isdigit():
  627. continue
  628. newText+=x
  629. bonusText=newText
  630. bonusImage.SAFE_SetStringEvent("MOUSE_OVER_IN",self.OverInBonus, bonusText)
  631. bonusImage.SAFE_SetStringEvent("MOUSE_OVER_OUT",self.OverOutBonus)
  632. #bonusText = bonusText.replace(":","")
  633. #index = bonusText.find("+")
  634. #if index == -1:
  635. # index = bonusText.find("%")
  636. # if index == -1:
  637. # index =0
  638. #if not index <= 0:
  639. # bonusText = bonusText[:index]
  640. bonusName = ui.TextLine()
  641. bonusName.AddFlag("not_pick")
  642. bonusName.SetParent(bonusImage)
  643. bonusName.SetHorizontalAlignLeft()
  644. bonusName.SetPosition(72+52-23-97,3)
  645. bonusName.SetFontName(localeInfo.UI_DEF_FONT)
  646. bonusName.SetText(bonusText)
  647. bonusName.Show()
  648. elementList["%d_%d_name"%(i,j)] = bonusName
  649. bonusValue = ui.TextLine()
  650. bonusValue.AddFlag("not_pick")
  651. bonusValue.SetParent(bonusImage)
  652. bonusValue.SetHorizontalAlignRight()
  653. bonusValue.SetPosition(170+52+20,3)
  654. bonusValue.SetFontName(localeInfo.UI_DEF_FONT)
  655. bonusValue.SetText("|cFFD3936F0|r")
  656. bonusValue.Show()
  657. elementList["%d_%d_value"%(i,j)] = bonusValue
  658. self.SetCategory(0)
  659. def OverOutBonus(self):
  660. interface = constInfo.GetInterfaceInstance()
  661. if interface:
  662. if interface.tooltipItem:
  663. interface.tooltipItem.HideToolTip()
  664. def OverInBonus(self, bonusName):
  665. interface = constInfo.GetInterfaceInstance()
  666. if interface:
  667. if interface.tooltipItem:
  668. interface.tooltipItem.ClearToolTip()
  669. interface.tooltipItem.AppendTextLine(bonusName)
  670. interface.tooltipItem.ShowToolTip()
  671. def OnMouseWheel(self, nLen):
  672. if self.btnIndex == 0:
  673. if self.ElementDictionary.has_key("scrollBar"):
  674. scrollBar = self.ElementDictionary["scrollBar"]
  675. if scrollBar.IsShow():
  676. if nLen > 0:
  677. scrollBar.OnUp()
  678. else:
  679. scrollBar.OnDown()
  680. return True
  681. return False
  682. def __OnValueUpdate(self):
  683. elementList = self.ElementDictionary
  684. itemSearch = elementList["itemSearch"]
  685. ui.EditLine.OnIMEUpdate(itemSearch)
  686. bonusWindow = self.GetChild("bonus_window")
  687. searchText = itemSearch.GetText()
  688. board = elementList["searchBoard"]
  689. totalWidth = 129
  690. if len(searchText) > 0:
  691. self.ElementDictionary["scrollBar"].SetPos(0, True)
  692. totalWidth-=25
  693. windowHeight = bonusWindow.GetWidth()-15
  694. textSize = itemSearch.GetTextSize()[0]
  695. if textSize >= totalWidth:
  696. if textSize >= windowHeight:
  697. totalWidth = windowHeight
  698. else:
  699. totalWidth = textSize
  700. totalWidth+=25
  701. if totalWidth >= windowHeight:
  702. totalWidth = windowHeight
  703. board.SetSize(totalWidth,23)
  704. itemSearch.SetSize(totalWidth,23)
  705. board.SetPosition((bonusWindow.GetWidth()/2)-(board.GetWidth()/2),11)
  706. searchBtn = elementList["searchBtn"]
  707. searchBtn.SetPosition(itemSearch.GetWidth()-searchBtn.GetWidth(),2)
  708. self.Refresh()
  709. def SetBonusCategory(self, emptyArg, categoryIndex):
  710. category = self.ElementDictionary["%d_category"%categoryIndex]
  711. category.buttonStatus = not category.buttonStatus
  712. if category.buttonStatus == 0:
  713. self.ElementDictionary["%d_categoryText"%categoryIndex].SetText("|Eemoji/plus|e "+bonus_list_2[categoryIndex][0])
  714. else:
  715. self.ElementDictionary["%d_categoryText"%categoryIndex].SetText("|Eemoji/negative|e "+bonus_list_2[categoryIndex][0])
  716. self.Refresh()
  717. def Refresh(self):
  718. elementList = self.ElementDictionary
  719. (X_POS,Y_POS) = (3,43)
  720. CATEGORY_Y_RANGE = 25
  721. CATEGORY_Y_FIRST_BONUS_RANGE = 29
  722. BONUS_X = 13
  723. if self.btnIndex == 0:
  724. bonusWindow = self.GetChild("bonus_window")
  725. scrollBar = self.GetChild("scrollBar")
  726. (basePos,windowHeight) = (0,bonusWindow.GetHeight()-46)
  727. searchText = elementList["itemSearch"].GetText().lower()
  728. maxHeight = 0
  729. if len(searchText) > 0:
  730. for i in xrange(len(bonus_list_2)):
  731. bonus_data = bonus_list_2[i][1]
  732. for j in xrange(len(bonus_data)):
  733. text = elementList["%d_%d_name"%(i,j)].GetText().lower()
  734. if text.find(searchText) != -1:
  735. #if len(text) >= len(searchText):
  736. # if text[:len(searchText)] == searchText:
  737. maxHeight += CATEGORY_Y_FIRST_BONUS_RANGE
  738. else:
  739. for i in xrange(len(bonus_list_2)):
  740. bonus_data = bonus_list_2[i][1]
  741. if elementList.has_key("%d_category"%i):
  742. categoryBtn = elementList["%d_category"%i]
  743. if categoryBtn.buttonStatus == 0:
  744. maxHeight += CATEGORY_Y_RANGE
  745. else:
  746. maxHeight += CATEGORY_Y_FIRST_BONUS_RANGE
  747. for j in xrange(len(bonus_data)):
  748. maxHeight += CATEGORY_Y_FIRST_BONUS_RANGE
  749. if maxHeight > windowHeight:
  750. scrollLen = maxHeight-windowHeight
  751. basePos = int(scrollBar.GetPos()*scrollLen)
  752. stepSize = 1.0 / (scrollLen/100.0)
  753. scrollBar.SetScrollStep(stepSize)
  754. scrollBar.SetMiddleBarSize(float(windowHeight-5)/float(maxHeight))
  755. scrollBar.Show()
  756. else:
  757. scrollBar.Hide()
  758. textLines = []
  759. images = []
  760. _wy = bonusWindow.GetGlobalPosition()[1]+43
  761. if len(searchText) > 0:
  762. for i in xrange(len(bonus_list_2)):
  763. bonus_data = bonus_list_2[i][1]
  764. if elementList.has_key("%d_category"%i):
  765. elementList["%d_category"%i].Hide()
  766. for j in xrange(len(bonus_data)):
  767. text = elementList["%d_%d_name"%(i,j)].GetText().lower()
  768. if text.find(searchText) != -1:
  769. elementList["%d_%d_image"%(i,j)].Show()
  770. elementList["%d_%d_image"%(i,j)].SetPosition(BONUS_X, Y_POS - basePos)
  771. elementList["%d_%d_value"%(i,j)].SetText("|cFFD3936F"+str(localeInfo.NumberToString(player.GetStatus(bonus_data[j][1])))+"|r")
  772. Y_POS += CATEGORY_Y_FIRST_BONUS_RANGE
  773. images.append(elementList["%d_%d_image"%(i,j)])
  774. textLines.append(elementList["%d_%d_name"%(i,j)])
  775. textLines.append(elementList["%d_%d_value"%(i,j)])
  776. else:
  777. elementList["%d_%d_image"%(i,j)].Hide()
  778. else:
  779. for i in xrange(len(bonus_list_2)):
  780. bonus_data = bonus_list_2[i][1]
  781. if elementList.has_key("%d_category"%i):
  782. categoryBtn = elementList["%d_category"%i]
  783. categoryBtn.SetPosition(X_POS, Y_POS - basePos)
  784. categoryBtn.Show()
  785. images.append(categoryBtn)
  786. textLines.append(elementList["%d_categoryText"%i])
  787. if categoryBtn.buttonStatus == 0:
  788. Y_POS += CATEGORY_Y_RANGE
  789. for j in xrange(len(bonus_data)):
  790. elementList["%d_%d_image"%(i,j)].Hide()
  791. else:
  792. Y_POS += CATEGORY_Y_FIRST_BONUS_RANGE
  793. for j in xrange(len(bonus_data)):
  794. elementList["%d_%d_image"%(i,j)].Show()
  795. elementList["%d_%d_image"%(i,j)].SetPosition(BONUS_X, Y_POS - basePos)
  796. elementList["%d_%d_value"%(i,j)].SetText("|cFFD3936F"+str(localeInfo.NumberToString(player.GetStatus(bonus_data[j][1])))+"|r")
  797. Y_POS += CATEGORY_Y_FIRST_BONUS_RANGE
  798. images.append(elementList["%d_%d_image"%(i,j)])
  799. textLines.append(elementList["%d_%d_name"%(i,j)])
  800. textLines.append(elementList["%d_%d_value"%(i,j)])
  801. for childItem in textLines:
  802. (_x,_y) = childItem.GetGlobalPosition()
  803. if _y < _wy:
  804. if childItem.IsShow():
  805. childItem.Hide()
  806. elif _y > (_wy+windowHeight-20):
  807. if childItem.IsShow():
  808. childItem.Hide()
  809. else:
  810. if not childItem.IsShow():
  811. childItem.Show()
  812. for childItem in images:
  813. childHeight = childItem.GetHeight()
  814. (_x,_y) = childItem.GetGlobalPosition()
  815. if _y < _wy:
  816. childItem.SetRenderingRect(0,ui.calculateRect(childHeight-abs(_y-_wy),childHeight),0,0)
  817. elif _y+childHeight > (_wy+windowHeight-4):
  818. calculate = (_wy+windowHeight-4) - (_y+childHeight)
  819. if calculate == 0:
  820. return
  821. f = ui.calculateRect(childHeight-abs(calculate),childHeight)
  822. childItem.SetRenderingRect(0,0,0,f)
  823. else:
  824. childItem.SetRenderingRect(0,0,0,0)
  825. # elif self.btnIndex == 1:
  826. # for i in xrange(len(stat_list)):
  827. # if elementList.has_key("%d_stat"%i):
  828. # elementList["%d_stat"%i].SetText(localeInfo.DottedNumber(player.GetKillLOG(stat_list[i][1])))
  829. #def OnUpdate(self):
  830. # self.Refresh()
  831. def SetCategory(self, categoryIndex):
  832. self.btnIndex = categoryIndex
  833. self.ElementDictionary["itemSearch"].KillFocus()
  834. self.GetChild("bonus_window").Show()
  835. self.GetChild("stat_window").Hide()
  836. self.Refresh()
  837. def OnScroll(self):
  838. pass
  839. class ScrollBarNew(ui.Window):
  840. SCROLLBAR_WIDTH = 7
  841. SCROLL_BTN_XDIST = 0
  842. SCROLL_BTN_YDIST = 0
  843. class MiddleBar(ui.DragButton):
  844. def __init__(self):
  845. ui.DragButton.__init__(self)
  846. self.AddFlag("movable")
  847. self.SetWindowName("scrollbar_middlebar")
  848. def MakeImage(self):
  849. top = ui.ExpandedImageBox()
  850. top.SetParent(self)
  851. top.LoadImage(IMG_DIR+"scrollbar/scrollbar_top.tga")
  852. top.AddFlag("not_pick")
  853. top.Show()
  854. topScale = ui.ExpandedImageBox()
  855. topScale.SetParent(self)
  856. topScale.SetPosition(0, top.GetHeight())
  857. topScale.LoadImage(IMG_DIR+"scrollbar/scrollbar_scale.tga")
  858. topScale.AddFlag("not_pick")
  859. topScale.Show()
  860. bottom = ui.ExpandedImageBox()
  861. bottom.SetParent(self)
  862. bottom.LoadImage(IMG_DIR+"scrollbar/scrollbar_bottom.tga")
  863. bottom.AddFlag("not_pick")
  864. bottom.Show()
  865. bottomScale = ui.ExpandedImageBox()
  866. bottomScale.SetParent(self)
  867. bottomScale.LoadImage(IMG_DIR+"scrollbar/scrollbar_scale.tga")
  868. bottomScale.AddFlag("not_pick")
  869. bottomScale.Show()
  870. middle = ui.ExpandedImageBox()
  871. middle.SetParent(self)
  872. middle.LoadImage(IMG_DIR+"scrollbar/scrollbar_mid.tga")
  873. middle.AddFlag("not_pick")
  874. middle.Show()
  875. self.top = top
  876. self.topScale = topScale
  877. self.bottom = bottom
  878. self.bottomScale = bottomScale
  879. self.middle = middle
  880. def SetSize(self, height):
  881. minHeight = self.top.GetHeight() + self.bottom.GetHeight() + self.middle.GetHeight()
  882. height = max(minHeight, height)
  883. ui.DragButton.SetSize(self, 10, height)
  884. scale = (height - minHeight) / 2
  885. extraScale = 0
  886. if (height - minHeight) % 2 == 1:
  887. extraScale = 1
  888. self.topScale.SetRenderingRect(0, 0, 0, scale - 1)
  889. self.middle.SetPosition(0, self.top.GetHeight() + scale)
  890. self.bottomScale.SetPosition(0, self.middle.GetBottom())
  891. self.bottomScale.SetRenderingRect(0, 0, 0, scale - 1 + extraScale)
  892. self.bottom.SetPosition(0, height - self.bottom.GetHeight())
  893. def __init__(self):
  894. ui.Window.__init__(self)
  895. self.pageSize = 1
  896. self.curPos = 0.0
  897. self.eventScroll = None
  898. self.eventArgs = None
  899. self.lockFlag = False
  900. self.CreateScrollBar()
  901. self.SetScrollBarSize(0)
  902. self.scrollStep = 0.4
  903. self.SetWindowName("NONAME_ScrollBar")
  904. def __del__(self):
  905. ui.Window.__del__(self)
  906. def CreateScrollBar(self):
  907. topImage = ui.ExpandedImageBox()
  908. topImage.SetParent(self)
  909. topImage.AddFlag("not_pick")
  910. topImage.LoadImage(IMG_DIR+"scrollbar/scroll_top.tga")
  911. topImage.Show()
  912. bottomImage = ui.ExpandedImageBox()
  913. bottomImage.SetParent(self)
  914. bottomImage.AddFlag("not_pick")
  915. bottomImage.LoadImage(IMG_DIR+"scrollbar/scroll_bottom.tga")
  916. bottomImage.Show()
  917. middleImage = ui.ExpandedImageBox()
  918. middleImage.SetParent(self)
  919. middleImage.AddFlag("not_pick")
  920. middleImage.SetPosition(0, topImage.GetHeight())
  921. middleImage.LoadImage(IMG_DIR+"scrollbar/scroll_mid.tga")
  922. middleImage.Show()
  923. self.topImage = topImage
  924. self.bottomImage = bottomImage
  925. self.middleImage = middleImage
  926. middleBar = self.MiddleBar()
  927. middleBar.SetParent(self)
  928. middleBar.SetMoveEvent(ui.__mem_func__(self.OnMove))
  929. middleBar.Show()
  930. middleBar.MakeImage()
  931. middleBar.SetSize(12)
  932. self.middleBar = middleBar
  933. def Destroy(self):
  934. self.eventScroll = None
  935. self.eventArgs = None
  936. def SetScrollEvent(self, event, *args):
  937. self.eventScroll = event
  938. self.eventArgs = args
  939. def SetMiddleBarSize(self, pageScale):
  940. self.middleBar.SetSize(int(pageScale * float(self.GetHeight() - (self.SCROLL_BTN_YDIST*2))))
  941. realHeight = self.GetHeight() - (self.SCROLL_BTN_YDIST*2) - self.middleBar.GetHeight()
  942. self.pageSize = realHeight
  943. def SetScrollBarSize(self, height):
  944. self.SetSize(self.SCROLLBAR_WIDTH, height)
  945. self.pageSize = height - self.SCROLL_BTN_YDIST*2 - self.middleBar.GetHeight()
  946. middleImageScale = float((height - self.SCROLL_BTN_YDIST*2) - self.middleImage.GetHeight()) / float(self.middleImage.GetHeight())
  947. self.middleImage.SetRenderingRect(0, 0, 0, middleImageScale)
  948. self.bottomImage.SetPosition(0, height - self.bottomImage.GetHeight())
  949. self.middleBar.SetRestrictMovementArea(self.SCROLL_BTN_XDIST, self.SCROLL_BTN_YDIST, \
  950. self.middleBar.GetWidth(), height - self.SCROLL_BTN_YDIST * 2)
  951. self.middleBar.SetPosition(self.SCROLL_BTN_XDIST, self.SCROLL_BTN_YDIST)
  952. def SetScrollStep(self, step):
  953. self.scrollStep = step
  954. def OnUp(self):
  955. self.SetPos(self.curPos-self.scrollStep)
  956. def OnDown(self):
  957. self.SetPos(self.curPos+self.scrollStep)
  958. def GetScrollStep(self):
  959. return self.scrollStep
  960. def GetPos(self):
  961. return self.curPos
  962. def OnUp(self):
  963. self.SetPos(self.curPos-self.scrollStep)
  964. def OnDown(self):
  965. self.SetPos(self.curPos+self.scrollStep)
  966. def SetPos(self, pos, moveEvent = True):
  967. pos = max(0.0, pos)
  968. pos = min(1.0, pos)
  969. newPos = float(self.pageSize) * pos
  970. self.middleBar.SetPosition(self.SCROLL_BTN_XDIST, int(newPos) + self.SCROLL_BTN_YDIST)
  971. if moveEvent == True:
  972. self.OnMove()
  973. def OnMove(self):
  974. if self.lockFlag:
  975. return
  976. if 0 == self.pageSize:
  977. return
  978. (xLocal, yLocal) = self.middleBar.GetLocalPosition()
  979. self.curPos = float(yLocal - self.SCROLL_BTN_YDIST) / float(self.pageSize)
  980. if self.eventScroll:
  981. apply(self.eventScroll, self.eventArgs)
  982. def OnMouseLeftButtonDown(self):
  983. (xMouseLocalPosition, yMouseLocalPosition) = self.GetMouseLocalPosition()
  984. newPos = float(yMouseLocalPosition) / float(self.GetHeight())
  985. self.SetPos(newPos)
  986. def LockScroll(self):
  987. self.lockFlag = True
  988. def UnlockScroll(self):
  989. self.lockFlag = False
  990. class SearchSlotBoard(ui.Window):
  991. CORNER_WIDTH = 7
  992. CORNER_HEIGHT = 7
  993. LINE_WIDTH = 7
  994. LINE_HEIGHT = 7
  995. LT = 0
  996. LB = 1
  997. RT = 2
  998. RB = 3
  999. L = 0
  1000. R = 1
  1001. T = 2
  1002. B = 3
  1003. def __init__(self):
  1004. ui.Window.__init__(self)
  1005. self.MakeBoard()
  1006. self.MakeBase()
  1007. def MakeBoard(self):
  1008. cornerPath = IMG_DIR+"board/corner_"
  1009. linePath = IMG_DIR+"board/"
  1010. CornerFileNames = [ cornerPath+dir+".tga" for dir in ("left_top", "left_bottom", "right_top", "right_bottom") ]
  1011. LineFileNames = [ linePath+dir+".tga" for dir in ("left", "right", "top", "bottom") ]
  1012. self.Corners = []
  1013. for fileName in CornerFileNames:
  1014. Corner = ui.ExpandedImageBox()
  1015. Corner.AddFlag("not_pick")
  1016. Corner.LoadImage(fileName)
  1017. Corner.SetParent(self)
  1018. Corner.SetPosition(0, 0)
  1019. Corner.Show()
  1020. self.Corners.append(Corner)
  1021. self.Lines = []
  1022. for fileName in LineFileNames:
  1023. Line = ui.ExpandedImageBox()
  1024. Line.AddFlag("not_pick")
  1025. Line.LoadImage(fileName)
  1026. Line.SetParent(self)
  1027. Line.SetPosition(0, 0)
  1028. Line.Show()
  1029. self.Lines.append(Line)
  1030. self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  1031. self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  1032. def MakeBase(self):
  1033. self.Base = ui.ExpandedImageBox()
  1034. self.Base.AddFlag("not_pick")
  1035. self.Base.LoadImage(IMG_DIR+"board/base.tga")
  1036. self.Base.SetParent(self)
  1037. self.Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  1038. self.Base.Show()
  1039. def __del__(self):
  1040. ui.Window.__del__(self)
  1041. def Destroy(self):
  1042. self.Base=0
  1043. self.Corners=0
  1044. self.Lines=0
  1045. self.CORNER_WIDTH = 0
  1046. self.CORNER_HEIGHT = 0
  1047. self.LINE_WIDTH = 0
  1048. self.LINE_HEIGHT = 0
  1049. self.LT = 0
  1050. self.LB = 0
  1051. self.RT = 0
  1052. self.RB = 0
  1053. self.L = 0
  1054. self.R = 0
  1055. self.T = 0
  1056. self.B = 0
  1057. def SetSize(self, width, height):
  1058. width = max(self.CORNER_WIDTH*2, width)
  1059. height = max(self.CORNER_HEIGHT*2, height)
  1060. ui.Window.SetSize(self, width, height)
  1061. self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  1062. self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  1063. self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  1064. self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  1065. self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  1066. verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  1067. horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  1068. self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  1069. self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  1070. self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  1071. self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  1072. if self.Base:
  1073. self.Base.SetRenderingRect(0, 0, horizontalShowingPercentage, verticalShowingPercentage)

uicharacterdetails