Advertisement
Guest User

Untitled

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