def ConstructLayout(self): if not self.jobData: return if self.jobData.status == industry.STATUS_READY: self.deliverBtn = Button( name='deliverBtn', parent=self, align=uiconst.TOALL, label='<b>' + localization.GetByLabel('UI/Industry/Deliver'), func=self.OnDeliverBtn, padding=2) self.deliverBtn.width = self.deliverBtn.height = 0 self.deliverBtn.Blink(time=3000) self.Enable() else: self.Disable() gaugeCont = ContainerAutoSize(name='gaugeCont', parent=self, align=uiconst.TOBOTTOM) mainCont = Container(name='mainCont', parent=self) self.deliverBtn = None self.valueLabel = EveLabelMedium(parent=mainCont, align=uiconst.CENTERLEFT, left=4) if self.jobData.status == industry.STATUS_INSTALLED: color = industryUIConst.COLOR_MANUFACTURING if self.jobData.activityID == industry.MANUFACTURING else industryUIConst.COLOR_SCIENCE self.gauge = Gauge(parent=gaugeCont, align=uiconst.TOTOP, state=uiconst.UI_DISABLED, color=color, height=6, gaugeHeight=6, padTop=1, backgroundColor=(1.0, 1.0, 1.0, 0.05))
def Layout(self): gaugeCont = Container(parent=self, align=uiconst.TOTOP, height=32) Frame(parent=gaugeCont, texturePath='res:/UI/Texture/classes/skilltrading/frame.png', cornerSize=3, opacity=0.5) self.gaugeBG = GradientSprite(bgParent=gaugeCont, align=uiconst.TOALL, rgbData=[(0.0, (1.0, 1.0, 1.0))], alphaData=[(0.0, 0.0), (0.4, 0.9), (0.6, 0.9), (1.0, 0.0)], opacity=0.1) self.extractButton = ExtractButton(parent=gaugeCont, align=uiconst.TOALL, controller=self.controller) self.gauge = Gauge(parent=gaugeCont, align=uiconst.TOTOP, state=uiconst.UI_DISABLED, height=30, gaugeHeight=30, top=1, color=COLOR_MODIFIED, backgroundColor=(1.0, 1.0, 0.0, 0.0)) self.noProgressHint = EveHeaderMedium( parent=gaugeCont, align=uiconst.CENTER, width=self.width, bold=True, text=localization.GetByLabel('UI/SkillTrading/DropToExtractHint'), opacity=0.5) self.amountLabel = ExtractorBarAmountLabel( parent=self, align=uiconst.TOTOP, top=2, goal=self.controller.SKILL_POINT_GOAL)
class JobStateContainer(Container): default_state = uiconst.UI_NORMAL def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.jobData = attributes.jobData self.ConstructLayout() self.UpdateValue() def ConstructLayout(self): if not self.jobData: return if self.jobData.status == industry.STATUS_READY: self.deliverBtn = Button(name='deliverBtn', parent=self, align=uiconst.TOALL, label='<b>' + localization.GetByLabel('UI/Industry/Deliver'), func=self.OnDeliverBtn, padding=2) self.deliverBtn.width = self.deliverBtn.height = 0 self.deliverBtn.Blink(time=3000) self.Enable() else: self.Disable() gaugeCont = ContainerAutoSize(name='gaugeCont', parent=self, align=uiconst.TOBOTTOM) mainCont = Container(name='mainCont', parent=self) self.deliverBtn = None self.valueLabel = EveLabelMedium(parent=mainCont, align=uiconst.CENTERLEFT, left=4) if self.jobData.status == industry.STATUS_INSTALLED: color = industryUIConst.COLOR_MANUFACTURING if self.jobData.activityID == industry.MANUFACTURING else industryUIConst.COLOR_SCIENCE self.gauge = Gauge(parent=gaugeCont, align=uiconst.TOTOP, state=uiconst.UI_DISABLED, color=color, height=6, gaugeHeight=6, padTop=1, backgroundColor=(1.0, 1.0, 1.0, 0.05)) def OnStatusChanged(self): self.Flush() self.ConstructLayout() if self.jobData.status == industry.STATUS_DELIVERED: uicore.animations.FadeTo(self.valueLabel, 0.0, 1.0) def UpdateValue(self, animate = False, num = 0): if not self.jobData or self.jobData.status in (industry.STATUS_READY, industry.STATUS_UNSUBMITTED): return if self.jobData.status == industry.STATUS_INSTALLED: progressRatio = self.jobData.GetJobProgressRatio() if progressRatio: self.gauge.SetValueInstantly(progressRatio) if animate and progressRatio != 1.0: self.gauge.AnimFlash(1.0, duration=3.0, timeOffset=num * 0.1) self.valueLabel.text = self.jobData.GetJobStateLabel() def OnDeliverBtn(self, *args): sm.GetService('industrySvc').CompleteJob(self.jobData.jobID) sm.GetService('audio').SendUIEvent('ind_jobDelivered') def OnNewJobData(self, jobData): self.jobData = jobData self.OnStatusChanged() self.UpdateValue(animate=True) def StartUpdate(self): uthread.new(self._UpdateThread) def _UpdateThread(self): while not self.destroyed: self.UpdateValue() blue.synchro.SleepWallclock(500)
def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.value = 0.0 iconPath = attributes.iconPath iconSize = attributes.iconSize minValue = attributes.minValue maxValue = attributes.maxValue showBG = attributes.get('showBG', True) isCompact = attributes.get('isCompact', False) self.jobData = attributes.jobData self.gauge = Gauge(parent=self, align=uiconst.TOBOTTOM, state=uiconst.UI_DISABLED, height=6, gaugeHeight=6, padTop=1, backgroundColor=(1.0, 1.0, 1.0, 0.05)) if isCompact: self.icon = None self.valueLabel = None return mainCont = Container(name='mainCont', parent=self) if showBG: self.bg = StretchSpriteHorizontal(bgParent=mainCont, texturePath='res:/UI/Texture/Classes/Industry/Center/bgMETE.png') FillThemeColored(bgParent=self, opacity=0.5) else: self.bg = None left = 8 if showBG else 2 self.icon = Sprite(name='icon', parent=mainCont, align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, pos=(left, 3, self.ICONSIZE, self.ICONSIZE), texturePath=self.ICONPATH, opacity=0.6) self.valueLabel = EveLabelMediumBold(parent=mainCont, align=uiconst.TOPRIGHT, top=4, left=left) self.removeIcon = Sprite(parent=mainCont, align=uiconst.CENTERRIGHT, state=uiconst.UI_HIDDEN, texturePath='res:/ui/texture/icons/73_16_45.png', pos=(0, 0, 12, 12), color=Color.RED, hint=localization.GetByLabel('UI/Industry/PreviewModeHint')) self.removeIcon.OnClick = self.OnRemoveIconClick self.previewEdit = SinglelineEdit(name='previewEdit', parent=mainCont, align=uiconst.CENTERRIGHT, state=uiconst.UI_HIDDEN, ints=(0, self.MAXVAL), OnChange=self.OnPreviewEdit, pos=(12, 0, 34, 20)) self.errorFrame = ErrorFrame(bgParent=self, padding=(1, 1, 1, 8))
def AddGaugeAndIconToContainer(self, container, damageType, color): iconCont = Container(parent=container, name='iconCont', width=self.iconSize, align=uiconst.TOLEFT, state=uiconst.UI_DISABLED) icon = Icon(parent=iconCont, pos=(0, 0, self.iconSize, self.iconSize), align=uiconst.CENTERLEFT, idx=0, ignoreSize=True, state=uiconst.UI_DISABLED) if not self.showIcon: iconCont.display = False gauge = Gauge(parent=container, name='gauge_%s' % damageType, value=0.0, color=color, gaugeHeight=self.gaugeHeight, align=uiconst.TOALL, pos=(0, self.gaugeTopOffset, 0, 0), state=uiconst.UI_DISABLED, gradientBrightnessFactor=1.5) container.gauge = gauge container.icon = icon setattr(self, 'gauge_%s' % damageType, gauge)
def ApplyAttributes(self, attributes): Gauge.ApplyAttributes(self, attributes) facilityData = attributes.facilityData activityID = attributes.activityID self.valueLabel = EveLabelSmallBold(parent=self, align=uiconst.CENTER, idx=0, top=1) for i in xrange(11): self.ShowMarker(i / 10.0, color=(0.5, 0.5, 0.7, i / 60.0)) systemCostIndexes = facilityData.GetCostIndexByActivityID() value = systemCostIndexes.get(activityID, 0.0) maxValue = sm.GetService('facilitySvc').GetMaxActivityModifier(activityID) Gauge.SetValue(self, value / maxValue) self.valueLabel.text = '%.2f%%' % (value * 100.0)
def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) sm.RegisterNotify(self) self.jobData = attributes.jobData self.materialData = attributes.materialData self.materialData.on_updated.connect(self.OnMaterialUpdated) self.materialData.on_errors.connect(self.OnMaterialErrors) self.isReady = None self.icon = ItemIcon(parent=self, typeID=self.materialData.typeID, align=CENTERTOP, state=UI_DISABLED, pos=(0, 6, 32, 32)) self.label = Label(parent=self, align=CENTERBOTTOM, top=-1, fontsize=10) self.bgGlow = Sprite( name='bgGlow', parent=self, align=TOALL, state=UI_DISABLED, texturePath='res:/UI/Texture/Classes/Industry/Input/bgGlow.png', color=COLOR_READY, opacity=OPACITY_DEFAULT) self.bgFrame = Sprite( name='bgFrame', parent=self, align=TOALL, state=UI_DISABLED, texturePath='res:/UI/Texture/Classes/Industry/Input/bgFrame.png', color=COLOR_FRAME) FillThemeColored(bgParent=self, opacity=0.5) Sprite( name='valueBg', parent=self, align=TOALL, state=UI_DISABLED, texturePath='res:/UI/Texture/Classes/Industry/Input/valueBg.png', color=COLOR_FRAME, opacity=0.1) self.gauge = Gauge(parent=self, align=BOTTOMLEFT, state=UI_DISABLED, pos=(0, 13, self.width + 1, 0), gaugeHeight=3, gradientBrightnessFactor=1.0, backgroundColor=(0, 0, 0, 0)) self.bgFill = Sprite( name='bgFill', parent=self, align=TOALL, state=UI_DISABLED, texturePath='res:/UI/Texture/Classes/Industry/Input/bg.png', color=COLOR_FRAME, opacity=0.1) self.ConstructBackground() self.UpdateState()
def _SetupDurationPanel(self, parent): maxSeconds = int(BENCHMARK_MAX_DURATION_IN_MS / 1000) defaultSeconds = int(BENCHMARK_DEFAULT_DURATION_IN_MS / 1000) self.durationSlider = Slider( name='mySlider', parent=parent, minValue=1, maxValue=maxSeconds, startVal=defaultSeconds, increments=[i + 1 for i in xrange(maxSeconds)], onsetvaluefunc=self._OnTimeChanged, align=uiconst.TOTOP, padLeft=10, padRight=10) self.progress = Gauge(name='progress', parent=parent, color=Color.WHITE, align=uiconst.TOTOP, padTop=20, padLeft=10, padRight=10) self._OnTimeChanged(self.durationSlider)
class BaseContainerMETE(Container): default_align = uiconst.TOPLEFT default_state = uiconst.UI_NORMAL def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.value = 0.0 iconPath = attributes.iconPath iconSize = attributes.iconSize minValue = attributes.minValue maxValue = attributes.maxValue showBG = attributes.get('showBG', True) isCompact = attributes.get('isCompact', False) self.jobData = attributes.jobData self.gauge = Gauge(parent=self, align=uiconst.TOBOTTOM, state=uiconst.UI_DISABLED, height=6, gaugeHeight=6, padTop=1, backgroundColor=(1.0, 1.0, 1.0, 0.05)) if isCompact: self.icon = None self.valueLabel = None return mainCont = Container(name='mainCont', parent=self) if showBG: self.bg = StretchSpriteHorizontal( bgParent=mainCont, texturePath='res:/UI/Texture/Classes/Industry/Center/bgMETE.png' ) FillThemeColored(bgParent=self, opacity=0.5) else: self.bg = None left = 8 if showBG else 2 self.icon = Sprite(name='icon', parent=mainCont, align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, pos=(left, 3, self.ICONSIZE, self.ICONSIZE), texturePath=self.ICONPATH, opacity=0.6) self.valueLabel = EveLabelMediumBold(parent=mainCont, align=uiconst.TOPRIGHT, top=4, left=left) self.removeIcon = Sprite( parent=mainCont, align=uiconst.CENTERRIGHT, state=uiconst.UI_HIDDEN, texturePath='res:/ui/texture/icons/73_16_45.png', pos=(0, 0, 12, 12), color=Color.RED, hint=localization.GetByLabel('UI/Industry/PreviewModeHint')) self.removeIcon.OnClick = self.OnRemoveIconClick self.previewEdit = SinglelineEdit(name='previewEdit', parent=mainCont, align=uiconst.CENTERRIGHT, state=uiconst.UI_HIDDEN, ints=(0, self.MAXVAL), OnChange=self.OnPreviewEdit, pos=(12, 0, 34, 20)) self.errorFrame = ErrorFrame(bgParent=self, padding=(1, 1, 1, 8)) def SetValue(self, value): if self.value * (value or 1) < 0.0: self.gauge.SetValueInstantly(0.0) self.value = value if value < 0: self.gauge.SetGaugeAlign(uiconst.TORIGHT_PROP) self.gauge.SetValue(float(value) / self.MINVAL) self.gauge.SetColor(COLOR_NOTREADY) else: self.gauge.SetGaugeAlign(uiconst.TOLEFT_PROP) self.gauge.SetValue(float(value) / self.MAXVAL) self.gauge.SetColor(COLOR_READY) if not self.valueLabel: return if value < 0: self.valueLabel.text = '<color=%s>%s%%' % (Color.RGBtoHex( *COLOR_NOTREADY), value) elif value == 0: self.valueLabel.text = '<color=%s>%s%%' % (Color.RGBtoHex( *COLOR_FRAME), value) else: self.valueLabel.text = '<color=%s>%s%%' % (Color.RGBtoHex( *COLOR_READY), value) def OnMouseEnter(self, *args): sm.GetService('audio').SendUIEvent('ind_mouseEnter') def OnRemoveIconClick(self): self.ExitPreviewMode() def EnterPreviewMode(self): if not self.IsPreviewEnabled(): return self.previewEdit.Show() self.previewEdit.SetValue(self.GetPreviewEditValue()) self.valueLabel.Hide() self.errorFrame.Show() self.removeIcon.Show() uicore.registry.SetFocus(self.previewEdit) def ExitPreviewMode(self): self.previewEdit.Hide() self.valueLabel.Show() self.errorFrame.Hide() self.removeIcon.Hide() if self.jobData: self.jobData.timeEfficiency = None self.jobData.materialEfficiency = None self.jobData.update(self.jobData) def OnClick(self, *args): self.EnterPreviewMode() def OnMouseEnter(self, *args): if self.bg and self.IsPreviewEnabled(): uicore.animations.FadeTo(self.bg, self.bg.opacity, 1.5, duration=0.3) def OnMouseExit(self, *args): if self.bg: uicore.animations.FadeTo(self.bg, self.bg.opacity, 1.0, duration=0.3) def OnNewJobData(self, jobData): self.jobData = jobData self.ExitPreviewMode() def IsPreviewEnabled(self): if not self.jobData or self.jobData.activityID != industry.MANUFACTURING or self.jobData.jobID: return False return True def IsPreviewActive(self): return self.errorFrame.display def GetHint(self): if self.IsPreviewEnabled() and not self.IsPreviewActive(): return '<br><br>' + localization.GetByLabel( 'UI/Industry/EnterPreviewModeHint') return ''
class SkillExtractorBar(Container): default_height = 52 def ApplyAttributes(self, attributes): super(SkillExtractorBar, self).ApplyAttributes(attributes) self.controller = attributes.controller self.Layout() self.Update() self.controller.onUpdate.connect(self.Update) def Layout(self): gaugeCont = Container(parent=self, align=uiconst.TOTOP, height=32) Frame(parent=gaugeCont, texturePath='res:/UI/Texture/classes/skilltrading/frame.png', cornerSize=3, opacity=0.5) self.gaugeBG = GradientSprite(bgParent=gaugeCont, align=uiconst.TOALL, rgbData=[(0.0, (1.0, 1.0, 1.0))], alphaData=[(0.0, 0.0), (0.4, 0.9), (0.6, 0.9), (1.0, 0.0)], opacity=0.1) self.extractButton = ExtractButton(parent=gaugeCont, align=uiconst.TOALL, controller=self.controller) self.gauge = Gauge(parent=gaugeCont, align=uiconst.TOTOP, state=uiconst.UI_DISABLED, height=30, gaugeHeight=30, top=1, color=COLOR_MODIFIED, backgroundColor=(1.0, 1.0, 0.0, 0.0)) self.noProgressHint = EveHeaderMedium( parent=gaugeCont, align=uiconst.CENTER, width=self.width, bold=True, text=localization.GetByLabel('UI/SkillTrading/DropToExtractHint'), opacity=0.5) self.amountLabel = ExtractorBarAmountLabel( parent=self, align=uiconst.TOTOP, top=2, goal=self.controller.SKILL_POINT_GOAL) def Update(self): self.gauge.SetValue(self.controller.progress) self.amountLabel.AnimSetAmount(self.controller.extractedPoints) opacity = 0.0 if self.controller.progress > 0.0 else 0.8 animations.FadeTo(self.noProgressHint, startVal=self.noProgressHint.opacity, endVal=opacity) target = 0.5 - self.controller.progress if self.controller.progress > 0.0 else 0.0 animations.MorphVector2(self.gaugeBG, 'translationPrimary', startVal=self.gaugeBG.translationPrimary, endVal=(target, 0.0)) def OnDropData(self, source, data): for entry in data: skillID = self._GetDropDataSkillID(entry) if skillID is not None: try: self.controller.ExtractSkill(skillID) sm.GetService('audio').SendUIEvent('st_select_skills_play') except SkillExtractorError: pass def _GetDropDataSkillID(self, data): for attr in ('skillID', 'typeID', 'invtype'): skillID = getattr(data, attr, None) if skillID is not None: return skillID
class PerformanceBenchmarkWindow(Window): default_caption = 'Performance Tools' default_windowID = 'PerformanceToolsWindowID' default_width = 220 default_height = 200 default_topParentHeight = 0 default_minSize = (default_width, default_height) default_wontUseThis = 10 def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.lastPitch = 0.0 self.lastYaw = 0.0 self.camLock = False self.benchmarkDuration = BENCHMARK_DEFAULT_DURATION_IN_MS self.benchmarkRunning = False self.sceneDirector = SceneDirector() self.testOptions = [('classic cube of death', CUBE_CLASSIC), ('capital wrecks of death', CUBE_CAPITAL_WRECKS), ('AmarrCube', CUBE_AMARR), ('CaldariCube', CUBE_CALDARI), ('GallenteCube', CUBE_GALLENTE), ('MinmatarCube', CUBE_MINMATAR), ('UltraLODCube', CUBE_LOD), ('Add More Here', CUBE_ADD_MORE_HERE)] self.testCaseDescription = { CUBE_CLASSIC: 'Spawns a cube with a lot of different ships.', CUBE_CAPITAL_WRECKS: 'Spawns a cube with a lot of wrecks.', CUBE_AMARR: 'Spawns a cube of Amarr ships.', CUBE_CALDARI: 'Spawns a cube of Caldari ships.', CUBE_GALLENTE: 'Spawns a cube of Gallente ships.', CUBE_MINMATAR: 'Spawns a cube of Minmatar ships.', CUBE_LOD: 'Spawns a cube of ships around the camera.', CUBE_ADD_MORE_HERE: 'Does nothing useful.' } self.camPresetOptions = [('None', CAMERA_PRESET_NONE), ('Deathcube Far', CAMERA_PRESET_FAR), ('Deathcube Near', CAMERA_PRESET_NEAR), ('Deathcube UltraLOD', CAMERA_PRESET_ULTRA_LOD)] self._AddHeader('Test Cases') self._SetupTestCasePanel(self.sr.main) self._AddHeader('Camera') self._SetupCameraPanel(self.sr.main) self._AddHeader('Duration') self._SetupDurationPanel(self.sr.main) self.benchmarkButton = Button(name='myButton', parent=self.sr.main, align=uiconst.CENTERBOTTOM, label='Start Benchmark', func=self.ToggleBenchmark, width=40, padding=(0, 0, 0, 6)) def _AddHeader(self, text): EveHeaderSmall(parent=self.sr.main, text=text, align=uiconst.TOTOP, padding=(8, 6, 0, 3)) def _SetupTestCasePanel(self, mainCont): cont = Container(name='cont', parent=mainCont, align=uiconst.TOTOP, padLeft=4, padRight=4, height=40) self.testCombo = Combo(parent=cont, align=uiconst.TOTOP, options=self.testOptions, callback=self.TestComboChanged) self.testCombo.SetHint(self.testCaseDescription[1]) buttonBox = Container(name='buttonBox', parent=cont, align=uiconst.TOTOP, padTop=3, height=20) self.stayHereCheckbox = Checkbox(parent=buttonBox, text=u'Stay where you are', align=uiconst.TOLEFT, checked=False, height=18, width=120) Button(parent=buttonBox, label='Spawn', align=uiconst.TORIGHT, func=self.SpawnTestcase, width=40, height=18) Button(parent=buttonBox, label='Clear', align=uiconst.TORIGHT, func=self.sceneDirector.ClearAll, width=40, height=18) Button(parent=buttonBox, label='Damage', align=uiconst.TORIGHT, func=self.sceneDirector.ApplyDamage, width=40, height=18, hint='Wait for ships to load before calling this') def _SetupCameraPanel(self, mainCont): presetCont = Container(name='presetCont', parent=mainCont, align=uiconst.TOTOP, height=20, padLeft=4, padRight=4) Label(name='presetCombo', parent=presetCont, align=uiconst.TOLEFT, width=40, text='Preset') self.cboCamPresets = Combo(parent=presetCont, align=uiconst.TOTOP, options=self.camPresetOptions, callback=self.OnCamPreset) pitchCont = Container(name='pitchCont', parent=mainCont, align=uiconst.TOTOP, height=20, padLeft=4, padRight=4) Label(name='pitchLabel', parent=pitchCont, align=uiconst.TOLEFT, width=40, padTop=3, text='Pitch') self.pitchField = SinglelineEdit(name='pitchField', parent=pitchCont, align=uiconst.TOTOP, floats=[-90.0, 90.0, 1], setvalue=str(self.lastPitch)) self.pitchField.OnChange = self.OnCamChange yawCont = Container(name='yawCont', parent=mainCont, align=uiconst.TOTOP, height=20, padLeft=4, padRight=4) Label(name='yawLabel', parent=yawCont, align=uiconst.TOLEFT, width=40, padTop=3, text='Yaw') self.yawField = SinglelineEdit(name='yawField', parent=yawCont, align=uiconst.TOTOP, floats=[-180.0, 180.0, 1], setvalue=str(self.lastYaw)) self.yawField.OnChange = self.OnCamChange panCont = Container(name='panCont', parent=mainCont, align=uiconst.TOTOP, height=20, padLeft=4, padRight=4) Label(name='panLabel', parent=panCont, align=uiconst.TOLEFT, width=40, padTop=3, text='Pan') self.panField = SinglelineEdit( name='panField', parent=panCont, align=uiconst.TOTOP, ints=[MIN_PAN_DISTANCE, MAX_PAN_DISTANCE], setvalue=0) self.panField.OnChange = self.OnCamChange buttonBox = Container(name='buttonBox', parent=mainCont, align=uiconst.TOTOP, padTop=3, height=20) Button( parent=buttonBox, label='Capture camera coords', align=uiconst.TORIGHT, func=self.OnStoreCurrentCameraValues, width=40, height=18, hint= 'Captures the current camera coordinates and saves them in the input fields' ) uthread.new(self._GetCurrentCameraValues) def _SetupDurationPanel(self, parent): maxSeconds = int(BENCHMARK_MAX_DURATION_IN_MS / 1000) defaultSeconds = int(BENCHMARK_DEFAULT_DURATION_IN_MS / 1000) self.durationSlider = Slider( name='mySlider', parent=parent, minValue=1, maxValue=maxSeconds, startVal=defaultSeconds, increments=[i + 1 for i in xrange(maxSeconds)], onsetvaluefunc=self._OnTimeChanged, align=uiconst.TOTOP, padLeft=10, padRight=10) self.progress = Gauge(name='progress', parent=parent, color=Color.WHITE, align=uiconst.TOTOP, padTop=20, padLeft=10, padRight=10) self._OnTimeChanged(self.durationSlider) def _OnTimeChanged(self, slider): self.benchmarkDuration = slider.GetValue() * 1000 def TestComboChanged(self, *args): self.testCombo.SetHint( self.testCaseDescription[self.testCombo.GetValue()]) def OnCamChange(self, *args): if self.camLock: return self.lastPitch = float(self.pitchField.GetValue()) self.lastYaw = float(self.yawField.GetValue()) self.pan = int(self.panField.GetValue()) self.sceneDirector.SetCamera(self.lastYaw, self.lastPitch, self.pan) def OnCamPreset(self, *args): presId = self.cboCamPresets.GetValue() if presId == 0: return pitch, yaw, pan = CAMERA_PRESETS[presId] self.camLock = True self.pitchField.SetValue(pitch) self.yawField.SetValue(yaw) self.panField.SetValue(pan) self.camLock = False self.OnCamChange() def _GetMemoryUsage(self): try: meg = 1.0 / 1024.0 / 1024.0 mem, pymem, workingset, pagefaults, bluemem = blue.pyos.cpuUsage[ -1][2] return mem * meg except: pass return 0 def ToggleBenchmark(self, *args): self.progress.SetValue(0) def _thread(): frameTimes = [] graphData = {} t0 = blue.os.GetWallclockTime() startTime = blue.os.GetWallclockTime() startMem = self._GetMemoryUsage() while self.benchmarkRunning: blue.synchro.Yield() t1 = blue.os.GetWallclockTime() ms = float(blue.os.TimeDiffInUs(t0, t1)) / 1000.0 t0 = t1 frameTimes.append(ms) timeFromStartInMs = float(blue.os.TimeDiffInUs(startTime, t1)) / 1000.0 graphData[timeFromStartInMs] = ms if blue.os.TimeDiffInMs(startTime, t1) > self.benchmarkDuration: self.benchmarkRunning = False break self.progress.SetValue(timeFromStartInMs / self.benchmarkDuration, animate=False) frameTimes.sort() median = frameTimes[len(frameTimes) / 2] minMS = frameTimes[0] maxMS = frameTimes[-1] summed = reduce(lambda x, y: x + y, frameTimes) avg = summed / len(frameTimes) result = 'Min: %0.1fms Max: %0.1fms\n' % (minMS, maxMS) result += 'Median: %0.1fms %0.1ffps\n' % (median, 1000.0 / median) result += 'Average: %0.1fms %0.1ffps\n' % (avg, 1000.0 / avg) endMem = self._GetMemoryUsage() result += 'Start Memory Usage: %0.1fmb\n' % (startMem, ) result += 'End Memory Usage: %0.1fmb\n' % (endMem, ) ResultDialog.Open(resultText=result, graphData=graphData) self.benchmarkButton.SetLabel('Start Benchmark') if self.benchmarkRunning: self.benchmarkRunning = False else: self.benchmarkRunning = True self.benchmarkButton.SetLabel('Stop Benchmark') uthread.new(_thread) def OnStoreCurrentCameraValues(self, *args): self._GetCurrentCameraValues() def _GetCurrentCameraValues(self): self.camLock = True cam = sm.GetService('sceneManager').GetActiveCamera() self.lastPitch = math.degrees(cam.pitch) self.lastYaw = math.degrees(cam.yaw) self.pan = pan = ClampPan(int(cam.GetZoomDistance())) self.pitchField.SetValue(self.lastPitch) self.yawField.SetValue(self.lastYaw) self.panField.SetValue(self.pan) self.camLock = False self.OnCamChange() def SpawnTestcase(self, *args): testID = self.testCombo.GetValue() stayHere = self.stayHereCheckbox.GetValue() startPos = self.sceneDirector.GoToAndReturnStartPosition(stayHere) self.sceneDirector.SpawnTestcase(testID, startPos)
def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.controller = SquadronMgmtController() self.shipFighterState = GetShipFighterState() self.tubeFlagID = attributes.tubeFlagID self.leftTube = Sprite( parent=self, texturePath= 'res:/UI/Texture/classes/CarrierBay/tubeSideElement.png', align=uiconst.TOLEFT_NOPUSH, width=15) self.rightTube = Sprite( parent=self, texturePath= 'res:/UI/Texture/classes/CarrierBay/tubeSideElementRIGHT.png', align=uiconst.TORIGHT_NOPUSH, width=15) inSpaceCont = Container(parent=self, height=86, align=uiconst.TOTOP) inSpaceCont.OnDropData = self.OnDropToSpace inSpaceCont.GetMenu = self.GetMenu self.squadronNumber = SquadronNumber(parent=inSpaceCont, top=1, left=1) self.squadronNumber.SetText(self.tubeFlagID) self.inStationCont = Container(parent=inSpaceCont, align=uiconst.TOALL) cantLaunchIcon = Sprite( parent=self.inStationCont, width=44, height=44, align=uiconst.CENTER, texturePath='res:/UI/Texture/classes/CarrierBay/unableToLaunch.png' ) self.stateCont = Container(parent=self, height=24, align=uiconst.TOTOP, state=uiconst.UI_NORMAL) self.stateContBG = Fill(bgParent=self.stateCont, color=(0, 0, 0, 0)) deckCont = Container(parent=self, height=86, align=uiconst.TOTOP, state=uiconst.UI_NORMAL) deckCont.OnDropData = self.OnDropToTube deckCont.GetMenu = self.GetMenu self.tubeStatusLabel = EveHeaderSmall(parent=self.stateCont, align=uiconst.CENTER, text='') self.loadingGauge = Gauge(parent=self.stateCont, align=uiconst.CENTERBOTTOM, backgroundColor=(0, 0, 0, 1), color=(0.2, 0.2, 0.2, 0.5), padLeft=1, padRight=1, top=1, width=75, value=0.0) self.loadingGauge.display = False spaceColor = Color(*COLOR_INSPACE) spaceColor.a = 1.0 self.launchIcon = ButtonIcon( parent=inSpaceCont, align=uiconst.CENTER, width=86, height=86, iconSize=44, texturePath='res:/UI/Texture/classes/CarrierBay/tubeLaunch_Up.png', downTexture= 'res:/UI/Texture/classes/CarrierBay/tubeLaunch_Down.png', hoverTexture= 'res:/UI/Texture/classes/CarrierBay/tubeLaunch_Over.png', iconColor=spaceColor.GetRGBA(), showGlow=False) self.launchIcon.OnClick = self.LaunchFightersFromTube self.launchIcon.OnDropData = self.OnDropToSpace returnColor = Color(*COLOR_RETURNING) returnColor.a = 1.0 self.scoopIcon = ButtonIcon( parent=deckCont, align=uiconst.CENTER, width=86, height=86, iconSize=44, texturePath='res:/UI/Texture/classes/CarrierBay/tubeRecall_Up.png', downTexture= 'res:/UI/Texture/classes/CarrierBay/tubeRecall_Down.png', hoverTexture= 'res:/UI/Texture/classes/CarrierBay/tubeRecall_Over.png', iconColor=returnColor.GetRGBA(), showGlow=False) self.scoopIcon.OnClick = self.RecallFighterToTube self.scoopIcon.OnDropData = self.OnDropToTube self.landingStrip = LandingStrip(parent=deckCont) self.landingStrip.display = False self.emptyTubeIcon = ButtonIcon( parent=deckCont, align=uiconst.CENTER, width=44, height=44, iconSize=44, texturePath='res:/UI/Texture/classes/CarrierBay/tubeOpen_Up.png', downTexture='res:/UI/Texture/classes/CarrierBay/tubeOpen_Down.png', hoverTexture='res:/UI/Texture/classes/CarrierBay/tubeOpen_Over.png', showGlow=False) self.emptyTubeIcon.OnDropData = self.OnDropToTube self.squadronInSpace = FightersHealthGauge(name='squadronInSpace', parent=inSpaceCont, align=uiconst.CENTER, width=86, height=86, state=TUBE_STATE_INSPACE, tubeFlagID=self.tubeFlagID) self.squadronInSpace.display = False self.squadronInSpace.GetMenu = self.GetMenu self.squadronInTube = FightersHealthGauge(name='squadronInTube', parent=deckCont, align=uiconst.CENTER, width=86, height=86, state=TUBE_STATE_READY, tubeFlagID=self.tubeFlagID) self.squadronInTube.OnDropData = self.OnDropToTube self.squadronInTube.display = False self.squadronInTube.GetMenu = self.GetMenu self.launchingStrip = LaunchingStrip(parent=inSpaceCont) self.launchingStrip.display = False self.UpdateLaunchTubeContentUI() self.UpdateLaunchTubeStateUI() self.UpdateInSpaceUI() self.shipFighterState.signalOnFighterTubeStateUpdate.connect( self.OnFighterTubeStateUpdate) self.shipFighterState.signalOnFighterTubeContentUpdate.connect( self.OnFighterTubeContentUpdate) self.shipFighterState.signalOnFighterInSpaceUpdate.connect( self.OnFighterInSpaceUpdate)
class FighterLaunchControlCont(Container): default_height = 196 default_width = 86 default_align = uiconst.TOLEFT def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.controller = SquadronMgmtController() self.shipFighterState = GetShipFighterState() self.tubeFlagID = attributes.tubeFlagID self.leftTube = Sprite( parent=self, texturePath= 'res:/UI/Texture/classes/CarrierBay/tubeSideElement.png', align=uiconst.TOLEFT_NOPUSH, width=15) self.rightTube = Sprite( parent=self, texturePath= 'res:/UI/Texture/classes/CarrierBay/tubeSideElementRIGHT.png', align=uiconst.TORIGHT_NOPUSH, width=15) inSpaceCont = Container(parent=self, height=86, align=uiconst.TOTOP) inSpaceCont.OnDropData = self.OnDropToSpace inSpaceCont.GetMenu = self.GetMenu self.squadronNumber = SquadronNumber(parent=inSpaceCont, top=1, left=1) self.squadronNumber.SetText(self.tubeFlagID) self.inStationCont = Container(parent=inSpaceCont, align=uiconst.TOALL) cantLaunchIcon = Sprite( parent=self.inStationCont, width=44, height=44, align=uiconst.CENTER, texturePath='res:/UI/Texture/classes/CarrierBay/unableToLaunch.png' ) self.stateCont = Container(parent=self, height=24, align=uiconst.TOTOP, state=uiconst.UI_NORMAL) self.stateContBG = Fill(bgParent=self.stateCont, color=(0, 0, 0, 0)) deckCont = Container(parent=self, height=86, align=uiconst.TOTOP, state=uiconst.UI_NORMAL) deckCont.OnDropData = self.OnDropToTube deckCont.GetMenu = self.GetMenu self.tubeStatusLabel = EveHeaderSmall(parent=self.stateCont, align=uiconst.CENTER, text='') self.loadingGauge = Gauge(parent=self.stateCont, align=uiconst.CENTERBOTTOM, backgroundColor=(0, 0, 0, 1), color=(0.2, 0.2, 0.2, 0.5), padLeft=1, padRight=1, top=1, width=75, value=0.0) self.loadingGauge.display = False spaceColor = Color(*COLOR_INSPACE) spaceColor.a = 1.0 self.launchIcon = ButtonIcon( parent=inSpaceCont, align=uiconst.CENTER, width=86, height=86, iconSize=44, texturePath='res:/UI/Texture/classes/CarrierBay/tubeLaunch_Up.png', downTexture= 'res:/UI/Texture/classes/CarrierBay/tubeLaunch_Down.png', hoverTexture= 'res:/UI/Texture/classes/CarrierBay/tubeLaunch_Over.png', iconColor=spaceColor.GetRGBA(), showGlow=False) self.launchIcon.OnClick = self.LaunchFightersFromTube self.launchIcon.OnDropData = self.OnDropToSpace returnColor = Color(*COLOR_RETURNING) returnColor.a = 1.0 self.scoopIcon = ButtonIcon( parent=deckCont, align=uiconst.CENTER, width=86, height=86, iconSize=44, texturePath='res:/UI/Texture/classes/CarrierBay/tubeRecall_Up.png', downTexture= 'res:/UI/Texture/classes/CarrierBay/tubeRecall_Down.png', hoverTexture= 'res:/UI/Texture/classes/CarrierBay/tubeRecall_Over.png', iconColor=returnColor.GetRGBA(), showGlow=False) self.scoopIcon.OnClick = self.RecallFighterToTube self.scoopIcon.OnDropData = self.OnDropToTube self.landingStrip = LandingStrip(parent=deckCont) self.landingStrip.display = False self.emptyTubeIcon = ButtonIcon( parent=deckCont, align=uiconst.CENTER, width=44, height=44, iconSize=44, texturePath='res:/UI/Texture/classes/CarrierBay/tubeOpen_Up.png', downTexture='res:/UI/Texture/classes/CarrierBay/tubeOpen_Down.png', hoverTexture='res:/UI/Texture/classes/CarrierBay/tubeOpen_Over.png', showGlow=False) self.emptyTubeIcon.OnDropData = self.OnDropToTube self.squadronInSpace = FightersHealthGauge(name='squadronInSpace', parent=inSpaceCont, align=uiconst.CENTER, width=86, height=86, state=TUBE_STATE_INSPACE, tubeFlagID=self.tubeFlagID) self.squadronInSpace.display = False self.squadronInSpace.GetMenu = self.GetMenu self.squadronInTube = FightersHealthGauge(name='squadronInTube', parent=deckCont, align=uiconst.CENTER, width=86, height=86, state=TUBE_STATE_READY, tubeFlagID=self.tubeFlagID) self.squadronInTube.OnDropData = self.OnDropToTube self.squadronInTube.display = False self.squadronInTube.GetMenu = self.GetMenu self.launchingStrip = LaunchingStrip(parent=inSpaceCont) self.launchingStrip.display = False self.UpdateLaunchTubeContentUI() self.UpdateLaunchTubeStateUI() self.UpdateInSpaceUI() self.shipFighterState.signalOnFighterTubeStateUpdate.connect( self.OnFighterTubeStateUpdate) self.shipFighterState.signalOnFighterTubeContentUpdate.connect( self.OnFighterTubeContentUpdate) self.shipFighterState.signalOnFighterInSpaceUpdate.connect( self.OnFighterInSpaceUpdate) def Close(self): self.shipFighterState.signalOnFighterTubeStateUpdate.disconnect( self.OnFighterTubeStateUpdate) self.shipFighterState.signalOnFighterTubeContentUpdate.disconnect( self.OnFighterTubeContentUpdate) self.shipFighterState.signalOnFighterInSpaceUpdate.disconnect( self.OnFighterInSpaceUpdate) def LaunchFightersFromTube(self): self.controller.LaunchFightersFromTube(self.tubeFlagID) def RecallFighterToTube(self): fighterInSpace = self.shipFighterState.GetFightersInSpace( self.tubeFlagID) self.controller.RecallFighterToTube(fighterInSpace.itemID) def ReturnAndOrbit(self): fighterInSpace = self.shipFighterState.GetFightersInSpace( self.tubeFlagID) sm.GetService('fighters').CmdReturnAndOrbit([fighterInSpace.itemID]) def OnDropToSpace(self, dragSource, dragData): data = dragData[0] if data.tubeFlagID == self.tubeFlagID and data.squadronState == TUBE_STATE_READY: self.LaunchFightersFromTube() def OnDropToTube(self, dragSource, dragData): data = dragData[0] if data.__guid__ == 'uicls.FightersHealthGauge': if data.tubeFlagID == self.tubeFlagID and data.squadronState == TUBE_STATE_INSPACE: self.RecallFighterToTube() elif data.__guid__ in ('xtriui.InvItem', 'listentry.InvItem'): tubeStatus = self.shipFighterState.GetTubeStatus(self.tubeFlagID) if tubeStatus.statusID in (TUBE_STATE_EMPTY, TUBE_STATE_READY): fighterID = data.itemID self.controller.LoadFightersToTube(fighterID, self.tubeFlagID) def UnloadTubeToFighterBay(self): self.controller.UnloadTubeToFighterBay(self.tubeFlagID) def UpdateLaunchTubeContentUI(self): fighterInTube = self.shipFighterState.GetFightersInTube( self.tubeFlagID) if fighterInTube is not None: self.squadronInTube.display = True if not self.ShouldShowStationUI(): self.launchIcon.display = True self.scoopIcon.display = False self.landingStrip.display = False self.squadronInTube.LoadFighterToSquadron(fighterInTube.typeID) self.squadronInTube.SetSquadronSize(fighterInTube.squadronSize) else: self.squadronInTube.display = False self.launchIcon.display = False def ShowStationUI(self): self.inStationCont.display = True self.launchIcon.display = False def UpdateLaunchTubeStateUI(self): tubeStatus = self.shipFighterState.GetTubeStatus(self.tubeFlagID) self.UpdateStatusUI(tubeStatus) if tubeStatus.endTime: if tubeStatus.statusID in (TUBE_STATE_RECALLING, TUBE_STATE_LANDING): self.landingStrip.display = True self.scoopIcon.display = False elif tubeStatus.statusID == TUBE_STATE_LAUNCHING: self.launchingStrip.display = True self.launchIcon.display = False else: self.loadingGauge.display = True now = gametime.GetSimTime() duration = float(tubeStatus.endTime - tubeStatus.startTime) loadingProgress = max( 0.0, min(1.0, (now - tubeStatus.startTime) / duration)) self.loadingGauge.SetValue(loadingProgress, animate=False) remainingTime = tubeStatus.endTime - now remainingTimeSeconds = max(float(remainingTime) / SEC, 0.1) self.loadingGauge.SetValueTimed(1.0, remainingTimeSeconds) self.tubeStatusLabel.top = -2 else: self.loadingGauge.SetValue(0) self.loadingGauge.display = False self.landingStrip.display = False self.launchingStrip.display = False self.tubeStatusLabel.top = 0 if tubeStatus.statusID == TUBE_STATE_EMPTY: self.emptyTubeIcon.display = True self.scoopIcon.display = False self.squadronNumber.SetColor(True) else: self.emptyTubeIcon.display = False self.squadronNumber.SetColor(False) def UpdateStatusUI(self, tubeStatus): stateText = LABEL_BY_STATE[tubeStatus.statusID] self.tubeStatusLabel.text = GetByLabel(stateText) if self.ShouldShowStationUI(): stateColor = Color(*COLOR_OPEN) else: stateColor = Color(*COLOR_BY_STATE[tubeStatus.statusID]) self.leftTube.SetRGBA(*stateColor.GetRGBA()) self.rightTube.SetRGBA(*stateColor.GetRGBA()) stateColor.a = 0.8 self.tubeStatusLabel.SetTextColor(stateColor.GetRGBA()) def UpdateInSpaceUI(self): if self.ShouldShowStationUI(): self.ShowStationUI() return self.inStationCont.display = False fighterInSpace = self.shipFighterState.GetFightersInSpace( self.tubeFlagID) if fighterInSpace is not None: self.scoopIcon.display = True self.squadronInSpace.display = True self.squadronInSpace.LoadFighterToSquadron(fighterInSpace.typeID) self.squadronInSpace.SetSquadronSize(fighterInSpace.squadronSize) else: self.scoopIcon.display = False self.squadronInSpace.display = False def GetMenu(self): m = [] fighterInTube = self.shipFighterState.GetFightersInTube( self.tubeFlagID) if fighterInTube is not None: if not session.stationid2: m.append((MenuLabel('UI/Inventory/Fighters/LaunchToSpace'), self.LaunchFightersFromTube)) m.append((MenuLabel('UI/Inventory/Fighters/UnloadFromLaunchTube'), self.UnloadTubeToFighterBay)) m.append((MenuLabel('UI/Commands/ShowInfo'), sm.GetService('menu').ShowInfo, (fighterInTube.typeID, fighterInTube.itemID))) fighterInSpace = self.shipFighterState.GetFightersInSpace( self.tubeFlagID) if fighterInSpace is not None: m.append((MenuLabel('UI/Inventory/Fighters/RecallToLaunchTube'), self.RecallFighterToTube)) m.append((MenuLabel('UI/Drones/ReturnDroneAndOrbit'), self.ReturnAndOrbit)) m.append((MenuLabel('UI/Commands/ShowInfo'), sm.GetService('menu').ShowInfo, (fighterInSpace.typeID, fighterInSpace.itemID))) return m def OnFighterTubeStateUpdate(self, tubeFlagID): if tubeFlagID == self.tubeFlagID: self.UpdateLaunchTubeStateUI() def OnFighterTubeContentUpdate(self, tubeFlagID): if tubeFlagID == self.tubeFlagID: self.UpdateLaunchTubeContentUI() def OnFighterInSpaceUpdate(self, fighterID, tubeFlagID): if tubeFlagID == self.tubeFlagID: self.UpdateInSpaceUI() def ShouldShowStationUI(self): return session.stationid2