Advertisement
Guest User

Untitled

a guest
Jul 12th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.21 KB | None | 0 0
  1. import ui
  2. import net
  3. import grp
  4. import snd
  5. import item
  6. import acce
  7. import player
  8. import uiToolTip
  9. import localeInfo
  10. import uiInventory
  11. import mouseModule
  12. import uiScriptLocale
  13.  
  14. class CombineWindow(ui.ScriptWindow):
  15. def __init__(self):
  16. ui.ScriptWindow.__init__(self)
  17. self.isLoaded = 0
  18. self.PositionOut = 0
  19. self.PositionStartX = 50
  20. self.PositionStartY = 50
  21.  
  22. def __del__(self):
  23. ui.ScriptWindow.__del__(self)
  24.  
  25. def Destroy(self):
  26. self.ClearDictionary()
  27. self.titleBar = None
  28. self.btnAccept = None
  29. self.btnCancel = None
  30. self.acceSlot = None
  31. self.needMoney = None
  32. self.Result = None
  33. self.PositionOut = 0
  34. self.PositionStartX = 0
  35. self.PositionStartY = 0
  36.  
  37. def LoadWindow(self):
  38. if self.isLoaded:
  39. return
  40.  
  41. self.isLoaded = 1
  42.  
  43. try:
  44. pyScrLoader = ui.PythonScriptLoader()
  45. pyScrLoader.LoadScriptFile(self, "uiscript/acce_combinewindow.py")
  46.  
  47. except:
  48. import exception
  49. exception.Abort("Acce_CombineWindow.LoadDialog.LoadScript")
  50.  
  51. try:
  52. self.titleBar = self.GetChild("TitleBar")
  53. self.btnAccept = self.GetChild("AcceptButton")
  54. self.btnCancel = self.GetChild("CancelButton")
  55. self.needMoney = self.GetChild("NeedMoney")
  56. self.Result = self.GetChild("Result")
  57. self.acceSlot = self.GetChild("AcceSlot")
  58. except:
  59. import exception
  60. exception.Abort("Acce_CombineWindow.LoadDialog.BindObject")
  61.  
  62. self.acceSlot.SetSelectEmptySlotEvent(ui.__mem_func__(self.OnSelectEmptySlot))
  63. self.acceSlot.SetUnselectItemSlotEvent(ui.__mem_func__(self.OnSelectItemSlot))
  64. self.acceSlot.SetUseSlotEvent(ui.__mem_func__(self.OnSelectItemSlot))
  65. self.acceSlot.SetOverInItemEvent(ui.__mem_func__(self.OnOverInItem))
  66. self.acceSlot.SetOverOutItemEvent(ui.__mem_func__(self.OnOverOutItem))
  67. self.titleBar.SetCloseEvent(ui.__mem_func__(self.OnClose))
  68. self.btnCancel.SetEvent(ui.__mem_func__(self.OnClose))
  69. self.btnAccept.SetEvent(ui.__mem_func__(self.OnAccept))
  70. self.tooltipItem = None
  71.  
  72. def SetItemToolTip(self, itemTooltip):
  73. self.tooltipItem = itemTooltip
  74.  
  75. def IsOpened(self):
  76. if self.IsShow() and self.isLoaded:
  77. return TRUE
  78.  
  79. return FALSE
  80.  
  81. def Open(self):
  82. self.PositionOut = 0
  83. (self.PositionStartX, self.PositionStartY, z) = player.GetMainCharacterPosition()
  84. self.needMoney.SetText(localeInfo.ACCE_REFINE_COST % (acce.GetPrice()))
  85. for i in xrange(acce.WINDOW_MAX_MATERIALS + 1):
  86. self.acceSlot.ClearSlot(i)
  87.  
  88. self.Show()
  89.  
  90. def Close(self):
  91. if self.tooltipItem:
  92. self.tooltipItem.HideToolTip()
  93.  
  94. self.Hide()
  95.  
  96. def OnClose(self):
  97. acce.SendCloseRequest()
  98.  
  99. def OnPressEscapeKey(self):
  100. self.OnClose()
  101. return TRUE
  102.  
  103. def OnAccept(self, selectedSlotPos):
  104. itemVnum = player.GetItemIndex(player.INVENTORY, selectedSlotPos)
  105. if itemVnum != 86059:
  106. acce.SendRefineRequest()
  107.  
  108. def OnUpdate(self):
  109. LIMIT_RANGE = acce.LIMIT_RANGE
  110. (x, y, z) = player.GetMainCharacterPosition()
  111. if abs(x - self.PositionStartX) >= LIMIT_RANGE or abs(y - self.PositionStartY) >= LIMIT_RANGE:
  112. if not self.PositionOut:
  113. self.PositionOut += 1
  114. self.OnClose()
  115.  
  116. def OnSelectEmptySlot(self, selectedSlotPos):
  117. isAttached = mouseModule.mouseController.isAttached()
  118. if not isAttached or selectedSlotPos == acce.WINDOW_MAX_MATERIALS:
  119. return
  120.  
  121. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  122. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  123. attachedInvenType = player.SlotTypeToInvenType(attachedSlotType)
  124. mouseModule.mouseController.DeattachObject()
  125. if attachedSlotType == player.SLOT_TYPE_INVENTORY and attachedInvenType == player.INVENTORY:
  126. acce.Add(attachedInvenType, attachedSlotPos, selectedSlotPos)
  127.  
  128. def OnSelectItemSlot(self, selectedSlotPos):
  129. if selectedSlotPos == acce.WINDOW_MAX_MATERIALS:
  130. return
  131.  
  132. mouseModule.mouseController.DeattachObject()
  133. acce.Remove(selectedSlotPos)
  134.  
  135. def OnOverInItem(self, selectedSlotPos):
  136. if self.tooltipItem:
  137. if selectedSlotPos == acce.WINDOW_MAX_MATERIALS:
  138. (isHere, iCell) = acce.GetAttachedItem(0)
  139. if isHere:
  140. self.tooltipItem.SetAcceResultItem(iCell)
  141. else:
  142. (isHere, iCell) = acce.GetAttachedItem(selectedSlotPos)
  143. if isHere:
  144. self.tooltipItem.SetInventoryItem(iCell)
  145.  
  146. def OnOverOutItem(self):
  147. if self.tooltipItem:
  148. self.tooltipItem.HideToolTip()
  149.  
  150. def Refresh(self, iAct):
  151. self.needMoney.SetText(localeInfo.ACCE_REFINE_COST % (acce.GetPrice()))
  152. self.acceSlot.ClearSlot(acce.WINDOW_MAX_MATERIALS)
  153. for i in xrange(acce.WINDOW_MAX_MATERIALS):
  154. self.acceSlot.ClearSlot(i)
  155. (isHere, iCell) = acce.GetAttachedItem(i)
  156. if isHere:
  157. self.acceSlot.SetItemSlot(i, player.GetItemIndex(iCell), 0)
  158. if i == int(acce.WINDOW_MAX_MATERIALS - 1):
  159. (itemVnum, MinAbs, MaxAbs) = acce.GetResultItem()
  160. if not itemVnum:
  161. break
  162.  
  163. self.acceSlot.SetItemSlot(i + 1, itemVnum, 0)
  164. break
  165.  
  166. class AbsorbWindow(ui.ScriptWindow):
  167. def __init__(self):
  168. ui.ScriptWindow.__init__(self)
  169. self.isLoaded = 0
  170. self.PositionOut = 0
  171. self.PositionStartX = 50
  172. self.PositionStartY = 50
  173.  
  174. def __del__(self):
  175. ui.ScriptWindow.__del__(self)
  176.  
  177. def Destroy(self):
  178. self.ClearDictionary()
  179. self.titleBar = None
  180. self.btnAccept = None
  181. self.btnCancel = None
  182. self.acceSlot = None
  183. self.PositionOut = 0
  184. self.PositionStartX = 0
  185. self.PositionStartY = 0
  186.  
  187. def LoadWindow(self):
  188. if self.isLoaded:
  189. return
  190.  
  191. self.isLoaded = 1
  192.  
  193. try:
  194. pyScrLoader = ui.PythonScriptLoader()
  195. pyScrLoader.LoadScriptFile(self, "uiscript/acce_absorbwindow.py")
  196.  
  197. except:
  198. import exception
  199. exception.Abort("Acce_AbsorbtionWindow.LoadDialog.LoadScript")
  200.  
  201. try:
  202. self.titleBar = self.GetChild("TitleBar")
  203. self.btnAccept = self.GetChild("AcceptButton")
  204. self.btnCancel = self.GetChild("CancelButton")
  205. self.acceSlot = self.GetChild("AcceSlot")
  206. except:
  207. import exception
  208. exception.Abort("Acce_AbsorbtionWindow.LoadDialog.BindObject")
  209.  
  210. self.acceSlot.SetSelectEmptySlotEvent(ui.__mem_func__(self.OnSelectEmptySlot))
  211. self.acceSlot.SetUnselectItemSlotEvent(ui.__mem_func__(self.OnSelectItemSlot))
  212. self.acceSlot.SetUseSlotEvent(ui.__mem_func__(self.OnSelectItemSlot))
  213. self.acceSlot.SetOverInItemEvent(ui.__mem_func__(self.OnOverInItem))
  214. self.acceSlot.SetOverOutItemEvent(ui.__mem_func__(self.OnOverOutItem))
  215. self.titleBar.SetCloseEvent(ui.__mem_func__(self.OnClose))
  216. self.btnCancel.SetEvent(ui.__mem_func__(self.OnClose))
  217. self.btnAccept.SetEvent(ui.__mem_func__(self.OnAccept))
  218.  
  219. self.tooltipItem = None
  220.  
  221. def SetItemToolTip(self, itemTooltip):
  222. self.tooltipItem = itemTooltip
  223.  
  224. def IsOpened(self):
  225. if self.IsShow() and self.isLoaded:
  226. return TRUE
  227.  
  228. return FALSE
  229.  
  230. def Open(self):
  231. self.PositionOut = 0
  232. (self.PositionStartX, self.PositionStartY, z) = player.GetMainCharacterPosition()
  233. for i in xrange(acce.WINDOW_MAX_MATERIALS + 1):
  234. self.acceSlot.ClearSlot(i)
  235.  
  236. self.Show()
  237.  
  238. def Close(self):
  239. if self.tooltipItem:
  240. self.tooltipItem.HideToolTip()
  241.  
  242. self.Hide()
  243.  
  244. def OnClose(self):
  245. acce.SendCloseRequest()
  246.  
  247. def OnPressEscapeKey(self):
  248. self.OnClose()
  249. return TRUE
  250.  
  251. def OnAccept(self):
  252. acce.SendRefineRequest()
  253.  
  254. def OnUpdate(self):
  255. LIMIT_RANGE = acce.LIMIT_RANGE
  256. (x, y, z) = player.GetMainCharacterPosition()
  257. if abs(x - self.PositionStartX) >= LIMIT_RANGE or abs(y - self.PositionStartY) >= LIMIT_RANGE:
  258. if not self.PositionOut:
  259. self.PositionOut += 1
  260. self.OnClose()
  261.  
  262. def OnSelectEmptySlot(self, selectedSlotPos):
  263. isAttached = mouseModule.mouseController.isAttached()
  264. if not isAttached or selectedSlotPos == acce.WINDOW_MAX_MATERIALS:
  265. return
  266.  
  267. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  268. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  269. attachedInvenType = player.SlotTypeToInvenType(attachedSlotType)
  270. mouseModule.mouseController.DeattachObject()
  271. if attachedSlotType == player.SLOT_TYPE_INVENTORY and attachedInvenType == player.INVENTORY:
  272. acce.Add(attachedInvenType, attachedSlotPos, selectedSlotPos)
  273.  
  274. def OnSelectItemSlot(self, selectedSlotPos):
  275. if selectedSlotPos == acce.WINDOW_MAX_MATERIALS:
  276. return
  277.  
  278. mouseModule.mouseController.DeattachObject()
  279. acce.Remove(selectedSlotPos)
  280.  
  281. def OnOverInItem(self, selectedSlotPos):
  282. if self.tooltipItem:
  283. if selectedSlotPos == acce.WINDOW_MAX_MATERIALS:
  284. (isHere1, iCell1) = acce.GetAttachedItem(0)
  285. (isHere2, iCell2) = acce.GetAttachedItem(1)
  286. if isHere1 and isHere2:
  287. self.tooltipItem.SetAcceResultAbsItem(iCell1, iCell2)
  288. else:
  289. (isHere, iCell) = acce.GetAttachedItem(selectedSlotPos)
  290. if isHere:
  291. self.tooltipItem.SetInventoryItem(iCell)
  292.  
  293. def OnOverOutItem(self):
  294. if self.tooltipItem:
  295. self.tooltipItem.HideToolTip()
  296.  
  297. def Refresh(self, iAct):
  298. self.acceSlot.ClearSlot(acce.WINDOW_MAX_MATERIALS)
  299. for i in xrange(acce.WINDOW_MAX_MATERIALS):
  300. self.acceSlot.ClearSlot(i)
  301. (isHere, iCell) = acce.GetAttachedItem(i)
  302. if isHere:
  303. self.acceSlot.SetItemSlot(i, player.GetItemIndex(iCell), 0)
  304. if i == int(acce.WINDOW_MAX_MATERIALS - 1):
  305. (itemVnum, MinAbs, MaxAbs) = acce.GetResultItem()
  306. if not itemVnum:
  307. break
  308.  
  309. self.acceSlot.SetItemSlot(i + 1, itemVnum, 0)
  310. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement