Advertisement
deadx2

Untitled

Aug 29th, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.84 KB | None | 0 0
  1. import app
  2. import constInfo
  3. import uimg
  4. import uiToolTip
  5. import item
  6. import localemg
  7. import player
  8. import grp
  9. import time
  10. import net
  11. import event
  12.  
  13. class TombolaWindow(uimg.BoardWithTitleBar):
  14.    
  15.     def __init__(self):
  16.         uimg.BoardWithTitleBar.__init__(self)
  17.         self.__BuildWindow()
  18.        
  19.     def __del__(self):
  20.         uimg.BoardWithTitleBar.__del__(self)
  21.    
  22.     def __BuildWindow(self):
  23.        
  24.         self.xOpen = 0
  25.         self.yOpen = 0
  26.        
  27.         self.speedDown = 5
  28.         self.timeDiff = 0.1
  29.        
  30.         self.tooltipItem = None
  31.        
  32.         self.Poziom = 0
  33.        
  34.         self.animate = FALSE
  35.         self.blink = FALSE
  36.        
  37.         self.blinkTimes = 6
  38.         self.blinkLast = 0
  39.        
  40.         self.position = 1
  41.         self.toPosition = 16
  42.         self.lastClock = 0
  43.        
  44.         self.SetSize(341+45, 364+45+30)
  45.         self.AddFlag("float")
  46.         self.AddFlag("movable")
  47.         #self.SetFontColorNew(230, 208, 162)
  48.         self.SetTitleName("|cffe6d0a2Tombola")
  49.         self.SetCloseEvent(uimg.__mem_func__(self.OnClose))
  50.        
  51.         image = uimg.ImageBox()
  52.         image.SetParent(self)
  53.         image.LoadImage("illumina/inne/tombola_new.tga")
  54.         image.SetPosition(6+8, 29+9)
  55.         image.Show()
  56.         self.background = image
  57.        
  58.         select = uimg.ImageBox()
  59.         select.SetParent(self.background)
  60.         select.SetPosition(14, 13)
  61.         select.LoadImage("d:/ymir work/ui/tombola/1.tga")
  62.         select.Hide()
  63.         self.select = select
  64.        
  65.         button = uimg.Button()
  66.         button.SetParent(self.background)
  67.         button.SetPosition(125+8+6, 124+9+5)
  68.         button.SetUpVisual("illumina/inne/tombola_btn1.tga")
  69.         button.SetOverVisual("illumina/inne/tombola_btn2.tga")
  70.         button.SetDownVisual("illumina/inne/tombola_btn3.tga")
  71.         button.SetEvent(uimg.__mem_func__(self.OnButtonClick))
  72.         button.Show()
  73.         #self.run = button
  74.         self.button = button
  75.        
  76.         button1 = uimg.RadioButton()
  77.         button1.SetParent(self)
  78.         button1.SetPosition(51, 356+29)
  79.         button1.SetUpVisual("illumina/inne/btn_kod2_long_01.tga")
  80.         button1.SetOverVisual("illumina/inne/btn_kod2_long_02.tga")
  81.         button1.SetDownVisual("illumina/inne/btn_kod2_long_03.tga")
  82.         button1.SetEvent(uimg.__mem_func__(self.OnButtonClickLevel_1))
  83.         button1.SetText("|cffe6d0a2Poziom I")
  84.         button1.Show()
  85.         self.button1 = button1
  86.        
  87.         button2 = uimg.RadioButton()
  88.         button2.SetParent(self)
  89.         button2.SetPosition(51+100, 356+29)
  90.         button2.SetUpVisual("illumina/inne/btn_kod2_long_01.tga")
  91.         button2.SetOverVisual("illumina/inne/btn_kod2_long_02.tga")
  92.         button2.SetDownVisual("illumina/inne/btn_kod2_long_03.tga")
  93.         button2.SetEvent(uimg.__mem_func__(self.OnButtonClickLevel_2))
  94.         button2.SetText("|cffe6d0a2Poziom II")
  95.         button2.Show()
  96.         self.button2 = button2
  97.        
  98.         button3 = uimg.RadioButton()
  99.         button3.SetParent(self)
  100.         button3.SetPosition(51+200, 356+29)
  101.         button3.SetUpVisual("illumina/inne/btn_kod2_long_01.tga")
  102.         button3.SetOverVisual("illumina/inne/btn_kod2_long_02.tga")
  103.         button3.SetDownVisual("illumina/inne/btn_kod2_long_03.tga")
  104.         button3.SetEvent(uimg.__mem_func__(self.OnButtonClickLevel_3))
  105.         button3.SetText("|cffe6d0a2Poziom III")
  106.         button3.Show()
  107.         self.button3 = button3
  108.        
  109.         self.slots = [
  110.             self.__CreateSlot(1, 161 - 5+8+6+7, 53 - 4+9+5+7+4),
  111.             self.__CreateSlot(2, 207 - 5+8+6+7, 63 - 4+9+5+7+4),
  112.             self.__CreateSlot(3, 248 - 5+8+6+7, 93 - 4+9+5+7+4),
  113.             self.__CreateSlot(4, 277 - 5+8+6+7, 135 - 4+9+5+7+4),
  114.             self.__CreateSlot(5, 290 - 5+8+6+7, 182 - 4+9+5+7+4),
  115.             self.__CreateSlot(6, 277 - 5+8+6+7, 228 - 4+9+5+7+4),
  116.             self.__CreateSlot(7, 248 - 5+8+6+7, 271 - 4+9+5+7+4),
  117.             self.__CreateSlot(8, 207 - 5+8+6+7, 298 - 4+9+5+7+4),
  118.             self.__CreateSlot(9, 160 - 5+8+6+7, 307 - 4+9+5+7+4),
  119.             self.__CreateSlot(10, 114 - 5+8+6+7, 296 - 4+9+5+7+4),
  120.             self.__CreateSlot(11, 72 - 5+8+6+7, 269 - 4+9+5+7+4),
  121.             self.__CreateSlot(12, 44 - 5+8+6+7, 229 - 4+9+5+7+4),
  122.             self.__CreateSlot(13, 30 - 5+8+6+7, 183 - 4+9+5+7+4),
  123.             self.__CreateSlot(14, 41 - 5+8+6+7, 133 - 4+9+5+7+4),
  124.             self.__CreateSlot(15, 70 - 5+8+6+7, 92 - 4+9+5+7+4),
  125.             self.__CreateSlot(16, 112 - 5+8+6+7, 63 - 4+9+5+7+4)
  126.         ]
  127.        
  128.         self.OnButtonClickLevel_1()
  129.        
  130.         self.items = {}
  131.        
  132.     def __CreateSlot(self, number, x, y):
  133.         grid = uimg.GridSlotWindow()
  134.         grid.SetParent(self)
  135.         grid.SetPosition(x, y)
  136.         grid.ArrangeSlot(number, 1, 1, 32, 32, 0, 0)
  137.         grid.SetOverInItemEvent(uimg.__mem_func__(self.OverInItem))
  138.         grid.SetOverOutItemEvent(uimg.__mem_func__(self.OverOutItem))
  139.         grid.RefreshSlot()
  140.         grid.Show()
  141.        
  142.         return grid
  143.    
  144.     def OverInItem(self, slotIndex):
  145.         if slotIndex < 1 or slotIndex > 16:
  146.             return
  147.        
  148.         self.tooltipItem = uiToolTip.ItemToolTip()
  149.         self.tooltipItem.AddItemData(self.items[slotIndex - 1], 0, 0)
  150.         self.tooltipItem.Show()
  151.  
  152.     def OverOutItem(self):
  153.         if self.tooltipItem:
  154.             self.tooltipItem.HideToolTip()
  155.            
  156.     def OnButtonClick(self):
  157.         constInfo.CMDRESOLVER_MSG = "tombola|begin"
  158.         event.QuestButtonClick(int(constInfo.CMDRESOLVER_QUID))
  159.         net.SendQuestInputStringPacket("poziom" + str(self.Poziom))
  160.        
  161.     def OnButtonClickLevel_1(self):
  162.         self.Poziom = 1
  163.        
  164.     def OnButtonClickLevel_2(self):
  165.         self.Poziom = 2
  166.        
  167.     def OnButtonClickLevel_3(self):
  168.         self.Poziom = 3
  169.    
  170.     def OnPrepare(self, items):
  171.         items = items.split("|")
  172.        
  173.         j = 0
  174.         for i in range(0, 32, 2):
  175.             self.slots[j].SetItemSlot(j + 1, int(items[i]), int(items[i + 1]))
  176.             self.items[j] = int(items[i])
  177.             j += 1
  178.        
  179.     def OnRun(self, data):
  180.         data = data.split("|")
  181.        
  182.         self.toPosition = int(data[0])
  183.         self.speedDown = int(data[1])
  184.        
  185.         self.blinkTimes = 6
  186.         self.blinkLast = 0
  187.        
  188.         self.position = 1
  189.         self.animate = TRUE
  190.         self.blink = FALSE
  191.         self.timeDiff = 0.1
  192.        
  193.         self.lastClock = app.GetTime()
  194.        
  195.     def OnUpdate(self):
  196.         if self.animate == TRUE:
  197.             if (app.GetTime() - self.lastClock) >= self.timeDiff:
  198.                 self.lastClock = app.GetTime()
  199.                
  200.                 self.toPosition -= 1
  201.                
  202.                 if self.toPosition <= self.speedDown:
  203.                     self.timeDiff += 0.1
  204.                
  205.                 self.position += 1
  206.                 if self.position == 17:
  207.                     self.position = 1
  208.                
  209.                 if not self.select.IsShow():
  210.                     self.select.Show()
  211.                
  212.                 self.select.LoadImage("d:/ymir work/ui/tombola/" + str(self.position) + ".tga")
  213.                
  214.                 if self.toPosition == 0:
  215.                     self.animate = FALSE
  216.                     self.blink = TRUE
  217.                    
  218.                     constInfo.CMDRESOLVER_MSG = "tombola|end"
  219.                     event.QuestButtonClick(int(constInfo.CMDRESOLVER_QUID2))
  220.                    
  221.         if self.blink == TRUE and (app.GetTime() - self.blinkLast) >= 0.3:
  222.             if self.blinkTimes > 0:
  223.                 if self.blinkTimes % 2:
  224.                     self.select.Hide()
  225.                 else:
  226.                     self.select.Show()
  227.                 self.blinkTimes -= 1
  228.             else:  
  229.                 self.blink = FALSE
  230.                 self.blinkTimes = 6
  231.                 self.blinkLast = 0
  232.                 self.select.Hide()
  233.                 self.select.LoadImage("d:/ymir work/ui/tombola/1.tga")
  234.                
  235.             self.blinkLast = app.GetTime()
  236.            
  237.         (x, y, z) = player.GetMainCharacterPosition()
  238.         if abs(x - self.xOpen) > 1000 or abs(y - self.yOpen) > 1000:
  239.             self.Close()
  240.            
  241.     def Open(self):
  242.         if not self.IsShow():
  243.             self.Show()
  244.             (self.xOpen, self.yOpen, z) = player.GetMainCharacterPosition()
  245.             event.QuestButtonClick(int(constInfo.TOMBOLA_INFO))
  246.         else:
  247.             self.Close()
  248.            
  249.     def Close(self):
  250.         if self.IsShow():
  251.             self.Hide()
  252.            
  253.     def OnClose(self):
  254.         self.Close()
  255.        
  256.     def OnPressEscapeKey(self):
  257.         self.Close()
  258.         return TRUE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement