1. import ui, grp, app, wiki, item, nonplayer, renderTarget, constInfo, skill, WikiUI
  2. import localeInfo
  3. import chat
  4. import dbg
  5. # if false will be textline!
  6. USE_ITEM_COUNT_NUMBER_LINE = False
  7. # if this true item refine showing start index in +0 than +9 will be next item if have!
  8. SHOW_NEXT_ITEM_REFINE = False
  9. SHOW_ITEM_LOWER_TO_BIG = False
  10. # category load speed
  11. AUTOLOAD_SPEED = 0.010
  12. AUTOLOAD_MONSTER_SPEED = 0.020
  13. IMG_DIR = "d:/ymir work/ui/game/wiki/"
  14. class EncyclopediaofGame(ui.BoardWithTitleBar):
  15. def __del__(self):
  16. ui.BoardWithTitleBar.__del__(self)
  17. def Destroy(self):
  18. if self.children.has_key("listBoxCube"):
  19. self.children["listBoxCube"].ClearItem()
  20. self.children["listBoxCube"]=None
  21. del self.children["listBoxCube"]
  22. if self.children.has_key("resultpageListbox"):
  23. self.children["resultpageListbox"].RemoveAllItems()
  24. self.children["resultpageListbox"]=None
  25. del self.children["resultpageListbox"]
  26. self.selectArg=""
  27. self.AIAppendAlgoritm = None
  28. if len(self.children) != 0:
  29. ui.BoardWithTitleBar.Destroy(self)
  30. constInfo.SetMainParent(None)
  31. constInfo.SetListBox(None)
  32. self.children = {}
  33. def __init__(self):
  34. ui.BoardWithTitleBar.__init__(self)
  35. self.SetWindowName("EncyclopediaofGame")
  36. self.AddFlag("movable")
  37. self.AddFlag("float")
  38. self.AddFlag("animate")
  39. self.children = {}
  40. self.Destroy()
  41. # Default variable
  42. self.children["characterIndex"]=0
  43. self.Initialize()
  44. def Initialize(self):
  45. self.SetSize(720, 480)
  46. self.SetTitleName(localeInfo.WIKI_TITLE)
  47. self.SetCenterPosition()
  48. self.LoadSearchInfos()
  49. self.LoadCategoryInfos()
  50. self.LoadBlock()
  51. self.LoadResultPage()
  52. def LoadResultPage(self):
  53. resultPageImage = ui.ImageBox()
  54. resultPageImage.SetParent(self)
  55. resultPageImage.LoadImage(IMG_DIR+"result_wall.tga")
  56. resultPageImage.SetPosition(150,104)
  57. resultPageImage.Show()
  58. self.children["resultPageImage"] = resultPageImage
  59. for j in xrange(4):
  60. characterBtn = ui.RadioButton()
  61. characterBtn.SetParent(resultPageImage)
  62. characterBtn.SetEvent(ui.__mem_func__(self.__SelectCharacters),j)
  63. characterBtn.SetUpVisual(IMG_DIR+"character/%d_0.tga"%j)
  64. characterBtn.SetOverVisual(IMG_DIR+"character/%d_1.tga"%j)
  65. characterBtn.SetDownVisual(IMG_DIR+"character/%d_2.tga"%j)
  66. characterBtn.SetPosition(16+(132*j),11)
  67. characterBtn.Hide()
  68. self.children["job_%d_characterBtn"%j] = characterBtn
  69. resultpageListbox = WikiUI.ScrollBarNew()
  70. resultpageListbox.SetParent(self)
  71. self.children["resultpageListbox"] = resultpageListbox
  72. resultpageListboxScrollbar = WikiUI.ScrollBarNew()
  73. resultpageListboxScrollbar.SetParent(self)
  74. self.children["resultpageListboxScrollbar"] = resultpageListboxScrollbar
  75. resultpageListbox = WikiUI.ListBox()
  76. resultpageListbox.SetParent(self)
  77. resultpageListbox.SetScrollBar(resultpageListboxScrollbar)
  78. self.children["resultpageListbox"] = resultpageListbox
  79. constInfo.SetMainParent(self)
  80. constInfo.SetListBox(resultpageListbox)
  81. resultpagebtn = ui.ExpandedImageBox()
  82. resultpagebtn.SetParent(self) # <board>
  83. resultpagebtn.SetPosition(150,32)
  84. resultpagebtn.SetEvent(ui.__mem_func__(self.LoadGuidePage),"mouse_click")
  85. resultpagebtn.Show()
  86. self.children["resultpagebtn"] = resultpagebtn
  87. self.LoadGuidePage()
  88. def LoadGuidePage(self, emptyArg = ""):
  89. self.__SelectType("System#0",False,False)
  90. def LoadBlock(self):
  91. blockImage = ui.ImageBox()
  92. blockImage.SetParent(self)
  93. blockImage.LoadImage(IMG_DIR+"block.tga")
  94. blockImage.SetPosition(140,32)
  95. blockImage.Show()
  96. self.children["blockImage"] = blockImage
  97. def LoadSearchInfos(self):
  98. self.children["selectedMob"] = 0
  99. self.children["selectedItem"] = 0
  100. searchSlot = ui.ImageBox()
  101. searchSlot.SetParent(self)
  102. searchSlot.LoadImage(IMG_DIR+"search_slot.tga")
  103. searchSlot.SetPosition(13,32)
  104. searchSlot.Show()
  105. self.children["searchSlot"] = searchSlot
  106. searchButton = ui.Button()
  107. searchButton.SetParent(searchSlot)
  108. searchButton.SetUpVisual(IMG_DIR+"button_0.tga")
  109. searchButton.SetOverVisual(IMG_DIR+"button_1.tga")
  110. searchButton.SetDownVisual(IMG_DIR+"button_2.tga")
  111. searchButton.SAFE_SetEvent(self.StartSearchItem)
  112. searchButton.SetPosition(91,3)
  113. searchButton.Show()
  114. self.children["searchButton"] = searchButton
  115. searchItemName = ui.EditLine()
  116. searchItemName.SetParent(searchSlot)
  117. searchItemName.SetPosition(2,5)
  118. searchItemName.SetSize(91,26)
  119. #searchItemName.SetFontName("Tahoma:11")
  120. searchItemName.SetInfoMessage(localeInfo.WIKI_ITEM_NAME)
  121. searchItemName.SetMax(30)
  122. searchItemName.isNeedEmpty = False
  123. searchItemName.OnPressEscapeKey = ui.__mem_func__(self.Close)
  124. searchItemName.SetOutline()
  125. searchItemName.OnIMEUpdate = ui.__mem_func__(self.__OnValueUpdateItem)
  126. searchItemName.SetReturnEvent(ui.__mem_func__(self.StartSearchItem))
  127. searchItemName.Show()
  128. self.children["searchItemName"] = searchItemName
  129. searchClearBtn = ui.Button()
  130. searchClearBtn.SetParent(searchSlot)
  131. searchClearBtn.SetUpVisual(IMG_DIR+"clear_button_1.tga")
  132. searchClearBtn.SetOverVisual(IMG_DIR+"clear_button_2.tga")
  133. searchClearBtn.SetDownVisual(IMG_DIR+"clear_button_1.tga")
  134. searchClearBtn.SetPosition(75,5)
  135. searchClearBtn.SAFE_SetEvent(self.ClearEditlineItem)
  136. searchClearBtn.Hide()
  137. self.children["searchClearBtn"] = searchClearBtn
  138. mobSlot = ui.ImageBox()
  139. mobSlot.SetParent(self)
  140. mobSlot.LoadImage(IMG_DIR+"search_slot.tga")
  141. mobSlot.SetPosition(13,32+29)
  142. mobSlot.Show()
  143. self.children["mobSlot"] = mobSlot
  144. searchButtonMob = ui.Button()
  145. searchButtonMob.SetParent(mobSlot)
  146. searchButtonMob.SetUpVisual(IMG_DIR+"button_0.tga")
  147. searchButtonMob.SetOverVisual(IMG_DIR+"button_1.tga")
  148. searchButtonMob.SetDownVisual(IMG_DIR+"button_2.tga")
  149. searchButtonMob.SAFE_SetEvent(self.StartSearchMob)
  150. searchButtonMob.SetPosition(91,2)
  151. searchButtonMob.Show()
  152. self.children["searchButtonMob"] = searchButtonMob
  153. searchMobName = ui.EditLine()
  154. searchMobName.SetParent(mobSlot)
  155. searchMobName.SetPosition(2,5)
  156. searchMobName.SetSize(91,26)
  157. #searchMobName.SetFontName("Tahoma:11")
  158. searchMobName.SetInfoMessage(localeInfo.WIKI_MOB_NAME)
  159. searchMobName.isNeedEmpty = False
  160. searchMobName.SetMax(30)
  161. searchMobName.SetOutline()
  162. searchMobName.OnPressEscapeKey = ui.__mem_func__(self.Close)
  163. searchMobName.OnIMEUpdate = ui.__mem_func__(self.__OnValueUpdateMob)
  164. searchMobName.SetReturnEvent(ui.__mem_func__(self.StartSearchMob))
  165. searchMobName.Show()
  166. self.children["searchMobName"] = searchMobName
  167. searchClearBtnMob = ui.Button()
  168. searchClearBtnMob.SetParent(mobSlot)
  169. searchClearBtnMob.SetUpVisual(IMG_DIR+"clear_button_1.tga")
  170. searchClearBtnMob.SetOverVisual(IMG_DIR+"clear_button_2.tga")
  171. searchClearBtnMob.SetDownVisual(IMG_DIR+"clear_button_1.tga")
  172. searchClearBtnMob.SetPosition(75,5)
  173. searchClearBtnMob.SAFE_SetEvent(self.ClearEditlineMob)
  174. searchClearBtnMob.Hide()
  175. self.children["searchClearBtnMob"] = searchClearBtnMob
  176. def SetHistoryButtons(self):
  177. historyBack = self.children["historyBack"]
  178. historyNext = self.children["historyNext"]
  179. #currentSearch = self.children["currentSearch"]
  180. currentIndex = self.children["currentIndex"]
  181. historySearch = self.children["historySearch"]
  182. if len(historySearch) == 0:
  183. historyNext.SetUpVisual(IMG_DIR+"btn_arrow_right_normal.tga")
  184. historyNext.SetOverVisual(IMG_DIR+"btn_arrow_right_normal.tga")
  185. historyNext.SetDownVisual(IMG_DIR+"btn_arrow_right_normal.tga")
  186. historyBack.SetUpVisual(IMG_DIR+"btn_arrow_left_normal.tga")
  187. historyBack.SetOverVisual(IMG_DIR+"btn_arrow_left_normal.tga")
  188. historyBack.SetDownVisual(IMG_DIR+"btn_arrow_left_normal.tga")
  189. return
  190. #chat.AppendChat(1,"currentIndex %d len %d"%(currentIndex, len(historySearch)))
  191. if currentIndex > 0:
  192. historyBack.SetUpVisual(IMG_DIR+"btn_arrow_left_normal.tga")
  193. historyBack.SetOverVisual(IMG_DIR+"btn_arrow_left_hover.tga")
  194. historyBack.SetDownVisual(IMG_DIR+"btn_arrow_left_down.tga")
  195. else:
  196. historyBack.SetUpVisual(IMG_DIR+"btn_arrow_left_normal.tga")
  197. historyBack.SetOverVisual(IMG_DIR+"btn_arrow_left_normal.tga")
  198. historyBack.SetDownVisual(IMG_DIR+"btn_arrow_left_normal.tga")
  199. if currentIndex+1 >= len(historySearch):
  200. historyNext.SetUpVisual(IMG_DIR+"btn_arrow_right_normal.tga")
  201. historyNext.SetOverVisual(IMG_DIR+"btn_arrow_right_normal.tga")
  202. historyNext.SetDownVisual(IMG_DIR+"btn_arrow_right_normal.tga")
  203. else:
  204. historyNext.SetUpVisual(IMG_DIR+"btn_arrow_right_normal.tga")
  205. historyNext.SetOverVisual(IMG_DIR+"btn_arrow_right_hover.tga")
  206. historyNext.SetDownVisual(IMG_DIR+"btn_arrow_right_down.tga")
  207. def RunHistoryArgument(self, argument):
  208. if argument.find("NEW") != -1:
  209. argumentList = argument.split("#")
  210. self.ShowItemInfo(int(argumentList[1]), int(argumentList[2]), False)
  211. else:
  212. self.__SelectType(argument, False, False)
  213. def ClickBackHistory(self):
  214. currentIndex = self.children["currentIndex"]
  215. historySearch = self.children["historySearch"]
  216. if currentIndex-1 < 0:
  217. return
  218. currentIndex-=1
  219. self.children["currentIndex"]=currentIndex
  220. self.RunHistoryArgument(historySearch[currentIndex])
  221. self.SetHistoryButtons()
  222. def ClickNextHistory(self):
  223. currentIndex = self.children["currentIndex"]
  224. historySearch = self.children["historySearch"]
  225. if currentIndex+1 >= len(historySearch):
  226. return
  227. currentIndex+=1
  228. self.children["currentIndex"]=currentIndex
  229. self.RunHistoryArgument(historySearch[currentIndex])
  230. self.SetHistoryButtons()
  231. def get_length(self, x):
  232. return len(x[0])
  233. def UpdateItemsList(self):
  234. input_text_real = self.children["searchItemName"].GetText()
  235. input_len = len(input_text_real)
  236. if input_len == 0:
  237. self.ClearEditlineItem()
  238. return False
  239. if localeInfo.IsARABIC():
  240. input_text = input_text_real
  241. else:
  242. input_text = input_text_real.lower()
  243. self.children["searchClearBtn"].Show()
  244. items_list = item.GetItemsByName(str(input_text))
  245. itemList = []
  246. namesList = []
  247. for i, itemVnum in enumerate(items_list, start=1):
  248. (realVnum, isRefineItem) = WikiUI.getRealVnum(itemVnum)
  249. if isRefineItem:
  250. realVnum += wiki.GetRefineMaxLevel(realVnum)
  251. if itemVnum != realVnum:
  252. continue
  253. item.SelectItem(itemVnum)
  254. if localeInfo.IsARABIC():
  255. itemName = item.GetItemName()
  256. else:
  257. itemName = item.GetItemName().lower()
  258. if itemName.find("+") != -1:
  259. itemName = itemName[:itemName.find("+")]
  260. tempName = list(itemName)
  261. for i in xrange(input_len):
  262. tempName[i]=list(input_text_real)[i]
  263. itemName = ""
  264. for x in xrange(len(tempName)):
  265. itemName+=tempName[x]
  266. if itemName in namesList:
  267. continue
  268. namesList.append(itemName)
  269. itemList.append([itemName, realVnum])
  270. if len(itemList) > 0:
  271. if len(itemList) > 1:
  272. itemList = sorted(itemList, key=self.get_length,reverse=False)
  273. self.children["selectedItem"] = itemList[0][1]
  274. self.children["searchItemName"].SetInfoMessage(itemList[0][0])
  275. else:
  276. self.children["selectedItem"] = 0
  277. self.children["searchItemName"].SetInfoMessage("")
  278. return True
  279. def __OnValueUpdateItem(self):
  280. ui.EditLine.OnIMEUpdate(self.children["searchItemName"])
  281. if not self.UpdateItemsList():
  282. self.ClearEditlineItem()
  283. def OnKeyDown(self, key):
  284. if app.DIK_RETURN == key:
  285. if self.children["selectedItem"] > 1:
  286. self.StartSearchItem()
  287. else:
  288. self.StartSearchItem()
  289. return True
  290. return True
  291. def ClearEditlineItem(self):
  292. self.children["selectedItem"]=0
  293. self.children["searchItemName"].SetText("")
  294. self.children["searchItemName"].SetInfoMessage(localeInfo.WIKI_ITEM_NAME)
  295. self.children["searchClearBtn"].Hide()
  296. def StartSearchItem(self):
  297. if self.children["selectedItem"] != 0:
  298. self.ShowItemInfo(self.children["selectedItem"],0)
  299. def UpdateMobsList(self):
  300. input_text_real = self.children["searchMobName"].GetText()
  301. input_len = len(input_text_real)
  302. if input_len == 0:
  303. self.ClearEditlineMob()
  304. return False
  305. if localeInfo.IsARABIC():
  306. input_text = input_text_real
  307. else:
  308. input_text = input_text_real.lower()
  309. self.children["searchClearBtnMob"].Show()
  310. mobs_list = nonplayer.GetMobsByName(str(input_text))
  311. mobList = []
  312. namesList = []
  313. for i, mobVnum in enumerate(mobs_list, start=1):
  314. if localeInfo.IsARABIC():
  315. mob_name = nonplayer.GetMonsterName(mobVnum)
  316. else:
  317. mob_name = nonplayer.GetMonsterName(mobVnum).lower()
  318. tempName = list(mob_name)
  319. for i in xrange(input_len):
  320. tempName[i]=list(input_text_real)[i]
  321. mob_name = ""
  322. for x in xrange(len(tempName)):
  323. mob_name+=tempName[x]
  324. if mob_name in namesList:
  325. continue
  326. namesList.append(mob_name)
  327. mobList.append([mob_name, mobVnum])
  328. if len(mobList) > 0:
  329. if len(mobList) > 1:
  330. mobList = sorted(mobList, key=self.get_length,reverse=False)
  331. self.children["selectedMob"] = mobList[0][1]
  332. self.children["searchMobName"].SetInfoMessage(mobList[0][0])
  333. else:
  334. self.children["selectedMob"] = 0
  335. self.children["searchMobName"].SetInfoMessage("")
  336. return True
  337. def __OnValueUpdateMob(self):
  338. ui.EditLine.OnIMEUpdate(self.children["searchMobName"])
  339. if not self.UpdateMobsList():
  340. self.ClearEditlineMob()
  341. def OnKeyDown(self, key):
  342. if app.DIK_RETURN == key:
  343. if self.children["selectedMob"] > 1:
  344. self.StartSearchMob()
  345. else:
  346. self.StartSearchMob()
  347. return True
  348. return True
  349. def ClearEditlineMob(self):
  350. self.children["selectedMob"]=0
  351. self.children["searchMobName"].SetText("")
  352. self.children["searchMobName"].SetInfoMessage(localeInfo.WIKI_MOB_NAME)
  353. self.children["searchClearBtnMob"].Hide()
  354. def StartSearchMob(self):
  355. if self.children["selectedMob"] != 0:
  356. self.ShowItemInfo(self.children["selectedMob"],1)
  357. def LoadCategoryInfos(self):
  358. categoryText = ui.TextLine()
  359. categoryText.SetParent(self)
  360. categoryText.SetPosition(13,89)
  361. categoryText.SetText(localeInfo.WIKI_CATEGORY)
  362. categoryText.Show()
  363. self.children["categoryText"] = categoryText
  364. scrollBarListBoxCube = WikiUI.ScrollBarNew()
  365. scrollBarListBoxCube.SetParent(self)
  366. scrollBarListBoxCube.SetPosition(109+15,105)
  367. scrollBarListBoxCube.Show()
  368. self.children["scrollBarListBoxCube"] = scrollBarListBoxCube
  369. listBoxCube = WikiUI.CategoryList()
  370. listBoxCube.SetParent(self)
  371. listBoxCube.SetPosition(13,105)
  372. listBoxCube.SetSize(109, 355)
  373. listBoxCube.Show()
  374. listBoxCube.SetScrollBar(scrollBarListBoxCube)
  375. self.children["listBoxCube"] = listBoxCube
  376. scrollBarListBoxCube.SetScrollBarSize(listBoxCube.GetHeight()-5)
  377. self.children["historySearch"] = []
  378. self.children["currentIndex"] = 0
  379. historyBack = ui.Button()
  380. historyBack.SetParent(self)
  381. historyBack.SetUpVisual(IMG_DIR+"btn_arrow_left_normal.tga")
  382. historyBack.SetOverVisual(IMG_DIR+"btn_arrow_left_normal.tga")
  383. historyBack.SetDownVisual(IMG_DIR+"btn_arrow_left_normal.tga")
  384. historyBack.SetPosition(13,105+listBoxCube.GetHeight()-5)
  385. historyBack.SAFE_SetEvent(self.ClickBackHistory)
  386. historyBack.Show()
  387. self.children["historyBack"] = historyBack
  388. historyNext = ui.Button()
  389. historyNext.SetParent(self)
  390. historyNext.SetUpVisual(IMG_DIR+"btn_arrow_right_normal.tga")
  391. historyNext.SetOverVisual(IMG_DIR+"btn_arrow_right_normal.tga")
  392. historyNext.SetDownVisual(IMG_DIR+"btn_arrow_right_normal.tga")
  393. historyNext.SetPosition(13+historyBack.GetWidth()+2,105+listBoxCube.GetHeight()-5)
  394. historyNext.SAFE_SetEvent(self.ClickNextHistory)
  395. historyNext.Show()
  396. self.children["historyNext"] = historyNext
  397. listBoxCubeItems = [
  398. {
  399. 'item' : self.CreateCategoryItem(localeInfo.WIKI_EQUIPMENT, lambda arg = ("Equipment#"): self.__EmptyFunction(arg)),
  400. 'children' : (
  401. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_EQUIPMENT_WEAPONS, lambda arg = ("Equipment#0"): self.__SelectType(arg)),},
  402. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_EQUIPMENT_ARMOR, lambda arg = ("Equipment#1"): self.__SelectType(arg)),},
  403. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_EQUIPMENT_HELMET, lambda arg = ("Equipment#2"): self.__SelectType(arg)),},
  404. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_EQUIPMENT_SHIELD, lambda arg = ("Equipment#3"): self.__SelectType(arg)),},
  405. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_EQUIPMENT_EARRING, lambda arg = ("Equipment#4"): self.__SelectType(arg)),},
  406. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_EQUIPMENT_BRACELET, lambda arg = ("Equipment#5"): self.__SelectType(arg)),},
  407. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_EQUIPMENT_NECKLACE, lambda arg = ("Equipment#6"): self.__SelectType(arg)),},
  408. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_EQUIPMENT_SHOES, lambda arg = ("Equipment#7"): self.__SelectType(arg)),},
  409. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_EQUIPMENT_BELT, lambda arg = ("Equipment#8"): self.__SelectType(arg)),},
  410. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_EQUIPMENT_TALISMAN, lambda arg = ("Equipment#9"): self.__SelectType(arg)),},
  411. # {'item' : self.CreateCategorySubItem(localeInfo.WIKI_EQUIPMENT_RINGS, lambda arg = ("Equipment#10"): self.__SelectType(arg)),},
  412. )
  413. },
  414. {
  415. 'item' : self.CreateCategoryItem(localeInfo.WIKI_COSTUMES, lambda arg = ("Costume#"): self.__EmptyFunction(arg)),
  416. 'children' : (
  417. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_WEAPON_SKIN, lambda arg = ("Costume#0"): self.__SelectType(arg)),},
  418. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_BODY_COSTUME, lambda arg = ("Costume#1"): self.__SelectType(arg)),},
  419. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_HAIR_COSTUME, lambda arg = ("Costume#2"): self.__SelectType(arg)),},
  420. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_SASH_COSTUME, lambda arg = ("Costume#3"): self.__SelectType(arg)),},
  421. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_SHINING, lambda arg = ("Costume#4"): self.__SelectType(arg)),},
  422. )
  423. },
  424. {
  425. 'item' : self.CreateCategoryItem(localeInfo.WIKI_MOUNT, lambda arg = ("Mount#"): self.__EmptyFunction(arg)),
  426. 'children' : (
  427. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_MOUNT_ITEM, lambda arg = ("Mount#5"): self.__SelectType(arg)),},
  428. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_PET_ITEM, lambda arg = ("Mount#6"): self.__SelectType(arg)),},
  429. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_PET_LEVEABLE_ITEM, lambda arg = ("Mount#7"): self.__SelectType(arg)),},
  430. )
  431. },
  432. {
  433. 'item' : self.CreateCategoryItem(localeInfo.WIKI_CHESTS, lambda arg = ("Chests#"): self.__EmptyFunction(arg)),
  434. 'children' : (
  435. # {'item' : self.CreateCategorySubItem(localeInfo.WIKI_CHESTS_BOSS, lambda arg = ("Chests#0"): self.__SelectType(arg)),},
  436. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_CHESTS_DUNGEON, lambda arg = ("Chests#1"): self.__SelectType(arg))},
  437. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_CHESTS_OTHER, lambda arg = ("Chests#2"): self.__SelectType(arg))},
  438. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_CHESTS_EVENT, lambda arg = ("Chests#3"): self.__SelectType(arg))},
  439. )
  440. },
  441. {
  442. 'item' : self.CreateCategoryItem(localeInfo.WIKI_BOSSES, lambda arg = ("Bosses#"): self.__EmptyFunction(arg)),
  443. 'children' : (
  444. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_1_75, lambda arg = ("Bosses#0"): self.__SelectType(arg)),},
  445. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_76_100, lambda arg = ("Bosses#1"): self.__SelectType(arg)),},
  446. )
  447. },
  448. # {
  449. # 'item' : self.CreateCategoryItem(localeInfo.WIKI_MONSTER, lambda arg = ("Monster#"): self.__EmptyFunction(arg)),
  450. # 'children' : (
  451. # {'item' : self.CreateCategorySubItem(localeInfo.WIKI_1_75, lambda arg = ("Monster#0"): self.__SelectType(arg)),},
  452. # {'item' : self.CreateCategorySubItem(localeInfo.WIKI_76_100, lambda arg = ("Monster#1"): self.__SelectType(arg)),},
  453. # )
  454. # },
  455. {
  456. 'item' : self.CreateCategoryItem(localeInfo.WIKI_METINSTONE, lambda arg = ("Metinstone#"): self.__EmptyFunction(arg)),
  457. 'children' : (
  458. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_1_75, lambda arg = ("Metinstone#0"): self.__SelectType(arg)),},
  459. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_76_100, lambda arg = ("Metinstone#1"): self.__SelectType(arg)),},
  460. )
  461. },
  462. {
  463. 'item' : self.CreateCategoryItem(localeInfo.WIKI_SYSTEM2, lambda arg = ("System#"): self.__EmptyFunction(arg)),
  464. 'children' : (
  465. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_COSTUME, lambda arg = ("System#2"): self.__SelectType(arg)),},
  466. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_PETS, lambda arg = ("System#4"): self.__SelectType(arg)),},
  467. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_BIOLOGO, lambda arg = ("System#5"): self.__SelectType(arg)),},
  468. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_ALCHEMY, lambda arg = ("System#7"): self.__SelectType(arg)),},
  469. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_EVENTS, lambda arg = ("System#8"): self.__SelectType(arg)),},
  470. )
  471. },
  472. {
  473. 'item' : self.CreateCategoryItem(localeInfo.WIKI_GUIDES, lambda arg = ("System#"): self.__EmptyFunction(arg)),
  474. 'children' : (
  475. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_BASIC, lambda arg = ("System#0"): self.__SelectType(arg)),},
  476. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_ATTR_RARE, lambda arg = ("System#1"): self.__SelectType(arg)),},
  477. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_BASIC_DROP, lambda arg = ("System#3"): self.__SelectType(arg)),},
  478. )
  479. },
  480. {
  481. 'item' : self.CreateCategoryItem(localeInfo.WIKI_GAMERULES, lambda arg = ("System#"): self.__EmptyFunction(arg)),
  482. 'children' : (
  483. {'item' : self.CreateCategorySubItem(localeInfo.WIKI_GAME_RULES, lambda arg = ("System#6"): self.__SelectType(arg)),},
  484. )
  485. },
  486. ]
  487. self.children["listBoxCube"].AppendItemList(listBoxCubeItems)
  488. def __EmptyFunction(self, arg):
  489. pass
  490. def LoadData(self, arg):
  491. self.__SelectType(arg)
  492. def __SelectCharacters(self, buttonIndex):
  493. for j in xrange(4):
  494. if self.children["characterIndex"] == buttonIndex:
  495. self.children["job_%d_characterBtn"%j].Down()
  496. else:
  497. self.children["job_%d_characterBtn"%j].SetUp()
  498. self.children["characterIndex"]=buttonIndex
  499. self.__SelectType(self.selectArg, True)
  500. def __ClickRadioButton(self, buttonList, buttonIndex):
  501. try:
  502. btn=buttonList[buttonIndex]
  503. except IndexError:
  504. return
  505. for eachButton in buttonList:
  506. eachButton.SetUp()
  507. btn.Down()
  508. def SetCharacterImagesStatus(self, flag):
  509. for j in xrange(4):
  510. if not flag:
  511. self.children["job_%d_characterBtn"%j].Hide()
  512. else:
  513. self.children["job_%d_characterBtn"%j].Show()
  514. if self.children["characterIndex"] == j:
  515. self.children["job_%d_characterBtn"%j].Down()
  516. else:
  517. self.children["job_%d_characterBtn"%j].SetUp()
  518. def ClearResultListbox(self, argList, isSpecial = False):
  519. self.AIAppendAlgoritm = None
  520. try:
  521. resultpageListbox = self.children["resultpageListbox"]
  522. resultpageListboxScrollbar = self.children["resultpageListboxScrollbar"]
  523. resultpageListbox.RemoveAllItems()
  524. resultpageListbox.Show()
  525. resultpageListboxScrollbar.Hide()
  526. if len(argList) == 0 or argList[0] == "":
  527. return
  528. imageFile = WikiUI.GetResultPageImage(argList)
  529. if imageFile:
  530. self.children["resultpagebtn"].LoadImage(imageFile)
  531. self.children["resultpagebtn"].Show()
  532. if argList[0] == "Equipment" and isSpecial == False:
  533. self.SetCharacterImagesStatus(True)
  534. resultpageListbox.SetPosition(155, 160)
  535. resultpageListbox.SetSize(540, 318)
  536. resultpageListboxScrollbar.SetPosition(699, 160)
  537. resultpageListboxScrollbar.SetScrollBarSize(resultpageListbox.GetHeight()-20)
  538. else:
  539. self.SetCharacterImagesStatus(False)
  540. resultpageListbox.SetPosition(158,109)
  541. resultpageListbox.SetSize(540, 360)
  542. resultpageListboxScrollbar.SetPosition(699, 109)
  543. resultpageListboxScrollbar.SetScrollBarSize(350)
  544. except:
  545. pass
  546. def __SelectType(self, arg, isCharacterBtn = False, isHistory = True):
  547. #try:
  548. if isCharacterBtn == False and self.selectArg == arg:
  549. return
  550. if isHistory:
  551. historySearch = self.children["historySearch"]
  552. historySearch.append(arg)
  553. self.children["currentIndex"] = len(historySearch)-1
  554. self.SetHistoryButtons()
  555. self.selectArg = arg
  556. argList = arg.split("#")
  557. self.ClearResultListbox(argList)
  558. AIAppendAlgoritm = WikiUI.AutoLoad()
  559. AIAppendAlgoritm.SetFlag("loadTime", AUTOLOAD_SPEED)
  560. if argList[0] == "Equipment":
  561. maxSize = wiki.GetCategorySize(self.children["characterIndex"],int(argList[1]))
  562. if maxSize == 0:
  563. return
  564. AIAppendAlgoritm.SetFlag("maxSize", maxSize-1)
  565. AIAppendAlgoritm.SetFlag("loadType","Equipment")
  566. AIAppendAlgoritm.SetFlag("characterIndex",self.children["characterIndex"])
  567. AIAppendAlgoritm.SetFlag("itemType",int(argList[1]))
  568. elif argList[0] == "Costume" or argList[0] == "Mount":
  569. maxSize = wiki.GetCostumeSize(int(argList[1]))
  570. if maxSize == 0:
  571. return
  572. AIAppendAlgoritm.SetFlag("maxSize", maxSize-1)
  573. AIAppendAlgoritm.SetFlag("loadType","Costume")
  574. AIAppendAlgoritm.SetFlag("itemType",int(argList[1]))
  575. elif argList[0] == "Chests":
  576. maxSize = wiki.GetChestSize(int(argList[1]))
  577. if maxSize == 0:
  578. return
  579. AIAppendAlgoritm.SetFlag("maxSize", maxSize-1)
  580. AIAppendAlgoritm.SetFlag("loadType","Chests")
  581. AIAppendAlgoritm.SetFlag("itemType",int(argList[1]))
  582. elif argList[0] == "Bosses":
  583. maxSize = wiki.GetBossSize(int(argList[1]))
  584. if maxSize == 0:
  585. return
  586. AIAppendAlgoritm.SetFlag("maxSize", maxSize-1)
  587. AIAppendAlgoritm.SetFlag("loadType","Bosses")
  588. AIAppendAlgoritm.SetFlag("itemType",int(argList[1]))
  589. AIAppendAlgoritm.SetFlag("loadTime", AUTOLOAD_MONSTER_SPEED)
  590. elif argList[0] == "Monster":
  591. maxSize = wiki.GetMonsterSize(int(argList[1]))
  592. if maxSize == 0:
  593. return
  594. AIAppendAlgoritm.SetFlag("maxSize", maxSize-1)
  595. AIAppendAlgoritm.SetFlag("loadType","Monster")
  596. AIAppendAlgoritm.SetFlag("itemType",int(argList[1]))
  597. AIAppendAlgoritm.SetFlag("loadTime", AUTOLOAD_MONSTER_SPEED)
  598. elif argList[0] == "Metinstone":
  599. maxSize = wiki.GetStoneSize(int(argList[1]))
  600. if maxSize == 0:
  601. return
  602. AIAppendAlgoritm.SetFlag("maxSize", maxSize-1)
  603. AIAppendAlgoritm.SetFlag("loadType","Metinstone")
  604. AIAppendAlgoritm.SetFlag("itemType",int(argList[1]))
  605. elif WikiUI.IsArticleCategory(argList):
  606. if len(argList) == 3:
  607. event_item = ArticleGUI(argList[1]+"#"+argList[2])
  608. else:
  609. event_item = ArticleGUI(int(argList[1]))
  610. self.children["resultpageListbox"].AppendItem(event_item)
  611. event_item.LoadItemInfos()
  612. self.children["resultpageListboxScrollbar"].Hide()
  613. return
  614. if AIAppendAlgoritm.GetFlag("loadTime") != 0:
  615. self.AIAppendAlgoritm = AIAppendAlgoritm
  616. #except:
  617. # dbg.TraceError("Saving crash from __SelectType")
  618. def ShowItemInfo(self, vnum, arg, isHistory = True):
  619. #try:
  620. if isHistory:
  621. historySearch = self.children["historySearch"]
  622. historySearch.append("NEW#%d#%d"%(vnum, arg))
  623. self.children["currentIndex"] = len(historySearch)-1
  624. self.SetHistoryButtons()
  625. if arg == 3:
  626. self.__SelectType(vnum)
  627. elif arg == 0:
  628. self.selectArg = "Equipment#0"
  629. self.ClearResultListbox(self.selectArg.split("#"), True)
  630. self.children["resultpageListboxScrollbar"].Hide()
  631. (vnum, isRefineItem) = WikiUI.getRealVnum(vnum)
  632. if isRefineItem:
  633. vnum += wiki.GetRefineMaxLevel(vnum)
  634. resultpageListbox = self.children["resultpageListbox"]
  635. if isRefineItem:
  636. new_refine_table = EquipmentItem(99, vnum)
  637. new_refine_table.LoadItemInfos()
  638. resultpageListbox.AppendItem(new_refine_table)
  639. item.SelectItem(vnum)
  640. if item.GetItemType() == item.ITEM_TYPE_GIFTBOX:
  641. item_table = MonsterItemSpecial(vnum, 3)
  642. item_table.LoadItemInfos()
  643. resultpageListbox.AppendItem(item_table)
  644. monster_statics = MonsterStatics(vnum, 3)
  645. monster_statics.LoadItemInfos()
  646. resultpageListbox.AppendItem(monster_statics)
  647. else:
  648. item_table = MonsterItemSpecial(vnum, 1)
  649. item_table.LoadItemInfos()
  650. resultpageListbox.AppendItem(item_table)
  651. resultpageListbox.Render(0)
  652. self.children["resultpageListboxScrollbar"].Hide()
  653. self.selectArg=""
  654. elif arg == 1:
  655. self.selectArg = "Monster#0"
  656. self.ClearResultListbox(self.selectArg.split("#"), True)
  657. self.children["resultpageListboxScrollbar"].Show()
  658. resultpageListbox = self.children["resultpageListbox"]
  659. monster_table = MonsterItemSpecial(vnum, 0)
  660. monster_table.LoadItemInfos()
  661. resultpageListbox.AppendItem(monster_table)
  662. monster_statics = MonsterStatics(vnum, 0)
  663. monster_statics.LoadItemInfos()
  664. resultpageListbox.AppendItem(monster_statics)
  665. resultpageListbox.Render(0)
  666. self.selectArg=""
  667. #except:
  668. # dbg.TraceError("Saving crash from ShowItemInfo")
  669. def OnUpdate(self):
  670. self.CheckLoadProcess()
  671. def SetTimeForHide(self, isOpen):
  672. __ai = self.AIAppendAlgoritm
  673. if __ai != None:
  674. if isOpen:
  675. __ai.SetFlag("nexTime",app.GetTime()+0.15)
  676. else:
  677. __ai.SetFlag("nexTime",app.GetTime()+999999)
  678. def CheckLoadProcess(self):
  679. #try:
  680. __ai = self.AIAppendAlgoritm
  681. if __ai != None:
  682. if __ai.GetFlag("nexTime") > app.GetTime():
  683. return
  684. __ai.SetFlag("nexTime", app.GetTime()+__ai.GetFlag("loadTime"))
  685. loadType = __ai.GetFlag("loadType")
  686. listIndex = __ai.GetFlag("maxSize")
  687. if loadType == "Equipment":
  688. equipItemPointer = EquipmentItem(listIndex, wiki.GetCategoryData(__ai.GetFlag("characterIndex"), __ai.GetFlag("itemType"), listIndex))
  689. equipItemPointer.LoadItemInfos()
  690. equipItemPointer.sortIndex = listIndex
  691. self.children["resultpageListbox"].AppendItem(equipItemPointer, False)
  692. elif loadType == "Costume":
  693. createNewWindow = True
  694. ListBoxItems = self.children["resultpageListbox"].itemList
  695. if len(ListBoxItems) > 0:
  696. lastItem = ListBoxItems[len(ListBoxItems)-1]
  697. if lastItem.CanAddNewItem():
  698. lastItem.LoadItemInfos(wiki.GetCostumeData(__ai.GetFlag("itemType"), listIndex))
  699. createNewWindow = False
  700. if createNewWindow:
  701. equipItemPointer = SpecialClass(listIndex, 0)
  702. equipItemPointer.LoadItemInfos(wiki.GetCostumeData(__ai.GetFlag("itemType"), listIndex))
  703. equipItemPointer.sortIndex = listIndex
  704. self.children["resultpageListbox"].AppendItem(equipItemPointer, False)
  705. elif loadType == "Chests":
  706. (itemVnum, bossVnum) = wiki.GetChestData(__ai.GetFlag("itemType"), listIndex)
  707. if itemVnum == 0:
  708. return
  709. equipItemPointer = ListBoxItemSpecial(listIndex, itemVnum, bossVnum, 0)
  710. equipItemPointer.LoadItemInfos()
  711. equipItemPointer.sortIndex = listIndex
  712. self.children["resultpageListbox"].AppendItem(equipItemPointer, False)
  713. elif loadType == "Monster":
  714. mobVnum = wiki.GetMonsterData(__ai.GetFlag("itemType"), listIndex)
  715. if mobVnum == 0:
  716. return
  717. equipItemPointer = ListBoxItemSpecial(listIndex, mobVnum, 0, 1)
  718. equipItemPointer.LoadItemInfos()
  719. equipItemPointer.sortIndex = listIndex
  720. self.children["resultpageListbox"].AppendItem(equipItemPointer, False)
  721. elif loadType == "Bosses":
  722. mobVnum = wiki.GetBossData(__ai.GetFlag("itemType"), listIndex)
  723. if mobVnum == 0:
  724. return
  725. equipItemPointer = ListBoxItemSpecial(listIndex, mobVnum, 0, 1)
  726. equipItemPointer.LoadItemInfos()
  727. equipItemPointer.sortIndex = listIndex
  728. self.children["resultpageListbox"].AppendItem(equipItemPointer, False)
  729. elif loadType == "Metinstone":
  730. mobVnum = wiki.GetStoneData(__ai.GetFlag("itemType"), listIndex)
  731. if mobVnum == 0:
  732. return
  733. equipItemPointer = ListBoxItemSpecial(listIndex, mobVnum, 0, 1)
  734. equipItemPointer.LoadItemInfos()
  735. equipItemPointer.sortIndex = listIndex
  736. self.children["resultpageListbox"].AppendItem(equipItemPointer, False)
  737. self.SetPositionToSort(self.children["resultpageListbox"], loadType)
  738. __ai.SetFlag("maxSize", listIndex-1)
  739. if listIndex-1 < 0:
  740. self.AIAppendAlgoritm = None
  741. self.children["resultpageListbox"].CalculateScroll()
  742. #except:
  743. # dbg.TraceError("Saving crash from OnUpdate")
  744. def get_key(self, data):
  745. return data.sortIndex
  746. def SetPositionToSort(self, listBox, loadType):
  747. itemList = listBox.itemList
  748. if len(itemList) > 1:
  749. if loadType == "Costume":
  750. itemList = sorted(itemList, key=self.get_key,reverse=True)
  751. else:
  752. itemList = sorted(itemList, key=self.get_key,reverse=SHOW_ITEM_LOWER_TO_BIG)
  753. y = 0
  754. for child in itemList:
  755. child.Hide()
  756. child.SetPosition(0, y, True)
  757. child.OnRender()
  758. child.Show()
  759. y+=child.GetHeight()
  760. def CreateCategoryItem(self, text, event, offset = 0):
  761. listboxItem = WikiUI.CategoryItem(text)
  762. listboxItem.SetVisible(True)
  763. listboxItem.SetEvent(event)
  764. listboxItem.SetOffset(offset)
  765. return listboxItem
  766. def CreateCategorySubItem(self, text, event, offset = 0):
  767. listboxItem = WikiUI.CategorySubItem(text)
  768. listboxItem.SetEvent(event)
  769. listboxItem.SetOffset(offset)
  770. return listboxItem
  771. def SetRenderTargetsStatus(self, bShowStatus):
  772. if self.children.has_key("resultpageListbox"):
  773. resultpageListbox = self.children["resultpageListbox"].itemList
  774. for child in resultpageListbox:
  775. if child.renderIndex != -1:
  776. renderTarget.SetVisibility(child.renderIndex, bShowStatus)
  777. def Open(self):
  778. self.SetRenderTargetsStatus(True)
  779. self.Show()
  780. self.SetTimeForHide(True)
  781. def Close(self):
  782. self.SetRenderTargetsStatus(False)
  783. self.SetTimeForHide(False)
  784. self.children["searchMobName"].KillFocus()
  785. self.children["searchItemName"].KillFocus()
  786. self.Hide()
  787. def OnPressExitKey(self):
  788. self.Close()
  789. return TRUE
  790. def OnPressEscapeKey(self):
  791. self.Close()
  792. return TRUE
  793. class EquipmentItem(WikiUI.DefaultWikiImage):
  794. class RefineItem(WikiUI.DefaultWikiWindow):
  795. def __del__(self):
  796. WikiUI.DefaultWikiWindow.__del__(self)
  797. def __init__(self):
  798. WikiUI.DefaultWikiWindow.__init__(self)
  799. def LoadData(self, refine, itemVnum, refineCount, refineData):
  800. tooltipImage = ui.ImageBox()
  801. tooltipImage.SetParent(self)
  802. tooltipImage.SetPosition(0,0)
  803. tooltipImage.SetSize(41, 19)
  804. tooltipImage.SAFE_SetStringEvent("MOUSE_OVER_IN",self.OverInItem,(itemVnum-wiki.GetRefineMaxLevel(itemVnum))+refine)
  805. tooltipImage.SAFE_SetStringEvent("MOUSE_OVER_OUT",self.OverOutItem)
  806. tooltipImage.Show()
  807. self.children.append(tooltipImage)
  808. step_refine = ui.TextLine()
  809. step_refine.SetParent(self)
  810. step_refine.SetText("+%d"%refine)
  811. step_refine.SetHorizontalAlignCenter()
  812. step_refine.SetPosition(21,5)
  813. step_refine.Show()
  814. self.children.append(step_refine)
  815. step_price = ui.TextLine()
  816. step_price.SetParent(self)
  817. if SHOW_NEXT_ITEM_REFINE:
  818. step_price.SetText(localeInfo.MoneyFormat(refineData["cost"]).replace(".000","k"))
  819. else:
  820. if refine:
  821. step_price.SetText(localeInfo.MoneyFormat(refineData["cost"]).replace(".000","k"))
  822. else:
  823. step_price.SetText("-")
  824. step_price.SetHorizontalAlignCenter()
  825. priceYPos = [140, 140, 140, 180, 230, 275]
  826. step_price.SetPosition(21, priceYPos[refineCount]-21)
  827. step_price.Show()
  828. self.children.append(step_price)
  829. for i in xrange(refineCount):
  830. refineItem = refineData["item_vnum_%d"%i]
  831. needInsertIcon = refineItem != 0
  832. if needInsertIcon == True and SHOW_NEXT_ITEM_REFINE == False and refine == 0:
  833. needInsertIcon = False
  834. if needInsertIcon:
  835. item.SelectItem(refineItem)
  836. refineItemIcon = ui.ExpandedImageBox()
  837. refineItemIcon.SetParent(self)
  838. refineItemIcon.LoadImage(item.GetIconImageFileName())
  839. refineItemIcon.SAFE_SetStringEvent("MOUSE_OVER_IN",self.OverInItem,refineItem)
  840. refineItemIcon.SAFE_SetStringEvent("MOUSE_OVER_OUT",self.OverOutItem)
  841. refineItemIcon.SetEvent(ui.__mem_func__(self.OnClickItem),"mouse_click",0,refineItem)
  842. refineItemIcon.SetPosition(5,20+5+(i*(32+5+10)))
  843. refineItemIcon.Show()
  844. self.children.append(refineItemIcon)
  845. if refineData["item_count_%d"%i] > 0:
  846. if USE_ITEM_COUNT_NUMBER_LINE:
  847. refineItemCount = ui.NumberLine()
  848. refineItemCount.SetParent(self)
  849. refineItemCount.SetNumber(str(refineData["item_count_%d"%i]))
  850. refineItemCount.SetPosition(5+28,20+5+(i*(32+5+10))+32)
  851. else:
  852. refineItemCount = ui.TextLine()
  853. refineItemCount.SetParent(self)
  854. refineItemCount.SetText(str(refineData["item_count_%d"%i]))
  855. refineItemCount.SetPosition(5+28,20+5+(i*(32+5+10))+20)
  856. refineItemCount.Show()
  857. self.children.append(refineItemCount)
  858. else:
  859. emptyRefine = ui.TextLine()
  860. emptyRefine.SetParent(self)
  861. emptyRefine.AddFlag("not_pick")
  862. emptyRefine.SetPosition(self.GetWidth()/2,21+18+(i*44))
  863. emptyRefine.SetText("-")
  864. emptyRefine.Show()
  865. self.children.append(emptyRefine)
  866. def __del__(self):
  867. WikiUI.DefaultWikiImage.__del__(self)
  868. def Destroy(self):
  869. self.refineItems = []
  870. self.listIndex = 0
  871. self.itemVnum = 0
  872. self.refineCount = 0
  873. WikiUI.DefaultWikiImage.Destroy(self)
  874. def __init__(self, listIndex, itemVnum):
  875. WikiUI.DefaultWikiImage.__init__(self)
  876. self.Destroy()
  877. self.listIndex = listIndex
  878. self.itemVnum = itemVnum
  879. self.refineCount = 2
  880. self.refineLevel = wiki.GetRefineMaxLevel(itemVnum)
  881. for j in xrange(self.refineLevel+1):
  882. if item.SelectItemWiki((self.itemVnum-self.refineLevel)+j) == 1:
  883. argv = wiki.GetRefineItems(item.GetRefineSet())
  884. if argv != 0:
  885. self.InsertRefine(*argv)
  886. continue
  887. self.InsertRefine(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
  888. self.LoadImage(IMG_DIR+"slot/slot_%d.tga"%self.refineCount)
  889. self.children.append(self)
  890. # add scrollbar extra height!
  891. if self.refineLevel >= 11:
  892. self.SetSize(self.GetWidth(),self.GetHeight()+20)
  893. def LoadItemInfos(self):
  894. if self.IsLoaded == False:
  895. self.IsLoaded=True
  896. item.SelectItem(self.itemVnum-self.refineLevel)
  897. (firstLevel, secondLevel) = (0, 0)
  898. for i in xrange(item.LIMIT_MAX_NUM):
  899. (limitType, limitValue) = item.GetLimit(i)
  900. if item.LIMIT_LEVEL == limitType:
  901. if limitValue != 0:
  902. firstLevel=limitValue
  903. break
  904. item.SelectItem(self.itemVnum)
  905. for i in xrange(item.LIMIT_MAX_NUM):
  906. (limitType, limitValue) = item.GetLimit(i)
  907. if item.LIMIT_LEVEL == limitType:
  908. if limitValue != 0:
  909. secondLevel=limitValue
  910. break
  911. itemName = ui.TextLine()
  912. itemName.SetParent(self)
  913. item_name = item.GetItemName()
  914. if item_name.find("+") != -1:
  915. item_name = item_name[:item_name.find("+")]
  916. itemName.SetText(item_name)
  917. itemName.SetPosition(5, 5)
  918. itemName.Show()
  919. self.children.append(itemName)
  920. itemLevel = ui.TextLine()
  921. itemLevel.SetParent(self)
  922. if secondLevel != firstLevel:
  923. itemLevel.SetText(localeInfo.WIKI_LEVEL_TEXT2%(firstLevel,secondLevel,0,self.refineLevel))
  924. else:
  925. itemLevel.SetText(localeInfo.WIKI_LEVEL_TEXT%(firstLevel,0,self.refineLevel))
  926. itemLevel.SetPosition(355,5)
  927. itemLevel.Show()
  928. self.children.append(itemLevel)
  929. itemIcon = ui.ExpandedImageBox()
  930. itemIcon.SetParent(self)
  931. if item.GetIconImageFileName().find("gr2") == -1:
  932. itemIcon.LoadImage(item.GetIconImageFileName())
  933. else:
  934. itemIcon.LoadImage("icon/item/27995.tga")
  935. itemLevelCoordinates = [ [0,0],[0,0],[10,55],[10,70],[10,80],[10,115]]
  936. itemIcon.SetPosition(itemLevelCoordinates[self.refineCount][0],itemLevelCoordinates[self.refineCount][1])
  937. if self.listIndex == 99:
  938. itemIcon.SAFE_SetStringEvent("MOUSE_OVER_IN",self.OverInItem,self.itemVnum-self.refineLevel)
  939. else:
  940. itemIcon.SAFE_SetStringEvent("MOUSE_OVER_IN",self.OverInItem,self.itemVnum)
  941. itemIcon.SetEvent(ui.__mem_func__(self.OnClickItem),"mouse_click", 0)
  942. itemIcon.SAFE_SetStringEvent("MOUSE_OVER_OUT",self.OverOutItem)
  943. itemIcon.Show()
  944. self.children.append(itemIcon)
  945. upgradeItem = ui.TextLine()
  946. upgradeItem.SetParent(self)
  947. upgradeItem.SetText(localeInfo.WIKI_UPGRADE_COSTS)
  948. upgradeItem.SetPosition(50,24)
  949. upgradeItem.Show()
  950. self.children.append(upgradeItem)
  951. yangCost = ui.TextLine()
  952. yangCost.SetParent(self)
  953. yangCost.SetText(localeInfo.WIKI_YANG_COSTS)
  954. list = [140, 140, 140, 180, 230, 275]
  955. yangCost.SetPosition(58,list[self.refineCount])
  956. yangCost.Show()
  957. self.children.append(yangCost)
  958. listboxSizes = [ [0,0],[0,0],[411,136],[411,180],[411,228],[411,276]]
  959. refinedVnum = item.GetRefinedVnum()
  960. if refinedVnum != 0:
  961. item.SelectItem(refinedVnum)
  962. nextItemIcon = ui.ExpandedImageBox()
  963. nextItemIcon.SetParent(self)
  964. if item.GetIconImageFileName().find("gr2") == -1:
  965. nextItemIcon.LoadImage(item.GetIconImageFileName())
  966. else:
  967. nextItemIcon.LoadImage("icon/item/27995.tga")
  968. nextItemIcon.SetPosition(75,itemLevelCoordinates[self.refineCount][1])
  969. nextItemIcon.SAFE_SetStringEvent("MOUSE_OVER_IN",self.OverInItem,refinedVnum)
  970. nextItemIcon.SAFE_SetStringEvent("MOUSE_OVER_OUT",self.OverOutItem)
  971. nextItemIcon.SetEvent(ui.__mem_func__(self.OnClickItem),"mouse_click",refinedVnum)
  972. nextItemIcon.Show()
  973. self.children.append(nextItemIcon)
  974. Listbox = WikiUI.ListBoxEx(True)
  975. Listbox.SetParent(self)
  976. Listbox.SetSize(listboxSizes[self.refineCount][0],listboxSizes[self.refineCount][1])
  977. Listbox.SetPosition(130,20)
  978. Listbox.SetItemStep(41)
  979. Listbox.SetItemSize(41,listboxSizes[self.refineCount][1])
  980. Listbox.SetViewItemCount(10)
  981. Listbox.SetOnMouseWhell(False)
  982. if self.refineLevel >= 11:
  983. scrollheightpos = [ 156, 156, 156, 200, 255, 296]
  984. scrollbar = WikiUI.HorizontalScrollBarNew()
  985. scrollbar.SetParent(self)
  986. scrollbar.SetPosition(0, scrollheightpos[self.refineCount])
  987. scrollbar.SetScrollBarSize(540)
  988. #scrollbar.SetScrollBarSize(10.0/float(self.refineLevel))
  989. scrollbar.itsNeedDoubleRender = True
  990. scrollbar.Show()
  991. Listbox.SetScrollBar(scrollbar)
  992. self.children.append(scrollbar)
  993. for i in xrange(self.refineLevel+1):
  994. refine_data = self.RefineItem()
  995. Listbox.AppendItem(refine_data)
  996. if SHOW_NEXT_ITEM_REFINE:
  997. refine_data.LoadData(i, self.itemVnum, self.refineCount, self.refineItems[i])
  998. else:
  999. if i == 0:
  1000. refine_data.LoadData(i, self.itemVnum, self.refineCount, self.refineItems[i])
  1001. else:
  1002. refine_data.LoadData(i, self.itemVnum, self.refineCount, self.refineItems[i-1])
  1003. Listbox.SetBasePos(0)
  1004. Listbox.Show()
  1005. self.Listbox = Listbox
  1006. self.OnRender()
  1007. self.Show()
  1008. def OnClickItem(self, arg, vnum = 0):
  1009. self.OverOutItem()
  1010. parent = constInfo.GetMainParent()
  1011. if parent != None:
  1012. if vnum != 0:
  1013. parent.ShowItemInfo(vnum+wiki.GetRefineMaxLevel(vnum),0)
  1014. else:
  1015. parent.ShowItemInfo(self.itemVnum,0)
  1016. def InsertRefine(self, id,item_vnum_0,item_count_0,item_vnum_1,item_count_1,item_vnum_2,item_count_2,item_vnum_3,item_count_3,item_vnum_4,item_count_4,cost,prob,refine_count):
  1017. self.refineItems.append(\
  1018. {
  1019. "id" : int(id),\
  1020. "item_vnum_0" : int(item_vnum_0),\
  1021. "item_count_0" : int(item_count_0),\
  1022. "item_vnum_1" : int(item_vnum_1),\
  1023. "item_count_1" : int(item_count_1),\
  1024. "item_vnum_2" : int(item_vnum_2),\
  1025. "item_count_2" : int(item_count_2),\
  1026. "item_vnum_3" : int(item_vnum_3),\
  1027. "item_count_3" : int(item_count_3),\
  1028. "item_vnum_4" : int(item_vnum_4),\
  1029. "item_count_4" : int(item_count_4),\
  1030. "cost" : long(cost),\
  1031. "prob" : long(prob),\
  1032. "refine_count" : int(refine_count),\
  1033. },
  1034. )
  1035. if refine_count > self.refineCount:
  1036. self.refineCount = refine_count
  1037. class MonsterItemSpecial(WikiUI.DefaultWikiImage):
  1038. def __del__(self):
  1039. WikiUI.DefaultWikiImage.__del__(self)
  1040. def Destroy(self):
  1041. self.vnum = 0
  1042. renderTarget.SetVisibility(self.renderIndex, False)
  1043. renderTarget.ResetModel(self.renderIndex)
  1044. WikiUI.DefaultWikiImage.Destroy(self)
  1045. def __init__(self, vnum, type):
  1046. WikiUI.DefaultWikiImage.__init__(self)
  1047. self.vnum = vnum
  1048. self.isType = type
  1049. self.LoadImage(IMG_DIR+"slot/special_slot.tga")
  1050. self.children.append(self)
  1051. def LoadItemInfos(self):
  1052. if self.IsLoaded == False:
  1053. self.IsLoaded=True
  1054. #self.renderIndex = app.GetRandom(900, 1000)
  1055. self.renderIndex = renderTarget.GetFreeIndex(1000, 1000000)
  1056. Listbox = None
  1057. if self.isType == 0 or self.isType == 3:
  1058. if self.isType == 0:
  1059. renterTarget = ui.RenderTarget()
  1060. renterTarget.SetParent(self)
  1061. renterTarget.SetPosition(1,1)
  1062. renterTarget.SetSize(187,163)
  1063. renterTarget.SetRenderTarget(self.renderIndex)
  1064. renterTarget.Show()
  1065. self.children.append(renterTarget)
  1066. renderTarget.SelectModel(self.renderIndex, self.vnum)
  1067. renderTarget.SetVisibility(self.renderIndex, True)
  1068. elif self.isType == 3:
  1069. item.SelectItem(self.vnum)
  1070. itemIcon = ui.ExpandedImageBox()
  1071. itemIcon.SetParent(self)
  1072. if item.GetIconImageFileName().find("gr2") == -1:
  1073. itemIcon.LoadImage(item.GetIconImageFileName())
  1074. else:
  1075. itemIcon.LoadImage("icon/item/27995.tga")
  1076. itemIcon.SetPosition(70,45)
  1077. itemIcon.SAFE_SetStringEvent("MOUSE_OVER_IN",self.OverInItem,self.vnum)
  1078. itemIcon.SAFE_SetStringEvent("MOUSE_OVER_OUT",self.OverOutItem)
  1079. itemIcon.Show()
  1080. self.children.append(itemIcon)
  1081. Listbox = WikiUI.ListBoxGrid()
  1082. Listbox.SetParent(self)
  1083. Listbox.SetPosition(190, 25)
  1084. Listbox.SetSize(350, 138)
  1085. Listbox.AddRenderEvent(self.OnRender)
  1086. dropList = ui.TextLine()
  1087. dropList.SetParent(self)
  1088. if self.isType == 0:
  1089. dropList.SetText(localeInfo.WIKI_DROPLIST_INFO%nonplayer.GetMonsterName(self.vnum))
  1090. elif self.isType == 3:
  1091. dropList.SetText(localeInfo.WIKI_CONTENT_INFO%item.GetItemName())
  1092. dropList.SetPosition(300,6)
  1093. dropList.Show()
  1094. self.children.append(dropList)
  1095. monsterInfo = ui.TextLine()
  1096. monsterInfo.SetParent(self)
  1097. if self.isType == 0:
  1098. monsterInfo.SetText(localeInfo.WIKI_STATICS_INFO%nonplayer.GetMonsterName(self.vnum))
  1099. elif self.isType == 3:
  1100. monsterInfo.SetText(localeInfo.WIKI_AVAIBLE_AT)
  1101. monsterInfo.SetHorizontalAlignCenter()
  1102. monsterInfo.SetPosition(245,170)
  1103. monsterInfo.Show()
  1104. self.children.append(monsterInfo)
  1105. if self.isType == 0:
  1106. sizeFunc = wiki.GetMobInfoSize
  1107. getFunc = wiki.GetMobInfoData
  1108. elif self.isType == 3:
  1109. sizeFunc = wiki.GetSpecialInfoSize
  1110. getFunc = wiki.GetSpecialInfoData
  1111. grid = ui.Grid(width = 11, height = 50)
  1112. for j in xrange(sizeFunc(self.vnum)):
  1113. (vnum, count) = getFunc(self.vnum,j)
  1114. if vnum == 0:
  1115. continue
  1116. item.SelectItem(vnum)
  1117. (width, height) = item.GetItemSize()
  1118. if width == 0 or height == 0:
  1119. continue
  1120. item_new = ui.ExpandedImageBox()
  1121. item_new.SetParent(Listbox)
  1122. if item.GetIconImageFileName().find("gr2") == -1:
  1123. item_new.LoadImage(item.GetIconImageFileName())
  1124. else:
  1125. item_new.LoadImage("icon/item/27995.tga")
  1126. item_new.SAFE_SetStringEvent("MOUSE_OVER_IN",self.OverInItem,vnum)
  1127. item_new.SAFE_SetStringEvent("MOUSE_OVER_OUT",self.OverOutItem)
  1128. item_new.SetEvent(ui.__mem_func__(self.OnClickItem),"mouse_click",0,vnum)
  1129. pos = grid.find_blank(width, height)
  1130. grid.put(pos, width, height)
  1131. (x, y) = WikiUI.calculatePos(pos, 10)
  1132. item_new.SetPosition(x, y, True)
  1133. item_new.itsNeedDoubleRender = True
  1134. item_new.Show()
  1135. self.children.append(item_new)
  1136. Listbox.AppendItem(item_new)
  1137. if count>1:
  1138. itemNumberline = ui.NumberLine()
  1139. itemNumberline.SetParent(Listbox)
  1140. itemNumberline.SetNumber(str(count))
  1141. itemNumberline.SetPosition(x+15,y+item_new.GetHeight()-10,True)
  1142. itemNumberline.itsNeedDoubleRender = True
  1143. itemNumberline.Show()
  1144. Listbox.AppendItem(itemNumberline)
  1145. self.children.append(itemNumberline)
  1146. if Listbox.isNeedScrollBar():
  1147. scrollBar = WikiUI.ScrollBarNew()
  1148. scrollBar.SetParent(Listbox)
  1149. scrollBar.SetPosition(Listbox.GetWidth()-10, 0)
  1150. scrollBar.SetScrollBarSize(137)
  1151. scrollBar.Hide()
  1152. self.children.append(scrollBar)
  1153. Listbox.SetScrollBar(scrollBar)
  1154. else:
  1155. item.SelectItem(self.vnum)
  1156. if WikiUI.IsCanModelPreview(self.vnum):
  1157. renterTarget = ui.RenderTarget()
  1158. renterTarget.SetParent(self)
  1159. renterTarget.SetPosition(1,1)
  1160. renterTarget.SetSize(187,163)
  1161. renterTarget.SetRenderTarget(self.renderIndex)
  1162. renterTarget.Show()
  1163. self.children.append(renterTarget)
  1164. WikiUI.SetItemToModelPreview(self.renderIndex, self.vnum)
  1165. itemIcon = ui.ExpandedImageBox()
  1166. itemIcon.SetParent(self)
  1167. if item.GetIconImageFileName().find("gr2") == -1:
  1168. itemIcon.LoadImage(item.GetIconImageFileName())
  1169. else:
  1170. itemIcon.LoadImage("icon/item/27995.tga")
  1171. if WikiUI.IsCanModelPreview(self.vnum):
  1172. itemIcon.SetPosition(renterTarget.GetWidth()-itemIcon.GetWidth()-3,3)
  1173. else:
  1174. itemIcon.SetPosition(70,45)
  1175. itemIcon.SAFE_SetStringEvent("MOUSE_OVER_IN",self.OverInItem,self.vnum)
  1176. itemIcon.SAFE_SetStringEvent("MOUSE_OVER_OUT",self.OverOutItem)
  1177. itemIcon.Show()
  1178. self.children.append(itemIcon)
  1179. avaible = ui.TextLine()
  1180. avaible.SetParent(self)
  1181. avaible.SetText(localeInfo.WIKI_AVAIBLE_AT)
  1182. avaible.SetPosition(350,6)
  1183. avaible.Show()
  1184. self.children.append(avaible)
  1185. Listbox = WikiUI.ListBoxGrid()
  1186. Listbox.SetParent(self)
  1187. Listbox.SetPosition(190, 25)
  1188. Listbox.SetSize(350, 128)
  1189. Listbox.AddRenderEvent(self.OnRender)
  1190. item.SelectItem(60001)
  1191. (itemVnum, isRefineItem) = WikiUI.getRealVnum(self.vnum)
  1192. (x , y, isHave, unknownItem) = (5, 5, False, item.GetItemName())
  1193. chest_list = wiki.GetItemDropFromChest(itemVnum, isRefineItem)
  1194. for i, chestVnum in enumerate(chest_list, start=0):
  1195. if isHave == False:
  1196. isHave=True
  1197. self.AppendTextLine(Listbox, "|cFF0080FF"+localeInfo.WIKI_CHESTS+":", x, y)
  1198. y+=14
  1199. item.SelectItem(chestVnum)
  1200. self.AppendTextLine(Listbox, "|Eemoji/e_wiki|e "+item.GetItemName() if unknownItem != item.GetItemName() else "|Eemoji/e_wiki|e "+localeInfo.WIKI_UNKOWN_ITEM%chestVnum,x,y)
  1201. y+=14
  1202. if len(Listbox.itemList) > 0:
  1203. y+=28
  1204. isHave = False
  1205. mob_vnums = wiki.GetItemDropFromMonster(itemVnum, isRefineItem)
  1206. for i, mobVnum in enumerate(mob_vnums, start=0):
  1207. if isHave == False:
  1208. isHave=True
  1209. self.AppendTextLine(Listbox, "|cFF0080FF"+localeInfo.WIKI_MONSTER+":",x,y)
  1210. y+=14
  1211. level = nonplayer.GetMonsterLevel(mobVnum)
  1212. self.AppendTextLine(Listbox, "|Eemoji/e_wiki|e "+localeInfo.WIKI_UNKOWN_MOB%mobVnum if level <= 0 else "|Eemoji/e_wiki|e "+nonplayer.GetMonsterName(mobVnum)+ " - Lv."+str(level), x, y)
  1213. y+=14
  1214. if Listbox.isNeedScrollBar():
  1215. scrollBar = WikiUI.ScrollBarNew()
  1216. scrollBar.SetParent(Listbox)
  1217. scrollBar.SetPosition(Listbox.GetWidth()-10, 0)
  1218. scrollBar.SetScrollBarSize(137)
  1219. self.children.append(scrollBar)
  1220. Listbox.SetScrollBar(scrollBar)
  1221. if Listbox != None:
  1222. if len(Listbox.itemList) > 0:
  1223. self.Listbox = Listbox
  1224. Listbox.SetBasePos(0, False)
  1225. Listbox.Show()
  1226. self.OnRender()
  1227. self.Show()
  1228. def AppendTextLine(self, Listbox, text, x, y):
  1229. textLine = ui.TextLine()
  1230. textLine.SetParent(Listbox)
  1231. textLine.itsNeedDoubleRender = True
  1232. textLine.SetText(text)
  1233. textLine.SetPosition(x, y, True)
  1234. textLine.Show()
  1235. self.children.append(textLine)
  1236. Listbox.AppendItem(textLine)
  1237. class MonsterStatics(WikiUI.DefaultWikiImage):
  1238. def __del__(self):
  1239. WikiUI.DefaultWikiImage.__del__(self)
  1240. def Destroy(self):
  1241. self.mobVnum = 0
  1242. WikiUI.DefaultWikiImage.Destroy(self)
  1243. def __init__(self, mobVnum, isType):
  1244. WikiUI.DefaultWikiImage.__init__(self)
  1245. self.Destroy()
  1246. self.mobVnum = mobVnum
  1247. self.isType = isType
  1248. self.LoadImage(IMG_DIR+"slot/big_empty.tga")
  1249. self.children.append(self)
  1250. def LoadItemInfos(self):
  1251. if self.IsLoaded == False:
  1252. self.IsLoaded=True
  1253. ListBox = WikiUI.ListBoxGrid()
  1254. ListBox.SetParent(self)
  1255. ListBox.SetSize(self.GetWidth(), self.GetHeight()-10)
  1256. ListBox.AddRenderEvent(self.OnRender)
  1257. if self.isType == 3:
  1258. item.SelectItem(60001)
  1259. (itemVnum, isRefineItem) = WikiUI.getRealVnum(self.mobVnum)
  1260. (x , y, isHave, unknownItem) = (5, 5, False, item.GetItemName())
  1261. chest_list = wiki.GetItemDropFromChest(itemVnum, isRefineItem)
  1262. for i, chestVnum in enumerate(chest_list, start=0):
  1263. if isHave == False:
  1264. isHave=True
  1265. self.AppendTextLine(ListBox, "|cFF0080FF"+localeInfo.WIKI_CHESTS+":", x, y)
  1266. y+=14
  1267. item.SelectItem(chestVnum)
  1268. self.AppendTextLine(ListBox, "|Eemoji/e_wiki|e "+item.GetItemName() if unknownItem != item.GetItemName() else "|Eemoji/e_wiki|e "+localeInfo.WIKI_UNKOWN_ITEM%chestVnum,x,y)
  1269. y+=14
  1270. if len(ListBox.itemList) > 0:
  1271. y+=28
  1272. isHave = False
  1273. mob_vnums = wiki.GetItemDropFromMonster(itemVnum, isRefineItem)
  1274. for i, mobVnum in enumerate(mob_vnums, start=0):
  1275. if isHave == False:
  1276. isHave=True
  1277. self.AppendTextLine(ListBox, "|cFF0080FF"+localeInfo.WIKI_MONSTER+":",x,y)
  1278. y+=14
  1279. level = nonplayer.GetMonsterLevel(mobVnum)
  1280. self.AppendTextLine(ListBox, "|Eemoji/e_wiki|e "+localeInfo.WIKI_UNKOWN_MOB%mobVnum if level <= 0 else "|Eemoji/e_wiki|e "+nonplayer.GetMonsterName(mobVnum)+ " - Lv."+str(level), x, y)
  1281. y+=14
  1282. elif self.isType == 0:
  1283. self.AppendTextLine(ListBox, "|Eemoji/e_wiki|e "+localeInfo.WIKI_LEVEL_MOB_TEXT%nonplayer.GetMonsterLevel(self.mobVnum), 5, 3)
  1284. RACE_FLAG_TO_NAME = {
  1285. 1 << 0 : localeInfo.TARGET_INFO_RACE_ANIMAL,
  1286. 1 << 1 : localeInfo.TARGET_INFO_RACE_UNDEAD,
  1287. 1 << 2 : localeInfo.TARGET_INFO_RACE_DEVIL,
  1288. 1 << 3 : localeInfo.TARGET_INFO_RACE_HUMAN,
  1289. 1 << 4 : localeInfo.TARGET_INFO_RACE_ORC,
  1290. 1 << 5 : localeInfo.TARGET_INFO_RACE_MILGYO,
  1291. }
  1292. SUB_RACE_FLAG_TO_NAME = {
  1293. 1 << 11 : localeInfo.TARGET_INFO_RACE_ELEC,
  1294. 1 << 12 : localeInfo.TARGET_INFO_RACE_FIRE,
  1295. 1 << 13 : localeInfo.TARGET_INFO_RACE_ICE,
  1296. 1 << 14 : localeInfo.TARGET_INFO_RACE_WIND,
  1297. 1 << 15 : localeInfo.TARGET_INFO_RACE_EARTH,
  1298. 1 << 16 : localeInfo.TARGET_INFO_RACE_DARK,
  1299. 1 << 17 : localeInfo.TARGET_INFO_RACE_ZODIAC,
  1300. }
  1301. mainrace = ""
  1302. subrace = ""
  1303. dwRaceFlag = nonplayer.GetMonsterRaceFlag(self.mobVnum)
  1304. for i in xrange(18):
  1305. curFlag = 1 << i
  1306. if constInfo.IS_SET(dwRaceFlag, curFlag):
  1307. if RACE_FLAG_TO_NAME.has_key(curFlag):
  1308. mainrace += RACE_FLAG_TO_NAME[curFlag] + ", "
  1309. elif SUB_RACE_FLAG_TO_NAME.has_key(curFlag):
  1310. subrace += SUB_RACE_FLAG_TO_NAME[curFlag] + ", "
  1311. if nonplayer.IsMonsterStone(self.mobVnum):
  1312. mainrace += localeInfo.TARGET_INFO_RACE_METIN + ", "
  1313. if mainrace == "":
  1314. mainrace = localeInfo.TARGET_INFO_NO_RACE
  1315. else:
  1316. mainrace = mainrace[:-2]
  1317. if subrace == "":
  1318. subrace = localeInfo.TARGET_INFO_NO_RACE
  1319. else:
  1320. subrace = subrace[:-2]
  1321. self.AppendTextLine(ListBox, "|Eemoji/e_wiki|e "+localeInfo.WIKI_STATICS_INFO_TYPE%(mainrace,subrace), 5, 3*(7*1))
  1322. (mindmg, maxdmg) = nonplayer.GetMonsterDamage(self.mobVnum)
  1323. self.AppendTextLine(ListBox, "|Eemoji/e_wiki|e "+localeInfo.WIKI_STATICS_INFO_DMG%(mindmg,maxdmg,nonplayer.GetMonsterMaxHP(self.mobVnum)), 5, 3*(7*2))
  1324. (minyang, maxyang) = nonplayer.GetMonsterPrice(self.mobVnum)
  1325. exp = nonplayer.GetMonsterExp(self.mobVnum)
  1326. self.AppendTextLine(ListBox, "|Eemoji/e_wiki|e "+localeInfo.WIKI_STATICS_INFO_YNG%(minyang,maxyang,exp), 5, 3*(7*3))
  1327. self.AppendTextLine(ListBox, "|Eemoji/e_wiki|e "+localeInfo.WIKI_STATICS_INFO_DEFENSES, 5, 3*(7*4))
  1328. resists = {
  1329. nonplayer.MOB_RESIST_SWORD : localeInfo.TARGET_INFO_RESIST_SWORD,
  1330. nonplayer.MOB_RESIST_TWOHAND : localeInfo.TARGET_INFO_RESIST_TWOHAND,
  1331. nonplayer.MOB_RESIST_DAGGER : localeInfo.TARGET_INFO_RESIST_DAGGER,
  1332. nonplayer.MOB_RESIST_BELL : localeInfo.TARGET_INFO_RESIST_BELL,
  1333. nonplayer.MOB_RESIST_FAN : localeInfo.TARGET_INFO_RESIST_FAN,
  1334. nonplayer.MOB_RESIST_BOW : localeInfo.TARGET_INFO_RESIST_BOW,
  1335. nonplayer.MOB_RESIST_MAGIC : localeInfo.TARGET_INFO_RESIST_MAGIC,
  1336. }
  1337. c = 0
  1338. for resist, label in resists.items():
  1339. resistText = label % nonplayer.GetMonsterResist(self.mobVnum, resist)
  1340. self.AppendTextLine(ListBox, "|Eemoji/e_wiki|e %s"%resistText, 5+8, 3*(7*(5+c)))
  1341. c+=1
  1342. if ListBox.isNeedScrollBar():
  1343. scrollBar = WikiUI.ScrollBarNew()
  1344. scrollBar.SetParent(ListBox)
  1345. scrollBar.SetPosition(ListBox.GetWidth()-10,5)
  1346. scrollBar.SetScrollBarSize(150)
  1347. scrollBar.Show()
  1348. ListBox.SetScrollBar(scrollBar)
  1349. self.children.append(scrollBar)
  1350. self.OnRender()
  1351. ListBox.Show()
  1352. self.Listbox = ListBox
  1353. self.Show()
  1354. def AppendTextLine(self, Listbox, text, x, y):
  1355. textLine = ui.TextLine()
  1356. textLine.SetParent(Listbox)
  1357. textLine.itsNeedDoubleRender = True
  1358. textLine.SetText(text)
  1359. textLine.SetPosition(x, y, True)
  1360. textLine.Show()
  1361. self.children.append(textLine)
  1362. Listbox.AppendItem(textLine)
  1363. class ListBoxItemSpecial(WikiUI.DefaultWikiImage):
  1364. def __del__(self):
  1365. WikiUI.DefaultWikiImage.__del__(self)
  1366. def Destroy(self):
  1367. self.renterTarget = None
  1368. WikiUI.DefaultWikiImage.Destroy(self)
  1369. def __init__(self, index, itemVnum, mobVnum, type):
  1370. WikiUI.DefaultWikiImage.__init__(self)
  1371. self.listIndex = index
  1372. self.itemVnum = itemVnum
  1373. self.mobVnum = mobVnum
  1374. self.isType = type
  1375. self.LoadImage(IMG_DIR+"slot/slot.tga")
  1376. self.children.append(self)
  1377. def LoadItemInfos(self):
  1378. if self.IsLoaded == False:
  1379. self.IsLoaded=True
  1380. name = "-"
  1381. if self.isType == 0:
  1382. item.SelectItem(self.itemVnum)
  1383. name = nonplayer.GetMonsterName(self.mobVnum)
  1384. else:
  1385. name = nonplayer.GetMonsterName(self.itemVnum)
  1386. itemName = ui.TextLine()
  1387. itemName.SetParent(self)
  1388. if self.isType == 0:
  1389. itemName.SetText(localeInfo.WIKI_CONTENT_INFO%item.GetItemName())
  1390. else:
  1391. itemName.SetText(localeInfo.WIKI_DROPLIST_INFO%name)
  1392. itemName.SetText(itemName.GetText()+" - Level %d"%nonplayer.GetMonsterLevel(self.itemVnum))
  1393. itemName.SetText(itemName.GetText()+" - Mob Vnum %d"%self.itemVnum) # test
  1394. itemName.SetPosition(270, 5)
  1395. itemName.SetHorizontalAlignCenter()
  1396. itemName.Show()
  1397. self.children.append(itemName)
  1398. origin = ui.TextLine()
  1399. origin.SetParent(self)
  1400. origin.SetText(localeInfo.WIKI_ORIGIN)
  1401. origin.SetPosition(480,5)
  1402. origin.Show()
  1403. self.children.append(origin)
  1404. bossVnum = ui.TextLine()
  1405. bossVnum.SetParent(self)
  1406. bossVnum.SetHorizontalAlignCenter()
  1407. bossVnum.SetPosition(490,45)
  1408. if self.isType == 0 and self.mobVnum != 0:
  1409. bossVnum.SetText(name)
  1410. else:
  1411. bossVnum.SetText("-")
  1412. bossVnum.Show()
  1413. self.children.append(bossVnum)
  1414. if self.isType == 0:
  1415. itemIcon = ui.ExpandedImageBox()
  1416. itemIcon.SetParent(self)
  1417. if item.GetIconImageFileName().find("gr2") == -1:
  1418. itemIcon.LoadImage(item.GetIconImageFileName())
  1419. else:
  1420. itemIcon.LoadImage("icon/item/27995.tga")
  1421. itemIcon.SetPosition(10,25)
  1422. itemIcon.SAFE_SetStringEvent("MOUSE_OVER_IN",self.OverInItem,self.itemVnum)
  1423. itemIcon.SAFE_SetStringEvent("MOUSE_OVER_OUT",self.OverOutItem)
  1424. itemIcon.SetEvent(ui.__mem_func__(self.OnClickItem),"mouse_click",0,self.itemVnum)
  1425. itemIcon.Show()
  1426. self.children.append(itemIcon)
  1427. else:
  1428. renterTarget = ui.RenderTarget()
  1429. renterTarget.SetParent(self)
  1430. renterTarget.SetPosition(1,1)
  1431. renterTarget.SetSize(47,87)
  1432. renterTarget.SetRenderTarget(20+self.listIndex)
  1433. renterTarget.Show()
  1434. renterTarget.SetEvent(ui.__mem_func__(self.OnClickItem),"mouse_click",1,self.itemVnum)
  1435. self.children.append(renterTarget)
  1436. renderTarget.SelectModel(20+self.listIndex, self.itemVnum)
  1437. renderTarget.SetVisibility(20+self.listIndex, True)
  1438. whileSize = 0
  1439. if self.isType == 0:
  1440. whileSize = wiki.GetSpecialInfoSize(self.itemVnum)
  1441. else:
  1442. whileSize = wiki.GetMobInfoSize(self.itemVnum)
  1443. if whileSize != 0:
  1444. Listbox = WikiUI.ListBoxGrid()
  1445. Listbox.SetParent(self)
  1446. Listbox.SetPosition(48,22)
  1447. Listbox.SetSize(403, 65)
  1448. Listbox.AddRenderEvent(self.OnRender)
  1449. Listbox.Show()
  1450. gridCalculate = ui.Grid(width = 12, height = 50)
  1451. screenSize = 0
  1452. for j in xrange(whileSize):
  1453. vnum, count = 0,0
  1454. if self.isType == 0:
  1455. (vnum,count) = wiki.GetSpecialInfoData(self.itemVnum,j)
  1456. else:
  1457. (vnum,count) = wiki.GetMobInfoData(self.itemVnum,j)
  1458. if vnum == 0:
  1459. continue
  1460. item.SelectItem(vnum)
  1461. (width,height) = item.GetItemSize()
  1462. if width == 0 or height == 0:
  1463. continue
  1464. pos = gridCalculate.find_blank(width, height)
  1465. gridCalculate.put(pos,width,height)
  1466. (x, y) = WikiUI.calculatePos(pos, 11)
  1467. item_new = ui.ExpandedImageBox()
  1468. item_new.SetParent(Listbox)
  1469. if item.GetIconImageFileName().find("gr2") == -1:
  1470. item_new.LoadImage(item.GetIconImageFileName())
  1471. else:
  1472. item_new.LoadImage("icon/item/27995.tga")
  1473. item_new.SAFE_SetStringEvent("MOUSE_OVER_IN",self.OverInItem,vnum)
  1474. item_new.SAFE_SetStringEvent("MOUSE_OVER_OUT",self.OverOutItem)
  1475. item_new.SetEvent(ui.__mem_func__(self.OnClickItem),"mouse_click",0,vnum)
  1476. item_new.SetPosition(x, y, True)
  1477. if y+item_new.GetHeight() > screenSize:
  1478. screenSize = y+item_new.GetHeight()
  1479. item_new.itsNeedDoubleRender = True
  1480. item_new.Show()
  1481. Listbox.AppendItem(item_new)
  1482. self.children.append(item_new)
  1483. if count>1:
  1484. if USE_ITEM_COUNT_NUMBER_LINE:
  1485. itemNumberline = ui.NumberLine()
  1486. else:
  1487. itemNumberline = ui.TextLine()
  1488. itemNumberline.SetParent(Listbox)
  1489. if USE_ITEM_COUNT_NUMBER_LINE:
  1490. itemNumberline.SetNumber(str(count))
  1491. itemNumberline.SetPosition(x+15,y+item_new.GetHeight()-10,True)
  1492. else:
  1493. itemNumberline.SetText(str(count))
  1494. itemNumberline.SetPosition(x+item_new.GetWidth()-5,y+item_new.GetHeight()-10,True)
  1495. itemNumberline.itsNeedDoubleRender = True
  1496. itemNumberline.Show()
  1497. Listbox.AppendItem(itemNumberline)
  1498. self.children.append(itemNumberline)
  1499. if Listbox.isNeedScrollBar():
  1500. scrollbar = WikiUI.ScrollBarNew()
  1501. scrollbar.SetParent(self)
  1502. scrollbar.SetPosition(443, 23)
  1503. scrollbar.SetScrollBarSize(63)
  1504. scrollbar.itsNeedDoubleRender = True
  1505. scrollbar.Show()
  1506. self.children.append(scrollbar)
  1507. Listbox.SetScrollBar(scrollbar)
  1508. self.Listbox = Listbox
  1509. self.OnRender()
  1510. self.Show()
  1511. class ArticleGUI(WikiUI.DefaultWikiImage):
  1512. def __del__(self):
  1513. WikiUI.DefaultWikiImage.__del__(self)
  1514. def Destroy(self):
  1515. self.index = 0
  1516. self.scrollPos = 0.0
  1517. WikiUI.DefaultWikiImage.Destroy(self)
  1518. def __init__(self, index):
  1519. WikiUI.DefaultWikiImage.__init__(self)
  1520. if isinstance(index, str):
  1521. if index.find("#") != -1:
  1522. indexList = index.split("#")
  1523. if len(indexList) == 2:
  1524. self.index = int(indexList[0])
  1525. self.scrollPos = float(indexList[1])
  1526. else:
  1527. self.index = index
  1528. self.scrollPos = 0.0
  1529. self.LoadImage(IMG_DIR+"slot/big2_empty.tga")
  1530. self.children.append(self)
  1531. def LoadItemInfos(self):
  1532. if self.IsLoaded == False:
  1533. self.IsLoaded = True
  1534. Listbox = WikiUI.ListBoxGrid()
  1535. Listbox.SetParent(self)
  1536. Listbox.SetPosition(0,0)
  1537. Listbox.SetSize(self.GetWidth()-15, self.GetHeight()-15)
  1538. Listbox.AddRenderEvent(self.OnRender)
  1539. self.ReadArticle(Listbox, self.index)
  1540. self.CheckScrollBarNeed(Listbox)
  1541. Listbox.Show()
  1542. self.Listbox = Listbox
  1543. self.OnRender()
  1544. self.Show()
  1545. def GetFileName(self, index):
  1546. file_dict= {
  1547. 0 : "wiki/basic_guide.txt",
  1548. 1 : "wiki/bonus67.txt",
  1549. 2 : "wiki/costume.txt",
  1550. 3 : "wiki/drops.txt",
  1551. 4 : "wiki/pets.txt",
  1552. 5 : "wiki/biologist.txt",
  1553. 6 : "wiki/gamerules.txt",
  1554. 7 : "wiki/alchemy.txt",
  1555. 8 : "wiki/events.txt",
  1556. }
  1557. if file_dict.has_key(index):
  1558. return app.GetLocalePath()+"/"+file_dict[index]
  1559. return ""
  1560. def ParseToken(self, data):
  1561. data = data.replace(chr(10), "").replace(chr(13), "")
  1562. if not (len(data) and data[0] == "["):
  1563. return (False, {}, data)
  1564. fnd = data.find("]")
  1565. if fnd <= 0:
  1566. return (False, {}, data)
  1567. content = data[1:fnd]
  1568. data = data[fnd+1:]
  1569. content = content.split(";")
  1570. container = {}
  1571. for i in content:
  1572. i = i.strip()
  1573. splt = i.split("=")
  1574. if len(splt) == 1:
  1575. container[splt[0].lower().strip()] = True
  1576. else:
  1577. container[splt[0].lower().strip()] = splt[1].lower().strip()
  1578. return (True, container, data)
  1579. def GetColorFromString(self, strCol):
  1580. retData = []
  1581. dNum = 4
  1582. hCol = long(strCol, 16)
  1583. if hCol <= 0xFFFFFF:
  1584. retData.append(1.0)
  1585. dNum = 3
  1586. for i in xrange(dNum):
  1587. retData.append(float((hCol >> (8 * i)) & 0xFF) / 255.0)
  1588. retData.reverse()
  1589. return retData
  1590. def DirectionEvent(self, emptyArg, type, index, pos):
  1591. parent = constInfo.GetMainParent()
  1592. if parent != None:
  1593. if "item" == type:
  1594. parent.ShowItemInfo(index,0)
  1595. elif "mob" == type:
  1596. parent.ShowItemInfo(index,1)
  1597. elif "article" == type:
  1598. parent.ShowItemInfo("system#"+str(index)+"#"+str(pos),3)
  1599. def ReadArticle(self, Listbox, index):
  1600. fileName = self.GetFileName(index)
  1601. if fileName == "":
  1602. return
  1603. try:
  1604. lines = pack_open(fileName, "r").readlines()
  1605. except:
  1606. pass
  1607. _y = 10
  1608. for i in lines:
  1609. (ret, tokenMap, i) = self.ParseToken(i)
  1610. if ret:
  1611. if tokenMap.has_key("banner_img"):
  1612. mainParent = constInfo.GetMainParent()
  1613. if mainParent != None:
  1614. resultpagebtn = mainParent.children["resultpagebtn"]
  1615. resultpagebtn.LoadImage(tokenMap["banner_img"])
  1616. resultpagebtn.Show()
  1617. tokenMap.pop("banner_img")
  1618. #
  1619. if tokenMap.has_key("img"):
  1620. cimg = ui.ExpandedImageBox()
  1621. cimg.SetParent(Listbox)
  1622. cimg.AddFlag("attach")
  1623. cimg.AddFlag("not_pick")
  1624. cimg.LoadImage(tokenMap["img"])
  1625. cimg.Show()
  1626. tokenMap.pop("img")
  1627. x = 0
  1628. if tokenMap.has_key("x"):
  1629. x = int(tokenMap["x"])
  1630. tokenMap.pop("x")
  1631. y = 0
  1632. if tokenMap.has_key("y"):
  1633. y = int(tokenMap["y"])
  1634. tokenMap.pop("y")
  1635. if tokenMap.has_key("center_align"):
  1636. cimg.SetPosition(Listbox.GetWidth() / 2 - cimg.GetWidth() / 2, y, True)
  1637. tokenMap.pop("center_align")
  1638. elif tokenMap.has_key("right_align"):
  1639. cimg.SetPosition(Listbox.GetWidth() - cimg.GetWidth(), y, True)
  1640. tokenMap.pop("right_align")
  1641. else:
  1642. cimg.SetPosition(x, y, True)
  1643. self.children.append(cimg)
  1644. Listbox.AppendItem(cimg)
  1645. if tokenMap.has_key("item"):
  1646. itemVnum = int(tokenMap["item"])
  1647. tokenMap.pop("item")
  1648. item.SelectItem(itemVnum)
  1649. cimg = ui.ExpandedImageBox()
  1650. cimg.SetParent(Listbox)
  1651. if item.GetIconImageFileName().find("gr2") == -1:
  1652. cimg.LoadImage(item.GetIconImageFileName())
  1653. else:
  1654. cimg.LoadImage("icon/item/27995.tga")
  1655. cimg.SAFE_SetStringEvent("MOUSE_OVER_IN",self.OverInItem,itemVnum)
  1656. cimg.SAFE_SetStringEvent("MOUSE_OVER_OUT",self.OverOutItem)
  1657. cimg.SetEvent(ui.__mem_func__(self.OnClickItem),"mouse_click",0,itemVnum)
  1658. cimg.Show()
  1659. x = 0
  1660. if tokenMap.has_key("x"):
  1661. x = int(tokenMap["x"])
  1662. tokenMap.pop("x")
  1663. y = 0
  1664. if tokenMap.has_key("y"):
  1665. y = int(tokenMap["y"])
  1666. tokenMap.pop("y")
  1667. if tokenMap.has_key("center_align"):
  1668. cimg.SetPosition(Listbox.GetWidth() / 2 - cimg.GetWidth() / 2, y, True)
  1669. tokenMap.pop("center_align")
  1670. elif tokenMap.has_key("right_align"):
  1671. cimg.SetPosition(Listbox.GetWidth() - cimg.GetWidth(), y, True)
  1672. tokenMap.pop("right_align")
  1673. else:
  1674. cimg.SetPosition(x, y, True)
  1675. self.children.append(cimg)
  1676. Listbox.AppendItem(cimg)
  1677. if tokenMap.has_key("link"):
  1678. link = tokenMap["link"]
  1679. tokenMap.pop("link")
  1680. if tokenMap.has_key("linkindex"):
  1681. linkindex = int(tokenMap["linkindex"])
  1682. tokenMap.pop("linkindex")
  1683. else:
  1684. linkindex = 0
  1685. if tokenMap.has_key("linkpos"):
  1686. linkpos = float(tokenMap["linkpos"])
  1687. tokenMap.pop("linkpos")
  1688. else:
  1689. linkpos = 0
  1690. if tokenMap.has_key("linktext"):
  1691. linkText = WikiUI.GetArgToString(tokenMap["linktext"])
  1692. tokenMap.pop("linktext")
  1693. else:
  1694. linkText = ""
  1695. tmp = WikiUI.TextlineLink()
  1696. tmp.SetParent(Listbox)
  1697. if tokenMap.has_key("font_size"):
  1698. splt = localeInfo.UI_DEF_FONT.split(":")
  1699. tmp.SetFontName(splt[0]+":"+tokenMap["font_size"])
  1700. tokenMap.pop("font_size")
  1701. else:
  1702. tmp.SetFontName(localeInfo.UI_DEF_FONT)
  1703. tmp.SetText(WikiUI.GetArgToString(linkText), 1.2)
  1704. tmp.Show()
  1705. tmp.SetSize(*tmp.GetTextSize())
  1706. if tokenMap.has_key("color"):
  1707. fontColor = self.GetColorFromString(tokenMap["color"])
  1708. tmp.SetColor(grp.GenerateColor(fontColor[0], fontColor[1], fontColor[2], fontColor[3]), fontColor[0], fontColor[1], fontColor[2])
  1709. tokenMap.pop("color")
  1710. tmp.SetMouseLeftButtonDownEvent(ui.__mem_func__(self.DirectionEvent), "",link, linkindex, linkpos)
  1711. tmp.linkIcon.SetMouseLeftButtonDownEvent(ui.__mem_func__(self.DirectionEvent),"", link, linkindex, linkpos)
  1712. if tokenMap.has_key("y"):
  1713. y = int(tokenMap["y"])
  1714. tokenMap.pop("y")
  1715. if tokenMap.has_key("center_align"):
  1716. tmp.SetPosition(Listbox.GetWidth() / 2 - tmp.GetWidth() / 2, y, True)
  1717. tokenMap.pop("center_align")
  1718. elif tokenMap.has_key("right_align"):
  1719. tmp.SetPosition(Listbox.GetWidth() - tmp.GetWidth(), y, True)
  1720. tokenMap.pop("right_align")
  1721. else:
  1722. tmp.SetPosition(x, y, True)
  1723. self.children.append(tmp)
  1724. Listbox.AppendItem(tmp)
  1725. if tokenMap.has_key("rendertarget"):
  1726. mobVnum = int(tokenMap["rendertarget"])
  1727. tokenMap.pop("rendertarget")
  1728. (width, height) = (47, 87)
  1729. if tokenMap.has_key("width"):
  1730. width = int(tokenMap["width"])
  1731. tokenMap.pop("width")
  1732. if tokenMap.has_key("height"):
  1733. height = int(tokenMap["height"])
  1734. tokenMap.pop("height")
  1735. #targetIndex = app.GetRandom(100,1000)
  1736. targetIndex = renderTarget.GetFreeIndex(1000, 1000000)
  1737. tmp = ui.RenderTarget()
  1738. tmp.SetParent(Listbox)
  1739. tmp.SetSize(width, height)
  1740. tmp.SetRenderTarget(targetIndex)
  1741. tmp.SetEvent(ui.__mem_func__(self.DirectionEvent),"mouse_click", "mob", mobVnum, 0)
  1742. tmp.Show()
  1743. renderTarget.SelectModel(targetIndex, mobVnum)
  1744. renderTarget.SetVisibility(targetIndex, True)
  1745. if tokenMap.has_key("y"):
  1746. y = int(tokenMap["y"])
  1747. tokenMap.pop("y")
  1748. if tokenMap.has_key("center_align"):
  1749. tmp.SetPosition(Listbox.GetWidth() / 2 - tmp.GetWidth() / 2, y, True)
  1750. tokenMap.pop("center_align")
  1751. elif tokenMap.has_key("right_align"):
  1752. tmp.SetPosition(Listbox.GetWidth() - tmp.GetWidth(), y, True)
  1753. tokenMap.pop("right_align")
  1754. else:
  1755. tmp.SetPosition(x, y, True)
  1756. self.children.append(tmp)
  1757. Listbox.AppendItem(tmp)
  1758. if ret and not len(i):
  1759. continue
  1760. i = i.replace("*", "|Eemoji/e_wiki|e")
  1761. tmp = ui.TextLine()
  1762. tmp.SetParent(Listbox)
  1763. if tokenMap.has_key("font_size"):
  1764. splt = localeInfo.UI_DEF_FONT.split(":")
  1765. tmp.SetFontName(splt[0]+":"+tokenMap["font_size"])
  1766. tokenMap.pop("font_size")
  1767. else:
  1768. tmp.SetFontName(localeInfo.UI_DEF_FONT)
  1769. tmp.SetText(WikiUI.GetArgToString(i))
  1770. tmp.Show()
  1771. tmp.SetSize(*tmp.GetTextSize())
  1772. if tokenMap.has_key("color"):
  1773. fontColor = self.GetColorFromString(tokenMap["color"])
  1774. tmp.SetPackedFontColor(grp.GenerateColor(fontColor[0], fontColor[1], fontColor[2], fontColor[3]))
  1775. tokenMap.pop("color")
  1776. tmp.SetPosition(5, _y, True)
  1777. _y+=tmp.GetHeight()
  1778. if tokenMap.has_key("center_align"):
  1779. tmp.SetPosition(Listbox.GetWidth() / 2 - tmp.GetWidth() / 2, tmp.GetLocalPosition()[1], True)
  1780. tokenMap.pop("center_align")
  1781. elif tokenMap.has_key("right_align"):
  1782. tmp.SetPosition(Listbox.GetWidth() - tmp.GetWidth(), tmp.GetLocalPosition()[1], True)
  1783. tokenMap.pop("right_align")
  1784. elif tokenMap.has_key("x_padding"):
  1785. tmp.SetPosition(int(tokenMap["x_padding"]), tmp.GetLocalPosition()[1], True)
  1786. tokenMap.pop("x_padding")
  1787. tmp.Show()
  1788. self.children.append(tmp)
  1789. Listbox.AppendItem(tmp)
  1790. def CheckScrollBarNeed(self, Listbox):
  1791. if Listbox.isNeedScrollBar():
  1792. scrollBar = WikiUI.ScrollBarNew()
  1793. scrollBar.SetParent(self)
  1794. scrollBar.SetPosition(self.GetWidth()-15+8,2)
  1795. scrollBar.SetScrollBarSize(337)
  1796. scrollBar.Show()
  1797. self.children.append(scrollBar)
  1798. Listbox.SetScrollBar(scrollBar)
  1799. scrollBar.SetPos(self.scrollPos)
  1800. Listbox.OnScroll()
  1801. class SpecialClass(WikiUI.DefaultWikiWindow):
  1802. def __del__(self):
  1803. WikiUI.DefaultWikiWindow.__del__(self)
  1804. def Destroy(self):
  1805. self.vnumList = []
  1806. WikiUI.DefaultWikiWindow.Destroy(self)
  1807. def __init__(self, listIndex, isMonster):
  1808. WikiUI.DefaultWikiWindow.__init__(self)
  1809. self.Destroy()
  1810. self.isType = isMonster
  1811. self.listIndex = listIndex
  1812. self.SetSize(540, 147)
  1813. def CanAddNewItem(self):
  1814. return len(self.vnumList) < 4
  1815. def LoadItemInfos(self, data = -1):
  1816. if data == -1:
  1817. return
  1818. xPos = len(self.vnumList) * (127+9)
  1819. bg = ui.ExpandedImageBox()
  1820. bg.SetParent(self)
  1821. bg.LoadImage(IMG_DIR+"slot/special_single.tga")
  1822. bg.SetPosition(xPos, 0)
  1823. bg.Show()
  1824. self.children.append(bg)
  1825. item.SelectItem(data)
  1826. itemIcon = ui.ExpandedImageBox()
  1827. itemIcon.SetParent(bg)
  1828. if item.GetIconImageFileName().find("gr2") == -1:
  1829. itemIcon.LoadImage(item.GetIconImageFileName())
  1830. else:
  1831. itemIcon.LoadImage("icon/item/27995.tga")
  1832. itemIcon.SetPosition((bg.GetWidth()/2)-(itemIcon.GetWidth()/2), ((bg.GetHeight()-20)/2)-(itemIcon.GetHeight()/2))
  1833. itemIcon.SAFE_SetStringEvent("MOUSE_OVER_IN",self.OverInItem,data)
  1834. itemIcon.SAFE_SetStringEvent("MOUSE_OVER_OUT",self.OverOutItem)
  1835. itemIcon.SetEvent(ui.__mem_func__(self.OnClickItem),"mouse_click",0,data)
  1836. itemIcon.Show()
  1837. self.children.append(itemIcon)
  1838. itemName = ui.TextLine()
  1839. itemName.SetParent(bg)
  1840. itemName.SetText(item.GetItemName())
  1841. maxWidth = bg.GetWidth()-15
  1842. newText = ""
  1843. while True:
  1844. if itemName.GetTextSize()[0] > maxWidth:
  1845. newText = itemName.GetText()[:len(itemName.GetText())-2]+"..."
  1846. itemName.SetText(itemName.GetText()[:len(itemName.GetText())-2])
  1847. continue
  1848. break
  1849. if newText != "":
  1850. itemName.SetText(newText)
  1851. itemName.SetPosition(bg.GetWidth()/2, bg.GetHeight()-18)
  1852. itemName.SetHorizontalAlignCenter()
  1853. itemName.Show()
  1854. self.children.append(itemName)
  1855. self.vnumList.append(data)
  1856. self.OnRender()
  1857. self.Show()
  1858. def OverOutItem(self):
  1859. if self.renderIndex != 0:
  1860. renderTarget.SetVisibility(self.renderIndex, False)
  1861. renderTarget.ResetModel(self.renderIndex)
  1862. WikiUI.DefaultWikiWindow.OverOutItem(self)
  1863. def OverInItem(self, itemVnum):
  1864. interface = constInfo.GetInterfaceInstance()
  1865. if interface:
  1866. tooltipItem = interface.tooltipItem
  1867. if tooltipItem:
  1868. tooltipItem.ClearToolTip()
  1869. self.renderIndex = renderTarget.GetFreeIndex(1000, 1000000)
  1870. tooltipItem.toolTipWidth-= 35
  1871. renterTarget = ui.RenderTarget()
  1872. renterTarget.SetParent(tooltipItem)
  1873. renterTarget.SetPosition(10, 5)
  1874. renterTarget.SetSize(tooltipItem.toolTipWidth-20,150)
  1875. renterTarget.SetRenderTarget(self.renderIndex)
  1876. renterTarget.Show()
  1877. tooltipItem.childrenList.append(renterTarget)
  1878. tooltipItem.toolTipHeight+=150
  1879. tooltipItem.ResizeToolTip()
  1880. WikiUI.SetItemToModelPreview(self.renderIndex, itemVnum)
  1881. tooltipItem.SetItemToolTipWiki(itemVnum)

wiki