Advertisement
Guest User

switchbot.py

a guest
Apr 6th, 2020
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 59.40 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. import game
  12. import ui
  13.  
  14. from uitooltip import ItemToolTip
  15. # Switchbot by Mijago ; v 2.2.1
  16.  
  17. WEAR_NAMES = ItemToolTip.WEAR_NAMES
  18. AFFECT_DICT = ItemToolTip.AFFECT_DICT
  19.  
  20. ### Hier die Boni angeben, die auf dem Server aktiviert sind. Die angegebene Liste ist nur ein Beispiel und MUSS angepasst werden!
  21. BONI_AVAIL = [1,2,3,4,5,6,9,10,12,13,14,15,16,17,18,19,20,21,22,23,27,28,29,30,31,32,33,34,35,37,39,41,43,44,45,48,53,71,72]
  22.  
  23. # Hier 6/7 Boni angeben!
  24. BONI_RARE_AVAIL = [1,3,4,5,6,59,60,61,62,63]
  25.  
  26. # Das Switch-Item
  27. SWITCH_VNUM = 71084
  28. SWITCH_RARE_VNUM = 71052
  29.  
  30. # Die folgenden zahlen geben den MINMAX Bereich des Reglers an, der die Zeit angibt.
  31. MIN_SWITCH_DELAY = 35
  32. MAX_SWITCH_DELAY_APPEND = 120
  33.  
  34. # Max 10!!
  35. MAX_NUM = 7
  36.  
  37. proposals = {
  38.     1: { # 1 = Weapon
  39.         "PVP (Corp)":[
  40.             [9,10],
  41.             [15,15],
  42.             [17,15],
  43.             [16,15],
  44.             [5,10],
  45.             [3,10],
  46.         ],
  47.         "PVP (Mental)":[
  48.             [9,10],
  49.             [15,15],
  50.             [17,15],
  51.             [6,10],
  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("Switch ("+str(self.index+1)+") STOP")
  129.         self.sub_parent.boni_active = 1
  130.         if self.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("Switch ("+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 Oprit")
  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 Pornit")
  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("Terminat")
  169.         self.Starter.SetText("Itemul ("+str(self.index+1)+") terminat")
  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 Terminat")
  179.         self.Starter_rare_boni.SetText("6/7 Terminat")
  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,240+42)
  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+103)
  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.        
  251.  
  252.         self.EnableRareBoni = CheckBox("Bonusurile 6/7")
  253.         self.EnableRareBoni.SetParent(self)
  254.         self.EnableRareBoni.SetPosition(10,283)
  255.         self.EnableRareBoni.eventUp   = self.disable_rare_boni
  256.         self.EnableRareBoni.eventDown = self.enable_rare_boni
  257.         self.EnableRareBoni.Show()
  258.        
  259.         self.Starter = ui.ToggleButton()
  260.         self.Starter.SetWindowHorizontalAlignCenter()
  261.         self.Starter.SetParent(self)
  262.         self.Starter.SetUpVisual("d:/ymir work/ui/public/XLarge_Button_01.sub")
  263.         self.Starter.SetOverVisual("d:/ymir work/ui/public/XLarge_button_02.sub")
  264.         self.Starter.SetDownVisual("d:/ymir work/ui/public/XLarge_button_03.sub")
  265.         self.Starter.SetPosition(0,140)
  266.         self.Starter.SetText("6/7 porneste")
  267.         self.Starter.SetToggleDownEvent(self.Activate)
  268.         self.Starter.SetToggleUpEvent(self.Deactivate)
  269.         self.Starter.Show()
  270.        
  271.         self.Starter_rare_boni = ui.ToggleButton()
  272.         self.Starter_rare_boni.SetWindowHorizontalAlignCenter()
  273.         self.Starter_rare_boni.SetParent(self)
  274.         self.Starter_rare_boni.SetUpVisual("d:/ymir work/ui/public/Large_Button_01.sub")
  275.         self.Starter_rare_boni.SetOverVisual("d:/ymir work/ui/public/Large_button_02.sub")
  276.         self.Starter_rare_boni.SetDownVisual("d:/ymir work/ui/public/Large_button_03.sub")
  277.         self.Starter_rare_boni.SetPosition(200,139+45)
  278.         self.Starter_rare_boni.SetText("6/7 porneste")
  279.         self.Starter_rare_boni.SetToggleDownEvent(self.Activate_rare)
  280.         self.Starter_rare_boni.SetToggleUpEvent(self.Deactivate_rare)
  281.         self.Starter_rare_boni.Hide()
  282.        
  283.         for i in range(7,5,-1):
  284.             vas = i
  285.             self.boni[vas] = {}
  286.             self.boni[vas][0] = ui.TextLine()
  287.             self.boni[vas][0].SetParent(self)
  288.             self.boni[vas][0].SetText("Bonus "+str(vas))
  289.             self.boni[vas][0].SetPosition(15,10+25*(vas-1))
  290.             self.boni[vas][0].Hide()
  291.             self.boni[vas][1] = DropDown(self,"- alege bonusul -")
  292.             self.boni[vas][1].SetPosition(70,10+25*(vas-1))
  293.             for x in AFFECT_DICT:
  294.                 if x in BONI_RARE_AVAIL:
  295.                     self.boni[vas][1].AppendItem(str(AFFECT_DICT[x](0)),x)
  296.             self.boni[vas][1].SetSize(330,20)
  297.             self.boni[vas][1].Hide()
  298.             self.boni[vas][2] = ui.Bar("UI")
  299.             self.boni[vas][2].SetParent(self)
  300.             self.boni[vas][2].SetPosition(410,10+25*(vas-1))
  301.             self.boni[vas][2].SetColor(0xC0000000)
  302.             self.boni[vas][2].SetSize(80,20)
  303.             self.boni[vas][2].Hide()
  304.             self.boni[vas][3] = Edit2("0",14)
  305.             self.boni[vas][3].SetParent(self.boni[vas][2])
  306.             self.boni[vas][3].SetNumberMode()
  307.             self.boni[vas][3].SetSize(80,20)
  308.             self.boni[vas][3].SetPosition(4,3)
  309.             self.boni[vas][3].Hide()
  310.        
  311.         for i in range(0,5):
  312.             vas = 5-i
  313.             self.boni[vas] = {}
  314.             self.boni[vas][0] = ui.TextLine()
  315.             self.boni[vas][0].SetParent(self)
  316.             self.boni[vas][0].SetText("Bonus "+str(vas))
  317.             self.boni[vas][0].SetPosition(15,10+25*(vas-1))
  318.             self.boni[vas][0].Show()
  319.             self.boni[vas][1] = DropDown(self,"- alege bonusul -")
  320.             self.boni[vas][1].SetPosition(70,10+25*(vas-1))
  321.             for x in AFFECT_DICT:
  322.                 if x in BONI_AVAIL:
  323.                     self.boni[vas][1].AppendItem(str(AFFECT_DICT[x](0)),x)
  324.             self.boni[vas][1].SetSize(330,20)
  325.             self.boni[vas][1].Show()
  326.             self.boni[vas][2] = ui.Bar("UI")
  327.             self.boni[vas][2].SetParent(self)
  328.             self.boni[vas][2].SetPosition(410,10+25*(vas-1))
  329.             self.boni[vas][2].SetColor(0xC0000000)
  330.             self.boni[vas][2].SetSize(80,20)
  331.             self.boni[vas][2].Show()
  332.             self.boni[vas][3] = Edit2("0",14)
  333.             self.boni[vas][3].SetParent(self.boni[vas][2])
  334.             self.boni[vas][3].SetNumberMode()
  335.             self.boni[vas][3].SetSize(80,20)
  336.             self.boni[vas][3].SetPosition(4,3)
  337.             self.boni[vas][3].Show()
  338.        
  339.         self.but_propose = DropDown(self,'Sugestii',0)
  340.         self.but_propose.SetParent(self)
  341.         self.but_propose.SetPosition(380,304)
  342.         self.but_propose.OnChange=self.change_boni
  343.         self.but_propose.Show()
  344.            
  345.         self.BlockBar = ui.Bar()
  346.         self.BlockBar.SetParent(self)
  347.         self.BlockBar.SetColor(COLOR_INACTIVE)
  348.         self.BlockBar.SetPosition(0,5)
  349.         self.BlockBar.SetSize(500,170-5+35+2)
  350.         self.BlockBar.Hide()
  351.        
  352.         self.BlockBar.sub = ui.Bar()
  353.         self.BlockBar.sub.SetParent(self)
  354.         self.BlockBar.sub.SetColor(COLOR_INACTIVE)
  355.         self.BlockBar.sub.SetPosition(500-122,5+170-5+35+2)
  356.         self.BlockBar.sub.SetSize(122,30)
  357.         self.BlockBar.sub.Hide()
  358.        
  359.         self.BlockText = ui.TextLine()
  360.         self.BlockText.SetParent(self.BlockBar)
  361.         self.BlockText.SetWindowHorizontalAlignCenter()
  362.         self.BlockText.SetHorizontalAlignCenter()
  363.         self.BlockText.SetPosition(0,240)
  364.         self.BlockText.SetText("La acest item nu se pot schimba bonusurile.")
  365.         self.BlockText.Show()
  366.        
  367.        
  368.         self.prepare_propose()
  369.        
  370.     def change_boni(self):
  371.         use = self.but_propose.DropList.GetSelectedItem().value
  372.         bon = 1
  373.         item.SelectItem(self.sub_parent.vnum)
  374.         for x in use:
  375.             # TODO: Check if bonus exists on item!!
  376.             ok = 1
  377.             for i in xrange(item.ITEM_APPLY_MAX_NUM):
  378.                 (affectType, affectValue) = item.GetAffect(i)
  379.                 if affectType == x[0]:
  380.                     ok = 0
  381.             if ok == 0:
  382.                 continue
  383.             y = self.boni[bon][1]
  384.             y.SelectByAffectId(x[0])
  385.             self.boni[bon][1].act.SetText(y.DropList.GetSelectedItem().textBox.GetText())
  386.             self.boni[bon][3].SetText(str(x[1]))
  387.             bon+=1
  388.  
  389.         for x in range(bon,6):
  390.             y = self.boni[x][1].DropList
  391.             y.SelectIndex(0)
  392.             self.boni[x][1].act.SetText(y.GetSelectedItem().textBox.GetText())
  393.             self.boni[x][3].SetText("0")
  394.            
  395.        
  396.     def prepare_propose(self):
  397.         self.but_propose.DropList.RemoveAllItems()
  398.         self.but_propose.maxh = 95
  399.         self.but_propose.c = 0
  400.         self.but_propose.AppendItem("Gol",[])
  401.        
  402.         item.SelectItem(self.sub_parent.vnum)
  403.         type = item.GetItemType()
  404.        
  405.         use = proposals[type]
  406.         if type == 2:
  407.             use = use[item.GetItemSubType()]
  408.        
  409.         for prop in use:
  410.             self.but_propose.AppendItem(prop,use[prop])
  411.            
  412.        
  413.            
  414.        
  415. class ItemTabBar(ui.Window):
  416.    
  417.     class BlockBar(ui.Window):
  418.         size_res = 32
  419.         multi = 1
  420.         def SetSize(self,i=1):
  421.             self.multi = i
  422.             ui.Window.SetSize(self,self.size_res,self.size_res*i)
  423.             if self.rare_enabled == 1:
  424.                 self.swib_normal.SetSize(self.size_res,self.size_res*i/3*2)
  425.                 pos1 = int(1.0*self.size_res*i/3.0*2.0)
  426.                 self.swib_normal.SetSize(self.size_res,pos1)
  427.                 self.swib_rare.SetSize(self.size_res,self.size_res*i-pos1)
  428.                 self.swib_rare.SetPosition(0,pos1)
  429.                 self.swib_rare.Show()
  430.             else:
  431.                 self.swib_normal.SetSize(self.size_res,self.size_res*i)
  432.                 self.swib_rare.Hide()
  433.            
  434.         def Enable_rare(self,o = 1):
  435.             self.rare_enabled = o
  436.             self.SetSize(self.multi)
  437.            
  438.         def __init__(self):
  439.             ui.Window.__init__(self)
  440.             self.rare_enabled = 0
  441.             self.swib_normal = ui.Bar()
  442.             self.swib_normal.SetParent(self)
  443.             self.swib_normal.SetSize(self.size_res,self.size_res*self.multi)
  444.             self.swib_normal.SetColor(COLOR_INACTIVE)
  445.             self.swib_normal.SetPosition(0,0)
  446.             self.swib_normal.Show()
  447.            
  448.             self.swib_rare = ui.Bar()
  449.             self.swib_rare.SetParent(self)
  450.             self.swib_rare.SetSize(self.size_res,self.size_res)
  451.             self.swib_rare.SetColor(COLOR_INACTIVE_RARE)
  452.             self.swib_rare.SetPosition(0,0)
  453.             self.swib_rare.Hide()
  454.             self.SetSize(1)
  455.            
  456.    
  457.     class ItemTab(ui.Bar):
  458.        
  459.         height_selected   = 36*3+8
  460.         height_unselected = 36*3+5
  461.        
  462.         def Destroy(self):
  463.             self.parentWindow.parentWindow.enable_rebuy.SetParent(self.parentWindow.parentWindow)
  464.             self.parentWindow.parentWindow.but_speed.SetParent(self.parentWindow.parentWindow)
  465.             self.parentWindow.parentWindow.help_show_rare.SetParent(self.parentWindow.parentWindow)
  466.             self.parentWindow.parentWindow.help_rebuy.SetParent(self.parentWindow.parentWindow)
  467.             # self.parentWindow.parentWindow.help_stop_all.SetParent(self.parentWindow.parentWindow)
  468.             self.parentWindow.parentWindow.help_duration.SetParent(self.parentWindow.parentWindow)
  469.             # self.parentWindow.parentWindow.but_deactivate_all.SetParent(self.parentWindow.parentWindow)
  470.             # self.parentWindow.parentWindow.but_deactivate_all.Hide()
  471.             self.parentWindow.parentWindow.enable_rebuy.Hide()
  472.             self.parentWindow.parentWindow.but_speed.Hide()
  473.            
  474.             self.bonusSelector.Hide()
  475.             self.bonusSelector.__del__()
  476.             self.Hide()
  477.             self.__del__()
  478.        
  479.         def DeleteMe(self):
  480.             self.parentWindow.DeleteTab(self.tabnum)
  481.        
  482.         def __init__(self,parent,tabnum,index = 0,vnum = 0): ## Init ItemTab
  483.             ui.Bar.__init__(self)
  484.             self.SetColor(COLOR_BG)
  485.             self.SetSize(self.width,self.height_unselected)
  486.             self.index = index
  487.             self.tabnum = tabnum
  488.             self.vnum = vnum
  489.             self.count = 0
  490.             self.count_rare = 0
  491.             self.parentWindow = parent
  492.             self.SetParent(parent)
  493.  
  494.            
  495.            
  496.             if self.parentWindow.parentWindow.gameWindow != None:
  497.                 self.blockBar = ItemTabBar.BlockBar()
  498.                 self.blockBar.SetParent(self.parentWindow.parentWindow.gameWindow.interface.wndInventory.wndItem)
  499.                 ipi = self.parentWindow.parentWindow.gameWindow.interface.wndInventory.inventoryPageIndex
  500.                 self.blockBar.Show()
  501.                 ip2 = self.index - ipi*45
  502.                 self.blockBar.SetPosition(((ip2-int(ip2/5)*5)*self.blockBar.size_res),int(ip2/5)*self.blockBar.size_res)
  503.            
  504.             self.ItemIcon = ui.ImageBox()
  505.             self.ItemIcon.SetParent(self)
  506.             self.ItemIcon.AddFlag("not_pick")
  507.             self.ItemIcon.SetWindowHorizontalAlignCenter()
  508.             self.ItemIcon.SetWindowVerticalAlignCenter()
  509.             self.ItemIcon.Show()
  510.            
  511.             self.SlotName = ui.TextLine()
  512.             self.SlotName.SetParent(self)
  513.             self.SlotName.SetWindowHorizontalAlignCenter()
  514.             self.SlotName.SetHorizontalAlignCenter()
  515.             self.SlotName.SetPosition(0,5)
  516.             self.SlotName.SetText("Slot %d" % (self.index+1))
  517.             self.SlotName.AddFlag("not_pick")
  518.             self.SlotName.Show()
  519.            
  520.             self.StatusBar = Bar() # Special Bar
  521.             self.StatusBar.SetParent(self)
  522.             self.StatusBar.SetWindowVerticalAlignBottom()
  523.             self.StatusBar.SetSize(self.width,20)
  524.             self.StatusBar.SetPosition(0,20)
  525.             self.StatusBar.SetColor(COLOR_INACTIVE)
  526.             self.StatusBar.AddFlag("not_pick")
  527.             self.StatusBar.Show()
  528.            
  529.             self.StatusText = ui.TextLine()
  530.             self.StatusText.SetParent(self.StatusBar)
  531.             # self.StatusText.SetParent(self)
  532.             self.StatusText.SetWindowHorizontalAlignCenter()
  533.             self.StatusText.SetWindowVerticalAlignCenter()
  534.             self.StatusText.SetHorizontalAlignCenter()
  535.             self.StatusText.SetVerticalAlignCenter()
  536.             self.StatusText.SetPosition(0,0)
  537.             self.StatusText.SetText("Inactiv")
  538.             self.StatusText.Show()
  539.            
  540.            
  541.             self.StatusBar_rare = Bar() # Special Bar
  542.             self.StatusBar_rare.SetParent(self)
  543.             self.StatusBar_rare.SetWindowVerticalAlignBottom()
  544.             self.StatusBar_rare.SetSize(self.width,20)
  545.             self.StatusBar_rare.SetPosition(0,40)
  546.             self.StatusBar_rare.SetColor(COLOR_INACTIVE_RARE)
  547.             self.StatusBar_rare.AddFlag("not_pick")
  548.             self.StatusBar_rare.Hide()
  549.            
  550.             self.StatusText_rare = ui.TextLine()
  551.             self.StatusText_rare.SetParent(self.StatusBar_rare)
  552.             self.StatusText_rare.SetWindowHorizontalAlignCenter()
  553.             self.StatusText_rare.SetWindowVerticalAlignCenter()
  554.             self.StatusText_rare.SetHorizontalAlignCenter()
  555.             self.StatusText_rare.SetVerticalAlignCenter()
  556.             self.StatusText_rare.SetPosition(0,0)
  557.             self.StatusText_rare.SetText("6/7 Inactiv")
  558.             self.StatusText_rare.Show()
  559.            
  560.            
  561.             self.CloseBut = ui.Button()
  562.             self.CloseBut.SetParent(self)
  563.             self.CloseBut.SetUpVisual("d:/ymir work/ui/public/close_button_01.sub")
  564.             self.CloseBut.SetOverVisual("d:/ymir work/ui/public/close_button_02.sub")
  565.             self.CloseBut.SetDownVisual("d:/ymir work/ui/public/close_button_03.sub")
  566.             self.CloseBut.SetToolTipText("Close TAB", 0, -23)
  567.             self.CloseBut.SetEvent(self.DeleteMe)
  568.             self.CloseBut.SetPosition(0,0)
  569.             self.CloseBut.Show()
  570.            
  571.        
  572.            
  573.             self.OnMouseLeftButtonDown = lambda: self.Select()
  574.            
  575.             self.boni_active = 0
  576.             self.boni_rare_active = 0
  577.            
  578.             self.bonusSelector = BonusSelector(self)
  579.             self.bonusSelector.SetParentProxy(self.parentWindow.parentWindow)
  580.             self.bonusSelector.SetPosition(10,35+36*3+4*2)
  581.             self.bonusSelector.Hide()
  582.             self.vnum = 0
  583.             self.SetIndex(index)
  584.            
  585.             self.resetSwitch()
  586.             self.resetSwitch_rare()
  587.  
  588.         def IsActive(self):
  589.             return self.boni_active == 1
  590.         def IsActive_rare(self):
  591.             return self.boni_rare_active == 1
  592.            
  593.         def SetParentProxy(self,parent):
  594.             ui.Bar.SetParentProxy(self,parent)
  595.         def Select(self):
  596.             for a in self.parentWindow.tabList:
  597.                 self.parentWindow.tabList[a].UnSelect()
  598.                 self.parentWindow.tabList[a].bonusSelector.Hide()
  599.             self.bonusSelector.Show()
  600.             self.SetSize(self.width,self.height_selected)
  601.             self.Update()
  602.             # self.parentWindow.parentWindow.but_deactivate_all.SetParent(self.bonusSelector)
  603.             # self.parentWindow.parentWindow.but_deactivate_all.SetPosition(415-10,200+10)
  604.             # self.parentWindow.parentWindow.but_deactivate_all.Show()
  605.             self.parentWindow.parentWindow.enable_rebuy.SetParent(self.bonusSelector)
  606.             self.parentWindow.parentWindow.enable_rebuy.SetPosition(10,285+20)
  607.             self.parentWindow.parentWindow.enable_rebuy.Show()
  608.             self.parentWindow.parentWindow.but_speed.SetParent(self.bonusSelector)
  609.             self.parentWindow.parentWindow.but_speed.SetPosition(0,290+20)
  610.             self.parentWindow.parentWindow.but_speed.Show()
  611.            
  612.             self.parentWindow.parentWindow.help_show_rare.SetParent(self.bonusSelector)
  613.             self.parentWindow.parentWindow.help_rebuy.SetParent(self.bonusSelector)
  614.             # self.parentWindow.parentWindow.help_stop_all.SetParent(self.bonusSelector)
  615.             self.parentWindow.parentWindow.help_duration.SetParent(self.bonusSelector)
  616.            
  617.            
  618.         def UnSelect(self):
  619.             self.SetSize(self.width,self.height_unselected)
  620.             self.Update()
  621.            
  622.         def Update(self):
  623.             self.StatusBar.SetPosition(0,20)
  624.             self.SetPosition((self.width+self.dist)*self.tabnum,0)
  625.             self.SlotName.SetText("Slot %d" % (self.index+1))
  626.            
  627.         def resetSwitch(self):
  628.             self.values = [0,0,0,0,0]
  629.         def resetSwitch_rare(self):
  630.             self.values_rare = [0,0]
  631.        
  632.         # last_switch = -1
  633.         rebuyed = 0
  634.         def nachkauf(self):
  635.             if self.parentWindow.parentWindow.buyed != 0:
  636.                 return
  637.             else:
  638.                 self.parentWindow.parentWindow.buyed = 1
  639.             if self.parentWindow.parentWindow.enable_rebuy.checked == 1:
  640.                 for i in range(0,shop.SHOP_SLOT_COUNT):
  641.                     me = shop.GetItemID(i)
  642.                     if me == SWITCH_VNUM:
  643.                         if shop.GetItemPrice(i) > player.GetMoney():
  644.                             # chat.AppendChat(1,"-- Switchitem gefunden! Aber wir haben kein Geld :(")
  645.                             self.bonusSelector.Deactivate()
  646.                             return
  647.                         else:
  648.                             net.SendShopBuyPacket(i)
  649.                             self.rebuyed = 1
  650.                             # self.Switch()
  651.                             return
  652.                            
  653.         rebuyed_rare = 0
  654.         def nachkauf_rare(self):
  655.             if self.parentWindow.parentWindow.buyed_rare != 0:
  656.                 return
  657.             else:
  658.                 self.parentWindow.parentWindow.buyed_rare = 1
  659.             if self.parentWindow.parentWindow.enable_rebuy.checked == 1:
  660.                 for i in range(0,shop.SHOP_SLOT_COUNT):
  661.                     me = shop.GetItemID(i)
  662.                     if me == SWITCH_RARE_VNUM:
  663.                         if shop.GetItemPrice(i) > player.GetMoney():
  664.                             # chat.AppendChat(1,"-- Switchitem gefunden! Aber wir haben kein Geld :(")
  665.                             self.bonusSelector.Deactivate_rare()
  666.                             return
  667.                         else:
  668.                             net.SendShopBuyPacket(i)
  669.                             self.rebuyed_rare = 1
  670.                             # self.Switch()
  671.                             return
  672.             # self.bonusSelector.Deactivate()
  673.        
  674.         def Switch_rare(self):
  675.             lc = 0
  676.             for i in range(0,90*2):
  677.                 if player.GetItemIndex(i) == SWITCH_RARE_VNUM:
  678.                     lc+=player.GetItemCount(i)
  679.                    
  680.             if lc == 0 and self.parentWindow.parentWindow.enable_rebuy.checked == 0:
  681.                 chat.AppendChat(2,"Slot %d: 6/7 Switchen abgebrochen -> Keine Switchitems & Nachkauf war nicht erfolgreich!" % (self.index+1))
  682.                 self.bonusSelector.Deactivate_rare()
  683.                 return
  684.            
  685.             if lc < 15:
  686.                 self.nachkauf_rare()
  687.            
  688.             if lc == 0:
  689.                 self.bonusSelector.Deactivate_rare()
  690.                 chat.AppendChat(2,"Slot %d: Nu aveti schimbator de 6/7 ! Cumparati!" % (self.index+1))
  691.                 return
  692.            
  693.             for i in range(0,90*2):
  694.                 if player.GetItemIndex(i) == SWITCH_RARE_VNUM:
  695.                     net.SendItemUseToItemPacket(i,self.index)
  696.                     return
  697.        
  698.         def Switch(self):
  699.             lc = 0
  700.             for i in range(0,90*2):
  701.                 if player.GetItemIndex(i) == SWITCH_VNUM:
  702.                     lc+=player.GetItemCount(i)
  703.            
  704.             if lc == 0 and self.parentWindow.parentWindow.enable_rebuy.checked == 0:
  705.                 self.bonusSelector.Deactivate()
  706.                 return
  707.            
  708.             if lc < 15:
  709.                 self.nachkauf()
  710.                
  711.             if lc == 0:
  712.                 self.bonusSelector.Deactivate()
  713.                 return
  714.  
  715.             for i in range(0,90*2):
  716.                 if player.GetItemIndex(i) == SWITCH_VNUM:
  717.                     net.SendItemUseToItemPacket(i,self.index)
  718.                     return
  719.             # self.nachkauf()
  720.            
  721.         def checkSwitch(self):
  722.             ok = 0
  723.             for i in range(0,5):
  724.                 if player.GetItemAttribute(self.index, i) != self.values[i]:
  725.                     ok = 1
  726.             self.prob = self.GetProb()
  727.             self.StatusText.SetText("Activ (%d%%)" %self.prob)
  728.             if ok == 1 or self.prob >= 90:
  729.                 if self.prob >= 90:
  730.                     chat.AppendChat(1,"Slot %d: bonusurile au fost gasit!" % (self.index+1))
  731.                     self.bonusSelector.Finish()
  732.                     return
  733.                 self.values  = [player.GetItemAttribute(self.index, i) for i in range(0,5)]
  734.                 self.Switch()
  735.             elif self.rebuyed > 0:
  736.                 self.rebuyed = 0
  737.                 self.Switch()
  738.             elif ok == 0 and self.count < 5:
  739.                 self.count+=1
  740.             elif ok == 0 and self.count >= 5:
  741.                 self.count = 0
  742.                 self.Switch()
  743.             # elif self.last_switch > -1 and player.GetItemCount(self.last_switch) == 0:
  744.             # chat.AppendChat(2,"%d"%player.GetItemCount(self.last_switch))
  745.                 # self.last_switch = 0
  746.                 # self.Switch()
  747.             # else:
  748.                 # if self.GetProb() != 100:
  749.                     # self.Switch()
  750.             pass
  751.        
  752.         def checkSwitch_rare(self):
  753.             ok = 0
  754.             for i in range(0,2):
  755.                 if player.GetItemAttribute(self.index, i+6) != self.values_rare[i]:
  756.                     ok = 1
  757.             self.prob_rare = self.GetProb_rare()
  758.             self.StatusText_rare.SetText("Activ (%d%%)" %self.prob_rare)
  759.             if ok == 1 or self.prob_rare >= 90:
  760.                 if self.prob_rare >= 90:
  761.                     self.bonusSelector.Finish_rare()
  762.                     chat.AppendChat(1,"Slot %d: bonusurile 6/7 au fost gasite!" % (self.index+1))
  763.                     return
  764.                 self.values_rare  = [player.GetItemAttribute(self.index, i) for i in range(5,7)]
  765.                 self.Switch_rare()
  766.             elif self.rebuyed_rare > 0:
  767.                 self.rebuyed_rare = 0
  768.                 self.Switch_rare()
  769.             elif ok == 0 and self.count_rare < 5:
  770.                 self.count_rare+=1
  771.             elif ok == 0 and self.count_rare >= 5:
  772.                 self.count_rare = 0
  773.                 self.Switch_rare()
  774.                
  775.             pass
  776.         def UpdateItem(self):
  777.             # try:
  778.             vnum = player.GetItemIndex(self.index)
  779.             if vnum == 0 and self.vnum != 0:
  780.                 self.resetSwitch()
  781.                 self.resetSwitch_rare()
  782.                 self.vnum = 0
  783.                 self.bonusSelector.Deactivate()
  784.                 self.bonusSelector.Block()
  785.                 self.bonusSelector.prepare_propose()
  786.                 self.ItemIcon.Hide()
  787.                 if self.parentWindow.parentWindow.gameWindow != None:
  788.                     self.blockBar.SetSize(1)
  789.                 return
  790.             elif vnum != self.vnum:
  791.                 self.resetSwitch()
  792.                 self.resetSwitch_rare()
  793.                 self.vnum = vnum
  794.                 self.bonusSelector.Deactivate()
  795.                 self.bonusSelector.prepare_propose()
  796.                 item.SelectItem(self.vnum)
  797.                 if self.parentWindow.parentWindow.gameWindow != None:
  798.                     (w,h) = item.GetItemSize()
  799.                     self.blockBar.SetSize(h)
  800.                
  801.                 if item.GetItemType() != 1 and item.GetItemType() != 2:
  802.                     self.bonusSelector.Block()
  803.                 else:
  804.                     self.bonusSelector.Unblock()
  805.                
  806.                
  807.                 self.ItemIcon.Show()
  808.                 self.ItemIcon.LoadImage(item.GetIconImageFileName())
  809.                 # self.values = [player.GetItemAttribute(self.index, i) for i in range(0,5)]
  810.                 return
  811.             if self.IsActive():
  812.                 self.checkSwitch()
  813.                
  814.             if self.IsActive_rare():
  815.                 self.checkSwitch_rare()
  816.                
  817.             # except:
  818.                 # pass
  819.            
  820.         def SetIndex(self,index):
  821.             self.index = index
  822.             self.bonusSelector.index = index
  823.             self.bonusSelector.Starter.SetText("Switch ("+str(index+1)+") Start")
  824.             self.Update()
  825.             self.UpdateItem()
  826.            
  827.         def GetProb_rare(self):
  828.             values = [player.GetItemAttribute(self.index, i+6) for i in range(0,2)]
  829.             val2 = {}
  830.             for i in range(0,2):
  831.                 try:
  832.                     affectString = AFFECT_DICT[values[i][0]](values[i][1])
  833.                     val2[values[i][0]] = values[i][1]
  834.                     self.bonusSelector.ibi[i+6].SetText(affectString)
  835.                 except:
  836.                     pass
  837.             prob = 0
  838.             max  = 0
  839.            
  840.             yp = self.GenList_rare()
  841.             for x in yp:
  842.                 if yp[x] in val2 and val2[yp[x]] >= int(self.bonusSelector.boni[x+5][3].GetText()):
  843.                     prob = prob+1
  844.                 max = max+1
  845.             if max > 0:
  846.                 prozent = 100/max*prob
  847.             else:
  848.                 prozent = 100
  849.             return prozent
  850.             pass
  851.         def GetProb(self):
  852.             values = [player.GetItemAttribute(self.index, i) for i in range(0,5)]
  853.             val2 = {}
  854.             # for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  855.             for i in range(0,5):
  856.                 try:
  857.                     affectString = AFFECT_DICT[values[i][0]](values[i][1])
  858.                     val2[values[i][0]] = values[i][1]
  859.                     self.bonusSelector.ibi[i].SetText(affectString)
  860.                 except:
  861.                     pass
  862.             prob = 0
  863.             max  = 0
  864.             yp = self.GenList()
  865.             for x in yp:
  866.                 if yp[x] in val2 and val2[yp[x]] >= int(self.bonusSelector.boni[x][3].GetText()):
  867.                     prob = prob+1
  868.                 max = max+1
  869.             if max > 0:
  870.                 prozent = 100/max*prob
  871.             else:
  872.                 prozent = 100
  873.             return prozent
  874.            
  875.         def GenList(self):
  876.             ret = {}
  877.             for i in range(0,5):
  878.                 if self.bonusSelector.boni[5-i][1].selected.value != 0:
  879.                     ret[5-i] = self.bonusSelector.boni[5-i][1].selected.value
  880.             return ret
  881.         def GenList_rare(self):
  882.             ret = {}
  883.             for i in range(0,2):
  884.                 if self.bonusSelector.boni[6+i][1].selected.value != 0:
  885.                     ret[i+1] = self.bonusSelector.boni[6+i][1].selected.value
  886.             return ret
  887.            
  888.     def __init__(self,parent):
  889.         ui.Window.__init__(self)
  890.         self.SetSize(500,36*3+4*2)
  891.         self.tabCount = 0
  892.         self.tabList = {}
  893.        
  894.         self.parentWindow = parent
  895.         self.SetParent(parent)
  896.         self.plusBar = ui.Bar()
  897.         self.plusBar.SetParent(self)
  898.         self.plusBar.SetSize(90,30)
  899.         self.plusBar.SetWindowVerticalAlignCenter()
  900.         self.plusBar.SetColor(COLOR_BG)
  901.         # self.plusBar.OnMouseLeftButtonDown = lambda: self.AddTab_pre()
  902.         self.plusBar.OnMouseLeftButtonUp = lambda: self.AddTab_pre()
  903.         self.OnMouseLeftButtonUp = lambda: self.AddTab_pre()
  904.         self.plusBar.SetPosition(30,0)
  905.         self.plusBar.Show()
  906.        
  907.         self.AddText = ui.TextLine()
  908.         self.AddText.SetParent(self.plusBar)
  909.         self.AddText.SetText("Trage itemul aici")
  910.         self.AddText.SetWindowVerticalAlignCenter()
  911.         self.AddText.SetWindowHorizontalAlignCenter()
  912.         self.AddText.SetVerticalAlignCenter()
  913.         self.AddText.SetHorizontalAlignCenter()
  914.         self.AddText.SetPosition(0,0)
  915.         self.AddText.Show()
  916.        
  917.         dist = [
  918.             [500,  0  ], #1
  919.             [240, 10  ],
  920.             [160, 10  ],
  921.             [117, 10.5],
  922.             # [ 80, 25  ], #5
  923.             [ 92, 10  ], #5
  924.             [ 75, 10  ], #6
  925.             [ 64,  9  ], #7
  926.             [ 56,  7.5], #8
  927.             [ 50,  6.5], #9
  928.             [ 45,  5.5], #10
  929.         ][MAX_NUM-1]
  930.         self.ItemTab.width = dist[0]
  931.         self.ItemTab.dist  = dist[1]
  932.  
  933.        
  934.         #For 8
  935.         # dist  = 9-1.5
  936.         # width = 56
  937.        
  938.         # For 9
  939.         # dist  = 9-2.5
  940.         # width = 50
  941.        
  942.         # For 10
  943.         # dist  = 9-3.5
  944.         # width = 45
  945.        
  946.        
  947.     def DeleteTab(self,id):
  948.         if self.parentWindow.gameWindow != None:
  949.             self.tabList[id].blockBar.Hide()
  950.             self.tabList[id].blockBar.Destroy()
  951.         self.tabList[id].Destroy()
  952.         # del self.tabList[id]
  953.         self.tabCount = self.tabCount -1
  954.         if self.tabCount > id and id < 5:
  955.             for i in xrange(id,self.tabCount):
  956.                 self.tabList[i] = self.tabList[i+1]
  957.                 self.tabList[i].tabnum = i
  958.                 self.tabList[i].SetPosition((self.tabList[i].width+self.tabList[i].dist)*i,0)
  959.                
  960.             del self.tabList[self.tabCount]
  961.            
  962.         else:
  963.             del self.tabList[id]
  964.            
  965.        
  966.         if self.tabCount > 0:
  967.             self.tabList[0].Select()
  968.        
  969.         if (self.ItemTab.width+self.ItemTab.dist)*self.tabCount < 20:
  970.             self.parentWindow.SetSize(520,480-210)
  971.             self.parentWindow.but_speed.Hide()
  972.             self.plusBar.SetPosition(20,0)
  973.         else:
  974.             (x,y) = self.tabList[self.tabCount-1].GetLocalPosition()
  975.             self.plusBar.SetPosition(x+self.ItemTab.width+self.ItemTab.dist,0)
  976.             # self.plusBar.SetPosition((self.ItemTab.width+self.ItemTab.dist)*self.tabCount-10,0)
  977.         self.plusBar.Show()
  978.        
  979.     def AddTab_pre(self):
  980.         if mouseModule.mouseController.isAttached():
  981.             attachedSlotType = mouseModule.mouseController.GetAttachedType()
  982.             attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  983.             attachedSlotVnum = mouseModule.mouseController.GetAttachedItemIndex()
  984.            
  985.             item.SelectItem(attachedSlotVnum)
  986.             if item.GetItemType() != 1 and item.GetItemType() != 2:
  987.                 mouseModule.mouseController.DeattachObject()
  988.                 chat.AppendChat(2,"Acest item nu se poate bonusa.")
  989.                 return
  990.            
  991.             for a in self.tabList:
  992.                 if self.tabList[a].index == attachedSlotPos:
  993.                     mouseModule.mouseController.DeattachObject()
  994.                     chat.AppendChat(2,"Acest slot este deja la bonusat!")
  995.                     return
  996.                
  997.                
  998.             if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  999.                 self.AddTab(attachedSlotPos,attachedSlotVnum)
  1000.                 chat.AppendChat(2,"Itemul este adaugat in schimbator!")
  1001.  
  1002.             mouseModule.mouseController.DeattachObject()
  1003.        
  1004.     def AddTab(self,id,vnum = 0):
  1005.         if self.tabCount < MAX_NUM:
  1006.             self.tabList[self.tabCount] = self.ItemTab(self,self.tabCount,id,vnum)
  1007.            
  1008.             self.tabList[self.tabCount].Select()
  1009.             self.tabList[self.tabCount].Show()
  1010.             self.tabCount+= 1
  1011.             if (self.ItemTab.width+self.ItemTab.dist)*self.tabCount < 20:
  1012.                 self.plusBar.SetPosition(20,0)
  1013.             else:
  1014.                 (x,y) = self.tabList[self.tabCount-1].GetLocalPosition()
  1015.                 self.plusBar.SetPosition(x+self.ItemTab.width+self.ItemTab.dist,0)
  1016.        
  1017.         if self.tabCount == MAX_NUM:
  1018.             self.plusBar.Hide()
  1019.            
  1020.         self.parentWindow.SetSize(520,480+10)
  1021.         self.parentWindow.but_speed.Show()
  1022.             # return 0
  1023.  
  1024. class Bot(ui.BoardWithTitleBar):
  1025.     class PinGroup(ui.Bar):
  1026.         def OnUpdate(self):
  1027.             ## Now check position.
  1028.             (x,y) = self.GetGlobalPosition()
  1029.             max_x = wndMgr.GetScreenWidth()-self.GetWidth()
  1030.             max_y = wndMgr.GetScreenHeight()-self.GetHeight()-DISTANCE_BOTTOM
  1031.             if not x == self.pos_x  or not y == self.pos_y:
  1032.                 old_dir = self.dir
  1033.                 if self.pos_x == 0 and not self.pos_y == 0 and not self.pos_y == max_y and old_dir != 1:
  1034.                     self.parse_dir(1)
  1035.                 elif self.pos_x == max_x and not self.pos_y == 0 and not self.pos_y == max_y and old_dir != 2:
  1036.                     self.parse_dir(2)
  1037.                 elif self.pos_y == max_y and not self.pos_x == 0 and not self.pos_x == max_x and old_dir != 4:
  1038.                     self.parse_dir(4)
  1039.                 elif self.pos_y == 0 and not self.pos_x == 0 and not self.pos_x == max_x and old_dir != 3:
  1040.                     self.parse_dir(3)
  1041.                    
  1042.                 max_x = wndMgr.GetScreenWidth()-self.GetWidth()
  1043.                 max_y = wndMgr.GetScreenHeight()-self.GetHeight()-DISTANCE_BOTTOM  
  1044.                    
  1045.                
  1046.                 if self.pos_x == 0 and not self.pos_y == 0 and not self.pos_y == max_y:
  1047.                     x = 0
  1048.                 elif self.pos_x == max_x and not self.pos_y == 0 and not self.pos_y == max_y:
  1049.                     x = max_x
  1050.                 elif self.pos_y == 0 and not self.pos_x == 0 and not self.pos_x == max_x:
  1051.                     y = 0
  1052.                 elif self.pos_y == max_y and not self.pos_x == 0 and not self.pos_x == max_x:
  1053.                     y = max_y
  1054.                 if x > 0 and x < max_x and y > 0 and y < max_y:
  1055.                     if y < int(max_y/2):
  1056.                         y = 0
  1057.                     else:
  1058.                         y = max_y
  1059.                    
  1060.                     if x < int(max_x/2):
  1061.                         x = 0
  1062.                     else:
  1063.                         x = max_x
  1064.                        
  1065.                
  1066.                 x = min(max(0,x),wndMgr.GetScreenWidth()-self.GetWidth())
  1067.                 y = min(max(0,y),wndMgr.GetScreenHeight()-self.GetHeight()-DISTANCE_BOTTOM)
  1068.                 self.SetPosition(x,y)
  1069.                 self.pos_x = x
  1070.                 self.pos_y = y
  1071.             # (self.pos_x,self.pos_y) = self.GetGlobalPosition()
  1072.             self.parent.OnUpdate()
  1073.             for c in self.txtlist:
  1074.                 c.SetColor(c.item.StatusBar.color)
  1075.                 c.txt2.SetText("Status: %s" % c.item.StatusText.GetText())
  1076.                 try:
  1077.                     c.listWin2.SetColor(c.item.StatusBar_rare.color)
  1078.                     c.txt3.SetText("Status: %s" % c.item.StatusText_rare.GetText())
  1079.                 except:
  1080.                     pass
  1081.                
  1082.         def ShowMainWindow(self):
  1083.             (x,y) = self.parent.GetGlobalPosition()
  1084.             x = min(max(32,x),wndMgr.GetScreenWidth()-self.parent.GetWidth()-32)
  1085.             y = min(max(32,y),wndMgr.GetScreenHeight()-self.parent.GetHeight()-DISTANCE_BOTTOM-32)
  1086.             self.parent.SetPosition(x,y)
  1087.             self.parent.Show()
  1088.             self.__del__()
  1089.         def parse_dir(self,dir):
  1090.             self.dir = dir
  1091.             w,h = 100,50
  1092.             for listWin in self.txtlist:
  1093.                 itm = listWin.item
  1094.                 listWin.AddFlag("not_pick")
  1095.                 if dir >= 3:
  1096.                     listWin.SetPosition(w,4)
  1097.                     listWin.SetSize(90,h-8)
  1098.                     w+=92
  1099.                     if itm.bonusSelector.EnableRareBoni.checked == 1:
  1100.                         w+=15
  1101.                         listWin.SetSize(105,4+12+12)
  1102.                         listWin.listWin2.SetSize(105,14)
  1103.                         listWin.listWin2.Show()
  1104.                         listWin.txt3.Show()
  1105.                 else:
  1106.                     listWin.SetPosition(0,h)
  1107.                     listWin.SetSize(w,4+12+12+2)
  1108.                    
  1109.                     if itm.bonusSelector.EnableRareBoni.checked == 1:
  1110.                         listWin.SetSize(w,4+12+12)
  1111.                         listWin.listWin2.SetSize(w,14)
  1112.                         listWin.listWin2.Show()
  1113.                         listWin.txt3.Show()
  1114.                         # itl.append(txt3)
  1115.                         h+=12
  1116.                         pass
  1117.                     h+=4+12+12+4
  1118.             self.SetSize(w,h)
  1119.        
  1120.         def __init__(self,parent,dir = 1):
  1121.             self.parent = parent
  1122.             self.dir = dir
  1123.             ui.Bar.__init__(self)
  1124.             # Direction: 1 = left; 2 = right; 3 = top
  1125.             self.SetColor(COLOR_BG)
  1126.             w,h = 100,50
  1127.            
  1128.             self.AddFlag("float")
  1129.             self.AddFlag("movable")
  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("Afiseaza")
  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("Opreste tot")
  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("Switchbot Metin2Galaxy")
  1294.         self.AddFlag("float")
  1295.         self.AddFlag("movable")
  1296.         self.SetPosition(30,30)
  1297.         # self.SetSize(520,480)
  1298.         # self.SetSize(520,480-210)
  1299.         self.SetSize(520,480-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("Minimieren", 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("HELP SWITCH", 0, -23)
  1324.         self.titleBar.HelpBut.SetText("HELP")
  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("Opreste tot")
  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, 3)
  1353.        
  1354.         self.enable_rebuy = CheckBox("Cumparator 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,'Trage un item aici pentru a schimba.')
  1383.         self.help_add_item.SetParent(self)
  1384.         self.help_add_item.SetPosition(60,50)
  1385.        
  1386.         self.help_minimize = HelpBar(0.8,'Aceasta casuta poate fi micsorata prin tragerea ei la margine!',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,'Aici puteti selecta si 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,'Vrei sa cumparam schimbator?')
  1396.         self.help_rebuy.SetParent(self)
  1397.         # self.help_rebuy.SetPosition(25,297)
  1398.        
  1399.         self.help_stop_all = HelpBar(0.8,'Opreste toate operatiunile!',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,'Afiseaza robotul.',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.         import constInfo
  1419.         constInfo.BOT=0
  1420.        
  1421.         ui.BoardWithTitleBar.Hide(self)
  1422.         self.bot_shown = 0
  1423.        
  1424.        
  1425.     def deactivate_all(self):
  1426.         for a in self.itemTabBar.tabList:
  1427.             self.itemTabBar.tabList[a].bonusSelector.Starter.SetUp()
  1428.             self.itemTabBar.tabList[a].bonusSelector.Starter.OnToggleUp()
  1429.             self.itemTabBar.tabList[a].bonusSelector.Starter_rare_boni.SetUp()
  1430.             self.itemTabBar.tabList[a].bonusSelector.Starter_rare_boni.OnToggleUp()
  1431.         pass
  1432.        
  1433.     drag = 0
  1434.     def drag_start(self):
  1435.         self.drag = 1
  1436.        
  1437.     def drag_end(self):
  1438.         self.drag = 0
  1439.         if self.pinhint > 0:
  1440.             self.PinShow(self.pinhint)
  1441.             # self.PinGroupBox = self.PinGroup()
  1442.             pass
  1443.         self.ShowPinHint(0)
  1444.        
  1445.     def PinShow(self,dir):
  1446.         self.PinGroupBox = self.PinGroup(self,dir)
  1447.         self.Hide()
  1448.         self.PinGroupBox.Show()
  1449.        
  1450.     def EnableInventoryTweak(self,gameWindow):
  1451.         self.gameWindow=gameWindow
  1452.         self.gameWindow.interface.wndInventory.inventoryTab[0].SetEvent(lambda arg=0: self.__SetInventoryPage(arg))
  1453.         self.gameWindow.interface.wndInventory.inventoryTab[1].SetEvent(lambda arg=1: self.__SetInventoryPage(arg))
  1454.     def __SetInventoryPage(self,arg):
  1455.         self.gameWindow.interface.wndInventory.SetInventoryPage(arg)
  1456.         for a in self.itemTabBar.tabList:
  1457.             itm = self.itemTabBar.tabList[a]
  1458.             if itm.index >= arg*45 and itm.index < (arg+1)*45:
  1459.                 itm.blockBar.Show()
  1460.             else:
  1461.                 itm.blockBar.Hide()
  1462.     help_on = 0
  1463.     counter = 0
  1464.     AboutWindow = None
  1465.     def OnUpdate(self):
  1466.         if self.AboutWindow:
  1467.             if self.AboutWindow.x_counter > 1:
  1468.                 self.AboutWindow.x_counter -=1
  1469.                 self.AboutWindow.text6.SetText("Time: %0.1f" % (self.AboutWindow.x_counter/45.0))
  1470.             elif self.AboutWindow.x_counter == 1:
  1471.                 self.AboutWindow.Hide()
  1472.                 # self.AboutWindow.Delete()
  1473.                
  1474.         if self.help_on == 1:
  1475.             (x,y) = self.itemTabBar.plusBar.GetLocalPosition()
  1476.             self.help_add_item.SetPosition(x+20,50)
  1477.             self.help_add_item.Show()
  1478.             self.help_stop_all.Show()
  1479.            
  1480.             self.help_minimize.Show()
  1481.             if self.itemTabBar.tabCount > 0:
  1482.                 self.help_show_rare.SetPosition(25,164)
  1483.                 self.help_show_rare.Show()
  1484.                 self.help_rebuy.SetPosition(15,147)
  1485.                 self.help_rebuy.Show()
  1486.                
  1487.                 # self.help_duration.SetPosition(300,180)
  1488.                 self.help_duration.SetPosition(190-5.5+self.but_speed.GetSliderPos()*int(35.5+self.but_speed.GetWidth()/2),180)
  1489.                 self.help_duration.Show()
  1490.                
  1491.             else:
  1492.                 self.help_show_rare.Hide()
  1493.                 self.help_rebuy.Hide()
  1494.                 self.help_duration.Hide()
  1495.            
  1496.         else:
  1497.             self.help_add_item.Hide()
  1498.             self.help_minimize.Hide()
  1499.             self.help_show_rare.Hide()
  1500.             self.help_rebuy.Hide()
  1501.             self.help_stop_all.Hide()
  1502.             self.help_duration.Hide()
  1503.            
  1504.         if self.drag == 1:
  1505.             (x1, y1) = self.GetGlobalPosition()
  1506.             # if x1 < 0:
  1507.                 # x1 = 0
  1508.             # elif x1 > wndMgr.GetScreenWidth()-520:
  1509.                 # x1 = wndMgr.GetScreenWidth()-520
  1510.             # if y1 < 0:
  1511.                 # y1 = 0
  1512.             # elif y1 > wndMgr.GetScreenHeight()-36-self.GetHeight():
  1513.                 # y1 = wndMgr.GetScreenHeight()-36-self.GetHeight()
  1514.             x1 = max(min(wndMgr.GetScreenWidth()-520,x1),0)
  1515.             y1 = max(min(wndMgr.GetScreenHeight()-36-self.GetHeight(),y1),0)
  1516.             self.SetPosition(x1,y1)
  1517.             if x1 < 30:
  1518.                 self.ShowPinHint(1)
  1519.             elif wndMgr.GetScreenWidth()-x1-520 < 30:
  1520.                 self.ShowPinHint(2)
  1521.             elif y1 < 30:
  1522.                 self.ShowPinHint(3)
  1523.             elif wndMgr.GetScreenHeight()-y1-self.GetHeight() < 60:
  1524.                 self.ShowPinHint(4)
  1525.             else:
  1526.                 self.ShowPinHint(0)
  1527.             # self.SetPosition(x1+(x-self.drag_pos[0]),y1)
  1528.             pass
  1529.        
  1530.         if self.gameWindow != None:
  1531.             for a in self.itemTabBar.tabList:
  1532.                 itm = self.itemTabBar.tabList[a]
  1533.            
  1534.            
  1535.            
  1536.         self.counter+=1
  1537.         if self.counter >= int(self.but_speed.GetSliderPos()*MAX_SWITCH_DELAY_APPEND+MIN_SWITCH_DELAY):
  1538.             self.buyed = 0
  1539.             self.buyed_rare = 0
  1540.             self.counter = 0
  1541.             for a in self.itemTabBar.tabList:
  1542.                 itm = self.itemTabBar.tabList[a]
  1543.                 itm.UpdateItem()
  1544.                 # if itm.
  1545.                
  1546.  
  1547.     def about(self):
  1548.         self.AboutWindow = ui.ThinBoard()
  1549.         self.AboutWindow.SetParent(self)
  1550.         self.AboutWindow.SetSize(250,100)
  1551.         self.AboutWindow.SetWindowHorizontalAlignCenter()
  1552.         self.AboutWindow.SetWindowVerticalAlignCenter()
  1553.         self.AboutWindow.SetPosition(0,0)
  1554.         self.AboutWindow.Show()
  1555.         self.AboutWindow.x_counter = 450
  1556.        
  1557.         self.AboutWindow.text1 = ui.TextLine()
  1558.         self.AboutWindow.text1.SetParent(self.AboutWindow)
  1559.         self.AboutWindow.text1.SetWindowHorizontalAlignCenter()
  1560.         self.AboutWindow.text1.SetHorizontalAlignCenter()
  1561.         self.AboutWindow.text1.SetPosition(0,5)
  1562.         self.AboutWindow.text1.SetText("Switchbot !")
  1563.         self.AboutWindow.text1.SetPackedFontColor(ui.GenerateColor(58, 141, 221))
  1564.         self.AboutWindow.text1.Show()
  1565.        
  1566.         self.AboutWindow.text2 = ui.TextLine()
  1567.         self.AboutWindow.text2.SetParent(self.AboutWindow)
  1568.         self.AboutWindow.text2.SetPosition(8,18)
  1569.         self.AboutWindow.text2.SetText("Metin2Galaxy - PVM-PVP SERVER !")
  1570.         self.AboutWindow.text2.Show()
  1571.        
  1572.         self.AboutWindow.text3 = ui.TextLine()
  1573.         self.AboutWindow.text3.SetParent(self.AboutWindow)
  1574.         self.AboutWindow.text3.SetPosition(8,18+13)
  1575.         self.AboutWindow.text3.SetText("Acest sistem schimba bonusurile automat. ")
  1576.         self.AboutWindow.text3.Show()
  1577.        
  1578.         self.AboutWindow.text4 = ui.TextLine()
  1579.         self.AboutWindow.text4.SetParent(self.AboutWindow)
  1580.         self.AboutWindow.text4.SetPosition(8,18+13*3)
  1581.         self.AboutWindow.text4.SetText("Va dorim un joc cat mai placut!")
  1582.         self.AboutWindow.text4.Show()
  1583.        
  1584.         self.AboutWindow.text5 = ui.TextLine()
  1585.         self.AboutWindow.text5.SetParent(self.AboutWindow)
  1586.         self.AboutWindow.text5.SetPosition(8,18+13*4)
  1587.         self.AboutWindow.text5.SetText("")
  1588.         self.AboutWindow.text5.Show()
  1589.        
  1590.         self.AboutWindow.text6 = ui.TextLine()
  1591.         self.AboutWindow.text6.SetParent(self.AboutWindow)
  1592.         self.AboutWindow.text6.SetPosition(200,18+13*5)
  1593.         self.AboutWindow.text6.SetText("Time: %d" % self.AboutWindow.x_counter)
  1594.         self.AboutWindow.text6.Show()
  1595.        
  1596.        
  1597.        
  1598. class HelpBar(ui.Window):
  1599.     def __init__(self,width,text,centered = 0):
  1600.         ui.Window.__init__(self)
  1601.         self.AddFlag("not_pick")
  1602.         self.AddFlag("attach")
  1603.        
  1604.         img = ui.ExpandedImageBox()
  1605.        
  1606.         img.SetParent(self)
  1607.         img.LoadImage("d:/ymir work/ui/pattern/help_stick.tga")
  1608.         img.SetRenderingRect(0.0, -width, 0.0, 0.0)
  1609.         img.Show()
  1610.        
  1611.         self.img = img
  1612.        
  1613.         txt = ui.TextLine()
  1614.        
  1615.         txt=ui.TextLine()
  1616.         txt.SetParent(self)
  1617.         txt.SetText(text)
  1618.         txt.Show()
  1619.        
  1620.         img.SetPosition(0,18-width*img.GetHeight())
  1621.         txt.SetPosition(0,0)
  1622.         txt.SetWindowHorizontalAlignCenter()
  1623.         if centered != 0:
  1624.             txt.SetHorizontalAlignCenter()
  1625.         # txt.SetPosition(0,0)
  1626.        
  1627.         self.txt = txt
  1628.    
  1629. class DropDown(ui.Window):
  1630.     dropped  = 0
  1631.     dropstat = 0
  1632.     last = 0
  1633.     lastS = 0
  1634.     maxh = 95
  1635.     OnChange = None
  1636.     class Item(ui.ListBoxEx.Item):
  1637.         def __init__(self,parent, text,value=0):
  1638.             ui.ListBoxEx.Item.__init__(self)
  1639.  
  1640.             self.textBox=ui.TextLine()
  1641.             self.textBox.SetParent(self)
  1642.             self.textBox.SetText(text)
  1643.             # self.textBox.SetLimitWidth(parent.GetWidth()-132)
  1644.             self.textBox.Show()
  1645.             self.value = value
  1646.         def GetValue(self):
  1647.             return self.value
  1648.         def __del__(self):
  1649.             ui.ListBoxEx.Item.__del__(self)
  1650.            
  1651.     def __init__(self,parent,tt = "",down=1):
  1652.         ui.Window.__init__(self,"TOP_MOST")
  1653.         self.down = down
  1654.         self.SetParentProxy(parent)
  1655.         self.bg = ui.Bar("TOP_MOST")
  1656.         self.bg.SetParent(self)
  1657.         self.bg.SetPosition(0,0)
  1658.         self.bg.SetColor(0xc0000000)
  1659.         self.bg.OnMouseOverIn = self.bgMouseIn
  1660.         self.bg.OnMouseOverOut = self.bgMouseOut
  1661.         self.bg.OnMouseLeftButtonDown = self.ExpandMe
  1662.         self.bg.Show()
  1663.         self.act = ui.TextLine()
  1664.         self.act.SetParent(self.bg)
  1665.         self.act.SetPosition(4,2)
  1666.         self.act.SetText(tt)
  1667.         self.act.Show()
  1668.         self.GetText = self.act.GetText
  1669.        
  1670.         self.Drop = ui.Bar("TOP_MOST")
  1671.         self.Drop.SetParent(self.GetParentProxy())
  1672.         self.Drop.SetPosition(0,21)
  1673.         # self.Drop.SetSize(150,95)
  1674.         self.Drop.SetSize(150,0)
  1675.         # self.Drop.SetColor(0xc00a0a0a)
  1676.         self.Drop.SetColor(0xff0a0a0a)
  1677.        
  1678.        
  1679.         self.ScrollBar = ui.ThinScrollBar()
  1680.         self.ScrollBar.SetParent(self.Drop)
  1681.         self.ScrollBar.SetPosition(132,0)
  1682.         # self.ScrollBar.SetScrollBarSize(95)
  1683.         self.ScrollBar.SetScrollBarSize(0)
  1684.         # self.ScrollBar.Show()
  1685.        
  1686.         self.DropList = ui.ListBoxEx()
  1687.         self.DropList.SetParent(self.Drop)
  1688.         self.DropList.itemHeight = 12
  1689.         self.DropList.itemStep = 13
  1690.         self.DropList.SetPosition(0,0)
  1691.         # self.DropList.SetSize(132,self.maxh)
  1692.         self.DropList.SetSize(132,13)
  1693.         self.DropList.SetScrollBar(self.ScrollBar)
  1694.         self.DropList.SetSelectEvent(self.SetTitle)
  1695.         self.DropList.SetViewItemCount(0)
  1696.         self.DropList.Show()
  1697.         if tt != "":
  1698.             self.AppendItemAndSelect(tt)
  1699.         self.selected = self.DropList.GetSelectedItem()
  1700.        
  1701.            
  1702.         self.SetSize(120,20)
  1703.     def __del__(self):
  1704.         ui.Window.__del__(self)
  1705.     c = 1
  1706.     def AppendItem(self,text,value=0):
  1707.         self.c+=1  
  1708.         self.DropList.AppendItem(self.Item(self,text,value))
  1709.         self.maxh = min(95,13*self.c)
  1710.         if self.c > 7:
  1711.             self.ScrollBar.Show()
  1712.            
  1713.        
  1714.     def AppendItemAndSelect(self,text,value=0):
  1715.         self.DropList.AppendItem(self.Item(self,text,value))
  1716.         self.DropList.SelectIndex(len(self.DropList.itemList)-1)
  1717.        
  1718.     def SelectByAffectId(self,id):
  1719.         for x in self.DropList.itemList:
  1720.             if x.value == id:
  1721.                 self.DropList.SelectItem(x)
  1722.                 break
  1723.                
  1724.     def SetTitle(self,item):
  1725.         self.act.SetText(str(item.textBox.GetText()))
  1726.         self.last = self.DropList.basePos
  1727.         self.lastS = self.ScrollBar.GetPos()
  1728.         self.dropped = 0
  1729.         self.selected = item
  1730.         if self.OnChange:
  1731.             self.OnChange()
  1732.         # self.Drop.Hide()
  1733.        
  1734.     def SetPosition(self,w,h):
  1735.         ui.Window.SetPosition(self,w,h)
  1736.         if self.down == 1:
  1737.             self.Drop.SetPosition(w,h+21)
  1738.         else:
  1739.             self.Drop.SetPosition(w,h-self.Drop.GetHeight())
  1740.        
  1741.     def SetSize(self,w,h):
  1742.         ui.Window.SetSize(self,w,h)
  1743.         self.bg.SetSize(w,h)
  1744.         self.Drop.SetSize(w,0)
  1745.         self.DropList.SetSize(w-18,self.maxh)
  1746.         for x in self.DropList.itemList:
  1747.             x.SetSize(w-18,12)
  1748.         self.ScrollBar.SetPosition(w-18,0)
  1749.        
  1750.        
  1751.     def ExpandMe(self):
  1752.         if self.dropped == 1:
  1753.             # self.Drop.Hide()
  1754.             self.dropped = 0
  1755.         else:
  1756.             # self.Drop.Show()
  1757.             self.dropped = 1
  1758.            
  1759.     def OnUpdate(self):
  1760.         iter = 6
  1761.         if self.Drop.GetHeight() < 50:
  1762.             self.ScrollBar.Hide()
  1763.         else:
  1764.             self.ScrollBar.Show()
  1765.            
  1766.         if self.dropped == 0 and self.dropstat == 1:
  1767.             if self.Drop.GetHeight() <=0:
  1768.                 self.dropstat = 0
  1769.                 self.Drop.SetSize(self.Drop.GetWidth(),0)
  1770.                 self.ScrollBar.SetScrollBarSize(self.Drop.GetHeight())
  1771.                 self.Drop.Hide()
  1772.             else:
  1773.                 if self.Drop.GetHeight()-iter < 0:
  1774.                     self.Drop.SetSize(self.Drop.GetWidth(),0)
  1775.                 else:
  1776.                     self.Drop.SetSize(self.Drop.GetWidth(),self.Drop.GetHeight()-iter)
  1777.                     (w,h) = self.GetLocalPosition()
  1778.                     self.SetPosition(w,h)
  1779.                        
  1780.                    
  1781.                 self.ScrollBar.SetScrollBarSize(self.Drop.GetHeight())
  1782.             self.DropList.SetViewItemCount(int(self.Drop.GetHeight()/13))
  1783.             self.DropList.SetBasePos(self.last+1)
  1784.             self.DropList.SetBasePos(self.last)
  1785.         elif self.dropped == 1 and self.dropstat == 0:
  1786.             self.Drop.Show()
  1787.             self.SetTop()
  1788.             if self.Drop.GetHeight() >=self.maxh:
  1789.                 self.Drop.SetSize(self.Drop.GetWidth(),self.maxh)
  1790.                 self.ScrollBar.SetScrollBarSize(self.maxh)
  1791.                 self.dropstat = 1
  1792.                 self.DropList.SetViewItemCount(7)
  1793.                 self.ScrollBar.SetPos(self.lastS)
  1794.             else:
  1795.                 self.ScrollBar.SetScrollBarSize(self.Drop.GetHeight()+iter)
  1796.                 self.Drop.SetSize(self.Drop.GetWidth(),self.Drop.GetHeight()+iter)
  1797.                 (w,h) = self.GetLocalPosition()
  1798.                 self.SetPosition(w,h)
  1799.             self.DropList.SetViewItemCount(int(self.Drop.GetHeight()/13))
  1800.             self.DropList.SetBasePos(self.last+1)
  1801.             self.DropList.SetBasePos(self.last)
  1802.        
  1803.     ## BG Hover
  1804.     def bgMouseIn(self):
  1805.         self.bg.SetColor(0xc00a0a0a)
  1806.     def bgMouseOut(self):
  1807.         self.bg.SetColor(0xc0000000)
  1808.        
  1809.  
  1810. class Edit2(ui.EditLine):
  1811.     def __init__(self,main = "",ml = 99):
  1812.         ui.EditLine.__init__(self)
  1813.         self.SetText(main)
  1814.         self.main = main
  1815.         self.SetMax(ml)
  1816.         self.SetUserMax(ml)
  1817.     def GetText(self):
  1818.         res = ui.EditLine.GetText(self)
  1819.         if res == "":
  1820.             return "0"
  1821.         else:
  1822.             return res
  1823.            
  1824.     def __del__(self):
  1825.         ui.EditLine.__del__(self)
  1826.     def OnSetFocus(self):
  1827.         ui.EditLine.OnSetFocus(self)
  1828.         if ui.EditLine.GetText(self) == self.main:
  1829.             self.SetText("")
  1830.     def OnKillFocus(self):
  1831.         ui.EditLine.OnKillFocus(self)
  1832.         if ui.EditLine.GetText(self) == "":
  1833.             self.SetText(self.main)
  1834.            
  1835.  
  1836. class CheckBox(ui.Window):
  1837.     checked = 0
  1838.     eventUp  =None
  1839.     eventDown=None
  1840.     def __init__(self,cont = ""):
  1841.         ui.Window.__init__(self)
  1842.         self.BG = ui.Bar("UI")
  1843.         self.BG.SetParent(self)
  1844.         self.BG.SetPosition(0,0)
  1845.         self.BG.SetSize(20,20)
  1846.         # self.BG.SetColor(0xc00b0b0b)
  1847.         self.BG.SetColor(COLOR_CHECKBOX_NOT_SELECTED)
  1848.         self.BG.OnMouseLeftButtonUp = self.Toggle
  1849.         self.OnMouseLeftButtonUp = self.Toggle
  1850.         self.BG.Show()
  1851.         self.Title = ui.TextLine()
  1852.         self.Title.SetParent(self)
  1853.         self.Title.SetPosition(25,2)
  1854.         self.Title.SetText(cont)
  1855.         self.Title.Show()
  1856.         self.stat = ui.TextLine()
  1857.         self.stat.SetParent(self.BG)
  1858.         self.stat.SetPosition(0,0)
  1859.         self.stat.SetWindowHorizontalAlignCenter()
  1860.         self.stat.SetWindowVerticalAlignCenter()
  1861.         self.stat.SetHorizontalAlignCenter()
  1862.         self.stat.SetVerticalAlignCenter()
  1863.         self.stat.SetSize(0,0)
  1864.         self.stat.SetText("")
  1865.         self.SetSize(25+self.Title.GetTextSize()[0]+5,20)
  1866.         self.stat.Show()
  1867.     def __del__(self):
  1868.         ui.ToggleButton.__del__(self)
  1869.     def Toggle(self):
  1870.         if self.checked == 1:
  1871.             self.OnToggleUp()
  1872.         else:
  1873.             self.OnToggleDown()
  1874.     def OnToggleUp(self):
  1875.         self.stat.SetText("")
  1876.         # self.BG.SetColor(0xc00b0b0b)
  1877.         self.BG.SetColor(COLOR_CHECKBOX_NOT_SELECTED)
  1878.         self.checked = 0
  1879.         if self.eventUp:
  1880.             self.eventUp()
  1881.     def OnToggleDown(self):
  1882.         # self.BG.SetColor(0xf00b0b0b)
  1883.         self.BG.SetColor(COLOR_CHECKBOX_SELECTED)
  1884.         self.stat.SetText("X")
  1885.         self.checked = 1
  1886.         if self.eventDown:
  1887.             self.eventDown()
  1888.  
  1889.            
  1890. # Zum Testen
  1891. # a = Bot()
  1892. # a.Show()
  1893.  
  1894. # oder;
  1895. # Bot().Show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement