예제 #1
0
 def AddOptionText(self):
     self.labelShadow = ThreePartContainer(
         parent=self,
         name='labelShadow',
         pos=(0, 0, 200, 30),
         align=uiconst.CENTERTOP,
         state=uiconst.UI_DISABLED,
         idx=0,
         leftTexturePath=
         'res:/UI/Texture/classes/RadialMenu/textShadowLeft.png',
         rightTexturePath=
         'res:/UI/Texture/classes/RadialMenu/textShadowRight.png',
         centerTexturePath=
         'res:/UI/Texture/classes/RadialMenu/textShadowCenter.png',
         sideSize=24,
         color=(0, 0, 0, 0.6))
     self.labelShadow.display = False
     self.shortcutHint = ShortcutHint(parent=self.labelShadow,
                                      text='',
                                      bgColor=(0.15, 0.15, 0.15, 1.0),
                                      textColor=(0.5, 0.5, 0.5, 1.0),
                                      align=uiconst.CENTERRIGHT,
                                      left=24,
                                      idx=0)
     self.optionLabel = uicontrols.EveLabelLarge(parent=self.labelShadow,
                                                 state=uiconst.UI_DISABLED,
                                                 align=uiconst.CENTER,
                                                 top=0,
                                                 idx=0,
                                                 bold=True)
     self.optionLabel.display = False
     self.AdjustTextShadow()
예제 #2
0
 def ApplyAttributes(self, attributes):
     ProbeTooltipButtonBase.ApplyAttributes(self, attributes)
     self.checkBox = Checkbox(groupname=attributes.groupName,
                              align=uiconst.CENTER,
                              checked=attributes.checked,
                              retval=attributes.retval,
                              wrapLabel=True,
                              prefstype=None,
                              width=16,
                              height=16,
                              state=uiconst.UI_DISABLED)
     self.AddCell(self.checkBox, cellPadding=(5, 1, 4, 1))
     self.deleteFunction = attributes.deleteFunc
     self.editFunction = attributes.editFunc
     self.label = EveLabelSmall(text=attributes.text,
                                bold=True,
                                align=uiconst.CENTERLEFT,
                                autoFitToText=True,
                                width=128)
     self.AddCell(self.label,
                  colSpan=1 if attributes.filterIndex is not None else 2,
                  cellPadding=(0, 2, 6, 2))
     if attributes.filterIndex is not None:
         shortcutObj = ShortcutHint(text=str(attributes.filterIndex))
         self.AddCell(shortcutObj, cellPadding=(2, 2, 2, 0))
         return shortcutObj
예제 #3
0
 def AddTypeAndIcon(self,
                    label,
                    typeID,
                    moduleShortcut=None,
                    moduleDamageAmount=0,
                    iconSize=26,
                    minRowSize=30):
     self.FillRow()
     self.AddSpacer(height=minRowSize, width=0)
     iconCont = Container(pos=(0, 0, iconSize, iconSize),
                          align=uiconst.CENTER)
     iconObj = Icon(parent=iconCont,
                    pos=(0, 0, iconSize, iconSize),
                    align=uiconst.TOPLEFT,
                    ignoreSize=True)
     iconObj.LoadIconByTypeID(typeID, size=iconSize, ignoreSize=True)
     techIcon = Icon(parent=iconCont,
                     width=16,
                     height=16,
                     align=uiconst.TOPLEFT,
                     idx=0,
                     top=0)
     GetTechLevelIcon(techIcon, typeID=typeID)
     self.AddCell(iconCont, cellPadding=2)
     if moduleShortcut:
         nameColSpan = self.columns - 3
     else:
         nameColSpan = self.columns - 2
     if moduleDamageAmount > 0:
         damagedText = localization.GetByLabel(
             'UI/Inflight/ModuleRacks/ModuleDamaged',
             color='<color=red>',
             percentageNum=moduleDamageAmount)
         label += '<br>' + damagedText
     labelObj = self.AddLabelMedium(text=label,
                                    align=uiconst.CENTERLEFT,
                                    cellPadding=self.labelPadding,
                                    colSpan=nameColSpan)
     if moduleShortcut:
         shortcutObj = ShortcutHint(text=moduleShortcut)
         shortcutObj.width += 10
         shortcutObj.padLeft = 10
         self.AddCell(shortcutObj)
     return (iconObj, labelObj)
예제 #4
0
 def AddTypeAndIcon(self, iconSize = 26, minRowSize = 30):
     self.FillRow()
     self.AddSpacer(height=minRowSize, width=0)
     iconID = self.ability.iconID
     iconCont = Container(pos=(0,
      0,
      iconSize,
      iconSize), align=uiconst.CENTER)
     iconObj = Icon(parent=iconCont, pos=(0,
      0,
      iconSize,
      iconSize), icon=iconID, align=uiconst.TOPLEFT, ignoreSize=True)
     self.AddCell(iconCont, cellPadding=2)
     nameColSpan = self.columns - 3
     abilityName = GetByMessageID(self.abilityNameID)
     label = abilityText = '<b>%s</b>' % abilityName
     labelObj = self.AddLabelMedium(text=label, align=uiconst.CENTERLEFT, cellPadding=self.labelPadding, colSpan=nameColSpan)
     abilityShortcut = uicore.cmd.GetShortcutStringByFuncName('CmdActivateHighPowerSlot%i' % (self.slotID + 1))
     shortcutObj = ShortcutHint(text=abilityShortcut)
     shortcutObj.width += 10
     shortcutObj.padLeft = 10
     self.AddCell(shortcutObj)
     return (iconObj, labelObj)
