deadx2

Untitled

Aug 28th, 2017
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.69 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.         image = uimg.ImageBox()
  49.         image.SetParent(self)
  50.         image.LoadImage("illumina/inne/tombola_new.tga")
  51.         image.SetPosition(6+8, 29+9)
  52.         image.Show()
  53.         self.background = image
  54.        
  55.         select = uimg.ImageBox()
  56.         select.SetParent(self.background)
  57.         select.SetPosition(14, 13)
  58.         select.LoadImage("d:/ymir work/ui/tombola/1.tga")
  59.         select.Hide()
  60.         self.select = select
  61.        
  62.         button = uimg.Button()
  63.         button.SetParent(self.background)
  64.         button.SetPosition(125+8+6, 124+9+5)
  65.         button.SetUpVisual("illumina/inne/tombola_btn1.tga")
  66.         button.SetOverVisual("illumina/inne/tombola_btn2.tga")
  67.         button.SetDownVisual("illumina/inne/tombola_btn3.tga")
  68.         button.SetEvent(uimg.__mem_func__(self.OnButtonClick))
  69.         button.Show()
  70.         #self.run = button
  71.         self.button = button
  72.        
  73.         button1 = uimg.RadioButton()
  74.         button1.SetParent(self.background)
  75.         button1.SetPosition(50-13, 356)
  76.         button1.SetUpVisual("illumina/inne/btn_kod2_long_01.tga")
  77.         button1.SetOverVisual("illumina/inne/btn_kod2_long_02.tga")
  78.         button1.SetDownVisual("illumina/inne/btn_kod2_long_03.tga")
  79.         #button1.SetEvent(uimg.__mem_func__(self.OnButtonClick))
  80.         #button1.SetFontColorNew(230, 208, 162)
  81.         button1.SetText("|cffe6d0a2Poziom I")
  82.         button1.Show()
  83.         self.button1 = button1
  84.        
  85.         button2 = uimg.RadioButton()
  86.         button2.SetParent(self.background)
  87.         button2.SetPosition(50+100-13, 356)
  88.         button2.SetUpVisual("illumina/inne/btn_kod2_long_01.tga")
  89.         button2.SetOverVisual("illumina/inne/btn_kod2_long_02.tga")
  90.         button2.SetDownVisual("illumina/inne/btn_kod2_long_03.tga")
  91.         #button2.SetEvent(uimg.__mem_func__(self.OnButtonClick))
  92.         #button2.SetFontColorNew(230, 208, 162)
  93.         button2.SetText("|cffe6d0a2Poziom II")
  94.         button2.Show()
  95.         self.button2 = button2
  96.        
  97.         button3 = uimg.RadioButton()
  98.         button3.SetParent(self.background)
  99.         button3.SetPosition(50+200-13, 356)
  100.         button3.SetUpVisual("illumina/inne/btn_kod2_long_01.tga")
  101.         button3.SetOverVisual("illumina/inne/btn_kod2_long_02.tga")
  102.         button3.SetDownVisual("illumina/inne/btn_kod2_long_03.tga")
  103.         #button3.SetEvent(uimg.__mem_func__(self.OnButtonClick))
  104.         #button3.SetFontColorNew(230, 208, 162)
  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.items = {}
  129.        
  130.     def __CreateSlot(self, number, x, y):
  131.         grid = uimg.GridSlotWindow()
  132.         grid.SetParent(self)
  133.         grid.SetPosition(x, y)
  134.         grid.ArrangeSlot(number, 1, 1, 32, 32, 0, 0)
  135.         grid.SetOverInItemEvent(uimg.__mem_func__(self.OverInItem))
  136.         grid.SetOverOutItemEvent(uimg.__mem_func__(self.OverOutItem))
  137.         grid.RefreshSlot()
  138.         grid.Show()
  139.        
  140.         return grid
  141.    
  142.     def OverInItem(self, slotIndex):
  143.         if slotIndex < 1 or slotIndex > 16:
  144.             return
  145.        
  146.         self.tooltipItem = uiToolTip.ItemToolTip()
  147.         self.tooltipItem.AddItemData(self.items[slotIndex - 1], 0, 0)
  148.         self.tooltipItem.Show()
  149.  
  150.     def OverOutItem(self):
  151.         if self.tooltipItem:
  152.             self.tooltipItem.HideToolTip()
  153.            
  154.     def OnButtonClick(self):
  155.         constInfo.CMDRESOLVER_MSG = "tombola|begin"
  156.         event.QuestButtonClick(int(constInfo.CMDRESOLVER_QUID))
  157.    
  158.     def OnPrepare(self, items):
  159.         items = items.split("|")
  160.        
  161.         j = 0
  162.         for i in range(0, 32, 2):
  163.             self.slots[j].SetItemSlot(j + 1, int(items[i]), int(items[i + 1]))
  164.             self.items[j] = int(items[i])
  165.             j += 1
  166.        
  167.     def OnRun(self, data):
  168.         data = data.split("|")
  169.        
  170.         self.toPosition = int(data[0])
  171.         self.speedDown = int(data[1])
  172.        
  173.         self.blinkTimes = 6
  174.         self.blinkLast = 0
  175.        
  176.         self.position = 1
  177.         self.animate = TRUE
  178.         self.blink = FALSE
  179.         self.timeDiff = 0.1
  180.        
  181.         self.lastClock = app.GetTime()
  182.        
  183.     def OnUpdate(self):
  184.         if self.animate == TRUE:
  185.             if (app.GetTime() - self.lastClock) >= self.timeDiff:
  186.                 self.lastClock = app.GetTime()
  187.                
  188.                 self.toPosition -= 1
  189.                
  190.                 if self.toPosition <= self.speedDown:
  191.                     self.timeDiff += 0.1
  192.                
  193.                 self.position += 1
  194.                 if self.position == 17:
  195.                     self.position = 1
  196.                
  197.                 if not self.select.IsShow():
  198.                     self.select.Show()
  199.                
  200.                 self.select.LoadImage("d:/ymir work/ui/tombola/" + str(self.position) + ".tga")
  201.                
  202.                 if self.toPosition == 0:
  203.                     self.animate = FALSE
  204.                     self.blink = TRUE
  205.                    
  206.                     constInfo.CMDRESOLVER_MSG = "tombola|end"
  207.                     event.QuestButtonClick(int(constInfo.CMDRESOLVER_QUID2))
  208.                    
  209.         if self.blink == TRUE and (app.GetTime() - self.blinkLast) >= 0.3:
  210.             if self.blinkTimes > 0:
  211.                 if self.blinkTimes % 2:
  212.                     self.select.Hide()
  213.                 else:
  214.                     self.select.Show()
  215.                 self.blinkTimes -= 1
  216.             else:  
  217.                 self.blink = FALSE
  218.                 self.blinkTimes = 6
  219.                 self.blinkLast = 0
  220.                 self.select.Hide()
  221.                 self.select.LoadImage("d:/ymir work/ui/tombola/1.tga")
  222.                
  223.             self.blinkLast = app.GetTime()
  224.            
  225.         (x, y, z) = player.GetMainCharacterPosition()
  226.         if abs(x - self.xOpen) > 1000 or abs(y - self.yOpen) > 1000:
  227.             self.Close()
  228.            
  229.     def Open(self):
  230.         if not self.IsShow():
  231.             self.Show()
  232.             (self.xOpen, self.yOpen, z) = player.GetMainCharacterPosition()
  233.             event.QuestButtonClick(int(constInfo.TOMBOLA_INFO))
  234.         else:
  235.             self.Close()
  236.            
  237.     def Close(self):
  238.         if self.IsShow():
  239.             self.Hide()
  240.            
  241.     def OnClose(self):
  242.         self.Close()
  243.        
  244.     def OnPressEscapeKey(self):
  245.         self.Close()
  246.         return TRUE
Advertisement
Add Comment
Please, Sign In to add comment