1. import offlineshop
  2. import ui
  3. import app
  4. import item
  5. import player
  6. import dbg
  7. import uicommon
  8. import uitooltip
  9. import localeInfo
  10. import ime
  11. import snd
  12. import uipickmoney
  13. import grp
  14. import mouseModule
  15. ENABLE_ITEM_WITHDRAW_QUESTION_SHOP_SAFEBOX = False
  16. SUBTYPE_NOSET = 255
  17. SEARCH_RESULT_LIMIT = 250
  18. COLOR_TEXT_SHORTCUT = grp.GenerateColor(1.0,1.0,0.5,1.0)
  19. YANG_PER_CHEQUE = 1000000000
  20. ENABLE_CHEQUE_SYSTEM = 0
  21. ENABLE_WOLFMAN_CHARACTER = 0
  22. ENABLE_MOUNT_COSTUME_SYSTEM = 0
  23. ENABLE_ACCE_COSTUME_SYSTEM = 0
  24. ENABLE_WEAPON_COSTUME_SYSTEM = 0
  25. ENABLE_MAGIC_REDUCTION_SYSTEM = 0
  26. try:
  27. if app.ENABLE_CHEQUE_SYSTEM:
  28. ENABLE_CHEQUE_SYSTEM = 1
  29. except:
  30. pass
  31. try:
  32. if app.ENABLE_WOLFMAN_CHARACTER:
  33. ENABLE_WOLFMAN_CHARACTER = 1
  34. except:
  35. pass
  36. try:
  37. if app.ENABLE_MOUNT_COSTUME_SYSTEM:
  38. ENABLE_MOUNT_COSTUME_SYSTEM = 1
  39. except:
  40. pass
  41. try:
  42. if app.ENABLE_ACCE_COSTUME_SYSTEM:
  43. ENABLE_ACCE_COSTUME_SYSTEM = 1
  44. except:
  45. pass
  46. try:
  47. if app.ENABLE_WEAPON_COSTUME_SYSTEM:
  48. ENABLE_WEAPON_COSTUME_SYSTEM = 1
  49. except:
  50. pass
  51. try:
  52. if app.ENABLE_MAGIC_REDUCTION_SYSTEM:
  53. ENABLE_MAGIC_REDUCTION_SYSTEM = 1
  54. except:
  55. pass
  56. #globals methods used to know if are making a new shop (inventory stuff)
  57. def IsBuildingShop():
  58. interface = offlineshop.GetOfflineshopBoard()
  59. if not interface:
  60. return False
  61. return interface.IsBuildingShop()
  62. def IsSaleSlot(win,slot):
  63. interface = offlineshop.GetOfflineshopBoard()
  64. if not interface:
  65. return False
  66. return interface.IsForSaleSlot(win,slot)
  67. #auctions
  68. def IsForAuctionSlot(win,slot):
  69. interface = offlineshop.GetOfflineshopBoard()
  70. if not interface:
  71. return False
  72. return interface.IsForAuctionSlot(win, slot)
  73. def IsBuildingAuction():
  74. interface = offlineshop.GetOfflineshopBoard()
  75. if not interface:
  76. return False
  77. return interface.IsBuildingAuction()
  78. def PutsError(line):
  79. dbg.TraceError("offlineshop interface error : %s "%line)
  80. def NumberToString(num):
  81. if num < 0:
  82. return "-" + NumberToString(-num)
  83. parts = []
  84. # while num > 1000:
  85. while num >= 1000:
  86. parts.insert(0,"%03d"%(num%1000))
  87. num = num//1000
  88. parts.insert(0,"%d"%num)
  89. return '.'.join(parts)
  90. def GetDurationString(dur):
  91. days = dur // (24 * 60)
  92. hours = (dur//60)%24
  93. minutes = dur%60
  94. res = " "
  95. if days > 0:
  96. res += localeInfo.OFFLINESHOP_DAY_TEXT%days + " "
  97. if hours > 0:
  98. res += localeInfo.OFFLINESHOP_HOUR_TEXT%hours + " "
  99. if minutes > 0:
  100. res += localeInfo.OFFLINESHOP_MINUTE_TEXT%minutes
  101. if days == 0 and hours == 0 and minutes == 0:
  102. return localeInfo.OFFLINESHOP_MINUTE_TEXT%0
  103. return res
  104. def MakeSlotInfo(window, slotIndex, yang, cheque=0):
  105. res = {}
  106. itemIndex = player.GetItemIndex(window, slotIndex)
  107. itemCount = player.GetItemCount(window, slotIndex)
  108. res["slot"] = slotIndex
  109. res["window"]= window
  110. res["vnum"] = itemIndex
  111. res["count"] = itemCount
  112. res["socket"]= {}
  113. res["attr"] = {}
  114. try:
  115. if ENABLE_CHANGELOOK_SYSTEM:
  116. res['trans'] = player.GetItemTransmutation(window, slotIndex)
  117. except:
  118. pass
  119. if ENABLE_CHEQUE_SYSTEM:
  120. res['cheque'] = cheque
  121. for x in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  122. attr = player.GetItemAttribute(window, slotIndex, x)
  123. res['attr'][x] = {}
  124. res['attr'][x]["type"] = attr[0]
  125. res['attr'][x]["value"] = attr[1]
  126. for x in xrange(player.METIN_SOCKET_MAX_NUM):
  127. res['socket'][x] = player.GetItemMetinSocket(window, slotIndex, x)
  128. res["price"] = yang
  129. return res
  130. def MakeOfferCancelButton():
  131. btn = ui.Button()
  132. btn.SetUpVisual("offlineshop/myoffers/deleteoffer_default.png")
  133. btn.SetDownVisual("offlineshop/myoffers/deleteoffer_down.png")
  134. btn.SetOverVisual("offlineshop/myoffers/deleteoffer_over.png")
  135. btn.Show()
  136. return btn
  137. def MakeOfferViewImage(isView):
  138. flag = "0"
  139. if isView:
  140. flag="1"
  141. img = ui.ImageBox()
  142. img.LoadImage("offlineshop/myoffers/viewicon_%s.png"%flag)
  143. img.Show()
  144. return img
  145. def MakeDefaultEmptySlot(event = None):
  146. slot = Slot(False)
  147. if event:
  148. slot.SetOnMouseLeftButtonUpEvent(event)
  149. return slot
  150. def GetBestOfferPriceYang(lst):
  151. if not lst:
  152. return 0
  153. max =0
  154. for info in lst:
  155. if info['price_yang'] > max:
  156. max = info['price_yang']
  157. return max
  158. def SortByDatetime(lst):
  159. def CustomSortByDatetime(a,b):
  160. def CmpFunc(a,b):
  161. if a > b:
  162. return -1
  163. if b > a:
  164. return 1
  165. return 0
  166. keys = ('year' , 'month' , 'day', 'hour', 'minute')
  167. for k in keys:
  168. if a[k] != b[k]:
  169. return CmpFunc(a[k] , b[k])
  170. return 0
  171. lst.sort(cmp=CustomSortByDatetime)
  172. def SortOffersByPrice(lst):
  173. def CustomSortByOfferPrice(a,b):
  174. price_a = a.get('price_yang', 0)
  175. price_b = b.get('price_yang', 0)
  176. if price_a > price_b:
  177. return -1
  178. if price_b < price_b:
  179. return 1
  180. return 0
  181. lst.sort(cmp=CustomSortByOfferPrice)
  182. return lst
  183. class TableWindow(ui.Window):
  184. def __init__(self, col, row, width, height, realw, realh):
  185. ui.Window.__init__(self)
  186. self.rows = row
  187. self.columns = col
  188. self.width = width
  189. self.height = height
  190. ui.Window.SetSize(self, realw, realh)
  191. def __del__(self):
  192. ui.Window.__del__(self)
  193. def __GetCoordByPos(self, col,row, child):
  194. stepx = self.width/self.columns
  195. stepy = self.height/self.rows
  196. x = stepx * col
  197. y = stepy * row
  198. x += stepx/2 - child.GetWidth() /2
  199. y += stepy/2 - child.GetHeight()/2
  200. return x,y
  201. def SetTableElement(self, column , row, child= None):
  202. if self.rows <= row:
  203. PutsError("cannot SetTableElement on row %d"%row)
  204. return
  205. if self.columns <= column:
  206. PutsError("cannot SetTableElement on column %d (row %d )"%(column,row))
  207. return
  208. if child == None:
  209. return
  210. x,y = self.__GetCoordByPos(column, row, child)
  211. child.SetParent(self)
  212. child.SetPosition( x, y)
  213. child.Show()
  214. class TableWindowWithScrollbar(TableWindow):
  215. SCROLLBAR_HORIZONTAL = 0
  216. SCROLLBAR_VERTICAL = 1
  217. def __init__(self, w, h , columns, rows, scrollbar=0):
  218. htable = h if scrollbar == self.SCROLLBAR_VERTICAL else h-18
  219. wtable = w if scrollbar == self.SCROLLBAR_HORIZONTAL else w -18
  220. TableWindow.__init__(self , columns, rows , wtable, htable, w ,h)
  221. self.childrenDict = {}
  222. self.scrollbar = None
  223. self.rows_count = rows
  224. self.columns_count = columns
  225. self.total_row = 0
  226. self.elementCount = 0
  227. self.defaultCreate = None
  228. self.defaultCreateArgs = None
  229. self.defaultChildren = []
  230. self.__loadScrollbar(scrollbar)
  231. self.ClearElement()
  232. def __del__(self):
  233. self.childrenDict = {}
  234. self.scrollbar = None
  235. self.defaultCreate = None
  236. self.defaultCreateArgs = None
  237. self.defaultChildren = []
  238. TableWindow.__del__(self)
  239. def __loadScrollbar(self, scrollbar):
  240. if scrollbar == self.SCROLLBAR_VERTICAL:
  241. template = {
  242. 'button1' : {
  243. 'default' : 'offlineshop/scrollbar/vertical/button1_default.png',
  244. 'over' : 'offlineshop/scrollbar/vertical/button1_over.png',
  245. 'down' : 'offlineshop/scrollbar/vertical/button1_down.png',
  246. },
  247. 'button2' : {
  248. 'default' : 'offlineshop/scrollbar/vertical/button2_default.png',
  249. 'over' : 'offlineshop/scrollbar/vertical/button2_over.png',
  250. 'down' : 'offlineshop/scrollbar/vertical/button2_down.png',
  251. },
  252. 'middle' : {
  253. 'default' : 'offlineshop/scrollbar/vertical/middle_default.png',
  254. 'over' : 'offlineshop/scrollbar/vertical/middle_over.png',
  255. 'down' : 'offlineshop/scrollbar/vertical/middle_down.png',
  256. },
  257. 'base' : "offlineshop/scrollbar/vertical/base_image.png",
  258. 'onscroll' : self.__refreshViewList,
  259. 'parent' : self,
  260. 'orientation' : ui.CustomScrollBar.VERTICAL,
  261. 'align' : {'mode': ui.CustomScrollBar.RIGHT,},
  262. }
  263. else:
  264. template = {
  265. 'button1' : {
  266. 'default' : 'offlineshop/scrollbar/horizontal/button1_default.png',
  267. 'over' : 'offlineshop/scrollbar/horizontal/button1_over.png',
  268. 'down' : 'offlineshop/scrollbar/horizontal/button1_down.png',
  269. },
  270. 'button2' : {
  271. 'default' : 'offlineshop/scrollbar/horizontal/button2_default.png',
  272. 'over' : 'offlineshop/scrollbar/horizontal/button2_over.png',
  273. 'down' : 'offlineshop/scrollbar/horizontal/button2_down.png',
  274. },
  275. 'middle' : {
  276. 'default' : 'offlineshop/scrollbar/horizontal/middle_default.png',
  277. 'over' : 'offlineshop/scrollbar/horizontal/middle_over.png',
  278. 'down' : 'offlineshop/scrollbar/horizontal/middle_down.png',
  279. },
  280. 'base' : "offlineshop/scrollbar/horizontal/base_image.png",
  281. 'onscroll' : self.__refreshViewList,
  282. 'parent' : self,
  283. 'orientation' : ui.CustomScrollBar.HORIZONTAL,
  284. 'align' : {'mode':ui.CustomScrollBar.BOTTOM,},
  285. }
  286. self.scrollbar = ui.CustomScrollBar(template)
  287. def SetElement(self, column, row, child):
  288. if not row in self.childrenDict:
  289. self.childrenDict[row] = {}
  290. self.childrenDict[row][column] = child
  291. self.__refreshViewList()
  292. def SetDefaultCreateChild(self, func, *args):
  293. self.defaultCreate = func
  294. self.defaultCreateArgs = args
  295. def __refreshViewList(self):
  296. if self.scrollbar.orientation == ui.CustomScrollBar.VERTICAL:
  297. if len(self.childrenDict.keys()) <= self.rows_count:
  298. self.scrollbar.Hide()
  299. else:
  300. self.scrollbar.Show()
  301. init_row = self.__getInitRow()
  302. for row, dct in self.childrenDict.items():
  303. for column, child in dct.items():
  304. if row < init_row or row >= init_row + self.rows_count:
  305. child.Hide()
  306. continue
  307. self.SetTableElement(column, row-init_row , child)
  308. #updated 25-01-2020 #topatch
  309. for s in self.defaultChildren:
  310. s.Destroy()
  311. self.defaultChildren = []
  312. if self.defaultCreate:
  313. for row in xrange(init_row, init_row + self.rows_count):
  314. for col in xrange(self.columns_count):
  315. if not row in self.childrenDict or not col in self.childrenDict[row]:
  316. defaultChild = self.defaultCreate(*self.defaultCreateArgs) if self.defaultCreateArgs else self.defaultCreate()
  317. defaultChild.Show()
  318. self.SetTableElement(col, row - init_row, defaultChild)
  319. self.defaultChildren.append(defaultChild)
  320. elif self.scrollbar.orientation == ui.CustomScrollBar.HORIZONTAL:
  321. if len(self.childrenDict.get(0, [])) <= self.columns_count:
  322. self.scrollbar.Hide()
  323. else:
  324. self.scrollbar.Show()
  325. init_column = self.__getInitColumn()
  326. end_column = init_column+ self.columns_count
  327. # norm_column = xrange(0, self.columns_count)
  328. for dct in self.childrenDict.values():
  329. for elm in dct.values():
  330. elm.Hide()
  331. for col in xrange(init_column, end_column):
  332. for row, dct in self.childrenDict.items():
  333. if col in dct:
  334. self.SetTableElement(col-init_column, row , dct[col])
  335. dct[col].Show()
  336. #updated 25-01-2020 #topatch
  337. for s in self.defaultChildren:
  338. s.Destroy()
  339. self.defaultChildren = []
  340. if self.defaultCreate:
  341. for row in xrange(0, self.rows_count):
  342. for col in xrange(init_column, end_column):
  343. if not row in self.childrenDict or not col in self.childrenDict[row]:
  344. defaultChild = self.defaultCreate(*self.defaultCreateArgs) if self.defaultCreateArgs else self.defaultCreate()
  345. defaultChild.Show()
  346. self.SetTableElement(col-init_column, row, defaultChild)
  347. self.defaultChildren.append(defaultChild)
  348. def __getInitRow(self):
  349. if not self.scrollbar.IsShow():
  350. return 0
  351. return int((len(self.childrenDict.keys()) - self.rows_count ) * self.scrollbar.GetPos())
  352. def __getInitColumn(self):
  353. if not self.scrollbar.IsShow():
  354. return 0
  355. return int((len(self.childrenDict.get(0,[])) - self.columns_count ) * self.scrollbar.GetPos())
  356. def __AdjustScrollbarStep(self):
  357. total_slots = self.rows_count*self.columns_count
  358. extra_element = self.elementCount - (total_slots)
  359. if extra_element <= 0:
  360. return
  361. if self.scrollbar.orientation == ui.CustomScrollBar.HORIZONTAL:
  362. extra_col = int(extra_element // self.rows_count)
  363. if extra_element % self.rows_count != 0:
  364. extra_col += 1
  365. self.scrollbar.SetScrollStep(1.0 / float(extra_col+1))
  366. else:
  367. extra_row_count = int(extra_element/self.columns_count)
  368. if extra_element % self.columns_count != 0:
  369. extra_row_count += 1
  370. self.scrollbar.SetScrollStep(1.0/float(extra_row_count+1))
  371. def ClearElement(self):
  372. for a in self.childrenDict.values():
  373. for child in a.values():
  374. child.Hide()
  375. self.childrenDict = {}
  376. self.elementCount = 0
  377. self.__refreshViewList()
  378. def AddElement(self, child):
  379. normElement = self.columns_count*self.rows_count
  380. if self.elementCount < normElement or self.scrollbar.orientation == ui.CustomScrollBar.VERTICAL:
  381. column = self.elementCount%self.columns_count
  382. row = self.elementCount//self.columns_count
  383. else:
  384. index = self.elementCount - normElement
  385. row = index % self.rows_count
  386. column= index //self.rows_count
  387. column += self.columns_count
  388. self.SetElement(column, row, child)
  389. self.elementCount += 1
  390. self.__AdjustScrollbarStep()
  391. def GetElementDict(self):
  392. return self.childrenDict
  393. class Slot(ui.Window):
  394. def __init__(self, isSold=False):
  395. ui.Window.__init__(self)
  396. self.background = None
  397. self.background_sold = None
  398. self.iconImage = None
  399. self.countText = None
  400. self.upgradeImage = None
  401. self.slotInfo = {}
  402. self.index = 0
  403. self.eventClick = None
  404. self.childrens = []
  405. self.__loadBackground(isSold)
  406. print("initializing Slot")
  407. #updated 25-01-2020 #topatch
  408. def __del__(self):
  409. self.__clear()
  410. ui.Window.__del__(self)
  411. #updated 25-01-2020 #topatch
  412. def __clear(self):
  413. self.background = None
  414. self.iconImage = None
  415. self.countText = None
  416. self.upgradeImage = None
  417. self.background_sold = None
  418. ui.Window.SetOnMouseLeftButtonUpEvent(self, None)
  419. if self.background:
  420. self.background.SetOnMouseLeftButtonUpEvent(None)
  421. if self.iconImage:
  422. self.iconImage.SetOnMouseLeftButtonUpEvent(None)
  423. if self.countText:
  424. self.countText.SetOnMouseLeftButtonUpEvent(None)
  425. if self.upgradeImage:
  426. self.upgradeImage.SetOnMouseLeftButtonUpEvent(None)
  427. if self.background_sold:
  428. self.background_sold.SetOnMouseLeftButtonUpEvent(None)
  429. self.slotInfo = {}
  430. self.index = 0
  431. self.eventClick = None
  432. self.childrens = []
  433. #updated 25-01-2020 #topatch
  434. def Destroy(self):
  435. self.__clear()
  436. def __loadBackground(self, isSold):
  437. bg = ui.ImageBox()
  438. bg.LoadImage("offlineshop/slot/base_image.png")
  439. bg.SetParent(self)
  440. bg.SetPosition(0,0)
  441. bg.Show()
  442. self.SetSize(bg.GetWidth(), bg.GetHeight())
  443. self.background = bg
  444. sold = ui.ImageBox()
  445. sold.LoadImage("offlineshop/slot/base_image_sold.png")
  446. sold.SetParent(self.background)
  447. sold.SetPosition(0, 0)
  448. if isSold:
  449. sold.Show()
  450. else:
  451. sold.Hide()
  452. self.background_sold = sold
  453. def SetInfo(self, info):
  454. self.slotInfo = info
  455. self.SetSlot(info["vnum"] , info["count"])
  456. def GetInfo(self):
  457. return self.slotInfo
  458. def SetSlot(self, itemvnum, itemcount):
  459. item.SelectItem(itemvnum)
  460. image = item.GetIconImageFileName()
  461. name = item.GetItemName()
  462. self.__SetItemIconImage(image)
  463. self.__SetItemCount(itemcount)
  464. self.__SetUpgradeByName(name)
  465. def SetIndex(self, index):
  466. self.index = index
  467. def GetIndex(self):
  468. return self.index
  469. def SetSold(self, flag):
  470. if flag:
  471. self.background_sold.Show()
  472. else:
  473. self.background_sold.Hide()
  474. def __GetIconPosition(self, image):
  475. w = image.GetWidth()
  476. h = image.GetHeight()
  477. return (self.background.GetWidth()/2 - w/2, self.background.GetHeight()/2 - h/2)
  478. def __SetItemIconImage(self, icon):
  479. image = ui.ImageBox()
  480. image.LoadImage(icon)
  481. image.SetParent(self.background)
  482. x,y = self.__GetIconPosition(image)
  483. image.SetPosition(x,y)
  484. image.Show()
  485. self.iconImage = image
  486. def __GetCountPosition(self):
  487. x,y = self.iconImage.GetLocalPosition()
  488. x += self.iconImage.GetWidth()/2
  489. y += self.iconImage.GetHeight()
  490. return (x,y)
  491. def __SetItemCount(self, count):
  492. if count <= 1:
  493. self.countText = None
  494. return
  495. countText = ui.TextLine()
  496. countText.SetParent(self.background)
  497. x,y = self.__GetCountPosition()
  498. countText.SetPosition(x,y)
  499. countText.SetHorizontalAlignCenter()
  500. countText.SetText("x"+str(count))
  501. countText.Show()
  502. self.countText = countText
  503. def __GetUpgradeImagePosition(self,img):
  504. w = img.GetWidth()
  505. h = img.GetHeight()
  506. bw = self.background.GetWidth()
  507. bh = self.background.GetHeight()
  508. return (bw - (w+5), bh-(h+5))
  509. def __SetUpgradeByName(self, name):
  510. name = name.strip()
  511. if len(name) > 2:
  512. if name[-2] == '+':
  513. if name[-1].isdigit():
  514. value = int(name[-1])
  515. upgrade = ui.ImageBox()
  516. upgrade.LoadImage("offlineshop/slot/upgrade/%d.png"%value)
  517. upgrade.SetParent(self.background)
  518. x,y = self.__GetUpgradeImagePosition(upgrade)
  519. upgrade.SetPosition(x,y)
  520. upgrade.Show()
  521. self.upgradeImage = upgrade
  522. def SetOnMouseLeftButtonUpEvent(self, event):
  523. self.eventClick = event
  524. ui.Window.SetOnMouseLeftButtonUpEvent(self, self.__OnClick)
  525. if self.background:
  526. self.background.SetOnMouseLeftButtonUpEvent(self.__OnClick)
  527. if self.iconImage:
  528. self.iconImage.SetOnMouseLeftButtonUpEvent(self.__OnClick)
  529. if self.countText:
  530. self.countText.SetOnMouseLeftButtonUpEvent(self.__OnClick)
  531. if self.upgradeImage:
  532. self.upgradeImage.SetOnMouseLeftButtonUpEvent(self.__OnClick)
  533. if self.background_sold:
  534. self.background_sold.SetOnMouseLeftButtonUpEvent(self.__OnClick)
  535. def __OnClick(self):
  536. if self.eventClick!=None:
  537. self.eventClick(self)
  538. def IsInSlot(self):
  539. if not self.IsShow():
  540. return False
  541. if self.IsIn():
  542. return True
  543. if self.background:
  544. if self.background.IsIn():
  545. return True
  546. if self.iconImage:
  547. if self.iconImage.IsIn():
  548. return True
  549. if self.countText:
  550. if self.countText.IsIn():
  551. return True
  552. if self.upgradeImage:
  553. if self.upgradeImage.IsIn():
  554. return True
  555. if self.background_sold:
  556. if self.background_sold.IsShow() and self.background_sold.IsIn():
  557. return True
  558. if self.childrens:
  559. for child in self.childrens:
  560. if child.IsIn():
  561. return True
  562. return False
  563. def AppendChild(self, child):
  564. child.SetParent(self.background)
  565. self.childrens.append(child)
  566. class Offer(ui.Window):
  567. def __init__(self, info):
  568. ui.Window.__init__(self)
  569. self.bgImage = None
  570. self.guestName = None
  571. self.priceText = None
  572. self.acceptButton = None
  573. self.deleteButton = None
  574. self.itemText = None
  575. self.info = {}
  576. self.index = 0
  577. self.is_accept = 0
  578. self.acceptEvent = None
  579. self.deniedEvent = None
  580. self.info = info
  581. self.index = info["id"]
  582. self.is_accept = info["is_accept"]
  583. self.__loadBackground()
  584. self.__loadButtons()
  585. self.SetGuestName(info['buyer_name'])
  586. self.SetPriceYang(info["price"])
  587. def __del__(self):
  588. self.bgImage = None
  589. self.guestName = None
  590. self.priceText = None
  591. self.acceptButton = None
  592. self.deleteButton = None
  593. self.itemText = None
  594. self.info = {}
  595. self.index = 0
  596. self.is_accept = 0
  597. self.acceptEvent = None
  598. self.deniedEvent = None
  599. ui.Window.__del__(self)
  600. def __loadBackground(self):
  601. bg = ui.ImageBox()
  602. bg.SetParent(self)
  603. bg.SetPosition(0,0)
  604. bg.LoadImage("offlineshop/offer/base_image.png")
  605. bg.Show()
  606. self.SetSize(bg.GetWidth(), bg.GetHeight())
  607. self.bgImage = bg
  608. def SetGuestName(self, name):
  609. text = ui.TextLine()
  610. text.SetParent(self.bgImage)
  611. text.SetPosition(77 , 0)
  612. text.SetHorizontalAlignCenter()
  613. text.Show()
  614. text.SetText(name)
  615. self.guestName = text
  616. def SetPriceYang(self, yang):
  617. text = ui.TextLine()
  618. text.SetParent(self.bgImage)
  619. text.SetPosition(355 , 0)
  620. # text.SetHorizontalAlignCenter()
  621. text.Show()
  622. text.SetText(localeInfo.NumberToMoneyString(yang))
  623. self.priceText = text
  624. def SetItemName(self, name):
  625. text = ui.TextLine()
  626. text.SetParent(self.bgImage)
  627. text.SetPosition(239 , 0)
  628. text.SetHorizontalAlignCenter()
  629. text.Show()
  630. text.SetText(name)
  631. self.itemText = text
  632. def __loadButtons(self):
  633. if self.info["is_accept"]:
  634. return
  635. #accept
  636. button = ui.Button()
  637. button.SetParent(self.bgImage)
  638. button.SetPosition(self.bgImage.GetWidth() - 50, 0)
  639. path = "offlineshop/offer/accept_%s.png"
  640. button.SetUpVisual(path%"default")
  641. button.SetOverVisual(path%"over")
  642. button.SetDownVisual(path%"down")
  643. button.Show()
  644. self.acceptButton = button
  645. #denied
  646. button = ui.Button()
  647. button.SetParent(self.bgImage)
  648. button.SetPosition(self.bgImage.GetWidth() - 30, 0)
  649. path = "offlineshop/offer/cancel_%s.png"
  650. button.SetUpVisual(path%"default")
  651. button.SetOverVisual(path%"over")
  652. button.SetDownVisual(path%"down")
  653. button.Show()
  654. self.deleteButton = button
  655. def SetAcceptButtonEvent(self, event):
  656. if self.acceptButton:
  657. self.acceptButton.SAFE_SetEvent(self.__OnAccept)
  658. self.acceptEvent = event
  659. def SetDeleteButtonEvent(self, event):
  660. if self.deleteButton:
  661. self.deleteButton.SAFE_SetEvent(self.__OnCancel)
  662. self.deniedEvent = event
  663. def GetInfo(self):
  664. return self.info
  665. def __OnAccept(self):
  666. if self.acceptEvent:
  667. self.acceptEvent(self)
  668. def __OnCancel(self):
  669. if self.deniedEvent:
  670. self.deniedEvent(self)
  671. class AuctionOffer(ui.Window):
  672. def __init__(self, info):
  673. ui.Window.__init__(self)
  674. self.background = None
  675. self.ownerName = None
  676. self.offerText = None
  677. self.__LoadWindow(info)
  678. def __del__(self):
  679. self.background = None
  680. self.ownerName = None
  681. self.offerText = None
  682. ui.Window.__del__(self)
  683. def __LoadWindow(self, info):
  684. name = info["buyer_name"]
  685. best_yang = info['price_yang']
  686. self.__LoadBackground()
  687. self.__LoadOwnerName(name)
  688. self.__LoadOfferText(best_yang)
  689. def GetInfo(self):
  690. return self.info
  691. def __LoadBackground(self):
  692. bg = ui.ImageBox()
  693. bg.LoadImage("offlineshop/shoplist/shoplist_element_default.png")
  694. bg.SetParent(self)
  695. bg.SetPosition(0, 0)
  696. bg.Show()
  697. self.SetSize(bg.GetWidth(), bg.GetHeight())
  698. self.background = bg
  699. def __LoadOwnerName(self, ownerName):
  700. if not ownerName:
  701. return
  702. text = ui.TextLine()
  703. text.SetParent(self.background)
  704. text.SetPosition(186, 1)
  705. text.SetHorizontalAlignCenter()
  706. text.SetText(ownerName)
  707. text.Show()
  708. self.ownerName = text
  709. def __LoadOfferText(self, yang):
  710. text = ui.TextLine()
  711. text.SetParent(self.background)
  712. text.SetPosition(403, 1)
  713. text.SetHorizontalAlignCenter()
  714. text.SetText(localeInfo.NumberToMoneyString(yang))
  715. text.Show()
  716. self.offerText = text
  717. class MyOffer(ui.Window):
  718. def __init__(self, info):
  719. ui.Window.__init__(self)
  720. self.info = info
  721. self.clear()
  722. self.__LoadBackground()
  723. self.__LoadOwnerName()
  724. self.__LoadOfferText()
  725. self.__LoadSlot()
  726. self.__LoadCancelButton()
  727. def clear(self):
  728. self.background = None
  729. self.ownerName = None
  730. self.offerText = None
  731. self.slot = None
  732. self.cancelButton = None
  733. self.cancelButtonEvent = None
  734. def __del__(self):
  735. self.clear()
  736. ui.Window.__del__(self)
  737. def __LoadBackground(self):
  738. bg = ui.ImageBox()
  739. bg.SetParent(self)
  740. bg.SetPosition(0,0)
  741. bg.LoadImage("offlineshop/myoffers/offer_base_image.png")
  742. bg.Show()
  743. self.SetSize(bg.GetWidth(), bg.GetHeight())
  744. self.background = bg
  745. def __LoadOwnerName(self):
  746. text = ui.TextLine()
  747. text.SetParent(self.background)
  748. text.SetPosition(175, 38)
  749. text.SetHorizontalAlignCenter()
  750. text.SetText(self.info.get('shop_name', ""))
  751. text.Show()
  752. self.ownerName = text
  753. def __LoadOfferText(self):
  754. text = ui.TextLine()
  755. text.SetParent(self.background)
  756. text.SetPosition(175, 60)
  757. text.SetHorizontalAlignCenter()
  758. text.SetText(NumberToString(self.info.get('price', "")))
  759. text.Show()
  760. self.offerText = text
  761. def __LoadSlot(self):
  762. slot = Slot(self.info['is_accept'])
  763. slot.SetInfo(self.info['item'])
  764. slot.SetParent(self.background)
  765. slot.SetPosition(9,4)
  766. slot.Show()
  767. self.slot = slot
  768. def __LoadCancelButton(self):
  769. button = ui.Button()
  770. button.SetParent(self.background)
  771. button.SetPosition(self.GetWidth()/2, 46 + 40)
  772. button.SetUpVisual("d:/ymir work/ui/public/small_button_01.sub")
  773. button.SetDownVisual("d:/ymir work/ui/public/small_button_03.sub")
  774. button.SetOverVisual("d:/ymir work/ui/public/small_button_02.sub")
  775. button.SetText(localeInfo.OFFLINESHOP_MYOFFERS_CANCEL_BUTTON_TEXT)
  776. button.Show()
  777. button.SAFE_SetEvent(self.__OnClickCancelButton)
  778. self.cancelButton = button
  779. def SetCancelButtonEvent(self, event):
  780. self.cancelButtonEvent = event
  781. def __OnClickCancelButton(self):
  782. if self.cancelButtonEvent:
  783. self.cancelButtonEvent(self.info['offer_id'])
  784. def IsInSlot(self):
  785. return self.slot.IsInSlot()
  786. def GetIndex(self):
  787. return self.info['offer_id']
  788. #updated 25-01-2020 #topatch
  789. def DisableCancelButton(self):
  790. if self.cancelButton:
  791. self.cancelButton.Hide()
  792. class AuctionListElement(ui.Window):
  793. def __init__(self, info):
  794. ui.Window.__init__(self)
  795. self.ownerName = None
  796. self.durationText = None
  797. self.offerCountText = None
  798. self.owner_id = -1
  799. self.info = info
  800. self.button = None
  801. self.buttonEvent = None
  802. self.bestYangText = None
  803. self.__LoadWindow(info)
  804. def __del__(self):
  805. self.ownerName = None
  806. self.durationText = None
  807. self.offerCountText = None
  808. self.owner_id = -1
  809. self.info = {}
  810. self.button = None
  811. self.buttonEvent = None
  812. self.bestYangText = None
  813. ui.Window.__del__(self)
  814. def __LoadWindow(self, info):
  815. owner_id = info["owner_id"]
  816. duration = info["duration"]
  817. count = info["offer_count"]
  818. name = info["owner_name"]
  819. best_yang = info['best_yang']
  820. self.owner_id = owner_id
  821. self.__LoadOpenAuctionButton()
  822. self.__LoadOwnerName(name)
  823. self.__LoadDuration(duration)
  824. self.__LoadCount(count)
  825. self.__LoadBestYang(best_yang)
  826. def SetIndex(self,index):
  827. self.owner_id = index
  828. def GetIndex(self):
  829. return self.owner_id
  830. def GetInfo(self):
  831. return self.info
  832. def SetOnClickOpenShopButton(self, event):
  833. self.openShopButton.SAFE_SetEvent(self.__OnClickOpenShop)
  834. self.openShopButtonEvent = event
  835. def __LoadOwnerName(self, ownerName):
  836. if not ownerName:
  837. return
  838. text = ui.TextLine()
  839. text.SetParent(self.button)
  840. text.SetPosition(85, 0)
  841. text.SetHorizontalAlignCenter()
  842. text.SetText(ownerName)
  843. text.Show()
  844. self.ownerName = text
  845. def __LoadDuration(self, duration):
  846. text = ui.TextLine()
  847. text.SetParent(self.button)
  848. text.SetPosition(344, 0)
  849. text.SetHorizontalAlignCenter()
  850. text.SetText(GetDurationString(duration))
  851. text.Show()
  852. self.durationText = text
  853. def __LoadCount(self, count):
  854. text = ui.TextLine()
  855. text.SetParent(self.button)
  856. text.SetPosition(480, 0)
  857. text.SetHorizontalAlignCenter()
  858. text.SetText(str(count))
  859. text.Show()
  860. self.offerCountText = text
  861. def __LoadBestYang(self, yang):
  862. text = ui.TextLine()
  863. text.SetParent(self.button)
  864. text.SetPosition(217, 0)
  865. text.SetHorizontalAlignCenter()
  866. text.SetText(localeInfo.NumberToMoneyString(yang))
  867. text.Show()
  868. self.bestYangText = text
  869. def SetOnClickOpenAuctionButton(self, event):
  870. self.button.SAFE_SetEvent(self.__OnClickMe)
  871. self.buttonEvent = event
  872. def __OnClickMe(self):
  873. if self.buttonEvent:
  874. self.buttonEvent(self.owner_id)
  875. def __LoadOpenAuctionButton(self):
  876. button = ui.Button()
  877. button.SetParent(self)
  878. button.SetUpVisual("offlineshop/shoplist/shoplist_element_default.png")
  879. button.SetDownVisual("offlineshop/shoplist/shoplist_element_down.png")
  880. button.SetOverVisual("offlineshop/shoplist/shoplist_element_over.png")
  881. button.SetPosition(0, 0)
  882. button.Show()
  883. self.SetSize(button.GetWidth(), button.GetHeight())
  884. self.button = button
  885. def IsInSlot(self):
  886. if self.IsIn():
  887. return True
  888. if self.ownerName:
  889. if self.ownerName.IsIn():
  890. return True
  891. if self.durationText:
  892. if self.durationText.IsIn():
  893. return True
  894. if self.offerCountText:
  895. if self.offerCountText.IsIn():
  896. return True
  897. if self.button:
  898. if self.button.IsIn():
  899. return True
  900. return False
  901. class ShopListElement(ui.Window):
  902. def __init__(self , info):
  903. ui.Window.__init__(self)
  904. self.ownerName = None
  905. self.shopName = None
  906. self.durationText = None
  907. self.countText = None
  908. self.openShopButton = None
  909. self.openShopButtonEvent = None
  910. self.owner_id = -1
  911. self.__LoadWindow(info)
  912. def __del__(self):
  913. self.ownerName = None
  914. self.shopName = None
  915. self.durationText = None
  916. self.countText = None
  917. self.openShopButton = None
  918. self.openShopButtonEvent = None
  919. self.owner_id = -1
  920. ui.Window.__del__(self)
  921. def __LoadWindow(self, info):
  922. owner_id = info["owner_id"]
  923. duration = info["duration"]
  924. count = info["count"]
  925. name = info["name"]
  926. ownerName = name[:name.find('@')] if '@' in name else "NONAME"
  927. name = name[name.find('@')+1:] if '@' in name else name
  928. self.owner_id = owner_id
  929. self.__LoadOpenShopButton()
  930. self.__LoadOwnerName(ownerName)
  931. self.__LoadShopName(name)
  932. self.__LoadDuration(duration)
  933. self.__LoadCount(count)
  934. def SetOnClickOpenShopButton(self, event):
  935. self.openShopButton.SAFE_SetEvent(self.__OnClickOpenShop)
  936. self.openShopButtonEvent = event
  937. def __OnClickOpenShop(self):
  938. if self.openShopButtonEvent:
  939. self.openShopButtonEvent(self.owner_id)
  940. def __LoadOpenShopButton(self):
  941. button = ui.Button()
  942. button.SetParent(self)
  943. button.SetUpVisual("offlineshop/shoplist/shoplist_element_default.png")
  944. button.SetDownVisual("offlineshop/shoplist/shoplist_element_down.png")
  945. button.SetOverVisual("offlineshop/shoplist/shoplist_element_over.png")
  946. button.SetPosition(0, 0)
  947. button.Show()
  948. self.SetSize(button.GetWidth(), button.GetHeight())
  949. self.openShopButton = button
  950. def __LoadOwnerName(self ,ownerName):
  951. if not ownerName:
  952. return
  953. text = ui.TextLine()
  954. text.SetParent(self.openShopButton)
  955. text.SetPosition(48 , 2)
  956. text.SetHorizontalAlignCenter()
  957. text.SetText(ownerName)
  958. text.Show()
  959. self.ownerName = text
  960. def __LoadShopName(self ,name):
  961. text = ui.TextLine()
  962. text.SetParent(self.openShopButton)
  963. text.SetPosition(198 , 2)
  964. text.SetHorizontalAlignCenter()
  965. text.SetText(name)
  966. text.Show()
  967. self.shopName = text
  968. def __LoadDuration(self ,duration):
  969. text = ui.TextLine()
  970. text.SetParent(self.openShopButton)
  971. text.SetPosition(358 , 2)
  972. text.SetHorizontalAlignCenter()
  973. text.SetText(GetDurationString(duration))
  974. text.Show()
  975. self.durationText = text
  976. def __LoadCount(self ,count):
  977. text = ui.TextLine()
  978. text.SetParent(self.openShopButton)
  979. text.SetPosition(480 , 2)
  980. text.SetHorizontalAlignCenter()
  981. text.SetText(str(count))
  982. text.Show()
  983. self.countText = text
  984. class Suggestions():
  985. def __init__(self):
  986. self.inputBox = None
  987. self.comboBox = None
  988. self.mainDict = {}
  989. self.tempDict = {}
  990. self.isRefreshing = False
  991. self.isSelecting = False
  992. def SetInputBox(self, box):
  993. box.OnIMEUpdate = self.__OnUpdateInputBox
  994. self.inputBox = box
  995. def SetComboBox(self, box):
  996. box.SetEvent(ui.__mem_func__(self.__OnSelectItem))
  997. box.ClearItem()
  998. box.SetCurrentItem(localeInfo.OFFLINESHOP_NAME_SUGGESTION_UNSELECT)
  999. self.comboBox = box
  1000. def SetMainDict(self, inDict):
  1001. def getUnrefined(st):
  1002. pos = st.find('+')
  1003. if pos == -1:
  1004. return st
  1005. if pos > len(st) -4 and pos > 4:
  1006. return st[:pos]
  1007. return st
  1008. cleanDict = {}
  1009. inserted = []
  1010. for name , vnum in inDict.items():
  1011. unrefined = getUnrefined(name).lower().strip()
  1012. if unrefined in inserted:
  1013. continue
  1014. cleanDict[unrefined] = vnum
  1015. inserted.append(unrefined)
  1016. self.mainDict = cleanDict
  1017. def __OnUpdateInputBox(self):
  1018. snd.PlaySound("sound/ui/type.wav")
  1019. ui.TextLine.SetText(self.inputBox, ime.GetText(self.inputBox.bCodePage))
  1020. self.__RefreshComboBox()
  1021. def __RefreshComboBox(self):
  1022. if self.isSelecting:
  1023. return
  1024. self.isRefreshing = True
  1025. self.tempDict = {}
  1026. inputText = self.inputBox.GetText().lower().strip()
  1027. if len(inputText) < 3:
  1028. return
  1029. self.comboBox.ClearItem()
  1030. self.comboBox.SetCurrentItem(localeInfo.OFFLINESHOP_NAME_SUGGESTION_UNSELECT)
  1031. idx = 0
  1032. for k,v in self.mainDict.items():
  1033. if inputText in k.lower():
  1034. self.tempDict[idx] = k
  1035. self.comboBox.InsertItem(idx, k)
  1036. idx += 1
  1037. if idx == 20:
  1038. break
  1039. self.isRefreshing = False
  1040. def __OnSelectItem(self, index):
  1041. if self.isRefreshing:
  1042. return
  1043. self.isSelecting = True
  1044. self.inputBox.SetText(self.tempDict[index])
  1045. self.isSelecting = False
  1046. def __del__(self):
  1047. self.inputBox = None
  1048. self.comboBox = None
  1049. self.mainDict = {}
  1050. self.tempDict = {}
  1051. def Clear(self):
  1052. self.comboBox.ClearItem()
  1053. self.comboBox.SetCurrentItem(localeInfo.OFFLINESHOP_NAME_SUGGESTION_UNSELECT)
  1054. class SuggestionElement(ui.Button):
  1055. def __init__(self):
  1056. self.clickEvent = None
  1057. self.index = 0
  1058. ui.Button.__init__(self)
  1059. def __del__(self):
  1060. self.clickEvent = None
  1061. ui.Button.__del__(self)
  1062. def SetClickEvent(self, event):
  1063. self.clickEvent = event
  1064. self.SAFE_SetEvent(self.__OnClickMe)
  1065. def __OnClickMe(self):
  1066. if self.clickEvent:
  1067. self.clickEvent(self.index)
  1068. def SetElement(self, index, text):
  1069. self.index = index
  1070. self.SetText(text)
  1071. class SuggestionSelector(ui.Window):
  1072. def __init__(self):
  1073. ui.Window.__init__(self)
  1074. self.scrollbar = None
  1075. self.background = None
  1076. self.attributeDict = {}
  1077. self.onSelectEvent = None
  1078. self.elements = []
  1079. self.__loadBackground()
  1080. self.__loadElements()
  1081. self.__loadScrollbar()
  1082. def __loadBackground(self):
  1083. bg = ui.ImageBox()
  1084. bg.LoadImage("offlineshop/searchfilter/attribute_selector_base_image.png")
  1085. bg.SetParent(self)
  1086. bg.SetPosition(0,0)
  1087. bg.Show()
  1088. self.background = bg
  1089. self.SetSize(bg.GetWidth() , bg.GetHeight())
  1090. def __loadElements(self):
  1091. for x in xrange(8):
  1092. element = SuggestionElement()
  1093. element.SetParent(self.background)
  1094. element.SetPosition(0, x * 16)
  1095. element.SetUpVisual("offlineshop/searchfilter/attribute_default.png")
  1096. element.SetDownVisual("offlineshop/searchfilter/attribute_down.png")
  1097. element.SetOverVisual("offlineshop/searchfilter/attribute_over.png")
  1098. element.Show()
  1099. element.SetClickEvent(self.__OnSelectAttribute)
  1100. self.elements.append(element)
  1101. def __loadScrollbar(self):
  1102. scroll = ui.ScrollBar()
  1103. scroll.SetParent(self.background)
  1104. scroll.SetPosition(self.GetWidth()-10, 0)
  1105. scroll.SetScrollBarSize(self.GetHeight())
  1106. scroll.SetScrollEvent(self.__OnScroll)
  1107. scroll.Show()
  1108. self.scrollbar = scroll
  1109. def __OnSelectAttribute(self, index):
  1110. if self.onSelectEvent:
  1111. self.onSelectEvent(index)
  1112. def __OnScroll(self):
  1113. self.__refreshViewList()
  1114. def __refreshViewList(self):
  1115. pos = self.scrollbar.GetPos()
  1116. initIndex = int(pos * (len(self.attributeDict) - len(self.elements) ))
  1117. for x in xrange(initIndex , initIndex + len(self.elements)):
  1118. index = self.attributeDict.keys()[x]
  1119. text = self.attributeDict[index]
  1120. self.elements[x-initIndex].SetElement(index, text)
  1121. def SetAttributeDict(self, dct):
  1122. self.attributeDict = dct
  1123. self.__refreshViewList()
  1124. def SetSelectEvent(self, event):
  1125. self.onSelectEvent = event
  1126. def __del__(self):
  1127. self.background = None
  1128. self.elements = []
  1129. self.scrollbar = None
  1130. self.onSelectEvent = None
  1131. ui.Window.__del__(self)
  1132. class FilterHistoryElement(ui.Window):
  1133. def __init__(self, info):
  1134. ui.Window.__init__(self)
  1135. self.button = None
  1136. self.datetext = None
  1137. self.timetext = None
  1138. self.counttext = None
  1139. self.buttonEvent = None
  1140. self.info = {}
  1141. self.__loadButton()
  1142. self.__loadDateText(info)
  1143. self.__loadTimeText(info)
  1144. self.__loadCountText(info)
  1145. self.info = info
  1146. def GetInfo(self):
  1147. return self.info
  1148. def SetButtonEvent(self , event):
  1149. self.buttonEvent = event
  1150. self.button.SAFE_SetEvent(self.__OnClickMe)
  1151. def __OnClickMe(self):
  1152. if self.buttonEvent:
  1153. self.buttonEvent(self)
  1154. def __loadButton(self):
  1155. button = ui.Button()
  1156. button.SetParent(self)
  1157. button.SetPosition(0,0)
  1158. path = "offlineshop/searchhistory/element_%s.png"
  1159. button.SetUpVisual(path%"default")
  1160. button.SetDownVisual(path%"down")
  1161. button.SetOverVisual(path%"over")
  1162. button.Show()
  1163. self.SetSize(button.GetWidth(), button.GetHeight())
  1164. self.button = button
  1165. def __loadDateText(self,info):
  1166. text = ui.TextLine()
  1167. text.SetParent(self.button)
  1168. text.SetPosition(60, 3)
  1169. day = info["day"]
  1170. month = info["month"]
  1171. year = info["year"]
  1172. text.SetText("%02d - %02d - %d "%(day, month, year))
  1173. text.Show()
  1174. self.datetext = text
  1175. def __loadTimeText(self, info):
  1176. text = ui.TextLine()
  1177. text.SetParent(self.button)
  1178. text.SetPosition(190+75, 3)
  1179. hour = info["hour"]
  1180. minute = info["minute"]
  1181. text.SetText("%02d : %02d " % (hour, minute))
  1182. text.Show()
  1183. self.timetext = text
  1184. def __loadCountText(self, info):
  1185. text = ui.TextLine()
  1186. text.SetParent(self.button)
  1187. text.SetPosition(485, 3)
  1188. count = info["count"]
  1189. text.SetText(" %d " % (count))
  1190. text.SetHorizontalAlignCenter()
  1191. text.Show()
  1192. self.counttext = text
  1193. def __del__(self):
  1194. self.button = None
  1195. self.datetext = None
  1196. self.timetext = None
  1197. self.counttext = None
  1198. self.buttonEvent= None
  1199. ui.Window.__del__(self)
  1200. def IsInSlot(self):
  1201. if not self.IsShow():
  1202. return False
  1203. if self.IsIn():
  1204. return True
  1205. if self.button:
  1206. if self.button.IsIn():
  1207. return True
  1208. if self.datetext:
  1209. if self.datetext.IsIn():
  1210. return True
  1211. if self.timetext:
  1212. if self.timetext.IsIn():
  1213. return True
  1214. if self.counttext:
  1215. if self.counttext.IsIn():
  1216. return True
  1217. return False
  1218. def GetIndex(self):
  1219. return self.info['id']
  1220. class FilterPatternElement(ui.Window):
  1221. def __init__(self, info):
  1222. ui.Window.__init__(self)
  1223. self.button = None
  1224. self.datetext = None
  1225. self.nametext = None
  1226. self.buttonEvent = None
  1227. self.info = {}
  1228. self.__loadButton()
  1229. self.__loadDateText(info)
  1230. self.__loadNameText(info)
  1231. self.info = info
  1232. def GetInfo(self):
  1233. return self.info
  1234. def SetButtonEvent(self , event):
  1235. self.buttonEvent = event
  1236. self.button.SAFE_SetEvent(self.__OnClickMe)
  1237. def __OnClickMe(self):
  1238. if self.buttonEvent:
  1239. self.buttonEvent(self)
  1240. def __loadButton(self):
  1241. button = ui.Button()
  1242. button.SetParent(self)
  1243. button.SetPosition(0,0)
  1244. path = "offlineshop/searchhistory/element_%s.png"
  1245. button.SetUpVisual(path%"default")
  1246. button.SetDownVisual(path%"down")
  1247. button.SetOverVisual(path%"over")
  1248. button.Show()
  1249. self.SetSize(button.GetWidth(), button.GetHeight())
  1250. self.button = button
  1251. def __loadDateText(self,info):
  1252. text = ui.TextLine()
  1253. text.SetParent(self.button)
  1254. text.SetPosition(352, 3)
  1255. day = info["day"]
  1256. month = info["month"]
  1257. year = info["year"]
  1258. hour = info["hour"]
  1259. minute = info["minute"]
  1260. text.SetText("%02d - %02d - %d %02d : %02d"%(day, month, year, hour, minute))
  1261. text.Show()
  1262. self.datetext = text
  1263. def __loadNameText(self, info):
  1264. text = ui.TextLine()
  1265. text.SetParent(self.button)
  1266. text.SetPosition(20, 3)
  1267. text.SetText(info["name"])
  1268. text.Show()
  1269. self.nametext = text
  1270. def __del__(self):
  1271. self.button = None
  1272. self.datetext = None
  1273. self.nametext = None
  1274. self.buttonEvent = None
  1275. ui.Window.__del__(self)
  1276. def IsInSlot(self):
  1277. if not self.IsShow():
  1278. return False
  1279. if self.IsIn():
  1280. return True
  1281. if self.button:
  1282. if self.button.IsIn():
  1283. return True
  1284. if self.datetext:
  1285. if self.datetext.IsIn():
  1286. return True
  1287. if self.nametext:
  1288. if self.nametext.IsIn():
  1289. return True
  1290. return False
  1291. def GetIndex(self):
  1292. return self.info['id']
  1293. #
  1294. # class ItemTableWithScrollbar(ui.Window):
  1295. #
  1296. # def __init__(self, columns, rows, width, height):
  1297. # self.rows = rows
  1298. # self.columns = columns
  1299. # self.slots = [[Slot() for x in xrange(rows)] for y in xrange(columns)]
  1300. #
  1301. # self.width = width
  1302. # self.height = height -13
  1303. #
  1304. # template = {
  1305. # 'button1' : {
  1306. # 'default' : 'offlineshop/scrollbar/horizontal/button1_default.png',
  1307. # 'over' : 'offlineshop/scrollbar/horizontal/button1_over.png',
  1308. # 'down' : 'offlineshop/scrollbar/horizontal/button1_down.png',
  1309. # },
  1310. # 'button2' : {
  1311. # 'default' : 'offlineshop/scrollbar/horizontal/button2_default.png',
  1312. # 'over' : 'offlineshop/scrollbar/horizontal/button2_over.png',
  1313. # 'down' : 'offlineshop/scrollbar/horizontal/button2_down.png',
  1314. # },
  1315. # 'middle' : {
  1316. # 'default' : 'offlineshop/scrollbar/horizontal/middle_default.png',
  1317. # 'over' : 'offlineshop/scrollbar/horizontal/middle_over.png',
  1318. # 'down' : 'offlineshop/scrollbar/horizontal/middle_down.png',
  1319. # },
  1320. # 'base' : "offlineshop/scrollbar/horizontal/base_image.png",
  1321. # 'onscroll' : self.__refreshViewList,
  1322. # 'parent' : self,
  1323. #
  1324. # 'orientation' : ui.CustomScrollBar.HORIZONTAL,
  1325. # 'align' : {'mode' :ui.CustomScrollBar.BOTTOM ,},
  1326. # }
  1327. #
  1328. # self.scrollbar = ui.CustomScrollBar(template)
  1329. # self.scrollbar.Show()
  1330. #
  1331. # offsetx = int(self.width/self.columns)
  1332. # offsety = int(self.height/self.rows)
  1333. #
  1334. # for col in xrange(self.columns):
  1335. # for row in xrange(self.rows):
  1336. # x,y = (offsetx*col , offsety* row)
  1337. # self.slots[col][row].SetPosition(x,y)
  1338. # self.slots.Show()
  1339. #
  1340. #
  1341. # def __del__(self):
  1342. # self.rows = 0
  1343. # self.columns = 0
  1344. # self.slots = []
  1345. #
  1346. # self.width = 0
  1347. # self.height = 0
  1348. # self.scrollbar = None
  1349. #
  1350. #
  1351. # def ClearTable(self):
  1352. # self.info = []
  1353. #
  1354. class NewOfflineShopBoard(ui.ScriptWindow):
  1355. #constants
  1356. BOARD_KEYS = ("create_shop" , "my_shop", "open_shop", "shop_list", "search_history", )
  1357. ITEM_TYPES = {
  1358. item.ITEM_TYPE_NONE : {
  1359. "name" : localeInfo.OFFLINESHOP_TYPE_COMBOBOX_NOSET,
  1360. },
  1361. item.ITEM_TYPE_WEAPON : {
  1362. "name" : localeInfo.OFFLINESHOP_TYPE_COMBOBOX_WEAPON,
  1363. "subtypes" : {
  1364. item.WEAPON_SWORD : localeInfo.OFFLINESHOP_COMBOBOX_WEAPON_SWORD,
  1365. item.WEAPON_DAGGER : localeInfo.OFFLINESHOP_COMBOBOX_WEAPON_DAGGER,
  1366. item.WEAPON_BOW : localeInfo.OFFLINESHOP_COMBOBOX_WEAPON_BOW,
  1367. item.WEAPON_TWO_HANDED : localeInfo.OFFLINESHOP_COMBOBOX_WEAPON_TWO_HANDED,
  1368. item.WEAPON_BELL : localeInfo.OFFLINESHOP_COMBOBOX_WEAPON_BELL,
  1369. item.WEAPON_FAN : localeInfo.OFFLINESHOP_COMBOBOX_WEAPON_FAN,
  1370. },
  1371. },
  1372. item.ITEM_TYPE_ARMOR : {
  1373. "name" : localeInfo.OFFLINESHOP_TYPE_COMBOBOX_ARMOR,
  1374. "subtypes" : {
  1375. item.ARMOR_BODY : localeInfo.OFFLINESHOP_COMBOBOX_ARMOR_BODY,
  1376. item.ARMOR_HEAD : localeInfo.OFFLINESHOP_COMBOBOX_ARMOR_HEAD,
  1377. item.ARMOR_SHIELD : localeInfo.OFFLINESHOP_COMBOBOX_ARMOR_SHIELD,
  1378. item.ARMOR_WRIST : localeInfo.OFFLINESHOP_COMBOBOX_ARMOR_WRIST,
  1379. item.ARMOR_FOOTS : localeInfo.OFFLINESHOP_COMBOBOX_ARMOR_FOOTS,
  1380. item.ARMOR_NECK : localeInfo.OFFLINESHOP_COMBOBOX_ARMOR_NECK,
  1381. item.ARMOR_EAR : localeInfo.OFFLINESHOP_COMBOBOX_ARMOR_EAR,
  1382. },
  1383. },
  1384. item.ITEM_TYPE_METIN : {
  1385. "name" : localeInfo.OFFLINESHOP_TYPE_COMBOBOX_METIN,
  1386. },
  1387. item.ITEM_TYPE_FISH : {
  1388. "name" : localeInfo.OFFLINESHOP_TYPE_COMBOBOX_FISH,
  1389. },
  1390. item.ITEM_TYPE_SKILLBOOK : {
  1391. "name" : localeInfo.OFFLINESHOP_TYPE_COMBOBOX_SKILLBOOK,
  1392. },
  1393. item.ITEM_TYPE_BLEND : {
  1394. "name" : localeInfo.OFFLINESHOP_TYPE_COMBOBOX_BLEND,
  1395. },
  1396. item.ITEM_TYPE_DS : {
  1397. "name" : localeInfo.OFFLINESHOP_TYPE_COMBOBOX_DS,
  1398. },
  1399. item.ITEM_TYPE_RING : {
  1400. "name" : localeInfo.OFFLINESHOP_TYPE_COMBOBOX_RING,
  1401. },
  1402. item.ITEM_TYPE_BELT : {
  1403. "name" : localeInfo.OFFLINESHOP_TYPE_COMBOBOX_BELT,
  1404. },
  1405. item.ITEM_TYPE_METIN : {
  1406. "name" : localeInfo.OFFLINESHOP_TYPE_COMBOBOX_METIN,
  1407. },
  1408. item.ITEM_TYPE_GIFTBOX : {
  1409. "name" : localeInfo.OFFLINESHOP_TYPE_COMBOBOX_GIFTBOX,
  1410. },
  1411. item.ITEM_TYPE_COSTUME : {
  1412. "name" : localeInfo.OFFLINESHOP_TYPE_COMBOBOX_COSTUME,
  1413. "subtypes" : {
  1414. item.COSTUME_TYPE_BODY : localeInfo.OFFLINESHOP_COMBOBOX_COSTUME_BODY,
  1415. item.COSTUME_TYPE_HAIR : localeInfo.OFFLINESHOP_COMBOBOX_COSTUME_HAIR,
  1416. },
  1417. },
  1418. item.ITEM_TYPE_MATERIAL :{
  1419. "name": localeInfo.OFFLINESHOP_TYPE_COMBOBOX_REFINE,
  1420. },
  1421. }
  1422. if ENABLE_WOLFMAN_CHARACTER:
  1423. ITEM_TYPES[item.ITEM_TYPE_WEAPON]["subtypes"][item.WEAPON_CLAW] = localeInfo.OFFLINESHOP_COMBOBOX_WEAPON_CLAW
  1424. if ENABLE_MOUNT_COSTUME_SYSTEM:
  1425. ITEM_TYPES[item.ITEM_TYPE_COSTUME][item.COSTUME_TYPE_MOUNT] = localeInfo.OFFLINESHOP_COMBOBOX_COSTUME_MOUNT
  1426. if ENABLE_ACCE_COSTUME_SYSTEM:
  1427. ITEM_TYPES[item.ITEM_TYPE_COSTUME][item.COSTUME_TYPE_ACCE] = localeInfo.OFFLINESHOP_COMBOBOX_COSTUME_ACCE
  1428. if ENABLE_WEAPON_COSTUME_SYSTEM:
  1429. ITEM_TYPES[item.ITEM_TYPE_COSTUME][item.COSTUME_TYPE_WEAPON] = localeInfo.OFFLINESHOP_COMBOBOX_COSTUME_WEAPON
  1430. #members
  1431. ATTRIBUTES = {
  1432. 0 : localeInfo.OFFLINESHOP_ATTR_UNSET,
  1433. item.APPLY_MAX_HP : localeInfo.OFFLINESHOP_ATTR_MAX_HP,
  1434. item.APPLY_MAX_SP : localeInfo.OFFLINESHOP_ATTR_MAX_SP,
  1435. item.APPLY_CON : localeInfo.OFFLINESHOP_ATTR_CON,
  1436. item.APPLY_INT : localeInfo.OFFLINESHOP_ATTR_INT,
  1437. item.APPLY_STR : localeInfo.OFFLINESHOP_ATTR_STR,
  1438. item.APPLY_DEX : localeInfo.OFFLINESHOP_ATTR_DEX,
  1439. item.APPLY_ATT_SPEED : localeInfo.OFFLINESHOP_ATTR_ATT_SPEED,
  1440. item.APPLY_MOV_SPEED : localeInfo.OFFLINESHOP_ATTR_MOV_SPEED,
  1441. item.APPLY_CAST_SPEED : localeInfo.OFFLINESHOP_ATTR_CAST_SPEED,
  1442. item.APPLY_HP_REGEN : localeInfo.OFFLINESHOP_ATTR_HP_REGEN,
  1443. item.APPLY_SP_REGEN : localeInfo.OFFLINESHOP_ATTR_SP_REGEN,
  1444. item.APPLY_POISON_PCT : localeInfo.OFFLINESHOP_ATTR_APPLY_POISON_PCT,
  1445. item.APPLY_STUN_PCT : localeInfo.OFFLINESHOP_ATTR_APPLY_STUN_PCT,
  1446. item.APPLY_SLOW_PCT : localeInfo.OFFLINESHOP_ATTR_APPLY_SLOW_PCT,
  1447. item.APPLY_CRITICAL_PCT : localeInfo.OFFLINESHOP_ATTR_APPLY_CRITICAL_PCT,
  1448. item.APPLY_PENETRATE_PCT : localeInfo.OFFLINESHOP_ATTR_APPLY_PENETRATE_PCT,
  1449. item.APPLY_ATTBONUS_WARRIOR : localeInfo.OFFLINESHOP_ATTR_APPLY_ATTBONUS_WARRIOR,
  1450. item.APPLY_ATTBONUS_ASSASSIN : localeInfo.OFFLINESHOP_ATTR_APPLY_ATTBONUS_ASSASSIN,
  1451. item.APPLY_ATTBONUS_SURA : localeInfo.OFFLINESHOP_ATTR_APPLY_ATTBONUS_SURA,
  1452. item.APPLY_ATTBONUS_SHAMAN : localeInfo.OFFLINESHOP_ATTR_APPLY_ATTBONUS_SHAMAN,
  1453. item.APPLY_ATTBONUS_MONSTER : localeInfo.OFFLINESHOP_ATTR_APPLY_ATTBONUS_MONSTER,
  1454. item.APPLY_ATTBONUS_HUMAN : localeInfo.OFFLINESHOP_ATTR_APPLY_ATTBONUS_HUMAN,
  1455. item.APPLY_ATTBONUS_ANIMAL : localeInfo.OFFLINESHOP_ATTR_APPLY_ATTBONUS_ANIMAL,
  1456. item.APPLY_ATTBONUS_ORC : localeInfo.OFFLINESHOP_ATTR_APPLY_ATTBONUS_ORC,
  1457. item.APPLY_ATTBONUS_MILGYO : localeInfo.OFFLINESHOP_ATTR_APPLY_ATTBONUS_MILGYO,
  1458. item.APPLY_ATTBONUS_UNDEAD : localeInfo.OFFLINESHOP_ATTR_APPLY_ATTBONUS_UNDEAD,
  1459. item.APPLY_ATTBONUS_DEVIL : localeInfo.OFFLINESHOP_ATTR_APPLY_ATTBONUS_DEVIL,
  1460. item.APPLY_STEAL_HP : localeInfo.OFFLINESHOP_ATTR_APPLY_STEAL_HP,
  1461. item.APPLY_STEAL_SP : localeInfo.OFFLINESHOP_ATTR_APPLY_STEAL_SP,
  1462. item.APPLY_MANA_BURN_PCT : localeInfo.OFFLINESHOP_ATTR_APPLY_MANA_BURN_PCT,
  1463. item.APPLY_DAMAGE_SP_RECOVER : localeInfo.OFFLINESHOP_ATTR_APPLY_DAMAGE_SP_RECOVER,
  1464. item.APPLY_BLOCK : localeInfo.OFFLINESHOP_ATTR_APPLY_BLOCK,
  1465. item.APPLY_DODGE : localeInfo.OFFLINESHOP_ATTR_APPLY_DODGE,
  1466. item.APPLY_RESIST_SWORD : localeInfo.OFFLINESHOP_ATTR_APPLY_RESIST_SWORD,
  1467. item.APPLY_RESIST_TWOHAND : localeInfo.OFFLINESHOP_ATTR_APPLY_RESIST_TWOHAND,
  1468. item.APPLY_RESIST_DAGGER : localeInfo.OFFLINESHOP_ATTR_APPLY_RESIST_DAGGER,
  1469. item.APPLY_RESIST_BELL : localeInfo.OFFLINESHOP_ATTR_APPLY_RESIST_BELL,
  1470. item.APPLY_RESIST_FAN : localeInfo.OFFLINESHOP_ATTR_APPLY_RESIST_FAN,
  1471. item.APPLY_RESIST_BOW : localeInfo.OFFLINESHOP_ATTR_RESIST_BOW,
  1472. # item.APPLY_RESIST_FIRE : localeInfo.OFFLINESHOP_ATTR_RESIST_FIRE,
  1473. # item.APPLY_RESIST_ELEC : localeInfo.OFFLINESHOP_ATTR_RESIST_ELEC,
  1474. item.APPLY_RESIST_MAGIC : localeInfo.OFFLINESHOP_ATTR_RESIST_MAGIC,
  1475. # item.APPLY_RESIST_WIND : localeInfo.OFFLINESHOP_ATTR_APPLY_RESIST_WIND,
  1476. item.APPLY_REFLECT_MELEE : localeInfo.OFFLINESHOP_ATTR_APPLY_REFLECT_MELEE,
  1477. # item.APPLY_REFLECT_CURSE : localeInfo.OFFLINESHOP_ATTR_APPLY_REFLECT_CURSE,
  1478. item.APPLY_POISON_REDUCE : localeInfo.OFFLINESHOP_ATTR_APPLY_POISON_REDUCE,
  1479. # item.APPLY_KILL_SP_RECOVER : localeInfo.OFFLINESHOP_ATTR_APPLY_KILL_SP_RECOVER,
  1480. item.APPLY_EXP_DOUBLE_BONUS : localeInfo.OFFLINESHOP_ATTR_APPLY_EXP_DOUBLE_BONUS,
  1481. item.APPLY_GOLD_DOUBLE_BONUS : localeInfo.OFFLINESHOP_ATTR_APPLY_GOLD_DOUBLE_BONUS,
  1482. item.APPLY_ITEM_DROP_BONUS : localeInfo.OFFLINESHOP_ATTR_APPLY_ITEM_DROP_BONUS,
  1483. # item.APPLY_POTION_BONUS : localeInfo.OFFLINESHOP_ATTR_APPLY_POTION_BONUS,
  1484. # item.APPLY_KILL_HP_RECOVER : localeInfo.OFFLINESHOP_ATTR_APPLY_KILL_HP_RECOVER,
  1485. item.APPLY_IMMUNE_STUN : localeInfo.OFFLINESHOP_ATTR_APPLY_IMMUNE_STUN,
  1486. item.APPLY_IMMUNE_SLOW : localeInfo.OFFLINESHOP_ATTR_APPLY_IMMUNE_SLOW,
  1487. item.APPLY_IMMUNE_FALL : localeInfo.OFFLINESHOP_ATTR_APPLY_IMMUNE_FALL,
  1488. # item.APPLY_BOW_DISTANCE : localeInfo.OFFLINESHOP_ATTR_BOW_DISTANCE,
  1489. item.APPLY_DEF_GRADE_BONUS : localeInfo.OFFLINESHOP_ATTR_DEF_GRADE,
  1490. item.APPLY_ATT_GRADE_BONUS : localeInfo.OFFLINESHOP_ATTR_ATT_GRADE,
  1491. # item.APPLY_MAGIC_ATT_GRADE : localeInfo.OFFLINESHOP_ATTR_MAGIC_ATT_GRADE,
  1492. # item.APPLY_MAGIC_DEF_GRADE : localeInfo.OFFLINESHOP_ATTR_MAGIC_DEF_GRADE,
  1493. # item.APPLY_MAX_STAMINA : localeInfo.OFFLINESHOP_ATTR_MAX_STAMINA,
  1494. # item.APPLY_MALL_ATTBONUS : localeInfo.OFFLINESHOP_ATTR_MALL_ATTBONUS,
  1495. # item.APPLY_MALL_DEFBONUS : localeInfo.OFFLINESHOP_ATTR_MALL_DEFBONUS,
  1496. # item.APPLY_MALL_EXPBONUS : localeInfo.OFFLINESHOP_ATTR_MALL_EXPBONUS,
  1497. # item.APPLY_MALL_ITEMBONUS : localeInfo.OFFLINESHOP_ATTR_MALL_ITEMBONUS,
  1498. # item.APPLY_MALL_GOLDBONUS : localeInfo.OFFLINESHOP_ATTR_MALL_GOLDBONUS,
  1499. item.APPLY_SKILL_DAMAGE_BONUS : localeInfo.OFFLINESHOP_ATTR_SKILL_DAMAGE_BONUS,
  1500. item.APPLY_NORMAL_HIT_DAMAGE_BONUS : localeInfo.OFFLINESHOP_ATTR_NORMAL_HIT_DAMAGE_BONUS,
  1501. item.APPLY_SKILL_DEFEND_BONUS : localeInfo.OFFLINESHOP_ATTR_SKILL_DEFEND_BONUS,
  1502. item.APPLY_NORMAL_HIT_DEFEND_BONUS : localeInfo.OFFLINESHOP_ATTR_NORMAL_HIT_DEFEND_BONUS,
  1503. # item.APPLY_PC_BANG_EXP_BONUS : localeInfo.OFFLINESHOP_ATTR_MALL_EXPBONUS_P_STATIC,
  1504. # item.APPLY_PC_BANG_DROP_BONUS : localeInfo.OFFLINESHOP_ATTR_MALL_ITEMBONUS_P_STATIC,
  1505. # item.APPLY_RESIST_WARRIOR : localeInfo.OFFLINESHOP_ATTR_APPLY_RESIST_WARRIOR,
  1506. # item.APPLY_RESIST_ASSASSIN : localeInfo.OFFLINESHOP_ATTR_APPLY_RESIST_ASSASSIN,
  1507. # item.APPLY_RESIST_SURA : localeInfo.OFFLINESHOP_ATTR_APPLY_RESIST_SURA,
  1508. # item.APPLY_RESIST_SHAMAN : localeInfo.OFFLINESHOP_ATTR_APPLY_RESIST_SHAMAN,
  1509. # item.APPLY_MAX_HP_PCT : localeInfo.OFFLINESHOP_ATTR_APPLY_MAX_HP_PCT,
  1510. # item.APPLY_MAX_SP_PCT : localeInfo.OFFLINESHOP_ATTR_APPLY_MAX_SP_PCT,
  1511. # item.APPLY_ENERGY : localeInfo.OFFLINESHOP_ATTR_ENERGY,
  1512. # item.APPLY_COSTUME_ATTR_BONUS : localeInfo.OFFLINESHOP_ATTR_COSTUME_ATTR_BONUS,
  1513. # item.APPLY_MAGIC_ATTBONUS_PER : localeInfo.OFFLINESHOP_ATTR_MAGIC_ATTBONUS_PER,
  1514. # item.APPLY_MELEE_MAGIC_ATTBONUS_PER : localeInfo.OFFLINESHOP_ATTR_MELEE_MAGIC_ATTBONUS_PER,
  1515. # item.APPLY_RESIST_ICE : localeInfo.OFFLINESHOP_ATTR_RESIST_ICE,
  1516. # item.APPLY_RESIST_EARTH : localeInfo.OFFLINESHOP_ATTR_RESIST_EARTH,
  1517. # item.APPLY_RESIST_DARK : localeInfo.OFFLINESHOP_ATTR_RESIST_DARK,
  1518. # item.APPLY_ANTI_CRITICAL_PCT : localeInfo.OFFLINESHOP_ATTR_ANTI_CRITICAL_PCT,
  1519. # item.APPLY_ANTI_PENETRATE_PCT : localeInfo.OFFLINESHOP_ATTR_ANTI_PENETRATE_PCT,
  1520. }
  1521. if ENABLE_WOLFMAN_CHARACTER:
  1522. ATTRIBUTES.update({
  1523. item.APPLY_BLEEDING_PCT : localeInfo.OFFLINESHOP_ATTR_APPLY_BLEEDING_PCT,
  1524. item.APPLY_BLEEDING_REDUCE : localeInfo.OFFLINESHOP_ATTR_APPLY_BLEEDING_REDUCE,
  1525. item.APPLY_ATTBONUS_WOLFMAN : localeInfo.OFFLINESHOP_ATTR_APPLY_ATTBONUS_WOLFMAN,
  1526. item.APPLY_RESIST_CLAW : localeInfo.OFFLINESHOP_ATTR_APPLY_RESIST_CLAW,
  1527. item.APPLY_RESIST_WOLFMAN : localeInfo.OFFLINESHOP_ATTR_APPLY_RESIST_WOLFMAN,
  1528. })
  1529. if ENABLE_MAGIC_REDUCTION_SYSTEM:
  1530. ATTRIBUTES.update({
  1531. item.APPLY_RESIST_MAGIC_REDUCTION : localeInfo.OFFLINESHOP_ATTR_RESIST_MAGIC_REDUCTION,
  1532. })
  1533. try:
  1534. if app.__ENABLE_FIFTH_STATUS__:
  1535. ATTRIBUTES[item.APPLY_RES] = localeInfo.OFFLINESHOP_ATTR_RES
  1536. ATTRIBUTES[item.APPLY_HARDNESS_GRADE] = localeInfo.OFFLINESHOP_ATTR_HARDNESS_GRADE
  1537. except:
  1538. pass
  1539. def __init__(self):
  1540. ui.ScriptWindow.__init__(self)
  1541. self.clear()
  1542. offlineshop.SetOfflineshopBoard(self)
  1543. self.__loadWindow()
  1544. def clear(self):
  1545. # menu
  1546. self.MyShopButton = None
  1547. self.ListOfShopButton = None
  1548. self.SearchFilterButton = None
  1549. self.SearchHistoryButton = None
  1550. self.MyPatternsButton = None
  1551. self.MyAuctionButton = None
  1552. self.ListOfAuctionsButton = None
  1553. # common
  1554. self.pageBoards = {}
  1555. self.pageCategory = "my_shop"
  1556. self.updateEvents = {}
  1557. self.itemTooltip = None
  1558. self.popupMessage = None
  1559. self.ShopItemForSale = []
  1560. self.ShopItemSold = []
  1561. self.EditPriceSlot = None
  1562. self.AddItemSlotIndex = -1
  1563. self.CommonInputPriceDlg = None
  1564. self.CommonQuestionDlg = None
  1565. self.CommonPickValuteDlg = None
  1566. self.TitleBar = None
  1567. # filtering
  1568. self.SearchFilterShopItemResult = []
  1569. self.FilterHistory = []
  1570. self.FilterPatterns = {}
  1571. # shoplist
  1572. self.ShopList = []
  1573. self.ShopOpenInfo = {}
  1574. self.ShopListTable = None
  1575. # create shop member
  1576. self.InsertedItems = []
  1577. self.CreateShopNameEdit = None
  1578. self.CreateShopDaysCountText = None
  1579. self.CreateShopHoursCountText = None
  1580. self.CreateShopItemsTable = None
  1581. self.CreateShopItemsInfos = {}
  1582. # myshop page member
  1583. self.MyShopItemsTable = None
  1584. self.MyShopShopTitle = None
  1585. self.MyShopShopDuration = None
  1586. self.MyShopCloseButton = None
  1587. self.MyShopEditNameDlg = None
  1588. self.MyShopOffers = None
  1589. self.MyShopOffersTable = None
  1590. # open shop page member
  1591. self.OpenShopItemsTable = None
  1592. self.OpenShopBackToListButton = None
  1593. self.OpenShopShopTitle = None
  1594. self.OpenShopShopDuration = None
  1595. self.OpenShopBuyItemID = -1
  1596. # search & filter page
  1597. self.SearchFilterItemsNameDict = {}
  1598. self.SearchFilterCheckBoxesRace = {}
  1599. self.SearchFilterCheckBoxes = {}
  1600. self.SearchFilterAttributeButtons = []
  1601. self.SearchFilterComboBoxSuggestion = None
  1602. self.SearchFilterSuggestionObj = None
  1603. self.SearchFilterItemNameInput = None
  1604. self.SearchFilterItemLevelStart = None
  1605. self.SearchFilterItemLevelEnd = None
  1606. self.SearchFilterItemYangMin = None
  1607. self.SearchFilterItemYangMax = None
  1608. self.SearchFilterResetFilterButton = None
  1609. self.SearchFilterSavePatternButton = None
  1610. self.SearchFilterStartSearch = None
  1611. self.SearchFilterResultItemsTable = None
  1612. # Search History page
  1613. self.SearchHistoryTable = None
  1614. # mypattern page
  1615. self.SearchPatternsTable = None
  1616. self.SearchPatternsInputNameDlg = None
  1617. # shop safebox
  1618. self.ShopSafeboxItems = []
  1619. self.ShopSafeboxItemsTable = None
  1620. self.ShopSafeboxValuteAmount=0
  1621. self.ShopSafeboxValuteText = None
  1622. self.ShopSafeboxWithdrawYangButton = None
  1623. if ENABLE_CHEQUE_SYSTEM:
  1624. self.ShopSafeboxValuteTextCheque = None
  1625. # my offers page
  1626. self.MyOffersList = None
  1627. self.MyOffersTable = None
  1628. # my auction page
  1629. self.MyAuctionInfo = {}
  1630. self.MyAuctionOffers = []
  1631. self.MyAuctionOfferTable = None
  1632. self.MyAuctionOwnerName = None
  1633. self.MyAuctionDuration = None
  1634. self.MyAuctionBestOffer = None
  1635. self.MyAuctionMinRaise = None
  1636. self.MyAuctionSlot = None
  1637. # open auction page
  1638. self.OpenAuctionInfo = {}
  1639. self.OpenAuctionOffers = []
  1640. self.OpenAuctionOfferTable = None
  1641. self.OpenAuctionOwnerName = None
  1642. self.OpenAuctionDuration = None
  1643. self.OpenAuctionBestOffer = None
  1644. self.OpenAuctionMinRaise = None
  1645. self.OpenAuctionSlot = None
  1646. # auctionlist
  1647. self.AuctionListInfo = {}
  1648. self.AuctionListTable = None
  1649. # create auction page
  1650. self.CreateAuctionCreateAuctionButton = None
  1651. self.CreateAuctionDaysInput = None
  1652. self.CreateAuctionStartingPriceInput = None
  1653. self.CreateAuctionSlot = None
  1654. self.CreateAuctionDaysIncreaseButton = None
  1655. self.CreateAuctionDaysDecreaseButton = None
  1656. #refresh symbol
  1657. self.RefreshSymbol = None
  1658. def Destroy(self):
  1659. self.Hide()
  1660. self.clear()
  1661. self.ClearDictionary()
  1662. #offlineshop-updated 05/08/19
  1663. def OnPressEscapeKey(self):
  1664. self.Close()
  1665. return True
  1666. def __del__(self):
  1667. self.Destroy()
  1668. print("------------ DESTROYED OFFLINESHOP INTERFACE ------------")
  1669. ui.ScriptWindow.__del__(self)
  1670. def __loadWindow(self):
  1671. pyLoader = ui.PythonScriptLoader()
  1672. pyLoader.LoadScriptFile(self , "uiscript/offlineshopwindow.py")
  1673. childDict = {
  1674. "create_shop" : "MyShopBoardNoShop",
  1675. "my_shop" : "MyShopBoard",
  1676. "open_shop" : "ListOfShop_OpenShop",
  1677. "shop_list" : "ListOfShop_List",
  1678. "shop_safebox" : "ShopSafeboxPage",
  1679. "my_offers" : "MyOffersPage",
  1680. "search_history" : "SearchHistoryBoard",
  1681. "my_patterns" : "MyPatternsBoard",
  1682. "search_filter" : "SearchFilterBoard",
  1683. "my_auction" : "MyAuction",
  1684. "auction_list" : "AuctionList",
  1685. "open_auction" : "OpenAuction",
  1686. "create_auction" : "CreateAuction",
  1687. }
  1688. self.pageBoards = {}
  1689. for k, v in childDict.items():
  1690. self.pageBoards[k] = self.GetChild(v)
  1691. self.pageBoards[k].Hide()
  1692. #refresh symbol
  1693. self.RefreshSymbol = self.GetChild("RefreshSymbol")
  1694. #create shop page
  1695. # self.HowToInsertItemText = self.GetChild("HowToInsertItems")
  1696. self.CreateShopNameEdit = self.GetChild("ShopNameInput")
  1697. self.CreateShopDaysCountText = self.GetChild("DaysCountText")
  1698. self.CreateShopHoursCountText = self.GetChild("HoursCountText")
  1699. self.CreateShopIncreaseDaysButton = self.GetChild("IncreaseDaysButton")
  1700. self.CreateShopDecreaseDaysButton = self.GetChild("DecreaseDaysButton")
  1701. self.CreateShopIncreaseHoursButton = self.GetChild("IncreaseHoursButton")
  1702. self.CreateShopDecreaseHoursButton = self.GetChild("DecreaseHoursButton")
  1703. self.CreateShopButton = self.GetChild("CreateShopButton")
  1704. self.CreateShopIncreaseDaysButton.SAFE_SetEvent(self.__OnClickCreateShopIncreaseDaysButton)
  1705. self.CreateShopDecreaseDaysButton.SAFE_SetEvent(self.__OnClickCreateShopDecreaseDaysButton)
  1706. self.CreateShopIncreaseHoursButton.SAFE_SetEvent(self.__OnClickCreateShopIncreaseHoursButton)
  1707. self.CreateShopDecreaseHoursButton.SAFE_SetEvent(self.__OnClickCreateShopDecreaseHoursButton)
  1708. self.CreateShopButton.SAFE_SetEvent(self.__OnClickCreateShopButton)
  1709. self.__MakeCreateShopItemsTable()
  1710. #myshop page
  1711. self.MyShopShopDuration = self.GetChild("MyShopShopDuration")
  1712. self.MyShopShopTitle = self.GetChild("MyShopShopTitle")
  1713. self.MyShopCloseButton = self.GetChild("MyShopCloseButton")
  1714. self.MyShopEditTitleButton = self.GetChild("MyShopEditTitleButton")
  1715. self.__MakeMyShopItemsTable()
  1716. self.__MakeMyShopOffersTable()
  1717. self.MyShopCloseButton.SAFE_SetEvent(self.__OnClickCloseButton)
  1718. self.MyShopEditTitleButton.SAFE_SetEvent(self.__OnClickMyShopEditNameButton)
  1719. self.MyShopEditNameDlg = uicommon.InputDialogWithDescription()
  1720. self.MyShopEditNameDlg.SetMaxLength(35)
  1721. self.MyShopEditNameDlg.SetDescription(localeInfo.OFFLINESHOP_EDIT_SHOPNAME_DESCRIPTION)
  1722. self.MyShopEditNameDlg.SetAcceptEvent(self.__OnAcceptChangeShopNameDlg)
  1723. self.MyShopEditNameDlg.SetCancelEvent(self.__OnCancelChangeShopNameDlg)
  1724. self.MyShopEditNameDlg.SetTitle(localeInfo.OFFLINESHOP_EDIT_SHOPNAME_TITLE)
  1725. self.MyShopEditNameDlg.Hide()
  1726. #shoplist page
  1727. self.__MakeShopListTable()
  1728. #OpenShop page
  1729. self.OpenShopBackToListButton = self.GetChild("OpenShopBackToListButton")
  1730. self.OpenShopShopTitle = self.GetChild("OpenShopShopTitle")
  1731. self.OpenShopShopDuration = self.GetChild("OpenShopShopDuration")
  1732. self.CommonQuestionDlg = uicommon.QuestionDialog()
  1733. self.CommonPickValuteDlg = uipickmoney.PickMoneyDialog()
  1734. self.CommonPickValuteDlg.LoadDialog()
  1735. self.OpenShopBackToListButton.SAFE_SetEvent(self.__OnClickShopListPage)
  1736. self.__MakeOpenShopItemsTable()
  1737. self.TitleBar = self.GetChild("TitleBar")
  1738. self.TitleBar.SetCloseEvent(self.Close)
  1739. #changepage buttons
  1740. self.MyShopButton = self.GetChild("MyShopButton")
  1741. self.ListOfShopButton = self.GetChild("ListOfShopButton")
  1742. self.ShopSafeboxButton = self.GetChild("ShopSafeboxButton")
  1743. self.MyOffersPageButton = self.GetChild("MyOffersPageButton")
  1744. self.SearchFilterButton = self.GetChild("SearchFilterButton")
  1745. self.SearchHistoryButton = self.GetChild("SearchHistoryButton")
  1746. self.MyPatternsButton = self.GetChild("MyPatternsButton")
  1747. self.MyAuctionButton = self.GetChild("MyAuctionButton")
  1748. self.ListOfAuctionsButton = self.GetChild("ListOfAuctionsButton")
  1749. #events setting
  1750. self.MyShopButton.SAFE_SetEvent(self.__OnClickMyShopPage)
  1751. self.ListOfShopButton.SAFE_SetEvent(self.__OnClickShopListPage)
  1752. self.ShopSafeboxButton.SAFE_SetEvent(self.__OnClickShopSafeboxPage)
  1753. self.MyOffersPageButton.SAFE_SetEvent(self.__OnClickMyOffersPage)
  1754. self.SearchFilterButton.SAFE_SetEvent(self.__OnClickSearchFilterPage)
  1755. self.SearchHistoryButton.SAFE_SetEvent(self.__OnClickSearchHistoryPage)
  1756. self.MyPatternsButton.SAFE_SetEvent(self.__OnClickMyPatternsPage)
  1757. self.MyAuctionButton.SAFE_SetEvent(self.__OnClickMyAuctionPage)
  1758. self.ListOfAuctionsButton.SAFE_SetEvent(self.__OnClickAuctionListPage)
  1759. #updateEvents
  1760. self.updateEvents = {
  1761. "my_shop" : self.__OnUpdateMyShopPage,
  1762. "create_shop" : self.__OnUpdateCreateShopPage,
  1763. "open_shop" : self.__OnUpdateOpenShopPage,
  1764. "search_filter" : self.__OnUpdateSearchFilterPage,
  1765. "shop_safebox" : self.__OnUpdateShopSafeboxPage,
  1766. "my_offers" : self.__OnUpdateMyOffersPage,
  1767. "search_history": self.__OnUpdateSearchHistoryPage,
  1768. "my_patterns" : self.__OnUpdateMyPatternPage,
  1769. "create_auction": self.__OnUpdateCreateAuctionPage,
  1770. "my_auction" : self.__OnUpdateMyAuctionPage,
  1771. "open_auction" : self.__OnUpdateOpenAuctionPage,
  1772. "auction_list" : self.__OnUpdateAuctionListPage,
  1773. }
  1774. #item tooltip
  1775. tooltip = uitooltip.ItemToolTip(width=300)
  1776. tooltip.ClearToolTip()
  1777. tooltip.SetFollow(True)
  1778. tooltip.Hide()
  1779. self.itemTooltip = tooltip
  1780. #popup message
  1781. popup = uicommon.PopupDialog()
  1782. popup.SetWidth(250)
  1783. popup.Hide()
  1784. self.popupMessage = popup
  1785. #input price
  1786. self.CommonInputPriceDlg = uicommon.MoneyInputDialogCheque()
  1787. self.CommonInputPriceDlg.SetAcceptEvent(self.__OnAcceptInputPrice)
  1788. self.CommonInputPriceDlg.SetCancelEvent(self.__OnCancelInputPrice)
  1789. #search filter page
  1790. offlineshop.RefreshItemNameMap()
  1791. self.__MakeSearchFilterResultItemsTable()
  1792. self.SearchFilterItemNameInput = self.GetChild("SearchFilterItemNameInput")
  1793. self.SearchFilterItemLevelStart = self.GetChild("SearchFilterItemLevelStart")
  1794. self.SearchFilterItemLevelEnd = self.GetChild("SearchFilterItemLevelEnd")
  1795. self.SearchFilterItemYangMin = self.GetChild("SearchFilterItemYangMin")
  1796. self.SearchFilterItemYangMax = self.GetChild("SearchFilterItemYangMax")
  1797. self.SearchFilterResetFilterButton = self.GetChild("SearchFilterResetFilterButton")
  1798. self.SearchFilterSavePatternButton = self.GetChild("SearchFilterSavePatternButton")
  1799. self.SearchFilterStartSearch = self.GetChild("SearchFilterStartSearch")
  1800. self.__MakeSearchFilterCheckBoxes()
  1801. self.SearchFilterComboBoxSuggestion = ui.ComboBox()
  1802. self.SearchFilterComboBoxSuggestion.SetParent(self.pageBoards["search_filter"])
  1803. self.SearchFilterComboBoxSuggestion.SetPosition(75,50)
  1804. self.SearchFilterComboBoxSuggestion.SetSize(130,17)
  1805. self.SearchFilterComboBoxSuggestion.Show()
  1806. self.SearchFilterSuggestionObj = Suggestions()
  1807. self.SearchFilterSuggestionObj.SetComboBox(self.SearchFilterComboBoxSuggestion)
  1808. self.SearchFilterSuggestionObj.SetInputBox(self.SearchFilterItemNameInput)
  1809. self.SearchFilterSuggestionObj.SetMainDict(self.SearchFilterItemsNameDict)
  1810. self.SearchFilterResetFilterButton.SAFE_SetEvent(self.__OnClickSearchFilterResetFilterButton)
  1811. self.SearchFilterSavePatternButton.SAFE_SetEvent(self.__OnClickSearchFilterSavePatternButton)
  1812. self.SearchFilterStartSearch.SAFE_SetEvent(self.__OnClickSearchFilterStartSearch)
  1813. #subtype
  1814. self.SearchFilterSubTypeComboBox = ui.ComboBox()
  1815. self.SearchFilterSubTypeComboBox.SetParent(self.pageBoards["search_filter"])
  1816. self.SearchFilterSubTypeComboBox.SetPosition(220,50)
  1817. self.SearchFilterSubTypeComboBox.SetSize(100,17)
  1818. self.SearchFilterSubTypeComboBox.Show()
  1819. self.SearchFilterSubTypeComboBox.InsertItem(SUBTYPE_NOSET , localeInfo.OFFLINESHOP_TYPE_COMBOBOX_NOSET)
  1820. self.SearchFilterSubTypeComboBox.SetCurrentItem(localeInfo.OFFLINESHOP_TYPE_COMBOBOX_NOSET)
  1821. #type
  1822. self.SearchFilterTypeComboBox = ui.ComboBox()
  1823. self.SearchFilterTypeComboBox.SetParent(self.pageBoards["search_filter"])
  1824. self.SearchFilterTypeComboBox.SetPosition(220,29)
  1825. self.SearchFilterTypeComboBox.SetSize(100,17)
  1826. self.SearchFilterTypeComboBox.Show()
  1827. #insert types
  1828. for k,v in self.ITEM_TYPES.items():
  1829. self.SearchFilterTypeComboBox.InsertItem(k, v["name"])
  1830. self.SearchFilterTypeComboBox.SetCurrentItem(localeInfo.OFFLINESHOP_TYPE_COMBOBOX_NOSET)
  1831. self.SearchFilterTypeComboBox.SetEvent(self.__OnSelectSearchFilterTypeComboBox)
  1832. self.SearchFilterSubTypeComboBox.SetEvent(self.__OnSelectSearchFilterSubTypeComboBox)
  1833. self.SearchFilterTypeComboBoxIndex = 0
  1834. self.SearchFilterSubTypeComboBoxIndex = SUBTYPE_NOSET
  1835. #attributes
  1836. for i in xrange(player.ATTRIBUTE_SLOT_NORM_NUM):
  1837. self.SearchFilterAttributeButtons.append(self.GetChild("SearchFilterAttributeButton%d"%(i+1)))
  1838. self.SearchFilterAttributeButtons[i].SAFE_SetEvent(self.__OnClickSearchFilterAttributeButton, i)
  1839. self.SearchFilterAttributeButtons[i].SetText(self.ATTRIBUTES[0])
  1840. selector = SuggestionSelector()
  1841. selector.SetParent(self.pageBoards["search_filter"])
  1842. selector.SetSelectEvent(self.__OnSelectSearchFilterSuggestionSelector)
  1843. selector.SetAttributeDict(self.ATTRIBUTES)
  1844. selector.Hide()
  1845. self.SearchFilterSuggestionSelector = selector
  1846. self.SearchFilterAttributeSetting = [0 for x in xrange(player.ATTRIBUTE_SLOT_NORM_NUM)]
  1847. #search history page
  1848. self.__MakeSearchHistoryTable()
  1849. #search pattern page
  1850. self.__MakeSearchPatternsTable()
  1851. self.SearchPatternsInputNameDlg = uicommon.InputDialogWithDescription()
  1852. self.SearchPatternsInputNameDlg.SetMaxLength(25)
  1853. self.SearchPatternsInputNameDlg.SetDescription(localeInfo.OFFLINESHOP_MY_PATTERN_INSERT_NAME_DESC)
  1854. self.SearchPatternsInputNameDlg.SetAcceptEvent(self.__OnAcceptMyPatternInputName)
  1855. self.SearchPatternsInputNameDlg.SetCancelEvent(self.__OnCancelMyPatternInputName)
  1856. self.SearchPatternsInputNameDlg.SetTitle(localeInfo.OFFLINESHOP_MY_PATTERN_INSERT_NAME_TITLE)
  1857. self.SearchPatternsInputNameDlg.Hide()
  1858. #safebox page
  1859. self.__MakeShopSafeboxItemsTable()
  1860. self.ShopSafeboxValuteText = self.GetChild("ShopSafeboxValuteText")
  1861. self.ShopSafeboxWithdrawYangButton = self.GetChild("ShopSafeboxWithdrawYangButton")
  1862. self.ShopSafeboxWithdrawYangButton.SAFE_SetEvent(self.__OnClickShopSafeboxWithdrawYang)
  1863. if ENABLE_CHEQUE_SYSTEM:
  1864. self.ShopSafeboxValuteTextCheque= self.GetChild("ShopSafeboxValuteTextCheque")
  1865. #myoffers page
  1866. self.__MakeMyOffersTable()
  1867. #myAuction page
  1868. self.MyAuctionOwnerName = self.GetChild("MyAuction_OwnerName")
  1869. self.MyAuctionDuration = self.GetChild("MyAuction_Duration")
  1870. self.MyAuctionBestOffer = self.GetChild("MyAuction_BestOffer")
  1871. self.MyAuctionMinRaise = self.GetChild("MyAuction_MinRaise")
  1872. self.__MakeMyAuctionOffersTable()
  1873. #open auction page
  1874. self.OpenAuctionOwnerName = self.GetChild("OpenAuction_OwnerName")
  1875. self.OpenAuctionDuration = self.GetChild("OpenAuction_Duration")
  1876. self.OpenAuctionBestOffer = self.GetChild("OpenAuction_BestOffer")
  1877. self.OpenAuctionMinRaise = self.GetChild("OpenAuction_MinRaise")
  1878. #updated 11.01.2020
  1879. self.OpenAuctionBackToListButton = self.GetChild("OpenAuctionBackToListButton")
  1880. self.OpenAuctionBackToListButton.SAFE_SetEvent(self.__OnClickAuctionListPage)
  1881. if ENABLE_CHEQUE_SYSTEM:
  1882. self.ShopSafeboxValuteTextCheque= self.GetChild("ShopSafeboxValuteTextCheque")
  1883. self.__MakeOpenAuctionOffersTable()
  1884. #auction list page
  1885. self.__MakeAuctionListTable()
  1886. #create auction page
  1887. self.CreateAuctionCreateAuctionButton = self.GetChild("CreateAuctionCreateAuctionButton")
  1888. self.CreateAuctionDaysInput = self.GetChild("CreateAuctionDaysInput")
  1889. self.CreateAuctionStartingPriceInput = self.GetChild("CreateAuctionStartingPriceInput")
  1890. self.CreateAuctionWindowPos =-1
  1891. self.CreateAuctionSlotPos=-1
  1892. self.CreateAuctionDaysDecreaseButton = self.GetChild("CreateAuctionIncreaseDaysButton")
  1893. self.CreateAuctionDaysIncreaseButton = self.GetChild("CreateAuctionDecreaseDaysButton")
  1894. self.CreateAuctionCreateAuctionButton.SAFE_SetEvent(self.__OnClickCreateAuctionButton)
  1895. self.CreateAuctionDaysDecreaseButton.SAFE_SetEvent(self.__OnClickCreateAuctionDaysDecreaseButton)
  1896. self.CreateAuctionDaysIncreaseButton.SAFE_SetEvent(self.__OnClickCreateAuctionDaysIncreaseButton)
  1897. self.__MakeCreateAuctionSlot()
  1898. #fixing escape key
  1899. items = (
  1900. self.CreateShopNameEdit,
  1901. self.SearchFilterItemNameInput,
  1902. self.SearchFilterItemLevelStart,
  1903. self.SearchFilterItemLevelEnd,
  1904. self.SearchFilterItemYangMin,
  1905. self.SearchFilterItemYangMax,
  1906. self.CreateAuctionStartingPriceInput,
  1907. )
  1908. autokill = lambda arg: arg.KillFocus()
  1909. for item in items:
  1910. item.OnPressEscapeKey = lambda : autokill(item)
  1911. def Open(self):
  1912. events = {
  1913. "my_shop" : self.__OnClickMyShopPage,
  1914. "open_shop" : self.__OnClickShopListPage,
  1915. "shop_list" : self.__OnClickShopListPage,
  1916. "shop_safebox" : self.__OnClickShopSafeboxPage,
  1917. "my_offers" : self.__OnClickMyOffersPage,
  1918. "search_history" : self.__OnClickSearchHistoryPage,
  1919. "my_patterns" : self.__OnClickMyPatternsPage,
  1920. "search_filter" : self.__OnClickSearchFilterPage,
  1921. "my_auction" : self.__OnClickMyAuctionPage,
  1922. "auction_list" : self.__OnClickAuctionListPage,
  1923. "open_auction" : self.__OnClickAuctionListPage,
  1924. }
  1925. if self.pageCategory in events.keys():
  1926. events[self.pageCategory]()
  1927. self.Show()
  1928. def Close(self):
  1929. self.Hide()
  1930. self.itemTooltip.Hide()
  1931. self.MyShopEditNameDlg.Hide()
  1932. self.CommonQuestionDlg.Hide()
  1933. self.CommonPickValuteDlg.Hide()
  1934. self.CommonInputPriceDlg.Hide()
  1935. offlineshop.SendCloseBoard()
  1936. def __ResetCreateShopPage(self):
  1937. # self.HowToInsertItemText.Show()
  1938. self.CreateShopItemsTable.ClearElement()
  1939. self.CreateShopItemsInfos = {}
  1940. def __MakeCreateShopItemsTable(self):
  1941. board = self.pageBoards["create_shop"]
  1942. table = TableWindowWithScrollbar(575, 325, 11,3, TableWindowWithScrollbar.SCROLLBAR_HORIZONTAL)
  1943. table.SetParent(board)
  1944. table.SetPosition(25, 115)
  1945. table.SetDefaultCreateChild(MakeDefaultEmptySlot, self.__OnClickCreateShopEmptySlot)
  1946. table.Show()
  1947. self.CreateShopItemsTable = table
  1948. def __MakeMyShopItemsTable(self):
  1949. board = self.pageBoards["my_shop"]
  1950. table = TableWindowWithScrollbar(588, 324, 11,3, TableWindowWithScrollbar.SCROLLBAR_HORIZONTAL)
  1951. table.SetParent(board)
  1952. table.SetPosition(17, 49)
  1953. table.SetDefaultCreateChild(MakeDefaultEmptySlot, self.__OnClickMyShopEmptySlot)
  1954. table.Show()
  1955. self.MyShopItemsTable = table
  1956. def __MakeMyShopOffersTable(self):
  1957. board = self.pageBoards["my_shop"]
  1958. table = TableWindowWithScrollbar(585, 114, 1,5 , TableWindowWithScrollbar.SCROLLBAR_VERTICAL)
  1959. table.SetParent(board)
  1960. table.SetPosition(20, 395)
  1961. table.Show()
  1962. self.MyShopOffersTable = table
  1963. def __MakeShopListTable(self):
  1964. board = self.pageBoards["shop_list"]
  1965. table = TableWindowWithScrollbar(570, 476, 1, 23, TableWindowWithScrollbar.SCROLLBAR_VERTICAL)
  1966. table.SetParent(board)
  1967. table.SetPosition(30, 26)
  1968. table.Show()
  1969. self.ShopListTable = table
  1970. def __MakeOpenShopItemsTable(self):
  1971. board = self.pageBoards["open_shop"]
  1972. table = TableWindowWithScrollbar(584, 440, 11,4, TableWindowWithScrollbar.SCROLLBAR_HORIZONTAL)
  1973. table.SetParent(board)
  1974. table.SetPosition(20,55)
  1975. table.SetDefaultCreateChild(MakeDefaultEmptySlot)
  1976. table.Show()
  1977. self.OpenShopItemsTable = table
  1978. def __MakeOpenAuctionOffersTable(self):
  1979. board = self.pageBoards["open_auction"]
  1980. table = TableWindowWithScrollbar(580, 340, 1, 20, TableWindowWithScrollbar.SCROLLBAR_VERTICAL)
  1981. table.SetParent(board)
  1982. table.SetPosition(16, 159)
  1983. table.Show()
  1984. self.OpenAuctionOfferTable = table
  1985. def __MakeMyAuctionOffersTable(self):
  1986. board = self.pageBoards["my_auction"]
  1987. table = TableWindowWithScrollbar(580, 340, 1,20, TableWindowWithScrollbar.SCROLLBAR_VERTICAL)
  1988. table.SetParent(board)
  1989. table.SetPosition(16, 159)
  1990. table.Show()
  1991. self.MyAuctionOfferTable = table
  1992. def __MakeAuctionListTable(self):
  1993. board = self.pageBoards["auction_list"]
  1994. table = TableWindowWithScrollbar(581, 471, 1, 20, TableWindowWithScrollbar.SCROLLBAR_VERTICAL)
  1995. table.SetParent(board)
  1996. table.SetPosition(21, 28)
  1997. table.Show()
  1998. self.AuctionListTable = table
  1999. def __MakeSearchFilterCheckBoxes(self):
  2000. positions = {
  2001. "name" : { "x" : 20, "y" : 9, },
  2002. "type" : { "x" : 222, "y" : 9, },
  2003. "price" : { "x" : 224, "y" : 83, },
  2004. "level" : { "x" : 338, "y" : 9, },
  2005. "wear" : { "x" : 20, "y" : 83, },
  2006. "attr" : { "x" : 404, "y" : 9, },
  2007. }
  2008. if ENABLE_WOLFMAN_CHARACTER:
  2009. race = {
  2010. "warrior" : { "x" : 66+18, "y" : 88, },
  2011. "assassin" : { "x" : 66+18, "y" : 114, },
  2012. "sura" : { "x" : 139+10, "y" : 88, },
  2013. "shaman" : { "x" : 139+10, "y" : 114, },
  2014. "wolfman" : { "x" : 20, "y" : 114, },
  2015. }
  2016. else:
  2017. race = {
  2018. "warrior" : { "x" : 66, "y" : 88, },
  2019. "assassin" : { "x" : 66, "y" : 114, },
  2020. "sura" : { "x" : 139, "y" : 88, },
  2021. "shaman" : { "x" : 139, "y" : 114, },
  2022. }
  2023. for k, v in positions.items():
  2024. checkbox = ui.CheckBox({'base' : "offlineshop/checkbox/base.png", 'tip' : "offlineshop/checkbox/tip.png",})
  2025. checkbox.SetParent(self.pageBoards["search_filter"])
  2026. checkbox.SetPosition(v["x"] , v["y"])
  2027. checkbox.Show()
  2028. self.SearchFilterCheckBoxes[k] = checkbox
  2029. for k, v in race.items():
  2030. checkbox = ui.CheckBox({'base' : "offlineshop/checkbox/%s_base.png"%k , 'tip' : "offlineshop/checkbox/%s_tip.png"%k,})
  2031. checkbox.SetParent(self.pageBoards["search_filter"])
  2032. checkbox.SetPosition(v["x"] , v["y"])
  2033. checkbox.Show()
  2034. checkbox.Enable()
  2035. self.SearchFilterCheckBoxesRace[k] = checkbox
  2036. def __MakeSearchFilterResultItemsTable(self):
  2037. board = self.pageBoards["search_filter"]
  2038. table = TableWindowWithScrollbar(585, 329, 11, 3, TableWindowWithScrollbar.SCROLLBAR_HORIZONTAL)
  2039. table.SetParent(board)
  2040. table.SetPosition(14,153)
  2041. table.SetDefaultCreateChild(MakeDefaultEmptySlot)
  2042. table.ClearElement()
  2043. table.Show()
  2044. self.SearchFilterResultItemsTable = table
  2045. def __MakeSearchHistoryTable(self):
  2046. board = self.pageBoards["search_history"]
  2047. table = TableWindowWithScrollbar(585, 470, 1, 20 , TableWindowWithScrollbar.SCROLLBAR_VERTICAL)
  2048. table.SetParent(board)
  2049. table.SetPosition(13, 32)
  2050. table.Show()
  2051. self.SearchHistoryTable = table
  2052. def __MakeSearchPatternsTable(self):
  2053. board = self.pageBoards["my_patterns"]
  2054. table = TableWindowWithScrollbar(585, 470, 1, 20, TableWindowWithScrollbar.SCROLLBAR_VERTICAL)
  2055. table.SetParent(board)
  2056. table.SetPosition(13, 36)
  2057. table.Show()
  2058. self.SearchPatternsTable = table
  2059. def __MakeShopSafeboxItemsTable(self):
  2060. board = self.pageBoards["shop_safebox"]
  2061. table = TableWindowWithScrollbar(582, 443, 11, 4, TableWindowWithScrollbar.SCROLLBAR_HORIZONTAL)
  2062. table.SetParent(board)
  2063. table.SetPosition(18, 50)
  2064. table.SetDefaultCreateChild(MakeDefaultEmptySlot)
  2065. table.Show()
  2066. self.ShopSafeboxItemsTable = table
  2067. def __MakeMyOffersTable(self):
  2068. board = self.pageBoards["my_offers"]
  2069. table = TableWindowWithScrollbar(584, 445, 2, 4, TableWindowWithScrollbar.SCROLLBAR_VERTICAL)
  2070. table.SetParent(board)
  2071. table.SetPosition(18, 50)
  2072. table.Show()
  2073. self.MyOffersTable = table
  2074. def __MakeCreateAuctionSlot(self):
  2075. if self.CreateAuctionSlot:
  2076. del self.CreateAuctionSlot
  2077. slot = Slot()
  2078. slot.Show()
  2079. slot.SetParent(self.pageBoards['create_auction'])
  2080. slot.SetPosition(430,152)
  2081. # slot.SetInfo(info)
  2082. self.CreateAuctionSlot = slot
  2083. def __MakeMyAuctionSlot(self, info):
  2084. if self.MyAuctionSlot:
  2085. del self.MyAuctionSlot
  2086. slot = Slot()
  2087. slot.SetParent(self.pageBoards['my_auction'])
  2088. slot.SetPosition(339+54,97-73)
  2089. slot.SetInfo(info)
  2090. slot.Show()
  2091. self.MyAuctionSlot = slot
  2092. def __MakeOpenAuctionSlot(self, info):
  2093. if self.OpenAuctionSlot:
  2094. del self.OpenAuctionSlot
  2095. slot = Slot()
  2096. slot.SetParent(self.pageBoards['open_auction'])
  2097. slot.SetPosition(339+54,97-73)
  2098. slot.SetInfo(info)
  2099. slot.Show()
  2100. slot.SetOnMouseLeftButtonUpEvent(self.__OnClickOpenAuctionMakeOffer)
  2101. self.OpenAuctionSlot = slot
  2102. def __OnClickCreateShopIncreaseDaysButton(self):
  2103. days = int(self.CreateShopDaysCountText.GetText())
  2104. if days == offlineshop.OFFLINESHOP_MAX_DAYS:
  2105. self.CreateShopDaysCountText.SetText("0")
  2106. else:
  2107. self.CreateShopDaysCountText.SetText(str(days+1))
  2108. def __OnClickCreateShopDecreaseDaysButton(self):
  2109. days = int(self.CreateShopDaysCountText.GetText())
  2110. if days == 0:
  2111. self.CreateShopDaysCountText.SetText(str(offlineshop.OFFLINESHOP_MAX_DAYS))
  2112. else:
  2113. self.CreateShopDaysCountText.SetText(str(days-1))
  2114. def __OnClickCreateShopIncreaseHoursButton(self):
  2115. hours = int(self.CreateShopHoursCountText.GetText())
  2116. if hours == offlineshop.OFFLINESHOP_MAX_HOURS:
  2117. self.CreateShopHoursCountText.SetText("0")
  2118. else:
  2119. self.CreateShopHoursCountText.SetText(str(hours+1))
  2120. def __OnClickCreateShopDecreaseHoursButton(self):
  2121. hours = int(self.CreateShopHoursCountText.GetText())
  2122. if hours == 0:
  2123. self.CreateShopHoursCountText.SetText(str(offlineshop.OFFLINESHOP_MAX_HOURS))
  2124. else:
  2125. self.CreateShopHoursCountText.SetText(str(hours-1))
  2126. def __OnClickCloseButton(self):
  2127. offlineshop.SendForceCloseShop()
  2128. def __OnClickMyShopEditNameButton(self):
  2129. self.MyShopEditNameDlg.inputValue.SetText("")
  2130. self.MyShopEditNameDlg.Open()
  2131. def __OnClickMyShopPage(self):
  2132. offlineshop.SendCloseBoard()
  2133. offlineshop.SendOpenShopOwner()
  2134. self.EnableRefreshSymbol()
  2135. def __OnClickShopListPage(self):
  2136. offlineshop.SendCloseBoard()
  2137. offlineshop.SendRequestShopList()
  2138. self.EnableRefreshSymbol()
  2139. def __OnClickShopSafeboxPage(self):
  2140. offlineshop.SendCloseBoard()
  2141. offlineshop.SendSafeboxOpen()
  2142. self.EnableRefreshSymbol()
  2143. def __OnClickMyOffersPage(self):
  2144. offlineshop.SendCloseBoard()
  2145. offlineshop.SendOfferListRequest()
  2146. self.EnableRefreshSymbol()
  2147. def __OnClickSearchFilterPage(self):
  2148. offlineshop.SendCloseBoard()
  2149. self.pageCategory = "search_filter"
  2150. for page in self.pageBoards.values():
  2151. page.Hide()
  2152. self.pageBoards["search_filter"].Show()
  2153. def __OnSelectSearchFilterTypeComboBox(self, index):
  2154. self.SearchFilterSubTypeComboBox.ClearItem()
  2155. self.SearchFilterSubTypeComboBox.InsertItem(SUBTYPE_NOSET , localeInfo.OFFLINESHOP_TYPE_COMBOBOX_NOSET)
  2156. if index == 0:
  2157. self.SearchFilterTypeComboBoxIndex = 0
  2158. self.SearchFilterTypeComboBox.SetCurrentItem(localeInfo.OFFLINESHOP_TYPE_COMBOBOX_NOSET)
  2159. self.SearchFilterSubTypeComboBox.SetCurrentItem(localeInfo.OFFLINESHOP_TYPE_COMBOBOX_NOSET)
  2160. self.SearchFilterSubTypeComboBoxIndex = SUBTYPE_NOSET
  2161. return
  2162. self.SearchFilterTypeComboBoxIndex = index
  2163. self.SearchFilterTypeComboBox.SetCurrentItem(self.ITEM_TYPES[index]['name'])
  2164. if self.ITEM_TYPES.has_key(index) and self.ITEM_TYPES[index].has_key('subtypes'):
  2165. for sub, name in self.ITEM_TYPES[index]['subtypes'].items():
  2166. self.SearchFilterSubTypeComboBox.InsertItem(sub, name)
  2167. else:
  2168. self.SearchFilterSubTypeComboBox.SetCurrentItem(localeInfo.OFFLINESHOP_TYPE_COMBOBOX_NOSET)
  2169. self.SearchFilterSubTypeComboBoxIndex = SUBTYPE_NOSET
  2170. def __OnSelectSearchFilterSubTypeComboBox(self, index):
  2171. if index == SUBTYPE_NOSET:
  2172. self.SearchFilterSubTypeComboBox.SetCurrentItem(localeInfo.OFFLINESHOP_TYPE_COMBOBOX_NOSET)
  2173. self.SearchFilterSubTypeComboBoxIndex = SUBTYPE_NOSET
  2174. return
  2175. self.SearchFilterSubTypeComboBoxIndex = index
  2176. self.SearchFilterSubTypeComboBox.SetCurrentItem(self.ITEM_TYPES[self.SearchFilterTypeComboBoxIndex]['subtypes'][index])
  2177. def __OnSelectSearchFilterSuggestionSelector(self, index):
  2178. self.SearchFilterAttributeButtons[self.SearchFilterAttributeButtonIndex].SetText(self.ATTRIBUTES[index])
  2179. self.SearchFilterAttributeSetting[self.SearchFilterAttributeButtonIndex] = index
  2180. self.SearchFilterAttributeButtonIndex = -1
  2181. self.SearchFilterSuggestionSelector.Hide()
  2182. def __OnClickSearchFilterAttributeButton(self, index):
  2183. if self.SearchFilterSuggestionSelector.IsShow():
  2184. self.SearchFilterSuggestionSelector.Hide()
  2185. self.SearchFilterAttributeButtonIndex = -1
  2186. else:
  2187. self.SearchFilterAttributeButtonIndex = index
  2188. x,y = self.SearchFilterAttributeButtons[index].GetLocalPosition()
  2189. y += self.SearchFilterAttributeButtons[index].GetHeight()
  2190. self.SearchFilterSuggestionSelector.SetPosition(x,y)
  2191. self.SearchFilterSuggestionSelector.Show()
  2192. def __OnClickSearchHistoryPage(self):
  2193. offlineshop.SendCloseBoard()
  2194. self.pageCategory = "search_history"
  2195. for v in self.pageBoards.values():
  2196. v.Hide()
  2197. self.pageBoards["search_history"].Show()
  2198. self.RefreshSearchHistoryPage()
  2199. def __OnClickMyPatternsPage(self):
  2200. offlineshop.SendCloseBoard()
  2201. for v in self.pageBoards.values():
  2202. v.Hide()
  2203. self.pageBoards["my_patterns"].Show()
  2204. self.pageCategory = "my_patterns"
  2205. self.RefreshMyPatternsPage()
  2206. def __OnClickSearchPatternElement(self, element):
  2207. info = element.GetInfo()
  2208. self.__SetSearchFilterPattern(info)
  2209. offlineshop.UpdateLastUseFilterPattern(info["id"])
  2210. def __OnClickMyAuctionPage(self):
  2211. offlineshop.SendCloseBoard()
  2212. offlineshop.SendAuctionOpenMy()
  2213. self.EnableRefreshSymbol()
  2214. def __OnClickAuctionListPage(self):
  2215. offlineshop.SendCloseBoard()
  2216. offlineshop.SendAuctionListRequest()
  2217. self.EnableRefreshSymbol()
  2218. def __OnClickCreateAuctionButton(self):
  2219. if self.CreateAuctionWindowPos == -1:
  2220. return
  2221. if self.CreateAuctionSlotPos == -1:
  2222. return
  2223. daystext = self.CreateAuctionDaysInput.GetText()
  2224. days = int(daystext) if daystext and daystext.isdigit() else 0
  2225. if 0 == days or offlineshop.OFFLINESHOP_MAX_DAYS<days:
  2226. self.__PopupMessage(localeInfo.OFFLINESHOP_CREATE_SHOP_INVALID_DURATION)
  2227. return
  2228. pricetext = self.CreateAuctionStartingPriceInput.GetText()
  2229. price = long(pricetext) if pricetext and pricetext.isdigit() else 0
  2230. if price <= 0:
  2231. self.__PopupMessage(localeInfo.OFFLINESHOP_CREATE_AUCTION_INVALID_PRICE)
  2232. return
  2233. offlineshop.SendAuctionCreate(self.CreateAuctionWindowPos, self.CreateAuctionSlotPos, price, days*24*60)
  2234. self.EnableRefreshSymbol()
  2235. def __OnClickCreateAuctionDaysDecreaseButton(self):
  2236. days = int(self.CreateAuctionDaysInput.GetText())
  2237. if days ==0:
  2238. self.CreateAuctionDaysInput.SetText(str(offlineshop.OFFLINESHOP_MAX_DAYS))
  2239. else:
  2240. self.CreateAuctionDaysInput.SetText(str(days-1))
  2241. def __OnClickCreateAuctionDaysIncreaseButton(self):
  2242. days = int(self.CreateAuctionDaysInput.GetText())
  2243. if days == offlineshop.OFFLINESHOP_MAX_DAYS:
  2244. self.CreateAuctionDaysInput.SetText("0")
  2245. else:
  2246. self.CreateAuctionDaysInput.SetText(str(days + 1))
  2247. def __OnClickSearchFilterResetFilterButton(self):
  2248. # combobox
  2249. for k, v in self.SearchFilterCheckBoxes.items():
  2250. v.Disable()
  2251. # raceflags
  2252. for v in self.SearchFilterCheckBoxesRace.values():
  2253. v.Enable()
  2254. # type/subtype
  2255. self.SearchFilterTypeComboBox.SetCurrentItem(localeInfo.OFFLINESHOP_TYPE_COMBOBOX_NOSET)
  2256. self.SearchFilterTypeComboBoxIndex = 0
  2257. self.SearchFilterSubTypeComboBox.SetCurrentItem(localeInfo.OFFLINESHOP_TYPE_COMBOBOX_NOSET)
  2258. self.SearchFilterSubTypeComboBoxIndex = SUBTYPE_NOSET
  2259. # name
  2260. self.SearchFilterItemNameInput.SetText("")
  2261. self.SearchFilterSuggestionObj.Clear()
  2262. # level
  2263. self.SearchFilterItemLevelStart.SetText("")
  2264. self.SearchFilterItemLevelEnd.SetText("")
  2265. # price
  2266. self.SearchFilterItemYangMin.SetText("")
  2267. self.SearchFilterItemYangMax.SetText("")
  2268. # attributes
  2269. for x in xrange(player.ATTRIBUTE_SLOT_NORM_NUM):
  2270. self.SearchFilterAttributeButtons[x].SetText(localeInfo.OFFLINESHOP_ATTR_UNSET)
  2271. self.SearchFilterAttributeSetting[x] = 0
  2272. self.SearchFilterResultItemsTable.ClearElement()
  2273. #offlineshop-updated 04/08/19
  2274. self.__OnSelectSearchFilterTypeComboBox(0)
  2275. self.__OnSelectSearchFilterSubTypeComboBox(SUBTYPE_NOSET)
  2276. def __OnClickSearchFilterSavePatternButton(self):
  2277. bActiveOne = False
  2278. for v in self.SearchFilterCheckBoxes.values():
  2279. if v.IsEnabled():
  2280. bActiveOne = True
  2281. break
  2282. if not bActiveOne:
  2283. self.__PopupMessage(localeInfo.OFFLINESHOP_NO_FILTER_ACTIVE_MESSAGE)
  2284. return
  2285. if not self.SearchPatternsInputNameDlg.IsShow():
  2286. self.SearchPatternsInputNameDlg.inputValue.SetText("")
  2287. self.SearchPatternsInputNameDlg.Open()
  2288. def __OnClickSearchFilterStartSearch(self):
  2289. bActiveOne = False
  2290. for v in self.SearchFilterCheckBoxes.values():
  2291. if v.IsEnabled():
  2292. bActiveOne = True
  2293. break
  2294. if not bActiveOne:
  2295. self.__PopupMessage(localeInfo.OFFLINESHOP_NO_FILTER_ACTIVE_MESSAGE)
  2296. return
  2297. if self.SearchFilterCheckBoxes["name"].IsEnabled():
  2298. if not self.SearchFilterItemNameInput.GetText():
  2299. self.__PopupMessage(localeInfo.OFFLINESHOP_SEARCH_FILTER_NAME_NOSET)
  2300. return
  2301. if self.SearchFilterCheckBoxes["price"].IsEnabled():
  2302. if self.SearchFilterItemYangMin.GetText()=="0" and self.SearchFilterItemYangMax.GetText()=="0":
  2303. self.__PopupMessage(localeInfo.OFFLINESHOP_SEARCH_PRICE_ERROR)
  2304. return
  2305. if self.SearchFilterCheckBoxes["level"].IsEnabled():
  2306. if self.SearchFilterItemLevelStart.GetText() == "0" and self.SearchFilterItemLevelEnd.GetText() == "0":
  2307. self.__PopupMessage(localeInfo.OFFLINESHOP_SEARCH_LEVEL_ERROR)
  2308. return
  2309. self.SearchFilterLastUsedSetting = self.GetSearchFilterSettings()
  2310. offlineshop.SendFilterRequest(*self.SearchFilterLastUsedSetting)
  2311. self.EnableRefreshSymbol()
  2312. def __OnClickFilterHistoryElement(self , element):
  2313. info = element.GetInfo()
  2314. self.__SetSearchFilterPattern(info)
  2315. def __OnClickDeleteMyOfferButton(self, id):
  2316. offer = None
  2317. for element in self.MyOffersList:
  2318. if element["offer_id"] == id:
  2319. offer = element
  2320. break
  2321. if not offer:
  2322. return
  2323. accepttext = localeInfo.OFFLINESHOP_CANCEL_OFFER_QUESTION_ACCEPT
  2324. canceltext = localeInfo.OFFLINESHOP_CANCEL_OFFER_QUESTION_CANCEL
  2325. question = localeInfo.OFFLINESHOP_CANCEL_OFFER_QUESTION
  2326. self.MyOffersCancelOfferInfo = (offer['offer_id'], offer['owner_id'])
  2327. self.__OpenQuestionDialog(len(question)*6 , accepttext, canceltext, self.__OnAcceptCancelOfferQuestion, self.__OnCancelCancelOfferQuestion, question)
  2328. def __SetSearchFilterPattern(self, info):
  2329. self.__OnClickSearchFilterPage()
  2330. # combobox
  2331. for k, v in self.SearchFilterCheckBoxes.items():
  2332. v.Disable()
  2333. # raceflags
  2334. raceFlags = {
  2335. "warrior" :item.ITEM_ANTIFLAG_WARRIOR,
  2336. "assassin" :item.ITEM_ANTIFLAG_ASSASSIN,
  2337. "sura" :item.ITEM_ANTIFLAG_SURA,
  2338. "shaman": item.ITEM_ANTIFLAG_SHAMAN,
  2339. }
  2340. flag = info["filter_wearflag"]
  2341. for k, v in raceFlags.items():
  2342. if flag & v != 0:
  2343. self.SearchFilterCheckBoxesRace[k].Disable()
  2344. if not self.SearchFilterCheckBoxes["wear"].IsEnabled():
  2345. self.SearchFilterCheckBoxes["wear"].Enable()
  2346. else:
  2347. self.SearchFilterCheckBoxesRace[k].Enable()
  2348. # type/subtype
  2349. if info["filter_type"] == 0:
  2350. self.SearchFilterTypeComboBox.SetCurrentItem(localeInfo.OFFLINESHOP_TYPE_COMBOBOX_NOSET)
  2351. self.SearchFilterTypeComboBoxIndex = 0
  2352. self.SearchFilterSubTypeComboBox.SetCurrentItem(localeInfo.OFFLINESHOP_TYPE_COMBOBOX_NOSET)
  2353. self.SearchFilterSubTypeComboBoxIndex = SUBTYPE_NOSET
  2354. else:
  2355. if not self.SearchFilterCheckBoxes["type"].IsEnabled():
  2356. self.SearchFilterCheckBoxes["type"].Enable()
  2357. typeCategory = self.ITEM_TYPES[info["filter_type"]]
  2358. self.SearchFilterTypeComboBox.SetCurrentItem(typeCategory["name"])
  2359. self.SearchFilterTypeComboBoxIndex = info["filter_type"]
  2360. subtype = info["filter_subtype"]
  2361. if subtype != SUBTYPE_NOSET and typeCategory.has_key('subtypes'):
  2362. self.SearchFilterSubTypeComboBox.SetCurrentItem(typeCategory['subtypes'][subtype])
  2363. self.SearchFilterSubTypeComboBoxIndex = subtype
  2364. else:
  2365. self.SearchFilterSubTypeComboBox.SetCurrentItem(localeInfo.OFFLINESHOP_TYPE_COMBOBOX_NOSET)
  2366. self.SearchFilterSubTypeComboBoxIndex = SUBTYPE_NOSET
  2367. # name
  2368. if info["filter_name"]:
  2369. self.SearchFilterCheckBoxes["name"].Enable()
  2370. self.SearchFilterItemNameInput.SetText(info["filter_name"])
  2371. # level
  2372. levelmin = info["level"]["start"]
  2373. levelmax = info["level"]["end"]
  2374. if levelmin != 0:
  2375. self.SearchFilterCheckBoxes["level"].Enable()
  2376. self.SearchFilterItemLevelStart.SetText(str(levelmin))
  2377. if levelmax != 0:
  2378. self.SearchFilterCheckBoxes["level"].Enable()
  2379. self.SearchFilterItemLevelEnd.SetText(str(levelmax))
  2380. # price
  2381. yangmin = info["price"]["start"]
  2382. yangmax = info["price"]["end"]
  2383. if yangmin != 0:
  2384. self.SearchFilterCheckBoxes["price"].Enable()
  2385. self.SearchFilterItemYangMin.SetText(str(yangmin))
  2386. if yangmax != 0:
  2387. self.SearchFilterCheckBoxes["price"].Enable()
  2388. self.SearchFilterItemYangMax.SetText(str(yangmax))
  2389. # attributes
  2390. attrs = info["attr"]["type"]
  2391. attr_actived = [v for v in attrs if v != 0]
  2392. for x in xrange(player.ATTRIBUTE_SLOT_NORM_NUM):
  2393. self.SearchFilterAttributeButtons[x].SetText(localeInfo.OFFLINESHOP_ATTR_UNSET)
  2394. self.SearchFilterAttributeSetting[x] = 0
  2395. if attr_actived:
  2396. self.SearchFilterCheckBoxes["attr"].Enable()
  2397. idx = 0
  2398. for attr in attr_actived:
  2399. self.SearchFilterAttributeButtons[idx].SetText(self.ATTRIBUTES[attr])
  2400. self.SearchFilterAttributeSetting[idx] = attr
  2401. idx += 1
  2402. def __PopupMessage(self, message):
  2403. self.popupMessage.SetText(message)
  2404. self.popupMessage.Open()
  2405. def __OpenQuestionDialog(self , width, accepttext, canceltext, acceptevent, cancelevent, text):
  2406. self.CommonQuestionDlg.SetAcceptText(accepttext)
  2407. self.CommonQuestionDlg.SetCancelText(canceltext)
  2408. self.CommonQuestionDlg.SAFE_SetAcceptEvent(acceptevent)
  2409. self.CommonQuestionDlg.SAFE_SetCancelEvent(cancelevent)
  2410. self.CommonQuestionDlg.SetText(text)
  2411. self.CommonQuestionDlg.SetWidth(width)
  2412. self.CommonQuestionDlg.Open()
  2413. if ENABLE_CHEQUE_SYSTEM:
  2414. def __OnPickValute(self, title, acceptEvent, maxValue, maxCheque, max=13):
  2415. self.CommonPickValuteDlg.SetMax(max)
  2416. self.CommonPickValuteDlg.SetTitleName(title)
  2417. self.CommonPickValuteDlg.SetAcceptEvent(acceptEvent)
  2418. self.CommonPickValuteDlg.Open(maxValue, maxCheque)
  2419. else:
  2420. def __OnPickValute(self, title, acceptEvent, maxValue, max=13):
  2421. self.CommonPickValuteDlg.SetMax(max)
  2422. self.CommonPickValuteDlg.SetTitleName(title)
  2423. self.CommonPickValuteDlg.SetAcceptEvent(acceptEvent)
  2424. self.CommonPickValuteDlg.Open(maxValue)
  2425. def OnShowPage(self):
  2426. showEvents = {
  2427. "my_shop" : self.__OnClickMyShopPage,
  2428. }
  2429. if self.pageCategory in showEvents:
  2430. showEvents[self.pageCategory]()
  2431. def BINARY_EnableRefreshSymbol(self):
  2432. if self.IsShow():
  2433. self.EnableRefreshSymbol()
  2434. def EnableRefreshSymbol(self):
  2435. self.RefreshSymbol.Show()
  2436. def DisableRefreshSymbol(self):
  2437. self.RefreshSymbol.Hide()
  2438. def ShopListClear(self):
  2439. self.ShopList = []
  2440. def ShopListAddItem( self, owner_id, duration , count , name):
  2441. newelement = {}
  2442. newelement["owner_id"] = owner_id
  2443. newelement["duration"] = duration
  2444. newelement["count"] = count
  2445. newelement["name"] = name
  2446. self.ShopList.append(newelement)
  2447. def ShopListShow(self):
  2448. self.RefreshShopListPage()
  2449. self.DisableRefreshSymbol()
  2450. def OpenShop( self, owner_id, duration, count, name):
  2451. self.ShopItemSold = []
  2452. self.ShopItemForSale = []
  2453. self.ShopOpenInfo["owner_id"] = owner_id
  2454. self.ShopOpenInfo["duration"] = duration
  2455. self.ShopOpenInfo["count"] = count
  2456. self.ShopOpenInfo["name"] = name
  2457. self.ShopOpenInfo["my_shop"] = False
  2458. def OpenShopItem_Alloc(self):
  2459. self.ShopItemForSale.append({})
  2460. def OpenShopItem_SetValue( self, key, index, *args):
  2461. if key == "id":
  2462. self.ShopItemForSale[index][key] = args[0]
  2463. elif key == "vnum" or key == 'trans':
  2464. self.ShopItemForSale[index][key] = args[0]
  2465. elif key == "count":
  2466. self.ShopItemForSale[index][key] = args[0]
  2467. elif key == "attr":
  2468. if not key in self.ShopItemForSale[index]:
  2469. self.ShopItemForSale[index][key] = {}
  2470. attr_index = args[0]
  2471. attr_type = args[1]
  2472. attr_value = args[2]
  2473. self.ShopItemForSale[index][key][attr_index] = {}
  2474. self.ShopItemForSale[index][key][attr_index]["type"] = attr_type
  2475. self.ShopItemForSale[index][key][attr_index]["value"] = attr_value
  2476. elif key == "socket":
  2477. if not key in self.ShopItemForSale[index]:
  2478. self.ShopItemForSale[index][key] = {}
  2479. socket_index = args[0]
  2480. socket_val = args[1]
  2481. self.ShopItemForSale[index][key][socket_index] = socket_val
  2482. elif key == "price" or key == 'cheque':
  2483. self.ShopItemForSale[index][key] = args[0]
  2484. def OpenShop_End(self):
  2485. self.RefreshOpenShopPage()
  2486. self.DisableRefreshSymbol()
  2487. if not self.IsShow():
  2488. self.Show()
  2489. def OpenShopOwner_Start( self, owner_id, duration , count , name):
  2490. self.ShopItemSold = []
  2491. self.ShopItemForSale = []
  2492. self.MyShopOffers = []
  2493. self.ShopOpenInfo["owner_id"] = owner_id
  2494. self.ShopOpenInfo["duration"] = duration
  2495. self.ShopOpenInfo["count"] = count
  2496. self.ShopOpenInfo["name"] = name
  2497. self.ShopOpenInfo["my_shop"] = True
  2498. def OpenShopOwner_End(self):
  2499. self.DisableRefreshSymbol()
  2500. self.RefreshMyShopPage()
  2501. if not self.IsShow():
  2502. self.Show()
  2503. def OpenShopOwnerItem_Alloc(self):
  2504. self.ShopItemForSale.append({})
  2505. def OpenShopOwnerItem_SetValue( self, key, index, *args):
  2506. if key == "id":
  2507. self.ShopItemForSale[index][key] = args[0]
  2508. elif key == "vnum" or key == 'trans':
  2509. self.ShopItemForSale[index][key] = args[0]
  2510. elif key == "count":
  2511. self.ShopItemForSale[index][key] = args[0]
  2512. elif key == "attr":
  2513. if not key in self.ShopItemForSale[index]:
  2514. self.ShopItemForSale[index][key] = {}
  2515. attr_index = args[0]
  2516. attr_type = args[1]
  2517. attr_value = args[2]
  2518. self.ShopItemForSale[index][key][attr_index] = {}
  2519. self.ShopItemForSale[index][key][attr_index]["type"] = attr_type
  2520. self.ShopItemForSale[index][key][attr_index]["value"] = attr_value
  2521. elif key == "socket":
  2522. if not key in self.ShopItemForSale[index]:
  2523. self.ShopItemForSale[index][key] = {}
  2524. socket_index = args[0]
  2525. socket_val = args[1]
  2526. self.ShopItemForSale[index][key][socket_index] = socket_val
  2527. elif key == "price" or key == 'cheque':
  2528. self.ShopItemForSale[index][key] = args[0]
  2529. def OpenShopOwner_SetOffer(self, itemid , buyerid, offerid, price, is_accept, buyer_name ):
  2530. newoffer = {}
  2531. newoffer["id"] = offerid
  2532. newoffer["item_id"] = itemid
  2533. newoffer["buyer_id"] = buyerid
  2534. newoffer["price"] = price
  2535. newoffer["is_accept"] = is_accept
  2536. newoffer['buyer_name'] = buyer_name
  2537. self.MyShopOffers.append(newoffer)
  2538. def OpenShopOwnerItemSold_Alloc( self ):
  2539. self.ShopItemSold.append({})
  2540. def OpenShopOwnerItemSold_SetValue( self, key , index , *args):
  2541. if key == "id":
  2542. self.ShopItemSold[index][key] = args[0]
  2543. elif key == "vnum" or key == 'trans':
  2544. self.ShopItemSold[index][key] = args[0]
  2545. elif key == "count":
  2546. self.ShopItemSold[index][key] = args[0]
  2547. elif key == "attr":
  2548. if not key in self.ShopItemSold[index]:
  2549. self.ShopItemSold[index][key] = {}
  2550. attr_index = args[0]
  2551. attr_type = args[1]
  2552. attr_value = args[2]
  2553. self.ShopItemSold[index][key][attr_index] = {}
  2554. self.ShopItemSold[index][key][attr_index]["type"] = attr_type
  2555. self.ShopItemSold[index][key][attr_index]["value"] = attr_value
  2556. elif key == "socket":
  2557. if not key in self.ShopItemSold[index]:
  2558. self.ShopItemSold[index][key] = {}
  2559. socket_index = args[0]
  2560. socket_val = args[1]
  2561. self.ShopItemSold[index][key][socket_index] = socket_val
  2562. elif key == "price" or key == 'cheque':
  2563. self.ShopItemSold[index][key] = args[0]
  2564. def OpenShopOwnerItemSold_Show( self):
  2565. pass
  2566. def OpenShopOwnerNoShop(self):
  2567. for v in self.pageBoards.values():
  2568. v.Hide()
  2569. self.pageBoards["create_shop"].Show()
  2570. self.pageCategory = "create_shop"
  2571. self.DisableRefreshSymbol()
  2572. self.__ResetCreateShopPage()
  2573. def ClearItemNames(self):
  2574. self.SearchFilterItemsNameDict = {}
  2575. def AppendItemName(self, vnum, name):
  2576. self.SearchFilterItemsNameDict[name] = vnum
  2577. def ShopClose( self):
  2578. pass
  2579. def ShopFilterResult( self , size):
  2580. self.SearchFilterShopItemResult = []
  2581. def ShopFilterResultItem_Alloc(self):
  2582. self.SearchFilterShopItemResult.append({})
  2583. def ShopFilterResultItem_SetValue( self, key, index, *args):
  2584. if key in ( "id", "vnum", "count", "price", "owner", 'trans', 'cheque'):
  2585. self.SearchFilterShopItemResult[index][key] = args[0]
  2586. elif key == "attr":
  2587. if not key in self.SearchFilterShopItemResult[index]:
  2588. self.SearchFilterShopItemResult[index][key] = {}
  2589. attr_index = args[0]
  2590. attr_type = args[1]
  2591. attr_value = args[2]
  2592. self.SearchFilterShopItemResult[index][key][attr_index] = {}
  2593. self.SearchFilterShopItemResult[index][key][attr_index]["type"] = attr_type
  2594. self.SearchFilterShopItemResult[index][key][attr_index]["value"] = attr_value
  2595. elif key == "socket":
  2596. if not key in self.SearchFilterShopItemResult[index]:
  2597. self.SearchFilterShopItemResult[index][key] = {}
  2598. socket_index = args[0]
  2599. socket_val = args[1]
  2600. self.SearchFilterShopItemResult[index][key][socket_index] = socket_val
  2601. def ShopFilterResult_Show(self):
  2602. self.SearchFilterResultItemsTable.ClearElement()
  2603. for info in self.SearchFilterShopItemResult:
  2604. slot = Slot()
  2605. slot.SetInfo(info)
  2606. slot.SetIndex((info["id"], info["owner"]))
  2607. slot.SetOnMouseLeftButtonUpEvent(self.__OnLeftClickSearchFilterShopResultItem)
  2608. slot.Show()
  2609. self.SearchFilterResultItemsTable.AddElement(slot)
  2610. if len(self.SearchFilterShopItemResult) == SEARCH_RESULT_LIMIT:
  2611. self.__PopupMessage(localeInfo.OFFLINESHOP_SEARCH_RISE_LIMIT%SEARCH_RESULT_LIMIT)
  2612. setting = self.GetSearchFilterSettings()
  2613. setting = (len(self.SearchFilterShopItemResult),) + setting
  2614. offlineshop.AppendNewFilterHistory(*setting)
  2615. self.DisableRefreshSymbol()
  2616. def OfferReceived( self, offer_id , notified, accepted, owner_id, offerer_id, item_id, yang):
  2617. pass
  2618. def OfferAccept( self, offer_id , notified, accepted, owner_id, offerer_id, item_id, yang):
  2619. pass
  2620. def ClearFilterHistory(self):
  2621. self.FilterHistory = []
  2622. def AllocFilterHistory( self):
  2623. self.FilterHistory.append({'id' : len(self.FilterHistory)})
  2624. def SetFilterHistoryValue( self, key, *args):
  2625. elm = self.FilterHistory[-1]
  2626. if key == "datetime":
  2627. elm["minute"] = args[0]
  2628. elm["hour"] = args[1]
  2629. elm["day"] = args[2]
  2630. elm["month"] = args[3]
  2631. elm["year"] = args[4]
  2632. elif key in ('count' , 'filter_type' , 'filter_subtype', 'filter_name' ,'filter_wearflag'):
  2633. elm[key] = args[0]
  2634. elif key in ('filter_price_yang_start', 'filter_price_yang_end'):
  2635. if not 'price' in elm:
  2636. elm['price'] = {}
  2637. elm['price'][key.replace('filter_price_yang_', '')] = args[0]
  2638. elif key in ('filter_level_start', 'filter_level_end'):
  2639. if not 'level' in elm:
  2640. elm['level'] = {}
  2641. elm['level'][key.replace('filter_level_', '')] = args[0]
  2642. elif key in ('filter_attr_type' , 'filter_attr_value'):
  2643. if not 'attr' in elm:
  2644. elm['attr'] = {}
  2645. elm['attr']['type'] = [0 for x in xrange(offlineshop.FILTER_ATTRIBUTE_NUM)]
  2646. elm['attr']['value'] = [0 for x in xrange(offlineshop.FILTER_ATTRIBUTE_NUM)]
  2647. elm['attr'][key.replace('filter_attr_', '')][args[0]] = args[1]
  2648. def ClearFilterPatterns( self):
  2649. self.FilterPatterns = {}
  2650. def AllocFilterPattern( self , id):
  2651. self.FilterPatterns[id] = {"id": id,}
  2652. def SetFilterPatternValue( self, key, idx, *args):
  2653. elm = self.FilterPatterns[idx]
  2654. if key == "datetime":
  2655. elm["minute"] = args[0]
  2656. elm["hour"] = args[1]
  2657. elm["day"] = args[2]
  2658. elm["month"] = args[3]
  2659. elm["year"] = args[4]
  2660. elif key in ('filter_type' , 'filter_subtype', 'filter_name' ,'filter_wearflag', 'name'):
  2661. elm[key] = args[0]
  2662. elif key in ('filter_price_yang_start', 'filter_price_yang_end'):
  2663. if not 'price' in elm:
  2664. elm['price'] = {}
  2665. elm['price'][key.replace('filter_price_yang_', '')] = args[0]
  2666. elif key in ('filter_level_start', 'filter_level_end'):
  2667. if not 'level' in elm:
  2668. elm['level'] = {}
  2669. elm['level'][key.replace('filter_level_', '')] = args[0]
  2670. elif key in ('filter_attr_type' , 'filter_attr_value'):
  2671. if not 'attr' in elm:
  2672. elm['attr'] = {}
  2673. elm['attr']['type'] = [0 for x in xrange(offlineshop.FILTER_ATTRIBUTE_NUM)]
  2674. elm['attr']['value'] = [0 for x in xrange(offlineshop.FILTER_ATTRIBUTE_NUM)]
  2675. elm['attr'][key.replace('filter_attr_', '')][args[0]] = args[1]
  2676. def GetSearchFilterSettings(self):
  2677. name = ""
  2678. raceflag = 0
  2679. type = 0
  2680. subtype = SUBTYPE_NOSET
  2681. levelmin = 0
  2682. levelmax = 0
  2683. yangmin = 0
  2684. yangmax = 0
  2685. attributes = tuple([(0,0) for x in xrange(player.ATTRIBUTE_SLOT_NORM_NUM)])
  2686. if self.SearchFilterCheckBoxes["name"].IsEnabled():
  2687. name = self.SearchFilterItemNameInput.GetText()
  2688. if self.SearchFilterCheckBoxes["type"].IsEnabled():
  2689. type = self.SearchFilterTypeComboBoxIndex
  2690. subtype = self.SearchFilterSubTypeComboBoxIndex
  2691. if self.SearchFilterCheckBoxes["price"].IsEnabled():
  2692. yangminst = self.SearchFilterItemYangMin.GetText()
  2693. yangmaxst = self.SearchFilterItemYangMax.GetText()
  2694. if yangminst and yangminst.isdigit():
  2695. yangmin = long(yangminst)
  2696. if yangmaxst and yangmaxst.isdigit():
  2697. yangmax = long(yangmaxst)
  2698. if self.SearchFilterCheckBoxes["level"].IsEnabled():
  2699. levelminst = self.SearchFilterItemLevelStart.GetText()
  2700. levelmaxst = self.SearchFilterItemLevelEnd.GetText()
  2701. if levelminst and levelminst.isdigit():
  2702. levelmin = int(levelminst)
  2703. if levelmaxst and levelmaxst.isdigit():
  2704. levelmax = int(levelmaxst)
  2705. if self.SearchFilterCheckBoxes["wear"].IsEnabled():
  2706. raceFlagDct = {
  2707. "warrior" : item.ITEM_ANTIFLAG_WARRIOR,
  2708. "assassin" : item.ITEM_ANTIFLAG_ASSASSIN,
  2709. "sura" : item.ITEM_ANTIFLAG_SURA,
  2710. "shaman" : item.ITEM_ANTIFLAG_SHAMAN,
  2711. }
  2712. if ENABLE_WOLFMAN_CHARACTER:
  2713. raceFlagDct.update({
  2714. "wolfman" : item.ITEM_ANTIFLAG_WOLFMAN,
  2715. })
  2716. for k,v in raceFlagDct.items():
  2717. if not self.SearchFilterCheckBoxesRace[k].IsEnabled():
  2718. raceflag |= v
  2719. if self.SearchFilterCheckBoxes["attr"].IsEnabled():
  2720. attributes = tuple([(self.SearchFilterAttributeSetting[x],0) for x in xrange(player.ATTRIBUTE_SLOT_NORM_NUM)])
  2721. return (type, subtype, name, (yangmin,yangmax), (levelmin, levelmax), raceflag, attributes)
  2722. def __IsSaleableSlot(self, win , pos):
  2723. if win == player.INVENTORY:
  2724. if player.IsEquipmentSlot(pos):
  2725. return False
  2726. if self.pageCategory in ("create_shop", "my_shop" ) and self.IsForSaleSlot(win, pos):
  2727. return False
  2728. if self.pageCategory == "create_auction" and self.IsForAuctionSlot(win,pos):
  2729. return False
  2730. try:
  2731. if app.__ENABLE_SPECIAL_INVENTORY_SYSTEM__:
  2732. if not win in (player.INVENTORY, player.DRAGON_SOUL_INVENTORY, player.UPGRADE_INVENTORY, player.SKILL_BOOK_INVENTORY, player.STONE_INVENTORY):
  2733. return False
  2734. except:
  2735. if not win in (player.INVENTORY, player.DRAGON_SOUL_INVENTORY):
  2736. return False
  2737. try:
  2738. if ENABLE_SOULBIND_SYSTEM:
  2739. itemSealDate = player.GetItemSealDate(win, pos)
  2740. if itemSealDate != item.E_SEAL_DATE_DEFAULT_TIMESTAMP:
  2741. return False
  2742. except:
  2743. pass
  2744. itemIndex = player.GetItemIndex(win,pos)
  2745. if itemIndex == 0:
  2746. return False
  2747. item.SelectItem(itemIndex)
  2748. if item.IsAntiFlag(item.ITEM_ANTIFLAG_MYSHOP) or item.IsAntiFlag(item.ITEM_ANTIFLAG_GIVE):
  2749. return False
  2750. return True
  2751. def ShopBuilding_AddInventoryItem(self, slot):
  2752. if player.GetItemIndex(player.INVENTORY, slot) ==0:
  2753. return
  2754. if player.IsEquipmentSlot(slot):
  2755. return
  2756. if self.IsForSaleSlot(player.INVENTORY,slot):
  2757. return
  2758. if self.__IsSaleableSlot(player.INVENTORY, slot):
  2759. self.OpenInsertPriceDialog(player.INVENTORY,slot)
  2760. def ShopBuilding_AddItem(self, win, pos):
  2761. if self.__IsSaleableSlot(win, pos):
  2762. self.OpenInsertPriceDialog(win,pos)
  2763. def AuctionBuilding_AddInventoryItem(self, slot):
  2764. if player.GetItemIndex(player.INVENTORY, slot) ==0:
  2765. return
  2766. if player.IsEquipmentSlot(slot):
  2767. return
  2768. if self.IsForAuctionSlot(player.INVENTORY, slot):
  2769. return
  2770. self.__OnSetCreateAuctionSlot(player.INVENTORY, slot)
  2771. def AuctionBuilding_AddItem(self, win, pos):
  2772. if self.__IsSaleableSlot(win, pos):
  2773. self.__OnSetCreateAuctionSlot(win, pos)
  2774. def SearchFilter_BuyFromSearch(self, ownerid, itemid): #patchme
  2775. if self.pageCategory != 'search_filter':
  2776. return
  2777. for item in self.SearchFilterShopItemResult:
  2778. if item['id'] == itemid and item['owner'] == ownerid:
  2779. self.SearchFilterShopItemResult.remove(item)
  2780. break
  2781. self.SearchFilterResultItemsTable.ClearElement()
  2782. for info in self.SearchFilterShopItemResult:
  2783. slot = Slot()
  2784. slot.SetInfo(info)
  2785. slot.SetIndex((info["id"], info["owner"]))
  2786. slot.SetOnMouseLeftButtonUpEvent(self.__OnLeftClickSearchFilterShopResultItem)
  2787. slot.Show()
  2788. self.SearchFilterResultItemsTable.AddElement(slot)
  2789. def ShopSafebox_Clear(self):
  2790. self.ShopSafeboxItems = []
  2791. self.ShopSafeboxItemsTable.ClearElement()
  2792. if ENABLE_CHEQUE_SYSTEM:
  2793. def ShopSafebox_SetValutes(self, yang, cheque):
  2794. self.ShopSafeboxValuteAmount = (yang, cheque)
  2795. self.ShopSafeboxValuteText.SetText(localeInfo.NumberToMoneyString(yang))
  2796. self.ShopSafeboxValuteTextCheque.SetText(localeInfo.NumberToChequeString(cheque))
  2797. else:
  2798. def ShopSafebox_SetValutes(self, yang):
  2799. self.ShopSafeboxValuteAmount = yang
  2800. self.ShopSafeboxValuteText.SetText(localeInfo.NumberToMoneyString(yang))
  2801. def ShopSafebox_AllocItem(self):
  2802. self.ShopSafeboxItems.append({})
  2803. def ShopSafebox_SetValue(self, key , *args):
  2804. elm = self.ShopSafeboxItems[-1]
  2805. if key in ("id", "vnum", "count", 'trans', 'cheque'):
  2806. elm[key] = args[0]
  2807. elif key == "socket":
  2808. if not key in elm:
  2809. elm[key] = [0 for x in xrange(player.METIN_SOCKET_MAX_NUM)]
  2810. elm[key][args[0]] = args[1]
  2811. elif key in ("attr_type", "attr_value"):
  2812. if not 'attr' in elm:
  2813. elm['attr'] = {}
  2814. if not args[0] in elm['attr']:
  2815. elm['attr'][args[0]] = {}
  2816. elm['attr'][args[0]][key.replace('attr_','')] = args[1]
  2817. def ShopSafebox_RefreshEnd(self):
  2818. for item in self.ShopSafeboxItems:
  2819. slot = Slot()
  2820. slot.SetIndex(item["id"])
  2821. slot.SetInfo(item)
  2822. slot.SetOnMouseLeftButtonUpEvent(self.__OnLeftClickShopSafeboxItem)
  2823. slot.Show()
  2824. self.ShopSafeboxItemsTable.AddElement(slot)
  2825. if not self.pageBoards["shop_safebox"].IsShow():
  2826. self.pageCategory = "shop_safebox"
  2827. for page in self.pageBoards.values():
  2828. page.Hide()
  2829. self.pageBoards["shop_safebox"].Show()
  2830. self.DisableRefreshSymbol()
  2831. def OfferList_Clear(self):
  2832. self.MyOffersList = []
  2833. def OfferList_AddOffer(self , shopname, offer_id, buyer_id, owner_id, item_id, yang, is_notified, is_accept):
  2834. self.MyOffersList.append({})
  2835. elm = self.MyOffersList[-1]
  2836. if '@' in shopname:
  2837. shopname = shopname[shopname.find('@') + 1:]
  2838. elm["shop_name"] = shopname
  2839. elm["offer_id"] = offer_id
  2840. elm["buyer_id"] = buyer_id
  2841. elm["owner_id"] = owner_id
  2842. elm["item_id"] = item_id
  2843. elm["price"] = yang
  2844. elm["is_notified"] = is_notified
  2845. elm["is_accept"] = is_accept
  2846. def OfferList_ItemSetValue(self, key , *args):
  2847. offer = self.MyOffersList[-1]
  2848. if not offer.has_key('item'):
  2849. offer['item']={}
  2850. elm = offer['item']
  2851. if key in ("id", "vnum", "count", "owner", "price", 'trans'):
  2852. elm[key] = args[0]
  2853. elif key == "socket":
  2854. if not key in elm:
  2855. elm[key] = [0 for x in xrange(player.METIN_SOCKET_MAX_NUM)]
  2856. elm[key][args[0]] = args[1]
  2857. elif key in ("attr_type", "attr_value"):
  2858. if not 'attr' in elm:
  2859. elm['attr'] = {}
  2860. if not args[0] in elm['attr']:
  2861. elm['attr'][args[0]] = {}
  2862. elm['attr'][args[0]][key.replace('attr_','')] = args[1]
  2863. def OfferList_End(self):
  2864. self.RefreshMyOffersPage()
  2865. self.DisableRefreshSymbol()
  2866. def AuctionList_Clear(self):
  2867. self.AuctionListInfo = []
  2868. self.AuctionListTable.ClearElement()
  2869. def AuctionList_Alloc(self):
  2870. self.AuctionListInfo.append({"item":{},})
  2871. def AuctionList_SetInto(self, ownerid, owner_name, duration, init_yang, best_yang, offer_count):
  2872. elm = self.AuctionListInfo[-1]
  2873. info = {
  2874. "owner_id" : ownerid,
  2875. "owner_name" : owner_name,
  2876. "duration" : duration,
  2877. "init_yang" : init_yang,
  2878. "best_yang" : best_yang,
  2879. "offer_count" : offer_count,
  2880. }
  2881. for k,v in info.items():
  2882. elm[k] = v
  2883. def AuctionList_SetItemInfo(self, vnum, count, *args):
  2884. elm = self.AuctionListInfo[-1]['item']
  2885. elm['count'] = count
  2886. elm['vnum'] = vnum
  2887. try:
  2888. if ENABLE_CHANGELOOK_SYSTEM and len(args) !=0 :
  2889. elm['trans'] = args[0]
  2890. except:
  2891. pass
  2892. def AuctionList_SetItemSocket(self, index, value):
  2893. elm = self.AuctionListInfo[-1]['item']
  2894. if not 'socket' in elm:
  2895. elm['socket'] = [0 for x in xrange(player.METIN_SOCKET_MAX_NUM)]
  2896. elm['socket'][index] = value
  2897. def AuctionList_SetItemAttribute(self, key, index, value):
  2898. elm = self.AuctionListInfo[-1]['item']
  2899. if not 'attr' in elm:
  2900. elm['attr'] = [{'type' :0, 'value': 0,} for x in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)]
  2901. elm['attr'][index][key] = value
  2902. def AuctionList_End(self):
  2903. self.RefreshAuctionListPage()
  2904. self.DisableRefreshSymbol()
  2905. def MyAuction_Clear(self):
  2906. self.MyAuctionInfo = {'item':{},}
  2907. def MyAuction_SetInto(self, owner_id, owner_name, duration, init_yang):
  2908. info = {
  2909. "owner_id" : owner_id,
  2910. "owner_name" : owner_name,
  2911. "duration" : duration,
  2912. "init_yang" : init_yang,
  2913. }
  2914. for k ,v in info.items():
  2915. self.MyAuctionInfo[k] = v
  2916. def MyAuction_SetItemInfo(self, vnum, count, *args):
  2917. elm = self.MyAuctionInfo['item']
  2918. elm['vnum'] = vnum
  2919. elm['count'] = count
  2920. try:
  2921. if ENABLE_CHANGELOOK_SYSTEM and len(args)>0:
  2922. elm['trans'] = args[0]
  2923. except:
  2924. pass
  2925. def MyAuction_SetItemSocket(self, index , value):
  2926. elm = self.MyAuctionInfo['item']
  2927. if not 'socket' in elm:
  2928. elm['socket'] = [0 for x in xrange(player.METIN_SOCKET_MAX_NUM)]
  2929. elm['socket'][index] = value
  2930. def MyAuction_SetItemAttribute(self, key , index , value):
  2931. elm = self.MyAuctionInfo['item']
  2932. if not 'attr' in elm:
  2933. elm['attr'] = [{'type' :0, 'value': 0,} for x in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)]
  2934. elm['attr'][index][key] = value
  2935. def MyAuction_AddOffer(self, buyer_id, buyer_name, owner_id, price_yang):
  2936. if not 'offers' in self.MyAuctionInfo:
  2937. self.MyAuctionInfo['offers'] = []
  2938. new = {}
  2939. new['buyer_name'] = buyer_name
  2940. new['price_yang'] = price_yang
  2941. self.MyAuctionInfo['offers'].append(new)
  2942. def MyAuction_End(self):
  2943. self.RefreshMyAuctionPage()
  2944. self.DisableRefreshSymbol()
  2945. def OpenAuction_Clear(self):
  2946. self.OpenAuctionInfo = {'item':{},}
  2947. def OpenAuction_SetInto(self, owner_id, owner_name, duration, init_yang):
  2948. info = {
  2949. "owner_id" : owner_id,
  2950. "owner_name" : owner_name,
  2951. "duration" : duration,
  2952. "init_yang" : init_yang,
  2953. }
  2954. for k ,v in info.items():
  2955. self.OpenAuctionInfo[k] = v
  2956. def OpenAuction_SetItemInfo(self, vnum, count, *args):
  2957. elm = self.OpenAuctionInfo['item']
  2958. elm['vnum'] = vnum
  2959. elm['count'] = count
  2960. try:
  2961. if ENABLE_CHANGELOOK_SYSTEM and len(args!=0):
  2962. elm['trans'] = args[0]
  2963. except:
  2964. pass
  2965. def OpenAuction_SetItemSocket(self, index , value):
  2966. elm = self.OpenAuctionInfo['item']
  2967. if not 'socket' in elm:
  2968. elm['socket'] = [0 for x in xrange(player.METIN_SOCKET_MAX_NUM)]
  2969. elm['socket'][index] = value
  2970. def OpenAuction_SetItemAttribute(self, key , index , value):
  2971. elm = self.OpenAuctionInfo['item']
  2972. if not 'attr' in elm:
  2973. elm['attr'] = [{'type' :0, 'value': 0,} for x in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)]
  2974. elm['attr'][index][key] = value
  2975. def OpenAuction_AddOffer(self, buyer_id, buyer_name, owner_id, price_yang):
  2976. if not 'offers' in self.OpenAuctionInfo:
  2977. self.OpenAuctionInfo['offers'] = []
  2978. new = {}
  2979. new['buyer_name'] = buyer_name
  2980. new['price_yang'] = price_yang
  2981. self.OpenAuctionInfo['offers'].append(new)
  2982. def OpenAuction_End(self):
  2983. self.RefreshOpenAuctionPage()
  2984. self.DisableRefreshSymbol()
  2985. def MyAuction_NoAuction(self):
  2986. self.pageCategory = "create_auction"
  2987. for page in self.pageBoards.values():
  2988. page.Hide()
  2989. self.pageBoards['create_auction'].Show()
  2990. self.DisableRefreshSymbol()
  2991. def OpenInsertPriceDialog(self, win, slot):
  2992. self.AddItemSlotIndex = (win,slot)
  2993. self.CommonInputPriceDlg.Open()
  2994. def __OnAcceptMyShopAcceptOffer(self):
  2995. offlineshop.SendOfferAccept(self.MyShopAcceptOfferID)
  2996. self.CommonQuestionDlg.Hide()
  2997. self.MyShopAcceptOfferID = -1
  2998. def __OnCancelMyShopAcceptOffer(self):
  2999. self.CommonQuestionDlg.Hide()
  3000. self.MyShopAcceptOfferID = -1
  3001. def __OnAcceptMyShopCancelOffer(self):
  3002. offlineshop.SendOfferCancel(self.MyShopCancelOfferID, self.ShopOpenInfo['owner_id'])
  3003. self.CommonQuestionDlg.Hide()
  3004. self.MyShopCancelOfferID = -1
  3005. def __OnCancelMyShopCancelOffer(self):
  3006. self.CommonQuestionDlg.Hide()
  3007. self.MyShopCancelOfferID = -1
  3008. def __OnCancelCancelOfferQuestion(self):
  3009. self.CommonQuestionDlg.Hide()
  3010. self.MyOffersCancelOfferInfo = []
  3011. def __OnAcceptCancelOfferQuestion(self):
  3012. info = self.MyOffersCancelOfferInfo
  3013. offlineshop.SendOfferCancel(info[0], info[1])
  3014. self.CommonQuestionDlg.Hide()
  3015. self.MyOffersCancelOfferInfo = []
  3016. def __OnAcceptInputPrice(self):
  3017. yang = self.CommonInputPriceDlg.GetText()
  3018. if not yang.isdigit():
  3019. return
  3020. yang = int(yang)
  3021. if not ENABLE_CHEQUE_SYSTEM:
  3022. if yang == 0:
  3023. return
  3024. if ENABLE_CHEQUE_SYSTEM:
  3025. cheque = self.CommonInputPriceDlg.GetChequeText()
  3026. if cheque.isdigit():
  3027. cheque = int(cheque)
  3028. else:
  3029. cheque = 0
  3030. if yang == 0 and cheque == 0:
  3031. return
  3032. if self.pageCategory == "create_shop" and self.AddItemSlotIndex != -1:
  3033. slot = Slot()
  3034. slot.SetIndex(self.AddItemSlotIndex)
  3035. if ENABLE_CHEQUE_SYSTEM:
  3036. slot.SetInfo(MakeSlotInfo(self.AddItemSlotIndex[0] , self.AddItemSlotIndex[1], yang, cheque))
  3037. else:
  3038. slot.SetInfo(MakeSlotInfo(self.AddItemSlotIndex[0] , self.AddItemSlotIndex[1], yang))
  3039. slot.SetOnMouseLeftButtonUpEvent(self.__OnLeftClickInsertedItem)
  3040. slot.Show()
  3041. self.CreateShopItemsTable.AddElement(slot)
  3042. self.CreateShopItemsInfos[slot.GetIndex()] = slot.GetInfo()
  3043. self.CommonInputPriceDlg.Hide()
  3044. # if self.HowToInsertItemText.IsShow():
  3045. # self.HowToInsertItemText.Hide()
  3046. self.AddItemSlotIndex = -1
  3047. elif self.pageCategory == "create_shop" and self.EditPriceSlot != None:
  3048. slot = self.EditPriceSlot
  3049. index = slot.GetIndex()
  3050. info = slot.GetInfo()
  3051. info["price"] = yang
  3052. if ENABLE_CHEQUE_SYSTEM:
  3053. info['cheque'] = cheque
  3054. self.CreateShopItemsInfos[slot.GetIndex()] = info
  3055. self.EditPriceSlot = None
  3056. self.CommonInputPriceDlg.Hide()
  3057. elif self.pageCategory == "my_shop" and self.AddItemSlotIndex != -1:
  3058. if ENABLE_CHEQUE_SYSTEM:
  3059. offlineshop.SendAddItem(self.AddItemSlotIndex[0], self.AddItemSlotIndex[1], yang, cheque)
  3060. else:
  3061. offlineshop.SendAddItem(self.AddItemSlotIndex[0], self.AddItemSlotIndex[1], yang)
  3062. self.AddItemSlotIndex = -1
  3063. self.CommonInputPriceDlg.Hide()
  3064. elif self.pageCategory == "my_shop" and self.EditPriceSlot != None:
  3065. slot = self.EditPriceSlot
  3066. index = slot.GetIndex()
  3067. if ENABLE_CHEQUE_SYSTEM:
  3068. offlineshop.SendEditItem(index, yang, cheque)
  3069. else:
  3070. offlineshop.SendEditItem(index, yang)
  3071. self.CommonInputPriceDlg.Hide()
  3072. self.EditPriceSlot = None
  3073. def __OnCancelInputPrice(self):
  3074. self.CommonInputPriceDlg.Hide()
  3075. self.AddItemSlotIndex = -1
  3076. self.EditPriceSlot = None
  3077. def __OnAcceptOpenShopBuyItemQuestion(self):
  3078. self.CommonQuestionDlg.Hide()
  3079. offlineshop.SendBuyItem(self.ShopOpenInfo["owner_id"] , self.OpenShopBuyItemID)
  3080. self.OpenShopBuyItemID = -1
  3081. def __OnCancelOpenShopBuyItemQuestion(self):
  3082. self.CommonQuestionDlg.Hide()
  3083. self.OpenShopBuyItemID = -1
  3084. def __OnAcceptSearchFilterBuyItemQuestion(self):
  3085. id,owner = self.SearchFilterResultClickedInfo
  3086. offlineshop.SendBuyItemFromSearch(owner, id)
  3087. self.CommonQuestionDlg.Hide()
  3088. self.SearchFilterResultClickedInfo = []
  3089. def __OnCancelSearchFilterBuyItemQuestion(self):
  3090. self.CommonQuestionDlg.Hide()
  3091. self.SearchFilterResultClickedInfo = []
  3092. def __OnAcceptChangeShopNameDlg(self):
  3093. newname = self.MyShopEditNameDlg.GetText()
  3094. self.MyShopEditNameDlg.Hide()
  3095. offlineshop.SendChangeName(newname)
  3096. def __OnCancelChangeShopNameDlg(self):
  3097. self.MyShopEditNameDlg.Hide()
  3098. def __OnAcceptMyPatternInputName(self):
  3099. name = self.SearchPatternsInputNameDlg.GetText()
  3100. self.SearchPatternsInputNameDlg.Hide()
  3101. if name:
  3102. setting = self.GetSearchFilterSettings()
  3103. setting = (name,) + setting
  3104. offlineshop.AppendNewFilterPattern(*setting)
  3105. self.__PopupMessage(localeInfo.OFFLINESHOP_PATTERN_SAVED_SUCCESS)
  3106. def __OnCancelMyPatternInputName(self):
  3107. self.SearchPatternsInputNameDlg.Hide()
  3108. def __OnAcceptShopSafeboxGetItemQuestion(self):
  3109. self.CommonQuestionDlg.Hide()
  3110. offlineshop.SendSafeboxGetItem(self.ShopSafeboxGetItemIndex)
  3111. self.ShopSafeboxGetItemIndex = -1
  3112. def __OnCancelShopSafeboxGetItemQuestion(self):
  3113. self.CommonQuestionDlg.Hide()
  3114. self.ShopSafeboxGetItemIndex = -1
  3115. if ENABLE_CHEQUE_SYSTEM:
  3116. def __OnAcceptShopSafeboxGetValuteInput(self , yang, cheque):
  3117. offlineshop.SendSafeboxGetValutes(yang, cheque)
  3118. else:
  3119. def __OnAcceptShopSafeboxGetValuteInput(self , yang):
  3120. offlineshop.SendSafeboxGetValutes(yang)
  3121. if ENABLE_CHEQUE_SYSTEM:
  3122. def __OnAcceptMakeOffer(self, yang, cheque):
  3123. offlineshop.SendOfferCreate(self.MakeOfferOwnerID, self.MakeOfferItemID, yang, cheque)
  3124. self.MakeOfferOwnerID = -1
  3125. self.MakeOfferItemID = -1
  3126. else:
  3127. def __OnAcceptMakeOffer(self, yang):
  3128. offlineshop.SendOfferCreate(self.MakeOfferOwnerID, self.MakeOfferItemID, yang)
  3129. self.MakeOfferOwnerID = -1
  3130. self.MakeOfferItemID = -1
  3131. def __OnClickCreateShopButton(self):
  3132. shopname = self.CreateShopNameEdit.GetText()
  3133. if not shopname:
  3134. self.__PopupMessage(localeInfo.OFFLINESHOP_CREATE_SHOP_NO_NAME_INSERTED)
  3135. return
  3136. days = int(self.CreateShopDaysCountText.GetText())
  3137. hours = int(self.CreateShopHoursCountText.GetText())
  3138. totaltime = days * 24 * 60
  3139. totaltime += hours * 60
  3140. if totaltime > offlineshop.OFFLINESHOP_MAX_MINUTES or totaltime <= 0:
  3141. self.__PopupMessage(localeInfo.OFFLINESHOP_CREATE_SHOP_INVALID_DURATION)
  3142. return
  3143. elements = self.CreateShopItemsTable.GetElementDict()
  3144. if not elements:
  3145. self.__PopupMessage(localeInfo.OFFLINESHOP_CREATE_SHOP_NO_ITEMS_INSERTED)
  3146. return
  3147. itemLst = []
  3148. for dct in elements.values():
  3149. for item in dct.values():
  3150. info = item.GetInfo()
  3151. if ENABLE_CHEQUE_SYSTEM:
  3152. tupleinfo = (info["window"], info["slot"] , info["price"] , info.get('cheque', 0))
  3153. else:
  3154. tupleinfo = (info["window"], info["slot"] , info["price"] )
  3155. itemLst.append(tupleinfo)
  3156. itemTuple = tuple(itemLst)
  3157. offlineshop.SendShopCreate(shopname, totaltime, itemTuple)
  3158. self.EnableRefreshSymbol()
  3159. def __OnLeftClickInsertedItem(self, slot):
  3160. if mouseModule.mouseController.isAttached():
  3161. if self.pageCategory == "create_shop":
  3162. self.__OnClickCreateShopEmptySlot()
  3163. elif self.pageCategory == "my_shop":
  3164. self.__OnClickMyShopEmptySlot()
  3165. return
  3166. if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  3167. self.__OnRemoveShopItem(slot)
  3168. else:
  3169. self.EditPriceSlot = slot
  3170. self.CommonInputPriceDlg.Open()
  3171. def __OnLeftClickShopItem(self, slot):
  3172. if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  3173. itemid = slot.GetIndex()
  3174. ownerid = self.ShopOpenInfo["owner_id"]
  3175. self.__OnMakeShopItemOffer(itemid, ownerid)
  3176. else:
  3177. self.OpenShopBuyItemID = slot.GetIndex()
  3178. info = slot.GetInfo()
  3179. item.SelectItem(info["vnum"])
  3180. name = item.GetItemName()
  3181. count = info["count"]
  3182. yang = info["price"]
  3183. if ENABLE_CHEQUE_SYSTEM:
  3184. cheque = info["cheque"]
  3185. if count > 1:
  3186. if ENABLE_CHEQUE_SYSTEM:
  3187. text = localeInfo.OFFLINESHOP_BUY_ITEM_QUESTION_COUNT2 % (name, count, yang, cheque)
  3188. else:
  3189. text = localeInfo.OFFLINESHOP_BUY_ITEM_QUESTION_COUNT % (name, count, yang)
  3190. else:
  3191. if ENABLE_CHEQUE_SYSTEM:
  3192. text = localeInfo.OFFLINESHOP_BUY_ITEM_QUESTION2 % (name, yang, cheque)
  3193. else:
  3194. text = localeInfo.OFFLINESHOP_BUY_ITEM_QUESTION % (name, yang)
  3195. width = 6 * len(text)
  3196. accept_text = localeInfo.OFFLINESHOP_BUY_ITEM_QUESTION_ACCEPT
  3197. cancel_text = localeInfo.OFFLINESHOP_BUY_ITEM_QUESTION_CANCEL
  3198. accept_event= self.__OnAcceptOpenShopBuyItemQuestion
  3199. cancel_event= self.__OnCancelOpenShopBuyItemQuestion
  3200. self.__OpenQuestionDialog(width, accept_text, cancel_text, accept_event, cancel_event, text)
  3201. def __OnLeftClickSearchFilterShopResultItem(self, slot):
  3202. if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_LCONTROL):
  3203. itemid,ownerid = slot.GetIndex()
  3204. self.__OnMakeShopItemOffer(itemid, ownerid)
  3205. else:
  3206. self.SearchFilterResultClickedInfo = slot.GetIndex()
  3207. info = slot.GetInfo()
  3208. item.SelectItem(info["vnum"])
  3209. name = item.GetItemName()
  3210. count = info["count"]
  3211. yang = info["price"]
  3212. if ENABLE_CHEQUE_SYSTEM:
  3213. cheque = info["cheque"]
  3214. if count > 1:
  3215. if ENABLE_CHEQUE_SYSTEM:
  3216. text = localeInfo.OFFLINESHOP_BUY_ITEM_QUESTION_COUNT2 % (name, count, yang, cheque)
  3217. else:
  3218. text = localeInfo.OFFLINESHOP_BUY_ITEM_QUESTION_COUNT % (name, count, yang)
  3219. else:
  3220. if ENABLE_CHEQUE_SYSTEM:
  3221. text = localeInfo.OFFLINESHOP_BUY_ITEM_QUESTION2 % (name, yang, cheque)
  3222. else:
  3223. text = localeInfo.OFFLINESHOP_BUY_ITEM_QUESTION % (name, yang)
  3224. width = 6 * len(text)
  3225. accept_text = localeInfo.OFFLINESHOP_BUY_ITEM_QUESTION_ACCEPT
  3226. cancel_text = localeInfo.OFFLINESHOP_BUY_ITEM_QUESTION_CANCEL
  3227. accept_event = self.__OnAcceptSearchFilterBuyItemQuestion
  3228. cancel_event = self.__OnCancelSearchFilterBuyItemQuestion
  3229. self.__OpenQuestionDialog(width, accept_text, cancel_text, accept_event, cancel_event, text)
  3230. def __OnClickCreateShopEmptySlot(self, *args):
  3231. if not mouseModule.mouseController.isAttached():
  3232. return
  3233. type = mouseModule.mouseController.GetAttachedType()
  3234. slot = mouseModule.mouseController.GetAttachedSlotNumber()
  3235. #tofix slot type to window type
  3236. type = player.SlotTypeToInvenType(type)
  3237. mouseModule.mouseController.DeattachObject()
  3238. self.ShopBuilding_AddItem(type,slot)
  3239. def __OnClickMyShopEmptySlot(self, *args):
  3240. # todebug
  3241. print("my shop shop empty slot")
  3242. if not mouseModule.mouseController.isAttached():
  3243. return
  3244. type = mouseModule.mouseController.GetAttachedType()
  3245. slot = mouseModule.mouseController.GetAttachedSlotNumber()
  3246. #tofix slot type to window type
  3247. type = player.SlotTypeToInvenType(type)
  3248. mouseModule.mouseController.DeattachObject()
  3249. self.ShopBuilding_AddItem(type,slot)
  3250. def __OnClickShopListOpenShop(self, id):
  3251. offlineshop.SendOpenShop(id)
  3252. def __OnClickOpenAuctionMakeOffer(self, slot):
  3253. if ENABLE_CHEQUE_SYSTEM:
  3254. self.__OnPickValute(localeInfo.OFFLINESHOP_AUCTION_MAKE_OFFER, self.__OnClickAcceptOpenAuctionPickValute, player.GetElk(), player.GetCheque())
  3255. else:
  3256. self.__OnPickValute(localeInfo.OFFLINESHOP_AUCTION_MAKE_OFFER, self.__OnClickAcceptOpenAuctionPickValute, player.GetElk())
  3257. if ENABLE_CHEQUE_SYSTEM:
  3258. def __OnClickAcceptOpenAuctionPickValute(self, yang, cheque):
  3259. if not self.OpenAuctionInfo.has_key('min_raise'):
  3260. return
  3261. if (yang + (cheque * YANG_PER_CHEQUE)) < self.OpenAuctionInfo['min_raise']:
  3262. self.__PopupMessage(localeInfo.OFFLINESHOP_AUCTION_MIN_RAISE%NumberToString(self.OpenAuctionInfo['min_raise']) )
  3263. return
  3264. offlineshop.SendAuctionAddOffer(self.OpenAuctionInfo['owner_id'] , yang, cheque)
  3265. else:
  3266. def __OnClickAcceptOpenAuctionPickValute(self, yang):
  3267. if not self.OpenAuctionInfo.has_key('min_raise'):
  3268. return
  3269. if yang < self.OpenAuctionInfo['min_raise']:
  3270. self.__PopupMessage(localeInfo.OFFLINESHOP_AUCTION_MIN_RAISE%NumberToString(self.OpenAuctionInfo['min_raise']) )
  3271. return
  3272. offlineshop.SendAuctionAddOffer(self.OpenAuctionInfo['owner_id'] , yang)
  3273. def __OnClickShopSafeboxWithdrawYang(self):
  3274. maxval = self.ShopSafeboxValuteAmount
  3275. if ENABLE_CHEQUE_SYSTEM:
  3276. self.__OnPickValute(localeInfo.OFFLINESHOP_SAFEBOX_GET_VALUTE_TITLE, self.__OnAcceptShopSafeboxGetValuteInput, maxval[0], maxval[1])
  3277. else:
  3278. self.__OnPickValute(localeInfo.OFFLINESHOP_SAFEBOX_GET_VALUTE_TITLE, self.__OnAcceptShopSafeboxGetValuteInput, maxval)
  3279. def __OnClickMyShopOfferAcceptButton(self, offer):
  3280. self.MyShopAcceptOfferID = offer.GetInfo()['id']
  3281. question = localeInfo.OFFLINESHOP_ACCEPT_OFFER_QUESTION
  3282. accepttext = localeInfo.OFFLINESHOP_ACCEPT_OFFER_QUESTION_ACCEPT
  3283. canceltext = localeInfo.OFFLINESHOP_ACCEPT_OFFER_QUESTION_CANCEL
  3284. self.__OpenQuestionDialog(len(question)*6 , accepttext, canceltext, self.__OnAcceptMyShopAcceptOffer, self.__OnCancelMyShopAcceptOffer, question)
  3285. def __OnClickMyShopOfferCancelButton(self, offer):
  3286. self.MyShopCancelOfferID = offer.GetInfo()['id']
  3287. question = localeInfo.OFFLINESHOP_CANCEL_OFFER_QUESTION
  3288. accepttext = localeInfo.OFFLINESHOP_CANCEL_OFFER_QUESTION_ACCEPT
  3289. canceltext = localeInfo.OFFLINESHOP_CANCEL_OFFER_QUESTION_CANCEL
  3290. self.__OpenQuestionDialog(len(question) * 6, accepttext, canceltext, self.__OnAcceptMyShopCancelOffer, self.__OnCancelMyShopCancelOffer, question)
  3291. def __OnClickOpenAuctionButton(self, idx):
  3292. offlineshop.SendAuctionOpenAuction(idx)
  3293. self.EnableRefreshSymbol()
  3294. def __OnLeftClickShopSafeboxItem(self, slot):
  3295. id = slot.GetIndex()
  3296. self.ShopSafeboxGetItemIndex = id
  3297. if ENABLE_ITEM_WITHDRAW_QUESTION_SHOP_SAFEBOX:
  3298. info = slot.GetInfo()
  3299. vnum = info["vnum"]
  3300. count = info["count"]
  3301. item.SelectItem(vnum)
  3302. name = item.GetItemName()
  3303. if count > 1:
  3304. text = localeInfo.OFFLINESHOP_SHOP_SAFEBOX_QUESTION_GET_ITEM_COUNT%(name,count)
  3305. else:
  3306. text = localeInfo.OFFLINESHOP_SHOP_SAFEBOX_QUESTION_GET_ITEM%name
  3307. width = len(text)*6
  3308. self.__OpenQuestionDialog(width, localeInfo.OFFLINESHOP_SHOP_SAFEBOX_ACCEPT, localeInfo.OFFLINESHOP_SAFEBOX_CANCEL, self.__OnAcceptShopSafeboxGetItemQuestion, self.__OnCancelShopSafeboxGetItemQuestion, text)
  3309. else:
  3310. self.__OnAcceptShopSafeboxGetItemQuestion()
  3311. def __OnRemoveShopItem(self, slot):
  3312. if self.pageCategory == "create_shop":
  3313. self.__OnRemoveShopItemCreateShopPage(slot)
  3314. elif self.pageCategory == "my_shop":
  3315. self.__OnRemoveShopItemMyShop(slot)
  3316. def __OnRemoveShopItemCreateShopPage(self, slot):
  3317. slot.Hide()
  3318. del self.CreateShopItemsInfos[slot.GetIndex()]
  3319. self.CreateShopItemsTable.ClearElement()
  3320. for k, v in self.CreateShopItemsInfos.items():
  3321. newslot = Slot()
  3322. newslot.SetIndex(k)
  3323. newslot.SetInfo(v)
  3324. newslot.SetOnMouseLeftButtonUpEvent(self.__OnLeftClickInsertedItem)
  3325. newslot.Show()
  3326. self.CreateShopItemsTable.AddElement(newslot)
  3327. def __OnRemoveShopItemMyShop(self, slot):
  3328. offlineshop.SendRemoveItem(slot.GetIndex())
  3329. def __OnMakeShopItemOffer(self , itemid , ownerid):
  3330. self.MakeOfferItemID = itemid
  3331. self.MakeOfferOwnerID= ownerid
  3332. title = localeInfo.OFFLINESHOP_MAKE_OFFER_TITLE
  3333. if ENABLE_CHEQUE_SYSTEM:
  3334. self.__OnPickValute(title, self.__OnAcceptMakeOffer, player.GetElk(), player.GetCheque())
  3335. else:
  3336. self.__OnPickValute(title, self.__OnAcceptMakeOffer, player.GetElk())
  3337. def __OnSetCreateAuctionSlot(self, win,slot):
  3338. vnum = player.GetItemIndex(win,slot)
  3339. if vnum ==0:
  3340. return
  3341. item.SelectItem(vnum)
  3342. if item.IsAntiFlag(item.ITEM_ANTIFLAG_MYSHOP) or item.IsAntiFlag(item.ITEM_ANTIFLAG_GIVE):
  3343. return
  3344. self.CreateAuctionWindowPos = win
  3345. self.CreateAuctionSlotPos = slot
  3346. count = player.GetItemCount(win,slot)
  3347. attrs = [{"type" : player.GetItemAttribute(win, slot, x)[0], "value" : player.GetItemAttribute(win, slot, x)[1]} for x in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)]
  3348. sockets = [player.GetItemMetinSocket(win,slot,x) for x in xrange(player.METIN_SOCKET_MAX_NUM)]
  3349. try:
  3350. if ENABLE_CHANGELOOK_SYSTEM:
  3351. trans = player.GetItemTransmutation(win, slot)
  3352. except:
  3353. pass
  3354. info = {
  3355. "vnum" : vnum,
  3356. "count" : count,
  3357. 'attr' : attrs,
  3358. 'socket' : sockets,
  3359. }
  3360. try:
  3361. if ENABLE_CHANGELOOK_SYSTEM:
  3362. info.update({
  3363. 'trans' : trans,
  3364. })
  3365. except:
  3366. pass
  3367. self.CreateAuctionSlot.SetInfo(info)
  3368. def IsBuildingShop(self):
  3369. return self.IsShow() and (self.pageCategory == "create_shop" or self.pageCategory=="my_shop")
  3370. def IsForSaleSlot(self,win,slot):
  3371. idx = (win,slot)
  3372. if not self.pageCategory=="create_shop" or not self.IsShow():
  3373. return False
  3374. if not self.CreateShopItemsTable:
  3375. return False
  3376. elementDict = self.CreateShopItemsTable.GetElementDict()
  3377. for dct in elementDict.values():
  3378. for value in dct.values():
  3379. if value.GetIndex() == idx:
  3380. return True
  3381. return False
  3382. def IsBuildingAuction(self):
  3383. if not self.IsShow():
  3384. return False
  3385. if self.pageCategory != "create_auction":
  3386. return False
  3387. return True
  3388. def IsForAuctionSlot(self, win, slot):
  3389. if not self.IsShow():
  3390. return False
  3391. if self.pageCategory != "create_auction":
  3392. return False
  3393. return self.CreateAuctionWindowPos == win and self.CreateAuctionSlotPos == slot
  3394. def __SetTooltip(self,info):
  3395. infocolor = COLOR_TEXT_SHORTCUT
  3396. is_building = self.IsBuildingShop()
  3397. self.itemTooltip.ClearToolTip()
  3398. sockets = [info["socket"][num] for num in xrange(player.METIN_SOCKET_MAX_NUM)]
  3399. attrs = [(info["attr"][num]['type'], info["attr"][num]['value']) for num in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)]
  3400. self.itemTooltip.AddItemData(info["vnum"], sockets, attrs)
  3401. try:
  3402. if ENABLE_CHANGELOOK_SYSTEM:
  3403. trans = info.get('trans',0)
  3404. if trans !=0 and trans != -1:
  3405. self.itemTooltip.AppendTransmutation(0,0, trans)
  3406. except:
  3407. pass
  3408. if self.pageCategory in ("open_shop", "my_shop", "search_filter", "create_shop"):
  3409. self.itemTooltip.AppendPrice(info["price"])
  3410. if ENABLE_CHEQUE_SYSTEM:
  3411. cheque = info.get('cheque',0)
  3412. if cheque!=0:
  3413. self.itemTooltip.AppendSellingChequePrice(cheque)
  3414. if is_building and not info.get('sold', False):
  3415. self.itemTooltip.AppendSpace(10)
  3416. self.itemTooltip.AppendTextLine(localeInfo.OFFLINESHOP_BUILDING_LEFT_CLICK_EDIT_PRICE, infocolor)
  3417. self.itemTooltip.AppendTextLine(localeInfo.OFFLINESHOP_BUILDING_LEFT_CLICK_CTRL_REMOVE_ITEM, infocolor)
  3418. elif self.pageCategory == "open_shop" or self.pageCategory == "search_filter":
  3419. self.itemTooltip.AppendSpace(10)
  3420. self.itemTooltip.AppendTextLine(localeInfo.OFFLINESHOP_OPEN_SHOP_LEFT_CLICK_BUY_ITEM, infocolor)
  3421. self.itemTooltip.AppendTextLine(localeInfo.OFFLINESHOP_OPEN_SHOP_LEFT_CLICK_MAKE_OFFER, infocolor)
  3422. elif self.pageCategory == "shop_safebox":
  3423. self.itemTooltip.AppendSpace(10)
  3424. self.itemTooltip.AppendTextLine(localeInfo.OFFLINESHOP_SAFEBOX_TOOLTIP_GETITEM, infocolor)
  3425. def __SetTooltipMyOffer(self, offer):
  3426. slot = offer.slot
  3427. self.__SetTooltip(slot.GetInfo())
  3428. index = offer.info['offer_id']
  3429. for elm in self.MyOffersList:
  3430. if elm['offer_id'] == index:
  3431. self.itemTooltip.AppendSpace(10)
  3432. self.itemTooltip.AppendPrice(elm['item']['price'])
  3433. self.itemTooltip.AppendTextLine(localeInfo.OFFLINESHOP_MY_OFFER_OFFER_TEXT%localeInfo.NumberToMoneyString(elm['price']))
  3434. break
  3435. def __SetTooltipSearch(self, element):
  3436. print("updating tooltip")
  3437. appendLine = lambda arg : (
  3438. uitooltip.ToolTip.AutoAppendTextLine(self.itemTooltip, arg),
  3439. self.itemTooltip.AlignHorizonalCenter())
  3440. self.itemTooltip.ClearToolTip()
  3441. info = element.info
  3442. name = info.get('filter_name', "")
  3443. wearflag = info.get('filter_wearflag', 0)
  3444. price_min = info.get('price', {}).get('start', 0)
  3445. price_max = info.get('price', {}).get('end', 0)
  3446. level_min = info.get('level', {}).get('start',0)
  3447. level_max = info.get('level', {}).get('end',0)
  3448. type = info.get('filter_type', 0)
  3449. subtype = info.get('filter_subtype', 255)
  3450. attrs = info.get('attr')
  3451. #name
  3452. if name:
  3453. appendLine(localeInfo.OFFLINESHOP_TOOLTIP_NAME_INFO +" "+ name)
  3454. #type
  3455. if type:
  3456. type_phrase = localeInfo.OFFLINESHOP_TOOLTIP_TYPE_INFO+ " "
  3457. type_phrase += self.ITEM_TYPES[type]['name']
  3458. if subtype != SUBTYPE_NOSET and self.ITEM_TYPES[type].has_key('subtypes'):
  3459. type_phrase += ", "+self.ITEM_TYPES[type]['subtypes'][subtype]
  3460. appendLine(type_phrase)
  3461. #price
  3462. if price_min or price_max:
  3463. price_phrase = localeInfo.OFFLINESHOP_TOOLTIP_PRICE_INFO + " "
  3464. if price_min and price_max:
  3465. price_phrase += NumberToString(price_min) + " - "+ localeInfo.NumberToMoneyString(price_max)
  3466. elif price_min:
  3467. price_phrase += " > "+ localeInfo.NumberToMoneyString(price_min)
  3468. elif price_max:
  3469. price_phrase += " < "+ localeInfo.NumberToMoneyString(price_max)
  3470. appendLine(price_phrase)
  3471. #level
  3472. if level_min or level_max:
  3473. level_phrase = localeInfo.OFFLINESHOP_TOOLTIP_LEVEL_INFO + " "
  3474. if level_min and level_max:
  3475. level_phrase += "%d - %d"%(level_min, level_max)
  3476. elif level_min:
  3477. level_phrase += " >= %d"%level_min
  3478. elif level_max:
  3479. level_phrase += " <= %d"%level_max
  3480. appendLine(level_phrase)
  3481. #wear
  3482. raceFlagDct = {
  3483. item.ITEM_ANTIFLAG_WARRIOR : localeInfo.OFFLINESHOP_WEAR_WARRIOR,
  3484. item.ITEM_ANTIFLAG_ASSASSIN : localeInfo.OFFLINESHOP_WEAR_ASSASSIN,
  3485. item.ITEM_ANTIFLAG_SURA : localeInfo.OFFLINESHOP_WEAR_SURA,
  3486. item.ITEM_ANTIFLAG_SHAMAN : localeInfo.OFFLINESHOP_WEAR_SHAMAN,
  3487. }
  3488. if ENABLE_WOLFMAN_CHARACTER:
  3489. raceFlagDct.update({
  3490. item.ITEM_ANTIFLAG_WOLFMAN: localeInfo.OFFLINESHOP_WEAR_WOLFMAN,
  3491. })
  3492. wearphrase = ""
  3493. for k ,v in raceFlagDct.items():
  3494. if not wearflag & k:
  3495. if wearphrase:
  3496. wearphrase += ", "
  3497. wearphrase += v
  3498. if wearphrase:
  3499. wearphrase = localeInfo.OFFLINESHOP_TOOLTIP_WEAR_INFO + wearphrase
  3500. appendLine(wearphrase)
  3501. #attribute
  3502. attribute_phrase = ""
  3503. for type in attrs['type']:
  3504. if type != 0:
  3505. if attribute_phrase:
  3506. attribute_phrase += ', '
  3507. attribute_phrase += self.ATTRIBUTES[type]
  3508. if attribute_phrase:
  3509. attribute_phrase = localeInfo.OFFLINESHOP_TOOLTIP_ATTR_INFO +' '+attribute_phrase
  3510. appendLine(attribute_phrase)
  3511. self.itemTooltip.ShowToolTip()
  3512. def __SetTooltipAuctionList(self, element):
  3513. itemInfo = element.GetInfo()['item']
  3514. self.__SetTooltip(itemInfo)
  3515. def OnUpdate(self):
  3516. # try:
  3517. if self.pageCategory in self.updateEvents:
  3518. self.updateEvents[self.pageCategory]()
  3519. # except:
  3520. # pass
  3521. def __OnUpdateMyShopPage(self):
  3522. self.__RefreshingTooltip(self.MyShopItemsTable)
  3523. def __OnUpdateCreateShopPage(self):
  3524. self.__RefreshingTooltip(self.CreateShopItemsTable)
  3525. def __OnUpdateOpenShopPage(self):
  3526. self.__RefreshingTooltip(self.OpenShopItemsTable)
  3527. def __OnUpdateSearchFilterPage(self):
  3528. self.__RefreshingTooltip(self.SearchFilterResultItemsTable)
  3529. def __OnUpdateSearchHistoryPage(self):
  3530. self.__RefreshingTooltip(self.SearchHistoryTable , self.__SetTooltipSearch)
  3531. def __OnUpdateMyPatternPage(self):
  3532. self.__RefreshingTooltip(self.SearchPatternsTable, self.__SetTooltipSearch)
  3533. def __OnUpdateShopSafeboxPage(self):
  3534. self.__RefreshingTooltip(self.ShopSafeboxItemsTable)
  3535. def __OnUpdateMyOffersPage(self):
  3536. self.__RefreshingTooltip(self.MyOffersTable, self.__SetTooltipMyOffer)
  3537. def __OnUpdateCreateAuctionPage(self):
  3538. if self.CreateAuctionSlot.IsShow():
  3539. if self.itemTooltip.IsShow():
  3540. if not self.CreateAuctionSlot.IsInSlot():
  3541. self.itemTooltip.Hide()
  3542. else:
  3543. if self.CreateAuctionSlot.IsInSlot() and self.CreateAuctionSlot.GetInfo():
  3544. self.__SetTooltip(self.CreateAuctionSlot.GetInfo())
  3545. def __OnUpdateMyAuctionPage(self):
  3546. if self.MyAuctionSlot.IsShow():
  3547. if self.itemTooltip.IsShow():
  3548. if not self.MyAuctionSlot.IsInSlot():
  3549. self.itemTooltip.Hide()
  3550. else:
  3551. if self.MyAuctionSlot.IsInSlot() and self.MyAuctionSlot.GetInfo():
  3552. self.__SetTooltip(self.MyAuctionSlot.GetInfo())
  3553. def __OnUpdateOpenAuctionPage(self):
  3554. if self.OpenAuctionSlot.IsShow():
  3555. if self.itemTooltip.IsShow():
  3556. if not self.OpenAuctionSlot.IsInSlot():
  3557. self.itemTooltip.Hide()
  3558. else:
  3559. if self.OpenAuctionSlot.IsInSlot() and self.OpenAuctionSlot.GetInfo():
  3560. self.__SetTooltip(self.OpenAuctionSlot.GetInfo())
  3561. self.itemTooltip.AppendTextLine(localeInfo.OFFLINESHOP_TOOLTIP_LEFT_CLICK_MAKE_OFFER)
  3562. def __OnUpdateAuctionListPage(self):
  3563. self.__RefreshingTooltip(self.AuctionListTable, self.__SetTooltipAuctionList)
  3564. def __RefreshingTooltip(self, table, event = None):
  3565. if not self.itemTooltip.IsShow():
  3566. elementDict = table.GetElementDict()
  3567. for dct in elementDict.values():
  3568. for value in dct.values():
  3569. if value.IsInSlot():
  3570. self.slotTooltipIndex = value.GetIndex()
  3571. if event == None:
  3572. self.__SetTooltip(value.GetInfo())
  3573. else:
  3574. event(value)
  3575. return
  3576. self.itemTooltip.Hide()
  3577. self.slotTooltipIndex = -1
  3578. else:
  3579. elementDict = table.GetElementDict()
  3580. for dct in elementDict.values():
  3581. for value in dct.values():
  3582. if value.IsInSlot():
  3583. if self.slotTooltipIndex == value.GetIndex():
  3584. return
  3585. self.slotTooltipIndex = value.GetIndex()
  3586. if event == None:
  3587. self.__SetTooltip(value.GetInfo())
  3588. else:
  3589. event(value)
  3590. return
  3591. self.itemTooltip.Hide()
  3592. self.slotTooltipIndex = -1
  3593. def RefreshMyShopPage(self):
  3594. #page
  3595. self.pageCategory = "my_shop"
  3596. for board in self.pageBoards.values():
  3597. board.Hide()
  3598. self.pageBoards["my_shop"].Show()
  3599. name = self.ShopOpenInfo["name"]
  3600. # title&duration
  3601. if '@' in name:
  3602. name = name[name.find('@')+1:]
  3603. self.MyShopShopTitle.SetText(name + " " + localeInfo.OFFLINESHOP_ITEMS_COUNT_TEXT%self.ShopOpenInfo["count"])
  3604. self.MyShopShopDuration.SetText(GetDurationString(self.ShopOpenInfo["duration"]))
  3605. #items table
  3606. self.MyShopItemsTable.ClearElement()
  3607. for item_info in self.ShopItemForSale:
  3608. slot = Slot()
  3609. slot.SetInfo(item_info)
  3610. slot.SetIndex(item_info["id"])
  3611. slot.SetOnMouseLeftButtonUpEvent(self.__OnLeftClickInsertedItem)
  3612. slot.Show()
  3613. self.MyShopItemsTable.AddElement(slot)
  3614. for item_info in self.ShopItemSold:
  3615. item_info["sold"] = True
  3616. slot = Slot(isSold=True)
  3617. slot.SetInfo(item_info)
  3618. slot.SetIndex(item_info["id"])
  3619. slot.Show()
  3620. self.MyShopItemsTable.AddElement(slot)
  3621. #offers
  3622. self.MyShopOffersTable.ClearElement()
  3623. for info in self.MyShopOffers:
  3624. # find item name
  3625. itemname = ""
  3626. for saleitem in self.ShopItemForSale:
  3627. if saleitem["id"] == info["item_id"]:
  3628. item.SelectItem(saleitem["vnum"])
  3629. itemname = item.GetItemName()
  3630. break
  3631. if not itemname:
  3632. continue
  3633. offer = Offer(info)
  3634. offer.Show()
  3635. offer.SetItemName(itemname)
  3636. if not info["is_accept"]:
  3637. offer.SetAcceptButtonEvent(self.__OnClickMyShopOfferAcceptButton)
  3638. offer.SetDeleteButtonEvent(self.__OnClickMyShopOfferCancelButton)
  3639. self.MyShopOffersTable.AddElement(offer)
  3640. def RefreshShopListPage(self):
  3641. self.pageCategory = "shop_list"
  3642. for board in self.pageBoards.values():
  3643. board.Hide()
  3644. self.pageBoards["shop_list"].Show()
  3645. self.ShopListTable.ClearElement()
  3646. for shop in self.ShopList:
  3647. element = ShopListElement(shop)
  3648. element.SetOnClickOpenShopButton(self.__OnClickShopListOpenShop)
  3649. element.Show()
  3650. self.ShopListTable.AddElement(element)
  3651. if self.itemTooltip.IsShow():
  3652. self.itemTooltip.Hide()
  3653. def RefreshOpenShopPage(self):
  3654. self.pageCategory = "open_shop"
  3655. for board in self.pageBoards.values():
  3656. board.Hide()
  3657. self.pageBoards["open_shop"].Show()
  3658. self.OpenShopItemsTable.ClearElement()
  3659. for info in self.ShopItemForSale:
  3660. slot = Slot()
  3661. slot.SetInfo(info)
  3662. slot.SetIndex(info["id"])
  3663. slot.SetOnMouseLeftButtonUpEvent(self.__OnLeftClickShopItem)
  3664. slot.Show()
  3665. self.OpenShopItemsTable.AddElement(slot)
  3666. name = self.ShopOpenInfo["name"]
  3667. duration = self.ShopOpenInfo["duration"]
  3668. if '@' in name:
  3669. name = name[name.find('@')+1:]
  3670. self.OpenShopShopTitle.SetText(name+ " " + localeInfo.OFFLINESHOP_ITEMS_COUNT_TEXT%self.ShopOpenInfo["count"])
  3671. self.OpenShopShopDuration.SetText(GetDurationString(duration))
  3672. def RefreshSearchHistoryPage(self):
  3673. self.SearchHistoryTable.ClearElement()
  3674. offlineshop.RefreshFilterHistory()
  3675. SortByDatetime(self.FilterHistory)
  3676. for elm in self.FilterHistory:
  3677. newElement = FilterHistoryElement(elm)
  3678. newElement.SetButtonEvent(self.__OnClickFilterHistoryElement)
  3679. newElement.Show()
  3680. self.SearchHistoryTable.AddElement(newElement)
  3681. def RefreshMyPatternsPage(self):
  3682. self.SearchPatternsTable.ClearElement()
  3683. offlineshop.RefreshFilterPatterns()
  3684. lst = self.FilterPatterns.values()
  3685. SortByDatetime(lst)
  3686. for v in lst:
  3687. pattern = FilterPatternElement(v)
  3688. pattern.SetButtonEvent(self.__OnClickSearchPatternElement)
  3689. pattern.Show()
  3690. self.SearchPatternsTable.AddElement(pattern)
  3691. def RefreshMyOffersPage(self):
  3692. self.pageCategory = "my_offers"
  3693. for board in self.pageBoards.values():
  3694. board.Hide()
  3695. self.pageBoards["my_offers"].Show()
  3696. self.MyOffersTable.ClearElement()
  3697. for info in self.MyOffersList:
  3698. offer = MyOffer(info)
  3699. offer.Show()
  3700. offer.SetCancelButtonEvent(self.__OnClickDeleteMyOfferButton)
  3701. slot = offer.slot
  3702. if not info['is_accept']:
  3703. viewImage = MakeOfferViewImage(info['is_notified'])
  3704. slot.AppendChild(viewImage)
  3705. viewImage.SetPosition(5,5)
  3706. viewImage.Show()
  3707. #updated 25-01-2020 #topatch
  3708. else:
  3709. offer.DisableCancelButton()
  3710. self.MyOffersTable.AddElement(offer)
  3711. def RefreshAuctionListPage(self):
  3712. self.pageCategory = "auction_list"
  3713. for board in self.pageBoards.values():
  3714. board.Hide()
  3715. self.pageBoards["auction_list"].Show()
  3716. self.AuctionListTable.ClearElement()
  3717. for info in self.AuctionListInfo:
  3718. elm = AuctionListElement(info)
  3719. elm.Show()
  3720. elm.SetIndex(info['owner_id'])
  3721. elm.SetOnClickOpenAuctionButton(self.__OnClickOpenAuctionButton)
  3722. self.AuctionListTable.AddElement(elm)
  3723. def RefreshMyAuctionPage(self):
  3724. self.pageCategory = "my_auction"
  3725. for board in self.pageBoards.values():
  3726. board.Hide()
  3727. self.pageBoards["my_auction"].Show()
  3728. self.MyAuctionOfferTable.ClearElement()
  3729. if 'offers' in self.MyAuctionInfo:
  3730. for info in SortOffersByPrice(self.MyAuctionInfo['offers']):
  3731. elm = AuctionOffer(info)
  3732. elm.Show()
  3733. self.MyAuctionOfferTable.AddElement(elm)
  3734. best_price = GetBestOfferPriceYang(self.MyAuctionInfo.get('offers', []))
  3735. if best_price ==0:
  3736. min_raise = self.MyAuctionInfo['init_yang']
  3737. else:
  3738. if best_price < 1000:
  3739. min_raise = best_price + 1000
  3740. else:
  3741. min_raise = long(float(best_price)*1.1)
  3742. self.MyAuctionBestOffer.SetText(localeInfo.NumberToMoneyString(best_price))
  3743. self.MyAuctionDuration.SetText(GetDurationString(self.MyAuctionInfo['duration']))
  3744. self.MyAuctionMinRaise.SetText(localeInfo.NumberToMoneyString(min_raise))
  3745. self.MyAuctionOwnerName.SetText(self.MyAuctionInfo['owner_name'])
  3746. if 'item' in self.MyAuctionInfo:
  3747. self.__MakeMyAuctionSlot(self.MyAuctionInfo['item'])
  3748. def RefreshOpenAuctionPage(self):
  3749. self.pageCategory = "open_auction"
  3750. for board in self.pageBoards.values():
  3751. board.Hide()
  3752. self.pageBoards["open_auction"].Show()
  3753. self.OpenAuctionOfferTable.ClearElement()
  3754. if 'offers' in self.OpenAuctionInfo:
  3755. for info in SortOffersByPrice(self.OpenAuctionInfo['offers']):
  3756. elm = AuctionOffer(info)
  3757. elm.Show()
  3758. self.OpenAuctionOfferTable.AddElement(elm)
  3759. best_price = GetBestOfferPriceYang(self.OpenAuctionInfo.get('offers' , []))
  3760. if best_price == 0:
  3761. min_raise = self.OpenAuctionInfo['init_yang']
  3762. else:
  3763. if best_price < 1000:
  3764. min_raise = best_price + 1000
  3765. else:
  3766. min_raise = long(float(best_price) * 1.1)
  3767. self.OpenAuctionInfo['min_raise'] = min_raise
  3768. self.OpenAuctionBestOffer.SetText(localeInfo.NumberToMoneyString(best_price))
  3769. self.OpenAuctionDuration.SetText(GetDurationString(self.OpenAuctionInfo['duration']))
  3770. self.OpenAuctionMinRaise.SetText(localeInfo.NumberToMoneyString(min_raise))
  3771. self.OpenAuctionOwnerName.SetText(self.OpenAuctionInfo['owner_name'])
  3772. if 'item' in self.OpenAuctionInfo:
  3773. self.__MakeOpenAuctionSlot(self.OpenAuctionInfo['item'])