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

mapViewPanel.py (6590B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\mapView\mapViewPanel.py
      2 import carbonui.const as uiconst
      3 import logging
      4 from carbonui.primitives.fill import Fill
      5 from carbonui.uicore import uicore
      6 from eve.client.script.ui import eveColor
      7 from eve.client.script.ui.shared.info.shipInfoWindow import EXPANDED_WIDTH
      8 from eve.client.script.ui.shared.mapView.controls.mapViewSettingButtons import MapViewSettingButtons
      9 from eve.client.script.ui.shared.mapView.dockPanel import DockablePanel
     10 from eve.client.script.ui.shared.mapView.dockPanelConst import DOCKPANELID_MAP
     11 from eve.client.script.ui.shared.mapView.mapViewConst import MAPVIEW_PRIMARY_ID
     12 from eve.client.script.ui.shared.mapView.mapViewWorld import MapViewWorld
     13 from eve.client.script.ui.shared.mapView.sidePanel.widgets.ore_availability.const import ORE_FILTERS_BY_CLASS
     14 from eve.client.script.ui.shared.mapView.sidePanel.widgets.ore_availability.controller import OreAvailabilityFilterController
     15 from eve.client.script.ui.shared.maps import mapcommon
     16 from eve.client.script.ui.view.viewStateConst import ViewState
     17 from mining.client import ore_const
     18 log = logging.getLogger(__name__)
     19 OVERLAY_LEFT_PADDING_FULLSCREEN = 128
     20 OVERLAY_RIGHT_PADDING_FULLSCREEN = 128
     21 OVERLAY_SIDE_PADDING_NONFULLSCREEN = 6
     22 EXPANDED_WIDTH = 600
     23 
     24 class MapViewPanel(DockablePanel):
     25     __notifyevents__ = DockablePanel.__notifyevents__ + ['OnSetCameraOffset', 'OnHideUI', 'OnShowUI']
     26     default_captionLabelPath = 'UI/Neocom/MapBtn'
     27     default_windowID = DOCKPANELID_MAP
     28     default_iconNum = 'res:/UI/Texture/windowIcons/map.png'
     29     default_analyticID = 'Map'
     30     default_minSize = (300, 300)
     31     panelID = default_windowID
     32     mapViewID = MAPVIEW_PRIMARY_ID
     33     mapView = None
     34     viewState = ViewState.StarMapNew
     35     hasImmersiveAudioOverlay = True
     36 
     37     def OnSetCameraOffset(self, cameraOffset):
     38         if self.mapView and not self.mapView.destroyed:
     39             if self.IsFullscreen():
     40                 x = -(cameraOffset * 0.5 - 0.5)
     41                 self.mapView.camera.cameraCenter = (x, 0.5)
     42             else:
     43                 self.mapView.camera.cameraCenter = (0.5, 0.5)
     44 
     45     def ApplyAttributes(self, attributes):
     46         self._expanded = False
     47         DockablePanel.ApplyAttributes(self, attributes)
     48         if not sm.GetService('ui').IsUiVisible():
     49             self.toolbarContainer.display = False
     50         zoomToItem = attributes.get('zoomToItem', True)
     51         self.mapView = MapViewWorld(parent=self.content, isFullScreen=self.IsFullscreen(), mapViewID=self.mapViewID, interestID=attributes.interestID, mapFilterID=attributes.starColorMode, zoomToItem=zoomToItem)
     52         if self.IsFullscreen():
     53             self.mapView.overlayTools.padding = (OVERLAY_LEFT_PADDING_FULLSCREEN,
     54              self.toolbarContainer.height + 6,
     55              OVERLAY_RIGHT_PADDING_FULLSCREEN,
     56              6)
     57         else:
     58             self.mapView.overlayTools.padding = (OVERLAY_SIDE_PADDING_NONFULLSCREEN,
     59              self.toolbarContainer.height + 6,
     60              OVERLAY_SIDE_PADDING_NONFULLSCREEN,
     61              6)
     62         MapViewSettingButtons(parent=self.toolbarContainer, align=uiconst.CENTERLEFT, onSettingsChangedCallback=self.mapView.OnMapViewSettingChanged, mapViewID=self.mapViewID, left=4, idx=0)
     63         Fill(bgParent=self.content, color=eveColor.BLACK, opacity=1.0)
     64 
     65     def Close(self, *args, **kwds):
     66         DockablePanel.Close(self, *args, **kwds)
     67         self.mapView = None
     68 
     69     def OnShowUI(self):
     70         self.mapView.overlayTools.display = True
     71         self.toolbarContainer.display = True
     72 
     73     def OnHideUI(self):
     74         if self.IsFullscreen():
     75             self.mapView.overlayTools.display = False
     76             self.toolbarContainer.display = False
     77 
     78     def SetActiveItemID(self, *args, **kwds):
     79         if self.mapView:
     80             return self.mapView.SetActiveItemID(*args, **kwds)
     81 
     82     def SetMapFilter(self, *args, **kwds):
     83         if self.mapView:
     84             return self.mapView.SetMapFilter(*args, **kwds)
     85 
     86     def OnDockModeChanged(self, *args, **kwds):
     87         if self.mapView:
     88             if self.mapView.overlayTools and not self.mapView.overlayTools.destroyed:
     89                 if self.IsFullscreen():
     90                     self.mapView.overlayTools.padLeft = OVERLAY_LEFT_PADDING_FULLSCREEN
     91                     self.mapView.overlayTools.padRight = OVERLAY_RIGHT_PADDING_FULLSCREEN
     92                 else:
     93                     self.mapView.overlayTools.padLeft = OVERLAY_SIDE_PADDING_NONFULLSCREEN
     94                     self.mapView.overlayTools.padRight = OVERLAY_SIDE_PADDING_NONFULLSCREEN
     95             self.mapView.OnDockModeChanged(self.IsFullscreen())
     96 
     97     def _OnResize(self, *args):
     98         DockablePanel._OnResize(self, *args)
     99         if self.mapView:
    100             self.mapView.OnWindowResize(self.width, self.height)
    101 
    102     def OnResizeUpdate(self, *args):
    103         if self.IsFullscreen():
    104             return
    105         _, _, width, _ = self.displayRect
    106         self._expanded = width >= uicore.ScaleDpi(EXPANDED_WIDTH)
    107 
    108     def SetActive(self, *args, **kwds):
    109         DockablePanel.SetActive(self, *args, **kwds)
    110         if self.mapView:
    111             self.mapView.SetFocusState(True)
    112 
    113     def OnSetInactive(self, *args, **kwds):
    114         DockablePanel.OnSetInactive(self, *args, **kwds)
    115         if self.mapView:
    116             self.mapView.SetFocusState(False)
    117 
    118     def CmdZoomInOut(self, zoomDelta):
    119         if self.mapView:
    120             self.mapView.camera.Zoom(0.0005 * zoomDelta)
    121 
    122     def OnStartMinimize_(self, *args):
    123         try:
    124             self.mapView.Hide()
    125         except AttributeError:
    126             pass
    127 
    128     def OnStartMaximize_(self, *args):
    129         try:
    130             self.mapView.Show()
    131         except AttributeError:
    132             pass
    133 
    134     @property
    135     def expanded(self):
    136         return self._expanded
    137 
    138     @classmethod
    139     def show_ore_distribution_filter(cls, type_id):
    140         if type_id in ore_const.BASE_TYPE_BY_VARIANT_TYPE:
    141             type_id = ore_const.BASE_TYPE_BY_VARIANT_TYPE[type_id]
    142         ore_class = ore_const.ORE_CLASS_BY_BASE_TYPE_ID.get(type_id, None)
    143         filter_id = ORE_FILTERS_BY_CLASS.get(ore_class, None)
    144         if filter_id:
    145             OreAvailabilityFilterController().set_selected_ore_type(ore_class, type_id)
    146         else:
    147             filter_id = mapcommon.STARMODE_ORE_AVAILABILITY
    148         wnd = cls.GetIfOpen()
    149         if wnd:
    150             wnd.SetMapFilter(filter_id, updateFocus=False)
    151             if wnd.IsMinimized():
    152                 wnd.Maximize()
    153         else:
    154             MapViewPanel.Open(starColorMode=filter_id)