Advertisement
Proiect

uishop

Apr 10th, 2020
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.16 KB | None | 0 0
  1. import net
  2. import player
  3. import item
  4. import snd
  5. import shop
  6. import net
  7. import wndMgr
  8. import app
  9. import chat
  10. import constInfo
  11. import ui
  12. import uiCommon
  13. import mouseModule
  14. import localeInfo
  15. import chr
  16.  
  17. ###################################################################################################
  18. ## Shop
  19. class ShopDialog(ui.ScriptWindow):
  20.  
  21. def __init__(self):
  22. ui.ScriptWindow.__init__(self)
  23. self.tooltipItem = 0
  24. self.xShopStart = 0
  25. self.yShopStart = 0
  26. self.questionDialog = None
  27. self.popup = None
  28. self.itemBuyQuestionDialog = None
  29. if app.WJ_ENABLE_TRADABLE_ICON:
  30. self.interface = None
  31. self.vid = 0
  32.  
  33. def __del__(self):
  34. ui.ScriptWindow.__del__(self)
  35.  
  36. def GetEmptyLines(self):
  37. emptyLines = 10
  38. for i in xrange(5):
  39. empty = 10
  40. for j in xrange(10):
  41. itemIndex = shop.GetItemID(5*j+i)
  42. if itemIndex > 0:
  43. item.SelectItem(itemIndex)
  44. (w, h) = item.GetItemSize()
  45. empty -= h
  46. if empty < emptyLines:
  47. emptyLines = empty
  48. return emptyLines
  49.  
  50. def __GetRealIndex(self, i):
  51. return self.tabIdx * shop.SHOP_SLOT_COUNT + i
  52.  
  53. def Refresh(self):
  54. if app.ENABLE_BATTLE_FIELD:
  55. coinType = shop.GetTabCoinType(self.tabIdx)
  56. if shop.SHOP_COIN_TYPE_BATTLE_POINT == coinType:
  57. self.battleBoard.Show()
  58. self.battleMyPoints.SetText(localeInfo.SHOP_MY_BATTLE_POINT % (player.GetBattlePoints()))
  59. self.battleUsablePoints.SetText(localeInfo.SHOP_LIMIT_TODAY % (shop.GetUsablePoint(),shop.GetLimitMaxPoint()))
  60. else:
  61. self.battleBoard.Hide()
  62. getItemID=shop.GetItemID
  63. getItemCount=shop.GetItemCount
  64. setItemID=self.itemSlotWindow.SetItemSlot
  65. for i in xrange(shop.SHOP_SLOT_COUNT):
  66. idx = self.__GetRealIndex(i)
  67. itemCount = getItemCount(idx)
  68. if itemCount <= 1:
  69. itemCount = 0
  70. setItemID(i, getItemID(idx), itemCount)
  71.  
  72. if app.ENABLE_CHANGELOOK_SYSTEM:
  73. itemTransmutedVnum = shop.GetItemTransmutation(idx)
  74. if itemTransmutedVnum:
  75. self.itemSlotWindow.DisableCoverButton(i)
  76. else:
  77. self.itemSlotWindow.EnableCoverButton(i)
  78.  
  79. wndMgr.RefreshSlot(self.itemSlotWindow.GetWindowHandle())
  80.  
  81. def SetItemData(self, pos, itemID, itemCount, itemPrice):
  82. shop.SetItemData(pos, itemID, itemCount, itemPrice)
  83.  
  84. def LoadDialog(self):
  85. try:
  86. PythonScriptLoader = ui.PythonScriptLoader()
  87. PythonScriptLoader.LoadScriptFile(self, "UIScript/ShopDialog.py")
  88. except:
  89. import exception
  90. exception.Abort("ShopDialog.LoadDialog.LoadObject")
  91.  
  92. smallTab1 = None
  93. smallTab2 = None
  94. smallTab3 = None
  95. middleTab1 = None
  96. middleTab2 = None
  97.  
  98. try:
  99. GetObject = self.GetChild
  100. self.board = GetObject("board")
  101. self.itemSlotWindow = GetObject("ItemSlot")
  102. #self.NameSlotWindow = GetObject("NameSlot")
  103. self.btnBuy = GetObject("BuyButton")
  104. self.btnSell = GetObject("SellButton")
  105. self.btnClose = GetObject("CloseButton")
  106. self.titleBar = GetObject("TitleBar")
  107. middleTab1 = GetObject("MiddleTab1")
  108. middleTab2 = GetObject("MiddleTab2")
  109. smallTab1 = GetObject("SmallTab1")
  110. smallTab2 = GetObject("SmallTab2")
  111. smallTab3 = GetObject("SmallTab3")
  112. if app.ENABLE_BATTLE_FIELD:
  113. self.battleBoard = GetObject("BattleShopSubBoard")
  114. self.battleMyPoints = GetObject("BattleShopSubInfo1")
  115. self.battleUsablePoints = GetObject("BattleShopSubInfo2")
  116. except:
  117. import exception
  118. exception.Abort("ShopDialog.LoadDialog.BindObject")
  119.  
  120. self.itemSlotWindow.SetSlotStyle(wndMgr.SLOT_STYLE_NONE)
  121. self.itemSlotWindow.SAFE_SetButtonEvent("LEFT", "EMPTY", self.SelectEmptySlot)
  122. self.itemSlotWindow.SAFE_SetButtonEvent("LEFT", "EXIST", self.SelectItemSlot)
  123. self.itemSlotWindow.SAFE_SetButtonEvent("RIGHT", "EXIST", self.UnselectItemSlot)
  124.  
  125. self.itemSlotWindow.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
  126. self.itemSlotWindow.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
  127.  
  128. self.btnBuy.SetToggleUpEvent(ui.__mem_func__(self.CancelShopping))
  129. self.btnBuy.SetToggleDownEvent(ui.__mem_func__(self.OnBuy))
  130.  
  131. self.btnSell.SetToggleUpEvent(ui.__mem_func__(self.CancelShopping))
  132. self.btnSell.SetToggleDownEvent(ui.__mem_func__(self.OnSell))
  133.  
  134. self.btnClose.SetEvent(ui.__mem_func__(self.AskClosePrivateShop))
  135.  
  136. self.titleBar.SetCloseEvent(ui.__mem_func__(self.Close))
  137.  
  138. self.smallRadioButtonGroup = ui.RadioButtonGroup.Create([[smallTab1, lambda : self.OnClickTabButton(0), None], [smallTab2, lambda : self.OnClickTabButton(1), None], [smallTab3, lambda : self.OnClickTabButton(2), None]])
  139. self.middleRadioButtonGroup = ui.RadioButtonGroup.Create([[middleTab1, lambda : self.OnClickTabButton(0), None], [middleTab2, lambda : self.OnClickTabButton(1), None]])
  140.  
  141. self.__HideMiddleTabs()
  142. self.__HideSmallTabs()
  143.  
  144. self.tabIdx = 0
  145. self.coinType = shop.SHOP_COIN_TYPE_GOLD
  146.  
  147. self.Refresh()
  148.  
  149. def __ShowBuySellButton(self):
  150. self.btnBuy.Show()
  151. self.btnSell.Show()
  152.  
  153. def __ShowMiddleTabs(self):
  154. self.middleRadioButtonGroup.Show()
  155.  
  156. def __ShowSmallTabs(self):
  157. self.smallRadioButtonGroup.Show()
  158.  
  159. def __HideBuySellButton(self):
  160. self.btnBuy.Hide()
  161. self.btnSell.Hide()
  162.  
  163. def __HideMiddleTabs(self):
  164. self.middleRadioButtonGroup.Hide()
  165.  
  166. def __HideSmallTabs(self):
  167. self.smallRadioButtonGroup.Hide()
  168.  
  169. def __SetTabNames(self):
  170. if shop.GetTabCount() == 2:
  171. self.middleRadioButtonGroup.SetText(0, shop.GetTabName(0))
  172. self.middleRadioButtonGroup.SetText(1, shop.GetTabName(1))
  173. elif shop.GetTabCount() == 3:
  174. self.smallRadioButtonGroup.SetText(0, shop.GetTabName(0))
  175. self.smallRadioButtonGroup.SetText(1, shop.GetTabName(1))
  176. self.smallRadioButtonGroup.SetText(2, shop.GetTabName(2))
  177.  
  178. def Destroy(self):
  179. if app.WJ_ENABLE_TRADABLE_ICON:
  180. self.Close(True)
  181. self.interface = None
  182. else:
  183. self.Close()
  184. self.ClearDictionary()
  185.  
  186. self.tooltipItem = 0
  187. self.board = 0
  188. self.itemSlotWindow = 0
  189. self.btnBuy = 0
  190. self.btnSell = 0
  191. self.btnClose = 0
  192. self.titleBar = 0
  193. self.questionDialog = None
  194. self.popup = None
  195. self.vid = 0
  196.  
  197. def Open(self, vid, type=0):
  198. self.vid=int(vid)
  199. isPrivateShop = False
  200. isMainPlayerPrivateShop = False
  201. myshop=False
  202.  
  203. for i in xrange(len(constInfo.MyShops)):
  204. if int(constInfo.MyShops[i]["vid"]) == int(self.vid):
  205. myshop=True
  206. self.vid=int(constInfo.MyShops[i]["id"])
  207.  
  208. chr.SelectInstance(self.vid)
  209.  
  210. if chr.GetRace() == 30000 or not chr.IsNPC(self.vid):
  211. isPrivateShop = True
  212.  
  213. self.board.SetSize(184, 392)
  214. self.itemSlotWindow.ArrangeSlot(0, 5, 10, 32, 32, 0, 0)
  215. self.itemSlotWindow.RefreshSlot()
  216. self.itemSlotWindow.SetSlotBaseImage("d:/ymir work/ui/public/Slot_Base.sub", 1.0, 1.0, 1.0, 1.0)
  217. self.btnBuy.SetPosition(21, 359)
  218. self.btnSell.SetPosition(104, 359)
  219.  
  220. if player.IsMainCharacterIndex(self.vid):
  221. myshop=True
  222. self.vid=""
  223.  
  224. if myshop == True:
  225. isMainPlayerPrivateShop = True
  226.  
  227. self.btnBuy.Hide()
  228. self.btnSell.Hide()
  229. self.btnClose.Show()
  230. else:
  231. if isPrivateShop == FALSE:
  232. EMPTY_LINES = 32 * self.GetEmptyLines()
  233.  
  234. self.board.SetSize(184, 392 - EMPTY_LINES)
  235.  
  236. self.itemSlotWindow.ArrangeSlot(0, 5, 10 - EMPTY_LINES / 32, 32, 32, 0, 0)
  237. self.itemSlotWindow.RefreshSlot()
  238. self.itemSlotWindow.SetSlotBaseImage("d:/ymir work/ui/public/Slot_Base.sub", 1.0, 1.0, 1.0, 1.0)
  239.  
  240. self.btnBuy.SetPosition(21, 359 - EMPTY_LINES)
  241. self.btnSell.SetPosition(104, 359 - EMPTY_LINES)
  242.  
  243. isMainPlayerPrivateShop = False
  244.  
  245. self.btnBuy.Show()
  246. self.btnSell.Show()
  247. self.btnClose.Hide()
  248.  
  249. shop.Open(isPrivateShop, isMainPlayerPrivateShop)
  250.  
  251. self.Refresh()
  252. self.SetTop()
  253. self.Show()
  254.  
  255. (self.xShopStart, self.yShopStart, z) = player.GetMainCharacterPosition()
  256.  
  257. if app.WJ_ENABLE_TRADABLE_ICON:
  258. if not isPrivateShop:
  259. self.interface.SetOnTopWindow(player.ON_TOP_WND_SHOP)
  260. self.interface.RefreshMarkInventoryBag()
  261.  
  262. if app.WJ_ENABLE_TRADABLE_ICON:
  263. def Close(self, isDestroy=False):
  264. self.interface.SetOnTopWindow(player.ON_TOP_WND_NONE)
  265. if not isDestroy:
  266. self.interface.RefreshMarkInventoryBag()
  267.  
  268. if self.itemBuyQuestionDialog:
  269. self.itemBuyQuestionDialog.Close()
  270. self.itemBuyQuestionDialog = None
  271. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
  272.  
  273. self.OnCloseQuestionDialog()
  274. shop.Close()
  275. net.SendShopEndPacket()
  276. self.CancelShopping()
  277. self.tooltipItem.HideToolTip()
  278. self.Hide()
  279. else:
  280. def Close(self):
  281. if self.itemBuyQuestionDialog:
  282. self.itemBuyQuestionDialog.Close()
  283. self.itemBuyQuestionDialog = None
  284. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
  285.  
  286. self.OnCloseQuestionDialog()
  287. shop.Close()
  288. net.SendShopEndPacket()
  289. self.CancelShopping()
  290. self.tooltipItem.HideToolTip()
  291. self.Hide()
  292.  
  293. def GetIndexFromSlotPos(self, slotPos):
  294. return self.tabIdx * shop.SHOP_SLOT_COUNT + slotPos
  295.  
  296. if app.ENABLE_BATTLE_FIELD:
  297. def ResetUsedBP(self, usedBP):
  298. self.battleUsablePoints.SetText(localeInfo.SHOP_LIMIT_TODAY % (int(usedBP),int(shop.GetLimitMaxPoint())))
  299.  
  300. def RefreshMyBP(self):
  301. self.battleMyPoints.SetText(localeInfo.SHOP_MY_BATTLE_POINT % (player.GetBattlePoints()))
  302.  
  303. def OnClickTabButton(self, idx):
  304. self.tabIdx = idx
  305. self.Refresh()
  306.  
  307. def AskClosePrivateShop(self):
  308. questionDialog = uiCommon.QuestionDialog()
  309. questionDialog.SetText(localeInfo.PRIVATE_SHOP_CLOSE_QUESTION)
  310. questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnClosePrivateShop))
  311. questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  312. questionDialog.Open()
  313. self.questionDialog = questionDialog
  314.  
  315. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
  316.  
  317. return True
  318.  
  319. def OnClosePrivateShop(self):
  320. net.SendChatPacket("/close_shop "+str(self.vid))
  321. self.OnCloseQuestionDialog()
  322. return True
  323.  
  324. def OnPressEscapeKey(self):
  325. self.Close()
  326. return True
  327.  
  328. def OnPressExitKey(self):
  329. self.Close()
  330. return True
  331.  
  332. def OnBuy(self):
  333. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_BUY_INFO)
  334. app.SetCursor(app.BUY)
  335. self.btnSell.SetUp()
  336.  
  337. def OnSell(self):
  338. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_SELL_INFO)
  339. app.SetCursor(app.SELL)
  340. self.btnBuy.SetUp()
  341.  
  342. def CancelShopping(self):
  343. self.btnBuy.SetUp()
  344. self.btnSell.SetUp()
  345. app.SetCursor(app.NORMAL)
  346.  
  347. def __OnClosePopupDialog(self):
  348. self.pop = None
  349. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
  350.  
  351. ## ��ȥ�� �ȸ��� ���� �߰�.
  352. def SellAttachedItem(self):
  353.  
  354. if shop.IsPrivateShop():
  355. mouseModule.mouseController.DeattachObject()
  356. return
  357.  
  358. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  359. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  360. attachedCount = mouseModule.mouseController.GetAttachedItemCount()
  361. attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()
  362.  
  363. if app.ENABLE_SPECIAL_STORAGE:
  364. if player.SLOT_TYPE_INVENTORY == attachedSlotType or\
  365. player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == attachedSlotType or\
  366. player.SLOT_TYPE_UPGRADE_INVENTORY == attachedSlotType or\
  367. player.SLOT_TYPE_BOOK_INVENTORY == attachedSlotType or\
  368. player.SLOT_TYPE_STONE_INVENTORY == attachedSlotType:
  369.  
  370. item.SelectItem(attachedItemIndex)
  371.  
  372. if item.IsAntiFlag(item.ANTIFLAG_SELL):
  373. popup = uiCommon.PopupDialog()
  374. popup.SetText(localeInfo.SHOP_CANNOT_SELL_ITEM)
  375. popup.SetAcceptEvent(self.__OnClosePopupDialog)
  376. popup.Open()
  377. self.popup = popup
  378. return
  379.  
  380. itemtype = player.SlotTypeToInvenType(attachedSlotType)
  381.  
  382. if player.IsValuableItem(itemtype, attachedSlotPos):
  383.  
  384. itemPrice = item.GetISellItemPrice()
  385.  
  386. if item.Is1GoldItem():
  387. itemPrice = attachedCount / itemPrice / 5
  388. else:
  389. itemPrice = itemPrice * max(1, attachedCount) / 5
  390.  
  391. itemName = item.GetItemName()
  392.  
  393. questionDialog = uiCommon.QuestionDialog()
  394. questionDialog.SetText(localeInfo.DO_YOU_SELL_ITEM(itemName, attachedCount, itemPrice))
  395.  
  396. questionDialog.SetAcceptEvent(lambda arg1=attachedSlotPos, arg2=attachedCount, arg3 = itemtype: self.OnSellItem(arg1, arg2, arg3))
  397. questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  398. questionDialog.Open()
  399. self.questionDialog = questionDialog
  400.  
  401. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
  402.  
  403. else:
  404. self.OnSellItem(attachedSlotPos, attachedCount, itemtype)
  405. else:
  406. snd.PlaySound("sound/ui/loginfail.wav")
  407. else:
  408. if player.SLOT_TYPE_INVENTORY == attachedSlotType or player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == attachedSlotType:
  409.  
  410. item.SelectItem(attachedItemIndex)
  411.  
  412. if item.IsAntiFlag(item.ANTIFLAG_SELL):
  413. popup = uiCommon.PopupDialog()
  414. popup.SetText(localeInfo.SHOP_CANNOT_SELL_ITEM)
  415. popup.SetAcceptEvent(self.__OnClosePopupDialog)
  416. popup.Open()
  417. self.popup = popup
  418. return
  419.  
  420. itemtype = player.INVENTORY
  421.  
  422. if player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == attachedSlotType:
  423. itemtype = player.DRAGON_SOUL_INVENTORY
  424.  
  425. if player.IsValuableItem(itemtype, attachedSlotPos):
  426.  
  427. itemPrice = item.GetISellItemPrice()
  428.  
  429. if item.Is1GoldItem():
  430. itemPrice = attachedCount / itemPrice / 5
  431. else:
  432. itemPrice = itemPrice * max(1, attachedCount) / 5
  433.  
  434. itemName = item.GetItemName()
  435.  
  436. questionDialog = uiCommon.QuestionDialog()
  437. questionDialog.SetText(localeInfo.DO_YOU_SELL_ITEM(itemName, attachedCount, itemPrice))
  438.  
  439. questionDialog.SetAcceptEvent(lambda arg1=attachedSlotPos, arg2=attachedCount, arg3 = itemtype: self.OnSellItem(arg1, arg2, arg3))
  440. questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  441. questionDialog.Open()
  442. self.questionDialog = questionDialog
  443.  
  444. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
  445.  
  446. else:
  447. self.OnSellItem(attachedSlotPos, attachedCount, itemtype)
  448. else:
  449. snd.PlaySound("sound/ui/loginfail.wav")
  450.  
  451. mouseModule.mouseController.DeattachObject()
  452.  
  453. def OnSellItem(self, slotPos, count, itemtype):
  454. net.SendShopSellPacketNew(slotPos, count, itemtype)
  455. snd.PlaySound("sound/ui/money.wav")
  456. self.OnCloseQuestionDialog()
  457.  
  458. def OnCloseQuestionDialog(self):
  459. if not self.questionDialog:
  460. return
  461.  
  462. self.questionDialog.Close()
  463. self.questionDialog = None
  464. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
  465.  
  466. def SelectEmptySlot(self, selectedSlotPos):
  467.  
  468. isAttached = mouseModule.mouseController.isAttached()
  469. if isAttached:
  470. self.SellAttachedItem()
  471.  
  472. def UnselectItemSlot(self, selectedSlotPos):
  473. if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
  474. return
  475. if shop.IsPrivateShop():
  476. self.AskBuyItem(selectedSlotPos)
  477. else:
  478. net.SendShopBuyPacket(self.__GetRealIndex(selectedSlotPos))
  479.  
  480. def SelectItemSlot(self, selectedSlotPos):
  481. if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
  482. return
  483.  
  484. isAttached = mouseModule.mouseController.isAttached()
  485. selectedSlotPos = self.__GetRealIndex(selectedSlotPos)
  486. if isAttached:
  487. self.SellAttachedItem()
  488.  
  489. else:
  490.  
  491. if True == shop.IsMainPlayerPrivateShop():
  492. return
  493.  
  494. curCursorNum = app.GetCursor()
  495. if app.BUY == curCursorNum:
  496. self.AskBuyItem(selectedSlotPos)
  497.  
  498. elif app.SELL == curCursorNum:
  499. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_SELL_INFO)
  500.  
  501. else:
  502. selectedItemID = shop.GetItemID(selectedSlotPos)
  503. itemCount = shop.GetItemCount(selectedSlotPos)
  504.  
  505. type = player.SLOT_TYPE_SHOP
  506. if shop.IsPrivateShop():
  507. type = player.SLOT_TYPE_PRIVATE_SHOP
  508.  
  509. mouseModule.mouseController.AttachObject(self, type, selectedSlotPos, selectedItemID, itemCount)
  510. mouseModule.mouseController.SetCallBack("INVENTORY", ui.__mem_func__(self.DropToInventory))
  511. snd.PlaySound("sound/ui/pick.wav")
  512.  
  513. def DropToInventory(self):
  514. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  515. self.AskBuyItem(attachedSlotPos)
  516.  
  517. def AskBuyItem(self, slotPos):
  518. slotPos = self.__GetRealIndex(slotPos)
  519.  
  520. itemIndex = shop.GetItemID(slotPos)
  521. itemPrice = shop.GetItemPrice(slotPos)
  522. itemCount = shop.GetItemCount(slotPos)
  523.  
  524. item.SelectItem(itemIndex)
  525. itemName = item.GetItemName()
  526.  
  527. itemBuyQuestionDialog = uiCommon.QuestionDialog()
  528. if app.__MULTI_SHOP__:
  529. if shop.GetBuyWithItem(slotPos) != 0:
  530. itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToWithItemString(shop.GetBuyWithItemCount(slotPos), item.GetItemName())))
  531. else:
  532. itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice)))
  533. itemBuyQuestionDialog.SetAcceptEvent(lambda arg=TRUE: self.AnswerBuyItem(arg))
  534. itemBuyQuestionDialog.SetCancelEvent(lambda arg=False: self.AnswerBuyItem(arg))
  535. itemBuyQuestionDialog.Open()
  536. itemBuyQuestionDialog.pos = slotPos
  537. self.itemBuyQuestionDialog = itemBuyQuestionDialog
  538.  
  539. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
  540.  
  541. def AnswerBuyItem(self, flag):
  542.  
  543. if flag:
  544. pos = self.itemBuyQuestionDialog.pos
  545. net.SendShopBuyPacket(pos)
  546.  
  547. self.itemBuyQuestionDialog.Close()
  548. self.itemBuyQuestionDialog = None
  549.  
  550. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
  551.  
  552. def SetItemToolTip(self, tooltipItem):
  553. self.tooltipItem = tooltipItem
  554.  
  555. def OverInItem(self, slotIndex):
  556. slotIndex = self.__GetRealIndex(slotIndex)
  557. if mouseModule.mouseController.isAttached():
  558. return
  559.  
  560. if 0 != self.tooltipItem:
  561. if shop.SHOP_COIN_TYPE_GOLD == shop.GetTabCoinType(self.tabIdx):
  562. self.tooltipItem.SetShopItem(slotIndex)
  563. else:
  564. if app.ENABLE_BATTLE_FIELD:
  565. self.tooltipItem.SetShopItemBySecondaryCoin(slotIndex, shop.GetTabCoinType(self.tabIdx))
  566. else:
  567. self.tooltipItem.SetShopItemBySecondaryCoin(slotIndex)
  568. def OverOutItem(self):
  569. if 0 != self.tooltipItem:
  570. self.tooltipItem.HideToolTip()
  571.  
  572. def OnUpdate(self):
  573.  
  574. USE_SHOP_LIMIT_RANGE = 1000
  575.  
  576. (x, y, z) = player.GetMainCharacterPosition()
  577. if abs(x - self.xShopStart) > USE_SHOP_LIMIT_RANGE or abs(y - self.yShopStart) > USE_SHOP_LIMIT_RANGE:
  578. self.Close()
  579.  
  580. if app.WJ_ENABLE_TRADABLE_ICON:
  581. def BindInterface(self, interface):
  582. self.interface = interface
  583.  
  584. def OnTop(self):
  585. if not shop.IsPrivateShop():
  586. self.interface.SetOnTopWindow(player.ON_TOP_WND_SHOP)
  587. self.interface.RefreshMarkInventoryBag()
  588.  
  589.  
  590. class MallPageDialog(ui.ScriptWindow):
  591. def __init__(self):
  592. ui.ScriptWindow.__init__(self)
  593.  
  594. def __del__(self):
  595. ui.ScriptWindow.__del__(self)
  596.  
  597. def Destroy(self):
  598. self.ClearDictionary()
  599.  
  600. def Open(self):
  601. scriptLoader = ui.PythonScriptLoader()
  602. scriptLoader.LoadScriptFile(self, "uiscript/mallpagedialog.py")
  603.  
  604. self.GetChild("titlebar").SetCloseEvent(ui.__mem_func__(self.Close))
  605.  
  606. (x, y)=self.GetGlobalPosition()
  607. x+=10
  608. y+=30
  609.  
  610. MALL_PAGE_WIDTH = 1024
  611. MALL_PAGE_HEIGHT = 600
  612.  
  613. app.ShowWebPage("http://google.com/", (x+10, y+40, x+width-20, y+height-40))
  614.  
  615. self.Lock()
  616. self.Show()
  617.  
  618. def Close(self):
  619. app.HideWebPage()
  620. self.Unlock()
  621. self.Hide()
  622.  
  623. def OnPressEscapeKey(self):
  624. self.Close()
  625. return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement