NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

megaMenu.py (3725B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\podGuide\megaMenu.py
      2 from carbonui.primitives.container import Container
      3 from carbonui.primitives.frame import Frame
      4 from carbonui.primitives.layoutGrid import LayoutGrid
      5 from carbonui.util.mouseTargetObject import MouseTargetObject
      6 from carbonui.util.various_unsorted import IsUnder
      7 import uthread
      8 from carbon.common.script.util.timerstuff import AutoTimer
      9 from eve.client.script.ui.podGuide.megaMenuEntries import MegaMenuHeader, MegaMenuEntry
     10 import carbonui.const as uiconst
     11 from carbonui.uicore import uicore
     12 
     13 class MegaMenu(Container):
     14     beingDestroyed = False
     15 
     16     def ApplyAttributes(self, attributes):
     17         Container.ApplyAttributes(self, attributes)
     18         megaMenuOptions = attributes.megaMenuOptions
     19         self.categoryInfo = attributes.categoryInfo
     20         self.openingButtonClass = attributes.openingButtonClass
     21         buttonContainer = Container(parent=self, name='buttonContainer', align=uiconst.TOTOP, height=50)
     22         navigationButton = self.openingButtonClass(parent=buttonContainer, categoryInfo=self.categoryInfo, state=uiconst.UI_NORMAL)
     23         Frame(bgParent=navigationButton, frameConst=('res:/UI/Texture/Shared/menuButtonBackground_Top.png', 17, -16))
     24         buttonContainer.height = navigationButton.height
     25         layoutGridCont = Container(name='layoutGridCont', parent=self)
     26         numSubgroups = len(megaMenuOptions)
     27         myLayoutGrid = LayoutGrid(parent=layoutGridCont, columns=numSubgroups, state=uiconst.UI_NORMAL)
     28         MouseTargetObject(myLayoutGrid)
     29         Frame(bgParent=myLayoutGrid, frameConst=('res:/UI/Texture/Shared/menuBackground.png', 17, -16))
     30         for eachColumnInfo in megaMenuOptions:
     31             column = MegaMenuColumn(columnInfo=eachColumnInfo)
     32             myLayoutGrid.AddCell(cellObject=column)
     33 
     34         al, at, aw, ah = myLayoutGrid.GetAbsolute()
     35         self.height = myLayoutGrid.height + buttonContainer.height
     36         self.width = myLayoutGrid.width
     37         self.updateThread = AutoTimer(100, self.UpdateMegaMenu)
     38         uicore.uilib.RegisterForTriuiEvents(uiconst.UI_MOUSEUP, self.OnGlobalMouseUp)
     39 
     40     def Close(self, *args):
     41         Container.Close(self, *args)
     42         self.updateThread = None
     43 
     44     def UpdateMegaMenu(self, *args):
     45         if self.beingDestroyed:
     46             return
     47         isMouseOverMenu = self.IsMouseOverMenu()
     48         if not isMouseOverMenu:
     49             self.beingDestroyed = True
     50             uthread.new(self.FadeOut_thread)
     51 
     52     def FadeOut_thread(self):
     53         uicore.animations.FadeOut(self, duration=0.25, callback=self.Close, sleep=True)
     54 
     55     def IsMouseOverMenu(self):
     56         overMegaMenu = IsUnder(uicore.uilib.mouseOver, self)
     57         overNavigationButton = IsUnder(uicore.uilib.mouseOver, self)
     58         return overMegaMenu or overNavigationButton
     59 
     60     def OnGlobalMouseUp(self, *args):
     61         uthread.new(self.Close)
     62 
     63 
     64 class MegaMenuColumn(LayoutGrid):
     65     default_columns = 1
     66     default_headerClass = MegaMenuHeader
     67     default_entryClass = MegaMenuEntry
     68 
     69     def ApplyAttributes(self, attributes):
     70         LayoutGrid.ApplyAttributes(self, attributes)
     71         headerClass = attributes.get('headerClass', self.default_headerClass)
     72         entryClass = attributes.get('entryClass', self.default_entryClass)
     73         columnInfo = attributes.columnInfo
     74         headerInfo = columnInfo['headerInfo']
     75         entryInfoList = columnInfo['entryInfoList']
     76         headerObject = headerClass(headerInfo=headerInfo)
     77         self.AddCell(cellObject=headerObject)
     78         for eachEntryInfo in entryInfoList:
     79             entryObject = entryClass(entryInfo=eachEntryInfo)
     80             self.AddCell(cellObject=entryObject)