Advertisement
deadx2

Untitled

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