Advertisement
Guest User

Untitled

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