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

releaseControlBtn.py (3573B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\shipHud\releaseControlBtn.py
      2 import carbonui.const as uiconst
      3 from carbonui.primitives.container import Container
      4 from carbonui.primitives.sprite import Sprite
      5 from localization import GetByLabel
      6 import math
      7 from carbonui.uicore import uicore
      8 from structures.types import IsFlexStructure
      9 MOUSE_OFF_OPACITY = 0.5
     10 MOUSE_ON_OPACITY = 1.0
     11 COLOR_TAKE_CONTROL = (172 / 255.0,
     12  84 / 255.0,
     13  40 / 255.0,
     14  1.0)
     15 
     16 class ReleaseControlBtn(Container):
     17     default_name = 'ReleaseControlBtn'
     18     default_width = 104
     19     default_height = 44
     20     default_state = uiconst.UI_NORMAL
     21 
     22     def ApplyAttributes(self, attributes):
     23         Container.ApplyAttributes(self, attributes)
     24         self.func = attributes.func
     25         self.structureTypeID = attributes.structureTypeID
     26         if IsFlexStructure(self.structureTypeID):
     27             self.hintText = GetByLabel('UI/Inflight/HUDOptions/BoardPreviousShipFromFlex')
     28         else:
     29             self.hintText = GetByLabel('UI/Inflight/HUDOptions/ReleaseControl')
     30         self.pickParent = Container(name='speedCircularPickParent', parent=self, align=uiconst.CENTERBOTTOM, pos=(0, 0, 144, 144), pickRadius=72, state=uiconst.UI_NORMAL)
     31         self.pickParent.OnMouseMove = self.OnMoveInPickParent
     32         self.pickParent.OnMouseExit = self.OnMouseExit
     33         self.pickParent.OnMouseEnter = self.OnMouseEnter
     34         self.pickParent.OnClick = self.OnClick
     35         self.pickParent.GetTooltipPosition = self.GetPickParentTooltipPosition
     36         self.arrowSprite = Sprite(parent=self.pickParent, name='releaseArrow', pos=(0, 0, 104, 44), align=uiconst.CENTERBOTTOM, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/ShipUI/releaseArrow.png', opacity=MOUSE_OFF_OPACITY, color=COLOR_TAKE_CONTROL)
     37         Sprite(parent=self.pickParent, name='buttonBody', pos=(0, 0, 104, 44), align=uiconst.CENTERBOTTOM, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/ShipUI/buttonBody.png')
     38 
     39     def OnMouseEnter(self, *args):
     40         self.OnMoveInPickParent()
     41 
     42     def OnMoveInPickParent(self, *args):
     43         isInside = self.IsInside()
     44         if isInside:
     45             hint = self.hintText
     46             opacity = MOUSE_ON_OPACITY
     47         else:
     48             hint = ''
     49             opacity = MOUSE_OFF_OPACITY
     50         self.pickParent.hint = hint
     51         self.arrowSprite.opacity = opacity
     52 
     53     def GetPickParentTooltipPosition(self):
     54         if self.pickParent is None or self.pickParent.destroyed:
     55             return (uicore.uilib.x - 5,
     56              uicore.uilib.y - 5,
     57              10,
     58              10)
     59         retLeft, retTop, retWidth, retHeight = self.GetAbsolute()
     60         return (retLeft,
     61          retTop + 14,
     62          retWidth,
     63          retHeight)
     64 
     65     def IsInside(self):
     66         if uicore.uilib.GetMouseOver() != self.pickParent:
     67             return False
     68         l, t, w, h = self.pickParent.GetAbsolute()
     69         centerX = l + w / 2
     70         centerY = t + h / 2
     71         y = float(uicore.uilib.y - centerY)
     72         x = float(uicore.uilib.x - centerX)
     73         if x and y:
     74             angle = math.atan(x / y)
     75             deg = angle / math.pi * 180.0
     76             factor = (45.0 + deg) / 90.0
     77             if factor < 0.0 or factor > 1.0:
     78                 return False
     79             return True
     80         return False
     81 
     82     def OnMouseExit(self, *args):
     83         self.arrowSprite.opacity = MOUSE_OFF_OPACITY
     84         self.hint = ''
     85 
     86     def OnClick(self, *args):
     87         if self.IsInside():
     88             self.func(self.structureTypeID)