Guest User

modified file

a guest
Nov 30th, 2016
72
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## -- ©2013, ®iWizz™. --
  2. ## ---------------------
  3.  
  4. # --<
  5. import os
  6. import ui
  7. import app
  8. import ime
  9. import grp
  10. import net
  11. import snd
  12. import item
  13. import chat
  14. import player
  15. import locale
  16. import grpText
  17. import uiRefine
  18. import constInfo
  19. import uiToolTip
  20. import mouseModule
  21. import uiAttachMetin
  22. import uiScriptLocale
  23.  
  24. class changeequip(ui.ScriptWindow):
  25. def __init__(self):
  26. import exception
  27. ui.ScriptWindow.__init__(self)
  28. self.wndEquip = None
  29. self.tokens = None
  30. self.tooltipItem = uiToolTip.ItemToolTip()
  31. self.tooltipItem.Hide()
  32. if constInfo.FAST_PAGE == 1:
  33. self.saveName = "lib/FastEquipPage1.pyc"
  34. elif constInfo.FAST_PAGE == 2:
  35. self.saveName = "lib/FastEquipPage2.pyc"
  36. elif constInfo.FAST_PAGE == 3:
  37. self.saveName = "lib/FastEquipPage3.pyc"
  38. elif constInfo.FAST_PAGE == 4:
  39. self.saveName = "lib/FastEquipPage4.pyc"
  40.  
  41. def __del__(self):
  42. ui.ScriptWindow.__del__(self)
  43.  
  44. def Show(self):
  45. self.__LoadWindow()
  46. ui.ScriptWindow.Show(self)
  47.  
  48. def Close(self):
  49. constInfo.FAST_EQUIP = 0
  50. snd.PlaySound("sound/ui/click.wav")
  51. self.Hide()
  52.  
  53. def __LoadWindow(self):
  54. try:
  55. pyScrLoader = ui.PythonScriptLoader()
  56. pyScrLoader.LoadScriptFile(self, "uiscript/fastequip_window.py")
  57. except:
  58. import exception
  59. exception.Abort("CostumeWindow.LoadWindow.LoadObject")
  60.  
  61. self.wndEquip = self.GetChild("equipslot")
  62. self.bottone_change = self.GetChild("change_button")
  63. self.clear_button = self.GetChild("clear_button")
  64. self.TitleBar = self.GetChild("TitleBar")
  65. self.pag1_button = self.GetChild("page1_button")
  66. self.pag2_button = self.GetChild("page2_button")
  67. self.pag3_button = self.GetChild("page3_button")
  68. self.pag4_button = self.GetChild("page4_button")
  69.  
  70. self.TitleBar.SetCloseEvent(ui.__mem_func__(self.Close))
  71. self.wndEquip.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectItemSlot))
  72. self.wndEquip.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot))
  73. self.wndEquip.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
  74. self.wndEquip.SetOverOutItemEvent(ui.__mem_func__(self.OnOverOutItem))
  75. self.bottone_change.SetEvent(ui.__mem_func__(self.__change_button))
  76. self.clear_button.SetEvent(ui.__mem_func__(self.__clear_button))
  77. self.pag1_button.SAFE_SetEvent(self.__pag1_button)
  78. self.pag2_button.SetEvent(ui.__mem_func__(self.__pag2_button))
  79. self.pag3_button.SetEvent(ui.__mem_func__(self.__pag3_button))
  80. self.pag4_button.SetEvent(ui.__mem_func__(self.__pag4_button))
  81.  
  82. if os.path.exists(self.saveName):
  83. self.tokens = open(self.saveName, "r").read().split()
  84. else:
  85. open(self.saveName, "w").write("@\t@\t@\t@\t@\t@\t@\t@\t@\t@")
  86.  
  87. button = self.GetChild("page1_button")
  88. button.Down()
  89.  
  90. def __clear_button(self):
  91. if constInfo.FAST_PAGE == 1:
  92. self.saveName = "lib/FastEquipPage1.pyc"
  93. if os.path.exists(self.saveName):
  94. os.remove(self.saveName)
  95. open(self.saveName, "w").write("@\t@\t@\t@\t@\t@\t@\t@\t@\t@")
  96. elif constInfo.FAST_PAGE == 2:
  97. self.saveName = "lib/FastEquipPage2.pyc"
  98. if os.path.exists(self.saveName):
  99. os.remove(self.saveName)
  100. open(self.saveName, "w").write("@\t@\t@\t@\t@\t@\t@\t@\t@\t@")
  101. elif constInfo.FAST_PAGE == 3:
  102. self.saveName = "lib/FastEquipPage3.pyc"
  103. if os.path.exists(self.saveName):
  104. os.remove(self.saveName)
  105. open(self.saveName, "w").write("@\t@\t@\t@\t@\t@\t@\t@\t@\t@")
  106. elif constInfo.FAST_PAGE == 4:
  107. self.saveName = "lib/FastEquipPage4.pyc"
  108. if os.path.exists(self.saveName):
  109. os.remove(self.saveName)
  110. open(self.saveName, "w").write("@\t@\t@\t@\t@\t@\t@\t@\t@\t@")
  111.  
  112. def __pag1_button(self):
  113. constInfo.FAST_PAGE = 1
  114. button2 = self.GetChild("page2_button")
  115. button3 = self.GetChild("page3_button")
  116. button4 = self.GetChild("page4_button")
  117. button2.SetUp()
  118. button3.SetUp()
  119. button4.SetUp()
  120.  
  121. self.saveName = "lib/FastEquipPage1.pyc"
  122. if os.path.exists(self.saveName):
  123. open(self.saveName, "r").read().split()
  124. else:
  125. open(self.saveName, "w").write("@\t@\t@\t@\t@\t@\t@\t@\t@\t@")
  126.  
  127. def __pag2_button(self):
  128. constInfo.FAST_PAGE = 2
  129. button1 = self.GetChild("page1_button")
  130. button3 = self.GetChild("page3_button")
  131. button4 = self.GetChild("page4_button")
  132. button1.SetUp()
  133. button3.SetUp()
  134. button4.SetUp()
  135.  
  136. self.saveName = "lib/FastEquipPage2.pyc"
  137. if os.path.exists(self.saveName):
  138. open(self.saveName, "r").read().split()
  139. else:
  140. open(self.saveName, "w").write("@\t@\t@\t@\t@\t@\t@\t@\t@\t@")
  141.  
  142. def __pag3_button(self):
  143. constInfo.FAST_PAGE = 3
  144. button1 = self.GetChild("page1_button")
  145. button2 = self.GetChild("page2_button")
  146. button4 = self.GetChild("page4_button")
  147. button1.SetUp()
  148. button2.SetUp()
  149. button4.SetUp()
  150.  
  151. self.saveName = "lib/FastEquipPage3.pyc"
  152. if os.path.exists(self.saveName):
  153. open(self.saveName, "r").read().split()
  154. else:
  155. open(self.saveName, "w").write("@\t@\t@\t@\t@\t@\t@\t@\t@\t@")
  156.  
  157. def __pag4_button(self):
  158. constInfo.FAST_PAGE = 4
  159. button1 = self.GetChild("page1_button")
  160. button2 = self.GetChild("page2_button")
  161. button3 = self.GetChild("page3_button")
  162. button1.SetUp()
  163. button2.SetUp()
  164. button3.SetUp()
  165.  
  166. self.saveName = "lib/FastEquipPage4.pyc"
  167. if os.path.exists(self.saveName):
  168. open(self.saveName, "r").read().split()
  169. else:
  170. open(self.saveName, "w").write("@\t@\t@\t@\t@\t@\t@\t@\t@\t@")
  171.  
  172. def __change_button(self):
  173. for i in range(1,11):
  174. if self.tokens[i-1] != "@":
  175. net.SendItemUsePacket(int(self.tokens[i-1]))
  176.  
  177. def OverInItem(self, slotNumber):
  178. if self.tooltipItem:
  179. self.tooltipItem.SetInventoryItem(int(self.tokens[slotNumber-1]))
  180.  
  181. def OnOverOutItem(self):
  182. if self.tooltipItem:
  183. self.tooltipItem.HideToolTip()
  184.  
  185. def SelectItemSlot(self, itemSlotIndex):
  186. isAttached = mouseModule.mouseController.isAttached()
  187. if isAttached:
  188. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  189. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  190. itemIndex = player.GetItemIndex(attachedSlotPos)
  191. itemCount = player.GetItemCount(attachedSlotPos)
  192. item.SelectItem(itemIndex)
  193. itemType = item.GetItemType()
  194. itemSubType = item.GetItemSubType()
  195.  
  196. if item.IsWearableFlag(item.WEARABLE_BODY):
  197. self.tokens[1-1] = attachedSlotPos
  198. snd.PlaySound("sound/ui/equip_metal_armor.wav")
  199. elif item.IsWearableFlag(item.WEARABLE_HEAD):
  200. self.tokens[2-1] = attachedSlotPos
  201. snd.PlaySound("sound/ui/drop.wav")
  202. elif item.IsWearableFlag(item.WEARABLE_FOOTS):
  203. self.tokens[3-1] = attachedSlotPos
  204. snd.PlaySound("sound/ui/drop.wav")
  205. elif item.IsWearableFlag(item.WEARABLE_WRIST):
  206. self.tokens[4-1] = attachedSlotPos
  207. snd.PlaySound("sound/ui/drop.wav")
  208. elif item.IsWearableFlag(item.WEARABLE_WEAPON):
  209. self.tokens[5-1] = attachedSlotPos
  210. if itemSubType == 2:
  211. snd.PlaySound("sound/ui/equip_bow.wav")
  212. else:
  213. snd.PlaySound("sound/ui/equip_metal_weapon.wav")
  214. elif item.IsWearableFlag(item.WEARABLE_NECK):
  215. self.tokens[6-1] = attachedSlotPos
  216. snd.PlaySound("sound/ui/equip_ring_amulet.wav")
  217. elif item.IsWearableFlag(item.WEARABLE_EAR):
  218. self.tokens[7-1] = attachedSlotPos
  219. snd.PlaySound("sound/ui/equip_ring_amulet.wav")
  220. elif item.IsWearableFlag(item.WEARABLE_SHIELD):
  221. self.tokens[8-1] = attachedSlotPos
  222. snd.PlaySound("sound/ui/drop.wav")
  223. elif item.IsWearableFlag(item.WEARABLE_ARROW):
  224. self.tokens[9-1] = attachedSlotPos
  225. snd.PlaySound("sound/ui/drop.wav")
  226. elif item.IsWearableFlag(item.WEARABLE_BELT):
  227. self.tokens[10-1] = attachedSlotPos
  228. snd.PlaySound("sound/ui/drop.wav")
  229. else:
  230. return
  231.  
  232. open(self.saveName, "w").write("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % tuple(self.tokens))
  233. mouseModule.mouseController.DeattachObject()
  234.  
  235. def OnUpdate(self):
  236. tokens = open(self.saveName, "r").read().split()
  237. self.tokens = tokens
  238. for i in range(1,11):
  239. if tokens[i-1] == "@":
  240. self.wndEquip.SetItemSlot(i, 0, 0)
  241. else:
  242. itemIndex = player.GetItemIndex(int(tokens[i-1]))
  243. if itemIndex != 0:
  244. item.SelectItem(itemIndex)
  245. if i == 1 and item.IsWearableFlag(item.WEARABLE_BODY):
  246. self.wndEquip.SetItemSlot(i, itemIndex, 0)
  247. elif i == 2 and item.IsWearableFlag(item.WEARABLE_HEAD):
  248. self.wndEquip.SetItemSlot(i, itemIndex, 0)
  249. elif i == 3 and item.IsWearableFlag(item.WEARABLE_FOOTS):
  250. self.wndEquip.SetItemSlot(i, itemIndex, 0)
  251. elif i == 4 and item.IsWearableFlag(item.WEARABLE_WRIST):
  252. self.wndEquip.SetItemSlot(i, itemIndex, 0)
  253. elif i == 5 and item.IsWearableFlag(item.WEARABLE_WEAPON):
  254. self.wndEquip.SetItemSlot(i, itemIndex, 0)
  255. elif i == 6 and item.IsWearableFlag(item.WEARABLE_NECK):
  256. self.wndEquip.SetItemSlot(i, itemIndex, 0)
  257. elif i == 7 and item.IsWearableFlag(item.WEARABLE_EAR):
  258. self.wndEquip.SetItemSlot(i, itemIndex, 0)
  259. elif i == 8 and item.IsWearableFlag(item.WEARABLE_SHIELD):
  260. self.wndEquip.SetItemSlot(i, itemIndex, 0)
  261. elif i == 9 and item.IsWearableFlag(item.WEARABLE_ARROW):
  262. self.wndEquip.SetItemSlot(i, itemIndex, 0)
  263. elif i == 10 and item.IsWearableFlag(item.WEARABLE_BELT):
  264. self.wndEquip.SetItemSlot(i, itemIndex, 0)
  265. else:
  266. self.wndEquip.SetItemSlot(i, 0, 0)
  267. self.tokens[i-1] = "@"
  268. open(self.saveName, "w").write("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % tuple(self.tokens))
  269. continue
  270. else:
  271. self.wndEquip.SetItemSlot(i, 0, 0)
  272.  
  273. def OnPressEscapeKey(self):
  274. self.Close()
  275. snd.PlaySound("sound/ui/click.wav")
  276. return TRUE
  277. # -->
RAW Paste Data