Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ui
- import dbg
- import app
- import ime
- import wndMgr
- import snd
- import player
- import net
- import chat
- import item
- import linecache
- import os
- NAME = ["Podstawowe", "Rosy", "Wody"]
- VNUM = {
- 0 : [39018, 39020, 39017, 39024, 39025],
- 1 : [50821, 50822, 50823, 50824, 50825, 50826],
- 2 : [50813, 50814, 50815, 50816, 50817, 50818, 50819, 50820],
- }
- class BoostWindow(ui.Window):
- def __init__(self):
- ui.Window.__init__(self)
- self.buttons = {}
- self.EnableList = {0:[], 1:[], 2:[],}
- self.size = 0
- self.NoweOkno()
- self.LoadBoost()
- def __del__(self):
- ui.Window.__del__(self)
- def BoostStatus(self, type, item):
- if item in self.EnableList[type]:
- return item
- else:
- return 0
- def LoadBoost(self):
- if not os.path.exists('lib/konta/boost.cfg'):
- return
- LBoost = {}
- for i in xrange(len(VNUM)):
- LBoost[i] = linecache.getline("lib/konta/boost.cfg", i+1)
- list = LBoost[i].split("|")
- for x in xrange(len(list)):
- TAB = self.EnableList[i]
- TAB.append(int(list[x]))
- b = int(list[x])
- if b in VNUM[i]:
- (Hb, HbN, Slot, btn) = self.buttons[i]
- btn[b][0].Down()
- def SaveBoot(self):
- f = open("lib/konta/boost.cfg", "w")
- for i in xrange(len(VNUM)):
- c = 0
- for item in VNUM[i]:
- c +=1
- if c >= len(VNUM[i]):
- f.write("%s\n" % self.BoostStatus(i, item))
- else:
- f.write("%s|" % self.BoostStatus(i, item))
- f.close()
- def NoweOkno(self):
- self.Board = ui.BoardWithTitleBar()
- self.Board.SetSize(300, 280)
- self.Board.SetCenterPosition()
- self.Board.AddFlag('movable')
- self.Board.AddFlag('float')
- self.Board.SetTitleName("Wzmocnienia Postaci")
- self.Board.SetCloseEvent(self.Close)
- for i in xrange(len(VNUM)):
- Hb = ui.HorizontalBar()
- Hb.SetParent(self.Board)
- Hb.SetPosition(15, 39 + self.size)
- Hb.Create(265)
- Hb.Show()
- HbN = ui.TextLine()
- HbN.SetParent(Hb)
- HbN.SetDefaultFontName()
- HbN.SetPosition(Hb.GetWidth()/2, 1)
- HbN.SetHorizontalAlignCenter()
- HbN.SetText(NAME[i])
- HbN.Show()
- Slot = ui.GridSlotWindow()
- Slot.SetParent(self.Board)
- Slot.SetSize(32*(len(VNUM[i])), 32)
- Slot.SetPosition(self.Board.GetWidth()/2-(32*(len(VNUM[i])))/2, 60 + self.size)
- Slot.Show()
- Slot.ArrangeSlot(0, len(VNUM[i]), 1, 32, 32, 0, 0)
- Slot.RefreshSlot()
- Slot.SetSlotBaseImage("d:/ymir work/ui/public/Slot_Base.sub", 1.0, 1.0, 1.0, 1.0)
- (x, y) = Slot.GetLocalPosition()
- btn = {}
- nx = 0
- for b in VNUM[i]:
- button = ui.ToggleButton()
- button.SetParent(self.Board)
- button.SetPosition(x+18+nx, y+18)
- button.SetUpVisual("d:/ymir work/ui/boost/off.tga")
- button.SetOverVisual("d:/ymir work/ui/boost/off.tga")
- button.SetDownVisual("d:/ymir work/ui/boost/on.tga")
- button.SetToggleUpEvent(lambda type=i, id=b: self.DisableBoost(type, id))
- button.SetToggleDownEvent(lambda type=i, id=b: self.EnableBoost(type, id))
- button.Show()
- nx += 32
- btn[b] = [button]
- a = 0
- for item in VNUM[i]:
- Slot.SetItemSlot(a, item, 0)
- a +=1
- self.size += 70
- self.buttons[i] = [Hb, HbN, Slot, btn]
- self.BoostButton = ui.Button()
- self.BoostButton.SetParent(self.Board)
- self.BoostButton.SetPosition(105, 245)
- self.BoostButton.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
- self.BoostButton.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
- self.BoostButton.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
- self.BoostButton.SetText("Aktywuj")
- self.BoostButton.SetEvent(ui.__mem_func__(self.UseBoost))
- self.BoostButton.Show()
- def UseBoost(self):
- c = []
- for a in xrange(len(self.EnableList)):
- for b in xrange(len(self.EnableList[a])):
- if self.EnableList[a][b] != 0:
- c.append(self.EnableList[a][b])
- if len(c) < 1:
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Wybierz, które wzmocnienia chcesz aktywować.")
- return
- for i in xrange(player.INVENTORY_PAGE_SIZE*5):
- ItemValue = player.GetItemIndex(i)
- if ItemValue in self.EnableList[0] or ItemValue in self.EnableList[1] or ItemValue in self.EnableList[2]:
- net.SendItemUsePacket(i)
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Przedmioty zostały aktywowane!")
- def EnableBoost(self, type, id):
- TAB = self.EnableList[type]
- TAB.append(id)
- self.SaveBoot()
- def DisableBoost(self, type, id):
- TAB = self.EnableList[type]
- TAB.remove(id)
- self.SaveBoot()
- def Show(self):
- if self.Board.IsShow():
- self.Close()
- else:
- self.Board.Show()
- def Close(self):
- self.Board.Hide()
- def OnPressEscapeKey(self):
- if self.Board.IsShow():
- self.Close()
- return TRUE
- return FALSE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement