Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import binascii
- import ui
- import dbg
- import app
- import net, player
- import item
- import chat
- import time
- import uiToolTip
- import wndMgr
- import localeInfo
- items = [
- [27101, 0], # 0
- [27104, 0], # 1
- [50813, 0], # 2
- [50814, 0], # 3
- [50817, 0], # 4
- [50818, 0], # 5
- [50819, 0], # 6
- [50820, 0], # 7
- [50821, 0], # 8
- [50822, 0], # 9
- [50823, 0], # 10
- [50824, 0], # 11
- [50825, 0], # 12
- [50826, 0], # 13
- [39024, 0], # 14
- [39025, 0], # 15
- [39017, 0], # 16
- [39018, 0], # 17
- [39020, 0], # 18
- [50840, 0], # 19
- [50841, 0], # 20
- [50842, 0], # 21
- [50843, 0], # 22
- [46000, 0], # 23
- [46001, 0], # 24
- [46002, 0], # 25
- ]
- class Dopalacze(ui.Window):
- strengthen = []
- PATH = ''
- power_cube = 0
- def __init__(self):
- ui.Window.__init__(self)
- self.Board = ui.BoardWithTitleBar()
- self.use = ui.Button()
- self.Rosa = []
- self.Woda = []
- self.EventDopalacze1 = []
- self.EventDopalacze2 = []
- self.EventDopalacze3 = []
- self.ZielarstwoSlot = []
- self.ZielarstwoSlot2 = []
- self.ZielarstwoSlot3 = []
- self.OtherItems = []
- self.OtherItems2 = []
- self.roski_text = ui.TextLine()
- self.event_dopalacze_text = ui.TextLine()
- self.zielarstwo_text = ui.TextLine()
- self.other_text = ui.TextLine()
- self.PATH = "dane/dopalacze/" + str(player.GetName()) + '_dops.dll'
- self.BuildWindow()
- self.ReadFromFile()
- self.CreateButtons()
- self.CreateZielarstwo()
- self.CreateRoski()
- self.CreateOther()
- self.SetToolTips()
- def __del__(self):
- ui.Window.__del__(self)
- def BuildWindow(self):
- self.Board.SetSize(320,235)
- self.Board.SetCenterPosition()
- self.Board.AddFlag('movable')
- self.Board.SetTitleName('Wzmocnienia Postaci')
- self.Board.SetCloseEvent(self.Close)
- self.Board.Show()
- #self.MainImage = ui.ImageBox()
- #self.MainImage.SetParent(self.Board)
- #self.MainImage.LoadImage("dopalacze.tga")
- #self.MainImage.SetPosition(13, 38)
- #self.MainImage.SetSize(300,260)
- #self.MainImage.Show()
- def SetItemToolTip(self, tooltipItem):
- self.tooltipItem = tooltipItem
- def WriteToFileEmptyData(self):
- file = open(self.PATH, 'w+')
- for x in items:
- value = binascii.b2a_base64("%d %d\n" % (x[0], x[1]))
- file.write(value)
- file.close()
- self.ReadFromFile()
- def WriteToFile(self):
- file = open(self.PATH, 'w')
- for x in self.strengthen:
- value = binascii.b2a_base64("%d %d\n" % (x[0], x[1]))
- file.write(value)
- file.close()
- def ReadFromFile(self):
- if os.path.exists(self.PATH):
- try:
- file = open(self.PATH, 'r')
- for x in file:
- x = str(binascii.a2b_base64(x))
- x = x.split()
- x[1] = int(x[1])
- x[0] = int(x[0])
- self.strengthen.append(x)
- file.close()
- if len(self.strengthen) < len(items):
- os.remove(self.PATH)
- self.WriteToFileEmptyData()
- except:
- self.WriteToFileEmptyData()
- else:
- self.WriteToFileEmptyData()
- def SetToolTips(self):
- for x in xrange(len(self.Woda)):
- self.Woda[x].SetToolTip()
- for x in xrange(len(self.Rosa)):
- self.Rosa[x].SetToolTip()
- def CreateRoski(self):
- self.Wody = None
- self.Rosy = None
- for x in xrange(0, 7):
- self.Wody = Wzmocnienia(self.Board, 15, 30, x, self.strengthen[x][1], self.strengthen[x][0], self)
- self.Woda.append(self.Wody)
- for x2 in xrange(7, 14):
- self.Rosy = Wzmocnienia(self.Board, 15, 75, x2 - 7, self.strengthen[x2][1], self.strengthen[x2][0], self)
- self.Rosa.append(self.Rosy)
- for x3 in xrange(14, 21):
- self.Rosy = Wzmocnienia(self.Board, 15, 120, x3 - 14, self.strengthen[x3][1], self.strengthen[x3][0], self)
- self.Rosa.append(self.Rosy)
- for x4 in xrange(21, 26):
- self.Rosy = Wzmocnienia(self.Board, 15, 165, x4 - 21, self.strengthen[x4][1], self.strengthen[x4][0], self)
- self.Rosa.append(self.Rosy)
- def CreateZielarstwo(self):
- self.zielarstwo = None
- def CreateOther(self):
- self.Other = None
- self.Other2 = None
- def CreateButtons(self):
- self.use.SetParent(self.Board)
- self.use.SetPosition(80, 210)
- self.use.SetUpVisual('d:/ymir work/ui/public/xlarge_button_01.sub')
- self.use.SetOverVisual('d:/ymir work/ui/public/xlarge_button_02.sub')
- self.use.SetDownVisual('d:/ymir work/ui/public/xlarge_button_03.sub')
- self.use.SetText('Aktywuj Wzmocnienia')
- self.use.SetEvent(self.OdpalWzmocnienia)
- self.use.Show()
- def OdpalWzmocnienia(self):
- #net.SendChatPacket("/lacostia_config dopalacze")
- self.RosyWody()
- self.EventDopalaczes1()
- self.Zielarstwo()
- self.OtherClick()
- #chat.AppendChat(chat.CHAT_TYPE_NOTICE, "<Informacja> Wybrane wzmocnienia zostaly aktywowane.")
- def RosyWody(self):
- for x in self.Woda:
- x.UseOdpal()
- x.Refresh()
- for x in self.Rosa:
- x.UseOdpal()
- x.Refresh()
- def EventDopalaczes1(self):
- for x in self.EventDopalacze1:
- x.UseOdpal()
- x.Refresh()
- for x in self.EventDopalacze2:
- x.UseOdpal()
- x.Refresh()
- for x in self.EventDopalacze3:
- x.UseOdpal()
- x.Refresh()
- def Zielarstwo(self):
- for x in self.ZielarstwoSlot:
- x.UseOdpal()
- x.Refresh()
- for x in self.ZielarstwoSlot2:
- x.UseOdpal()
- x.Refresh()
- for x in self.ZielarstwoSlot3:
- x.UseOdpal()
- x.Refresh()
- def OtherClick(self):
- for x in self.OtherItems:
- x.UseOdpal()
- x.Refresh()
- for x in self.OtherItems2:
- x.UseOdpal()
- x.Refresh()
- # def Destroy(self):
- # dbg.TraceError("Destroy uiDew")
- def OpenWindow(self):
- self.Board.Hide() if self.Board.IsShow() else self.Board.Show()
- def OnPressEscapeKey(self):
- self.Close()
- return TRUE
- def Close(self):
- self.Board.Hide()
- class Wzmocnienia:
- button = None
- _item = None
- name = ''
- status = None
- x = 0
- y = 0
- vNum = 0
- elemNum = 0
- window = None
- background = None
- def __init__(self, parent, x, y, elemNum, status, vNum, window):
- self.window = window
- self.x = x
- self.y = y
- self.vNum = vNum
- self.elemNum = elemNum
- self.tooltipItem = uiToolTip.ItemToolTip()
- self.tooltipItem.Hide()
- self.CreateBackground(parent)
- self.CreateImage(parent)
- self.CreateButton(parent, status)
- def __del__(self):
- self.Destroy()
- def Refresh(self):
- self.SetToolTip()
- def SetToolTipPos(self):
- width = self.tooltipItem.GetWidth()
- height = self.tooltipItem.toolTipHeight
- (x,y) = wndMgr.GetMousePosition()
- x = max(x, 0)
- y = max(y, 0)
- x = min(x + width / 2, wndMgr.GetScreenWidth() - width / 2) - width / 2
- y = min(y + self.tooltipItem.GetHeight(), wndMgr.GetScreenHeight()) - self.tooltipItem.GetHeight()
- self.tooltipItem.SetToolTipPosition(x, y + self.tooltipItem.GetHeight() + 34)
- def SetToolTip(self):
- if None != self.tooltipItem:
- self.tooltipItem.ClearToolTip()
- self.SetByItemInInventory()
- self.SetToolTipPos()
- self.tooltipItem.Hide()
- def SetByVNum(self):
- self.tooltipItem.SetItemToolTip(self.vNum)
- def SetByItemInInventory(self):
- itemx = item.SelectItem(self.vNum)
- for i in xrange(90*4):
- ItemValue = player.GetItemIndex(i)
- if ItemValue == self.vNum:
- self.tooltipItem.SetInventoryItem(i)
- return
- ItemValue = player.GetItemIndex(player.INVENTORY, i)
- if ItemValue == self.vNum:
- self.tooltipItem.SetInventoryItem(i, player.INVENTORY)
- return
- self.tooltipItem.AppendTextLine(self.name, self.tooltipItem.TITLE_COLOR)
- self.tooltipItem.AppendTextLine("Nie posiadasz tego przedmiotu", self.tooltipItem.DISABLE_COLOR)
- def OnMouseOverIn(self):
- if self.tooltipItem:
- self.SetToolTipPos()
- self.tooltipItem.SetTop()
- self.tooltipItem.Show()
- def OnMouseOverOut(self):
- if self.tooltipItem:
- self.tooltipItem.Hide()
- def CreateBackground(self, parent):
- self.background = ui.ExpandedImageBox()
- self.background.SetParent(parent)
- try:
- self.background.LoadImage("d:/ymir work/ui/public/Slot_Base.sub")
- self.background.SetPosition(self.x + 40 * self.elemNum + 5, self.y + 11)
- self.background.SAFE_SetStringEvent("MOUSE_OVER_IN", self.OnMouseOverIn)
- self.background.SAFE_SetStringEvent("MOUSE_OVER_OUT", self.OnMouseOverOut)
- self.background.Show()
- except:
- dbg.TraceError("No found item")
- def CreateImage(self, parent):
- self._item = ui.ExpandedImageBox()
- self._item.SetParent(self.background)
- item.SelectItem(self.vNum)
- try:
- self._img = item.GetIconImageFileName()
- self.name = item.GetItemName()
- self._item.LoadImage(self._img)
- self._item.SAFE_SetStringEvent("MOUSE_OVER_IN", self.OnMouseOverIn)
- self._item.SAFE_SetStringEvent("MOUSE_OVER_OUT", self.OnMouseOverOut)
- self._item.SetPosition(0, 0)
- self._item.Show()
- except:
- dbg.TraceError("No found item")
- def CreateButton(self, parent, status):
- self.button = ui.ToggleButton()
- if self._item != None:
- self.button.SetParent(self._item)
- self.button.SetSize(32, 32)
- self.button.SetPosition(16, 16)
- self.button.SetWindowVerticalAlignBottom()
- self.button.SetWindowHorizontalAlignRight()
- self.button.SetUpVisual('usun.tga')
- self.button.SetOverVisual('usun.tga')
- self.button.SetDownVisual('wczytaj.tga')
- self.button.SetText("")
- self.button.SetToggleUpEvent(self.TurnOff)
- self.button.SetToggleDownEvent(self.TurnOn)
- self.status = status
- if self.status is 1:
- self.button.Down()
- self.button.Show()
- def UseOdpal(self):
- if self.status is 1:
- for i in xrange(225):
- ItemValue = player.GetItemIndex(i)
- if ItemValue == self.vNum:
- net.SendItemUsePacket(i)
- break
- ItemValue = player.GetItemIndex(player.INVENTORY, i)
- if ItemValue == self.vNum:
- net.SendItemUsePacket(player.INVENTORY, i)
- break
- def getStatus(self):
- return self.status
- def TurnOn(self):
- self.status = 1
- for x in xrange(len(self.window.strengthen)):
- if self.window.strengthen[x][0] is self.vNum:
- self.window.strengthen[x][1] = 1
- self.window.WriteToFile()
- def TurnOff(self):
- self.button.SetUp()
- self.status = 0
- y = 0
- for x in xrange(len(self.window.strengthen)):
- if self.window.strengthen[x][0] is self.vNum:
- self.window.strengthen[x][1] = 0
- self.window.WriteToFile()
- def Destroy(self):
- del self.button
- del self._item
- del self.x
- del self.y
- del self.vNum
- del self.name
- del self.tooltipItem
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement