Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ui
- import dbg
- import app
- import player
- import net
- import chat
- import time
- Drop_Item_Status = 0
- class Drop_Item(ui.Window):
- def __init__(self):
- ui.Window.__init__(self)
- self.BuildWindow()
- self.Info_func()
- def __del__(self):
- ui.Window.__del__(self)
- def BuildWindow(self):
- self.Drop_Item = ui.BoardWithTitleBar()
- self.Drop_Item.SetSize(120, 105)
- self.Drop_Item.SetCenterPosition()
- self.Drop_Item.AddFlag('movable')
- self.Drop_Item.AddFlag('float')
- self.Drop_Item.SetTitleName('Drop Item')
- self.Drop_Item.SetCloseEvent(self.Drop_Item_Close)
- self.Drop_Item.Show()
- self.__BuildKeyDict()
- self.comp = Component()
- ### Buttons ###
- self.Drop_Item_Button = self.comp.Button(self.Drop_Item, 'Drop', '', 15, 40, self.Drop_Item_func, 'd:/ymir work/ui/public/large_button_01.sub', 'd:/ymir work/ui/public/large_button_02.sub', 'd:/ymir work/ui/public/large_button_03.sub')
- self.Drop_Item_Auto_Button = self.comp.Button(self.Drop_Item, 'Drop Auto', '', 15, 65, self.Drop_Item_Auto_func, 'd:/ymir work/ui/public/large_button_01.sub', 'd:/ymir work/ui/public/large_button_02.sub', 'd:/ymir work/ui/public/large_button_03.sub')
- ### Drop Item Func ###
- def Drop_Item_func(self):
- for i in xrange(0, player.INVENTORY_PAGE_COUNT * player.INVENTORY_PAGE_SIZE):
- Item_Vnum = player.GetItemIndex(i)
- if Item_Vnum == 30270:
- net.SendItemDropPacket(i)
- ### Drop Item Auto Button ###
- def Drop_Item_Auto_func(self):
- global Drop_Item_Status
- if Drop_Item_Status == 0:
- Drop_Item_Status = 1
- self.Drop_Item_Auto_Button.SetText("Drop Auto On")
- chat.AppendChat(2, "Drop Auto On!")
- else:
- Drop_Item_Status = 0
- self.Drop_Item_Auto_Button.SetText("Drop Auto Off")
- chat.AppendChat(2, "Drop Auto Off!")
- ### Info ###
- def Info_func(self):
- chat.AppendChat(2, "---------------------------")
- chat.AppendChat(1, "Simple code by ZAHON")
- chat.AppendChat(2, "---------------------------")
- ### OnUpdate ###
- def OnUpdate(self):
- global Drop_Item_Status
- if Drop_Item_Status == 1:
- self.Drop_Item_func()
- else:
- pass
- def __BuildKeyDict(self):
- onPressKeyDict = {}
- onPressKeyDict[app.DIK_F5] = lambda : self.OpenWindow()
- self.onPressKeyDict = onPressKeyDict
- def OnKeyDown(self, key):
- try:
- self.onPressKeyDict[key]()
- except KeyError:
- pass
- except:
- raise
- return TRUE
- def OpenWindow(self):
- if self.Board.IsShow():
- self.Board.Hide()
- else:
- self.Board.Show()
- def Drop_Item_Close(self):
- self.Drop_Item.Hide()
- class WaitingDialog(ui.ScriptWindow):
- def __init__(self):
- ui.ScriptWindow.__init__(self)
- self.eventTimeOver = lambda *arg: None
- self.eventExit = lambda *arg: None
- def __del__(self):
- ui.ScriptWindow.__del__(self)
- def Open(self, waitTime):
- curTime = time.clock()
- self.endTime = curTime + waitTime
- self.Show()
- def Close(self):
- self.Hide()
- def Destroy(self):
- self.Hide()
- def SAFE_SetTimeOverEvent(self, event):
- self.eventTimeOver = ui.__mem_func__(event)
- def SAFE_SetExitEvent(self, event):
- self.eventExit = ui.__mem_func__(event)
- def OnUpdate(self):
- lastTime = max(0, self.endTime - time.clock())
- if 0 == lastTime:
- self.Close()
- self.eventTimeOver()
- else:
- return
- class Component:
- def Button(self, parent, buttonName, tooltipText, x, y, func, UpVisual, OverVisual, DownVisual):
- button = ui.Button()
- if parent != None:
- button.SetParent(parent)
- button.SetPosition(x, y)
- button.SetUpVisual(UpVisual)
- button.SetOverVisual(OverVisual)
- button.SetDownVisual(DownVisual)
- button.SetText(buttonName)
- button.SetToolTipText(tooltipText)
- button.Show()
- button.SetEvent(func)
- return button
- def ToggleButton(self, parent, buttonName, tooltipText, x, y, funcUp, funcDown, UpVisual, OverVisual, DownVisual):
- button = ui.ToggleButton()
- if parent != None:
- button.SetParent(parent)
- button.SetPosition(x, y)
- button.SetUpVisual(UpVisual)
- button.SetOverVisual(OverVisual)
- button.SetDownVisual(DownVisual)
- button.SetText(buttonName)
- button.SetToolTipText(tooltipText)
- button.Show()
- button.SetToggleUpEvent(funcUp)
- button.SetToggleDownEvent(funcDown)
- return button
- def EditLine(self, parent, editlineText, x, y, width, heigh, max):
- SlotBar = ui.SlotBar()
- if parent != None:
- SlotBar.SetParent(parent)
- SlotBar.SetSize(width, heigh)
- SlotBar.SetPosition(x, y)
- SlotBar.Show()
- Value = ui.EditLine()
- Value.SetParent(SlotBar)
- Value.SetSize(width, heigh)
- Value.SetPosition(1, 1)
- Value.SetMax(max)
- Value.SetLimitWidth(width)
- Value.SetMultiLine()
- Value.SetText(editlineText)
- Value.Show()
- return SlotBar, Value
- def TextLine(self, parent, textlineText, x, y, color):
- textline = ui.TextLine()
- if parent != None:
- textline.SetParent(parent)
- textline.SetPosition(x, y)
- if color != None:
- textline.SetFontColor(color[0], color[1], color[2])
- textline.SetText(textlineText)
- textline.Show()
- return textline
- def RGB(self, r, g, b):
- return (r*255, g*255, b*255)
- def SliderBar(self, parent, sliderPos, func, x, y):
- Slider = ui.SliderBar()
- if parent != None:
- Slider.SetParent(parent)
- Slider.SetPosition(x, y)
- Slider.SetSliderPos(sliderPos / 100)
- Slider.Show()
- Slider.SetEvent(func)
- return Slider
- def ExpandedImage(self, parent, x, y, img):
- image = ui.ExpandedImageBox()
- if parent != None:
- image.SetParent(parent)
- image.SetPosition(x, y)
- image.LoadImage(img)
- image.Show()
- return image
- def ComboBox(self, parent, text, x, y, width):
- combo = ui.ComboBox()
- if parent != None:
- combo.SetParent(parent)
- combo.SetPosition(x, y)
- combo.SetSize(width, 15)
- combo.SetCurrentItem(text)
- combo.Show()
- return combo
- def ThinBoard(self, parent, moveable, x, y, width, heigh, center):
- thin = ui.ThinBoard()
- if parent != None:
- thin.SetParent(parent)
- if moveable == TRUE:
- thin.AddFlag('movable')
- thin.AddFlag('float')
- thin.SetSize(width, heigh)
- thin.SetPosition(x, y)
- if center == TRUE:
- thin.SetCenterPosition()
- thin.Show()
- return thin
- def Gauge(self, parent, width, color, x, y):
- gauge = ui.Gauge()
- if parent != None:
- gauge.SetParent(parent)
- gauge.SetPosition(x, y)
- gauge.MakeGauge(width, color)
- gauge.Show()
- return gauge
- def ListBoxEx(self, parent, x, y, width, heigh):
- bar = ui.Bar()
- if parent != None:
- bar.SetParent(parent)
- bar.SetPosition(x, y)
- bar.SetSize(width, heigh)
- bar.SetColor(0x77000000)
- bar.Show()
- ListBox=ui.ListBoxEx()
- ListBox.SetParent(bar)
- ListBox.SetPosition(0, 0)
- ListBox.SetSize(width, heigh)
- ListBox.Show()
- scroll = ui.ScrollBar()
- scroll.SetParent(ListBox)
- scroll.SetPosition(width-15, 0)
- scroll.SetScrollBarSize(heigh)
- scroll.Show()
- ListBox.SetScrollBar(scroll)
- return bar, ListBox
- Drop_Item().Show()
Advertisement
Add Comment
Please, Sign In to add comment