Advertisement
Guest User

Untitled

a guest
Dec 27th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.61 KB | None | 0 0
  1. import chat
  2. import ui
  3. import dbg
  4. import app
  5. import net
  6.  
  7. class Dialog1(ui.Window):
  8.     def __init__(self):
  9.         ui.Window.__init__(self)
  10.         self.BuildWindow()
  11.  
  12.     def __del__(self):
  13.         ui.Window.__del__(self)
  14.  
  15.     def BuildWindow(self):
  16.         self.Board = ui.BoardWithTitleBar()
  17.         self.Board.SetSize(154, 107)
  18.         self.Board.SetCenterPosition()
  19.         self.Board.AddFlag('movable')
  20.         self.Board.AddFlag('float')
  21.         self.Board.SetTitleName('Metin2 Yang Bot')
  22.         self.Board.SetCloseEvent(self.Close)
  23.         self.Board.Show()
  24.         self.__BuildKeyDict()
  25.         self.comp = Component()
  26.  
  27.         self.credits = self.comp.Button(self.Board, 'Credits', '', 91, 60, self.credits_func, 'd:/ymir work/ui/public/small_button_01.sub', 'd:/ymir work/ui/public/small_button_02.sub', 'd:/ymir work/ui/public/small_button_03.sub')
  28.         self.start = self.comp.Button(self.Board, 'Start', '', 18, 60, self.start_func, 'd:/ymir work/ui/public/middle_button_01.sub', 'd:/ymir work/ui/public/middle_button_02.sub', 'd:/ymir work/ui/public/middle_button_03.sub')
  29.         self.slotbar_timestxt, self.timestxt = self.comp.EditLine(self.Board, '10', 97, 38, 35, 15, 5)
  30.         self.times = self.comp.TextLine(self.Board, 'Times to repeat:', 18, 41, self.comp.RGB(650, 650, 255))
  31.    
  32.     def credits_func(self):
  33.         chat.AppendChat(chat.CHAT_TYPE_NOTICE, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Yang Bot~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
  34.         chat.AppendChat(chat.CHAT_TYPE_NOTICE, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Enjoy It~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
  35.    
  36.     def start_func(self):
  37.         for i in range(int(self.timestxt.GetText())):
  38.             net.SendShopBuyPacket(12)
  39.             net.SendShopSellPacket(0)
  40.        
  41.    
  42.     def __BuildKeyDict(self):
  43.         onPressKeyDict = {}
  44.         onPressKeyDict[app.DIK_F5]  = lambda : self.OpenWindow()
  45.         self.onPressKeyDict = onPressKeyDict
  46.    
  47.     def OnKeyDown(self, key):
  48.         try:
  49.             self.onPressKeyDict[key]()
  50.         except KeyError:
  51.             pass
  52.         except:
  53.             raise
  54.         return TRUE
  55.    
  56.     def OpenWindow(self):
  57.         if self.Board.IsShow():
  58.             self.Board.Hide()
  59.         else:
  60.             self.Board.Show()
  61.    
  62.     def Close(self):
  63.         self.Board.Hide()
  64.  
  65. class Component:
  66.     def Button(self, parent, buttonName, tooltipText, x, y, func, UpVisual, OverVisual, DownVisual):
  67.         button = ui.Button()
  68.         if parent != None:
  69.             button.SetParent(parent)
  70.         button.SetPosition(x, y)
  71.         button.SetUpVisual(UpVisual)
  72.         button.SetOverVisual(OverVisual)
  73.         button.SetDownVisual(DownVisual)
  74.         button.SetText(buttonName)
  75.         button.SetToolTipText(tooltipText)
  76.         button.Show()
  77.         button.SetEvent(func)
  78.         return button
  79.  
  80.     def ToggleButton(self, parent, buttonName, tooltipText, x, y, funcUp, funcDown, UpVisual, OverVisual, DownVisual):
  81.         button = ui.ToggleButton()
  82.         if parent != None:
  83.             button.SetParent(parent)
  84.         button.SetPosition(x, y)
  85.         button.SetUpVisual(UpVisual)
  86.         button.SetOverVisual(OverVisual)
  87.         button.SetDownVisual(DownVisual)
  88.         button.SetText(buttonName)
  89.         button.SetToolTipText(tooltipText)
  90.         button.Show()
  91.         button.SetToggleUpEvent(funcUp)
  92.         button.SetToggleDownEvent(funcDown)
  93.         return button
  94.  
  95.     def EditLine(self, parent, editlineText, x, y, width, heigh, max):
  96.         SlotBar = ui.SlotBar()
  97.         if parent != None:
  98.             SlotBar.SetParent(parent)
  99.         SlotBar.SetSize(width, heigh)
  100.         SlotBar.SetPosition(x, y)
  101.         SlotBar.Show()
  102.         Value = ui.EditLine()
  103.         Value.SetParent(SlotBar)
  104.         Value.SetSize(width, heigh)
  105.         Value.SetPosition(1, 1)
  106.         Value.SetMax(max)
  107.         Value.SetLimitWidth(width)
  108.         Value.SetMultiLine()
  109.         Value.SetText(editlineText)
  110.         Value.Show()
  111.         return SlotBar, Value
  112.  
  113.     def TextLine(self, parent, textlineText, x, y, color):
  114.         textline = ui.TextLine()
  115.         if parent != None:
  116.             textline.SetParent(parent)
  117.         textline.SetPosition(x, y)
  118.         if color != None:
  119.             textline.SetFontColor(color[0], color[1], color[2])
  120.         textline.SetText(textlineText)
  121.         textline.Show()
  122.         return textline
  123.  
  124.     def RGB(self, r, g, b):
  125.         return (r*255, g*255, b*255)
  126.  
  127.     def SliderBar(self, parent, sliderPos, func, x, y):
  128.         Slider = ui.SliderBar()
  129.         if parent != None:
  130.             Slider.SetParent(parent)
  131.         Slider.SetPosition(x, y)
  132.         Slider.SetSliderPos(sliderPos / 100)
  133.         Slider.Show()
  134.         Slider.SetEvent(func)
  135.         return Slider
  136.  
  137.     def ExpandedImage(self, parent, x, y, img):
  138.         image = ui.ExpandedImageBox()
  139.         if parent != None:
  140.             image.SetParent(parent)
  141.         image.SetPosition(x, y)
  142.         image.LoadImage(img)
  143.         image.Show()
  144.         return image
  145.  
  146.     def ComboBox(self, parent, text, x, y, width):
  147.         combo = ui.ComboBox()
  148.         if parent != None:
  149.             combo.SetParent(parent)
  150.         combo.SetPosition(x, y)
  151.         combo.SetSize(width, 15)
  152.         combo.SetCurrentItem(text)
  153.         combo.Show()
  154.         return combo
  155.  
  156.     def ThinBoard(self, parent, moveable, x, y, width, heigh, center):
  157.         thin = ui.ThinBoard()
  158.         if parent != None:
  159.             thin.SetParent(parent)
  160.         if moveable == TRUE:
  161.             thin.AddFlag('movable')
  162.             thin.AddFlag('float')
  163.         thin.SetSize(width, heigh)
  164.         thin.SetPosition(x, y)
  165.         if center == TRUE:
  166.             thin.SetCenterPosition()
  167.         thin.Show()
  168.         return thin
  169.  
  170.     def Gauge(self, parent, width, color, x, y):
  171.         gauge = ui.Gauge()
  172.         if parent != None:
  173.             gauge.SetParent(parent)
  174.         gauge.SetPosition(x, y)
  175.         gauge.MakeGauge(width, color)
  176.         gauge.Show()
  177.         return gauge
  178.  
  179.     def ListBoxEx(self, parent, x, y, width, heigh):
  180.         bar = ui.Bar()
  181.         if parent != None:
  182.             bar.SetParent(parent)
  183.         bar.SetPosition(x, y)
  184.         bar.SetSize(width, heigh)
  185.         bar.SetColor(0x77000000)
  186.         bar.Show()
  187.         ListBox=ui.ListBoxEx()
  188.         ListBox.SetParent(bar)
  189.         ListBox.SetPosition(0, 0)
  190.         ListBox.SetSize(width, heigh)
  191.         ListBox.Show()
  192.         scroll = ui.ScrollBar()
  193.         scroll.SetParent(ListBox)
  194.         scroll.SetPosition(width-15, 0)
  195.         scroll.SetScrollBarSize(heigh)
  196.         scroll.Show()
  197.         ListBox.SetScrollBar(scroll)
  198.         return bar, ListBox
  199.  
  200. Dialog1().Show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement