Guest User

switchbot

a guest
Oct 16th, 2018
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 43.08 KB | None | 0 0
  1. import shop
  2. import player
  3. import item
  4. import ui
  5. import net
  6. import locale
  7. import chat
  8. import grp
  9. import wndMgr
  10. import mouseModule
  11.  
  12. from uitooltip import ItemToolTip
  13. # Switchbot by Mijago
  14.  
  15. WEAR_NAMES = ItemToolTip.WEAR_NAMES
  16. AFFECT_DICT = ItemToolTip.AFFECT_DICT
  17. BONI_AVAIL = [1,2,3,4,5,6,9,10,12,13,14,15,16,17,21,23,27,28,29,30,31,32,33,34,37,39,41,43,44,45,48,53,71,72]
  18. BONI_RARE_AVAIL = [1,2]
  19.  
  20. SWITCH_VNUM = 71084
  21. SWITCH_RARE_VNUM = 71052
  22.  
  23. MIN_SWITCH_DELAY = 35
  24. MAX_SWITCH_DELAY_APPEND = 120
  25.  
  26. MAX_NUM = 5
  27.  
  28. COLOR_BG = grp.GenerateColor(0.0, 0.0, 0.0, 0.5)
  29. COLOR_INACTIVE = grp.GenerateColor(1.0, 0.0, 0.0, 0.2)
  30. COLOR_ACTIVE   = grp.GenerateColor(1.0, 0.6, 0.1, 0.2)
  31. COLOR_FINISHED = grp.GenerateColor(0.0, 1.0, 0.0, 0.2)
  32.  
  33. COLOR_INACTIVE_RARE = grp.GenerateColor(1.0, 0.2, 0.0, 0.2)
  34. COLOR_ACTIVE_RARE   = grp.GenerateColor(1.0, 0.7, 0.2, 0.2)
  35.  
  36. COLOR_HIGHLIGHT_RARE = grp.GenerateColor(0.0, 0.5, 1.0, 0.05)
  37.  
  38.  
  39. COLOR_PIN_HINT = grp.GenerateColor(0.0, 0.5, 1.0, 0.3)
  40.  
  41. class Bar(ui.Bar):
  42.     def __init__(self,layer = "UI"):
  43.         ui.Bar.__init__(self,layer)
  44.     def SetColor(self,color):
  45.         wndMgr.SetColor(self.hWnd, color)
  46.         self.color = color
  47.  
  48.  
  49. class BonusSelector(ui.Bar):
  50.     def Activate(self):
  51.         self.sub_parent.resetSwitch()
  52.         self.Status_new.SetColor(COLOR_ACTIVE)
  53.         self.sub_parent.StatusBar.SetColor(COLOR_ACTIVE)
  54.         self.sub_parent.StatusText.SetText("Activ")
  55.         self.Starter.SetText("Opreste schimbarea ("+str(self.index+1)+")")
  56.         self.sub_parent.boni_active = 1
  57.         if self.parentWindow.parentWindow.gameWindow != None:
  58.             self.sub_parent.blockBar.swib_normal.SetColor(COLOR_ACTIVE)
  59.         pass
  60.     def Deactivate(self):
  61.         self.sub_parent.resetSwitch()
  62.         self.Status_new.SetColor(COLOR_INACTIVE)
  63.         self.sub_parent.StatusBar.SetColor(COLOR_INACTIVE)
  64.         self.sub_parent.StatusText.SetText("Dezactivati")
  65.         self.Starter.SetText("Incepeti schimbarea ("+str(self.index+1)+")")
  66.         self.sub_parent.boni_active = 0
  67.         if self.sub_parent.parentWindow.parentWindow.gameWindow != None:
  68.             self.sub_parent.blockBar.swib_normal.SetColor(COLOR_INACTIVE)
  69.         pass
  70.    
  71.     def Activate_rare(self):
  72.         self.sub_parent.resetSwitch_rare()
  73.         self.sub_parent.StatusBar_rare.SetColor(COLOR_ACTIVE_RARE)
  74.         self.sub_parent.StatusText_rare.SetText("6/7 Activ")
  75.         self.Starter_rare_boni.SetText("Opreste 6/7")
  76.         self.sub_parent.boni_rare_active = 1
  77.         if self.parentWindow.parentWindow.gameWindow != None:
  78.             self.sub_parent.blockBar.swib_rare.SetColor(COLOR_ACTIVE_RARE)
  79.         pass
  80.     def Deactivate_rare(self):
  81.         self.sub_parent.resetSwitch_rare()
  82.         # self.Status_new.SetColor(COLOR_INACTIVE)
  83.         self.sub_parent.StatusBar_rare.SetColor(COLOR_INACTIVE_RARE)
  84.         self.sub_parent.StatusText_rare.SetText("6/7 inactiv")
  85.         self.Starter_rare_boni.SetText("alege 6/7")
  86.         self.Starter_rare_boni.SetUp()
  87.         self.sub_parent.boni_rare_active = 0
  88.         if self.sub_parent.parentWindow.parentWindow.gameWindow != None:
  89.             self.sub_parent.blockBar.swib_rare.SetColor(COLOR_INACTIVE_RARE)
  90.         pass
  91.        
  92.     def Finish(self):
  93.         self.Status_new.SetColor(COLOR_FINISHED)
  94.         self.sub_parent.StatusBar.SetColor(COLOR_FINISHED)
  95.         self.sub_parent.StatusText.SetText("Terminat !")
  96.         self.Starter.SetText("Bonusul ("+str(self.index+1)+") a fost schimbat.")
  97.         self.sub_parent.boni_active = 0
  98.         if self.sub_parent.parentWindow.parentWindow.gameWindow != None:
  99.             self.sub_parent.blockBar.swib_normal.SetColor(COLOR_FINISHED)
  100.         pass
  101.        
  102.     def Finish_rare(self):
  103.         # self.Status_new.SetColor(COLOR_FINISHED)
  104.         self.sub_parent.StatusBar_rare.SetColor(COLOR_FINISHED)
  105.         self.sub_parent.StatusText_rare.SetText("6/7 terminat")
  106.         self.Starter_rare_boni.SetText("6/7 schimbat")
  107.         self.sub_parent.boni_rare_active = 0
  108.         if self.sub_parent.parentWindow.parentWindow.gameWindow != None:
  109.             self.sub_parent.blockBar.swib_rare.SetColor(COLOR_FINISHED)
  110.         pass
  111.     def Block(self):
  112.         self.BlockBar.Show()
  113.         self.Starter.Hide()
  114.         pass
  115.     def Unblock(self):
  116.         self.BlockBar.Hide()
  117.         self.Starter.Show()
  118.         pass
  119.        
  120.        
  121.     def enable_rare_boni(self):
  122.         for i in range(0,4):
  123.             self.boni[6][i].Show()
  124.             self.boni[7][i].Show()
  125.         self.Starter.SetPosition(0,140+45)
  126.         self.bg_rare_boni.Show()
  127.         self.bg_rare_boni_but.Show()
  128.         self.Starter_rare_boni.Show()
  129.         self.sub_parent.StatusBar_rare.Show()
  130.        
  131.         if self.sub_parent.parentWindow.parentWindow.gameWindow != None:
  132.             self.sub_parent.blockBar.Enable_rare(1)
  133.        
  134.     def disable_rare_boni(self):
  135.         for i in range(0,4):
  136.             self.boni[6][i].Hide()
  137.             self.boni[7][i].Hide()
  138.         self.Starter.SetPosition(0,140)
  139.         self.bg_rare_boni.Hide()
  140.         self.bg_rare_boni_but.Hide()
  141.         self.Starter_rare_boni.Hide()
  142.         self.sub_parent.StatusBar_rare.Hide()
  143.         self.Deactivate_rare()
  144.         if self.sub_parent.parentWindow.parentWindow.gameWindow != None:
  145.             self.sub_parent.blockBar.Enable_rare(0)
  146.        
  147.     def __init__(self,sub_parent):
  148.         ui.Bar.__init__(self, "UI")
  149.         self.sub_parent = sub_parent
  150.         self.index = sub_parent.index
  151.         self.SetColor(COLOR_BG)
  152.         self.SetSize(500,225+10)
  153.         self.boni = {}
  154.         self.Status_new = ui.Bar()
  155.         self.Status_new.SetParent(self)
  156.         self.Status_new.SetColor(COLOR_INACTIVE)
  157.         self.Status_new.SetSize(500,5)
  158.         self.Status_new.Show()
  159.        
  160.        
  161.         self.bg_rare_boni = ui.Bar()
  162.         self.bg_rare_boni.SetColor(COLOR_HIGHLIGHT_RARE)
  163.         self.bg_rare_boni.SetParent(self)
  164.         self.bg_rare_boni.SetPosition(0,132)
  165.         self.bg_rare_boni.SetSize(500,51)
  166.         self.bg_rare_boni.Hide()
  167.        
  168.         self.bg_rare_boni_but = ui.Bar()
  169.         self.bg_rare_boni_but.SetColor(COLOR_HIGHLIGHT_RARE)
  170.         self.bg_rare_boni_but.SetParent(self)
  171.         self.bg_rare_boni_but.SetPosition(400,133+50)
  172.         self.bg_rare_boni_but.SetSize(100,25)
  173.         self.bg_rare_boni_but.Hide()
  174.        
  175.         self.EnableRareBoni = CheckBox("Schimbare 6/7")
  176.         self.EnableRareBoni.SetParent(self)
  177.         self.EnableRareBoni.SetPosition(10,185)
  178.         self.EnableRareBoni.eventUp   = self.disable_rare_boni
  179.         self.EnableRareBoni.eventDown = self.enable_rare_boni
  180.         self.EnableRareBoni.Show()
  181.        
  182.         self.Starter = ui.ToggleButton()
  183.         self.Starter.SetWindowHorizontalAlignCenter()
  184.         self.Starter.SetParent(self)
  185.         self.Starter.SetUpVisual("d:/ymir work/ui/public/XLarge_Button_01.sub")
  186.         self.Starter.SetOverVisual("d:/ymir work/ui/public/XLarge_button_02.sub")
  187.         self.Starter.SetDownVisual("d:/ymir work/ui/public/XLarge_button_03.sub")
  188.         self.Starter.SetPosition(0,140)
  189.         self.Starter.SetText("Alege")
  190.         self.Starter.SetToggleDownEvent(self.Activate)
  191.         self.Starter.SetToggleUpEvent(self.Deactivate)
  192.         self.Starter.Show()
  193.        
  194.         self.Starter_rare_boni = ui.ToggleButton()
  195.         self.Starter_rare_boni.SetWindowHorizontalAlignCenter()
  196.         self.Starter_rare_boni.SetParent(self)
  197.         self.Starter_rare_boni.SetUpVisual("d:/ymir work/ui/public/Large_Button_01.sub")
  198.         self.Starter_rare_boni.SetOverVisual("d:/ymir work/ui/public/Large_button_02.sub")
  199.         self.Starter_rare_boni.SetDownVisual("d:/ymir work/ui/public/Large_button_03.sub")
  200.         self.Starter_rare_boni.SetPosition(200,140+45)
  201.         self.Starter_rare_boni.SetText("Uruchom 6/7")
  202.         self.Starter_rare_boni.SetToggleDownEvent(self.Activate_rare)
  203.         self.Starter_rare_boni.SetToggleUpEvent(self.Deactivate_rare)
  204.         self.Starter_rare_boni.Hide()
  205.        
  206.         for i in range(7,5,-1):
  207.             vas = i
  208.             self.boni[vas] = {}
  209.             self.boni[vas][0] = ui.TextLine()
  210.             self.boni[vas][0].SetParent(self)
  211.             self.boni[vas][0].SetText("Bonus "+str(vas))
  212.             self.boni[vas][0].SetPosition(15,10+25*(vas-1))
  213.             self.boni[vas][0].Hide()
  214.             self.boni[vas][1] = DropDown(self,"- alege bonus -")
  215.             self.boni[vas][1].SetPosition(70,10+25*(vas-1))
  216.             for x in AFFECT_DICT:
  217.                 if x in BONI_RARE_AVAIL:
  218.                     self.boni[vas][1].AppendItem(str(AFFECT_DICT[x](0)),x)
  219.             self.boni[vas][1].SetSize(330,20)
  220.             self.boni[vas][1].Hide()
  221.             self.boni[vas][2] = ui.Bar("UI")
  222.             self.boni[vas][2].SetParent(self)
  223.             self.boni[vas][2].SetPosition(410,10+25*(vas-1))
  224.             self.boni[vas][2].SetColor(0xC0000000)
  225.             self.boni[vas][2].SetSize(80,20)
  226.             self.boni[vas][2].Hide()
  227.             self.boni[vas][3] = Edit2("0",14)
  228.             self.boni[vas][3].SetParent(self.boni[vas][2])
  229.             self.boni[vas][3].SetNumberMode()
  230.             self.boni[vas][3].SetSize(80,20)
  231.             self.boni[vas][3].SetPosition(4,3)
  232.             self.boni[vas][3].Hide()
  233.        
  234.         for i in range(0,5):
  235.             vas = 5-i
  236.             self.boni[vas] = {}
  237.             self.boni[vas][0] = ui.TextLine()
  238.             self.boni[vas][0].SetParent(self)
  239.             self.boni[vas][0].SetText("Bonus "+str(vas))
  240.             self.boni[vas][0].SetPosition(15,10+25*(vas-1))
  241.             self.boni[vas][0].Show()
  242.             self.boni[vas][1] = DropDown(self,"- alege bonus -")
  243.             self.boni[vas][1].SetPosition(70,10+25*(vas-1))
  244.             for x in AFFECT_DICT:
  245.                 if x in BONI_AVAIL:
  246.                     self.boni[vas][1].AppendItem(str(AFFECT_DICT[x](0)),x)
  247.             self.boni[vas][1].SetSize(330,20)
  248.             self.boni[vas][1].Show()
  249.             self.boni[vas][2] = ui.Bar("UI")
  250.             self.boni[vas][2].SetParent(self)
  251.             self.boni[vas][2].SetPosition(410,10+25*(vas-1))
  252.             self.boni[vas][2].SetColor(0xC0000000)
  253.             self.boni[vas][2].SetSize(80,20)
  254.             self.boni[vas][2].Show()
  255.             self.boni[vas][3] = Edit2("0",14)
  256.             self.boni[vas][3].SetParent(self.boni[vas][2])
  257.             self.boni[vas][3].SetNumberMode()
  258.             self.boni[vas][3].SetSize(80,20)
  259.             self.boni[vas][3].SetPosition(4,3)
  260.             self.boni[vas][3].Show()
  261.        
  262.            
  263.         self.BlockBar = ui.Bar()
  264.         self.BlockBar.SetParent(self)
  265.         self.BlockBar.SetColor(COLOR_INACTIVE)
  266.         self.BlockBar.SetPosition(0,5)
  267.         self.BlockBar.SetSize(500,170-5+35+2)
  268.         self.BlockBar.Hide()
  269.        
  270.         self.BlockText = ui.TextLine()
  271.         self.BlockText.SetParent(self.BlockBar)
  272.         self.BlockText.SetWindowHorizontalAlignCenter()
  273.         self.BlockText.SetHorizontalAlignCenter()
  274.         self.BlockText.SetPosition(0,140)
  275.         self.BlockText.SetText("Nu puteti schimba bonusurile pe acest obiect.")
  276.         self.BlockText.Show()
  277.        
  278.        
  279.            
  280.        
  281. class ItemTabBar(ui.Window):
  282.    
  283.     class BlockBar(ui.Window):
  284.         size_res = 32
  285.         multi = 1
  286.         def SetSize(self,i=1):
  287.             self.multi = i
  288.             ui.Window.SetSize(self,self.size_res,self.size_res*i)
  289.             if self.rare_enabled == 1:
  290.                 self.swib_normal.SetSize(self.size_res,self.size_res*i/3*2)
  291.                 pos1 = int(1.0*self.size_res*i/3.0*2.0)
  292.                 self.swib_normal.SetSize(self.size_res,pos1)
  293.                 self.swib_rare.SetSize(self.size_res,self.size_res*i-pos1)
  294.                 self.swib_rare.SetPosition(0,pos1)
  295.                 self.swib_rare.Show()
  296.             else:
  297.                 self.swib_normal.SetSize(self.size_res,self.size_res*i)
  298.                 self.swib_rare.Hide()
  299.            
  300.         def Enable_rare(self,o = 1):
  301.             self.rare_enabled = o
  302.             self.SetSize(self.multi)
  303.            
  304.         def __init__(self):
  305.             ui.Window.__init__(self)
  306.             self.rare_enabled = 0
  307.             self.swib_normal = ui.Bar()
  308.             self.swib_normal.SetParent(self)
  309.             self.swib_normal.SetSize(self.size_res,self.size_res*self.multi)
  310.             self.swib_normal.SetColor(COLOR_INACTIVE)
  311.             self.swib_normal.SetPosition(0,0)
  312.             self.swib_normal.Show()
  313.            
  314.             self.swib_rare = ui.Bar()
  315.             self.swib_rare.SetParent(self)
  316.             self.swib_rare.SetSize(self.size_res,self.size_res)
  317.             self.swib_rare.SetColor(COLOR_INACTIVE_RARE)
  318.             self.swib_rare.SetPosition(0,0)
  319.             self.swib_rare.Hide()
  320.             self.SetSize(1)
  321.            
  322.    
  323.     class ItemTab(ui.Bar):
  324.         dist  = 25
  325.         width = 80
  326.         height_selected   = 36*3+8
  327.         height_unselected = 36*3+5
  328.        
  329.         def Destroy(self):
  330.             self.parentWindow.parentWindow.but_deactivate_all.SetParent(self.parentWindow.parentWindow)
  331.             self.parentWindow.parentWindow.enable_rebuy.SetParent(self.parentWindow.parentWindow)
  332.             self.parentWindow.parentWindow.but_speed.SetParent(self.parentWindow.parentWindow)
  333.             self.parentWindow.parentWindow.but_deactivate_all.Hide()
  334.             self.parentWindow.parentWindow.enable_rebuy.Hide()
  335.             self.parentWindow.parentWindow.but_speed.Hide()
  336.            
  337.             self.bonusSelector.Hide()
  338.             self.bonusSelector.__del__()
  339.             self.Hide()
  340.             self.__del__()
  341.        
  342.         def DeleteMe(self):
  343.             self.parentWindow.DeleteTab(self.tabnum)
  344.        
  345.         def __init__(self,parent,tabnum,index = 0):
  346.             ui.Bar.__init__(self)
  347.             self.SetColor(COLOR_BG)
  348.             self.SetSize(self.width,self.height_unselected)
  349.             self.index = index
  350.             self.tabnum = tabnum
  351.             self.vnum = 0
  352.             self.count = 0
  353.             self.count_rare = 0
  354.             self.parentWindow = parent
  355.             self.SetParent(parent)
  356.            
  357.             if self.parentWindow.parentWindow.gameWindow != None:
  358.                 self.blockBar = ItemTabBar.BlockBar()
  359.                 self.blockBar.SetParent(self.parentWindow.parentWindow.gameWindow.interface.wndInventory.wndItem)
  360.                 ipi = self.parentWindow.parentWindow.gameWindow.interface.wndInventory.inventoryPageIndex
  361.                 self.blockBar.Show()
  362.                 ip2 = self.index - ipi*45
  363.                 self.blockBar.SetPosition(((ip2-int(ip2/5)*5)*self.blockBar.size_res),int(ip2/5)*self.blockBar.size_res)
  364.            
  365.             self.ItemIcon = ui.ImageBox()
  366.             self.ItemIcon.SetParent(self)
  367.             self.ItemIcon.AddFlag("not_pick")
  368.             self.ItemIcon.SetWindowHorizontalAlignCenter()
  369.             self.ItemIcon.SetWindowVerticalAlignCenter()
  370.             self.ItemIcon.Show()
  371.            
  372.             self.SlotName = ui.TextLine()
  373.             self.SlotName.SetParent(self)
  374.             self.SlotName.SetWindowHorizontalAlignCenter()
  375.             self.SlotName.SetHorizontalAlignCenter()
  376.             self.SlotName.SetPosition(0,5)
  377.             self.SlotName.SetText("Slot %d" % (self.index+1))
  378.             self.SlotName.AddFlag("not_pick")
  379.             self.SlotName.Show()
  380.            
  381.             self.StatusBar = Bar() # Special Bar
  382.             self.StatusBar.SetParent(self)
  383.             self.StatusBar.SetWindowVerticalAlignBottom()
  384.             self.StatusBar.SetSize(self.width,20)
  385.             self.StatusBar.SetPosition(0,20)
  386.             self.StatusBar.SetColor(COLOR_INACTIVE)
  387.             self.StatusBar.AddFlag("not_pick")
  388.             self.StatusBar.Show()
  389.            
  390.             self.StatusText = ui.TextLine()
  391.             self.StatusText.SetParent(self.StatusBar)
  392.             # self.StatusText.SetParent(self)
  393.             self.StatusText.SetWindowHorizontalAlignCenter()
  394.             self.StatusText.SetWindowVerticalAlignCenter()
  395.             self.StatusText.SetHorizontalAlignCenter()
  396.             self.StatusText.SetVerticalAlignCenter()
  397.             self.StatusText.SetPosition(0,0)
  398.             self.StatusText.SetText("Inactiv")
  399.             self.StatusText.Show()
  400.            
  401.            
  402.             self.StatusBar_rare = Bar() # Special Bar
  403.             self.StatusBar_rare.SetParent(self)
  404.             self.StatusBar_rare.SetWindowVerticalAlignBottom()
  405.             self.StatusBar_rare.SetSize(self.width,20)
  406.             self.StatusBar_rare.SetPosition(0,40)
  407.             self.StatusBar_rare.SetColor(COLOR_INACTIVE_RARE)
  408.             self.StatusBar_rare.AddFlag("not_pick")
  409.             self.StatusBar_rare.Hide()
  410.            
  411.             self.StatusText_rare = ui.TextLine()
  412.             self.StatusText_rare.SetParent(self.StatusBar_rare)
  413.             self.StatusText_rare.SetWindowHorizontalAlignCenter()
  414.             self.StatusText_rare.SetWindowVerticalAlignCenter()
  415.             self.StatusText_rare.SetHorizontalAlignCenter()
  416.             self.StatusText_rare.SetVerticalAlignCenter()
  417.             self.StatusText_rare.SetPosition(0,0)
  418.             self.StatusText_rare.SetText("6/7 Inactiv")
  419.             self.StatusText_rare.Show()
  420.            
  421.            
  422.             self.CloseBut = ui.Button()
  423.             self.CloseBut.SetParent(self)
  424.             self.CloseBut.SetUpVisual("d:/ymir work/ui/public/close_button_01.sub")
  425.             self.CloseBut.SetOverVisual("d:/ymir work/ui/public/close_button_02.sub")
  426.             self.CloseBut.SetDownVisual("d:/ymir work/ui/public/close_button_03.sub")
  427.             self.CloseBut.SetToolTipText("Zamknij kartê", 0, -23)
  428.             self.CloseBut.SetEvent(self.DeleteMe)
  429.             self.CloseBut.SetPosition(0,0)
  430.             self.CloseBut.Show()
  431.            
  432.        
  433.            
  434.             self.OnMouseLeftButtonDown = lambda: self.Select()
  435.            
  436.             self.boni_active = 0
  437.             self.boni_rare_active = 0
  438.            
  439.             self.bonusSelector = BonusSelector(self)
  440.             self.bonusSelector.SetParentProxy(self.parentWindow.parentWindow)
  441.             self.bonusSelector.SetPosition(10,35+36*3+4*2)
  442.             self.bonusSelector.Hide()
  443.            
  444.             self.SetIndex(index)
  445.            
  446.             self.resetSwitch()
  447.             self.resetSwitch_rare()
  448.  
  449.         def IsActive(self):
  450.             return self.boni_active == 1
  451.         def IsActive_rare(self):
  452.             return self.boni_rare_active == 1
  453.            
  454.         def SetParentProxy(self,parent):
  455.             ui.Bar.SetParentProxy(self,parent)
  456.         def Select(self):
  457.             for a in self.parentWindow.tabList:
  458.                 self.parentWindow.tabList[a].UnSelect()
  459.                 self.parentWindow.tabList[a].bonusSelector.Hide()
  460.             self.bonusSelector.Show()
  461.             self.SetSize(self.width,self.height_selected)
  462.             self.Update()
  463.             self.parentWindow.parentWindow.but_deactivate_all.SetParent(self.bonusSelector)
  464.             self.parentWindow.parentWindow.but_deactivate_all.SetPosition(415-10,200+10)
  465.             self.parentWindow.parentWindow.but_deactivate_all.Show()
  466.             self.parentWindow.parentWindow.enable_rebuy.SetParent(self.bonusSelector)
  467.             self.parentWindow.parentWindow.enable_rebuy.SetPosition(10,200+10)
  468.             self.parentWindow.parentWindow.enable_rebuy.Show()
  469.             self.parentWindow.parentWindow.but_speed.SetParent(self.bonusSelector)
  470.             self.parentWindow.parentWindow.but_speed.SetPosition(0,205+10)
  471.             self.parentWindow.parentWindow.but_speed.Show()
  472.            
  473.            
  474.         def UnSelect(self):
  475.             self.SetSize(self.width,self.height_unselected)
  476.             self.Update()
  477.            
  478.         def Update(self):
  479.             self.StatusBar.SetPosition(0,20)
  480.             self.SetPosition((self.width+self.dist)*self.tabnum,0)
  481.             self.SlotName.SetText("Slot %d" % (self.index+1))
  482.            
  483.         def resetSwitch(self):
  484.             self.values = [0,0,0,0,0]
  485.         def resetSwitch_rare(self):
  486.             self.values_rare = [0,0]
  487.        
  488.         # last_switch = -1
  489.         rebuyed = 0
  490.         def nachkauf(self):
  491.             if self.parentWindow.parentWindow.buyed != 0:
  492.                 return
  493.             else:
  494.                 self.parentWindow.parentWindow.buyed = 1
  495.             if self.parentWindow.parentWindow.enable_rebuy.checked == 1:
  496.                 for i in range(0,shop.SHOP_SLOT_COUNT):
  497.                     me = shop.GetItemID(i)
  498.                     if me == SWITCH_VNUM:
  499.                         if shop.GetItemPrice(i) > player.GetMoney():
  500.                             # chat.AppendChat(1,"-- Switchitem gefunden! Aber wir haben kein Geld :(")
  501.                             self.bonusSelector.Deactivate()
  502.                             return
  503.                         else:
  504.                             net.SendShopBuyPacket(i)
  505.                             self.rebuyed = 1
  506.                             # self.Switch()
  507.                             return
  508.                            
  509.         rebuyed_rare = 0
  510.         def nachkauf_rare(self):
  511.             if self.parentWindow.parentWindow.buyed_rare != 0:
  512.                 return
  513.             else:
  514.                 self.parentWindow.parentWindow.buyed_rare = 1
  515.             if self.parentWindow.parentWindow.enable_rebuy.checked == 1:
  516.                 for i in range(0,shop.SHOP_SLOT_COUNT):
  517.                     me = shop.GetItemID(i)
  518.                     if me == SWITCH_RARE_VNUM:
  519.                         if shop.GetItemPrice(i) > player.GetMoney():
  520.                             # chat.AppendChat(1,"-- Switchitem gefunden! Aber wir haben kein Geld :(")
  521.                             self.bonusSelector.Deactivate_rare()
  522.                             return
  523.                         else:
  524.                             net.SendShopBuyPacket(i)
  525.                             self.rebuyed_rare = 1
  526.                             # self.Switch()
  527.                             return
  528.             # self.bonusSelector.Deactivate()
  529.        
  530.         def Switch_rare(self):
  531.             lc = 0
  532.             for i in range(0,90*2):
  533.                 if player.GetItemIndex(i) == SWITCH_RARE_VNUM:
  534.                     lc+=player.GetItemCount(i)
  535.                    
  536.             if lc == 0 and self.parentWindow.parentWindow.enable_rebuy.checked == 0:
  537.                 chat.AppendChat(2,"Slot %d: 6/7 Schimbarea anulata! Nici o schimbare la bonusuri 6/7!" % (self.index+1))
  538.                 self.bonusSelector.Deactivate_rare()
  539.                 return
  540.            
  541.             if lc < 15:
  542.                 self.nachkauf_rare()
  543.            
  544.             if lc == 0:
  545.                 self.bonusSelector.Deactivate_rare()
  546.                 chat.AppendChat(2,"Slot %d: 6/7 Schimbarea anulata! Nici o schimbare la bonusuri 6/7!" % (self.index+1))
  547.                 return
  548.            
  549.             for i in range(0,90*2):
  550.                 if player.GetItemIndex(i) == SWITCH_RARE_VNUM:
  551.                     net.SendItemUseToItemPacket(i,self.index)
  552.                     return
  553.        
  554.         def Switch(self):
  555.             lc = 0
  556.             for i in range(0,90*2):
  557.                 if player.GetItemIndex(i) == SWITCH_VNUM:
  558.                     lc+=player.GetItemCount(i)
  559.            
  560.             if lc == 0 and self.parentWindow.parentWindow.enable_rebuy.checked == 0:
  561.                 self.bonusSelector.Deactivate()
  562.                 return
  563.            
  564.             if lc < 15:
  565.                 self.nachkauf()
  566.                
  567.             if lc == 0:
  568.                 self.bonusSelector.Deactivate()
  569.                 return
  570.  
  571.             for i in range(0,90*2):
  572.                 if player.GetItemIndex(i) == SWITCH_VNUM:
  573.                     net.SendItemUseToItemPacket(i,self.index)
  574.                     return
  575.             # self.nachkauf()
  576.            
  577.         def checkSwitch(self):
  578.             ok = 0
  579.             for i in range(0,5):
  580.                 if player.GetItemAttribute(self.index, i) != self.values[i]:
  581.                     ok = 1
  582.             self.prob = self.GetProb()
  583.             self.StatusText.SetText("Activ (%d%%)" %self.prob)
  584.             if ok == 1 or self.prob >= 90:
  585.                 if self.prob >= 90:
  586.                     chat.AppendChat(1,"Slot %d: Schimbarea completa!" % (self.index+1))
  587.                     self.bonusSelector.Finish()
  588.                     return
  589.                 self.values  = [player.GetItemAttribute(self.index, i) for i in range(0,5)]
  590.                 self.Switch()
  591.             elif self.rebuyed > 0:
  592.                 self.rebuyed = 0
  593.                 self.Switch()
  594.             elif ok == 0 and self.count < 5:
  595.                 self.count+=1
  596.             elif ok == 0 and self.count >= 5:
  597.                 self.count = 0
  598.                 self.Switch()
  599.             # elif self.last_switch > -1 and player.GetItemCount(self.last_switch) == 0:
  600.             # chat.AppendChat(2,"%d"%player.GetItemCount(self.last_switch))
  601.                 # self.last_switch = 0
  602.                 # self.Switch()
  603.             # else:
  604.                 # if self.GetProb() != 100:
  605.                     # self.Switch()
  606.             pass
  607.        
  608.         def checkSwitch_rare(self):
  609.             ok = 0
  610.             for i in range(0,2):
  611.                 if player.GetItemAttribute(self.index, i+6) != self.values_rare[i]:
  612.                     ok = 1
  613.             self.prob_rare = self.GetProb_rare()
  614.             self.StatusText_rare.SetText("Activ (%d%%)" %self.prob_rare)
  615.             if ok == 1 or self.prob_rare >= 90:
  616.                 if self.prob_rare >= 90:
  617.                     self.bonusSelector.Finish_rare()
  618.                     chat.AppendChat(1,"Terminat !" % (self.index+1))
  619.                     return
  620.                 self.values_rare  = [player.GetItemAttribute(self.index, i) for i in range(5,7)]
  621.                 self.Switch_rare()
  622.             elif self.rebuyed_rare > 0:
  623.                 self.rebuyed_rare = 0
  624.                 self.Switch_rare()
  625.             elif ok == 0 and self.count_rare < 5:
  626.                 self.count_rare+=1
  627.             elif ok == 0 and self.count_rare >= 5:
  628.                 self.count_rare = 0
  629.                 self.Switch_rare()
  630.                
  631.             pass
  632.         def UpdateItem(self):
  633.             # try:
  634.             vnum = player.GetItemIndex(self.index)
  635.             if vnum == 0:
  636.                 self.resetSwitch()
  637.                 self.resetSwitch_rare()
  638.                 self.vnum = 0
  639.                 self.bonusSelector.Deactivate()
  640.                 self.bonusSelector.Block()
  641.                 self.ItemIcon.Hide()
  642.                 if self.parentWindow.parentWindow.gameWindow != None:
  643.                     self.blockBar.SetSize(1)
  644.                 return
  645.             elif vnum != self.vnum:
  646.                 self.resetSwitch()
  647.                 self.resetSwitch_rare()
  648.                 self.vnum = vnum
  649.                 self.bonusSelector.Deactivate()
  650.                 item.SelectItem(self.vnum)
  651.                 if self.parentWindow.parentWindow.gameWindow != None:
  652.                     (w,h) = item.GetItemSize()
  653.                     self.blockBar.SetSize(h)
  654.                
  655.                 if item.GetItemType() != 1 and item.GetItemType() != 2:
  656.                     self.bonusSelector.Block()
  657.                 else:
  658.                     self.bonusSelector.Unblock()
  659.                
  660.                
  661.                 self.ItemIcon.Show()
  662.                 self.ItemIcon.LoadImage(item.GetIconImageFileName())
  663.                 # self.values = [player.GetItemAttribute(self.index, i) for i in range(0,5)]
  664.                 return
  665.             if self.IsActive():
  666.                 self.checkSwitch()
  667.                
  668.             if self.IsActive_rare():
  669.                 self.checkSwitch_rare()
  670.                
  671.             # except:
  672.                 # pass
  673.            
  674.         def SetIndex(self,index):
  675.             self.index = index
  676.             self.bonusSelector.index = index
  677.             self.bonusSelector.Starter.SetText("Schimbare  ("+str(index+1)+") pornita")
  678.             self.Update()
  679.             self.UpdateItem()
  680.            
  681.         def GetProb_rare(self):
  682.             values = [player.GetItemAttribute(self.index, i+6) for i in range(0,2)]
  683.             val2 = {}
  684.             for i in range(0,2):
  685.                 try:
  686.                     affectString = AFFECT_DICT[values[i][0]](values[i][1])
  687.                     val2[values[i][0]] = values[i][1]
  688.                     self.bonusSelector.ibi[i+6].SetText(affectString)
  689.                 except:
  690.                     pass
  691.             prob = 0
  692.             max  = 0
  693.            
  694.             yp = self.GenList_rare()
  695.             for x in yp:
  696.                 if yp[x] in val2 and val2[yp[x]] >= int(self.bonusSelector.boni[x+5][3].GetText()):
  697.                     prob = prob+1
  698.                 max = max+1
  699.             if max > 0:
  700.                 prozent = 100/max*prob
  701.             else:
  702.                 prozent = 100
  703.             return prozent
  704.             pass
  705.         def GetProb(self):
  706.             values = [player.GetItemAttribute(self.index, i) for i in range(0,5)]
  707.             val2 = {}
  708.             # for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  709.             for i in range(0,5):
  710.                 try:
  711.                     affectString = AFFECT_DICT[values[i][0]](values[i][1])
  712.                     val2[values[i][0]] = values[i][1]
  713.                     self.bonusSelector.ibi[i].SetText(affectString)
  714.                 except:
  715.                     pass
  716.             prob = 0
  717.             max  = 0
  718.             yp = self.GenList()
  719.             for x in yp:
  720.                 if yp[x] in val2 and val2[yp[x]] >= int(self.bonusSelector.boni[x][3].GetText()):
  721.                     prob = prob+1
  722.                 max = max+1
  723.             if max > 0:
  724.                 prozent = 100/max*prob
  725.             else:
  726.                 prozent = 100
  727.             return prozent
  728.            
  729.         def GenList(self):
  730.             ret = {}
  731.             for i in range(0,5):
  732.                 if self.bonusSelector.boni[5-i][1].selected.value != 0:
  733.                     ret[5-i] = self.bonusSelector.boni[5-i][1].selected.value
  734.             return ret
  735.         def GenList_rare(self):
  736.             ret = {}
  737.             for i in range(0,2):
  738.                 if self.bonusSelector.boni[6+i][1].selected.value != 0:
  739.                     ret[i+1] = self.bonusSelector.boni[6+i][1].selected.value
  740.             return ret
  741.            
  742.     def __init__(self,parent):
  743.         ui.Window.__init__(self)
  744.         self.SetSize(500,36*3+4*2)
  745.         self.tabCount = 0
  746.         self.tabList = {}
  747.        
  748.         self.parentWindow = parent
  749.         self.SetParent(parent)
  750.         self.plusBar = ui.Bar()
  751.         self.plusBar.SetParent(self)
  752.         self.plusBar.SetSize(90,30)
  753.         self.plusBar.SetWindowVerticalAlignCenter()
  754.         self.plusBar.SetColor(COLOR_BG)
  755.         # self.plusBar.OnMouseLeftButtonDown = lambda: self.AddTab_pre()
  756.         self.plusBar.OnMouseLeftButtonUp = lambda: self.AddTab_pre()
  757.         self.plusBar.SetPosition(30,0)
  758.         self.plusBar.Show()
  759.        
  760.         self.AddText = ui.TextLine()
  761.         self.AddText.SetParent(self.plusBar)
  762.         self.AddText.SetText("Pune itemul aici .")
  763.         self.AddText.SetWindowVerticalAlignCenter()
  764.         self.AddText.SetWindowHorizontalAlignCenter()
  765.         self.AddText.SetVerticalAlignCenter()
  766.         self.AddText.SetHorizontalAlignCenter()
  767.         self.AddText.SetPosition(0,0)
  768.         self.AddText.Show()
  769.        
  770.        
  771.        
  772.     def DeleteTab(self,id):
  773.         if self.parentWindow.gameWindow != None:
  774.             self.tabList[id].blockBar.Hide()
  775.             self.tabList[id].blockBar.Destroy()
  776.         self.tabList[id].Destroy()
  777.         # del self.tabList[id]
  778.         self.tabCount = self.tabCount -1
  779.         if self.tabCount > id and id < 5:
  780.             for i in xrange(id,self.tabCount):
  781.                 self.tabList[i] = self.tabList[i+1]
  782.                 self.tabList[i].tabnum = i
  783.                 self.tabList[i].SetPosition((self.tabList[i].width+self.tabList[i].dist)*i,0)
  784.                
  785.             del self.tabList[self.tabCount]
  786.            
  787.         else:
  788.             del self.tabList[id]
  789.            
  790.        
  791.         if self.tabCount > 0:
  792.             self.tabList[0].Select()
  793.        
  794.         if (self.ItemTab.width+self.ItemTab.dist)*self.tabCount < 20:
  795.             self.parentWindow.SetSize(520,387-210)
  796.             self.parentWindow.but_speed.Hide()
  797.             self.plusBar.SetPosition(20,0)
  798.         else:
  799.             self.plusBar.SetPosition((self.ItemTab.width+self.ItemTab.dist)*self.tabCount-10,0)
  800.         self.plusBar.Show()
  801.        
  802.     def AddTab_pre(self):
  803.         if mouseModule.mouseController.isAttached():
  804.             attachedSlotType = mouseModule.mouseController.GetAttachedType()
  805.             attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  806.             attachedSlotVnum = mouseModule.mouseController.GetAttachedItemIndex()
  807.            
  808.             item.SelectItem(attachedSlotVnum)
  809.             if item.GetItemType() != 1 and item.GetItemType() != 2:
  810.                 mouseModule.mouseController.DeattachObject()
  811.                 chat.AppendChat(2,"Nu puteti schimba bonusurile pe acest obiect.")
  812.                 return
  813.                
  814.             if attachedSlotPos > 89:
  815.                 mouseModule.mouseController.DeattachObject()
  816.                 chat.AppendChat(2,"Nu puteti modifica elementele de pe acest obiect.")
  817.                 return
  818.            
  819.             for a in self.tabList:
  820.                 if self.tabList[a].index == attachedSlotPos:
  821.                     mouseModule.mouseController.DeattachObject()
  822.                     chat.AppendChat(2,"Schimbarea obiectului este deja activat.")
  823.                     return
  824.                
  825.                
  826.             if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  827.                 self.AddTab(attachedSlotPos)
  828.                 chat.AppendChat(2,"Obiectul a fost adaugat")
  829.  
  830.             mouseModule.mouseController.DeattachObject()
  831.        
  832.     def AddTab(self,id):
  833.         if self.tabCount < MAX_NUM:
  834.             self.tabList[self.tabCount] = self.ItemTab(self,self.tabCount,id)
  835.            
  836.             self.tabList[self.tabCount].Select()
  837.             self.tabList[self.tabCount].Show()
  838.             self.tabCount+= 1
  839.             if (self.ItemTab.width+self.ItemTab.dist)*self.tabCount < 20:
  840.                 self.plusBar.SetPosition(20,0)
  841.             else:
  842.                 self.plusBar.SetPosition((self.ItemTab.width+self.ItemTab.dist)*self.tabCount-10,0)
  843.        
  844.         if self.tabCount == MAX_NUM:
  845.             self.plusBar.Hide()
  846.            
  847.         self.parentWindow.SetSize(520,387+10)
  848.         self.parentWindow.but_speed.Show()
  849.             # return 0
  850.  
  851. class Bot(ui.BoardWithTitleBar):
  852.     class PinGroup(ui.Bar):
  853.         def OnUpdate(self):
  854.             self.parent.OnUpdate()
  855.             for c in self.txtlist:
  856.                 c.SetColor(c.item.StatusBar.color)
  857.                 c.txt2.SetText("Status: %s" % c.item.StatusText.GetText())
  858.                 try:
  859.                     c.listWin2.SetColor(c.item.StatusBar_rare.color)
  860.                     c.txt3.SetText("Status: %s" % c.item.StatusText_rare.GetText())
  861.                 except:
  862.                     pass
  863.                
  864.         def ShowMainWindow(self):
  865.             self.parent.Show()
  866.             self.__del__()
  867.         def __init__(self,parent,dir = 1):
  868.             self.parent = parent
  869.             ui.Bar.__init__(self)
  870.             # Direction: 1 = left; 2 = right; 3 = top
  871.             self.SetColor(COLOR_BG)
  872.             w,h = 100,50
  873.            
  874.            
  875.             self.maximise_but = ui.Button()
  876.             self.maximise_but.SetParent(self)
  877.             self.maximise_but.SetPosition(4,4)
  878.             self.maximise_but.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
  879.             self.maximise_but.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
  880.             self.maximise_but.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
  881.             self.maximise_but.SetText("Mariti")
  882.             self.maximise_but.SetEvent(self.ShowMainWindow)
  883.             self.maximise_but.Show()
  884.            
  885.             self.stop_but = ui.Button()
  886.             self.stop_but.SetParent(self)
  887.             self.stop_but.SetPosition(4,24)
  888.             self.stop_but.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
  889.             self.stop_but.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
  890.             self.stop_but.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
  891.             self.stop_but.SetText("Opreste toate!")
  892.             self.stop_but.SetEvent(self.parent.deactivate_all)
  893.             self.stop_but.Show()
  894.            
  895.             self.txtlist = []
  896.             for a in self.parent.itemTabBar.tabList:
  897.                 itm = self.parent.itemTabBar.tabList[a]
  898.                
  899.                 listWin = ui.Bar()
  900.                 listWin.item = itm
  901.                 self.txtlist.append(listWin)
  902.                 listWin.SetColor(itm.StatusBar.color)
  903.                 listWin.SetParent(self)
  904.                 listWin.Show()
  905.                
  906.                 listWin.txt1 = ui.TextLine()
  907.                 listWin.txt1.SetParent(listWin)
  908.                 listWin.txt1.SetText("Slot %d:" %(itm.index+1))
  909.                 listWin.txt1.Show()
  910.                 listWin.txt1.SetPosition(4,2)
  911.                
  912.                 listWin.txt2 = ui.TextLine()
  913.                 listWin.txt2.SetParent(listWin)
  914.                 listWin.txt2.SetText("Status: %s" % itm.StatusText.GetText())
  915.                 listWin.txt2.SetPosition(4,2+12)
  916.                 listWin.txt2.Show()
  917.                
  918.                 listWin.listWin2 = ui.Bar()
  919.                 listWin.listWin2.SetColor(itm.StatusBar_rare.color)
  920.                 listWin.listWin2.SetParent(listWin)
  921.                 listWin.listWin2.SetPosition(0,4+12+12)
  922.                 listWin.listWin2.SetSize(w,12+2)
  923.                 listWin.listWin2.Hide()
  924.                
  925.                 listWin.txt3 = ui.TextLine()
  926.                 listWin.txt3.SetParent(listWin.listWin2)
  927.                 listWin.txt3.SetText("Status: %s" % itm.StatusText_rare.GetText())
  928.                 listWin.txt3.SetPosition(4,0)
  929.                 listWin.txt3.Hide()
  930.                
  931.                 if dir >= 3:
  932.                     listWin.SetPosition(w,4)
  933.                     listWin.SetSize(90,h-8)
  934.                     w+=92
  935.                     if itm.bonusSelector.EnableRareBoni.checked == 1:
  936.                         w+=15
  937.                         listWin.SetSize(105,4+12+12)
  938.                         listWin.listWin2.SetSize(105,14)
  939.                         listWin.listWin2.Show()
  940.                         listWin.txt3.Show()
  941.                 else:
  942.                     listWin.SetPosition(0,h)
  943.                     listWin.SetSize(w,4+12+12+2)
  944.                    
  945.                     if itm.bonusSelector.EnableRareBoni.checked == 1:
  946.                         listWin.SetSize(w,4+12+12)
  947.                         listWin.listWin2.Show()
  948.                         listWin.txt3.Show()
  949.                         # itl.append(txt3)
  950.                         h+=12
  951.                         pass
  952.                    
  953.                     h+=4+12+12+4
  954.                 # else:
  955.                    
  956.                 # self.txtlist.append(itl)
  957.            
  958.             self.SetSize(w,h)
  959.            
  960.             if dir == 1 or dir == 2:
  961.                 self.SetWindowVerticalAlignCenter()
  962.             elif dir == 3:
  963.                 self.SetWindowVerticalAlignTop()
  964.             else:
  965.                 self.SetWindowVerticalAlignBottom()
  966.             if dir == 1:
  967.                 self.SetWindowHorizontalAlignLeft()
  968.                 self.SetPosition(0,0)
  969.             elif dir == 2:
  970.                 self.SetWindowHorizontalAlignRight()
  971.                 self.SetPosition(self.GetWidth(),0)
  972.             elif dir == 3:
  973.                 self.SetWindowHorizontalAlignCenter()
  974.                 self.SetPosition(0,0)
  975.             elif dir == 4:
  976.                 self.SetWindowHorizontalAlignCenter()
  977.                 self.SetPosition(0,36+h)
  978.             else:
  979.                 return # ERR
  980.                
  981.    
  982.     pinhint = 0
  983.     def ShowPinHint(self,type):
  984.         self.pinhint = type
  985.         if type == 0:
  986.             self.PinHint.Hide()
  987.             return
  988.         # type=2
  989.         (x,y) = self.GetGlobalPosition()
  990.         if type == 1:  # Left
  991.             self.PinHint.SetWindowHorizontalAlignLeft()
  992.             #self.PinHint.SetWindowVerticalAlignCenter()
  993.             self.PinHint.SetSize(30,wndMgr.GetScreenHeight())
  994.             self.PinHint.SetPosition(0,y)
  995.         elif type == 2: # Right
  996.             self.PinHint.SetWindowHorizontalAlignRight()
  997.             #self.PinHint.SetWindowVerticalAlignCenter()
  998.             self.PinHint.SetSize(30,wndMgr.GetScreenHeight())
  999.             self.PinHint.SetPosition(30,y)
  1000.         elif type == 3: # Top
  1001.             #self.PinHint.SetWindowHorizontalAlignCenter()
  1002.             self.PinHint.SetWindowVerticalAlignTop()
  1003.             self.PinHint.SetSize(wndMgr.GetScreenWidth(),30)
  1004.             self.PinHint.SetPosition(x,0)
  1005.         elif type == 4: # Top
  1006.             #self.PinHint.SetWindowHorizontalAlignCenter()
  1007.             self.PinHint.SetWindowVerticalAlignBottom()
  1008.             self.PinHint.SetSize(wndMgr.GetScreenWidth(),30)
  1009.             self.PinHint.SetPosition(x,36+30)
  1010.         self.PinHint.Show()
  1011.         # else:
  1012.            
  1013.    
  1014.     def __init__(self):
  1015.         ui.BoardWithTitleBar.__init__(self)
  1016.         self.gameWindow = None
  1017.        
  1018.         self.SetTitleName("Schimbator de Bonusuri")
  1019.         self.AddFlag("float")
  1020.         self.AddFlag("movable")
  1021.         self.SetPosition(30,30)
  1022.         # self.SetSize(520,387)
  1023.         # self.SetSize(520,387-210)
  1024.         self.SetSize(520,387-210)
  1025.        
  1026.         self.PinHint = ui.Bar()
  1027.         self.PinHint.SetColor(COLOR_PIN_HINT)
  1028.         self.PinHint.Show()
  1029.        
  1030.         self.OnMouseLeftButtonDown = self.drag_start
  1031.         self.OnMouseLeftButtonUp   = self.drag_end     
  1032.        
  1033.         self.but_deactivate_all = ui.Button()
  1034.         self.but_deactivate_all.SetParent(self)
  1035.         # self.but_deactivate_all.SetPosition(415,350)
  1036.         self.but_deactivate_all.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
  1037.         self.but_deactivate_all.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
  1038.         self.but_deactivate_all.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
  1039.         self.but_deactivate_all.SetText("Inchide")
  1040.         self.but_deactivate_all.SetEvent(self.deactivate_all)
  1041.         self.but_deactivate_all.Hide()
  1042.        
  1043.         self.enable_rebuy = CheckBox("Activati cumparare")
  1044.         self.enable_rebuy.Toggle()
  1045.         self.enable_rebuy.Hide()
  1046.        
  1047.         self.but_speed = ui.SliderBar()
  1048.         self.but_speed.SetParent(self)
  1049.         self.but_speed.SetWindowHorizontalAlignCenter()
  1050.         self.but_speed.SetPosition(0,360)
  1051.         self.but_speed.SetSliderPos(0.0)
  1052.         # self.but_speed.SetToolTipText("Switch-Geschwindigkeit", 0, -23)
  1053.         # self.but_speed.Show()
  1054.         self.but_speed.Hide()
  1055.        
  1056.         self.itemTabBar = ItemTabBar(self)
  1057.         self.itemTabBar.SetPosition(10,35)
  1058.         self.itemTabBar.Show()
  1059.        
  1060.        
  1061.         self.buyed = 0
  1062.         self.buyed_rare = 0
  1063.        
  1064.         self.SetCloseEvent(self._Hide)
  1065.        
  1066.         self.Hide = self._Hide
  1067.        
  1068.     def Show(self):
  1069.         ui.BoardWithTitleBar.Show(self)
  1070.         self.bot_shown = 1
  1071.        
  1072.     def _Hide(self):
  1073.         ## ONLY FOR TESTING
  1074.         for a in range(0,self.itemTabBar.tabCount):
  1075.             self.itemTabBar.DeleteTab(0)
  1076.        
  1077.         ui.BoardWithTitleBar.Hide(self)
  1078.         self.bot_shown = 0
  1079.        
  1080.        
  1081.     def deactivate_all(self):
  1082.         for a in self.itemTabBar.tabList:
  1083.             self.itemTabBar.tabList[a].bonusSelector.Starter.SetUp()
  1084.             self.itemTabBar.tabList[a].bonusSelector.Starter.OnToggleUp()
  1085.             self.itemTabBar.tabList[a].bonusSelector.Starter_rare_boni.SetUp()
  1086.             self.itemTabBar.tabList[a].bonusSelector.Starter_rare_boni.OnToggleUp()
  1087.         pass
  1088.        
  1089.     drag = 0
  1090.     def drag_start(self):
  1091.         self.drag = 1
  1092.        
  1093.     def drag_end(self):
  1094.         self.drag = 0
  1095.         if self.pinhint > 0:
  1096.             self.PinShow(self.pinhint)
  1097.             # self.PinGroupBox = self.PinGroup()
  1098.             pass
  1099.         self.ShowPinHint(0)
  1100.        
  1101.     def PinShow(self,dir):
  1102.         self.PinGroupBox = self.PinGroup(self,dir)
  1103.         self.Hide()
  1104.         self.PinGroupBox.Show()
  1105.        
  1106.     def EnableInventoryTweak(self,gameWindow):
  1107.         self.gameWindow=gameWindow
  1108.         self.gameWindow.interface.wndInventory.inventoryTab[0].SetEvent(lambda arg=0: self.__SetInventoryPage(arg))
  1109.         self.gameWindow.interface.wndInventory.inventoryTab[1].SetEvent(lambda arg=1: self.__SetInventoryPage(arg))
  1110.     def __SetInventoryPage(self,arg):
  1111.         self.gameWindow.interface.wndInventory.SetInventoryPage(arg)
  1112.         for a in self.itemTabBar.tabList:
  1113.             itm = self.itemTabBar.tabList[a]
  1114.             if itm.index >= arg*45 and itm.index < (arg+1)*45:
  1115.                 itm.blockBar.Show()
  1116.             else:
  1117.                 itm.blockBar.Hide()
  1118.     counter = 0
  1119.     def OnUpdate(self):
  1120.         if self.drag == 1:
  1121.             x1, y1 = self.GetGlobalPosition()
  1122.             if x1 < 30:
  1123.                 self.ShowPinHint(1)
  1124.             elif wndMgr.GetScreenWidth()-x1-520 < 30:
  1125.                 self.ShowPinHint(2)
  1126.             elif y1 < 30:
  1127.                 self.ShowPinHint(3)
  1128.             elif wndMgr.GetScreenHeight()-y1-self.GetHeight() < 60:
  1129.                 self.ShowPinHint(4)
  1130.             else:
  1131.                 self.ShowPinHint(0)
  1132.             # self.SetPosition(x1+(x-self.drag_pos[0]),y1)
  1133.             pass
  1134.        
  1135.         if self.gameWindow != None:
  1136.             for a in self.itemTabBar.tabList:
  1137.                 itm = self.itemTabBar.tabList[a]
  1138.            
  1139.            
  1140.            
  1141.         self.counter+=1
  1142.         if self.counter >= int(self.but_speed.GetSliderPos()*MAX_SWITCH_DELAY_APPEND+MIN_SWITCH_DELAY):
  1143.             self.buyed = 0
  1144.             self.buyed_rare = 0
  1145.             self.counter = 0
  1146.             for a in self.itemTabBar.tabList:
  1147.                 itm = self.itemTabBar.tabList[a]
  1148.                 itm.UpdateItem()
  1149.                 # if itm.
  1150.        
  1151.    
  1152. class DropDown(ui.Window):
  1153.     dropped  = 0
  1154.     dropstat = 0
  1155.     last = 0
  1156.     lastS = 0
  1157.     maxh = 95
  1158.     OnChange = None
  1159.     class Item(ui.ListBoxEx.Item):
  1160.         def __init__(self,parent, text,value=0):
  1161.             ui.ListBoxEx.Item.__init__(self)
  1162.  
  1163.             self.textBox=ui.TextLine()
  1164.             self.textBox.SetParent(self)
  1165.             self.textBox.SetText(text)
  1166.             # self.textBox.SetLimitWidth(parent.GetWidth()-132)
  1167.             self.textBox.Show()
  1168.             self.value = value
  1169.         def GetValue(self):
  1170.             return self.value
  1171.         def __del__(self):
  1172.             ui.ListBoxEx.Item.__del__(self)
  1173.            
  1174.     def __init__(self,parent,tt = ""):
  1175.         ui.Window.__init__(self,"TOP_MOST")
  1176.         self.SetParentProxy(parent)
  1177.         self.bg = ui.Bar("TOP_MOST")
  1178.         self.bg.SetParent(self)
  1179.         self.bg.SetPosition(0,0)
  1180.         self.bg.SetColor(0xc0000000)
  1181.         self.bg.OnMouseOverIn = self.bgMouseIn
  1182.         self.bg.OnMouseOverOut = self.bgMouseOut
  1183.         self.bg.OnMouseLeftButtonDown = self.ExpandMe
  1184.         self.bg.Show()
  1185.         self.act = ui.TextLine()
  1186.         self.act.SetParent(self.bg)
  1187.         self.act.SetPosition(4,2)
  1188.         self.act.SetText(tt)
  1189.         self.act.Show()
  1190.         self.GetText = self.act.GetText
  1191.        
  1192.         self.Drop = ui.Bar("TOP_MOST")
  1193.         self.Drop.SetParent(self.GetParentProxy())
  1194.         self.Drop.SetPosition(0,21)
  1195.         # self.Drop.SetSize(150,95)
  1196.         self.Drop.SetSize(150,0)
  1197.         # self.Drop.SetColor(0xc00a0a0a)
  1198.         self.Drop.SetColor(0xff0a0a0a)
  1199.        
  1200.        
  1201.         self.ScrollBar = ui.ThinScrollBar()
  1202.         self.ScrollBar.SetParent(self.Drop)
  1203.         self.ScrollBar.SetPosition(132,0)
  1204.         # self.ScrollBar.SetScrollBarSize(95)
  1205.         self.ScrollBar.SetScrollBarSize(0)
  1206.         self.ScrollBar.Show()
  1207.        
  1208.         self.DropList = ui.ListBoxEx()
  1209.         self.DropList.SetParent(self.Drop)
  1210.         self.DropList.itemHeight = 12
  1211.         self.DropList.itemStep = 13
  1212.         self.DropList.SetPosition(0,0)
  1213.         self.DropList.SetSize(132,self.maxh)
  1214.         self.DropList.SetScrollBar(self.ScrollBar)
  1215.         self.DropList.SetSelectEvent(self.SetTitle)
  1216.         self.DropList.SetViewItemCount(0)
  1217.         self.DropList.Show()
  1218.         if tt != "":
  1219.             self.AppendItemAndSelect(tt)
  1220.         self.selected = self.DropList.GetSelectedItem()
  1221.        
  1222.            
  1223.         self.SetSize(120,20)
  1224.     def __del__(self):
  1225.         ui.Window.__del__(self)
  1226.     def AppendItem(self,text,value=0):
  1227.         self.DropList.AppendItem(self.Item(self,text,value))
  1228.     def AppendItemAndSelect(self,text,value=0):
  1229.         self.DropList.AppendItem(self.Item(self,text,value))
  1230.         self.DropList.SelectIndex(len(self.DropList.itemList)-1)
  1231.     def SetTitle(self,item):
  1232.         self.act.SetText(str(item.textBox.GetText()))
  1233.         self.last = self.DropList.basePos
  1234.         self.lastS = self.ScrollBar.GetPos()
  1235.         self.dropped = 0
  1236.         self.selected = item
  1237.         if self.OnChange:
  1238.             self.OnChange()
  1239.         # self.Drop.Hide()
  1240.        
  1241.     def SetPosition(self,w,h):
  1242.         ui.Window.SetPosition(self,w,h)
  1243.         self.Drop.SetPosition(w,h+21)
  1244.        
  1245.     def SetSize(self,w,h):
  1246.         ui.Window.SetSize(self,w,h)
  1247.         self.bg.SetSize(w,h)
  1248.         self.Drop.SetSize(w,0)
  1249.         self.DropList.SetSize(w-18,self.maxh)
  1250.         for x in self.DropList.itemList:
  1251.             x.SetSize(w-18,12)
  1252.         self.ScrollBar.SetPosition(w-18,0)
  1253.        
  1254.        
  1255.     def ExpandMe(self):
  1256.         if self.dropped == 1:
  1257.             # self.Drop.Hide()
  1258.             self.dropped = 0
  1259.         else:
  1260.             # self.Drop.Show()
  1261.             self.dropped = 1
  1262.            
  1263.     def OnUpdate(self):
  1264.         iter = 6
  1265.         if self.dropped == 0 and self.dropstat == 1:
  1266.             if self.Drop.GetHeight() <=0:
  1267.                 self.dropstat = 0
  1268.                 self.Drop.SetSize(self.Drop.GetWidth(),0)
  1269.                 self.ScrollBar.SetScrollBarSize(self.Drop.GetHeight())
  1270.                 self.Drop.Hide()
  1271.             else:
  1272.                 if self.Drop.GetHeight()-iter < 0:
  1273.                     self.Drop.SetSize(self.Drop.GetWidth(),0)
  1274.                 else:
  1275.                     self.Drop.SetSize(self.Drop.GetWidth(),self.Drop.GetHeight()-iter)
  1276.                    
  1277.                 self.ScrollBar.SetScrollBarSize(self.Drop.GetHeight())
  1278.             self.DropList.SetViewItemCount(int(self.Drop.GetHeight()/13))
  1279.             self.DropList.SetBasePos(self.last+1)
  1280.             self.DropList.SetBasePos(self.last)
  1281.         elif self.dropped == 1 and self.dropstat == 0:
  1282.             self.Drop.Show()
  1283.             self.SetTop()
  1284.             if self.Drop.GetHeight() >=self.maxh:
  1285.                 self.Drop.SetSize(self.Drop.GetWidth(),self.maxh)
  1286.                 self.ScrollBar.SetScrollBarSize(self.maxh)
  1287.                 self.dropstat = 1
  1288.                 self.DropList.SetViewItemCount(7)
  1289.                 self.ScrollBar.SetPos(self.lastS)
  1290.             else:
  1291.                 self.ScrollBar.SetScrollBarSize(self.Drop.GetHeight()+iter)
  1292.                 self.Drop.SetSize(self.Drop.GetWidth(),self.Drop.GetHeight()+iter)
  1293.             self.DropList.SetViewItemCount(int(self.Drop.GetHeight()/13))
  1294.             self.DropList.SetBasePos(self.last+1)
  1295.             self.DropList.SetBasePos(self.last)
  1296.        
  1297.     ## BG Hover
  1298.     def bgMouseIn(self):
  1299.         self.bg.SetColor(0xc00a0a0a)
  1300.     def bgMouseOut(self):
  1301.         self.bg.SetColor(0xc0000000)
  1302.        
  1303.  
  1304. class Edit2(ui.EditLine):
  1305.     def __init__(self,main = "",ml = 99):
  1306.         ui.EditLine.__init__(self)
  1307.         self.SetText(main)
  1308.         self.main = main
  1309.         self.SetMax(ml)
  1310.         self.SetUserMax(ml)
  1311.     def GetText(self):
  1312.         res = ui.EditLine.GetText(self)
  1313.         if res == "":
  1314.             return "0"
  1315.         else:
  1316.             return res
  1317.            
  1318.     def __del__(self):
  1319.         ui.EditLine.__del__(self)
  1320.     def OnSetFocus(self):
  1321.         ui.EditLine.OnSetFocus(self)
  1322.         if ui.EditLine.GetText(self) == self.main:
  1323.             self.SetText("")
  1324.     def OnKillFocus(self):
  1325.         ui.EditLine.OnKillFocus(self)
  1326.         if ui.EditLine.GetText(self) == "":
  1327.             self.SetText(self.main)
  1328.            
  1329.  
  1330. class CheckBox(ui.Window):
  1331.     checked = 0
  1332.     eventUp  =None
  1333.     eventDown=None
  1334.     def __init__(self,cont = ""):
  1335.         ui.Window.__init__(self)
  1336.         self.BG = ui.Bar("UI")
  1337.         self.BG.SetParent(self)
  1338.         self.BG.SetPosition(0,0)
  1339.         self.BG.SetSize(20,20)
  1340.         # self.BG.SetColor(0xc00b0b0b)
  1341.         self.BG.SetColor(0xc02b0b0b)
  1342.         self.BG.OnMouseLeftButtonUp = self.Toggle
  1343.         self.OnMouseLeftButtonUp = self.Toggle
  1344.         self.BG.Show()
  1345.         self.Title = ui.TextLine()
  1346.         self.Title.SetParent(self)
  1347.         self.Title.SetPosition(25,2)
  1348.         self.Title.SetText(cont)
  1349.         self.Title.Show()
  1350.         self.stat = ui.TextLine()
  1351.         self.stat.SetParent(self.BG)
  1352.         self.stat.SetPosition(0,0)
  1353.         self.stat.SetWindowHorizontalAlignCenter()
  1354.         self.stat.SetWindowVerticalAlignCenter()
  1355.         self.stat.SetHorizontalAlignCenter()
  1356.         self.stat.SetVerticalAlignCenter()
  1357.         self.stat.SetSize(0,0)
  1358.         self.stat.SetText("")
  1359.         self.SetSize(25+self.Title.GetTextSize()[0]+5,20)
  1360.         self.stat.Show()
  1361.     def __del__(self):
  1362.         ui.ToggleButton.__del__(self)
  1363.     def Toggle(self):
  1364.         if self.checked == 1:
  1365.             self.OnToggleUp()
  1366.         else:
  1367.             self.OnToggleDown()
  1368.     def OnToggleUp(self):
  1369.         self.stat.SetText("")
  1370.         # self.BG.SetColor(0xc00b0b0b)
  1371.         self.BG.SetColor(0xc02b0b0b)
  1372.         self.checked = 0
  1373.         if self.eventUp:
  1374.             self.eventUp()
  1375.     def OnToggleDown(self):
  1376.         # self.BG.SetColor(0xf00b0b0b)
  1377.         self.BG.SetColor(0xf00b2b0b)
  1378.         self.stat.SetText("X")
  1379.         self.checked = 1
  1380.         if self.eventDown:
  1381.             self.eventDown()
  1382.  
  1383.            
  1384. # Zum Testen
  1385. # a = Bot()
  1386. # a.Show()
  1387.  
  1388. # oder;
  1389. # Bot().Show()
Advertisement
Add Comment
Please, Sign In to add comment