Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
247
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.  
  366. self.prepare_propose()
  367.  
  368. def change_boni(self):
  369. use = self.but_propose.DropList.GetSelectedItem().value
  370. bon = 1
  371. item.SelectItem(self.sub_parent.vnum)
  372. for x in use:
  373. # TODO: Check if bonus exists on item!!
  374. ok = 1
  375. for i in xrange(item.ITEM_APPLY_MAX_NUM):
  376. (affectType, affectValue) = item.GetAffect(i)
  377. if affectType == x[0]:
  378. ok = 0
  379. if ok == 0:
  380. continue
  381. y = self.boni[bon][1]
  382. y.SelectByAffectId(x[0])
  383. self.boni[bon][1].act.SetText(y.DropList.GetSelectedItem().textBox.GetText())
  384. self.boni[bon][3].SetText(str(x[1]))
  385. bon+=1
  386.  
  387. for x in range(bon,6):
  388. y = self.boni[x][1].DropList
  389. y.SelectIndex(0)
  390. self.boni[x][1].act.SetText(y.GetSelectedItem().textBox.GetText())
  391. self.boni[x][3].SetText("0")
  392.  
  393.  
  394. def prepare_propose(self):
  395. self.but_propose.DropList.RemoveAllItems()
  396. self.but_propose.maxh = 95
  397. self.but_propose.c = 0
  398. self.but_propose.AppendItem("Sterge",[])
  399.  
  400. item.SelectItem(self.sub_parent.vnum)
  401. type = item.GetItemType()
  402.  
  403. use = proposals[type]
  404. if type == 2:
  405. use = use[item.GetItemSubType()]
  406.  
  407. for prop in use:
  408. self.but_propose.AppendItem(prop,use[prop])
  409.  
  410.  
  411.  
  412.  
  413. class ItemTabBar(ui.Window):
  414.  
  415. class BlockBar(ui.Window):
  416. size_res = 32
  417. multi = 1
  418. def SetSize(self,i=1):
  419. self.multi = i
  420. ui.Window.SetSize(self,self.size_res,self.size_res*i)
  421. if self.rare_enabled == 1:
  422. self.swib_normal.SetSize(self.size_res,self.size_res*i/3*2)
  423. pos1 = int(1.0*self.size_res*i/3.0*2.0)
  424. self.swib_normal.SetSize(self.size_res,pos1)
  425. self.swib_rare.SetSize(self.size_res,self.size_res*i-pos1)
  426. self.swib_rare.SetPosition(0,pos1)
  427. self.swib_rare.Show()
  428. else:
  429. self.swib_normal.SetSize(self.size_res,self.size_res*i)
  430. self.swib_rare.Hide()
  431.  
  432. def Enable_rare(self,o = 1):
  433. self.rare_enabled = o
  434. self.SetSize(self.multi)
  435.  
  436. def __init__(self):
  437. ui.Window.__init__(self)
  438. self.rare_enabled = 0
  439. self.swib_normal = ui.Bar()
  440. self.swib_normal.SetParent(self)
  441. self.swib_normal.SetSize(self.size_res,self.size_res*self.multi)
  442. self.swib_normal.SetColor(COLOR_INACTIVE)
  443. self.swib_normal.SetPosition(0,0)
  444. self.swib_normal.Show()
  445.  
  446. self.swib_rare = ui.Bar()
  447. self.swib_rare.SetParent(self)
  448. self.swib_rare.SetSize(self.size_res,self.size_res)
  449. self.swib_rare.SetColor(COLOR_INACTIVE_RARE)
  450. self.swib_rare.SetPosition(0,0)
  451. self.swib_rare.Hide()
  452. self.SetSize(1)
  453.  
  454.  
  455. class ItemTab(ui.Bar):
  456.  
  457. height_selected = 36*3+8
  458. height_unselected = 36*3+5
  459.  
  460. def Destroy(self):
  461. self.parentWindow.parentWindow.enable_rebuy.SetParent(self.parentWindow.parentWindow)
  462. self.parentWindow.parentWindow.but_speed.SetParent(self.parentWindow.parentWindow)
  463. self.parentWindow.parentWindow.help_show_rare.SetParent(self.parentWindow.parentWindow)
  464. self.parentWindow.parentWindow.help_rebuy.SetParent(self.parentWindow.parentWindow)
  465. # self.parentWindow.parentWindow.help_stop_all.SetParent(self.parentWindow.parentWindow)
  466. self.parentWindow.parentWindow.help_duration.SetParent(self.parentWindow.parentWindow)
  467. # self.parentWindow.parentWindow.but_deactivate_all.SetParent(self.parentWindow.parentWindow)
  468. # self.parentWindow.parentWindow.but_deactivate_all.Hide()
  469. self.parentWindow.parentWindow.enable_rebuy.Hide()
  470. self.parentWindow.parentWindow.but_speed.Hide()
  471.  
  472. self.bonusSelector.Hide()
  473. self.bonusSelector.__del__()
  474. self.Hide()
  475. self.__del__()
  476.  
  477. def DeleteMe(self):
  478. self.parentWindow.DeleteTab(self.tabnum)
  479.  
  480. def __init__(self,parent,tabnum,index = 0,vnum = 0): ## Init ItemTab
  481. ui.Bar.__init__(self)
  482. self.SetColor(COLOR_BG)
  483. self.SetSize(self.width,self.height_unselected)
  484. self.index = index
  485. self.tabnum = tabnum
  486. self.vnum = vnum
  487. self.count = 0
  488. self.count_rare = 0
  489. self.parentWindow = parent
  490. self.SetParent(parent)
  491.  
  492.  
  493.  
  494. if self.parentWindow.parentWindow.gameWindow != None:
  495. self.blockBar = ItemTabBar.BlockBar()
  496. self.blockBar.SetParent(self.parentWindow.parentWindow.gameWindow.interface.wndInventory.wndItem)
  497. ipi = self.parentWindow.parentWindow.gameWindow.interface.wndInventory.inventoryPageIndex
  498. self.blockBar.Show()
  499. ip2 = self.index - ipi*45
  500. self.blockBar.SetPosition(((ip2-int(ip2/5)*5)*self.blockBar.size_res),int(ip2/5)*self.blockBar.size_res)
  501.  
  502. self.ItemIcon = ui.ImageBox()
  503. self.ItemIcon.SetParent(self)
  504. self.ItemIcon.AddFlag("not_pick")
  505. self.ItemIcon.SetWindowHorizontalAlignCenter()
  506. self.ItemIcon.SetWindowVerticalAlignCenter()
  507. self.ItemIcon.Show()
  508.  
  509. self.SlotName = ui.TextLine()
  510. self.SlotName.SetParent(self)
  511. self.SlotName.SetWindowHorizontalAlignCenter()
  512. self.SlotName.SetHorizontalAlignCenter()
  513. self.SlotName.SetPosition(0,5)
  514. self.SlotName.SetText("Slot %d" % (self.index+1))
  515. self.SlotName.AddFlag("not_pick")
  516. self.SlotName.Show()
  517.  
  518. self.StatusBar = Bar() # Special Bar
  519. self.StatusBar.SetParent(self)
  520. self.StatusBar.SetWindowVerticalAlignBottom()
  521. self.StatusBar.SetSize(self.width,20)
  522. self.StatusBar.SetPosition(0,20)
  523. self.StatusBar.SetColor(COLOR_INACTIVE)
  524. self.StatusBar.AddFlag("not_pick")
  525. self.StatusBar.Show()
  526.  
  527. self.StatusText = ui.TextLine()
  528. self.StatusText.SetParent(self.StatusBar)
  529. # self.StatusText.SetParent(self)
  530. self.StatusText.SetWindowHorizontalAlignCenter()
  531. self.StatusText.SetWindowVerticalAlignCenter()
  532. self.StatusText.SetHorizontalAlignCenter()
  533. self.StatusText.SetVerticalAlignCenter()
  534. self.StatusText.SetPosition(0,0)
  535. self.StatusText.SetText("Inactiv")
  536. self.StatusText.Show()
  537.  
  538.  
  539. self.StatusBar_rare = Bar() # Special Bar
  540. self.StatusBar_rare.SetParent(self)
  541. self.StatusBar_rare.SetWindowVerticalAlignBottom()
  542. self.StatusBar_rare.SetSize(self.width,20)
  543. self.StatusBar_rare.SetPosition(0,40)
  544. self.StatusBar_rare.SetColor(COLOR_INACTIVE_RARE)
  545. self.StatusBar_rare.AddFlag("not_pick")
  546. self.StatusBar_rare.Hide()
  547.  
  548. self.StatusText_rare = ui.TextLine()
  549. self.StatusText_rare.SetParent(self.StatusBar_rare)
  550. self.StatusText_rare.SetWindowHorizontalAlignCenter()
  551. self.StatusText_rare.SetWindowVerticalAlignCenter()
  552. self.StatusText_rare.SetHorizontalAlignCenter()
  553. self.StatusText_rare.SetVerticalAlignCenter()
  554. self.StatusText_rare.SetPosition(0,0)
  555. self.StatusText_rare.SetText("6/7 Inactiv")
  556. self.StatusText_rare.Show()
  557.  
  558.  
  559. self.CloseBut = ui.Button()
  560. self.CloseBut.SetParent(self)
  561. self.CloseBut.SetUpVisual("d:/ymir work/ui/public/close_button_01.sub")
  562. self.CloseBut.SetOverVisual("d:/ymir work/ui/public/close_button_02.sub")
  563. self.CloseBut.SetDownVisual("d:/ymir work/ui/public/close_button_03.sub")
  564. self.CloseBut.SetToolTipText("Inchide tab", 0, -23)
  565. self.CloseBut.SetEvent(self.DeleteMe)
  566. self.CloseBut.SetPosition(0,0)
  567. self.CloseBut.Show()
  568.  
  569.  
  570.  
  571. self.OnMouseLeftButtonDown = lambda: self.Select()
  572.  
  573. self.boni_active = 0
  574. self.boni_rare_active = 0
  575.  
  576. self.bonusSelector = BonusSelector(self)
  577. self.bonusSelector.SetParentProxy(self.parentWindow.parentWindow)
  578. self.bonusSelector.SetPosition(10,35+36*3+4*2)
  579. self.bonusSelector.Hide()
  580. self.vnum = 0
  581. self.SetIndex(index)
  582.  
  583. self.resetSwitch()
  584. self.resetSwitch_rare()
  585.  
  586. def IsActive(self):
  587. return self.boni_active == 1
  588. def IsActive_rare(self):
  589. return self.boni_rare_active == 1
  590.  
  591. def SetParentProxy(self,parent):
  592. ui.Bar.SetParentProxy(self,parent)
  593. def Select(self):
  594. for a in self.parentWindow.tabList:
  595. self.parentWindow.tabList[a].UnSelect()
  596. self.parentWindow.tabList[a].bonusSelector.Hide()
  597. self.bonusSelector.Show()
  598. self.SetSize(self.width,self.height_selected)
  599. self.Update()
  600. # self.parentWindow.parentWindow.but_deactivate_all.SetParent(self.bonusSelector)
  601. # self.parentWindow.parentWindow.but_deactivate_all.SetPosition(415-10,200+10)
  602. # self.parentWindow.parentWindow.but_deactivate_all.Show()
  603. self.parentWindow.parentWindow.enable_rebuy.SetParent(self.bonusSelector)
  604. self.parentWindow.parentWindow.enable_rebuy.SetPosition(10,200+10)
  605. self.parentWindow.parentWindow.enable_rebuy.Show()
  606. self.parentWindow.parentWindow.but_speed.SetParent(self.bonusSelector)
  607. self.parentWindow.parentWindow.but_speed.SetPosition(0,205+10)
  608. self.parentWindow.parentWindow.but_speed.Show()
  609.  
  610. self.parentWindow.parentWindow.help_show_rare.SetParent(self.bonusSelector)
  611. self.parentWindow.parentWindow.help_rebuy.SetParent(self.bonusSelector)
  612. # self.parentWindow.parentWindow.help_stop_all.SetParent(self.bonusSelector)
  613. self.parentWindow.parentWindow.help_duration.SetParent(self.bonusSelector)
  614.  
  615.  
  616. def UnSelect(self):
  617. self.SetSize(self.width,self.height_unselected)
  618. self.Update()
  619.  
  620. def Update(self):
  621. self.StatusBar.SetPosition(0,20)
  622. self.SetPosition((self.width+self.dist)*self.tabnum,0)
  623. self.SlotName.SetText("Slot %d" % (self.index+1))
  624.  
  625. def resetSwitch(self):
  626. self.values = [0,0,0,0,0]
  627. def resetSwitch_rare(self):
  628. self.values_rare = [0,0]
  629.  
  630. # last_switch = -1
  631. rebuyed = 0
  632. def nachkauf(self):
  633. if self.parentWindow.parentWindow.buyed != 0:
  634. return
  635. else:
  636. self.parentWindow.parentWindow.buyed = 1
  637. if self.parentWindow.parentWindow.enable_rebuy.checked == 1:
  638. for i in range(0,shop.SHOP_SLOT_COUNT):
  639. me = shop.GetItemID(i)
  640. if me == SWITCH_VNUM:
  641. if shop.GetItemPrice(i) > player.GetMoney():
  642. # chat.AppendChat(1,"-- Switchitem gefunden! Aber wir haben kein Geld :(")
  643. self.bonusSelector.Deactivate()
  644. return
  645. else:
  646. net.SendShopBuyPacket(i)
  647. self.rebuyed = 1
  648. # self.Switch()
  649. return
  650.  
  651. rebuyed_rare = 0
  652. def nachkauf_rare(self):
  653. if self.parentWindow.parentWindow.buyed_rare != 0:
  654. return
  655. else:
  656. self.parentWindow.parentWindow.buyed_rare = 1
  657. if self.parentWindow.parentWindow.enable_rebuy.checked == 1:
  658. for i in range(0,shop.SHOP_SLOT_COUNT):
  659. me = shop.GetItemID(i)
  660. if me == SWITCH_RARE_VNUM:
  661. if shop.GetItemPrice(i) > player.GetMoney():
  662. # chat.AppendChat(1,"-- Switchitem gefunden! Aber wir haben kein Geld :(")
  663. self.bonusSelector.Deactivate_rare()
  664. return
  665. else:
  666. net.SendShopBuyPacket(i)
  667. self.rebuyed_rare = 1
  668. # self.Switch()
  669. return
  670. # self.bonusSelector.Deactivate()
  671.  
  672. def Switch_rare(self):
  673. lc = 0
  674. for i in range(0,90*2):
  675. if player.GetItemIndex(i) == SWITCH_RARE_VNUM:
  676. lc+=player.GetItemCount(i)
  677.  
  678. if lc == 0 and self.parentWindow.parentWindow.enable_rebuy.checked == 0:
  679. chat.AppendChat(2,"Slot %d: 6/7 Schimbare fara succes." % (self.index+1))
  680. self.bonusSelector.Deactivate_rare()
  681. return
  682.  
  683. if lc < 15:
  684. self.nachkauf_rare()
  685.  
  686. if lc == 0:
  687. self.bonusSelector.Deactivate_rare()
  688. chat.AppendChat(2,"Slot %d: 6/7 Schimbare abandonata." % (self.index+1))
  689. return
  690.  
  691. for i in range(0,90*2):
  692. if player.GetItemIndex(i) == SWITCH_RARE_VNUM:
  693. net.SendItemUseToItemPacket(i,self.index)
  694. return
  695.  
  696. def Switch(self):
  697. lc = 0
  698. for i in range(0,90*2):
  699. if player.GetItemIndex(i) == SWITCH_VNUM:
  700. lc+=player.GetItemCount(i)
  701.  
  702. if lc == 0 and self.parentWindow.parentWindow.enable_rebuy.checked == 0:
  703. self.bonusSelector.Deactivate()
  704. return
  705.  
  706. if lc < 15:
  707. self.nachkauf()
  708.  
  709. if lc == 0:
  710. self.bonusSelector.Deactivate()
  711. return
  712.  
  713. for i in range(0,90*2):
  714. if player.GetItemIndex(i) == SWITCH_VNUM:
  715. net.SendItemUseToItemPacket(i,self.index)
  716. return
  717. # self.nachkauf()
  718.  
  719. def checkSwitch(self):
  720. ok = 0
  721. for i in range(0,5):
  722. if player.GetItemAttribute(self.index, i) != self.values[i]:
  723. ok = 1
  724. self.prob = self.GetProb()
  725. self.StatusText.SetText("Activ (%d%%)" %self.prob)
  726. if ok == 1 or self.prob >= 90:
  727. if self.prob >= 90:
  728. chat.AppendChat(1,"Slot %d: Gata de schimbare" % (self.index+1))
  729. self.bonusSelector.Finish()
  730. return
  731. self.values = [player.GetItemAttribute(self.index, i) for i in range(0,5)]
  732. self.Switch()
  733. elif self.rebuyed > 0:
  734. self.rebuyed = 0
  735. self.Switch()
  736. elif ok == 0 and self.count < 5:
  737. self.count+=1
  738. elif ok == 0 and self.count >= 5:
  739. self.count = 0
  740. self.Switch()
  741. # elif self.last_switch > -1 and player.GetItemCount(self.last_switch) == 0:
  742. # chat.AppendChat(2,"%d"%player.GetItemCount(self.last_switch))
  743. # self.last_switch = 0
  744. # self.Switch()
  745. # else:
  746. # if self.GetProb() != 100:
  747. # self.Switch()
  748. pass
  749.  
  750. def checkSwitch_rare(self):
  751. ok = 0
  752. for i in range(0,2):
  753. if player.GetItemAttribute(self.index, i+6) != self.values_rare[i]:
  754. ok = 1
  755. self.prob_rare = self.GetProb_rare()
  756. self.StatusText_rare.SetText("Activ (%d%%)" %self.prob_rare)
  757. if ok == 1 or self.prob_rare >= 90:
  758. if self.prob_rare >= 90:
  759. self.bonusSelector.Finish_rare()
  760. chat.AppendChat(1,"Slot %d: 6/7 Gata de schimbare" % (self.index+1))
  761. return
  762. self.values_rare = [player.GetItemAttribute(self.index, i) for i in range(5,7)]
  763. self.Switch_rare()
  764. elif self.rebuyed_rare > 0:
  765. self.rebuyed_rare = 0
  766. self.Switch_rare()
  767. elif ok == 0 and self.count_rare < 5:
  768. self.count_rare+=1
  769. elif ok == 0 and self.count_rare >= 5:
  770. self.count_rare = 0
  771. self.Switch_rare()
  772.  
  773. pass
  774. def UpdateItem(self):
  775. # try:
  776. vnum = player.GetItemIndex(self.index)
  777. if vnum == 0 and self.vnum != 0:
  778. self.resetSwitch()
  779. self.resetSwitch_rare()
  780. self.vnum = 0
  781. self.bonusSelector.Deactivate()
  782. self.bonusSelector.Block()
  783. self.bonusSelector.prepare_propose()
  784. self.ItemIcon.Hide()
  785. if self.parentWindow.parentWindow.gameWindow != None:
  786. self.blockBar.SetSize(1)
  787. return
  788. elif vnum != self.vnum:
  789. self.resetSwitch()
  790. self.resetSwitch_rare()
  791. self.vnum = vnum
  792. self.bonusSelector.Deactivate()
  793. self.bonusSelector.prepare_propose()
  794. item.SelectItem(self.vnum)
  795. if self.parentWindow.parentWindow.gameWindow != None:
  796. (w,h) = item.GetItemSize(1,2,3,4,5,6,7,8,9)
  797. self.blockBar.SetSize(h)
  798.  
  799. if item.GetItemType() != 1 and item.GetItemType() != 2:
  800. self.bonusSelector.Block()
  801. else:
  802. self.bonusSelector.Unblock()
  803.  
  804.  
  805. self.ItemIcon.Show()
  806. self.ItemIcon.LoadImage(item.GetIconImageFileName())
  807. # self.values = [player.GetItemAttribute(self.index, i) for i in range(0,5)]
  808. return
  809. if self.IsActive():
  810. self.checkSwitch()
  811.  
  812. if self.IsActive_rare():
  813. self.checkSwitch_rare()
  814.  
  815. # except:
  816. # pass
  817.  
  818. def SetIndex(self,index):
  819. self.index = index
  820. self.bonusSelector.index = index
  821. self.bonusSelector.Starter.SetText("Schimba ("+str(index+1)+") Start")
  822. self.Update()
  823. self.UpdateItem()
  824.  
  825. def GetProb_rare(self):
  826. values = [player.GetItemAttribute(self.index, i+6) for i in range(0,2)]
  827. val2 = {}
  828. for i in range(0,2):
  829. try:
  830. affectString = AFFECT_DICT[values[i][0]](values[i][1])
  831. val2[values[i][0]] = values[i][1]
  832. self.bonusSelector.ibi[i+6].SetText(affectString)
  833. except:
  834. pass
  835. prob = 0
  836. max = 0
  837.  
  838. yp = self.GenList_rare()
  839. for x in yp:
  840. if yp[x] in val2 and val2[yp[x]] >= int(self.bonusSelector.boni[x+5][3].GetText()):
  841. prob = prob+1
  842. max = max+1
  843. if max > 0:
  844. prozent = 100/max*prob
  845. else:
  846. prozent = 100
  847. return prozent
  848. pass
  849. def GetProb(self):
  850. values = [player.GetItemAttribute(self.index, i) for i in range(0,5)]
  851. val2 = {}
  852. # for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  853. for i in range(0,5):
  854. try:
  855. affectString = AFFECT_DICT[values[i][0]](values[i][1])
  856. val2[values[i][0]] = values[i][1]
  857. self.bonusSelector.ibi[i].SetText(affectString)
  858. except:
  859. pass
  860. prob = 0
  861. max = 0
  862. yp = self.GenList()
  863. for x in yp:
  864. if yp[x] in val2 and val2[yp[x]] >= int(self.bonusSelector.boni[x][3].GetText()):
  865. prob = prob+1
  866. max = max+1
  867. if max > 0:
  868. prozent = 100/max*prob
  869. else:
  870. prozent = 100
  871. return prozent
  872.  
  873. def GenList(self):
  874. ret = {}
  875. for i in range(0,5):
  876. if self.bonusSelector.boni[5-i][1].selected.value != 0:
  877. ret[5-i] = self.bonusSelector.boni[5-i][1].selected.value
  878. return ret
  879. def GenList_rare(self):
  880. ret = {}
  881. for i in range(0,2):
  882. if self.bonusSelector.boni[6+i][1].selected.value != 0:
  883. ret[i+1] = self.bonusSelector.boni[6+i][1].selected.value
  884. return ret
  885.  
  886. def __init__(self,parent):
  887. ui.Window.__init__(self)
  888. self.SetSize(500,36*3+4*2)
  889. self.tabCount = 0
  890. self.tabList = {}
  891.  
  892. self.parentWindow = parent
  893. self.SetParent(parent)
  894. self.plusBar = ui.Bar()
  895. self.plusBar.SetParent(self)
  896. self.plusBar.SetSize(90,30)
  897. self.plusBar.SetWindowVerticalAlignCenter()
  898. self.plusBar.SetColor(COLOR_BG)
  899. # self.plusBar.OnMouseLeftButtonDown = lambda: self.AddTab_pre()
  900. self.plusBar.OnMouseLeftButtonUp = lambda: self.AddTab_pre()
  901. self.OnMouseLeftButtonUp = lambda: self.AddTab_pre()
  902. self.plusBar.SetPosition(30,0)
  903. self.plusBar.Show()
  904.  
  905. self.AddText = ui.TextLine()
  906. self.AddText.SetParent(self.plusBar)
  907. self.AddText.SetText("Trage itemul aici")
  908. self.AddText.SetWindowVerticalAlignCenter()
  909. self.AddText.SetWindowHorizontalAlignCenter()
  910. self.AddText.SetVerticalAlignCenter()
  911. self.AddText.SetHorizontalAlignCenter()
  912. self.AddText.SetPosition(0,0)
  913. self.AddText.Show()
  914.  
  915. dist = [
  916. [500, 0 ], #1
  917. [240, 10 ],
  918. [160, 10 ],
  919. [117, 10.5],
  920. # [ 80, 25 ], #5
  921. [ 92, 10 ], #5
  922. [ 75, 10 ], #6
  923. [ 64, 9 ], #7
  924. [ 56, 7.5], #8
  925. [ 50, 6.5], #9
  926. [ 45, 5.5], #10
  927. ][MAX_NUM-1]
  928. self.ItemTab.width = dist[0]
  929. self.ItemTab.dist = dist[1]
  930.  
  931.  
  932. #For 8
  933. # dist = 9-1.5
  934. # width = 56
  935.  
  936. # For 9
  937. # dist = 9-2.5
  938. # width = 50
  939.  
  940. # For 10
  941. # dist = 9-3.5
  942. # width = 45
  943.  
  944.  
  945. def DeleteTab(self,id):
  946. if self.parentWindow.gameWindow != None:
  947. self.tabList[id].blockBar.Hide()
  948. self.tabList[id].blockBar.Destroy()
  949. self.tabList[id].Destroy()
  950. # del self.tabList[id]
  951. self.tabCount = self.tabCount -1
  952. if self.tabCount > id and id < 5:
  953. for i in xrange(id,self.tabCount):
  954. self.tabList[i] = self.tabList[i+1]
  955. self.tabList[i].tabnum = i
  956. self.tabList[i].SetPosition((self.tabList[i].width+self.tabList[i].dist)*i,0)
  957.  
  958. del self.tabList[self.tabCount]
  959.  
  960. else:
  961. del self.tabList[id]
  962.  
  963.  
  964. if self.tabCount > 0:
  965. self.tabList[0].Select()
  966.  
  967. if (self.ItemTab.width+self.ItemTab.dist)*self.tabCount < 20:
  968. self.parentWindow.SetSize(520,387-210)
  969. self.parentWindow.but_speed.Hide()
  970. self.plusBar.SetPosition(20,0)
  971. else:
  972. (x,y) = self.tabList[self.tabCount-1].GetLocalPosition()
  973. self.plusBar.SetPosition(x+self.ItemTab.width+self.ItemTab.dist,0)
  974. # self.plusBar.SetPosition((self.ItemTab.width+self.ItemTab.dist)*self.tabCount-10,0)
  975. self.plusBar.Show()
  976.  
  977. def AddTab_pre(self):
  978. if mouseModule.mouseController.isAttached():
  979. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  980. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  981. attachedSlotVnum = mouseModule.mouseController.GetAttachedItemIndex()
  982.  
  983. item.SelectItem(attachedSlotVnum)
  984. if item.GetItemType() != 1 and item.GetItemType() != 2:
  985. mouseModule.mouseController.DeattachObject()
  986. chat.AppendChat(2,"Nu poti schimba pe acest item")
  987. return
  988.  
  989. for a in self.tabList:
  990. if self.tabList[a].index == attachedSlotPos:
  991. mouseModule.mouseController.DeattachObject()
  992. chat.AppendChat(2,"Acest slot este deja ocupat.")
  993. return
  994.  
  995.  
  996. if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  997. self.AddTab(attachedSlotPos,attachedSlotVnum)
  998. chat.AppendChat(2,"Item adaugat")
  999.  
  1000. mouseModule.mouseController.DeattachObject()
  1001.  
  1002. def AddTab(self,id,vnum = 0):
  1003. if self.tabCount < MAX_NUM:
  1004. self.tabList[self.tabCount] = self.ItemTab(self,self.tabCount,id,vnum)
  1005.  
  1006. self.tabList[self.tabCount].Select()
  1007. self.tabList[self.tabCount].Show()
  1008. self.tabCount+= 1
  1009. if (self.ItemTab.width+self.ItemTab.dist)*self.tabCount < 20:
  1010. self.plusBar.SetPosition(20,0)
  1011. else:
  1012. (x,y) = self.tabList[self.tabCount-1].GetLocalPosition()
  1013. self.plusBar.SetPosition(x+self.ItemTab.width+self.ItemTab.dist,0)
  1014.  
  1015. if self.tabCount == MAX_NUM:
  1016. self.plusBar.Hide()
  1017.  
  1018. self.parentWindow.SetSize(520,387+10)
  1019. self.parentWindow.but_speed.Show()
  1020. # return 0
  1021.  
  1022. class Bot(ui.BoardWithTitleBar):
  1023. class PinGroup(ui.Bar):
  1024. def OnUpdate(self):
  1025. ## Now check position.
  1026. (x,y) = self.GetGlobalPosition()
  1027. max_x = wndMgr.GetScreenWidth()-self.GetWidth()
  1028. max_y = wndMgr.GetScreenHeight()-self.GetHeight()-DISTANCE_BOTTOM
  1029. if not x == self.pos_x or not y == self.pos_y:
  1030. old_dir = self.dir
  1031. if self.pos_x == 0 and not self.pos_y == 0 and not self.pos_y == max_y and old_dir != 1:
  1032. self.parse_dir(1)
  1033. elif self.pos_x == max_x and not self.pos_y == 0 and not self.pos_y == max_y and old_dir != 2:
  1034. self.parse_dir(2)
  1035. elif self.pos_y == max_y and not self.pos_x == 0 and not self.pos_x == max_x and old_dir != 4:
  1036. self.parse_dir(4)
  1037. elif self.pos_y == 0 and not self.pos_x == 0 and not self.pos_x == max_x and old_dir != 3:
  1038. self.parse_dir(3)
  1039.  
  1040. max_x = wndMgr.GetScreenWidth()-self.GetWidth()
  1041. max_y = wndMgr.GetScreenHeight()-self.GetHeight()-DISTANCE_BOTTOM
  1042.  
  1043.  
  1044. if self.pos_x == 0 and not self.pos_y == 0 and not self.pos_y == max_y:
  1045. x = 0
  1046. elif self.pos_x == max_x and not self.pos_y == 0 and not self.pos_y == max_y:
  1047. x = max_x
  1048. elif self.pos_y == 0 and not self.pos_x == 0 and not self.pos_x == max_x:
  1049. y = 0
  1050. elif self.pos_y == max_y and not self.pos_x == 0 and not self.pos_x == max_x:
  1051. y = max_y
  1052. if x > 0 and x < max_x and y > 0 and y < max_y:
  1053. if y < int(max_y/2):
  1054. y = 0
  1055. else:
  1056. y = max_y
  1057.  
  1058. if x < int(max_x/2):
  1059. x = 0
  1060. else:
  1061. x = max_x
  1062.  
  1063.  
  1064. x = min(max(0,x),wndMgr.GetScreenWidth()-self.GetWidth())
  1065. y = min(max(0,y),wndMgr.GetScreenHeight()-self.GetHeight()-DISTANCE_BOTTOM)
  1066. self.SetPosition(x,y)
  1067. self.pos_x = x
  1068. self.pos_y = y
  1069. # (self.pos_x,self.pos_y) = self.GetGlobalPosition()
  1070. self.parent.OnUpdate()
  1071. for c in self.txtlist:
  1072. c.SetColor(c.item.StatusBar.color)
  1073. c.txt2.SetText("Status: %s" % c.item.StatusText.GetText())
  1074. try:
  1075. c.listWin2.SetColor(c.item.StatusBar_rare.color)
  1076. c.txt3.SetText("Status: %s" % c.item.StatusText_rare.GetText())
  1077. except:
  1078. pass
  1079.  
  1080. def ShowMainWindow(self):
  1081. (x,y) = self.parent.GetGlobalPosition()
  1082. x = min(max(32,x),wndMgr.GetScreenWidth()-self.parent.GetWidth()-32)
  1083. y = min(max(32,y),wndMgr.GetScreenHeight()-self.parent.GetHeight()-DISTANCE_BOTTOM-32)
  1084. self.parent.SetPosition(x,y)
  1085. self.parent.Show()
  1086. self.__del__()
  1087. def parse_dir(self,dir):
  1088. self.dir = dir
  1089. w,h = 100,50
  1090. for listWin in self.txtlist:
  1091. itm = listWin.item
  1092. listWin.AddFlag("not_pick")
  1093. if dir >= 3:
  1094. listWin.SetPosition(w,4)
  1095. listWin.SetSize(90,h-8)
  1096. w+=92
  1097. if itm.bonusSelector.EnableRareBoni.checked == 1:
  1098. w+=15
  1099. listWin.SetSize(105,4+12+12)
  1100. listWin.listWin2.SetSize(105,14)
  1101. listWin.listWin2.Show()
  1102. listWin.txt3.Show()
  1103. else:
  1104. listWin.SetPosition(0,h)
  1105. listWin.SetSize(w,4+12+12+2)
  1106.  
  1107. if itm.bonusSelector.EnableRareBoni.checked == 1:
  1108. listWin.SetSize(w,4+12+12)
  1109. listWin.listWin2.SetSize(w,14)
  1110. listWin.listWin2.Show()
  1111. listWin.txt3.Show()
  1112. # itl.append(txt3)
  1113. h+=12
  1114. pass
  1115. h+=4+12+12+4
  1116. self.SetSize(w,h)
  1117.  
  1118. def __init__(self,parent,dir = 1):
  1119. self.parent = parent
  1120. self.dir = dir
  1121. ui.Bar.__init__(self)
  1122. # Direction: 1 = left; 2 = right; 3 = top
  1123. self.SetColor(COLOR_BG)
  1124. w,h = 100,50
  1125.  
  1126. self.AddFlag("float")
  1127. self.AddFlag("movable")
  1128.  
  1129. constInfo.SWITCHBOT = 1
  1130.  
  1131.  
  1132.  
  1133. self.maximise_but = ui.Button()
  1134. self.maximise_but.SetParent(self)
  1135. self.maximise_but.SetPosition(4,4)
  1136. self.maximise_but.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
  1137. self.maximise_but.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
  1138. self.maximise_but.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
  1139. self.maximise_but.SetText("Marire")
  1140. self.maximise_but.SetEvent(self.ShowMainWindow)
  1141. self.maximise_but.Show()
  1142.  
  1143. self.stop_but = ui.Button()
  1144. self.stop_but.SetParent(self)
  1145. self.stop_but.SetPosition(4,24)
  1146. self.stop_but.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
  1147. self.stop_but.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
  1148. self.stop_but.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
  1149. self.stop_but.SetText("Dezactivati")
  1150. self.stop_but.SetEvent(self.parent.deactivate_all)
  1151. self.stop_but.Show()
  1152.  
  1153. self.txtlist = []
  1154. for a in self.parent.itemTabBar.tabList:
  1155. itm = self.parent.itemTabBar.tabList[a]
  1156.  
  1157. listWin = ui.Bar()
  1158. listWin.item = itm
  1159. self.txtlist.append(listWin)
  1160. listWin.SetColor(itm.StatusBar.color)
  1161. listWin.SetParent(self)
  1162. listWin.AddFlag("not_pick")
  1163. listWin.Show()
  1164.  
  1165. listWin.txt1 = ui.TextLine()
  1166. listWin.txt1.SetParent(listWin)
  1167. listWin.txt1.SetText("Slot %d:" %(itm.index+1))
  1168. listWin.txt1.Show()
  1169. listWin.txt1.SetPosition(4,2)
  1170.  
  1171. listWin.txt2 = ui.TextLine()
  1172. listWin.txt2.SetParent(listWin)
  1173. listWin.txt2.SetText("Status: %s" % itm.StatusText.GetText())
  1174. listWin.txt2.SetPosition(4,2+12)
  1175. listWin.txt2.Show()
  1176.  
  1177. listWin.listWin2 = ui.Bar()
  1178. listWin.listWin2.AddFlag("not_pick")
  1179. listWin.listWin2.SetColor(itm.StatusBar_rare.color)
  1180. listWin.listWin2.SetParent(listWin)
  1181. listWin.listWin2.SetPosition(0,4+12+12)
  1182. listWin.listWin2.SetSize(w,12+2)
  1183. listWin.listWin2.Hide()
  1184.  
  1185. listWin.txt3 = ui.TextLine()
  1186. listWin.txt3.SetParent(listWin.listWin2)
  1187. listWin.txt3.SetText("Status: %s" % itm.StatusText_rare.GetText())
  1188. listWin.txt3.SetPosition(4,0)
  1189. listWin.txt3.Hide()
  1190.  
  1191. if dir >= 3:
  1192. listWin.SetPosition(w,4)
  1193. listWin.SetSize(90,h-8)
  1194. w+=92
  1195. if itm.bonusSelector.EnableRareBoni.checked == 1:
  1196. w+=15
  1197. listWin.SetSize(105,4+12+12)
  1198. listWin.listWin2.SetSize(105,14)
  1199. listWin.listWin2.Show()
  1200. listWin.txt3.Show()
  1201. else:
  1202. listWin.SetPosition(0,h)
  1203. listWin.SetSize(w,4+12+12+2)
  1204.  
  1205. if itm.bonusSelector.EnableRareBoni.checked == 1:
  1206. listWin.SetSize(w,4+12+12)
  1207. listWin.listWin2.Show()
  1208. listWin.txt3.Show()
  1209. # itl.append(txt3)
  1210. h+=12
  1211. pass
  1212.  
  1213. h+=4+12+12+4
  1214. # else:
  1215.  
  1216. # self.txtlist.append(itl)
  1217.  
  1218. self.SetSize(w,h)
  1219. (x,y) = self.parent.GetGlobalPosition()
  1220.  
  1221. x = min(max(0,x),wndMgr.GetScreenWidth()-self.GetWidth())
  1222. y = min(max(0,y),wndMgr.GetScreenHeight()-self.GetHeight()-DISTANCE_BOTTOM)
  1223. if dir == 1:
  1224. # self.SetWindowHorizontalAlignLeft()
  1225. self.SetPosition(0,y)
  1226. elif dir == 2:
  1227. # self.SetWindowHorizontalAlignRight()
  1228. self.SetPosition(wndMgr.GetScreenWidth()-self.GetWidth(),y)
  1229. elif dir == 3:
  1230. # self.SetWindowVerticalAlignTop()
  1231. self.SetPosition(x,0)
  1232. else:
  1233. # self.SetWindowVerticalAlignBottom()
  1234. self.SetPosition(x,wndMgr.GetScreenHeight()-(DISTANCE_BOTTOM+h))
  1235.  
  1236. (self.pos_x,self.pos_y) = self.GetGlobalPosition()
  1237.  
  1238. self.parse_dir(dir)
  1239. # if dir == 1:
  1240. # self.SetWindowHorizontalAlignLeft()
  1241. # self.SetPosition(0,0)
  1242. # elif dir == 2:
  1243. # self.SetWindowHorizontalAlignRight()
  1244. # self.SetPosition(self.GetWidth(),0)
  1245. # elif dir == 3:
  1246. # self.SetWindowHorizontalAlignCenter()
  1247. # self.SetPosition(0,0)
  1248. # elif dir == 4:
  1249. # self.SetWindowHorizontalAlignCenter()
  1250. # self.SetPosition(0,36+h)
  1251. # else:
  1252. # return # ERR
  1253.  
  1254.  
  1255.  
  1256. pinhint = 0
  1257. def ShowPinHint(self,type):
  1258. self.pinhint = type
  1259. if type == 0:
  1260. self.PinHint.Hide()
  1261. return
  1262. # type=2
  1263.  
  1264. (x,y) = self.GetGlobalPosition()
  1265. if type == 1: # Left
  1266. self.PinHint.SetWindowHorizontalAlignLeft()
  1267. self.PinHint.SetWindowVerticalAlignCenter()
  1268. self.PinHint.SetSize(max(min(30,30-x),3),wndMgr.GetScreenHeight())
  1269. self.PinHint.SetPosition(0,0)
  1270. elif type == 2: # Right
  1271. self.PinHint.SetWindowHorizontalAlignRight()
  1272. self.PinHint.SetWindowVerticalAlignCenter()
  1273. self.PinHint.SetSize(30,wndMgr.GetScreenHeight())
  1274. self.PinHint.SetPosition(max(min(30,30-(wndMgr.GetScreenWidth()-(x+self.GetWidth()))),3),0)
  1275. elif type == 3: # Top
  1276. self.PinHint.SetWindowHorizontalAlignCenter()
  1277. self.PinHint.SetWindowVerticalAlignTop()
  1278. self.PinHint.SetSize(wndMgr.GetScreenWidth(),max(min(30,30-y),3))
  1279. self.PinHint.SetPosition(0,0)
  1280. elif type == 4: # Top
  1281. self.PinHint.SetWindowHorizontalAlignCenter()
  1282. self.PinHint.SetWindowVerticalAlignBottom()
  1283. self.PinHint.SetSize(wndMgr.GetScreenWidth(),30)
  1284. self.PinHint.SetPosition(0,36+max(min(30,30-(wndMgr.GetScreenHeight()-36-(y+self.GetHeight()))),3))
  1285. self.PinHint.Show()
  1286. # else:
  1287.  
  1288.  
  1289. def __init__(self):
  1290. ui.BoardWithTitleBar.__init__(self)
  1291. self.gameWindow = None
  1292.  
  1293. self.SetTitleName("|cFFFFFF00|h Schimbator de bonusuri")
  1294. self.AddFlag("float")
  1295. self.AddFlag("movable")
  1296. self.SetPosition(30,30)
  1297. # self.SetSize(520,387)
  1298. # self.SetSize(520,387-210)
  1299. self.SetSize(520,387-210)
  1300.  
  1301. self.PinHint = ui.Bar()
  1302. self.PinHint.SetColor(COLOR_PIN_HINT)
  1303. self.PinHint.Show()
  1304.  
  1305. self.OnMouseLeftButtonDown = self.drag_start
  1306. self.OnMouseLeftButtonUp = self.drag_end
  1307.  
  1308. self.titleBar.MinimizeBut = ui.Button()
  1309. self.titleBar.MinimizeBut.SetParent(self.titleBar)
  1310. self.titleBar.MinimizeBut.SetUpVisual("d:/ymir work/ui/public/minimize_button_01.sub")
  1311. self.titleBar.MinimizeBut.SetOverVisual("d:/ymir work/ui/public/minimize_button_02.sub")
  1312. self.titleBar.MinimizeBut.SetDownVisual("d:/ymir work/ui/public/minimize_button_03.sub")
  1313. self.titleBar.MinimizeBut.SetToolTipText("Minimize", 0, -23)
  1314. self.titleBar.MinimizeBut.SetPosition(520 - self.titleBar.btnClose.GetWidth()-3- 32 - 3, 3)
  1315. self.titleBar.MinimizeBut.SetEvent(lambda: self.PinShow(1))
  1316. self.titleBar.MinimizeBut.Show()
  1317.  
  1318. self.titleBar.HelpBut = ui.ToggleButton()
  1319. self.titleBar.HelpBut.SetParent(self.titleBar)
  1320. self.titleBar.HelpBut.SetUpVisual("d:/ymir work/ui/public/small_button_01.sub")
  1321. self.titleBar.HelpBut.SetOverVisual("d:/ymir work/ui/public/small_button_02.sub")
  1322. self.titleBar.HelpBut.SetDownVisual("d:/ymir work/ui/public/small_button_03.sub")
  1323. self.titleBar.HelpBut.SetToolTipText("Ajutor", 0, -23)
  1324. self.titleBar.HelpBut.SetText("Ajutor")
  1325. self.titleBar.HelpBut.SetPosition(3, 0)
  1326. self.titleBar.HelpBut.SetToggleDownEvent(lambda: self.ToggleHelp(1))
  1327. self.titleBar.HelpBut.SetToggleUpEvent(lambda: self.ToggleHelp(0))
  1328. self.titleBar.HelpBut.Show()
  1329.  
  1330.  
  1331. self.but_deactivate_all = ui.Button()
  1332. # self.but_deactivate_all.SetParent(self)
  1333. self.but_deactivate_all.SetParent(self.titleBar)
  1334. # self.but_deactivate_all.SetPosition(415,350)
  1335. self.but_deactivate_all.SetPosition(3+5+self.titleBar.HelpBut.GetWidth(), 0)
  1336. self.but_deactivate_all.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
  1337. self.but_deactivate_all.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
  1338. self.but_deactivate_all.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
  1339. self.but_deactivate_all.SetText("Opriti toate")
  1340. self.but_deactivate_all.SetEvent(self.deactivate_all)
  1341. self.but_deactivate_all.Show()
  1342.  
  1343. self.titleBar.but_deactivate_all = ui.Button()
  1344. self.titleBar.but_deactivate_all.SetParent(self.titleBar)
  1345. self.titleBar.but_deactivate_all.SetPosition(3+5+self.titleBar.HelpBut.GetWidth()+5+self.but_deactivate_all.GetWidth(), 0)
  1346. self.titleBar.but_deactivate_all.SetUpVisual("d:/ymir work/ui/public/small_button_01.sub")
  1347. self.titleBar.but_deactivate_all.SetOverVisual("d:/ymir work/ui/public/small_button_02.sub")
  1348. self.titleBar.but_deactivate_all.SetDownVisual("d:/ymir work/ui/public/small_button_03.sub")
  1349. self.titleBar.but_deactivate_all.SetText("Info")
  1350. self.titleBar.but_deactivate_all.SetEvent(self.about)
  1351. self.titleBar.but_deactivate_all.Show()
  1352. self.titleName.SetPosition(60, 4)
  1353.  
  1354. self.enable_rebuy = CheckBox("Cumpara automat")
  1355. self.enable_rebuy.Toggle()
  1356. self.enable_rebuy.Hide()
  1357.  
  1358. self.but_speed = ui.SliderBar()
  1359. self.but_speed.SetParent(self)
  1360. self.but_speed.SetWindowHorizontalAlignCenter()
  1361. self.but_speed.SetPosition(0,360)
  1362. self.but_speed.SetSliderPos(0.0)
  1363. # self.but_speed.SetToolTipText("Switch-Geschwindigkeit", 0, -23)
  1364. # self.but_speed.Show()
  1365. self.but_speed.Hide()
  1366.  
  1367. self.itemTabBar = ItemTabBar(self)
  1368. self.itemTabBar.SetPosition(10,35)
  1369. self.itemTabBar.Show()
  1370.  
  1371.  
  1372. self.buyed = 0
  1373. self.buyed_rare = 0
  1374.  
  1375. self.SetCloseEvent(self._Hide)
  1376.  
  1377. self.Hide = self._Hide
  1378.  
  1379.  
  1380. ### NOW initialize the HELP stuff!
  1381.  
  1382. self.help_add_item = HelpBar(0.8,'Pune un item aici.')
  1383. self.help_add_item.SetParent(self)
  1384. self.help_add_item.SetPosition(60,50)
  1385.  
  1386. self.help_minimize = HelpBar(0.8,'Trageti spre margine pentru a micsora!',1)
  1387. self.help_minimize.SetParent(self.titleBar)
  1388. self.help_minimize.SetWindowHorizontalAlignCenter()
  1389. self.help_minimize.SetPosition(100,-30)
  1390.  
  1391. self.help_show_rare = HelpBar(0.85,'De aici puteti activa 6/7.')
  1392. self.help_show_rare.SetParent(self)
  1393. # self.help_show_rare.SetPosition(35,312)
  1394.  
  1395. self.help_rebuy = HelpBar(0.5,'Daca cumpar mai multe bonusuri')
  1396. self.help_rebuy.SetParent(self)
  1397. # self.help_rebuy.SetPosition(25,297)
  1398.  
  1399. self.help_stop_all = HelpBar(0.8,'Opriti toate procesele',1)
  1400. self.help_stop_all.SetParent(self.titleBar)
  1401. self.help_stop_all.SetPosition(3+5+self.titleBar.HelpBut.GetWidth()*1.2,-30)
  1402.  
  1403. self.help_duration = HelpBar(0.8,'Incetineste procesele.',1)
  1404. self.help_duration.SetParent(self)
  1405.  
  1406.  
  1407. def ToggleHelp(self,val):
  1408. self.help_on = val
  1409.  
  1410. def Show(self):
  1411. ui.BoardWithTitleBar.Show(self)
  1412. self.bot_shown = 1
  1413.  
  1414. def _Hide(self):
  1415. ## ONLY FOR TESTING
  1416. # for a in range(0,self.itemTabBar.tabCount):
  1417. # self.itemTabBar.DeleteTab(0)
  1418.  
  1419. ui.BoardWithTitleBar.Hide(self)
  1420. self.bot_shown = 0
  1421. constInfo.SWITCHBOT = 0
  1422.  
  1423.  
  1424. def deactivate_all(self):
  1425. for a in self.itemTabBar.tabList:
  1426. self.itemTabBar.tabList[a].bonusSelector.Starter.SetUp()
  1427. self.itemTabBar.tabList[a].bonusSelector.Starter.OnToggleUp()
  1428. self.itemTabBar.tabList[a].bonusSelector.Starter_rare_boni.SetUp()
  1429. self.itemTabBar.tabList[a].bonusSelector.Starter_rare_boni.OnToggleUp()
  1430. pass
  1431.  
  1432. drag = 0
  1433. def drag_start(self):
  1434. self.drag = 1
  1435.  
  1436. def drag_end(self):
  1437. self.drag = 0
  1438. if self.pinhint > 0:
  1439. self.PinShow(self.pinhint)
  1440. # self.PinGroupBox = self.PinGroup()
  1441. pass
  1442. self.ShowPinHint(0)
  1443.  
  1444. def PinShow(self,dir):
  1445. self.PinGroupBox = self.PinGroup(self,dir)
  1446. self.Hide()
  1447. self.PinGroupBox.Show()
  1448.  
  1449. def EnableInventoryTweak(self,gameWindow):
  1450. self.gameWindow=gameWindow
  1451. self.gameWindow.interface.wndInventory.inventoryTab[0].SetEvent(lambda arg=0: self.__SetInventoryPage(arg))
  1452. self.gameWindow.interface.wndInventory.inventoryTab[1].SetEvent(lambda arg=1: self.__SetInventoryPage(arg))
  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