Advertisement
Guest User

Untitled

a guest
Feb 11th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.71 KB | None | 0 0
  1. import ui
  2. import dbg
  3. import app
  4. import ime
  5. import wndMgr
  6. import snd
  7. import player
  8. import net
  9. import chat
  10. import item
  11. import linecache
  12. import os
  13.  
  14. NAME = ["Podstawowe", "Rosy", "Wody"]
  15. VNUM = {
  16. 0 : [39018, 39020, 39017, 39024, 39025],
  17. 1 : [50821, 50822, 50823, 50824, 50825, 50826],
  18. 2 : [50813, 50814, 50815, 50816, 50817, 50818, 50819, 50820],
  19. }
  20.  
  21. class BoostWindow(ui.Window):
  22.  
  23. def __init__(self):
  24. ui.Window.__init__(self)
  25. self.buttons = {}
  26.  
  27. self.EnableList = {0:[], 1:[], 2:[],}
  28. self.size = 0
  29. self.NoweOkno()
  30. self.LoadBoost()
  31.  
  32. def __del__(self):
  33. ui.Window.__del__(self)
  34.  
  35. def BoostStatus(self, type, item):
  36. if item in self.EnableList[type]:
  37. return item
  38. else:
  39. return 0
  40.  
  41. def LoadBoost(self):
  42. if not os.path.exists('lib/konta/boost.cfg'):
  43. return
  44.  
  45. LBoost = {}
  46. for i in xrange(len(VNUM)):
  47. LBoost[i] = linecache.getline("lib/konta/boost.cfg", i+1)
  48. list = LBoost[i].split("|")
  49. for x in xrange(len(list)):
  50. TAB = self.EnableList[i]
  51. TAB.append(int(list[x]))
  52.  
  53. b = int(list[x])
  54. if b in VNUM[i]:
  55. (Hb, HbN, Slot, btn) = self.buttons[i]
  56. btn[b][0].Down()
  57.  
  58. def SaveBoot(self):
  59. f = open("lib/konta/boost.cfg", "w")
  60. for i in xrange(len(VNUM)):
  61. c = 0
  62. for item in VNUM[i]:
  63. c +=1
  64. if c >= len(VNUM[i]):
  65. f.write("%s\n" % self.BoostStatus(i, item))
  66. else:
  67. f.write("%s|" % self.BoostStatus(i, item))
  68. f.close()
  69.  
  70. def NoweOkno(self):
  71. self.Board = ui.BoardWithTitleBar()
  72. self.Board.SetSize(300, 280)
  73. self.Board.SetCenterPosition()
  74. self.Board.AddFlag('movable')
  75. self.Board.AddFlag('float')
  76. self.Board.SetTitleName("Wzmocnienia Postaci")
  77. self.Board.SetCloseEvent(self.Close)
  78.  
  79. for i in xrange(len(VNUM)):
  80. Hb = ui.HorizontalBar()
  81. Hb.SetParent(self.Board)
  82. Hb.SetPosition(15, 39 + self.size)
  83. Hb.Create(265)
  84. Hb.Show()
  85.  
  86. HbN = ui.TextLine()
  87. HbN.SetParent(Hb)
  88. HbN.SetDefaultFontName()
  89. HbN.SetPosition(Hb.GetWidth()/2, 1)
  90. HbN.SetHorizontalAlignCenter()
  91. HbN.SetText(NAME[i])
  92. HbN.Show()
  93.  
  94. Slot = ui.GridSlotWindow()
  95. Slot.SetParent(self.Board)
  96. Slot.SetSize(32*(len(VNUM[i])), 32)
  97. Slot.SetPosition(self.Board.GetWidth()/2-(32*(len(VNUM[i])))/2, 60 + self.size)
  98. Slot.Show()
  99. Slot.ArrangeSlot(0, len(VNUM[i]), 1, 32, 32, 0, 0)
  100. Slot.RefreshSlot()
  101. Slot.SetSlotBaseImage("d:/ymir work/ui/public/Slot_Base.sub", 1.0, 1.0, 1.0, 1.0)
  102.  
  103. (x, y) = Slot.GetLocalPosition()
  104.  
  105. btn = {}
  106. nx = 0
  107. for b in VNUM[i]:
  108. button = ui.ToggleButton()
  109. button.SetParent(self.Board)
  110. button.SetPosition(x+18+nx, y+18)
  111. button.SetUpVisual("d:/ymir work/ui/boost/off.tga")
  112. button.SetOverVisual("d:/ymir work/ui/boost/off.tga")
  113. button.SetDownVisual("d:/ymir work/ui/boost/on.tga")
  114. button.SetToggleUpEvent(lambda type=i, id=b: self.DisableBoost(type, id))
  115. button.SetToggleDownEvent(lambda type=i, id=b: self.EnableBoost(type, id))
  116. button.Show()
  117.  
  118. nx += 32
  119.  
  120. btn[b] = [button]
  121.  
  122. a = 0
  123. for item in VNUM[i]:
  124. Slot.SetItemSlot(a, item, 0)
  125. a +=1
  126.  
  127. self.size += 70
  128.  
  129. self.buttons[i] = [Hb, HbN, Slot, btn]
  130.  
  131. self.BoostButton = ui.Button()
  132. self.BoostButton.SetParent(self.Board)
  133. self.BoostButton.SetPosition(105, 245)
  134. self.BoostButton.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
  135. self.BoostButton.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
  136. self.BoostButton.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
  137. self.BoostButton.SetText("Aktywuj")
  138. self.BoostButton.SetEvent(ui.__mem_func__(self.UseBoost))
  139. self.BoostButton.Show()
  140.  
  141. def UseBoost(self):
  142. c = []
  143. for a in xrange(len(self.EnableList)):
  144. for b in xrange(len(self.EnableList[a])):
  145. if self.EnableList[a][b] != 0:
  146. c.append(self.EnableList[a][b])
  147.  
  148. if len(c) < 1:
  149. chat.AppendChat(chat.CHAT_TYPE_INFO, "Wybierz, które wzmocnienia chcesz aktywować.")
  150. return
  151.  
  152. for i in xrange(player.INVENTORY_PAGE_SIZE*5):
  153. ItemValue = player.GetItemIndex(i)
  154. if ItemValue in self.EnableList[0] or ItemValue in self.EnableList[1] or ItemValue in self.EnableList[2]:
  155. net.SendItemUsePacket(i)
  156.  
  157. chat.AppendChat(chat.CHAT_TYPE_INFO, "Przedmioty zostały aktywowane!")
  158.  
  159. def EnableBoost(self, type, id):
  160. TAB = self.EnableList[type]
  161. TAB.append(id)
  162.  
  163. self.SaveBoot()
  164.  
  165. def DisableBoost(self, type, id):
  166. TAB = self.EnableList[type]
  167. TAB.remove(id)
  168.  
  169. self.SaveBoot()
  170.  
  171. def Show(self):
  172. if self.Board.IsShow():
  173. self.Close()
  174. else:
  175. self.Board.Show()
  176.  
  177. def Close(self):
  178. self.Board.Hide()
  179.  
  180. def OnPressEscapeKey(self):
  181. if self.Board.IsShow():
  182. self.Close()
  183. return TRUE
  184. return FALSE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement