Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 59.01 KB | None | 0 0
  1. import shop
  2. import player
  3. import item
  4. import ui
  5. import net
  6. import localeInfo
  7. import game
  8. import chat
  9. import grp
  10. import wndMgr
  11. import mouseModule
  12. import constInfo
  13.  
  14. from uitooltip import ItemToolTip
  15. #
  16.  
  17. WEAR_NAMES = ItemToolTip.WEAR_NAMES
  18. AFFECT_DICT = ItemToolTip.AFFECT_DICT
  19.  
  20. ###
  21. BONI_AVAIL = [1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,18,19,20,21,22,23,27,28,29,30,31,32,33,34,35,36,37,39,41,43,44,45,48,53,71,72]
  22.  
  23. #
  24. BONI_RARE_AVAIL = [1,2]
  25.  
  26. # Das Switch-Item
  27. SWITCH_VNUM = 71084
  28. SWITCH_RARE_VNUM = 71052
  29.  
  30. #
  31. MIN_SWITCH_DELAY = 35
  32. MAX_SWITCH_DELAY_APPEND = 120
  33.  
  34. #
  35. MAX_NUM = 7
  36.  
  37. proposals = {
  38. 1: { # 1 = Weapon
  39. "PVP (Corp)":[
  40. [9,10],
  41. [15,10],
  42. [17,10],
  43. [16,10],
  44. [5,8],
  45. [3,8],
  46. ],
  47. "PVP (Mental)":[
  48. [9,10],
  49. [15,10],
  50. [17,10],
  51. [6,8],
  52. [5,10],
  53. [16,10],
  54. ],
  55. "PVM": [
  56. [5,10],
  57. [19,20],
  58. ],
  59. },
  60. 2: [ # Armor
  61. [ #BODY,
  62. ],
  63. [ #HEAD,
  64. ],
  65. [ #SHIELD,
  66. ],
  67. [ #WRIST,
  68. ],
  69. [ #FOOTS,
  70. ],
  71. [ #NECK,
  72. ],
  73. [ #EAR,
  74. ],
  75. ],
  76. }
  77.  
  78. # Farben :)
  79. # COLOR_BG = grp.GenerateColor(0.0, 0.0, 0.0, 0.5)
  80. # COLOR_INACTIVE = grp.GenerateColor(0.0, 0.0, 1.0, 0.2)
  81. # COLOR_ACTIVE = grp.GenerateColor(0.1, 0.6, 1.0, 0.2)
  82. # COLOR_FINISHED = grp.GenerateColor(0.0, 0.8, 1.0, 0.3)
  83.  
  84. # COLOR_INACTIVE_RARE = grp.GenerateColor(0.0, 0.2, 1.0, 0.2)
  85. # COLOR_ACTIVE_RARE = grp.GenerateColor(0.2, 0.7, 1.0, 0.2)
  86.  
  87. # COLOR_HIGHLIGHT_RARE = grp.GenerateColor(0.2, 0.2, 1.0, 0.05)
  88.  
  89. # COLOR_PIN_HINT = grp.GenerateColor(0.0, 0.5, 1.0, 0.3)
  90.  
  91. # COLOR_CHECKBOX_NOT_SELECTED = grp.GenerateColor(0.0, 0.3, 1.0, 0.1)
  92. # COLOR_CHECKBOX_SELECTED = grp.GenerateColor(0.0, 0.3, 1.0, 0.3)
  93.  
  94. # Standardfarben:
  95. COLOR_BG = grp.GenerateColor(0.0, 0.0, 0.0, 0.5)
  96. COLOR_INACTIVE = grp.GenerateColor(1.0, 0.0, 0.0, 0.2)
  97. COLOR_ACTIVE = grp.GenerateColor(1.0, 0.6, 0.1, 0.2)
  98. COLOR_FINISHED = grp.GenerateColor(0.0, 1.0, 0.0, 0.2)
  99.  
  100. COLOR_INACTIVE_RARE = grp.GenerateColor(1.0, 0.2, 0.0, 0.2)
  101. COLOR_ACTIVE_RARE = grp.GenerateColor(1.0, 0.7, 0.2, 0.2)
  102.  
  103. COLOR_HIGHLIGHT_RARE = grp.GenerateColor(1.0, 0.2, 0.2, 0.05)
  104.  
  105. COLOR_PIN_HINT = grp.GenerateColor(0.0, 0.5, 1.0, 0.3)
  106.  
  107.  
  108. COLOR_CHECKBOX_NOT_SELECTED = grp.GenerateColor(1.0, 0.3, 0.0, 0.1)
  109. COLOR_CHECKBOX_SELECTED = grp.GenerateColor(0.3, 1.0, 1.0, 0.3)
  110.  
  111.  
  112. DISTANCE_BOTTOM = 36
  113.  
  114. class Bar(ui.Bar):
  115. def __init__(self,layer = "UI"):
  116. ui.Bar.__init__(self,layer)
  117. def SetColor(self,color):
  118. wndMgr.SetColor(self.hWnd, color)
  119. self.color = color
  120.  
  121.  
  122. class BonusSelector(ui.Bar):
  123. def Activate(self):
  124. self.sub_parent.resetSwitch()
  125. self.Status_new.SetColor(COLOR_ACTIVE)
  126. self.sub_parent.StatusBar.SetColor(COLOR_ACTIVE)
  127. self.sub_parent.StatusText.SetText("Activ")
  128. self.Starter.SetText("Opreste ("+str(self.index+1)+") Stop")
  129. self.sub_parent.boni_active = 1
  130. if self.sub_parent.parentWindow.parentWindow.gameWindow != None:
  131. self.sub_parent.blockBar.swib_normal.SetColor(COLOR_ACTIVE)
  132. pass
  133. def Deactivate(self):
  134. self.sub_parent.resetSwitch()
  135. self.Status_new.SetColor(COLOR_INACTIVE)
  136. self.sub_parent.StatusBar.SetColor(COLOR_INACTIVE)
  137. self.sub_parent.StatusText.SetText("Inactiv")
  138. self.Starter.SetText("Schimba ("+str(self.index+1)+") Start")
  139. self.sub_parent.boni_active = 0
  140. if self.sub_parent.parentWindow.parentWindow.gameWindow != None:
  141. self.sub_parent.blockBar.swib_normal.SetColor(COLOR_INACTIVE)
  142. pass
  143.  
  144. def Activate_rare(self):
  145. self.sub_parent.resetSwitch_rare()
  146. self.sub_parent.StatusBar_rare.SetColor(COLOR_ACTIVE_RARE)
  147. self.sub_parent.StatusText_rare.SetText("6/7 Activ")
  148. self.Starter_rare_boni.SetText("6/7 Stop")
  149. self.sub_parent.boni_rare_active = 1
  150. if self.parentWindow.parentWindow.gameWindow != None:
  151. self.sub_parent.blockBar.swib_rare.SetColor(COLOR_ACTIVE_RARE)
  152. pass
  153. def Deactivate_rare(self):
  154. self.sub_parent.resetSwitch_rare()
  155. # self.Status_new.SetColor(COLOR_INACTIVE)
  156. self.sub_parent.StatusBar_rare.SetColor(COLOR_INACTIVE_RARE)
  157. self.sub_parent.StatusText_rare.SetText("6/7 Inactiv")
  158. self.Starter_rare_boni.SetText("6/7 Start")
  159. self.Starter_rare_boni.SetUp()
  160. self.sub_parent.boni_rare_active = 0
  161. if self.sub_parent.parentWindow.parentWindow.gameWindow != None:
  162. self.sub_parent.blockBar.swib_rare.SetColor(COLOR_INACTIVE_RARE)
  163. pass
  164.  
  165. def Finish(self):
  166. self.Status_new.SetColor(COLOR_FINISHED)
  167. self.sub_parent.StatusBar.SetColor(COLOR_FINISHED)
  168. self.sub_parent.StatusText.SetText("Gata")
  169. self.Starter.SetText("Schimba ("+str(self.index+1)+") Continua")
  170. self.sub_parent.boni_active = 0
  171. if self.sub_parent.parentWindow.parentWindow.gameWindow != None:
  172. self.sub_parent.blockBar.swib_normal.SetColor(COLOR_FINISHED)
  173. pass
  174.  
  175. def Finish_rare(self):
  176. # self.Status_new.SetColor(COLOR_FINISHED)
  177. self.sub_parent.StatusBar_rare.SetColor(COLOR_FINISHED)
  178. self.sub_parent.StatusText_rare.SetText("6/7 Gata")
  179. self.Starter_rare_boni.SetText("6/7 Continua")
  180. self.sub_parent.boni_rare_active = 0
  181. if self.sub_parent.parentWindow.parentWindow.gameWindow != None:
  182. self.sub_parent.blockBar.swib_rare.SetColor(COLOR_FINISHED)
  183. pass
  184. def Block(self):
  185. self.BlockBar.Show()
  186. self.BlockBar.sub.Show()
  187. self.Starter.Hide()
  188. pass
  189. def Unblock(self):
  190. self.BlockBar.sub.Hide()
  191. self.BlockBar.Hide()
  192. self.Starter.Show()
  193. pass
  194.  
  195.  
  196. def enable_rare_boni(self):
  197. for i in range(0,4):
  198. self.boni[6][i].Show()
  199. self.boni[7][i].Show()
  200. self.Starter.SetPosition(0,140+45)
  201. self.bg_rare_boni.Show()
  202. self.bg_rare_boni_but.Show()
  203. self.Starter_rare_boni.Show()
  204. self.sub_parent.StatusBar_rare.Show()
  205.  
  206. if self.sub_parent.parentWindow.parentWindow.gameWindow != None:
  207. self.sub_parent.blockBar.Enable_rare(1)
  208.  
  209. def disable_rare_boni(self):
  210. for i in range(0,4):
  211. self.boni[6][i].Hide()
  212. self.boni[7][i].Hide()
  213. self.Starter.SetPosition(0,140)
  214. self.bg_rare_boni.Hide()
  215. self.bg_rare_boni_but.Hide()
  216. self.Starter_rare_boni.Hide()
  217. self.sub_parent.StatusBar_rare.Hide()
  218. self.Deactivate_rare()
  219. if self.sub_parent.parentWindow.parentWindow.gameWindow != None:
  220. self.sub_parent.blockBar.Enable_rare(0)
  221.  
  222. def __init__(self,sub_parent):
  223. ui.Bar.__init__(self, "UI")
  224. self.sub_parent = sub_parent
  225. self.index = sub_parent.index
  226. self.SetColor(COLOR_BG)
  227. self.SetSize(500,225+10)
  228. self.boni = {}
  229. self.Status_new = ui.Bar()
  230. self.Status_new.SetParent(self)
  231. self.Status_new.SetColor(COLOR_INACTIVE)
  232. self.Status_new.SetSize(500,5)
  233. self.Status_new.Show()
  234.  
  235.  
  236. self.bg_rare_boni = ui.Bar()
  237. self.bg_rare_boni.SetColor(COLOR_HIGHLIGHT_RARE)
  238. self.bg_rare_boni.SetParent(self)
  239. self.bg_rare_boni.SetPosition(0,132)
  240. self.bg_rare_boni.SetSize(500,51)
  241. self.bg_rare_boni.Hide()
  242.  
  243. self.bg_rare_boni_but = ui.Bar()
  244. self.bg_rare_boni_but.SetColor(COLOR_HIGHLIGHT_RARE)
  245. self.bg_rare_boni_but.SetParent(self)
  246. self.bg_rare_boni_but.SetPosition(400,133+50)
  247. self.bg_rare_boni_but.SetSize(100,25)
  248. self.bg_rare_boni_but.Hide()
  249.  
  250. self.EnableRareBoni = CheckBox("6/7 Afisati")
  251. self.EnableRareBoni.SetParent(self)
  252. self.EnableRareBoni.SetPosition(10,185)
  253. self.EnableRareBoni.eventUp = self.disable_rare_boni
  254. self.EnableRareBoni.eventDown = self.enable_rare_boni
  255. self.EnableRareBoni.Show()
  256.  
  257. self.Starter = ui.ToggleButton()
  258. self.Starter.SetWindowHorizontalAlignCenter()
  259. self.Starter.SetParent(self)
  260. self.Starter.SetUpVisual("d:/ymir work/ui/public/XLarge_Button_01.sub")
  261. self.Starter.SetOverVisual("d:/ymir work/ui/public/XLarge_button_02.sub")
  262. self.Starter.SetDownVisual("d:/ymir work/ui/public/XLarge_button_03.sub")
  263. self.Starter.SetPosition(0,140)
  264. self.Starter.SetText("Schimba Start")
  265. self.Starter.SetToggleDownEvent(self.Activate)
  266. self.Starter.SetToggleUpEvent(self.Deactivate)
  267. self.Starter.Show()
  268.  
  269. self.Starter_rare_boni = ui.ToggleButton()
  270. self.Starter_rare_boni.SetWindowHorizontalAlignCenter()
  271. self.Starter_rare_boni.SetParent(self)
  272. self.Starter_rare_boni.SetUpVisual("d:/ymir work/ui/public/Large_Button_01.sub")
  273. self.Starter_rare_boni.SetOverVisual("d:/ymir work/ui/public/Large_button_02.sub")
  274. self.Starter_rare_boni.SetDownVisual("d:/ymir work/ui/public/Large_button_03.sub")
  275. self.Starter_rare_boni.SetPosition(200,140+45)
  276. self.Starter_rare_boni.SetText("6/7 Start")
  277. self.Starter_rare_boni.SetToggleDownEvent(self.Activate_rare)
  278. self.Starter_rare_boni.SetToggleUpEvent(self.Deactivate_rare)
  279. self.Starter_rare_boni.Hide()
  280.  
  281. for i in range(7,5,-1):
  282. vas = i
  283. self.boni[vas] = {}
  284. self.boni[vas][0] = ui.TextLine()
  285. self.boni[vas][0].SetParent(self)
  286. self.boni[vas][0].SetText("Bonus "+str(vas))
  287. self.boni[vas][0].SetPosition(15,10+25*(vas-1))
  288. self.boni[vas][0].Hide()
  289. self.boni[vas][1] = DropDown(self,"- Niciunul -")
  290. self.boni[vas][1].SetPosition(70,10+25*(vas-1))
  291. for x in AFFECT_DICT:
  292. if x in BONI_RARE_AVAIL:
  293. self.boni[vas][1].AppendItem(str(AFFECT_DICT[x](0)),x)
  294. self.boni[vas][1].SetSize(330,20)
  295. self.boni[vas][1].Hide()
  296. self.boni[vas][2] = ui.Bar("UI")
  297. self.boni[vas][2].SetParent(self)
  298. self.boni[vas][2].SetPosition(410,10+25*(vas-1))
  299. self.boni[vas][2].SetColor(0xC0000000)
  300. self.boni[vas][2].SetSize(80,20)
  301. self.boni[vas][2].Hide()
  302. self.boni[vas][3] = Edit2("0",14)
  303. self.boni[vas][3].SetParent(self.boni[vas][2])
  304. self.boni[vas][3].SetNumberMode()
  305. self.boni[vas][3].SetSize(80,20)
  306. self.boni[vas][3].SetPosition(4,3)
  307. self.boni[vas][3].Hide()
  308.  
  309. for i in range(0,5):
  310. vas = 5-i
  311. self.boni[vas] = {}
  312. self.boni[vas][0] = ui.TextLine()
  313. self.boni[vas][0].SetParent(self)
  314. self.boni[vas][0].SetText("Bonus "+str(vas))
  315. self.boni[vas][0].SetPosition(15,10+25*(vas-1))
  316. self.boni[vas][0].Show()
  317. self.boni[vas][1] = DropDown(self,"- Niciunul -")
  318. self.boni[vas][1].SetPosition(70,10+25*(vas-1))
  319. for x in AFFECT_DICT:
  320. if x in BONI_AVAIL:
  321. self.boni[vas][1].AppendItem(str(AFFECT_DICT[x](0)),x)
  322. self.boni[vas][1].SetSize(330,20)
  323. self.boni[vas][1].Show()
  324. self.boni[vas][2] = ui.Bar("UI")
  325. self.boni[vas][2].SetParent(self)
  326. self.boni[vas][2].SetPosition(410,10+25*(vas-1))
  327. self.boni[vas][2].SetColor(0xC0000000)
  328. self.boni[vas][2].SetSize(80,20)
  329. self.boni[vas][2].Show()
  330. self.boni[vas][3] = Edit2("0",14)
  331. self.boni[vas][3].SetParent(self.boni[vas][2])
  332. self.boni[vas][3].SetNumberMode()
  333. self.boni[vas][3].SetSize(80,20)
  334. self.boni[vas][3].SetPosition(4,3)
  335. self.boni[vas][3].Show()
  336.  
  337. self.but_propose = DropDown(self,'Sugestii',0)
  338. self.but_propose.SetParent(self)
  339. self.but_propose.SetPosition(380,210)
  340. self.but_propose.OnChange=self.change_boni
  341. self.but_propose.Show()
  342.  
  343. self.BlockBar = ui.Bar()
  344. self.BlockBar.SetParent(self)
  345. self.BlockBar.SetColor(COLOR_INACTIVE)
  346. self.BlockBar.SetPosition(0,5)
  347. self.BlockBar.SetSize(500,170-5+35+2)
  348. self.BlockBar.Hide()
  349.  
  350. self.BlockBar.sub = ui.Bar()
  351. self.BlockBar.sub.SetParent(self)
  352. self.BlockBar.sub.SetColor(COLOR_INACTIVE)
  353. self.BlockBar.sub.SetPosition(500-122,5+170-5+35+2)
  354. self.BlockBar.sub.SetSize(122,30)
  355. self.BlockBar.sub.Hide()
  356.  
  357. self.BlockText = ui.TextLine()
  358. self.BlockText.SetParent(self.BlockBar)
  359. self.BlockText.SetWindowHorizontalAlignCenter()
  360. self.BlockText.SetHorizontalAlignCenter()
  361. self.BlockText.SetPosition(0,140)
  362. self.BlockText.SetText("Nu poti schimba pe acest item")
  363. self.BlockText.Show()
  364.  
  365. self.prepare_propose()
  366.  
  367. def change_boni(self):
  368. use = self.but_propose.DropList.GetSelectedItem().value
  369. bon = 1
  370. item.SelectItem(self.sub_parent.vnum)
  371. for x in use:
  372. # TODO: Check if bonus exists on item!!
  373. ok = 1
  374. for i in xrange(item.ITEM_APPLY_MAX_NUM):
  375. (affectType, affectValue) = item.GetAffect(i)
  376. if affectType == x[0]:
  377. ok = 0
  378. if ok == 0:
  379. continue
  380. y = self.boni[bon][1]
  381. y.SelectByAffectId(x[0])
  382. self.boni[bon][1].act.SetText(y.DropList.GetSelectedItem().textBox.GetText())
  383. self.boni[bon][3].SetText(str(x[1]))
  384. bon+=1
  385.  
  386. for x in range(bon,6):
  387. y = self.boni[x][1].DropList
  388. y.SelectIndex(0)
  389. self.boni[x][1].act.SetText(y.GetSelectedItem().textBox.GetText())
  390. self.boni[x][3].SetText("0")
  391.  
  392.  
  393. def prepare_propose(self):
  394. self.but_propose.DropList.RemoveAllItems()
  395. self.but_propose.maxh = 95
  396. self.but_propose.c = 0
  397. self.but_propose.AppendItem("Sterge",[])
  398.  
  399. item.SelectItem(self.sub_parent.vnum)
  400. type = item.GetItemType()
  401.  
  402. use = proposals[type]
  403. if type == 2:
  404. use = use[item.GetItemSubType()]
  405.  
  406. for prop in use:
  407. self.but_propose.AppendItem(prop,use[prop])
  408.  
  409.  
  410.  
  411.  
  412. class ItemTabBar(ui.Window):
  413.  
  414. class BlockBar(ui.Window):
  415. size_res = 32
  416. multi = 1
  417. def SetSize(self,i=1):
  418. self.multi = i
  419. ui.Window.SetSize(self,self.size_res,self.size_res*i)
  420. if self.rare_enabled == 1:
  421. self.swib_normal.SetSize(self.size_res,self.size_res*i/3*2)
  422. pos1 = int(1.0*self.size_res*i/3.0*2.0)
  423. self.swib_normal.SetSize(self.size_res,pos1)
  424. self.swib_rare.SetSize(self.size_res,self.size_res*i-pos1)
  425. self.swib_rare.SetPosition(0,pos1)
  426. self.swib_rare.Show()
  427. else:
  428. self.swib_normal.SetSize(self.size_res,self.size_res*i)
  429. self.swib_rare.Hide()
  430.  
  431. def Enable_rare(self,o = 1):
  432. self.rare_enabled = o
  433. self.SetSize(self.multi)
  434.  
  435. def __init__(self):
  436. ui.Window.__init__(self)
  437. self.rare_enabled = 0
  438. self.swib_normal = ui.Bar()
  439. self.swib_normal.SetParent(self)
  440. self.swib_normal.SetSize(self.size_res,self.size_res*self.multi)
  441. self.swib_normal.SetColor(COLOR_INACTIVE)
  442. self.swib_normal.SetPosition(0,0)
  443. self.swib_normal.Show()
  444.  
  445. self.swib_rare = ui.Bar()
  446. self.swib_rare.SetParent(self)
  447. self.swib_rare.SetSize(self.size_res,self.size_res)
  448. self.swib_rare.SetColor(COLOR_INACTIVE_RARE)
  449. self.swib_rare.SetPosition(0,0)
  450. self.swib_rare.Hide()
  451. self.SetSize(1)
  452.  
  453.  
  454. class ItemTab(ui.Bar):
  455.  
  456. height_selected = 36*3+8
  457. height_unselected = 36*3+5
  458.  
  459. def Destroy(self):
  460. self.parentWindow.parentWindow.enable_rebuy.SetParent(self.parentWindow.parentWindow)
  461. self.parentWindow.parentWindow.but_speed.SetParent(self.parentWindow.parentWindow)
  462. self.parentWindow.parentWindow.help_show_rare.SetParent(self.parentWindow.parentWindow)
  463. self.parentWindow.parentWindow.help_rebuy.SetParent(self.parentWindow.parentWindow)
  464. # self.parentWindow.parentWindow.help_stop_all.SetParent(self.parentWindow.parentWindow)
  465. self.parentWindow.parentWindow.help_duration.SetParent(self.parentWindow.parentWindow)
  466. # self.parentWindow.parentWindow.but_deactivate_all.SetParent(self.parentWindow.parentWindow)
  467. # self.parentWindow.parentWindow.but_deactivate_all.Hide()
  468. self.parentWindow.parentWindow.enable_rebuy.Hide()
  469. self.parentWindow.parentWindow.but_speed.Hide()
  470.  
  471. self.bonusSelector.Hide()
  472. self.bonusSelector.__del__()
  473. self.Hide()
  474. self.__del__()
  475.  
  476. def DeleteMe(self):
  477. self.parentWindow.DeleteTab(self.tabnum)
  478.  
  479. def __init__(self,parent,tabnum,index = 0,vnum = 0): ## Init ItemTab
  480. ui.Bar.__init__(self)
  481. self.SetColor(COLOR_BG)
  482. self.SetSize(self.width,self.height_unselected)
  483. self.index = index
  484. self.tabnum = tabnum
  485. self.vnum = vnum
  486. self.count = 0
  487. self.count_rare = 0
  488. self.parentWindow = parent
  489. self.SetParent(parent)
  490.  
  491.  
  492.  
  493. if self.parentWindow.parentWindow.gameWindow != None:
  494. self.blockBar = ItemTabBar.BlockBar()
  495. self.blockBar.SetParent(self.parentWindow.parentWindow.gameWindow.interface.wndInventory.wndItem)
  496. ipi = self.parentWindow.parentWindow.gameWindow.interface.wndInventory.inventoryPageIndex
  497. self.blockBar.Show()
  498. ip2 = self.index - ipi*45
  499. self.blockBar.SetPosition(((ip2-int(ip2/5)*5)*self.blockBar.size_res),int(ip2/5)*self.blockBar.size_res)
  500.  
  501. self.ItemIcon = ui.ImageBox()
  502. self.ItemIcon.SetParent(self)
  503. self.ItemIcon.AddFlag("not_pick")
  504. self.ItemIcon.SetWindowHorizontalAlignCenter()
  505. self.ItemIcon.SetWindowVerticalAlignCenter()
  506. self.ItemIcon.Show()
  507.  
  508. self.SlotName = ui.TextLine()
  509. self.SlotName.SetParent(self)
  510. self.SlotName.SetWindowHorizontalAlignCenter()
  511. self.SlotName.SetHorizontalAlignCenter()
  512. self.SlotName.SetPosition(0,5)
  513. self.SlotName.SetText("Slot %d" % (self.index+1))
  514. self.SlotName.AddFlag("not_pick")
  515. self.SlotName.Show()
  516.  
  517. self.StatusBar = Bar() # Special Bar
  518. self.StatusBar.SetParent(self)
  519. self.StatusBar.SetWindowVerticalAlignBottom()
  520. self.StatusBar.SetSize(self.width,20)
  521. self.StatusBar.SetPosition(0,20)
  522. self.StatusBar.SetColor(COLOR_INACTIVE)
  523. self.StatusBar.AddFlag("not_pick")
  524. self.StatusBar.Show()
  525.  
  526. self.StatusText = ui.TextLine()
  527. self.StatusText.SetParent(self.StatusBar)
  528. # self.StatusText.SetParent(self)
  529. self.StatusText.SetWindowHorizontalAlignCenter()
  530. self.StatusText.SetWindowVerticalAlignCenter()
  531. self.StatusText.SetHorizontalAlignCenter()
  532. self.StatusText.SetVerticalAlignCenter()
  533. self.StatusText.SetPosition(0,0)
  534. self.StatusText.SetText("Inactiv")
  535. self.StatusText.Show()
  536.  
  537.  
  538. self.StatusBar_rare = Bar() # Special Bar
  539. self.StatusBar_rare.SetParent(self)
  540. self.StatusBar_rare.SetWindowVerticalAlignBottom()
  541. self.StatusBar_rare.SetSize(self.width,20)
  542. self.StatusBar_rare.SetPosition(0,40)
  543. self.StatusBar_rare.SetColor(COLOR_INACTIVE_RARE)
  544. self.StatusBar_rare.AddFlag("not_pick")
  545. self.StatusBar_rare.Hide()
  546.  
  547. self.StatusText_rare = ui.TextLine()
  548. self.StatusText_rare.SetParent(self.StatusBar_rare)
  549. self.StatusText_rare.SetWindowHorizontalAlignCenter()
  550. self.StatusText_rare.SetWindowVerticalAlignCenter()
  551. self.StatusText_rare.SetHorizontalAlignCenter()
  552. self.StatusText_rare.SetVerticalAlignCenter()
  553. self.StatusText_rare.SetPosition(0,0)
  554. self.StatusText_rare.SetText("6/7 Inactiv")
  555. self.StatusText_rare.Show()
  556.  
  557.  
  558. self.CloseBut = ui.Button()
  559. self.CloseBut.SetParent(self)
  560. self.CloseBut.SetUpVisual("d:/ymir work/ui/public/close_button_01.sub")
  561. self.CloseBut.SetOverVisual("d:/ymir work/ui/public/close_button_02.sub")
  562. self.CloseBut.SetDownVisual("d:/ymir work/ui/public/close_button_03.sub")
  563. self.CloseBut.SetToolTipText("Inchide tab", 0, -23)
  564. self.CloseBut.SetEvent(self.DeleteMe)
  565. self.CloseBut.SetPosition(0,0)
  566. self.CloseBut.Show()
  567.  
  568.  
  569.  
  570. self.OnMouseLeftButtonDown = lambda: self.Select()
  571.  
  572. self.boni_active = 0
  573. self.boni_rare_active = 0
  574.  
  575. self.bonusSelector = BonusSelector(self)
  576. self.bonusSelector.SetParentProxy(self.parentWindow.parentWindow)
  577. self.bonusSelector.SetPosition(10,35+36*3+4*2)
  578. self.bonusSelector.Hide()
  579. self.vnum = 0
  580. self.SetIndex(index)
  581.  
  582. self.resetSwitch()
  583. self.resetSwitch_rare()
  584.  
  585. def IsActive(self):
  586. return self.boni_active == 1
  587. def IsActive_rare(self):
  588. return self.boni_rare_active == 1
  589.  
  590. def SetParentProxy(self,parent):
  591. ui.Bar.SetParentProxy(self,parent)
  592. def Select(self):
  593. for a in self.parentWindow.tabList:
  594. self.parentWindow.tabList[a].UnSelect()
  595. self.parentWindow.tabList[a].bonusSelector.Hide()
  596. self.bonusSelector.Show()
  597. self.SetSize(self.width,self.height_selected)
  598. self.Update()
  599. # self.parentWindow.parentWindow.but_deactivate_all.SetParent(self.bonusSelector)
  600. # self.parentWindow.parentWindow.but_deactivate_all.SetPosition(415-10,200+10)
  601. # self.parentWindow.parentWindow.but_deactivate_all.Show()
  602. self.parentWindow.parentWindow.enable_rebuy.SetParent(self.bonusSelector)
  603. self.parentWindow.parentWindow.enable_rebuy.SetPosition(10,200+10)
  604. self.parentWindow.parentWindow.enable_rebuy.Show()
  605. self.parentWindow.parentWindow.but_speed.SetParent(self.bonusSelector)
  606. self.parentWindow.parentWindow.but_speed.SetPosition(0,205+10)
  607. self.parentWindow.parentWindow.but_speed.Show()
  608.  
  609. self.parentWindow.parentWindow.help_show_rare.SetParent(self.bonusSelector)
  610. self.parentWindow.parentWindow.help_rebuy.SetParent(self.bonusSelector)
  611. # self.parentWindow.parentWindow.help_stop_all.SetParent(self.bonusSelector)
  612. self.parentWindow.parentWindow.help_duration.SetParent(self.bonusSelector)
  613.  
  614.  
  615. def UnSelect(self):
  616. self.SetSize(self.width,self.height_unselected)
  617. self.Update()
  618.  
  619. def Update(self):
  620. self.StatusBar.SetPosition(0,20)
  621. self.SetPosition((self.width+self.dist)*self.tabnum,0)
  622. self.SlotName.SetText("Slot %d" % (self.index+1))
  623.  
  624. def resetSwitch(self):
  625. self.values = [0,0,0,0,0]
  626. def resetSwitch_rare(self):
  627. self.values_rare = [0,0]
  628.  
  629. # last_switch = -1
  630. rebuyed = 0
  631. def nachkauf(self):
  632. if self.parentWindow.parentWindow.buyed != 0:
  633. return
  634. else:
  635. self.parentWindow.parentWindow.buyed = 1
  636. if self.parentWindow.parentWindow.enable_rebuy.checked == 1:
  637. for i in range(0,shop.SHOP_SLOT_COUNT):
  638. me = shop.GetItemID(i)
  639. if me == SWITCH_VNUM:
  640. if shop.GetItemPrice(i) > player.GetMoney():
  641. # chat.AppendChat(1,"-- Switchitem gefunden! Aber wir haben kein Geld :(")
  642. self.bonusSelector.Deactivate()
  643. return
  644. else:
  645. net.SendShopBuyPacket(i)
  646. self.rebuyed = 1
  647. # self.Switch()
  648. return
  649.  
  650. rebuyed_rare = 0
  651. def nachkauf_rare(self):
  652. if self.parentWindow.parentWindow.buyed_rare != 0:
  653. return
  654. else:
  655. self.parentWindow.parentWindow.buyed_rare = 1
  656. if self.parentWindow.parentWindow.enable_rebuy.checked == 1:
  657. for i in range(0,shop.SHOP_SLOT_COUNT):
  658. me = shop.GetItemID(i)
  659. if me == SWITCH_RARE_VNUM:
  660. if shop.GetItemPrice(i) > player.GetMoney():
  661. # chat.AppendChat(1,"-- Switchitem gefunden! Aber wir haben kein Geld :(")
  662. self.bonusSelector.Deactivate_rare()
  663. return
  664. else:
  665. net.SendShopBuyPacket(i)
  666. self.rebuyed_rare = 1
  667. # self.Switch()
  668. return
  669. # self.bonusSelector.Deactivate()
  670.  
  671. def Switch_rare(self):
  672. lc = 0
  673. for i in range(0,90*2):
  674. if player.GetItemIndex(i) == SWITCH_RARE_VNUM:
  675. lc+=player.GetItemCount(i)
  676.  
  677. if lc == 0 and self.parentWindow.parentWindow.enable_rebuy.checked == 0:
  678. chat.AppendChat(2,"Slot %d: 6/7 Schimbare fara succes." % (self.index+1))
  679. self.bonusSelector.Deactivate_rare()
  680. return
  681.  
  682. if lc < 15:
  683. self.nachkauf_rare()
  684.  
  685. if lc == 0:
  686. self.bonusSelector.Deactivate_rare()
  687. chat.AppendChat(2,"Slot %d: 6/7 Schimbare abandonata." % (self.index+1))
  688. return
  689.  
  690. for i in range(0,90*2):
  691. if player.GetItemIndex(i) == SWITCH_RARE_VNUM:
  692. net.SendItemUseToItemPacket(i,self.index)
  693. return
  694.  
  695. def Switch(self):
  696. lc = 0
  697. for i in range(0,90*2):
  698. if player.GetItemIndex(i) == SWITCH_VNUM:
  699. lc+=player.GetItemCount(i)
  700.  
  701. if lc == 0 and self.parentWindow.parentWindow.enable_rebuy.checked == 0:
  702. self.bonusSelector.Deactivate()
  703. return
  704.  
  705. if lc < 15:
  706. self.nachkauf()
  707.  
  708. if lc == 0:
  709. self.bonusSelector.Deactivate()
  710. return
  711.  
  712. for i in range(0,90*2):
  713. if player.GetItemIndex(i) == SWITCH_VNUM:
  714. net.SendItemUseToItemPacket(i,self.index)
  715. return
  716. # self.nachkauf()
  717.  
  718. def checkSwitch(self):
  719. ok = 0
  720. for i in range(0,5):
  721. if player.GetItemAttribute(self.index, i) != self.values[i]:
  722. ok = 1
  723. self.prob = self.GetProb()
  724. self.StatusText.SetText("Activ (%d%%)" %self.prob)
  725. if ok == 1 or self.prob >= 90:
  726. if self.prob >= 90:
  727. chat.AppendChat(1,"Slot %d: Gata de schimbare" % (self.index+1))
  728. self.bonusSelector.Finish()
  729. return
  730. self.values = [player.GetItemAttribute(self.index, i) for i in range(0,5)]
  731. self.Switch()
  732. elif self.rebuyed > 0:
  733. self.rebuyed = 0
  734. self.Switch()
  735. elif ok == 0 and self.count < 5:
  736. self.count+= 1
  737. elif ok == 0 and self.count >= 5:
  738. self.count = 0
  739. self.Switch()
  740. # elif self.last_switch > -1 and player.GetItemCount(self.last_switch) == 0:
  741. # chat.AppendChat(2,"%d"%player.GetItemCount(self.last_switch))
  742. # self.last_switch = 0
  743. # self.Switch()
  744. # else:
  745. # if self.GetProb() != 100:
  746. # self.Switch()
  747. pass
  748.  
  749. def checkSwitch_rare(self):
  750. ok = 0
  751. for i in range(0,2):
  752. if player.GetItemAttribute(self.index, i+6) != self.values_rare[i]:
  753. ok = 1
  754. self.prob_rare = self.GetProb_rare()
  755. self.StatusText_rare.SetText("Activ (%d%%)" %self.prob_rare)
  756. if ok == 1 or self.prob_rare >= 90:
  757. if self.prob_rare >= 90:
  758. self.bonusSelector.Finish_rare()
  759. chat.AppendChat(1,"Slot %d: 6/7 Gata de schimbare" % (self.index+1))
  760. return
  761. self.values_rare = [player.GetItemAttribute(self.index, i) for i in range(5,7)]
  762. self.Switch_rare()
  763. elif self.rebuyed_rare > 0:
  764. self.rebuyed_rare = 0
  765. self.Switch_rare()
  766. elif ok == 0 and self.count_rare < 5:
  767. self.count_rare+=1
  768. elif ok == 0 and self.count_rare >= 5:
  769. self.count_rare = 0
  770. self.Switch_rare()
  771.  
  772. pass
  773. def UpdateItem(self):
  774. # try:
  775. vnum = player.GetItemIndex(self.index)
  776. if vnum == 0 and self.vnum != 0:
  777. self.resetSwitch()
  778. self.resetSwitch_rare()
  779. self.vnum = 0
  780. self.bonusSelector.Deactivate()
  781. self.bonusSelector.Block()
  782. self.bonusSelector.prepare_propose()
  783. self.ItemIcon.Hide()
  784. if self.parentWindow.parentWindow.gameWindow != None:
  785. self.blockBar.SetSize(1)
  786. return
  787. elif vnum != self.vnum:
  788. self.resetSwitch()
  789. self.resetSwitch_rare()
  790. self.vnum = vnum
  791. self.bonusSelector.Deactivate()
  792. self.bonusSelector.prepare_propose()
  793. item.SelectItem(self.vnum)
  794. if self.parentWindow.parentWindow.gameWindow != None:
  795. (w,h) = item.GetItemSize(1,2,3,4,5,6,7,8,9)
  796. self.blockBar.SetSize(h)
  797.  
  798. if item.GetItemType() != 1 and item.GetItemType() != 2:
  799. self.bonusSelector.Block()
  800. else:
  801. self.bonusSelector.Unblock()
  802.  
  803.  
  804. self.ItemIcon.Show()
  805. self.ItemIcon.LoadImage(item.GetIconImageFileName())
  806. # self.values = [player.GetItemAttribute(self.index, i) for i in range(0,5)]
  807. return
  808. if self.IsActive():
  809. self.checkSwitch()
  810.  
  811. if self.IsActive_rare():
  812. self.checkSwitch_rare()
  813.  
  814. # except:
  815. # pass
  816.  
  817. def SetIndex(self,index):
  818. self.index = index
  819. self.bonusSelector.index = index
  820. self.bonusSelector.Starter.SetText("Schimba ("+str(index+1)+") Start")
  821. self.Update()
  822. self.UpdateItem()
  823.  
  824. def GetProb_rare(self):
  825. values = [player.GetItemAttribute(self.index, i+6) for i in range(0,2)]
  826. val2 = {}
  827. for i in range(0,2):
  828. try:
  829. affectString = AFFECT_DICT[values[i][0]](values[i][1])
  830. val2[values[i][0]] = values[i][1]
  831. self.bonusSelector.ibi[i+6].SetText(affectString)
  832. except:
  833. pass
  834. prob = 0
  835. max = 0
  836.  
  837. yp = self.GenList_rare()
  838. for x in yp:
  839. if yp[x] in val2 and val2[yp[x]] >= int(self.bonusSelector.boni[x+5][3].GetText()):
  840. prob = prob+1
  841. max = max+1
  842. if max > 0:
  843. prozent = 100/max*prob
  844. else:
  845. prozent = 100
  846. return prozent
  847. pass
  848. def GetProb(self):
  849. values = [player.GetItemAttribute(self.index, i) for i in range(0,5)]
  850. val2 = {}
  851. # for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  852. for i in range(0,5):
  853. try:
  854. affectString = AFFECT_DICT[values[i][0]](values[i][1])
  855. val2[values[i][0]] = values[i][1]
  856. self.bonusSelector.ibi[i].SetText(affectString)
  857. except:
  858. pass
  859. prob = 0
  860. max = 0
  861. yp = self.GenList()
  862. for x in yp:
  863. if yp[x] in val2 and val2[yp[x]] >= int(self.bonusSelector.boni[x][3].GetText()):
  864. prob = prob+1
  865. max = max+1
  866. if max > 0:
  867. prozent = 100/max*prob
  868. else:
  869. prozent = 100
  870. return prozent
  871.  
  872. def GenList(self):
  873. ret = {}
  874. for i in range(0,5):
  875. if self.bonusSelector.boni[5-i][1].selected.value != 0:
  876. ret[5-i] = self.bonusSelector.boni[5-i][1].selected.value
  877. return ret
  878. def GenList_rare(self):
  879. ret = {}
  880. for i in range(0,2):
  881. if self.bonusSelector.boni[6+i][1].selected.value != 0:
  882. ret[i+1] = self.bonusSelector.boni[6+i][1].selected.value
  883. return ret
  884.  
  885. def __init__(self,parent):
  886. ui.Window.__init__(self)
  887. self.SetSize(500,36*3+4*2)
  888. self.tabCount = 0
  889. self.tabList = {}
  890.  
  891. self.parentWindow = parent
  892. self.SetParent(parent)
  893. self.plusBar = ui.Bar()
  894. self.plusBar.SetParent(self)
  895. self.plusBar.SetSize(90,30)
  896. self.plusBar.SetWindowVerticalAlignCenter()
  897. self.plusBar.SetColor(COLOR_BG)
  898. # self.plusBar.OnMouseLeftButtonDown = lambda: self.AddTab_pre()
  899. self.plusBar.OnMouseLeftButtonUp = lambda: self.AddTab_pre()
  900. self.OnMouseLeftButtonUp = lambda: self.AddTab_pre()
  901. self.plusBar.SetPosition(30,0)
  902. self.plusBar.Show()
  903.  
  904. self.AddText = ui.TextLine()
  905. self.AddText.SetParent(self.plusBar)
  906. self.AddText.SetText("Trage itemul aici")
  907. self.AddText.SetWindowVerticalAlignCenter()
  908. self.AddText.SetWindowHorizontalAlignCenter()
  909. self.AddText.SetVerticalAlignCenter()
  910. self.AddText.SetHorizontalAlignCenter()
  911. self.AddText.SetPosition(0,0)
  912. self.AddText.Show()
  913.  
  914. dist = [
  915. [500, 0 ], #1
  916. [240, 10 ],
  917. [160, 10 ],
  918. [117, 10.5],
  919. # [ 80, 25 ], #5
  920. [ 92, 10 ], #5
  921. [ 75, 10 ], #6
  922. [ 64, 9 ], #7
  923. [ 56, 7.5], #8
  924. [ 50, 6.5], #9
  925. [ 45, 5.5], #10
  926. ][MAX_NUM-1]
  927. self.ItemTab.width = dist[0]
  928. self.ItemTab.dist = dist[1]
  929.  
  930.  
  931. #For 8
  932. # dist = 9-1.5
  933. # width = 56
  934.  
  935. # For 9
  936. # dist = 9-2.5
  937. # width = 50
  938.  
  939. # For 10
  940. # dist = 9-3.5
  941. # width = 45
  942.  
  943.  
  944. def DeleteTab(self,id):
  945. if self.parentWindow.gameWindow != None:
  946. self.tabList[id].blockBar.Hide()
  947. self.tabList[id].blockBar.Destroy()
  948. self.tabList[id].Destroy()
  949. # del self.tabList[id]
  950. self.tabCount = self.tabCount -1
  951. if self.tabCount > id and id < 5:
  952. for i in xrange(id,self.tabCount):
  953. self.tabList[i] = self.tabList[i+1]
  954. self.tabList[i].tabnum = i
  955. self.tabList[i].SetPosition((self.tabList[i].width+self.tabList[i].dist)*i,0)
  956.  
  957. del self.tabList[self.tabCount]
  958.  
  959. else:
  960. del self.tabList[id]
  961.  
  962.  
  963. if self.tabCount > 0:
  964. self.tabList[0].Select()
  965.  
  966. if (self.ItemTab.width+self.ItemTab.dist)*self.tabCount < 20:
  967. self.parentWindow.SetSize(520,387-210)
  968. self.parentWindow.but_speed.Hide()
  969. self.plusBar.SetPosition(20,0)
  970. else:
  971. (x,y) = self.tabList[self.tabCount-1].GetLocalPosition()
  972. self.plusBar.SetPosition(x+self.ItemTab.width+self.ItemTab.dist,0)
  973. # self.plusBar.SetPosition((self.ItemTab.width+self.ItemTab.dist)*self.tabCount-10,0)
  974. self.plusBar.Show()
  975.  
  976. def AddTab_pre(self):
  977. if mouseModule.mouseController.isAttached():
  978. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  979. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  980. attachedSlotVnum = mouseModule.mouseController.GetAttachedItemIndex()
  981.  
  982. item.SelectItem(attachedSlotVnum)
  983. if item.GetItemType() != 1 and item.GetItemType() != 2:
  984. mouseModule.mouseController.DeattachObject()
  985. chat.AppendChat(2,"Nu poti schimba pe acest item")
  986. return
  987.  
  988. for a in self.tabList:
  989. if self.tabList[a].index == attachedSlotPos:
  990. mouseModule.mouseController.DeattachObject()
  991. chat.AppendChat(2,"Acest slot este deja ocupat.")
  992. return
  993.  
  994.  
  995. if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  996. self.AddTab(attachedSlotPos,attachedSlotVnum)
  997. chat.AppendChat(2,"Item adaugat")
  998.  
  999. mouseModule.mouseController.DeattachObject()
  1000.  
  1001. def AddTab(self,id,vnum = 0):
  1002. if self.tabCount < MAX_NUM:
  1003. self.tabList[self.tabCount] = self.ItemTab(self,self.tabCount,id,vnum)
  1004.  
  1005. self.tabList[self.tabCount].Select()
  1006. self.tabList[self.tabCount].Show()
  1007. self.tabCount+= 1
  1008. if (self.ItemTab.width+self.ItemTab.dist)*self.tabCount < 20:
  1009. self.plusBar.SetPosition(20,0)
  1010. else:
  1011. (x,y) = self.tabList[self.tabCount-1].GetLocalPosition()
  1012. self.plusBar.SetPosition(x+self.ItemTab.width+self.ItemTab.dist,0)
  1013.  
  1014. if self.tabCount == MAX_NUM:
  1015. self.plusBar.Hide()
  1016.  
  1017. self.parentWindow.SetSize(520,387+10)
  1018. self.parentWindow.but_speed.Show()
  1019. # return 0
  1020.  
  1021. class Bot(ui.BoardWithTitleBar):
  1022. class PinGroup(ui.Bar):
  1023. def OnUpdate(self):
  1024. ## Now check position.
  1025. (x,y) = self.GetGlobalPosition()
  1026. max_x = wndMgr.GetScreenWidth()-self.GetWidth()
  1027. max_y = wndMgr.GetScreenHeight()-self.GetHeight()-DISTANCE_BOTTOM
  1028. if not x == self.pos_x or not y == self.pos_y:
  1029. old_dir = self.dir
  1030. if self.pos_x == 0 and not self.pos_y == 0 and not self.pos_y == max_y and old_dir != 1:
  1031. self.parse_dir(1)
  1032. elif self.pos_x == max_x and not self.pos_y == 0 and not self.pos_y == max_y and old_dir != 2:
  1033. self.parse_dir(2)
  1034. elif self.pos_y == max_y and not self.pos_x == 0 and not self.pos_x == max_x and old_dir != 4:
  1035. self.parse_dir(4)
  1036. elif self.pos_y == 0 and not self.pos_x == 0 and not self.pos_x == max_x and old_dir != 3:
  1037. self.parse_dir(3)
  1038.  
  1039. max_x = wndMgr.GetScreenWidth()-self.GetWidth()
  1040. max_y = wndMgr.GetScreenHeight()-self.GetHeight()-DISTANCE_BOTTOM
  1041.  
  1042.  
  1043. if self.pos_x == 0 and not self.pos_y == 0 and not self.pos_y == max_y:
  1044. x = 0
  1045. elif self.pos_x == max_x and not self.pos_y == 0 and not self.pos_y == max_y:
  1046. x = max_x
  1047. elif self.pos_y == 0 and not self.pos_x == 0 and not self.pos_x == max_x:
  1048. y = 0
  1049. elif self.pos_y == max_y and not self.pos_x == 0 and not self.pos_x == max_x:
  1050. y = max_y
  1051. if x > 0 and x < max_x and y > 0 and y < max_y:
  1052. if y < int(max_y/2):
  1053. y = 0
  1054. else:
  1055. y = max_y
  1056.  
  1057. if x < int(max_x/2):
  1058. x = 0
  1059. else:
  1060. x = max_x
  1061.  
  1062.  
  1063. x = min(max(0,x),wndMgr.GetScreenWidth()-self.GetWidth())
  1064. y = min(max(0,y),wndMgr.GetScreenHeight()-self.GetHeight()-DISTANCE_BOTTOM)
  1065. self.SetPosition(x,y)
  1066. self.pos_x = x
  1067. self.pos_y = y
  1068. # (self.pos_x,self.pos_y) = self.GetGlobalPosition()
  1069. self.parent.OnUpdate()
  1070. for c in self.txtlist:
  1071. c.SetColor(c.item.StatusBar.color)
  1072. c.txt2.SetText("Status: %s" % c.item.StatusText.GetText())
  1073. try:
  1074. c.listWin2.SetColor(c.item.StatusBar_rare.color)
  1075. c.txt3.SetText("Status: %s" % c.item.StatusText_rare.GetText())
  1076. except:
  1077. pass
  1078.  
  1079. def ShowMainWindow(self):
  1080. (x,y) = self.parent.GetGlobalPosition()
  1081. x = min(max(32,x),wndMgr.GetScreenWidth()-self.parent.GetWidth()-32)
  1082. y = min(max(32,y),wndMgr.GetScreenHeight()-self.parent.GetHeight()-DISTANCE_BOTTOM-32)
  1083. self.parent.SetPosition(x,y)
  1084. self.parent.Show()
  1085. self.__del__()
  1086. def parse_dir(self,dir):
  1087. self.dir = dir
  1088. w,h = 100,50
  1089. for listWin in self.txtlist:
  1090. itm = listWin.item
  1091. listWin.AddFlag("not_pick")
  1092. if dir >= 3:
  1093. listWin.SetPosition(w,4)
  1094. listWin.SetSize(90,h-8)
  1095. w+=92
  1096. if itm.bonusSelector.EnableRareBoni.checked == 1:
  1097. w+=15
  1098. listWin.SetSize(105,4+12+12)
  1099. listWin.listWin2.SetSize(105,14)
  1100. listWin.listWin2.Show()
  1101. listWin.txt3.Show()
  1102. else:
  1103. listWin.SetPosition(0,h)
  1104. listWin.SetSize(w,4+12+12+2)
  1105.  
  1106. if itm.bonusSelector.EnableRareBoni.checked == 1:
  1107. listWin.SetSize(w,4+12+12)
  1108. listWin.listWin2.SetSize(w,14)
  1109. listWin.listWin2.Show()
  1110. listWin.txt3.Show()
  1111. # itl.append(txt3)
  1112. h+=12
  1113. pass
  1114. h+=4+12+12+4
  1115. self.SetSize(w,h)
  1116.  
  1117. def __init__(self,parent,dir = 1):
  1118. self.parent = parent
  1119. self.dir = dir
  1120. ui.Bar.__init__(self)
  1121. # Direction: 1 = left; 2 = right; 3 = top
  1122. self.SetColor(COLOR_BG)
  1123. w,h = 100,50
  1124.  
  1125. self.AddFlag("float")
  1126. self.AddFlag("movable")
  1127.  
  1128. constInfo.SWITCHBOT = 1
  1129.  
  1130.  
  1131.  
  1132. self.maximise_but = ui.Button()
  1133. self.maximise_but.SetParent(self)
  1134. self.maximise_but.SetPosition(4,4)
  1135. self.maximise_but.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
  1136. self.maximise_but.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
  1137. self.maximise_but.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
  1138. self.maximise_but.SetText("Marire")
  1139. self.maximise_but.SetEvent(self.ShowMainWindow)
  1140. self.maximise_but.Show()
  1141.  
  1142. self.stop_but = ui.Button()
  1143. self.stop_but.SetParent(self)
  1144. self.stop_but.SetPosition(4,24)
  1145. self.stop_but.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
  1146. self.stop_but.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
  1147. self.stop_but.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
  1148. self.stop_but.SetText("Dezactivati")
  1149. self.stop_but.SetEvent(self.parent.deactivate_all)
  1150. self.stop_but.Show()
  1151.  
  1152. self.txtlist = []
  1153. for a in self.parent.itemTabBar.tabList:
  1154. itm = self.parent.itemTabBar.tabList[a]
  1155.  
  1156. listWin = ui.Bar()
  1157. listWin.item = itm
  1158. self.txtlist.append(listWin)
  1159. listWin.SetColor(itm.StatusBar.color)
  1160. listWin.SetParent(self)
  1161. listWin.AddFlag("not_pick")
  1162. listWin.Show()
  1163.  
  1164. listWin.txt1 = ui.TextLine()
  1165. listWin.txt1.SetParent(listWin)
  1166. listWin.txt1.SetText("Slot %d:" %(itm.index+1))
  1167. listWin.txt1.Show()
  1168. listWin.txt1.SetPosition(4,2)
  1169.  
  1170. listWin.txt2 = ui.TextLine()
  1171. listWin.txt2.SetParent(listWin)
  1172. listWin.txt2.SetText("Status: %s" % itm.StatusText.GetText())
  1173. listWin.txt2.SetPosition(4,2+12)
  1174. listWin.txt2.Show()
  1175.  
  1176. listWin.listWin2 = ui.Bar()
  1177. listWin.listWin2.AddFlag("not_pick")
  1178. listWin.listWin2.SetColor(itm.StatusBar_rare.color)
  1179. listWin.listWin2.SetParent(listWin)
  1180. listWin.listWin2.SetPosition(0,4+12+12)
  1181. listWin.listWin2.SetSize(w,12+2)
  1182. listWin.listWin2.Hide()
  1183.  
  1184. listWin.txt3 = ui.TextLine()
  1185. listWin.txt3.SetParent(listWin.listWin2)
  1186. listWin.txt3.SetText("Status: %s" % itm.StatusText_rare.GetText())
  1187. listWin.txt3.SetPosition(4,0)
  1188. listWin.txt3.Hide()
  1189.  
  1190. if dir >= 3:
  1191. listWin.SetPosition(w,4)
  1192. listWin.SetSize(90,h-8)
  1193. w+=92
  1194. if itm.bonusSelector.EnableRareBoni.checked == 1:
  1195. w+=15
  1196. listWin.SetSize(105,4+12+12)
  1197. listWin.listWin2.SetSize(105,14)
  1198. listWin.listWin2.Show()
  1199. listWin.txt3.Show()
  1200. else:
  1201. listWin.SetPosition(0,h)
  1202. listWin.SetSize(w,4+12+12+2)
  1203.  
  1204. if itm.bonusSelector.EnableRareBoni.checked == 1:
  1205. listWin.SetSize(w,4+12+12)
  1206. listWin.listWin2.Show()
  1207. listWin.txt3.Show()
  1208. # itl.append(txt3)
  1209. h+=12
  1210. pass
  1211.  
  1212. h+=4+12+12+4
  1213. # else:
  1214.  
  1215. # self.txtlist.append(itl)
  1216.  
  1217. self.SetSize(w,h)
  1218. (x,y) = self.parent.GetGlobalPosition()
  1219.  
  1220. x = min(max(0,x),wndMgr.GetScreenWidth()-self.GetWidth())
  1221. y = min(max(0,y),wndMgr.GetScreenHeight()-self.GetHeight()-DISTANCE_BOTTOM)
  1222. if dir == 1:
  1223. # self.SetWindowHorizontalAlignLeft()
  1224. self.SetPosition(0,y)
  1225. elif dir == 2:
  1226. # self.SetWindowHorizontalAlignRight()
  1227. self.SetPosition(wndMgr.GetScreenWidth()-self.GetWidth(),y)
  1228. elif dir == 3:
  1229. # self.SetWindowVerticalAlignTop()
  1230. self.SetPosition(x,0)
  1231. else:
  1232. # self.SetWindowVerticalAlignBottom()
  1233. self.SetPosition(x,wndMgr.GetScreenHeight()-(DISTANCE_BOTTOM+h))
  1234.  
  1235. (self.pos_x,self.pos_y) = self.GetGlobalPosition()
  1236.  
  1237. self.parse_dir(dir)
  1238. # if dir == 1:
  1239. # self.SetWindowHorizontalAlignLeft()
  1240. # self.SetPosition(0,0)
  1241. # elif dir == 2:
  1242. # self.SetWindowHorizontalAlignRight()
  1243. # self.SetPosition(self.GetWidth(),0)
  1244. # elif dir == 3:
  1245. # self.SetWindowHorizontalAlignCenter()
  1246. # self.SetPosition(0,0)
  1247. # elif dir == 4:
  1248. # self.SetWindowHorizontalAlignCenter()
  1249. # self.SetPosition(0,36+h)
  1250. # else:
  1251. # return # ERR
  1252.  
  1253.  
  1254.  
  1255. pinhint = 0
  1256. def ShowPinHint(self,type):
  1257. self.pinhint = type
  1258. if type == 0:
  1259. self.PinHint.Hide()
  1260. return
  1261. # type=2
  1262.  
  1263. (x,y) = self.GetGlobalPosition()
  1264. if type == 1: # Left
  1265. self.PinHint.SetWindowHorizontalAlignLeft()
  1266. self.PinHint.SetWindowVerticalAlignCenter()
  1267. self.PinHint.SetSize(max(min(30,30-x),3),wndMgr.GetScreenHeight())
  1268. self.PinHint.SetPosition(0,0)
  1269. elif type == 2: # Right
  1270. self.PinHint.SetWindowHorizontalAlignRight()
  1271. self.PinHint.SetWindowVerticalAlignCenter()
  1272. self.PinHint.SetSize(30,wndMgr.GetScreenHeight())
  1273. self.PinHint.SetPosition(max(min(30,30-(wndMgr.GetScreenWidth()-(x+self.GetWidth()))),3),0)
  1274. elif type == 3: # Top
  1275. self.PinHint.SetWindowHorizontalAlignCenter()
  1276. self.PinHint.SetWindowVerticalAlignTop()
  1277. self.PinHint.SetSize(wndMgr.GetScreenWidth(),max(min(30,30-y),3))
  1278. self.PinHint.SetPosition(0,0)
  1279. elif type == 4: # Top
  1280. self.PinHint.SetWindowHorizontalAlignCenter()
  1281. self.PinHint.SetWindowVerticalAlignBottom()
  1282. self.PinHint.SetSize(wndMgr.GetScreenWidth(),30)
  1283. self.PinHint.SetPosition(0,36+max(min(30,30-(wndMgr.GetScreenHeight()-36-(y+self.GetHeight()))),3))
  1284. self.PinHint.Show()
  1285. # else:
  1286.  
  1287.  
  1288. def __init__(self):
  1289. ui.BoardWithTitleBar.__init__(self)
  1290. self.gameWindow = None
  1291.  
  1292. self.SetTitleName("|cFFFFFF00|h Schimbator de bonusuri")
  1293. self.AddFlag("float")
  1294. self.AddFlag("movable")
  1295. self.SetPosition(30,30)
  1296. # self.SetSize(520,387)
  1297. # self.SetSize(520,387-210)
  1298. self.SetSize(520,387-210)
  1299.  
  1300. self.PinHint = ui.Bar()
  1301. self.PinHint.SetColor(COLOR_PIN_HINT)
  1302. self.PinHint.Show()
  1303.  
  1304. self.OnMouseLeftButtonDown = self.drag_start
  1305. self.OnMouseLeftButtonUp = self.drag_end
  1306.  
  1307. self.titleBar.MinimizeBut = ui.Button()
  1308. self.titleBar.MinimizeBut.SetParent(self.titleBar)
  1309. self.titleBar.MinimizeBut.SetUpVisual("d:/ymir work/ui/public/minimize_button_01.sub")
  1310. self.titleBar.MinimizeBut.SetOverVisual("d:/ymir work/ui/public/minimize_button_02.sub")
  1311. self.titleBar.MinimizeBut.SetDownVisual("d:/ymir work/ui/public/minimize_button_03.sub")
  1312. self.titleBar.MinimizeBut.SetToolTipText("Minimize", 0, -23)
  1313. self.titleBar.MinimizeBut.SetPosition(520 - self.titleBar.btnClose.GetWidth()-3- 32 - 3, 3)
  1314. self.titleBar.MinimizeBut.SetEvent(lambda: self.PinShow(1))
  1315. self.titleBar.MinimizeBut.Show()
  1316.  
  1317. self.titleBar.HelpBut = ui.ToggleButton()
  1318. self.titleBar.HelpBut.SetParent(self.titleBar)
  1319. self.titleBar.HelpBut.SetUpVisual("d:/ymir work/ui/public/small_button_01.sub")
  1320. self.titleBar.HelpBut.SetOverVisual("d:/ymir work/ui/public/small_button_02.sub")
  1321. self.titleBar.HelpBut.SetDownVisual("d:/ymir work/ui/public/small_button_03.sub")
  1322. self.titleBar.HelpBut.SetToolTipText("Ajutor", 0, -23)
  1323. self.titleBar.HelpBut.SetText("Ajutor")
  1324. self.titleBar.HelpBut.SetPosition(3, 0)
  1325. self.titleBar.HelpBut.SetToggleDownEvent(lambda: self.ToggleHelp(1))
  1326. self.titleBar.HelpBut.SetToggleUpEvent(lambda: self.ToggleHelp(0))
  1327. self.titleBar.HelpBut.Show()
  1328.  
  1329.  
  1330. self.but_deactivate_all = ui.Button()
  1331. # self.but_deactivate_all.SetParent(self)
  1332. self.but_deactivate_all.SetParent(self.titleBar)
  1333. # self.but_deactivate_all.SetPosition(415,350)
  1334. self.but_deactivate_all.SetPosition(3+5+self.titleBar.HelpBut.GetWidth(), 0)
  1335. self.but_deactivate_all.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
  1336. self.but_deactivate_all.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
  1337. self.but_deactivate_all.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
  1338. self.but_deactivate_all.SetText("Opriti toate")
  1339. self.but_deactivate_all.SetEvent(self.deactivate_all)
  1340. self.but_deactivate_all.Show()
  1341.  
  1342. self.titleBar.but_deactivate_all = ui.Button()
  1343. self.titleBar.but_deactivate_all.SetParent(self.titleBar)
  1344. self.titleBar.but_deactivate_all.SetPosition(3+5+self.titleBar.HelpBut.GetWidth()+5+self.but_deactivate_all.GetWidth(), 0)
  1345. self.titleBar.but_deactivate_all.SetUpVisual("d:/ymir work/ui/public/small_button_01.sub")
  1346. self.titleBar.but_deactivate_all.SetOverVisual("d:/ymir work/ui/public/small_button_02.sub")
  1347. self.titleBar.but_deactivate_all.SetDownVisual("d:/ymir work/ui/public/small_button_03.sub")
  1348. self.titleBar.but_deactivate_all.SetText("Info")
  1349. self.titleBar.but_deactivate_all.SetEvent(self.about)
  1350. self.titleBar.but_deactivate_all.Show()
  1351. self.titleName.SetPosition(60, 4)
  1352.  
  1353. self.enable_rebuy = CheckBox("Cumpara automat")
  1354. self.enable_rebuy.Toggle()
  1355. self.enable_rebuy.Hide()
  1356.  
  1357. self.but_speed = ui.SliderBar()
  1358. self.but_speed.SetParent(self)
  1359. self.but_speed.SetWindowHorizontalAlignCenter()
  1360. self.but_speed.SetPosition(0,360)
  1361. self.but_speed.SetSliderPos(0.0)
  1362. # self.but_speed.SetToolTipText("Switch-Geschwindigkeit", 0, -23)
  1363. # self.but_speed.Show()
  1364. self.but_speed.Hide()
  1365.  
  1366. self.itemTabBar = ItemTabBar(self)
  1367. self.itemTabBar.SetPosition(10,35)
  1368. self.itemTabBar.Show()
  1369.  
  1370.  
  1371. self.buyed = 0
  1372. self.buyed_rare = 0
  1373.  
  1374. self.SetCloseEvent(self._Hide)
  1375.  
  1376. self.Hide = self._Hide
  1377.  
  1378.  
  1379. ### NOW initialize the HELP stuff!
  1380.  
  1381. self.help_add_item = HelpBar(0.8,'Pune un item aici.')
  1382. self.help_add_item.SetParent(self)
  1383. self.help_add_item.SetPosition(60,50)
  1384.  
  1385. self.help_minimize = HelpBar(0.8,'Trageti spre margine pentru a micsora!',1)
  1386. self.help_minimize.SetParent(self.titleBar)
  1387. self.help_minimize.SetWindowHorizontalAlignCenter()
  1388. self.help_minimize.SetPosition(100,-30)
  1389.  
  1390. self.help_show_rare = HelpBar(0.85,'De aici puteti activa 6/7.')
  1391. self.help_show_rare.SetParent(self)
  1392. # self.help_show_rare.SetPosition(35,312)
  1393.  
  1394. self.help_rebuy = HelpBar(0.5,'Daca cumpar mai multe bonusuri')
  1395. self.help_rebuy.SetParent(self)
  1396. # self.help_rebuy.SetPosition(25,297)
  1397.  
  1398. self.help_stop_all = HelpBar(0.8,'Opriti toate procesele',1)
  1399. self.help_stop_all.SetParent(self.titleBar)
  1400. self.help_stop_all.SetPosition(3+5+self.titleBar.HelpBut.GetWidth()*1.2,-30)
  1401.  
  1402. self.help_duration = HelpBar(0.8,'Incetineste procesele.',1)
  1403. self.help_duration.SetParent(self)
  1404.  
  1405.  
  1406. def ToggleHelp(self,val):
  1407. self.help_on = val
  1408.  
  1409. def Show(self):
  1410. ui.BoardWithTitleBar.Show(self)
  1411. self.bot_shown = 1
  1412.  
  1413. def _Hide(self):
  1414. ## ONLY FOR TESTING
  1415. # for a in range(0,self.itemTabBar.tabCount):
  1416. # self.itemTabBar.DeleteTab(0)
  1417.  
  1418. ui.BoardWithTitleBar.Hide(self)
  1419. self.bot_shown = 0
  1420. constInfo.SWITCHBOT = 0
  1421.  
  1422.  
  1423. def deactivate_all(self):
  1424. for a in self.itemTabBar.tabList:
  1425. self.itemTabBar.tabList[a].bonusSelector.Starter.SetUp()
  1426. self.itemTabBar.tabList[a].bonusSelector.Starter.OnToggleUp()
  1427. self.itemTabBar.tabList[a].bonusSelector.Starter_rare_boni.SetUp()
  1428. self.itemTabBar.tabList[a].bonusSelector.Starter_rare_boni.OnToggleUp()
  1429. pass
  1430.  
  1431. drag = 0
  1432. def drag_start(self):
  1433. self.drag = 1
  1434.  
  1435. def drag_end(self):
  1436. self.drag = 0
  1437. if self.pinhint > 0:
  1438. self.PinShow(self.pinhint)
  1439. # self.PinGroupBox = self.PinGroup()
  1440. pass
  1441. self.ShowPinHint(0)
  1442.  
  1443. def PinShow(self,dir):
  1444. self.PinGroupBox = self.PinGroup(self,dir)
  1445. self.Hide()
  1446. self.PinGroupBox.Show()
  1447.  
  1448. def EnableInventoryTweak(self,gameWindow):
  1449. self.gameWindow=gameWindow
  1450. self.gameWindow.interface.wndInventory.inventoryTab[0].SetEvent(lambda arg=0: self.__SetInventoryPage(arg))
  1451. self.gameWindow.interface.wndInventory.inventoryTab[1].SetEvent(lambda arg=1: self.__SetInventoryPage(arg))
  1452.  
  1453. def __SetInventoryPage(self,arg):
  1454. self.gameWindow.interface.wndInventory.SetInventoryPage(arg)
  1455. for a in self.itemTabBar.tabList:
  1456. itm = self.itemTabBar.tabList[a]
  1457. if itm.index >= arg*45 and itm.index < (arg+1)*45:
  1458. itm.blockBar.Show()
  1459. else:
  1460. itm.blockBar.Hide()
  1461. help_on = 0
  1462. counter = 0
  1463. AboutWindow = None
  1464. def OnUpdate(self):
  1465. if self.AboutWindow:
  1466. if self.AboutWindow.x_counter > 1:
  1467. self.AboutWindow.x_counter -=1
  1468. self.AboutWindow.text6.SetText("Timp: %0.1f" % (self.AboutWindow.x_counter/45.0))
  1469. elif self.AboutWindow.x_counter == 1:
  1470. self.AboutWindow.Hide()
  1471. # self.AboutWindow.Delete()
  1472.  
  1473. if self.help_on == 1:
  1474. (x,y) = self.itemTabBar.plusBar.GetLocalPosition()
  1475. self.help_add_item.SetPosition(x+20,50)
  1476. self.help_add_item.Show()
  1477. self.help_stop_all.Show()
  1478.  
  1479. self.help_minimize.Show()
  1480. if self.itemTabBar.tabCount > 0:
  1481. self.help_show_rare.SetPosition(25,164)
  1482. self.help_show_rare.Show()
  1483. self.help_rebuy.SetPosition(15,147)
  1484. self.help_rebuy.Show()
  1485.  
  1486. # self.help_duration.SetPosition(300,180)
  1487. self.help_duration.SetPosition(190-5.5+self.but_speed.GetSliderPos()*int(35.5+self.but_speed.GetWidth()/2),180)
  1488. self.help_duration.Show()
  1489.  
  1490. else:
  1491. self.help_show_rare.Hide()
  1492. self.help_rebuy.Hide()
  1493. self.help_duration.Hide()
  1494.  
  1495. else:
  1496. self.help_add_item.Hide()
  1497. self.help_minimize.Hide()
  1498. self.help_show_rare.Hide()
  1499. self.help_rebuy.Hide()
  1500. self.help_stop_all.Hide()
  1501. self.help_duration.Hide()
  1502.  
  1503. if self.drag == 1:
  1504. (x1, y1) = self.GetGlobalPosition()
  1505. # if x1 < 0:
  1506. # x1 = 0
  1507. # elif x1 > wndMgr.GetScreenWidth()-520:
  1508. # x1 = wndMgr.GetScreenWidth()-520
  1509. # if y1 < 0:
  1510. # y1 = 0
  1511. # elif y1 > wndMgr.GetScreenHeight()-36-self.GetHeight():
  1512. # y1 = wndMgr.GetScreenHeight()-36-self.GetHeight()
  1513. x1 = max(min(wndMgr.GetScreenWidth()-520,x1),0)
  1514. y1 = max(min(wndMgr.GetScreenHeight()-36-self.GetHeight(),y1),0)
  1515. self.SetPosition(x1,y1)
  1516. if x1 < 30:
  1517. self.ShowPinHint(1)
  1518. elif wndMgr.GetScreenWidth()-x1-520 < 30:
  1519. self.ShowPinHint(2)
  1520. elif y1 < 30:
  1521. self.ShowPinHint(3)
  1522. elif wndMgr.GetScreenHeight()-y1-self.GetHeight() < 60:
  1523. self.ShowPinHint(4)
  1524. else:
  1525. self.ShowPinHint(0)
  1526. # self.SetPosition(x1+(x-self.drag_pos[0]),y1)
  1527. pass
  1528.  
  1529. if self.gameWindow != None:
  1530. for a in self.itemTabBar.tabList:
  1531. itm = self.itemTabBar.tabList[a]
  1532.  
  1533.  
  1534.  
  1535. self.counter+=1
  1536. if self.counter >= int(self.but_speed.GetSliderPos()*MAX_SWITCH_DELAY_APPEND+MIN_SWITCH_DELAY):
  1537. self.buyed = 0
  1538. self.buyed_rare = 0
  1539. self.counter = 0
  1540. for a in self.itemTabBar.tabList:
  1541. itm = self.itemTabBar.tabList[a]
  1542. itm.UpdateItem()
  1543. # if itm.
  1544.  
  1545.  
  1546. def about(self):
  1547. self.AboutWindow = ui.ThinBoard()
  1548. self.AboutWindow.SetParent(self)
  1549. self.AboutWindow.SetSize(250,100)
  1550. self.AboutWindow.SetWindowHorizontalAlignCenter()
  1551. self.AboutWindow.SetWindowVerticalAlignCenter()
  1552. self.AboutWindow.SetPosition(0,0)
  1553. self.AboutWindow.Show()
  1554. self.AboutWindow.x_counter = 450
  1555.  
  1556. self.AboutWindow.text1 = ui.TextLine()
  1557. self.AboutWindow.text1.SetParent(self.AboutWindow)
  1558. self.AboutWindow.text1.SetWindowHorizontalAlignCenter()
  1559. self.AboutWindow.text1.SetHorizontalAlignCenter()
  1560. self.AboutWindow.text1.SetPosition(0,5)
  1561. self.AboutWindow.text1.SetText("Schimbator de bonusuri")
  1562. self.AboutWindow.text1.SetPackedFontColor(ui.GenerateColor(58, 141, 221))
  1563. self.AboutWindow.text1.Show()
  1564.  
  1565. self.AboutWindow.text2 = ui.TextLine()
  1566. self.AboutWindow.text2.SetParent(self.AboutWindow)
  1567. self.AboutWindow.text2.SetPosition(8,18)
  1568. self.AboutWindow.text2.SetText("Metin2 New")
  1569. self.AboutWindow.text2.Show()
  1570.  
  1571. self.AboutWindow.text3 = ui.TextLine()
  1572. self.AboutWindow.text3.SetParent(self.AboutWindow)
  1573. self.AboutWindow.text3.SetPosition(8,18+13)
  1574. self.AboutWindow.text3.SetText("Ideile noi sunt mereu bine venite!")
  1575. self.AboutWindow.text3.Show()
  1576.  
  1577. self.AboutWindow.text4 = ui.TextLine()
  1578. self.AboutWindow.text4.SetParent(self.AboutWindow)
  1579. self.AboutWindow.text4.SetPosition(8,18+13*3)
  1580. self.AboutWindow.text4.SetText("Te asteptam pe forumul nostru")
  1581. self.AboutWindow.text4.Show()
  1582.  
  1583. self.AboutWindow.text5 = ui.TextLine()
  1584. self.AboutWindow.text5.SetParent(self.AboutWindow)
  1585. self.AboutWindow.text5.SetPosition(8,18+13*4)
  1586. self.AboutWindow.text5.SetText("pentru a-ti exprima opinia.")
  1587. self.AboutWindow.text5.Show()
  1588. self.AboutWindow.text6 = ui.TextLine()
  1589. self.AboutWindow.text6.SetParent(self.AboutWindow)
  1590. self.AboutWindow.text6.SetPosition(200,18+13*5)
  1591. self.AboutWindow.text6.SetText("Timp: %d" % self.AboutWindow.x_counter)
  1592. self.AboutWindow.text6.Show()
  1593.  
  1594.  
  1595.  
  1596.  
  1597. class HelpBar(ui.Window):
  1598. def __init__(self,width,text,centered = 0):
  1599. ui.Window.__init__(self)
  1600. self.AddFlag("not_pick")
  1601. self.AddFlag("attach")
  1602.  
  1603. img = ui.ExpandedImageBox()
  1604.  
  1605. img.SetParent(self)
  1606. img.LoadImage("d:/ymir work/ui/pattern/help_stick.tga")
  1607. img.SetRenderingRect(0.0, -width, 0.0, 0.0)
  1608. img.Show()
  1609.  
  1610. self.img = img
  1611.  
  1612. txt = ui.TextLine()
  1613.  
  1614. txt=ui.TextLine()
  1615. txt.SetParent(self)
  1616. txt.SetText(text)
  1617. txt.Show()
  1618.  
  1619. img.SetPosition(0,18-width*img.GetHeight())
  1620. txt.SetPosition(0,0)
  1621. txt.SetWindowHorizontalAlignCenter()
  1622. if centered != 0:
  1623. txt.SetHorizontalAlignCenter()
  1624. # txt.SetPosition(0,0)
  1625.  
  1626. self.txt = txt
  1627.  
  1628. class DropDown(ui.Window):
  1629. dropped = 0
  1630. dropstat = 0
  1631. last = 0
  1632. lastS = 0
  1633. maxh = 95
  1634. OnChange = None
  1635. class Item(ui.ListBoxEx.Item):
  1636. def __init__(self,parent, text,value=0):
  1637. ui.ListBoxEx.Item.__init__(self)
  1638.  
  1639. self.textBox=ui.TextLine()
  1640. self.textBox.SetParent(self)
  1641. self.textBox.SetText(text)
  1642. # self.textBox.SetLimitWidth(parent.GetWidth()-132)
  1643. self.textBox.Show()
  1644. self.value = value
  1645. def GetValue(self):
  1646. return self.value
  1647. def __del__(self):
  1648. ui.ListBoxEx.Item.__del__(self)
  1649.  
  1650. def __init__(self,parent,tt = "",down=1):
  1651. ui.Window.__init__(self,"TOP_MOST")
  1652. self.down = down
  1653. self.SetParentProxy(parent)
  1654. self.bg = ui.Bar("TOP_MOST")
  1655. self.bg.SetParent(self)
  1656. self.bg.SetPosition(0,0)
  1657. self.bg.SetColor(0xc0000000)
  1658. self.bg.OnMouseOverIn = self.bgMouseIn
  1659. self.bg.OnMouseOverOut = self.bgMouseOut
  1660. self.bg.OnMouseLeftButtonDown = self.ExpandMe
  1661. self.bg.Show()
  1662. self.act = ui.TextLine()
  1663. self.act.SetParent(self.bg)
  1664. self.act.SetPosition(4,2)
  1665. self.act.SetText(tt)
  1666. self.act.Show()
  1667. self.GetText = self.act.GetText
  1668.  
  1669. self.Drop = ui.Bar("TOP_MOST")
  1670. self.Drop.SetParent(self.GetParentProxy())
  1671. self.Drop.SetPosition(0,21)
  1672. # self.Drop.SetSize(150,95)
  1673. self.Drop.SetSize(150,0)
  1674. # self.Drop.SetColor(0xc00a0a0a)
  1675. self.Drop.SetColor(0xff0a0a0a)
  1676.  
  1677.  
  1678. self.ScrollBar = ui.ThinScrollBar()
  1679. self.ScrollBar.SetParent(self.Drop)
  1680. self.ScrollBar.SetPosition(132,0)
  1681. # self.ScrollBar.SetScrollBarSize(95)
  1682. self.ScrollBar.SetScrollBarSize(0)
  1683. # self.ScrollBar.Show()
  1684.  
  1685. self.DropList = ui.ListBoxEx()
  1686. self.DropList.SetParent(self.Drop)
  1687. self.DropList.itemHeight = 12
  1688. self.DropList.itemStep = 13
  1689. self.DropList.SetPosition(0,0)
  1690. # self.DropList.SetSize(132,self.maxh)
  1691. self.DropList.SetSize(132,13)
  1692. self.DropList.SetScrollBar(self.ScrollBar)
  1693. self.DropList.SetSelectEvent(self.SetTitle)
  1694. self.DropList.SetViewItemCount(0)
  1695. self.DropList.Show()
  1696. if tt != "":
  1697. self.AppendItemAndSelect(tt)
  1698. self.selected = self.DropList.GetSelectedItem()
  1699.  
  1700.  
  1701. self.SetSize(120,20)
  1702. def __del__(self):
  1703. ui.Window.__del__(self)
  1704. c = 1
  1705. def AppendItem(self,text,value=0):
  1706. self.c+=1
  1707. self.DropList.AppendItem(self.Item(self,text,value))
  1708. self.maxh = min(95,13*self.c)
  1709. if self.c > 7:
  1710. self.ScrollBar.Show()
  1711.  
  1712.  
  1713. def AppendItemAndSelect(self,text,value=0):
  1714. self.DropList.AppendItem(self.Item(self,text,value))
  1715. self.DropList.SelectIndex(len(self.DropList.itemList)-1)
  1716.  
  1717. def SelectByAffectId(self,id):
  1718. for x in self.DropList.itemList:
  1719. if x.value == id:
  1720. self.DropList.SelectItem(x)
  1721. break
  1722.  
  1723. def SetTitle(self,item):
  1724. self.act.SetText(str(item.textBox.GetText()))
  1725. self.last = self.DropList.basePos
  1726. self.lastS = self.ScrollBar.GetPos()
  1727. self.dropped = 0
  1728. self.selected = item
  1729. if self.OnChange:
  1730. self.OnChange()
  1731. # self.Drop.Hide()
  1732.  
  1733. def SetPosition(self,w,h):
  1734. ui.Window.SetPosition(self,w,h)
  1735. if self.down == 1:
  1736. self.Drop.SetPosition(w,h+21)
  1737. else:
  1738. self.Drop.SetPosition(w,h-self.Drop.GetHeight())
  1739.  
  1740. def SetSize(self,w,h):
  1741. ui.Window.SetSize(self,w,h)
  1742. self.bg.SetSize(w,h)
  1743. self.Drop.SetSize(w,0)
  1744. self.DropList.SetSize(w-18,self.maxh)
  1745. for x in self.DropList.itemList:
  1746. x.SetSize(w-18,12)
  1747. self.ScrollBar.SetPosition(w-18,0)
  1748.  
  1749.  
  1750. def ExpandMe(self):
  1751. if self.dropped == 1:
  1752. # self.Drop.Hide()
  1753. self.dropped = 0
  1754. else:
  1755. # self.Drop.Show()
  1756. self.dropped = 1
  1757.  
  1758. def OnUpdate(self):
  1759. iter = 6
  1760. if self.Drop.GetHeight() < 50:
  1761. self.ScrollBar.Hide()
  1762. else:
  1763. self.ScrollBar.Show()
  1764.  
  1765. if self.dropped == 0 and self.dropstat == 1:
  1766. if self.Drop.GetHeight() <=0:
  1767. self.dropstat = 0
  1768. self.Drop.SetSize(self.Drop.GetWidth(),0)
  1769. self.ScrollBar.SetScrollBarSize(self.Drop.GetHeight())
  1770. self.Drop.Hide()
  1771. else:
  1772. if self.Drop.GetHeight()-iter < 0:
  1773. self.Drop.SetSize(self.Drop.GetWidth(),0)
  1774. else:
  1775. self.Drop.SetSize(self.Drop.GetWidth(),self.Drop.GetHeight()-iter)
  1776. (w,h) = self.GetLocalPosition()
  1777. self.SetPosition(w,h)
  1778.  
  1779.  
  1780. self.ScrollBar.SetScrollBarSize(self.Drop.GetHeight())
  1781. self.DropList.SetViewItemCount(int(self.Drop.GetHeight()/13))
  1782. self.DropList.SetBasePos(self.last+1)
  1783. self.DropList.SetBasePos(self.last)
  1784. elif self.dropped == 1 and self.dropstat == 0:
  1785. self.Drop.Show()
  1786. self.SetTop()
  1787. if self.Drop.GetHeight() >=self.maxh:
  1788. self.Drop.SetSize(self.Drop.GetWidth(),self.maxh)
  1789. self.ScrollBar.SetScrollBarSize(self.maxh)
  1790. self.dropstat = 1
  1791. self.DropList.SetViewItemCount(7)
  1792. self.ScrollBar.SetPos(self.lastS)
  1793. else:
  1794. self.ScrollBar.SetScrollBarSize(self.Drop.GetHeight()+iter)
  1795. self.Drop.SetSize(self.Drop.GetWidth(),self.Drop.GetHeight()+iter)
  1796. (w,h) = self.GetLocalPosition()
  1797. self.SetPosition(w,h)
  1798. self.DropList.SetViewItemCount(int(self.Drop.GetHeight()/13))
  1799. self.DropList.SetBasePos(self.last+1)
  1800. self.DropList.SetBasePos(self.last)
  1801.  
  1802. ## BG Hover
  1803. def bgMouseIn(self):
  1804. self.bg.SetColor(0xc00a0a0a)
  1805. def bgMouseOut(self):
  1806. self.bg.SetColor(0xc0000000)
  1807.  
  1808.  
  1809. class Edit2(ui.EditLine):
  1810. def __init__(self,main = "",ml = 99):
  1811. ui.EditLine.__init__(self)
  1812. self.SetText(main)
  1813. self.main = main
  1814. self.SetMax(ml)
  1815. self.SetUserMax(ml)
  1816. def GetText(self):
  1817. res = ui.EditLine.GetText(self)
  1818. if res == "":
  1819. return "0"
  1820. else:
  1821. return res
  1822.  
  1823. def __del__(self):
  1824. ui.EditLine.__del__(self)
  1825. def OnSetFocus(self):
  1826. ui.EditLine.OnSetFocus(self)
  1827. if ui.EditLine.GetText(self) == self.main:
  1828. self.SetText("")
  1829. def OnKillFocus(self):
  1830. ui.EditLine.OnKillFocus(self)
  1831. if ui.EditLine.GetText(self) == "":
  1832. self.SetText(self.main)
  1833.  
  1834.  
  1835. class CheckBox(ui.Window):
  1836. checked = 0
  1837. eventUp =None
  1838. eventDown=None
  1839. def __init__(self,cont = ""):
  1840. ui.Window.__init__(self)
  1841. self.BG = ui.Bar("UI")
  1842. self.BG.SetParent(self)
  1843. self.BG.SetPosition(0,0)
  1844. self.BG.SetSize(20,20)
  1845. # self.BG.SetColor(0xc00b0b0b)
  1846. self.BG.SetColor(COLOR_CHECKBOX_NOT_SELECTED)
  1847. self.BG.OnMouseLeftButtonUp = self.Toggle
  1848. self.OnMouseLeftButtonUp = self.Toggle
  1849. self.BG.Show()
  1850. self.Title = ui.TextLine()
  1851. self.Title.SetParent(self)
  1852. self.Title.SetPosition(25,2)
  1853. self.Title.SetText(cont)
  1854. self.Title.Show()
  1855. self.stat = ui.TextLine()
  1856. self.stat.SetParent(self.BG)
  1857. self.stat.SetPosition(0,0)
  1858. self.stat.SetWindowHorizontalAlignCenter()
  1859. self.stat.SetWindowVerticalAlignCenter()
  1860. self.stat.SetHorizontalAlignCenter()
  1861. self.stat.SetVerticalAlignCenter()
  1862. self.stat.SetSize(0,0)
  1863. self.stat.SetText("")
  1864. self.SetSize(25+self.Title.GetTextSize()[0]+5,20)
  1865. self.stat.Show()
  1866. def __del__(self):
  1867. ui.ToggleButton.__del__(self)
  1868. def Toggle(self):
  1869. if self.checked == 1:
  1870. self.OnToggleUp()
  1871. else:
  1872. self.OnToggleDown()
  1873. def OnToggleUp(self):
  1874. self.stat.SetText("")
  1875. # self.BG.SetColor(0xc00b0b0b)
  1876. self.BG.SetColor(COLOR_CHECKBOX_NOT_SELECTED)
  1877. self.checked = 0
  1878. if self.eventUp:
  1879. self.eventUp()
  1880. def OnToggleDown(self):
  1881. # self.BG.SetColor(0xf00b0b0b)
  1882. self.BG.SetColor(COLOR_CHECKBOX_SELECTED)
  1883. self.stat.SetText("X")
  1884. self.checked = 1
  1885. if self.eventDown:
  1886. self.eventDown()
  1887.  
  1888.  
  1889. # Zum Testen
  1890. # a = Bot()
  1891. # a.Show()
  1892.  
  1893. # oder;
  1894. # Bot().Show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement