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

cleanupSkyhookEntry.py (8559B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\sov\sovHub\skyhooksCleanup\cleanupSkyhookEntry.py
      2 import carbonui.text.styles
      3 from collections import OrderedDict
      4 import eveicon
      5 from carbonui import Align
      6 from carbonui.control.checkbox import Checkbox
      7 from carbonui.fontconst import EVE_BODY_FONTSIZE
      8 from carbonui.primitives.container import Container
      9 from carbonui.uiconst import LABELTABMARGIN
     10 from eve.client.script.ui import eveThemeColor
     11 from eve.client.script.ui.control.baseListEntry import BaseListEntryCustomColumns
     12 from eve.client.script.ui.control.scrollUtil import ColumnInfo
     13 from eve.client.script.ui.control.toggleButtonGroup import ToggleButtonGroup
     14 from eve.client.script.ui.control.toggleButtonGroupButton import ToggleButtonGroupButtonIcon
     15 from eve.client.script.ui.control.toggleButtonUnderlay import ToggleButtonUnderlay, FrameType
     16 from eve.client.script.ui.shared.sov.sovHub.skyhooksCleanup.cleanupSkyhookEntryController import MODE_DESTROY, MODE_ACQUIRE
     17 from eveexceptions import ExceptionEater
     18 from eveservices.menu import GetMenuService
     19 from localization import GetByLabel
     20 from carbonui.uicore import uicore
     21 import carbonui
     22 from signals.signalUtil import ConnectSignals, DisconnectSignals
     23 HEIGHT = 32
     24 PADDING_8 = 8
     25 PADDING_16 = 16
     26 PADDING_32 = 32
     27 CHECKBOX_PADDING = 24
     28 
     29 class CleanupSkyhookEntry(BaseListEntryCustomColumns):
     30     default_name = 'CleanupSkyhookEntry'
     31     default_height = HEIGHT
     32     headerInfo = d = OrderedDict()
     33     d['owner'] = ColumnInfo('UI/Common/Owner', None, False)
     34     d['name'] = ColumnInfo('UI/Common/Location', None)
     35     d['status'] = ColumnInfo('UI/Common/Status', None)
     36     d['toggle'] = ColumnInfo(-1, fixedWidth=70)
     37 
     38     def __init__(self, *args, **kwargs):
     39         self.controller = None
     40         super(CleanupSkyhookEntry, self).__init__(*args, **kwargs)
     41 
     42     def ApplyAttributes(self, attributes):
     43         BaseListEntryCustomColumns.ApplyAttributes(self, attributes)
     44         self.controller = self.node.entryController
     45         self.AddAnchoredButtons()
     46         self.AddCheckboxAndOwnerColumn()
     47         self.AddColumnBodyText(self.controller.locationText)
     48         statusLabel = self.AddColumnBodyText(self.controller.statusText)
     49         statusLabel.SetTextColor(self.controller.statusColor)
     50         self.AddColumnContainer()
     51         self.UpdateOpacity()
     52         signalsAndCallbacks = self.GetSignalsAndCallbacks()
     53         ConnectSignals(signalsAndCallbacks)
     54 
     55     def GetSignalsAndCallbacks(self):
     56         return [(self.controller.on_entry_updated, self.OnEntryUpdate), (self.controller.on_mode_updated, self.OnEntryUpdate)]
     57 
     58     def AddAnchoredButtons(self):
     59         cont = Container(parent=self, align=Align.CENTERRIGHT, state=carbonui.uiconst.UI_NORMAL, pos=(0, 0, 70, 24))
     60         self.toggleSwitchGroup = ToggleButtonGroup(name='toggleSwitchGroup', parent=cont, align=Align.CENTERRIGHT, height=24, width=64, callback=self.OnMyToggleBtnGroup, btnClass=ToggleButtonGroupButtonIconSwitch)
     61         self.toggleSwitchGroup.AddButton(MODE_DESTROY, iconSize=16, iconPath=eveicon.trashcan, btnClass=ToggleButtonGroupButtonIconSwitch, underlayClass=ToggleButtonUnderlaySwitch, colorSelected=eveThemeColor.THEME_ALERT, hint=GetByLabel('UI/Sovereignty/SovHub/SystemCleanup/Destroy'))
     62         self.toggleSwitchGroup.AddButton(MODE_ACQUIRE, iconSize=16, iconPath=eveicon.trade, btnClass=ToggleButtonGroupButtonIconSwitch, underlayClass=ToggleButtonUnderlaySwitch, colorSelected=eveThemeColor.THEME_FOCUS, hint=GetByLabel('UI/Sovereignty/SovHub/SystemCleanup/Convert'))
     63         self.toggleSwitchGroup.SetSelectedByID(MODE_ACQUIRE)
     64 
     65     def OnMyToggleBtnGroup(self, selectedID, oldSelectedID):
     66         self.controller.SetTransitMode(selectedID)
     67 
     68     def AddCheckboxAndOwnerColumn(self):
     69         column = self.AddColumnContainer()
     70         cb = Checkbox(parent=column, align=carbonui.Align.CENTERLEFT, left=PADDING_8, setting=self.controller.checkedSettings)
     71         if self.controller.IsProcessed():
     72             cb.disabled = True
     73         label = carbonui.text.styles.TextBody(parent=column, text=self.controller.ownerText, align=Align.CENTERLEFT, left=LABELTABMARGIN + CHECKBOX_PADDING)
     74         return label
     75 
     76     @staticmethod
     77     def GetColumnSortValues(controller):
     78         baseColumns = (controller.locationText.lower(), controller.ownerText.lower(), controller.statusText.lower())
     79         return baseColumns
     80 
     81     @staticmethod
     82     def GetSortValue(node, by, sortDirection, idx):
     83         return (node.columnSortValues[idx],) + tuple(node.columnSortValues)
     84 
     85     @classmethod
     86     def GetHeaders(cls):
     87         return [ x.columnText for x in cls.headerInfo.itervalues() ]
     88 
     89     @staticmethod
     90     def GetDynamicHeight(node, width):
     91         return HEIGHT
     92 
     93     @staticmethod
     94     def GetDefaultColumnWidth(*args):
     95         return {x.columnText:x.defaultWidth for x in CleanupSkyhookEntry.headerInfo.itervalues() if x.defaultWidth}
     96 
     97     def GetMenu(self):
     98         return GetMenuService().GetMenuFromItemIDTypeID(itemID=self.controller.itemID, typeID=self.controller.typeID)
     99 
    100     @staticmethod
    101     def GetColWidths(node, idx = None):
    102         controller = node.entryController
    103         LABEL_PARAMS = (EVE_BODY_FONTSIZE, 0, 0)
    104         measure = uicore.font.MeasureTabstops
    105 
    106         def GetWidthFor(idx):
    107             if idx == 0:
    108                 ownerText = controller.ownerText
    109                 checkboxPadding = CHECKBOX_PADDING
    110                 return checkboxPadding + measure([(ownerText,) + LABEL_PARAMS])[0]
    111             if idx == 1:
    112                 nameText = unicode(controller.locationText)
    113                 return measure([(nameText,) + LABEL_PARAMS])[0]
    114             if idx == 2:
    115                 return measure([(controller.statusText,) + LABEL_PARAMS])[0]
    116             return 50
    117 
    118         if idx is None:
    119             colWidths = [ GetWidthFor(i) for i in xrange(len(CleanupSkyhookEntry.headerInfo)) ]
    120             return colWidths
    121         return [GetWidthFor(idx)]
    122 
    123     def OnEntryUpdate(self):
    124         self.UpdateOpacity()
    125 
    126     def UpdateOpacity(self):
    127         isProcessed = self.controller.IsProcessed()
    128         if not isProcessed and self.controller.IsChecked():
    129             self.opacity = 1.0
    130             self.toggleSwitchGroup.state = carbonui.uiconst.UI_PICKCHILDREN
    131             for btn in self.toggleSwitchGroup.buttons:
    132                 btn.SetEnabled()
    133 
    134         else:
    135             self.opacity = 0.4
    136             self.toggleSwitchGroup.state = carbonui.uiconst.UI_DISABLED
    137             for btn in self.toggleSwitchGroup.buttons:
    138                 if isProcessed:
    139                     self.toggleSwitchGroup.opacity = 2.5
    140                     btn.UpdateColorSelected((1, 1, 1, 0.3))
    141                 else:
    142                     btn.SetDisabled()
    143 
    144     def OnClick(self, *args):
    145         if self.controller.IsProcessed():
    146             return
    147         self.controller.OnEntryClicked()
    148 
    149     def Close(self):
    150         with ExceptionEater('Closing CleanupSkyhookEntry'):
    151             signalsAndCallbacks = self.GetSignalsAndCallbacks()
    152             DisconnectSignals(signalsAndCallbacks)
    153         super(CleanupSkyhookEntry, self).Close()
    154 
    155 
    156 class ToggleButtonGroupButtonIconSwitch(ToggleButtonGroupButtonIcon):
    157 
    158     def OnButtonAdded(self):
    159         if not self.parent:
    160             return
    161         super(ToggleButtonGroupButtonIconSwitch, self).OnButtonAdded()
    162         idx = self.GetOrder()
    163         is_first = idx == 0
    164         is_last = idx == len(self.parent.children) - 1
    165         if not is_first:
    166             self.padLeft = 0
    167         if not is_last:
    168             self.padRight = 0
    169 
    170     def UpdateColorSelected(self, newColor):
    171         self.colorSelected = newColor
    172         self._underlay.UpdateColorSelected(newColor)
    173 
    174 
    175 class ToggleButtonUnderlaySwitch(ToggleButtonUnderlay):
    176 
    177     def _get_texture_path(self):
    178         if self.frame_type == FrameType.LEFT:
    179             return 'res:/UI/Texture/classes/toggleSwitch/leftFrame.png'
    180         if self.frame_type == FrameType.RIGHT:
    181             return 'res:/UI/Texture/classes/toggleSwitch/rightFrame.png'
    182         return 'res:/UI/Texture/classes/toggleSwitch/centerFrame.png'
    183 
    184     def _get_unselected_color(self):
    185         return (1.0, 1.0, 1.0, 0.1)
    186 
    187     def _update_color(self, duration = 0.0):
    188         return super(ToggleButtonUnderlaySwitch, self)._update_color(duration=0.0)
    189 
    190     def _update_glow_brightness(self, duration = 0.0):
    191         return super(ToggleButtonUnderlaySwitch, self)._update_color(duration=0.0)
    192 
    193     def UpdateColorSelected(self, newColor):
    194         self._selected_color_override = newColor
    195         self._update_color()