예제 #5
0
class RadialMenuShipUI(RadialMenu):
    __guid__ = 'uicls.RadialMenuShipUI'
    default_left = 0
    default_top = 0
    default_align = uiconst.TOPLEFT
    default_width = RM1_SizeInfo.width
    default_height = RM1_SizeInfo.height
    sizeInfo = RM1_SizeInfo
    default_showActionText = True
    shadowTexture = 'res:/UI/Texture/classes/RadialMenu/menuShadow3.png'
    buttonBackgroundOpacity = 0.9

    def SetSpecificValues(self, attributes):
        self.anchorObject = attributes.anchorObject
        self.displayName = attributes.displayName
        self.upCounter = 0

    def SetPosition(self):
        left, top, width, height = self.anchorObject.GetAbsolute()
        self.originalX = self.currentCenterX = left + width / 2
        self.originalY = self.currentCenterY = top + height / 2
        self.left = self.originalX - self.width / 2
        self.top = self.originalY - self.height / 2

    def LoadMyActions(self, doReset=False, animate=False, *args):
        optionsInfo = self.GetMyActions()
        if optionsInfo is None:
            return
        self.LoadButtons(self.firstLayerCont, optionsInfo, doReset=doReset)
        if animate:
            self.AnimateMenuFromCenter(duration=0.1)

    def GetMyActions(self, *args):
        pass

    def AdjustTextShadow(self, *args):
        if not self.optionLabel.display:
            if getattr(self, 'labelShadow', None):
                self.labelShadow.display = False
            return
        shorcutPadding = self.GetPaddingBecauseOfShortcut()
        centerWidth = self.optionLabel.textwidth + shorcutPadding
        self.optionLabel.left = -shorcutPadding / 2
        height = self.optionLabel.textheight + 4
        top = -18
        self.labelShadow.display = True
        self.labelShadow.SetCenterSizeAndTop(centerWidth, height, top=top)

    def GetPaddingBecauseOfShortcut(self):
        if not self.shortcutHint.textLabel.text:
            return 0
        return self.shortcutHint.width + 5

    def AddOptionText(self):
        self.labelShadow = ThreePartContainer(
            parent=self,
            name='labelShadow',
            pos=(0, 0, 200, 30),
            align=uiconst.CENTERTOP,
            state=uiconst.UI_DISABLED,
            idx=0,
            leftTexturePath=
            'res:/UI/Texture/classes/RadialMenu/textShadowLeft.png',
            rightTexturePath=
            'res:/UI/Texture/classes/RadialMenu/textShadowRight.png',
            centerTexturePath=
            'res:/UI/Texture/classes/RadialMenu/textShadowCenter.png',
            sideSize=24,
            color=(0, 0, 0, 0.6))
        self.labelShadow.display = False
        self.shortcutHint = ShortcutHint(parent=self.labelShadow,
                                         text='',
                                         bgColor=(0.15, 0.15, 0.15, 1.0),
                                         textColor=(0.5, 0.5, 0.5, 1.0),
                                         align=uiconst.CENTERRIGHT,
                                         left=24,
                                         idx=0)
        self.optionLabel = uicontrols.EveLabelLarge(parent=self.labelShadow,
                                                    state=uiconst.UI_DISABLED,
                                                    align=uiconst.CENTER,
                                                    top=0,
                                                    idx=0,
                                                    bold=True)
        self.optionLabel.display = False
        self.AdjustTextShadow()

    def GetIconTexturePath(self, activeOption, menuOptions=None):
        return menuOptions.iconPath

    def OnMouseUp(self, button, *args):
        uicore.uilib.UnclipCursor()
        self.cursorClipped = False
        self.upCounter += 1
        radialMenuBtn = self.GetRadialMenuButton()
        if button != radialMenuBtn:
            self.Close()
        if self.selectedBtn:
            self.ClickButton(self.selectedBtn)
        elif self.upCounter > 1:
            self.Close()

    def OnMouseUpBlocker(self, button, *args):
        uicls.RadialMenu.OnMouseUp(self, button, *args)

    def IsRadialMenuButtonActive(self, *args):
        if self.upCounter:
            return False
        menuButton = self.GetRadialMenuButton()
        actionmenuBtnState = uicore.uilib.GetMouseButtonState(menuButton)
        return actionmenuBtnState

    def GetRadialMenuButton(self, *args):
        return uiconst.MOUSELEFT

    def HiliteOneButton(self, btnCont, buttonLayer):
        RadialMenu.HiliteOneButton(self, btnCont, buttonLayer)
        self.SetShortcut(btnCont)
        self.AdjustTextShadow()

    def SetShortcut(self, btnCont):
        shortcutStr = self.GetShortcutString(btnCont)
        if not shortcutStr:
            return self.ClearShortcutHint()
        self.shortcutHint.display = True
        self.shortcutHint.textLabel.text = shortcutStr
        self.shortcutHint.AdjustSize()

    def GetShortcutString(self, btnCont):
        if not btnCont or not btnCont.actionButton:
            return
        commandName = getattr(btnCont.actionButton, 'commandName', None)
        if not commandName:
            return
        command = uicore.cmd.commandMap.GetCommandByName(commandName)
        if not command:
            return
        shortcutStr = command.GetShortcutAsString()
        return shortcutStr

    def ClearShortcutHint(self):
        self.shortcutHint.textLabel.text = ''
        self.shortcutHint.display = False