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

mapDebugContainer.py (2327B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\mapView\mapDebugContainer.py
      2 import random
      3 from carbon.common.script.util.timerstuff import AutoTimer
      4 from carbonui.text.styles import TextBody
      5 from carbonui.primitives.container import Container
      6 import carbonui.const as uiconst
      7 from logging import getLogger
      8 logger = getLogger(__name__)
      9 
     10 class MapDebugContainer(Container):
     11     default_align = uiconst.TOPRIGHT
     12     default_height = 200
     13     default_width = 200
     14     default_bgColor = (0.1, 0.1, 0.1, 1.3)
     15 
     16     def ApplyAttributes(self, attributes):
     17         super(MapDebugContainer, self).ApplyAttributes(attributes)
     18         self.mapView = attributes.mapView
     19         self.text = TextBody(parent=self, text='', align=uiconst.TOPRIGHT)
     20         self.updateTimer = AutoTimer(1000, self.UpdateData)
     21 
     22     def UpdateData(self, *args, **kwargs):
     23         if self.destroyed:
     24             self.updateTimer = None
     25             return
     26         try:
     27             self._UpdateData()
     28         except Exception as e:
     29             logger.exception('Failed to update debug data')
     30 
     31     def _UpdateData(self):
     32         camera = self.mapView.camera
     33         zoomValue = round(camera.GetZoomValue(), 3)
     34         zoomDist = round(camera.GetZoomDistance(), 3)
     35         aspectRatio = round(camera.GetAspectRatio(), 3)
     36         projectionFovConst = round(camera.GetProjectionFovConst(aspectRatio), 3)
     37         viewportX = self.mapView.sceneContainer.viewport.x
     38         viewportY = self.mapView.sceneContainer.viewport.y
     39         viewportWidth = self.mapView.sceneContainer.viewport.width
     40         viewportHeight = self.mapView.sceneContainer.viewport.height
     41         viewportProp = round(float(viewportWidth) / viewportHeight, 3)
     42         textList = ['Zoom Value = %s' % zoomValue,
     43          'Zoom Dist = %s' % zoomDist,
     44          'aspectRatio = %s' % aspectRatio,
     45          'projectionFovConst = %s' % projectionFovConst,
     46          '',
     47          'viewportX = %s' % viewportX,
     48          'viewportY = %s' % viewportY,
     49          'viewportWidth = %s' % viewportWidth,
     50          'viewportHeight = %s' % viewportHeight,
     51          'viewportProp = %s' % viewportProp]
     52         text = '<br>'.join(textList)
     53         self.text.SetText(text)
     54 
     55     def Close(self):
     56         super(MapDebugContainer, self).Close()
     57         self.mapView = None