Guest User

Drop_Item

a guest
Apr 24th, 2017
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.88 KB | None | 0 0
  1. import ui
  2. import dbg
  3. import app
  4. import player
  5. import net
  6. import chat
  7. import time
  8.  
  9. Drop_Item_Status = 0
  10.  
  11. class Drop_Item(ui.Window):
  12.     def __init__(self):
  13.         ui.Window.__init__(self)
  14.         self.BuildWindow()
  15.         self.Info_func()
  16.  
  17.     def __del__(self):
  18.         ui.Window.__del__(self)
  19.  
  20.     def BuildWindow(self):
  21.         self.Drop_Item = ui.BoardWithTitleBar()
  22.         self.Drop_Item.SetSize(120, 105)
  23.         self.Drop_Item.SetCenterPosition()
  24.         self.Drop_Item.AddFlag('movable')
  25.         self.Drop_Item.AddFlag('float')
  26.         self.Drop_Item.SetTitleName('Drop Item')
  27.         self.Drop_Item.SetCloseEvent(self.Drop_Item_Close)
  28.         self.Drop_Item.Show()
  29.         self.__BuildKeyDict()
  30.         self.comp = Component()
  31.  
  32.         ### Buttons ###
  33.         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')
  34.         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')
  35.    
  36.     ### Drop Item Func ###
  37.     def Drop_Item_func(self):
  38.         for i in xrange(0, player.INVENTORY_PAGE_COUNT * player.INVENTORY_PAGE_SIZE):
  39.             Item_Vnum = player.GetItemIndex(i)
  40.             if Item_Vnum == 30270:
  41.                 net.SendItemDropPacket(i)
  42.    
  43.     ### Drop Item Auto Button ###
  44.     def Drop_Item_Auto_func(self):
  45.         global Drop_Item_Status
  46.         if Drop_Item_Status == 0:
  47.             Drop_Item_Status = 1
  48.             self.Drop_Item_Auto_Button.SetText("Drop Auto On")
  49.             chat.AppendChat(2, "Drop Auto On!")
  50.         else:
  51.             Drop_Item_Status = 0
  52.             self.Drop_Item_Auto_Button.SetText("Drop Auto Off")
  53.             chat.AppendChat(2, "Drop Auto Off!")           
  54.        
  55.     ### Info ###
  56.     def Info_func(self):
  57.         chat.AppendChat(2, "---------------------------")  
  58.         chat.AppendChat(1, "Simple code by ZAHON") 
  59.         chat.AppendChat(2, "---------------------------")  
  60.        
  61.     ### OnUpdate ###   
  62.     def OnUpdate(self):
  63.         global Drop_Item_Status
  64.         if Drop_Item_Status == 1:
  65.             self.Drop_Item_func()
  66.         else:
  67.             pass
  68.    
  69.     def __BuildKeyDict(self):
  70.         onPressKeyDict = {}
  71.         onPressKeyDict[app.DIK_F5]  = lambda : self.OpenWindow()
  72.         self.onPressKeyDict = onPressKeyDict
  73.    
  74.     def OnKeyDown(self, key):
  75.         try:
  76.             self.onPressKeyDict[key]()
  77.         except KeyError:
  78.             pass
  79.         except:
  80.             raise
  81.         return TRUE
  82.    
  83.     def OpenWindow(self):
  84.         if self.Board.IsShow():
  85.             self.Board.Hide()
  86.         else:
  87.             self.Board.Show()
  88.    
  89.     def Drop_Item_Close(self):
  90.         self.Drop_Item.Hide()
  91.  
  92. class WaitingDialog(ui.ScriptWindow):
  93.  
  94.     def __init__(self):
  95.         ui.ScriptWindow.__init__(self)
  96.         self.eventTimeOver = lambda *arg: None
  97.         self.eventExit = lambda *arg: None
  98.  
  99.     def __del__(self):
  100.         ui.ScriptWindow.__del__(self)
  101.  
  102.     def Open(self, waitTime):
  103.         curTime = time.clock()
  104.         self.endTime = curTime + waitTime
  105.  
  106.         self.Show()    
  107.  
  108.     def Close(self):
  109.         self.Hide()
  110.  
  111.     def Destroy(self):
  112.         self.Hide()
  113.  
  114.     def SAFE_SetTimeOverEvent(self, event):
  115.         self.eventTimeOver = ui.__mem_func__(event)
  116.  
  117.     def SAFE_SetExitEvent(self, event):
  118.         self.eventExit = ui.__mem_func__(event)
  119.        
  120.    
  121.     def OnUpdate(self):
  122.         lastTime = max(0, self.endTime - time.clock())
  123.         if 0 == lastTime:
  124.             self.Close()
  125.             self.eventTimeOver()
  126.            
  127.         else:
  128.             return         
  129.        
  130. class Component:
  131.     def Button(self, parent, buttonName, tooltipText, x, y, func, UpVisual, OverVisual, DownVisual):
  132.         button = ui.Button()
  133.         if parent != None:
  134.             button.SetParent(parent)
  135.         button.SetPosition(x, y)
  136.         button.SetUpVisual(UpVisual)
  137.         button.SetOverVisual(OverVisual)
  138.         button.SetDownVisual(DownVisual)
  139.         button.SetText(buttonName)
  140.         button.SetToolTipText(tooltipText)
  141.         button.Show()
  142.         button.SetEvent(func)
  143.         return button
  144.  
  145.     def ToggleButton(self, parent, buttonName, tooltipText, x, y, funcUp, funcDown, UpVisual, OverVisual, DownVisual):
  146.         button = ui.ToggleButton()
  147.         if parent != None:
  148.             button.SetParent(parent)
  149.         button.SetPosition(x, y)
  150.         button.SetUpVisual(UpVisual)
  151.         button.SetOverVisual(OverVisual)
  152.         button.SetDownVisual(DownVisual)
  153.         button.SetText(buttonName)
  154.         button.SetToolTipText(tooltipText)
  155.         button.Show()
  156.         button.SetToggleUpEvent(funcUp)
  157.         button.SetToggleDownEvent(funcDown)
  158.         return button
  159.  
  160.     def EditLine(self, parent, editlineText, x, y, width, heigh, max):
  161.         SlotBar = ui.SlotBar()
  162.         if parent != None:
  163.             SlotBar.SetParent(parent)
  164.         SlotBar.SetSize(width, heigh)
  165.         SlotBar.SetPosition(x, y)
  166.         SlotBar.Show()
  167.         Value = ui.EditLine()
  168.         Value.SetParent(SlotBar)
  169.         Value.SetSize(width, heigh)
  170.         Value.SetPosition(1, 1)
  171.         Value.SetMax(max)
  172.         Value.SetLimitWidth(width)
  173.         Value.SetMultiLine()
  174.         Value.SetText(editlineText)
  175.         Value.Show()
  176.         return SlotBar, Value
  177.  
  178.     def TextLine(self, parent, textlineText, x, y, color):
  179.         textline = ui.TextLine()
  180.         if parent != None:
  181.             textline.SetParent(parent)
  182.         textline.SetPosition(x, y)
  183.         if color != None:
  184.             textline.SetFontColor(color[0], color[1], color[2])
  185.         textline.SetText(textlineText)
  186.         textline.Show()
  187.         return textline
  188.  
  189.     def RGB(self, r, g, b):
  190.         return (r*255, g*255, b*255)
  191.  
  192.     def SliderBar(self, parent, sliderPos, func, x, y):
  193.         Slider = ui.SliderBar()
  194.         if parent != None:
  195.             Slider.SetParent(parent)
  196.         Slider.SetPosition(x, y)
  197.         Slider.SetSliderPos(sliderPos / 100)
  198.         Slider.Show()
  199.         Slider.SetEvent(func)
  200.         return Slider
  201.  
  202.     def ExpandedImage(self, parent, x, y, img):
  203.         image = ui.ExpandedImageBox()
  204.         if parent != None:
  205.             image.SetParent(parent)
  206.         image.SetPosition(x, y)
  207.         image.LoadImage(img)
  208.         image.Show()
  209.         return image
  210.  
  211.     def ComboBox(self, parent, text, x, y, width):
  212.         combo = ui.ComboBox()
  213.         if parent != None:
  214.             combo.SetParent(parent)
  215.         combo.SetPosition(x, y)
  216.         combo.SetSize(width, 15)
  217.         combo.SetCurrentItem(text)
  218.         combo.Show()
  219.         return combo
  220.  
  221.     def ThinBoard(self, parent, moveable, x, y, width, heigh, center):
  222.         thin = ui.ThinBoard()
  223.         if parent != None:
  224.             thin.SetParent(parent)
  225.         if moveable == TRUE:
  226.             thin.AddFlag('movable')
  227.             thin.AddFlag('float')
  228.         thin.SetSize(width, heigh)
  229.         thin.SetPosition(x, y)
  230.         if center == TRUE:
  231.             thin.SetCenterPosition()
  232.         thin.Show()
  233.         return thin
  234.  
  235.     def Gauge(self, parent, width, color, x, y):
  236.         gauge = ui.Gauge()
  237.         if parent != None:
  238.             gauge.SetParent(parent)
  239.         gauge.SetPosition(x, y)
  240.         gauge.MakeGauge(width, color)
  241.         gauge.Show()
  242.         return gauge
  243.  
  244.     def ListBoxEx(self, parent, x, y, width, heigh):
  245.         bar = ui.Bar()
  246.         if parent != None:
  247.             bar.SetParent(parent)
  248.         bar.SetPosition(x, y)
  249.         bar.SetSize(width, heigh)
  250.         bar.SetColor(0x77000000)
  251.         bar.Show()
  252.         ListBox=ui.ListBoxEx()
  253.         ListBox.SetParent(bar)
  254.         ListBox.SetPosition(0, 0)
  255.         ListBox.SetSize(width, heigh)
  256.         ListBox.Show()
  257.         scroll = ui.ScrollBar()
  258.         scroll.SetParent(ListBox)
  259.         scroll.SetPosition(width-15, 0)
  260.         scroll.SetScrollBarSize(heigh)
  261.         scroll.Show()
  262.         ListBox.SetScrollBar(scroll)
  263.         return bar, ListBox
  264.  
  265. Drop_Item().Show()
Advertisement
Add Comment
Please, Sign In to add comment