Guest User

Untitled

a guest
May 2nd, 2025
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.54 KB | None | 0 0
  1. import ui
  2. import snd
  3. import shop
  4. import mouseModule
  5. import player
  6. import chr
  7. import net
  8. import uiCommon
  9. import localeInfo
  10. import chat
  11. import item
  12. import systemSetting #김준호
  13. import player #김준호
  14.  
  15. g_isBuildingPrivateShop = False
  16.  
  17. g_itemPriceDict={}
  18.  
  19. g_privateShopAdvertisementBoardDict={}
  20.  
  21. def Clear():
  22. global g_itemPriceDict
  23. global g_isBuildingPrivateShop
  24. g_itemPriceDict={}
  25. g_isBuildingPrivateShop = False
  26.  
  27. def IsPrivateShopItemPriceList():
  28. global g_itemPriceDict
  29. if g_itemPriceDict:
  30. return True
  31. else:
  32. return False
  33.  
  34. def IsBuildingPrivateShop():
  35. global g_isBuildingPrivateShop
  36. if player.IsOpenPrivateShop() or g_isBuildingPrivateShop:
  37. return True
  38. else:
  39. return False
  40.  
  41. def SetPrivateShopItemPrice(itemVNum, itemPrice):
  42. global g_itemPriceDict
  43. g_itemPriceDict[int(itemVNum)]=itemPrice
  44.  
  45. def GetPrivateShopItemPrice(itemVNum):
  46. try:
  47. global g_itemPriceDict
  48. return g_itemPriceDict[itemVNum]
  49. except KeyError:
  50. return 0
  51.  
  52. def UpdateADBoard():
  53. for key in g_privateShopAdvertisementBoardDict.keys():
  54. g_privateShopAdvertisementBoardDict[key].Show()
  55.  
  56. def DeleteADBoard(vid):
  57. if not g_privateShopAdvertisementBoardDict.has_key(vid):
  58. return
  59.  
  60. del g_privateShopAdvertisementBoardDict[vid]
  61.  
  62.  
  63. class PrivateShopAdvertisementBoard(ui.ThinBoard):
  64. def __init__(self):
  65. ui.ThinBoard.__init__(self, "UI_BOTTOM")
  66. self.shopAdvertismentBoardSeen =[]
  67. self.vid = None
  68. self.__MakeTextLine()
  69.  
  70. def __del__(self):
  71. ui.ThinBoard.__del__(self)
  72.  
  73. def __MakeTextLine(self):
  74. self.textLine = ui.TextLine()
  75. self.textLine.SetParent(self)
  76. self.textLine.SetWindowHorizontalAlignCenter()
  77. self.textLine.SetWindowVerticalAlignCenter()
  78. self.textLine.SetHorizontalAlignCenter()
  79. self.textLine.SetVerticalAlignCenter()
  80. self.textLine.Show()
  81.  
  82. def Open(self, vid, text):
  83. self.vid = vid
  84.  
  85.  
  86. self.textLine.SetText(text)
  87. if vid in self.shopAdvertismentBoardSeen:
  88. self.textLine.SetFontColor(1.0, 0.5, 0.1)
  89. self.textLine.UpdateRect()
  90. self.SetSize(len(text)*6 + 10*2, 20)
  91. self.Show()
  92.  
  93. g_privateShopAdvertisementBoardDict[vid] = self
  94.  
  95. def OnMouseLeftButtonUp(self):
  96. if not self.vid:
  97. return
  98. net.SendOnClickPacket(self.vid)
  99. if self.vid != player.GetMainCharacterIndex():
  100. self.textLine.SetFontColor(1.0, 0.5, 0.1)
  101. self.shopAdvertismentBoardSeen.append(self.vid)
  102. return True
  103.  
  104. def OnUpdate(self):
  105. if not self.vid:
  106. return
  107.  
  108. if systemSetting.IsShowSalesText():
  109. self.Show()
  110. x, y = chr.GetProjectPosition(self.vid, 220)
  111. self.SetPosition(x - self.GetWidth()/2, y - self.GetHeight()/2)
  112.  
  113. else:
  114. for key in g_privateShopAdvertisementBoardDict.keys():
  115. if player.GetMainCharacterIndex() == key: #상점풍선을 안보이게 감추는 경우에도, 플레이어 자신의 상점 풍선은 보이도록 함. by 김준호
  116. g_privateShopAdvertisementBoardDict[key].Show()
  117. x, y = chr.GetProjectPosition(player.GetMainCharacterIndex(), 220)
  118. g_privateShopAdvertisementBoardDict[key].SetPosition(x - self.GetWidth()/2, y - self.GetHeight()/2)
  119. else:
  120. g_privateShopAdvertisementBoardDict[key].Hide()
  121.  
  122. class PrivateShopBuilder(ui.ScriptWindow):
  123.  
  124. def __init__(self):
  125. #print "NEW MAKE_PRIVATE_SHOP_WINDOW ----------------------------------------------------------------"
  126. ui.ScriptWindow.__init__(self)
  127.  
  128. self.__LoadWindow()
  129. self.itemStock = {}
  130. self.tooltipItem = None
  131. self.priceInputBoard = None
  132. self.title = ""
  133.  
  134. def __del__(self):
  135. #print "------------------------------------------------------------- DELETE MAKE_PRIVATE_SHOP_WINDOW"
  136. ui.ScriptWindow.__del__(self)
  137.  
  138. def __LoadWindow(self):
  139. try:
  140. pyScrLoader = ui.PythonScriptLoader()
  141. pyScrLoader.LoadScriptFile(self, "UIScript/PrivateShopBuilder.py")
  142. except:
  143. import exception
  144. exception.Abort("PrivateShopBuilderWindow.LoadWindow.LoadObject")
  145.  
  146. try:
  147. GetObject = self.GetChild
  148. self.nameLine = GetObject("NameLine")
  149. self.itemSlot = GetObject("ItemSlot")
  150. self.btnOk = GetObject("OkButton")
  151. self.btnClose = GetObject("CloseButton")
  152. self.titleBar = GetObject("TitleBar")
  153. except:
  154. import exception
  155. exception.Abort("PrivateShopBuilderWindow.LoadWindow.BindObject")
  156.  
  157. self.btnOk.SetEvent(ui.__mem_func__(self.OnOk))
  158. self.btnClose.SetEvent(ui.__mem_func__(self.OnClose))
  159. self.titleBar.SetCloseEvent(ui.__mem_func__(self.OnClose))
  160.  
  161. self.itemSlot.SetSelectEmptySlotEvent(ui.__mem_func__(self.OnSelectEmptySlot))
  162. self.itemSlot.SetSelectItemSlotEvent(ui.__mem_func__(self.OnSelectItemSlot))
  163. self.itemSlot.SetOverInItemEvent(ui.__mem_func__(self.OnOverInItem))
  164. self.itemSlot.SetOverOutItemEvent(ui.__mem_func__(self.OnOverOutItem))
  165.  
  166. def Destroy(self):
  167. self.ClearDictionary()
  168.  
  169. self.nameLine = None
  170. self.itemSlot = None
  171. self.btnOk = None
  172. self.btnClose = None
  173. self.titleBar = None
  174. self.priceInputBoard = None
  175.  
  176. def Open(self, title):
  177.  
  178. self.title = title
  179.  
  180. if len(title) > 25:
  181. title = title[:22] + "..."
  182.  
  183. self.itemStock = {}
  184. shop.ClearPrivateShopStock()
  185. self.nameLine.SetText(title)
  186. self.SetCenterPosition()
  187. self.Refresh()
  188. self.Show()
  189.  
  190. global g_isBuildingPrivateShop
  191. g_isBuildingPrivateShop = True
  192.  
  193. def Close(self):
  194. global g_isBuildingPrivateShop
  195. g_isBuildingPrivateShop = False
  196.  
  197. self.title = ""
  198. self.itemStock = {}
  199. shop.ClearPrivateShopStock()
  200. self.Hide()
  201.  
  202. def SetItemToolTip(self, tooltipItem):
  203. self.tooltipItem = tooltipItem
  204.  
  205. def Refresh(self):
  206. getitemVNum=player.GetItemIndex
  207. getItemCount=player.GetItemCount
  208. setitemVNum=self.itemSlot.SetItemSlot
  209. delItem=self.itemSlot.ClearSlot
  210.  
  211. for i in xrange(shop.SHOP_SLOT_COUNT):
  212.  
  213. if not self.itemStock.has_key(i):
  214. delItem(i)
  215. continue
  216.  
  217. pos = self.itemStock
  218.  
  219. itemCount = getItemCount(*pos)
  220. if itemCount <= 1:
  221. itemCount = 0
  222. setitemVNum(i, getitemVNum(*pos), itemCount)
  223.  
  224. self.itemSlot.RefreshSlot()
  225.  
  226. def OnSelectEmptySlot(self, selectedSlotPos):
  227.  
  228. isAttached = mouseModule.mouseController.isAttached()
  229. if isAttached:
  230. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  231. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  232. mouseModule.mouseController.DeattachObject()
  233.  
  234. if player.SLOT_TYPE_INVENTORY != attachedSlotType and player.SLOT_TYPE_DRAGON_SOUL_INVENTORY != attachedSlotType:
  235. return
  236. attachedInvenType = player.SlotTypeToInvenType(attachedSlotType)
  237.  
  238. itemVNum = player.GetItemIndex(attachedInvenType, attachedSlotPos)
  239. item.SelectItem(itemVNum)
  240.  
  241. if item.IsAntiFlag(item.ANTIFLAG_GIVE) or item.IsAntiFlag(item.ANTIFLAG_MYSHOP):
  242. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.PRIVATE_SHOP_CANNOT_SELL_ITEM)
  243. return
  244.  
  245. priceInputBoard = uiCommon.MoneyInputDialog()
  246. priceInputBoard.SetTitle(localeInfo.PRIVATE_SHOP_INPUT_PRICE_DIALOG_TITLE)
  247. priceInputBoard.SetAcceptEvent(ui.__mem_func__(self.AcceptInputPrice))
  248. priceInputBoard.SetCancelEvent(ui.__mem_func__(self.CancelInputPrice))
  249. priceInputBoard.Open()
  250.  
  251. itemPrice=GetPrivateShopItemPrice(itemVNum)
  252.  
  253. if itemPrice>0:
  254. priceInputBoard.SetValue(itemPrice)
  255.  
  256. self.priceInputBoard = priceInputBoard
  257. self.priceInputBoard.itemVNum = itemVNum
  258. self.priceInputBoard.sourceWindowType = attachedInvenType
  259. self.priceInputBoard.sourceSlotPos = attachedSlotPos
  260. self.priceInputBoard.targetSlotPos = selectedSlotPos
  261.  
  262. def OnSelectItemSlot(self, selectedSlotPos):
  263.  
  264. isAttached = mouseModule.mouseController.isAttached()
  265. if isAttached:
  266. snd.PlaySound("sound/ui/loginfail.wav")
  267. mouseModule.mouseController.DeattachObject()
  268.  
  269. else:
  270. if not selectedSlotPos in self.itemStock:
  271. return
  272.  
  273. invenType, invenPos = self.itemStock[selectedSlotPos]
  274. shop.DelPrivateShopItemStock(invenType, invenPos)
  275. snd.PlaySound("sound/ui/drop.wav")
  276.  
  277. del self.itemStock[selectedSlotPos]
  278.  
  279. self.Refresh()
  280.  
  281. def AcceptInputPrice(self):
  282.  
  283. if not self.priceInputBoard:
  284. return True
  285.  
  286. text = self.priceInputBoard.GetText()
  287.  
  288. if not text:
  289. return True
  290.  
  291. if not text.isdigit():
  292. return True
  293.  
  294. if int(text) <= 0:
  295. return True
  296.  
  297. attachedInvenType = self.priceInputBoard.sourceWindowType
  298. sourceSlotPos = self.priceInputBoard.sourceSlotPos
  299. targetSlotPos = self.priceInputBoard.targetSlotPos
  300.  
  301. for privatePos, (itemWindowType, itemSlotIndex) in self.itemStock.items():
  302. if itemWindowType == attachedInvenType and itemSlotIndex == sourceSlotPos:
  303. shop.DelPrivateShopItemStock(itemWindowType, itemSlotIndex)
  304. del self.itemStock[privatePos]
  305.  
  306. price = int(self.priceInputBoard.GetText())
  307.  
  308. if IsPrivateShopItemPriceList():
  309. SetPrivateShopItemPrice(self.priceInputBoard.itemVNum, price)
  310.  
  311. shop.AddPrivateShopItemStock(attachedInvenType, sourceSlotPos, targetSlotPos, price)
  312. self.itemStock[targetSlotPos] = (attachedInvenType, sourceSlotPos)
  313. snd.PlaySound("sound/ui/drop.wav")
  314.  
  315. self.Refresh()
  316.  
  317. #####
  318.  
  319. self.priceInputBoard = None
  320. return True
  321.  
  322. def CancelInputPrice(self):
  323. self.priceInputBoard = None
  324. return True
  325.  
  326. def OnOk(self):
  327.  
  328. if not self.title:
  329. return
  330.  
  331. if 0 == len(self.itemStock):
  332. return
  333.  
  334. shop.BuildPrivateShop(self.title)
  335. self.Close()
  336.  
  337. def OnClose(self):
  338. self.Close()
  339.  
  340. def OnPressEscapeKey(self):
  341. self.Close()
  342. return True
  343.  
  344. def OnOverInItem(self, slotIndex):
  345.  
  346. if self.tooltipItem:
  347. if self.itemStock.has_key(slotIndex):
  348. self.tooltipItem.SetPrivateShopBuilderItem(*self.itemStock[slotIndex] + (slotIndex,))
  349.  
  350. def OnOverOutItem(self):
  351.  
  352. if self.tooltipItem:
  353. self.tooltipItem.HideToolTip()
Advertisement
Add Comment
Please, Sign In to add comment