def BuildNameCont(self): padding = 6 BumpedUnderlay(bgParent=self.nameCont) profileCont = Container(parent=self.nameCont, align=uiconst.TORIGHT, left=padding) self.profileCombo = Combo( label=GetByLabel('UI/Structures/Deployment/ProfileComboLabel'), parent=profileCont, options=self._GetProfileOptions(), name='profileCombo', width=100, align=uiconst.BOTTOMRIGHT, top=padding) profileCont.width = self.profileCombo.width nameText = GetByLabel('UI/Structures/Deployment/StructureName') self.ssPrefix = '%s - ' % CleanImportantMarkup( cfg.evelocations.Get(session.solarsystemid).locationName) self.nameEdit = PrefixedSingleLineEdit( name='nameEdit', parent=self.nameCont, maxLength=32 + len(self.ssPrefix), align=uiconst.TOBOTTOM, padLeft=padding, padRight=30, top=padding, label=nameText, prefix=self.ssPrefix, OnChange=self.nameChangedCallback) profileHeight = self.profileCombo.height - self.profileCombo.sr.label.top nameHeight = self.nameEdit.height - self.nameEdit.sr.label.top newHeight = max(profileHeight, nameHeight) + 2 * padding self.nameCont.height = newHeight
def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.SetWndIcon(None) self.SetCaption('Window manager') self.SetTopparentHeight(10) self.SetMinSize([360, 220]) options = [] for wndCls in Window.__subclasses__(): options.append((wndCls.__name__, wndCls)) options.sort() topCont = Container(name='params', parent=self.sr.main, align=uiconst.TOTOP, pad=(5, 5, 5, 5), pos=(0, 10, 0, 30)) self.mainCont = Container(name='params', parent=self.sr.main, align=uiconst.TOTOP, pos=(0, 0, 0, 50), padding=(5, 15, 5, 5)) self.extrasCont = Container(name='params', parent=self.sr.main, align=uiconst.TOALL, padding=(5, 15, 5, 5)) self.combo = Combo(parent=topCont, label='Select window', options=options, name='', select=settings.user.ui.Get('windowManagerOpenWindow'), callback=self.OnComboChanged, pos=(5, 0, 0, 0), width=150, align=uiconst.TOPLEFT) self.startupArgs = SinglelineEdit(name='', label='attributes', parent=topCont, setvalue='', align=uiconst.TOPLEFT, left=165, width=100) Button(parent=topCont, label='Load', align=uiconst.RELATIVE, func=self.OpenWindow, pos=(300, 0, 0, 0)) self.filenameEdit = SinglelineEdit(name='', label='Location', parent=self.mainCont, setvalue='', align=uiconst.TOTOP, top=15, readonly=True) Label(text='RELOAD', parent=self.extrasCont, top=10, state=uiconst.UI_NORMAL) Line(parent=self.extrasCont, align=uiconst.TOTOP) buttonCont = Container(name='buttonCont', parent=self.extrasCont, align=uiconst.TOTOP, pos=(0, 30, 0, 30)) Button(parent=buttonCont, label='ShipUI', align=uiconst.TOLEFT, func=self.ReloadShipUI) Button(parent=buttonCont, label='NEOCOM', align=uiconst.TOLEFT, func=self.ReloadNeocom, padLeft=1) Button(parent=buttonCont, label='Info Panels', align=uiconst.TOLEFT, func=self.ReloadInfoPanels, padLeft=1) Button(parent=buttonCont, label='Lobby', align=uiconst.TOLEFT, func=self.ReloadLobby, padLeft=1) Button(parent=buttonCont, label='Overview', align=uiconst.TOLEFT, func=self.ReloadOverview, padLeft=1) Button(parent=buttonCont, label='Mapbrowser', align=uiconst.TOLEFT, func=self.ReloadMapBrowser, padLeft=1) self.UpdateInfo(self.combo.GetKey(), self.combo.GetValue())
def PrimeTimeMenu(self, menuParent): headerCont = menuParent.AddContainer(align=uiconst.TOTOP, height=20, padding=const.defaultPadding) EveLabelLargeBold(parent=headerCont, text=GetByLabel('UI/Sovereignty/SetSovereigntyHour'), align=uiconst.TOTOP) menuParent.AddSpace(height=10) text = menuParent.AddText( GetByLabel('UI/Sovereignty/SetNewVulnerabilityTimeDescription')) text.GetEntryWidth = lambda mc=text: 250 cont = menuParent.AddContainer(align=uiconst.TOTOP, height=60, padding=const.defaultPadding) myCont = Container(name='myCont', parent=cont, align=uiconst.TOTOP, height=22, padTop=10) currentPrimeHour = self.GetCurrentPrimeHour() self.primeTimeCombo = Combo(name='primeTimeCombo', parent=myCont, options=self.GetTimeComboOptions(), select=currentPrimeHour, width=150) setBtn = Button(name='SetPrimeTimeBtn', align=uiconst.TOPRIGHT, parent=myCont, label=GetByLabel('UI/Common/CommandSet'), func=self.SetPrimeTime)
def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) sm.RegisterNotify(self) self.killentries = 25 self.topCont = Container(name='combatlogpanel', parent=self, align=uiconst.TOTOP, padTop=const.defaultPadding) combatValues = ((GetByLabel('UI/Corporations/Wars/Killmails/ShowKills'), 0), (GetByLabel('UI/Corporations/Wars/Killmails/ShowLosses'), 1)) selectedCombatType = settings.user.ui.Get('CombatLogCombo', 0) self.combatCombo = Combo(parent=self.topCont, name='combo', select=selectedCombatType, align=uiconst.TOPLEFT, left=1, callback=self.OnCombatChange, options=combatValues, idx=0, adjustWidth=True) self.sr.combatSetting = Checkbox(parent=self.topCont, align=uiconst.TOPLEFT, pos=(0, self.combatCombo.height + const.defaultPadding, 300, 14), configName='charsheet_condensedcombatlog', text=GetByLabel('UI/CharacterSheet/CharacterSheetWindow/KillsTabs/CondensedCombatLog'), checked=settings.user.ui.Get('charsheet_condensedcombatlog', 0), callback=self.CheckBoxChange) self.killReportQuickFilter = QuickFilterEdit(parent=self.topCont, left=const.defaultPadding, align=uiconst.TOPRIGHT, width=150) self.killReportQuickFilter.ReloadFunction = self.ReloadKillReports self.topCont.height = self.combatCombo.height + self.sr.combatSetting.height + const.defaultPadding self.btnContainer = Container(name='pageBtnContainer', parent=self, align=uiconst.TOBOTTOM, idx=0, padBottom=4) btn = GetBigButton(size=22, where=self.btnContainer, left=4, top=0) btn.SetAlign(uiconst.CENTERRIGHT) btn.hint = GetByLabel('UI/CharacterSheet/CharacterSheetWindow/KillsTabs/ViewMore') btn.sr.icon.LoadIcon('ui_23_64_2') btn = GetBigButton(size=22, where=self.btnContainer, left=4, top=0) btn.SetAlign(uiconst.CENTERLEFT) btn.hint = GetByLabel('UI/CharacterSheet/CharacterSheetWindow/KillsTabs/ViewPrevious') btn.sr.icon.LoadIcon('ui_23_64_1') self.btnContainer.height = max([ c.height for c in self.btnContainer.children ]) self.scroll = Scroll(parent=self, padding=(0, 4, 0, 4))
def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.jobData = None self.costCaption = IndustryCaptionLabel(name='costCaption', parent=self, align=uiconst.TOTOP, text=GetByLabel('UI/Industry/JobCost')) textCont = Container(parent=self) self.walletCombo = Combo(parent=textCont, align=uiconst.TOLEFT, state=uiconst.UI_HIDDEN, callback=self.OnWalletCombo, iconOnly=True, width=33, top=1) self.walletCombo.GetHint = self.GetWalletComboHint self.costLabel = EveLabelLarge(name='costLabel', parent=textCont, align=uiconst.TOTOP, padLeft=4) self.errorFrame = ErrorFrame(bgParent=self, padding=(0, -2, 0, -2))
def DrawCombos(self): durations = [[GetByLabel('UI/Market/MarketQuote/Immediate'), 0], [GetByLabel('UI/Common/DateWords/Day'), 1], [GetByLabel('UI/Market/MarketQuote/ThreeDays'), 3], [GetByLabel('UI/Common/DateWords/Week'), 7], [GetByLabel('UI/Market/MarketQuote/TwoWeeks'), 14], [GetByLabel('UI/Common/DateWords/Month'), 30], [GetByLabel('UI/Market/MarketQuote/ThreeMonths'), 90]] self.durationCombo = Combo(parent=self.bottomLeft, options=durations, top=6, callback=self.OnDurationChange)
def _SetupUIArea(self): self.UISettingsContainer = ContainerAutoSize(name='HistorySettings', align=uiconst.TOTOP, parent=self.rightContainer, alignMode=uiconst.TOTOP, padLeft=self.basePadLeft) EveLabelMediumBold(name='UI', align=uiconst.TOTOP, parent=self.UISettingsContainer, text=localization.GetByLabel('Notifications/NotificationSettings/UISettingHeader')) self._MakeSeperationLine(self.UISettingsContainer) if self.dev_simpleHistoryDisplayEnabled: Checkbox(name='simple history view', text=localization.GetByLabel('Notifications/NotificationSettings/SimpleHistoryDisplay'), parent=self.UISettingsContainer, align=uiconst.TOTOP, checked=True) hComboRowContainer = Container(name='ComboBoxRow', parent=self.UISettingsContainer, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, height=40, padRight=10) from eve.client.script.ui.control.eveCombo import Combo Combo(name='H-ExpandCombo', parent=hComboRowContainer, labelleft=120, label=localization.GetByLabel('Notifications/NotificationSettings/DefaultHExpand'), hint=localization.GetByLabel('Notifications/NotificationSettings/DefaultHExpandToolTip'), options=self.GetHorizontalComboOptions(), align=uiconst.TOTOP, width=self.rightContainer.width, callback=self.OnHorizontalComboSelect, select=self.notificationSettingHandler.GetHorizontalExpandAlignment()) Combo(name='V-ExpandCombo', parent=hComboRowContainer, labelleft=120, label=localization.GetByLabel('Notifications/NotificationSettings/DefaultVExpand'), hint=localization.GetByLabel('Notifications/NotificationSettings/DefaultVExpandToolTip'), align=uiconst.TOTOP, options=self.GetVerticalComboOptions(), width=self.rightContainer.width, callback=self.OnVerticalComboSelect, select=self.notificationSettingHandler.GetVerticalExpandAlignment())
def DrawDurationCombo(self): durations = [[GetByLabel('UI/Market/MarketQuote/Immediate'), 0], [GetByLabel('UI/Common/DateWords/Day'), 1], [GetByLabel('UI/Market/MarketQuote/ThreeDays'), 3], [GetByLabel('UI/Common/DateWords/Week'), 7], [GetByLabel('UI/Market/MarketQuote/TwoWeeks'), 14], [GetByLabel('UI/Common/DateWords/Month'), 30], [GetByLabel('UI/Market/MarketQuote/ThreeMonths'), 90]] durationValue = settings.user.ui.Get(self.durationSettingConfig, 0) self.durationCombo = Combo(parent=self.bottomLeft, options=durations, select=durationValue, top=6, callback=self.OnDurationChange)
def AddLocationCombo(self): locationOptions = self.GetLocationOptions() selected = self.controller.GetRange() self.locationRange = Combo(label='', parent=self, options=locationOptions, name='locationRange', select=selected, callback=self.ChangeLocationRange, left=self.uiLeft, top=-2, align=uiconst.CENTERLEFT) self.uiLeft = self.locationRange.left + self.locationRange.width + 10
def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.label = EveLabelSmall(text=attributes.text, parent=self, state=uiconst.UI_DISABLED, align=uiconst.CENTERLEFT, width=LABELWIDTH) self.combo = Combo(name='passwordEdit', parent=self, align=uiconst.TOLEFT, padLeft=LABELWIDTH, options=attributes.options, callback=attributes.callback, select=attributes.select, width=140)
def ConstructGhostFittingSwitch(self): texturePath = 'res:/UI/Texture/classes/Fitting/iconSimulatorToggle.png' iconSize = 32 switchCont = Container(parent=self.overlayCont, state=uiconst.UI_PICKCHILDREN, align=uiconst.TOPLEFT, pos=(const.defaultPadding, const.defaultPadding, 100, 32)) modeOptions = [(GetByLabel('UI/Fitting/FittingWindow/ModuleMode'), SIMULATION_MODULES), (GetByLabel('UI/Fitting/FittingWindow/SkillMode'), SIMULATION_SKILLS)] currentMode = sm.GetService('ghostFittingSvc').GetSimulationMode() self.ghostFittingSwitch = ButtonIcon(texturePath=texturePath, parent=switchCont, align=uiconst.CENTERLEFT, pos=(0, 0, iconSize, iconSize), func=self.ToggleGhostFitting, iconSize=iconSize) left = self.ghostFittingSwitch.left + self.ghostFittingSwitch.width self.simulateLabel = EveLabelMedium(parent=switchCont, text='Simulate', align=uiconst.CENTERLEFT, left=left) self.simulationMode = Combo( label='', parent=switchCont, options=modeOptions, name='simulationMode', select=int(currentMode == SIMULATION_SKILLS), callback=self.OnSimulationModeChanged, align=uiconst.CENTERLEFT, left=left) isSimulated = sm.GetService('fittingSvc').IsShipSimulated() self.ChangeSimulateUIstate(isSimulated)
def ApplyAttributes(self, attributes): super(RenderJobProfiler, self).ApplyAttributes(attributes) self.SetCaption('Render Job Profiler') self._renderJob = None self.SetTopparentHeight(0) parent = self.GetMainArea() parent.SetAlign(uiconst.TOALL) parent.padding = 5 top = Container(parent=parent, align=uiconst.TOTOP, height=20) Label(text='Render Job', parent=top, align=uiconst.TOLEFT, padding=4) combo = Combo(parent=top, options=[(rj.name, rj) for rj in trinity.renderJobs.recurring], callback=self._OnRenderJob, align=uiconst.TOALL) bottom = Container(parent=parent, align=uiconst.TOBOTTOM, height=20, padding=2) Button(parent=bottom, align=uiconst.CENTER, label='Copy', func=self._Copy, args=()) self._scroll = Scroll(parent=parent, align=uiconst.TOALL, top=4) self._OnRenderJob(None, None, combo.selectedValue) uthread2.StartTasklet(self._UpdateTiming)
def OnTabSelect(self): if self.isInitialized: self.UpdateScroll() return self.isInitialized = True self.topPanel = Container(name='topPanel', parent=self, align=uiconst.TOTOP, height=20, padding=(0, 6, 0, 6)) self.scroll = Scroll(parent=self, id='InstallationBrowser') self.scroll.OnSelectionChange = self.OnScrollSelectionChange self.ownerCombo = Combo(name='ownerCombo', parent=self.topPanel, align=uiconst.TOLEFT, prefsKey='IndustryBlueprintOwner', callback=self.OnOwnerCombo, options=self.GetOwnerOptions(), width=120, padRight=4) self.activityCombo = Combo(name='activityCombo', parent=self.topPanel, align=uiconst.TOLEFT, prefsKey='IndustryBlueprintActivity', callback=self.OnActivityCombo, options=self.GetActivityOptions(), width=120, padRight=4) self.viewModeButtons = ViewModeButtons( parent=self.topPanel, align=uiconst.TORIGHT, controller=self, settingsID='IndustryBlueprintBrowserViewMode') self.filterEdit = QuickFilterEdit( name='searchField', parent=self.topPanel, hinttext=localization.GetByLabel('UI/Inventory/Filter'), maxLength=64, align=uiconst.TORIGHT, OnClearFilter=self.OnFilterEditCleared, padRight=4) self.filterEdit.ReloadFunction = self.OnFilterEdit self.UpdateScroll()
def AddToLocationCont(self): self.locationCont.height = 28 self.orderMultiplierEdit = SinglelineEdit( name='orderMultiplierEdit', parent=self.locationCont, align=uiconst.TOPRIGHT, label=GetByLabel('UI/Market/MarketQuote/NumberOfOrders'), adjustWidth=True, ints=[1, 1000], left=const.defaultPadding, OnChange=self.OnMultiplierEditChange) self.stationCombo = Combo( parent=self.locationCont, callback=self.OnStationChanged, left=const.defaultPadding, width=200, noChoiceLabel=GetByLabel( 'UI/Market/MarketQuote/NotStationsAvailable')) self.LoadStationOptions()
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 GetScrollEntry(self, label, returnValue, hint=None, icon=None, indentLevel=None): data, returnValue = Combo.GetScrollEntry(self, label, returnValue, hint, icon, indentLevel) if data.data[1] == HEADER_OPTION: decoClass = SE_GenericCore else: decoClass = ScheduleEntry data.decoClass = decoClass data.vulnerableHours = returnValue return (data, returnValue)
def OnTabSelect(self): if self.isInitialized: self.UpdateOwnerCombo() self.UpdateScroll() return self.isInitialized = True self.topPanel = Container(name='topPanel', parent=self, align=TOTOP, height=20, padding=(0, 6, 0, 6)) self.scroll = Scroll(parent=self, id='BlueprintBrowser') self.scroll.OnSelectionChange = self.OnScrollSelectionChange self.scroll.OnKeyDown = self.OnScrollKeyDown self.scroll.OnChar = self.OnScrollChar utilMenuCont = Container(align=uiconst.TOLEFT, parent=self.topPanel, width=20) UtilMenu(menuAlign=uiconst.BOTTOMLEFT, parent=utilMenuCont, align=uiconst.CENTERLEFT, GetUtilMenu=self.GetSettingsMenu, texturePath='res:/UI/Texture/SettingsCogwheel.png', width=16, height=16, iconSize=18) self.ownerCombo = Combo(name='ownerCombo', parent=self.topPanel, align=uiconst.TOLEFT, callback=self.OnOwnerCombo, width=120) self.facilityCombo = Combo(name='facilityCombo', parent=self.topPanel, align=uiconst.TOLEFT, callback=self.OnFacilityCombo, width=200, padLeft=5) self.invLocationCombo = Combo(name='invLocationCombo', parent=self.topPanel, align=uiconst.TOLEFT, callback=self.OnInvLocationCombo, padLeft=5, width=120, settingsID='IndustryBlueprintBrowserInvLocation') self.blueprintTypeCombo = Combo(name='blueprintTypeCombo', parent=self.topPanel, align=uiconst.TOLEFT, callback=self.OnBlueprintTypeCombo, padLeft=5, width=100, settingsID='IndustryBlueprintBrowserType', options=self.GetBlueprintTypeComboOptions()) self.categoryGroupCombo = Combo(name='categoryGroupCombo ', parent=self.topPanel, align=uiconst.TOLEFT, callback=self.OnCategoryGroupCombo, padLeft=5, width=100) self.viewModeButtons = ViewModeButtons(parent=self.topPanel, align=uiconst.TORIGHT, controller=self, settingsID='IndustryBlueprintBrowserViewMode') self.filterEdit = QuickFilterEdit(name='searchField', parent=self.topPanel, hinttext=localization.GetByLabel('UI/Inventory/Filter'), maxLength=64, align=uiconst.TORIGHT, padRight=4) self.filterEdit.ReloadFunction = self.OnFilterEdit self.UpdateOwnerCombo() self.UpdateBlueprintTypeCombo() self.UpdateScroll()
def AddOwnerCombo(self): ownerOptions = [(GetByLabel('UI/Industry/AllFacilities'), browserUIConst.OWNER_ANY), (GetByLabel('UI/Industry/PublicFacilities'), browserUIConst.OWNER_NPC, None, 'res:/UI/Texture/Classes/Inventory/readOnly.png'), (GetByLabel('UI/Industry/CorpOwnedFacilities'), browserUIConst.OWNER_CORP, None, 'res:/UI/Texture/Classes/Industry/iconCorp.png')] selected = self.controller.GetStructureOwnerValue() self.ownerCombo = Combo(name='ownerCombo', parent=self, align=uiconst.CENTERLEFT, prefsKey='StructureBrowserOwner', callback=self.ChangeStructureOwnerFilter, options=ownerOptions, select=selected, padRight=4, top=-2, left=self.uiLeft) self.uiLeft = self.ownerCombo.left + self.ownerCombo.width + 10
class ComboWithLabel(Container): default_align = uiconst.TOTOP default_height = 20 default_padTop = 8 def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.label = EveLabelSmall(text=attributes.text, parent=self, state=uiconst.UI_DISABLED, align=uiconst.CENTERLEFT, width=LABELWIDTH) self.combo = Combo(name='passwordEdit', parent=self, align=uiconst.TOLEFT, padLeft=LABELWIDTH, options=attributes.options, callback=attributes.callback, select=attributes.select, width=140) def GetValue(self): return self.combo.GetValue()
def SetupUI(self, showUI = True): uicore.layer.main.Flush() col1 = Container(parent=uicore.layer.main, align=uiconst.TOLEFT, width=160, padLeft=20, padTop=10) self.femaleCB = self.AddCheckbox('female', col1) self.maleCB = self.AddCheckbox('male', col1) Line(parent=col1, align=uiconst.TOTOP) self.bloodlines = [] for bloodlineID, each in BLOODLINES: cb = self.AddCheckbox(each, col1) cb.bloodlineID = bloodlineID self.bloodlines.append(cb) Line(parent=col1, align=uiconst.TOTOP) cb = self.AddCheckbox('mannequin', col1) cb.bloodlineID = -1 cb.padTop = 5 self.mannequinCB = cb Line(parent=col1, align=uiconst.TOTOP, padBottom=15) cb = self.AddCheckbox('render rgb', col1) cb.hint = 'to render images with 3 different background to make alpha (needs processing). You should be using this' self.rgbCB = cb Line(parent=col1, align=uiconst.TOTOP, padBottom=15) cb = self.AddCheckbox('render Types', col1) self.renderTypesCb = cb cb.hint = 'check this to only render typed Items. Leave field blank to render all types, else provide typeIDs.\n<br>Usually typed items should only be rendered on mannequins, but can be rendered on any doll (tattoos look bad on mannequin so they are rendered on bloodlines)' self.typeIDsEditField = SinglelineEdit(parent=col1, align=uiconst.TOTOP, padding=(15, -4, 20, 0)) Line(parent=col1, align=uiconst.TOTOP, padBottom=15) cb = self.AddCheckbox('render sets', col1) self.renderSetsCb = cb cb.hint = 'check this to only render sets of typed items. Need to provide a list of sets of this format:\n<br>(typeID1, typeID2, typeID3), (typeID4, typeID5, typeID6)' self.setTypeIDsEditField = SinglelineEdit(parent=col1, align=uiconst.TOTOP, padding=(15, -4, 20, 0)) col2 = Container(parent=uicore.layer.main, align=uiconst.TOLEFT, width=160, padTop=10) col3 = Container(parent=uicore.layer.main, align=uiconst.TOLEFT, width=140, padTop=10) self.checkboxes = [] categs = SETUP.keys() categs.sort() for each in categs[:20]: if isinstance(each, types.StringTypes): cb = self.AddCheckbox(each, col2) self.checkboxes.append(cb) for each in categs[20:]: if isinstance(each, types.StringTypes): cb = self.AddCheckbox(each, col3) self.checkboxes.append(cb) Line(parent=col3, align=uiconst.TOTOP, padBottom=20) self.altCheckboxes = [] for each in ('poses', 'lights'): cb = self.AddCheckbox(each, col3) self.altCheckboxes.append(cb) self.sizeCombo = Combo(label='Size', parent=col3, options=[('512', 512), ('128', 128)], name='sizeCombo', align=uiconst.TOTOP, padTop=40) self.sizeCombo.hint = 'use 512 for NES rendering, unless the 128 rendering has been fixed' resolutionOption = [('Best', ccConst.TEXTURE_RESOLUTIONS[0]), ('Good', ccConst.TEXTURE_RESOLUTIONS[1]), ('Low', ccConst.TEXTURE_RESOLUTIONS[2])] self.resolutionCombo = Combo(label='Resolution', parent=col3, options=resolutionOption, name='resolutionComb', align=uiconst.TOTOP, padTop=20) self.resolutionCombo.hint = "it's ok to use Good for character creator/types, use Best for NES rendering" b1 = Button(parent=uicore.layer.main, label='Render', align=uiconst.CENTERBOTTOM, func=self.RenderLoopAll, top=20) b2 = Button(parent=uicore.layer.main, label='Try one item', align=uiconst.BOTTOMLEFT, func=self.RenderLoopTry, top=20, left=20) if not showUI: for each in [col1, col2, col3, b1, b2]: each.display = False
class ExplosionDebugger(object): def __init__(self): self.name = 'Explosions' self.windowID = 'Explosions_ ' + self.name self._sceneManager = sm.GetService('sceneManager') self._michelle = sm.GetService('michelle') self.scroll = None self.selectedBallsToExplosionBucketID = {} self.ballIDToExplosion = {} self.explosionBucketsUsedWhenWindowOpened = False def GetBall(self, ballID=None): if ballID is None: ballID = self.shipId return sm.GetService('michelle').GetBall(ballID) def _OnClose(self): SpaceObjectExplosionManager.USE_EXPLOSION_BUCKETS = self.explosionBucketsUsedWhenWindowOpened def ShowUI(self): self.explosionBucketsUsedWhenWindowOpened = SpaceObjectExplosionManager.USE_EXPLOSION_BUCKETS wnd = uicontrols.Window.Open(windowID=self.windowID) wnd.SetTopparentHeight(0) wnd.SetMinSize([500, 250]) wnd.SetCaption(self.name) wnd._OnClose = self._OnClose main = wnd.GetMainArea() bottomCont = Container(name='bottomCont', parent=main, align=uiconst.TOBOTTOM, height=30, width=50, padBottom=10) explosionSelectionContainer = Container(name='explosionSelectionCont', parent=main, align=uiconst.TOBOTTOM, height=30, padTop=10, padBottom=10) explosionContainer = Container(name='explosionContainer', parent=main, align=uiconst.TOALL, padBottom=10) self.scroll = uicontrols.Scroll(parent=explosionContainer) self.scroll.sr.id = 'explosionDebugScroll' self.scroll.OnSelectionChange = self.OnSelectionChange self.explosionCombo = Combo(name='myCombo', parent=explosionSelectionContainer, label='Set explosion to selected items', options=[('Random', None)], callback=self.OnExplosionSelected, align=uiconst.TOTOP, padRight=12, padLeft=12) buttonGrid = GridContainer(name='buttonGrid', parent=bottomCont, align=uiconst.CENTER, width=150, height=20, lines=1, columns=3) ButtonIcon( name='Play', parent=buttonGrid, align=uiconst.TORIGHT, width=20, height=20, iconSize=24, padRight=15, texturePath='res:/UI/Texture/Icons/play.png', func=self.Explode, hint='Play Explosions (the exploding ships will not survive)') ButtonIcon(name='Refresh', parent=buttonGrid, align=uiconst.CENTER, width=20, height=20, iconSize=24, texturePath='res:/UI/Texture/Icons/replay.png', func=self.UpdateTable, hint='Update table') ButtonIcon(name='ClearWrecks', parent=buttonGrid, align=uiconst.TOLEFT, width=20, height=20, iconSize=32, padLeft=15, texturePath='res:/UI/Texture/Icons/44_32_37.png', func=self.ClearWrecks, hint='Clear wrecks') self.UpdateTable() def UpdateTable(self): layout = '%s<t>%s<t>%s<t>%s<t>%s<t>%s' headers = [ 'distance (m)', 'itemID', 'Type Name', 'Group Name', 'Explosion Bucket ID', 'Selected Explosion' ] content = [] ballpark = sm.GetService('michelle').GetBallpark() balls = ballpark.GetBallsInRange(session.shipid, SEARCH_DISTANCE) selectedEntries = [] for ballID in balls: ball = sm.GetService('michelle').GetBall(ballID) if not hasattr(ball, 'typeData') or getattr( ball, 'exploded', False): continue typeID = ball.typeData['typeID'] explosionBucketID = GetExplosionBucketIDByTypeID(typeID) if explosionBucketID is None: continue typeName = evetypes.GetName(typeID) groupName = evetypes.GetGroupName(typeID) explosionRes = 'Random' dist = util.FmtAmt(ballpark.DistanceBetween( session.shipid, ballID)) info = (dist, ballID, typeName, groupName, explosionBucketID, explosionRes) label = layout % info entry = uicontrols.ScrollEntryNode( decoClass=uicontrols.SE_GenericCore, label=label) if ballID in self.selectedBallsToExplosionBucketID: selectedEntries.append(entry) content.append(entry) self.scroll.Load(contentList=content, headers=headers, fixedEntryHeight=18) self.scroll.SelectNodes(selectedEntries) def OnSelectionChange(self, selection): self.selectedBallsToExplosionBucketID = {} for item in selection: itemInfo = item.label.split('<t>') itemID = int(itemInfo[1]) explosionBucketID = int(itemInfo[4]) self.selectedBallsToExplosionBucketID[itemID] = explosionBucketID explosionBuckets = set(self.selectedBallsToExplosionBucketID.values()) options = [('Random', None)] for explosionBucketID in explosionBuckets: for race, explosions in GetExplosionRaces( int(explosionBucketID)).iteritems(): for explosion in explosions: options.append((explosion.filePath, explosion)) self.explosionCombo.LoadOptions(options) def OnExplosionSelected(self, combobox, key, value): selectedBalls = self.selectedBallsToExplosionBucketID.keys() for ballID in selectedBalls: if value is None: del self.ballIDToExplosion[ballID] else: self.ballIDToExplosion[ballID] = value for row in self.scroll.sr.nodes: if not row.get('selected', 0): continue label = row.label splitLabel = label.split('<t>') splitLabel[5] = value.filePath row.label = '<t>'.join(splitLabel) self.scroll.ReloadNodes() def Explode(self): SpaceObjectExplosionManager.USE_EXPLOSION_BUCKETS = True for ballID, explosion in self.ballIDToExplosion.iteritems(): SpaceObjectExplosionManager.SetPreferredExplosion( ballID, explosion) for ballID in self.selectedBallsToExplosionBucketID: sm.GetService('slash').SlashCmd('/kill %s' % ballID) if ballID in self.ballIDToExplosion: del self.ballIDToExplosion[ballID] self.selectedBallsToExplosionBucketID = {} def ClearWrecks(self): sm.GetService('slash').SlashCmd('/unspawn range=%s only=groupWreck' % SEARCH_DISTANCE)
def Enable(self, *args): Combo.Enable(self, *args) self.sr.expanderParent.Show()
class AssetRenderer(object): __guid__ = 'cc.AssetRenderer' __exportedcalls__ = {} def __init__(self, showUI = True): trinity.SetFpsEnabled(False) if uicore.layer.charactercreation.isopen: uicore.layer.charactercreation.TearDown() uicore.layer.charactercreation.Flush() uicore.layer.login.CloseView() uicore.layer.charsel.CloseView() for each in uicore.layer.main.children[:]: each.Close() uicore.device.ForceSize() self.resolution = ccConst.TEXTURE_RESOLUTIONS[1] self.oldNonRandomize = getattr(prefs, 'NoRandomize', False) prefs.NoRandomize = True self.characterSvc = sm.GetService('character') self.charID = 0 self.factory = sm.GetService('character').factory self.factory.compressTextures = False self.SetupUI(showUI=showUI) def SetupUI(self, showUI = True): uicore.layer.main.Flush() col1 = Container(parent=uicore.layer.main, align=uiconst.TOLEFT, width=160, padLeft=20, padTop=10) self.femaleCB = self.AddCheckbox('female', col1) self.maleCB = self.AddCheckbox('male', col1) Line(parent=col1, align=uiconst.TOTOP) self.bloodlines = [] for bloodlineID, each in BLOODLINES: cb = self.AddCheckbox(each, col1) cb.bloodlineID = bloodlineID self.bloodlines.append(cb) Line(parent=col1, align=uiconst.TOTOP) cb = self.AddCheckbox('mannequin', col1) cb.bloodlineID = -1 cb.padTop = 5 self.mannequinCB = cb Line(parent=col1, align=uiconst.TOTOP, padBottom=15) cb = self.AddCheckbox('render rgb', col1) cb.hint = 'to render images with 3 different background to make alpha (needs processing). You should be using this' self.rgbCB = cb Line(parent=col1, align=uiconst.TOTOP, padBottom=15) cb = self.AddCheckbox('render Types', col1) self.renderTypesCb = cb cb.hint = 'check this to only render typed Items. Leave field blank to render all types, else provide typeIDs.\n<br>Usually typed items should only be rendered on mannequins, but can be rendered on any doll (tattoos look bad on mannequin so they are rendered on bloodlines)' self.typeIDsEditField = SinglelineEdit(parent=col1, align=uiconst.TOTOP, padding=(15, -4, 20, 0)) Line(parent=col1, align=uiconst.TOTOP, padBottom=15) cb = self.AddCheckbox('render sets', col1) self.renderSetsCb = cb cb.hint = 'check this to only render sets of typed items. Need to provide a list of sets of this format:\n<br>(typeID1, typeID2, typeID3), (typeID4, typeID5, typeID6)' self.setTypeIDsEditField = SinglelineEdit(parent=col1, align=uiconst.TOTOP, padding=(15, -4, 20, 0)) col2 = Container(parent=uicore.layer.main, align=uiconst.TOLEFT, width=160, padTop=10) col3 = Container(parent=uicore.layer.main, align=uiconst.TOLEFT, width=140, padTop=10) self.checkboxes = [] categs = SETUP.keys() categs.sort() for each in categs[:20]: if isinstance(each, types.StringTypes): cb = self.AddCheckbox(each, col2) self.checkboxes.append(cb) for each in categs[20:]: if isinstance(each, types.StringTypes): cb = self.AddCheckbox(each, col3) self.checkboxes.append(cb) Line(parent=col3, align=uiconst.TOTOP, padBottom=20) self.altCheckboxes = [] for each in ('poses', 'lights'): cb = self.AddCheckbox(each, col3) self.altCheckboxes.append(cb) self.sizeCombo = Combo(label='Size', parent=col3, options=[('512', 512), ('128', 128)], name='sizeCombo', align=uiconst.TOTOP, padTop=40) self.sizeCombo.hint = 'use 512 for NES rendering, unless the 128 rendering has been fixed' resolutionOption = [('Best', ccConst.TEXTURE_RESOLUTIONS[0]), ('Good', ccConst.TEXTURE_RESOLUTIONS[1]), ('Low', ccConst.TEXTURE_RESOLUTIONS[2])] self.resolutionCombo = Combo(label='Resolution', parent=col3, options=resolutionOption, name='resolutionComb', align=uiconst.TOTOP, padTop=20) self.resolutionCombo.hint = "it's ok to use Good for character creator/types, use Best for NES rendering" b1 = Button(parent=uicore.layer.main, label='Render', align=uiconst.CENTERBOTTOM, func=self.RenderLoopAll, top=20) b2 = Button(parent=uicore.layer.main, label='Try one item', align=uiconst.BOTTOMLEFT, func=self.RenderLoopTry, top=20, left=20) if not showUI: for each in [col1, col2, col3, b1, b2]: each.display = False def AddCheckbox(self, cbName, parent, groupname = None): setting = Bunch(settings.user.ui.Get('assetRenderState', {})) cb = Checkbox(parent=parent, text=cbName, checked=bool(setting.Get(cbName, None)), callback=self.CBChange, groupname=groupname) cb.name = cbName return cb def CBChange(self, checkbox, *args): setting = settings.user.ui.Get('assetRenderState', {}) setting[checkbox.name] = checkbox.GetValue() settings.user.ui.Set('assetRenderState', setting) if not getattr(self, 'spreadingValue', False): ctrl = uicore.uilib.Key(uiconst.VK_CONTROL) if ctrl: self.spreadingValue = True if checkbox in self.bloodlines: for each in self.bloodlines: each.SetValue(checkbox.GetValue()) elif checkbox in self.checkboxes: for each in self.checkboxes: each.SetValue(checkbox.GetValue()) self.spreadingValue = False def RenderLoopTry(self, *args): self.RenderLoop(tryout=True) def RenderLoopAll(self, *args): self.RenderLoop(tryout=False) def RenderLoop(self, tryout = False, fromWebtools = False): try: self._RenderLoop(tryout=tryout, fromWebtools=fromWebtools) finally: uicore.device.ForceSize(512, 512) uicore.layer.menu.display = True uicore.layer.hint.display = True uicore.layer.main.display = True print 'in finally' prefs.NoRandomize = self.oldNonRandomize def _RenderLoop(self, tryout = False, fromWebtools = False): self.FindWhatToRender() self.characterSvc.characters = {} self.characterSvc.TearDown() uicore.layer.charactercreation.OpenView() uicore.layer.charactercreation.Flush() for layerName, layer in uicore.layer.__dict__.iteritems(): if isinstance(layer, LayerCore): layer.display = False renderSize = self.sizeCombo.GetValue() uicore.device.ForceSize(renderSize, renderSize) sm.GetService('sceneManager').SetSceneType(0) uicore.layer.charactercreation.SetupScene(ccConst.SCENE_PATH_CUSTOMIZATION) self.resolution = self.resolutionCombo.GetValue() scene = uicore.layer.charactercreation.scene lightScene = trinity.Load(NORMAL_LIGHT_SETTINGS) ccUtil.SetupLighting(scene, lightScene, lightScene) uicore.layer.charactercreation.cameraUpdateJob = None uicore.layer.charactercreation.camera = CharCreationCamera(None) uicore.layer.charactercreation.SetupCameraUpdateJob() camera = uicore.layer.charactercreation.camera self.SetupRenderJob() blue.pyos.synchro.SleepWallclock(2000) self.DoLightsAndPoses(camera, scene) self.DoAssets(camera, scene, tryout) def SetupRenderJob(self): for each in trinity.renderJobs.recurring: if each.name == 'cameraUpdate': trinity.renderJobs.recurring.remove(each) elif each.name == 'BaseSceneRenderJob': self.renderJob = each self.renderJob.RemoveStep('RENDER_BACKDROP') self.renderJob.SetClearColor((0.9, 0.9, 0.9, 0.0)) def FindWhatToRender(self): self.doRenderFemale = self.femaleCB.GetValue() self.doRenderMale = self.maleCB.GetValue() self.bloodlineIDsToRender = [ bloodlineCB.bloodlineID for bloodlineCB in self.bloodlines if bloodlineCB.GetValue() ] self.altGroupsToRender = [ checkBox.name for checkBox in self.altCheckboxes if checkBox.GetValue() ] self.assetCategoriesToRender = [ checkBox.name for checkBox in self.checkboxes if checkBox.GetValue() ] def DoLightsAndPoses(self, camera, scene): for altCategory in self.altGroupsToRender: for genderID, shouldRender in [(0, self.doRenderFemale), (1, self.doRenderMale)]: if not shouldRender: continue uicore.layer.charactercreation.genderID = genderID for bloodlineID in self.bloodlineIDsToRender: self.PosesAndLightThumbnails(bloodlineID, altCategory, camera, genderID, scene) def DoAssets(self, camera, scene, tryout): for gender, genderID, shouldRender in [('Female', 0, self.doRenderFemale), ('Male', 1, self.doRenderMale)]: if not shouldRender: continue if getattr(self, 'mannequinCB', None) and self.mannequinCB.GetValue(): avatar = self.RenderMannequinAssets(camera, genderID, scene, tryout) paperdollGender = ccUtil.GenderIDToPaperDollGender(genderID) for bloodlineID in self.bloodlineIDsToRender: character = self.PrepareBloodlineDoll(bloodlineID, paperdollGender, scene) self.RenderNormalAssets(bloodlineID, camera, character, genderID, scene, tryout) if tryout: break if tryout: break def PosesAndLightThumbnails(self, bloodlineID, altCategory, camera, genderID, scene): self.characterSvc.RemoveCharacter(self.charID) uicore.layer.charactercreation.ResetDna() paperdollGender = ccUtil.GenderIDToPaperDollGender(genderID) self.SetupCharacter(bloodlineID, scene, paperdollGender) for dcCategory in DRESSCODE[ccConst.hair]: dcTypeData = self.characterSvc.GetAvailableTypesByCategory(dcCategory, genderID, bloodlineID) if dcTypeData: dcItemType = dcTypeData[0] dcModifier = self.characterSvc.ApplyTypeToDoll(self.charID, dcItemType) character = self.characterSvc.GetSingleCharacter(self.charID) self.WaitForDollAndScene(character.doll, scene) trinity.WaitForResourceLoads() camera.SetFieldOfView(0.3) if altCategory == 'poses': self.RenderPoseThumbnails(bloodlineID, camera, character, genderID) elif altCategory == 'lights': self.RenderLightThumbnails(bloodlineID, camera, genderID) def RenderPoseThumbnails(self, bloodlineID, camera, character, genderID): if genderID == 0: camera.SetPointOfInterest((0.0, 1.5, 0.0)) else: camera.SetPointOfInterest((0.0, 1.6, 0.0)) camera.distance = 2.0 camera.Update() self.characterSvc.StartPosing(self.charID) character.avatar.animationUpdater.network.SetControlParameter('ControlParameters|NetworkMode', 2) renderRGB = self.rgbCB.GetValue() for i in xrange(ccConst.POSERANGE): self.characterSvc.ChangePose(i, self.charID) blue.pyos.synchro.SleepWallclock(100) outputPath = OUTPUT_ROOT + '%s_g%s_b%s.png' % ('pose_%s' % i, genderID, bloodlineID) self.SaveScreenShot(outputPath, rgb=renderRGB) def RenderLightThumbnails(self, bloodlineID, camera, genderID): if genderID == 0: camera.SetPointOfInterest((0.0, 1.6, 0.0)) else: camera.SetPointOfInterest((0.0, 1.7, 0.0)) camera.distance = 1.4 camera.Update() lightingList = ccConst.LIGHT_SETTINGS_ID lightingColorList = ccConst.LIGHT_COLOR_SETTINGS_ID renderRGB = self.rgbCB.GetValue() for each in lightingList: for color in lightingColorList: uicore.layer.charactercreation.SetLightsAndColor(each, color) blue.synchro.Yield() blue.resMan.Wait() trinity.WaitForResourceLoads() for i in xrange(10): blue.pyos.synchro.SleepWallclock(100) camera.Update() outputPath = OUTPUT_ROOT + '%s_g%s_b%s.png' % ('light_%s_%s' % (each, color), genderID, bloodlineID) self.SaveScreenShot(outputPath, rgb=renderRGB) def FreezeCharacter(self, avatar): avatar.animationUpdater.network.SetControlParameter('ControlParameters|isAlive', 0) avatar.animationUpdater.network.update = False blue.pyos.synchro.SleepWallclock(500) def RenderMannequinAssets(self, camera, genderID, scene, tryout): mannequin = paperDoll.PaperDollCharacter(self.factory) mannequin.doll = paperDoll.Doll('mannequin', gender=ccUtil.GenderIDToPaperDollGender(genderID)) doll = mannequin.doll if genderID == ccConst.GENDERID_MALE: doll.Load(MALE_MANNEQUIN, self.factory) else: doll.Load(FEMALE_MANNEQUIN, self.factory) self.WaitForDoll(doll) doll.overrideLod = paperDoll.LOD_SKIN doll.textureResolution = self.resolution mannequin.Spawn(scene, usePrepass=False) avatar = mannequin.avatar networkPath = ccConst.CHARACTER_CREATION_NETWORK self.factory.CreateGWAnimation(avatar, networkPath) network = avatar.animationUpdater.network if network is not None: network.SetControlParameter('ControlParameters|BindPose', 1.0) if doll.gender == 'female': network.SetAnimationSetIndex(0) else: network.SetAnimationSetIndex(1) blue.pyos.synchro.SleepWallclock(500) self.FreezeCharacter(avatar) if self.renderSetsCb.GetValue(): self.LoadMannequinAndCamera(mannequin, genderID, ccConst.outer, camera, scene) setText = self.setTypeIDsEditField.GetValue() setText = setText.strip() if not setText.endswith(','): setText += ',' clothingSets = eval(setText) for eachSet in clothingSets: self.DoRenderMannequinAssetType(avatar, eachSet, genderID, mannequin, scene, 'set') return avatar for category in self.assetCategoriesToRender: self.LoadMannequinAndCamera(mannequin, genderID, category, camera, scene) typeData = self.characterSvc.GetAvailableTypesByCategory(category, genderID, -1) for itemType in typeData: wasRendered = self.RenderMannequinAssetType(avatar, genderID, mannequin, scene, itemType, category) if wasRendered and tryout: break return avatar def LoadMannequinAndCamera(self, mannequin, genderID, category, camera, scene): doll = mannequin.doll if genderID == ccConst.GENDERID_MALE: doll.Load(MALE_MANNEQUIN, self.factory) else: doll.Load(FEMALE_MANNEQUIN, self.factory) self.WaitForDoll(doll) lightScene = trinity.Load(NORMAL_LIGHT_SETTINGS) ccUtil.SetupLighting(scene, lightScene, lightScene) cameraSetup = self.SetUpCamera(camera, category, mannequin, SETUP, scene, genderID) def GetTypeIDsFromField(self): typeIDsString = self.typeIDsEditField.GetValue() typeIDs = [ int(x) for x in typeIDsString.split(',') if x ] return typeIDs def RenderMannequinAssetType(self, avatar, genderID, mannequin, scene, itemType, category): typeID = itemType[2] if typeID in (None, -1): return False typeIDs = self.GetTypeIDsFromField() if typeIDs and typeID not in typeIDs: return False return self.DoRenderMannequinAssetType(avatar, [typeID], genderID, mannequin, scene, category) def DoRenderMannequinAssetType(self, avatar, typeIDs, genderID, mannequin, scene, category): if category == ccConst.bottommiddle: pantsModifiers = mannequin.doll.buildDataManager.GetModifiersByCategory(ccConst.bottomouter) for pm in pantsModifiers: mannequin.doll.RemoveResource(pm.GetResPath(), self.factory) modifierList = [] for typeID in typeIDs: asset = GetPaperDollResource(typeID, genderID) doll = mannequin.doll path = asset.resPath modifier = doll.SetItemType(self.factory, path, weight=1.0) if modifier: modifierList.append(modifier) mannequin.Update() self.WaitForDoll(doll) if not modifierList: return False self.SetShadow(avatar, scene) blue.pyos.synchro.SleepWallclock(500) renderRGB = self.rgbCB.GetValue() if len(typeIDs) == 1: outputPath = self.GetOutputPath(assetPath=path, genderID=genderID, category=category, typeID=typeID) else: typeIDsString = str(typeIDs).replace(' ', '').replace('(', '').replace(')', '').replace(',', '_') outputPath = self.GetOutputPath(assetPath=typeIDsString, genderID=genderID, category=category) self.SaveScreenShot(outputPath, rgb=renderRGB) for modifier in modifierList: doll.RemoveResource(modifier.GetResPath(), self.factory) mannequin.Update() self.WaitForDoll(doll) return True def PrepareBloodlineDoll(self, bloodlineID, paperdollGender, scene): self.characterSvc.RemoveCharacter(self.charID) uicore.layer.charactercreation.ResetDna() self.SetupCharacter(bloodlineID, scene, paperdollGender) character = self.characterSvc.GetSingleCharacter(self.charID) character.avatar.translation = (0.0, 0.0, 0.0) self.WaitForDollAndScene(character.doll, scene) self.FreezeCharacter(character.avatar) trinity.WaitForResourceLoads() return character def SetupCharacter(self, bloodlineID, scene, paperdollGender): self.characterSvc.AddCharacterToScene(self.charID, scene, paperdollGender, bloodlineID=bloodlineID) doll = self.characterSvc.GetSingleCharactersDoll(self.charID) doll.overrideLod = paperDoll.LOD_SKIN doll.textureResolution = self.resolution self.characterSvc.SetDollBloodline(self.charID, bloodlineID) self.characterSvc.ApplyItemToDoll(self.charID, 'head', bloodlineAssets[bloodlineID], doUpdate=False) self.characterSvc.UpdateDoll(self.charID, fromWhere='RenderLoop') def RenderNormalAssets(self, bloodlineID, camera, character, genderID, scene, tryout): doll = character.doll for category in self.assetCategoriesToRender: typeData = self.characterSvc.GetAvailableTypesByCategory(category, genderID, bloodlineID) lightScene = trinity.Load(NORMAL_LIGHT_COLOR) ccUtil.SetupLighting(scene, lightScene, lightScene) cameraSetup = self.SetUpCamera(camera, category, character, SETUP, scene, genderID) log.LogNotice('before dresscode') if category in DRESSCODE: removeDcModifers = self.EnforceDresscode(bloodlineID, category, doll, genderID) else: removeDcModifers = [] log.LogNotice('go render type') for itemType in typeData: wasRendered = self.RenderNormalType(bloodlineID, camera, category, character, genderID, itemType, scene) if tryout and wasRendered: break log.LogNotice('remove the dresscode') for dcResPath in removeDcModifers: doll.RemoveResource(dcResPath, self.factory) log.LogNotice('done with category') def RenderNormalType(self, bloodlineID, camera, category, character, genderID, itemType, scene): typeID = itemType[2] if typeID is not None: if not self.renderTypesCb.GetValue(): return False typeIDs = self.GetTypeIDsFromField() if typeIDs and typeID not in typeIDs: return False doll = character.doll modifer = self.characterSvc.ApplyTypeToDoll(self.charID, itemType) if not modifer: return False typeInfo = itemType[1] if typeInfo[0].startswith('scars'): self.SetCameraForScar(typeInfo, character, camera, scene) if typeInfo[0].startswith(PIERCINGCATEGORIES): self.SetCameraAndLightPiercings(category, typeInfo, character, camera, scene) self.ApplyTuckingIfNeeded(category) self.TrySetColor(bloodlineID, category, genderID, typeInfo) if (category, genderID) in EXAGGERATE: if getattr(modifer, 'weight', None) is not None: modifer.weight = 1.5 * modifer.weight self.characterSvc.UpdateDoll(self.charID, fromWhere='RenderLoop') self.SetShadow(character.avatar, scene) blue.pyos.synchro.SleepWallclock(500) self.WaitForDoll(doll) blue.resMan.Wait() trinity.WaitForResourceLoads() path = '_'.join(list(itemType[1])) outputPath = self.GetOutputPath(assetPath=path, genderID=genderID, category=category, bloodlineID=bloodlineID, typeID=typeID) renderRGB = self.rgbCB.GetValue() self.SaveScreenShot(outputPath, rgb=renderRGB) doll.RemoveResource(modifer.GetResPath(), self.factory) return True def ApplyTuckingIfNeeded(self, category): if category not in TUCKINDEX: return tuckPath, requiredModifier, subKey = ccConst.TUCKMAPPING[category] tuckModifier = sm.GetService('character').GetModifierByCategory(self.charID, tuckPath) if tuckModifier: tuckVariations = tuckModifier.GetVariations() tuckStyle = tuckModifier.GetResPath().split('/')[-1] self.characterSvc.ApplyItemToDoll(self.charID, category, tuckStyle, variation=tuckVariations[TUCKINDEX[category]]) def TrySetColor(self, bloodlineID, category, genderID, typeInfo): if category in (ccConst.beard, ccConst.hair, ccConst.eyebrows): category = ccConst.hair try: if typeInfo[1] or typeInfo[2]: return categoryColors = self.characterSvc.GetAvailableColorsForCategory(category, genderID, bloodlineID) if not categoryColors: return primary, secondary = categoryColors primaryVal = (primary[1][0], primary[1][2]) if primary and secondary: secondaryVal = (secondary[1][0], secondary[1][2]) self.characterSvc.SetColorValueByCategory(self.charID, category, primaryVal, secondaryVal) else: self.characterSvc.SetColorValueByCategory(self.charID, category, primaryVal, None) except: pass finally: if category == ccConst.hair: sm.GetService('character').SetHairDarkness(0, 0.5) def ReformatAssetPath(self, path): assetResPath = path.replace('/', '_').replace('.type', '') return assetResPath def WaitForDollAndScene(self, doll, scene): while len(scene.dynamics) < 1: blue.synchro.Yield() blue.synchro.Yield() self.WaitForDoll(doll) def WaitForDoll(self, doll): while doll.busyUpdating: blue.synchro.Yield() def EnforceDresscode(self, bloodlineID, category, doll, genderID): if category in DRESSCODE_CUSTOM_BY_CATEGORY: dressCode = DRESSCODE_CUSTOM_BY_CATEGORY[category][genderID] elif genderID == ccConst.GENDERID_FEMALE: dressCode = DRESSCODE_FEMALE_DEFAULT else: dressCode = DRESSCODE_MALE_DEFAULT removeDcModifers = [] for dcCategory in DRESSCODE_CATEGORIES: if dcCategory == category: continue dcTypeData = self.characterSvc.GetAvailableTypesByCategory(dcCategory, genderID, bloodlineID) if not dcTypeData: continue for itemType in dcTypeData: assetID = itemType[0] if assetID in dressCode: if dcCategory == ccConst.hair: var = self.GetHairColor(genderID, bloodlineID) else: var = None dcModifier = self.characterSvc.ApplyTypeToDoll(self.charID, itemType, doUpdate=False, rawColorVariation=var) if dcModifier: removeDcModifers.append(dcModifier.GetResPath()) self.WaitForDoll(doll) blue.resMan.Wait() break return removeDcModifers def SetShadow(self, avatar, scene): if paperDoll.SkinSpotLightShadows.instance is not None: paperDoll.SkinSpotLightShadows.instance.Clear(killThread=True) del paperDoll.SkinSpotLightShadows.instance paperDoll.SkinSpotLightShadows.instance = None ss = paperDoll.SkinSpotLightShadows(scene, debugVisualize=False, size=2048) ss.SetupSkinnedObject(avatar) paperDoll.SkinSpotLightShadows.instance = ss def SetCameraAndLightPiercings(self, category, typeInfo, character, camera, scene): typeName, a, b = typeInfo if typeName.endswith('left', 0, -1): dictToUse = PIERCINGLEFTGROUPS elif typeName.endswith('right', 0, -1): dictToUse = PIERCINGRIGHTGROUPS else: dictToUse = PIERCINGPAIRGROUPS self.SetUpCamera(camera, category, character, dictToUse, scene) def SetCameraForScar(self, typeInfo, character, camera, scene): group = SCARGROUPS.get(typeInfo, None) if group is None: print 'couldnt find the group, return' return self.SetUpCamera(camera, group, character, SCARCAMERASETINGS, scene) def SetCamera(self, camera, poi, distance, yaw, pitch): camera.SetPointOfInterest(poi) camera.distance = distance camera.SetFieldOfView(0.3) camera.SetYaw(yaw) camera.SetPitch(pitch) camera.Update() def SetUpCamera(self, camera, category, character, categoryList = SETUP, scene = None, genderID = None): if (category, genderID) in categoryList: options = categoryList[category, genderID] else: options = categoryList.get(category, None) if options: log.LogNotice('+ category = %s' % category) boneName, offset, lightSetting = options if lightSetting: path = '%s%s.red' % (LIGHTLOCATION, lightSetting) lightScene = trinity.Load(path) ccUtil.SetupLighting(scene, lightScene, lightScene) log.LogNotice('before joint') joint = 4294967295L while joint == 4294967295L: log.LogNotice('joint = %s' % joint) log.LogNotice('boneName = %s' % boneName) joint = character.avatar.GetBoneIndex(boneName) log.LogNotice('j = %s' % joint) blue.synchro.Yield() log.LogNotice('done waiting') log.LogNotice('-- joint = %s' % joint) poi = character.avatar.GetBonePosition(joint) distance, yOffset, xOffset, yaw, pitch = offset x, y, z = poi if yOffset: y += yOffset if xOffset: x += xOffset poi = (x, y, z) log.LogNotice('before poi') if category in (ccConst.bottomouter, ccConst.feet): poi = (0.0, y, z) log.LogNotice('before setting camera') self.SetCamera(camera, poi, distance, yaw, pitch) log.LogNotice('after setting camera') return (distance, yaw, pitch, poi) else: return def GetHairColor(self, genderID, bloodlineID): colorsA, colorsB = sm.GetService('character').GetAvailableColorsForCategory(ccConst.hair, genderID, bloodlineID) colorA = [] colorB = [] var = None color1Value, color1Name, color2Name, variation = (None, None, None, None) if len(colorsA) > 0: indexA = int(len(colorsA) * 0.3) colorA = colorsA[indexA] colorB = None if len(colorsB) > 0: colorB = colorsB[0] color1Value, color1Name, color2Name, variation = sm.GetService('character').GetColorsToUse(colorA, colorB) if color1Value: return var if colorB: var = variation elif len(colorA) > 0: var = colorA[1] return var def GetOutputPath(self, assetPath, genderID, category = None, bloodlineID = -1, typeID = None): assetResPath = self.ReformatAssetPath(assetPath) renderRGB = self.rgbCB.GetValue() categoryPath = self.ReformatAssetPath(category) if renderRGB: subFolder = RGB_FOLDER else: subFolder = categoryPath + '/' ccUtil.CreateCategoryFolderIfNeeded(OUTPUT_ROOT, subFolder) outputPath = OUTPUT_ROOT + subFolder if renderRGB: outputPath = outputPath + '%s~' % categoryPath if typeID: if genderID == ccConst.GENDERID_MALE: gender = 'male' else: gender = 'female' outputPath = outputPath + '%s_%s_%s.png' % (typeID, gender, assetResPath) elif bloodlineID < 0: outputPath = outputPath + '%s_g%s.png' % (assetResPath, genderID) else: outputPath = outputPath + '%s_g%s_b%s.png' % (assetResPath, genderID, bloodlineID) return outputPath def SaveScreenShot(self, outputPath, rgb = False): if rgb: clearColors = (('R', (1.0, 0.0, 0.0, 0.0)), ('G', (0.0, 1.0, 0.0, 0.0)), ('B', (0.0, 0.0, 1.0, 0.0))) else: clearColors = ((None, None),) print 'SaveScreenShot', outputPath for channel, color in clearColors: if color: self.renderJob.SetClearColor(color) blue.synchro.Yield() backBuffer = trinity.device.GetRenderContext().GetDefaultBackBuffer() if not backBuffer.isReadable: tempRT = trinity.Tr2RenderTarget(backBuffer.width, backBuffer.height, 1, backBuffer.format) backBuffer.Resolve(tempRT) bmp = trinity.Tr2HostBitmap(tempRT) else: bmp = trinity.Tr2HostBitmap(backBuffer) if bmp.format == trinity.PIXEL_FORMAT.B8G8R8A8_UNORM: bmp.ChangeFormat(trinity.PIXEL_FORMAT.B8G8R8X8_UNORM) if rgb: bmp.Save(outputPath[:-4] + '_' + channel + outputPath[-4:]) else: bmp.Save(outputPath)
def ShowUI(self): uicontrols.Window.CloseIfOpen(windowID=self.windowID) wnd = uicontrols.Window.Open(windowID=self.windowID) wnd.SetTopparentHeight(0) wnd.SetMinSize([500, 500]) wnd.SetCaption(self.name) main = wnd.GetMainArea() sofDB = blue.resMan.LoadObject( 'res:/dx9/model/spaceobjectfactory/data.red') self.sofFactions = [] for i in xrange(len(sofDB.faction)): self.sofFactions.append((sofDB.faction[i].name, i)) self.sofFactions.sort() self.sofHulls = [] for i in xrange(len(sofDB.hull)): self.sofHulls.append((sofDB.hull[i].name, i)) self.sofHulls.sort() self.sofRaces = [] for i in xrange(len(sofDB.race)): self.sofRaces.append((sofDB.race[i].name, i)) self.sofRaces.sort() self.sofMaterials = [] for i in xrange(len(sofDB.material)): self.sofMaterials.append((sofDB.material[i].name, i)) self.sofMaterials.sort() self.sofMaterials.insert(0, ('None', -1)) self.sofVariants = [] for i in xrange(len(sofDB.generic.variants)): self.sofVariants.append((sofDB.generic.variants[i].name, i)) self.sofVariants.sort() self.sofVariants.insert(0, ('None', -1)) self.sofPatterns = [] for i in xrange(len(sofDB.pattern)): self.sofPatterns.append((sofDB.pattern[i].name, i)) self.sofPatterns.sort() self.sofPatterns.insert(0, ('None', -1)) headerCont = Container(name='headerCont', parent=main, align=uiconst.TOTOP, height=30) gridCont = GridContainer(name='mainCont', parent=main, align=uiconst.TOBOTTOM, height=250, lines=5, columns=3) buttonConts = {} for y in xrange(gridCont.lines): for x in xrange(gridCont.columns): buttonConts[x, y] = Container(parent=gridCont) self.dnaLabel = EveLabelSmall(name='dnaLabel', align=uiconst.CENTER, parent=headerCont, text='') self.copyDnaButton = Button(name='copy_dna_button', align=uiconst.CENTER, parent=buttonConts[(0, 4)], label='Copy DNA', func=self._OnCopyDnaButton) self.applyButton = Button(name='apply_button', align=uiconst.CENTER, parent=buttonConts[(1, 4)], label='Apply', func=self._OnApplyButton) patternParent = Container(name='patternParent', parent=buttonConts[(0, 3)], align=uiconst.CENTER, height=18, width=175) self.patternCombo = Combo(name='pattern_combo', align=uiconst.TOLEFT, width=150, parent=patternParent, label='Pattern:', options=self.sofPatterns, callback=self.OnPatternComboChange, select=self.GetComboListIndex( self.sofPatterns, self.currentPattern)) factionParent = Container(name='factionParent', parent=buttonConts[(0, 2)], align=uiconst.CENTER, height=18, width=175) self.factionCombo = Combo(name='faction_combo', align=uiconst.TOLEFT, width=150, parent=factionParent, label='Faction:', options=self.sofFactions, callback=self.OnFactionComboChange, select=self.GetComboListIndex( self.sofFactions, self.currentFaction)) self.factionConstraint = Checkbox( name='faction_constraint', align=uiconst.TOLEFT, width=75, padLeft=10, parent=factionParent, text='Constrained', callback=self.OnFactionConstraintChanged) hullParent = Container(name='hullParent', parent=buttonConts[(0, 1)], align=uiconst.CENTER, height=18, width=175) self.hullCombo = Combo(name='hull_combo', align=uiconst.TOLEFT, width=150, parent=hullParent, label='Hull:', options=self.sofHulls, callback=self.OnHullComboChange, select=self.GetComboListIndex( self.sofHulls, self.currentHull)) self.hullConstraint = Checkbox(name='hull_constraint', align=uiconst.TOLEFT, width=75, padLeft=10, parent=hullParent, text='Constrained', callback=self.OnHullConstraintChanged) raceParent = Container(name='raceParent', parent=buttonConts[(0, 0)], align=uiconst.CENTER, height=18, width=175) self.raceCombo = Combo(name='race_combo', align=uiconst.TOLEFT, width=150, parent=raceParent, label='Race:', options=self.sofRaces, callback=self.OnRaceComboChange, select=self.GetComboListIndex( self.sofRaces, self.currentRace)) self.raceConstraint = Checkbox(name='race_constraint', align=uiconst.TOLEFT, width=75, padLeft=10, parent=raceParent, text='Constrained', callback=self.OnRaceConstraintChanged) self.matCombo1 = Combo(name='material_combo1', align=uiconst.CENTER, width=150, parent=buttonConts[(1, 0)], label='Material 1:', options=self.sofMaterials, callback=self.OnMat1ComboChange, select=self.GetComboListIndex( self.sofMaterials, self.currentMat[0])) self.matCombo2 = Combo(name='material_combo2', align=uiconst.CENTER, width=150, parent=buttonConts[(1, 1)], label='Material 2:', options=self.sofMaterials, callback=self.OnMat2ComboChange, select=self.GetComboListIndex( self.sofMaterials, self.currentMat[1])) self.matCombo3 = Combo(name='material_combo3', align=uiconst.CENTER, width=150, parent=buttonConts[(1, 2)], label='Material 3:', options=self.sofMaterials, callback=self.OnMat3ComboChange, select=self.GetComboListIndex( self.sofMaterials, self.currentMat[2])) self.matCombo4 = Combo(name='material_combo4', align=uiconst.CENTER, width=150, parent=buttonConts[(1, 3)], label='Material 4:', options=self.sofMaterials, callback=self.OnMat4ComboChange, select=self.GetComboListIndex( self.sofMaterials, self.currentMat[3])) self.dirtSlider = Slider(name='dirt_slider', align=uiconst.CENTER, label='Dirt', parent=buttonConts[(2, 0)], width=200, minValue=0.0, maxValue=100.0, startVal=50.0, setlabelfunc=self.UpdateDirtSliderLabel, onsetvaluefunc=self.OnDirtSliderChange, endsliderfunc=self.OnDirtSliderChange) materialSetIdContainer = Container(name='materialSetContainer', parent=buttonConts[(2, 1)], align=uiconst.CENTER, height=18, width=175) self.materialSetIDCombo = Combo(name='materialsetid_edit', align=uiconst.TOLEFT, label='Masterial Set ID', parent=materialSetIdContainer, options=[], callback=self.OnMaterialSetIDChange) self._FilterMaterialSet(False) self.materialSetFilteredByRace = Checkbox( name='materialSetFilter', align=uiconst.TOLEFT, width=150, padLeft=10, parent=materialSetIdContainer, text='Filter By Race', callback=self.OnMaterialSetFiltered) self.resPathInsertEdit = SinglelineEdit( name='respathinsert_edit', align=uiconst.CENTER, label='resPathInsert', parent=buttonConts[(2, 2)], width=100, setvalue='', OnFocusLost=self.OnResPathInsertChange, OnReturn=self.OnResPathInsertChange) self.variantCombo = Combo(name='variant_combo', align=uiconst.CENTER, width=150, parent=buttonConts[(2, 3)], label='Variants:', options=self.sofVariants, callback=self.OnVariantComboChange, select=self.GetComboListIndex( self.sofVariants, self.currentVariant)) self.previewCont = PreviewContainer(parent=main, align=uiconst.TOALL) self.previewCont.PreviewSofDna(self.GetPreviewDna())
def Disable(self, *args): Combo.Disable(self, *args) self.sr.expanderParent.Hide()
class SOFPreviewWindow: def __init__(self): self.name = 'SOF Preview Window' self.windowID = 'SOFPreviewWindow_ ' + self.name self.previewCont = None dna = self.GetDnaFromPlayerShip() self.currentHull = dna.split(':')[0] self.currentFaction = dna.split(':')[1] self.currentRace = dna.split(':')[2] self.currentMat = ['None', 'None', 'None', 'None'] self.currentVariant = 'None' self.currentPattern = 'None' self.currentDirtLevel = None self.currentResPathInsert = None self.constrainToFaction = False self.constrainToHull = False self.constrainToRace = False def _OnApplyButton(self, *args): self._UpdatePlayerShip() def _OnCopyDnaButton(self, *args): blue.pyos.SetClipboardData(self.GetPreviewDna()) def ShowUI(self): uicontrols.Window.CloseIfOpen(windowID=self.windowID) wnd = uicontrols.Window.Open(windowID=self.windowID) wnd.SetTopparentHeight(0) wnd.SetMinSize([500, 500]) wnd.SetCaption(self.name) main = wnd.GetMainArea() sofDB = blue.resMan.LoadObject( 'res:/dx9/model/spaceobjectfactory/data.red') self.sofFactions = [] for i in xrange(len(sofDB.faction)): self.sofFactions.append((sofDB.faction[i].name, i)) self.sofFactions.sort() self.sofHulls = [] for i in xrange(len(sofDB.hull)): self.sofHulls.append((sofDB.hull[i].name, i)) self.sofHulls.sort() self.sofRaces = [] for i in xrange(len(sofDB.race)): self.sofRaces.append((sofDB.race[i].name, i)) self.sofRaces.sort() self.sofMaterials = [] for i in xrange(len(sofDB.material)): self.sofMaterials.append((sofDB.material[i].name, i)) self.sofMaterials.sort() self.sofMaterials.insert(0, ('None', -1)) self.sofVariants = [] for i in xrange(len(sofDB.generic.variants)): self.sofVariants.append((sofDB.generic.variants[i].name, i)) self.sofVariants.sort() self.sofVariants.insert(0, ('None', -1)) self.sofPatterns = [] for i in xrange(len(sofDB.pattern)): self.sofPatterns.append((sofDB.pattern[i].name, i)) self.sofPatterns.sort() self.sofPatterns.insert(0, ('None', -1)) headerCont = Container(name='headerCont', parent=main, align=uiconst.TOTOP, height=30) gridCont = GridContainer(name='mainCont', parent=main, align=uiconst.TOBOTTOM, height=250, lines=5, columns=3) buttonConts = {} for y in xrange(gridCont.lines): for x in xrange(gridCont.columns): buttonConts[x, y] = Container(parent=gridCont) self.dnaLabel = EveLabelSmall(name='dnaLabel', align=uiconst.CENTER, parent=headerCont, text='') self.copyDnaButton = Button(name='copy_dna_button', align=uiconst.CENTER, parent=buttonConts[(0, 4)], label='Copy DNA', func=self._OnCopyDnaButton) self.applyButton = Button(name='apply_button', align=uiconst.CENTER, parent=buttonConts[(1, 4)], label='Apply', func=self._OnApplyButton) patternParent = Container(name='patternParent', parent=buttonConts[(0, 3)], align=uiconst.CENTER, height=18, width=175) self.patternCombo = Combo(name='pattern_combo', align=uiconst.TOLEFT, width=150, parent=patternParent, label='Pattern:', options=self.sofPatterns, callback=self.OnPatternComboChange, select=self.GetComboListIndex( self.sofPatterns, self.currentPattern)) factionParent = Container(name='factionParent', parent=buttonConts[(0, 2)], align=uiconst.CENTER, height=18, width=175) self.factionCombo = Combo(name='faction_combo', align=uiconst.TOLEFT, width=150, parent=factionParent, label='Faction:', options=self.sofFactions, callback=self.OnFactionComboChange, select=self.GetComboListIndex( self.sofFactions, self.currentFaction)) self.factionConstraint = Checkbox( name='faction_constraint', align=uiconst.TOLEFT, width=75, padLeft=10, parent=factionParent, text='Constrained', callback=self.OnFactionConstraintChanged) hullParent = Container(name='hullParent', parent=buttonConts[(0, 1)], align=uiconst.CENTER, height=18, width=175) self.hullCombo = Combo(name='hull_combo', align=uiconst.TOLEFT, width=150, parent=hullParent, label='Hull:', options=self.sofHulls, callback=self.OnHullComboChange, select=self.GetComboListIndex( self.sofHulls, self.currentHull)) self.hullConstraint = Checkbox(name='hull_constraint', align=uiconst.TOLEFT, width=75, padLeft=10, parent=hullParent, text='Constrained', callback=self.OnHullConstraintChanged) raceParent = Container(name='raceParent', parent=buttonConts[(0, 0)], align=uiconst.CENTER, height=18, width=175) self.raceCombo = Combo(name='race_combo', align=uiconst.TOLEFT, width=150, parent=raceParent, label='Race:', options=self.sofRaces, callback=self.OnRaceComboChange, select=self.GetComboListIndex( self.sofRaces, self.currentRace)) self.raceConstraint = Checkbox(name='race_constraint', align=uiconst.TOLEFT, width=75, padLeft=10, parent=raceParent, text='Constrained', callback=self.OnRaceConstraintChanged) self.matCombo1 = Combo(name='material_combo1', align=uiconst.CENTER, width=150, parent=buttonConts[(1, 0)], label='Material 1:', options=self.sofMaterials, callback=self.OnMat1ComboChange, select=self.GetComboListIndex( self.sofMaterials, self.currentMat[0])) self.matCombo2 = Combo(name='material_combo2', align=uiconst.CENTER, width=150, parent=buttonConts[(1, 1)], label='Material 2:', options=self.sofMaterials, callback=self.OnMat2ComboChange, select=self.GetComboListIndex( self.sofMaterials, self.currentMat[1])) self.matCombo3 = Combo(name='material_combo3', align=uiconst.CENTER, width=150, parent=buttonConts[(1, 2)], label='Material 3:', options=self.sofMaterials, callback=self.OnMat3ComboChange, select=self.GetComboListIndex( self.sofMaterials, self.currentMat[2])) self.matCombo4 = Combo(name='material_combo4', align=uiconst.CENTER, width=150, parent=buttonConts[(1, 3)], label='Material 4:', options=self.sofMaterials, callback=self.OnMat4ComboChange, select=self.GetComboListIndex( self.sofMaterials, self.currentMat[3])) self.dirtSlider = Slider(name='dirt_slider', align=uiconst.CENTER, label='Dirt', parent=buttonConts[(2, 0)], width=200, minValue=0.0, maxValue=100.0, startVal=50.0, setlabelfunc=self.UpdateDirtSliderLabel, onsetvaluefunc=self.OnDirtSliderChange, endsliderfunc=self.OnDirtSliderChange) materialSetIdContainer = Container(name='materialSetContainer', parent=buttonConts[(2, 1)], align=uiconst.CENTER, height=18, width=175) self.materialSetIDCombo = Combo(name='materialsetid_edit', align=uiconst.TOLEFT, label='Masterial Set ID', parent=materialSetIdContainer, options=[], callback=self.OnMaterialSetIDChange) self._FilterMaterialSet(False) self.materialSetFilteredByRace = Checkbox( name='materialSetFilter', align=uiconst.TOLEFT, width=150, padLeft=10, parent=materialSetIdContainer, text='Filter By Race', callback=self.OnMaterialSetFiltered) self.resPathInsertEdit = SinglelineEdit( name='respathinsert_edit', align=uiconst.CENTER, label='resPathInsert', parent=buttonConts[(2, 2)], width=100, setvalue='', OnFocusLost=self.OnResPathInsertChange, OnReturn=self.OnResPathInsertChange) self.variantCombo = Combo(name='variant_combo', align=uiconst.CENTER, width=150, parent=buttonConts[(2, 3)], label='Variants:', options=self.sofVariants, callback=self.OnVariantComboChange, select=self.GetComboListIndex( self.sofVariants, self.currentVariant)) self.previewCont = PreviewContainer(parent=main, align=uiconst.TOALL) self.previewCont.PreviewSofDna(self.GetPreviewDna()) def GetComboListIndex(self, comboContentList, name): for each in comboContentList: if each[0].lower() == name.lower(): return each[1] def GetPreviewDna(self): dna = self.currentHull + ':' + self.currentFaction + ':' + self.currentRace if any((x != 'None' for x in self.currentMat)): dna += ':mesh?' + str(self.currentMat[0]) + ';' + str( self.currentMat[1]) + ';' + str( self.currentMat[2]) + ';' + str(self.currentMat[3]) if self.currentResPathInsert is not None: dna += ':respathinsert?' + str(self.currentResPathInsert) if self.currentVariant != 'None': dna += ':variant?' + str(self.currentVariant) if self.currentPattern != 'None': dna += ':pattern?' + str(self.currentPattern) self.dnaLabel.text = dna return dna def GetDnaFromPlayerShip(self): michelle = sm.GetService('michelle') ship = michelle.GetBall(session.shipid) if ship is None: return 'ab1_t1:amarrbase:amarr' dna = ship.GetDNA() if dna is None: return 'ab1_t1:amarrbase:amarr' return dna def UpdateDirtSliderLabel(self, label, sliderID, displayName, value): dirtLevel = gfxutils.RemapDirtLevel(value) label.text = 'Dirt level: ' + str(dirtLevel) def OnDirtSliderChange(self, slider): self.currentDirtLevel = gfxutils.RemapDirtLevel(slider.GetValue()) self._UpdatePreviewShip() def OnFactionConstraintChanged(self, checkbox): self.constrainToFaction = checkbox.GetValue() self.ConstrainDnaSelection() def OnRaceConstraintChanged(self, checkbox): self.constrainToRace = checkbox.GetValue() self.ConstrainDnaSelection() def OnHullConstraintChanged(self, checkbox): self.constrainToHull = checkbox.GetValue() self.ConstrainDnaSelection() def OnMaterialSetFiltered(self, checkbox): materialSetFiltered = checkbox.GetValue() self._FilterMaterialSet(materialSetFiltered) def _FilterMaterialSet(self, filterByRace): materialSets = cfg.graphicMaterialSets availableMaterialSets = [] for materialSetID, materialSet in materialSets.iteritems(): if filterByRace: if hasattr( materialSet, 'sofRaceHint' ) and materialSet.sofRaceHint == self.raceCombo.GetKey(): availableMaterialSets.append(materialSetID) else: availableMaterialSets.append(materialSetID) availableMaterialSets.sort() self.TrySettingComboOptions(self.materialSetIDCombo, [('None', -1)] + [(str(key), key) for key in availableMaterialSets], -1) def ConstrainDnaSelection(self): raceQuery = '.*' factionQuery = '.*' hullQuery = '.*' if self.constrainToFaction: factionQuery = self.factionCombo.GetKey() if self.constrainToHull: hullQuery = self.hullCombo.GetKey() if self.constrainToRace: raceQuery = self.raceCombo.GetKey() if not self.constrainToFaction and not self.constrainToHull and not self.constrainToRace: self.currentFaction = self.TrySettingComboOptions( self.factionCombo, self.sofFactions, self.GetDefaultFactionForHull()) self.currentRace = self.TrySettingComboOptions( self.raceCombo, self.sofRaces, self.currentRace) self.currentHull = self.TrySettingComboOptions( self.hullCombo, self.sofHulls, self.currentHull) else: dnaList = GetDnaStringMatchingQuery(hullQuery, factionQuery, raceQuery) selectableRaces = [] selectableFactions = [] selectableHulls = [] for dna in dnaList: dnaElements = dna.split(':') hull = dnaElements[0] faction = dnaElements[1] race = dnaElements[2] if faction not in selectableFactions: selectableFactions.append(faction) if race not in selectableRaces: selectableRaces.append(race) if hull not in selectableHulls: selectableHulls.append(hull) if not self.constrainToHull: selectableHulls.sort() hullOptions = [(hullName, i) for i, hullName in enumerate(selectableHulls)] self.currentHull = self.TrySettingComboOptions( self.hullCombo, hullOptions, self.currentHull) if not self.constrainToFaction: selectableFactions.sort() options = [(factionName, i) for i, factionName in enumerate(selectableFactions)] self.currentFaction = self.TrySettingComboOptions( self.factionCombo, options, self.GetDefaultFactionForHull()) if not self.constrainToRace: selectableRaces.sort() raceOptions = [(raceName, i) for i, raceName in enumerate(selectableRaces)] self.currentRace = self.TrySettingComboOptions( self.raceCombo, raceOptions, self.currentRace) self._UpdatePreviewShip() def GetDefaultFactionForHull(self): if self.currentHull.endswith('t2'): return self._GetDefaultFactionForT2Hull(self.currentHull) else: return self._GetDefaultFactionForT1Hull(self.currentHull) @staticmethod def _GetDefaultFactionForT1Hull(hullName): dnaList = GetDnaStringMatchingQuery(hullName) if len(dnaList) == 0: return '' _, __, race = dnaList[0].split(':') return race + 'base' @staticmethod def _GetDefaultFactionForT2Hull(hullName): for factionName, hullList in DEFAULT_FACTION_FOR_T2HULLS.iteritems(): if hullName in hullList: return factionName return '' def TrySettingComboOptions(self, comboBox, options, selectedValue): comboBox.LoadOptions(options) return self.TrySettingComboValue(comboBox, selectedValue) def TrySettingComboValue(self, comboBox, selectedValue): try: comboBox.SelectItemByLabel(selectedValue) except RuntimeError: comboBox.SelectItemByIndex(0) print "Could not select '%s', defaulting to '%s'" % ( selectedValue, comboBox.GetKey()) return comboBox.GetKey() def OnPatternComboChange(self, comboBox, pattern, value): self.currentPattern = pattern self._UpdatePreviewShip() def OnFactionComboChange(self, comboBox, faction, value): self.currentFaction = faction if self.constrainToFaction: self.ConstrainDnaSelection() self._UpdatePreviewShip() def OnHullComboChange(self, comboBox, hull, value): self.currentHull = hull if self.constrainToHull: self.ConstrainDnaSelection() self._UpdatePreviewShip() def OnRaceComboChange(self, comboBox, race, value): self.currentRace = race if self.constrainToRace: self.ConstrainDnaSelection() self._UpdatePreviewShip() def OnMat1ComboChange(self, comboBox, material, value): self.currentMat[0] = material self._UpdatePreviewShip() def OnMat2ComboChange(self, comboBox, material, value): self.currentMat[1] = material self._UpdatePreviewShip() def OnMat3ComboChange(self, comboBox, material, value): self.currentMat[2] = material self._UpdatePreviewShip() def OnMat4ComboChange(self, comboBox, material, value): self.currentMat[3] = material self._UpdatePreviewShip() def OnVariantComboChange(self, comboBox, variant, value): self.currentVariant = variant self._UpdatePreviewShip() def OnMaterialSetIDChange(self, *args): materialComboKey = self.materialSetIDCombo.GetKey() if materialComboKey == 'None': materialComboKey = -1 materialSetID = int(materialComboKey) print 'trying to find materialset for ' + str(materialSetID) materialSet = cfg.graphicMaterialSets.GetIfExists(materialSetID) if hasattr(materialSet, 'sofFactionName'): idx = self.GetComboListIndex(self.sofFactions, materialSet.sofFactionName) self.factionCombo.SelectItemByValue(idx) self.OnFactionComboChange(self.factionCombo, materialSet.sofFactionName, idx) material1 = getattr(materialSet, 'material1', 'None') idx = self.GetComboListIndex(self.sofMaterials, material1) self.matCombo1.SelectItemByValue(idx) self.OnMat1ComboChange(self.matCombo1, material1, idx) material2 = getattr(materialSet, 'material2', 'None') idx = self.GetComboListIndex(self.sofMaterials, material2) self.matCombo2.SelectItemByValue(idx) self.OnMat2ComboChange(self.matCombo2, material2, idx) material3 = getattr(materialSet, 'material3', 'None') idx = self.GetComboListIndex(self.sofMaterials, material3) self.matCombo3.SelectItemByValue(idx) self.OnMat3ComboChange(self.matCombo3, material3, idx) material4 = getattr(materialSet, 'material4', 'None') idx = self.GetComboListIndex(self.sofMaterials, material4) self.matCombo4.SelectItemByValue(idx) self.OnMat4ComboChange(self.matCombo4, material4, idx) self.resPathInsertEdit.SetValue( getattr(materialSet, 'resPathInsert', '')) self.OnResPathInsertChange() sofPatternName = getattr(materialSet, 'sofPatterName', 'None') idx = self.GetComboListIndex(self.sofPatterns, sofPatternName) self.patternCombo.SelectItemByValue(idx) self.OnPatternComboChange(self.patternCombo, sofPatternName, idx) def OnResPathInsertChange(self, *args): resPathInsert = self.resPathInsertEdit.GetValue() print 'new respathinsert: ' + resPathInsert if len(resPathInsert) == 0: self.currentResPathInsert = None else: self.currentResPathInsert = resPathInsert self._UpdatePreviewShip() def _UpdatePreviewShip(self): if self.previewCont is not None: self.previewCont.PreviewSofDna(self.GetPreviewDna(), dirt=self.currentDirtLevel) def _UpdatePlayerShip(self): michelle = sm.GetService('michelle') ship = michelle.GetBall(session.shipid) if ship is None: return ship.UnfitHardpoints() ship.Release() while ship.model is not None: blue.synchro.Yield() ship.released = False ship.GetDNA = self.GetPreviewDna ship.LoadModel() ship.Assemble() if self.currentDirtLevel is not None: ship.model.dirtLevel = self.currentDirtLevel
def ShowUI(self): self.explosionBucketsUsedWhenWindowOpened = SpaceObjectExplosionManager.USE_EXPLOSION_BUCKETS wnd = uicontrols.Window.Open(windowID=self.windowID) wnd.SetTopparentHeight(0) wnd.SetMinSize([500, 250]) wnd.SetCaption(self.name) wnd._OnClose = self._OnClose main = wnd.GetMainArea() bottomCont = Container(name='bottomCont', parent=main, align=uiconst.TOBOTTOM, height=30, width=50, padBottom=10) explosionSelectionContainer = Container(name='explosionSelectionCont', parent=main, align=uiconst.TOBOTTOM, height=30, padTop=10, padBottom=10) explosionContainer = Container(name='explosionContainer', parent=main, align=uiconst.TOALL, padBottom=10) self.scroll = uicontrols.Scroll(parent=explosionContainer) self.scroll.sr.id = 'explosionDebugScroll' self.scroll.OnSelectionChange = self.OnSelectionChange self.explosionCombo = Combo(name='myCombo', parent=explosionSelectionContainer, label='Set explosion to selected items', options=[('Random', None)], callback=self.OnExplosionSelected, align=uiconst.TOTOP, padRight=12, padLeft=12) buttonGrid = GridContainer(name='buttonGrid', parent=bottomCont, align=uiconst.CENTER, width=150, height=20, lines=1, columns=3) ButtonIcon( name='Play', parent=buttonGrid, align=uiconst.TORIGHT, width=20, height=20, iconSize=24, padRight=15, texturePath='res:/UI/Texture/Icons/play.png', func=self.Explode, hint='Play Explosions (the exploding ships will not survive)') ButtonIcon(name='Refresh', parent=buttonGrid, align=uiconst.CENTER, width=20, height=20, iconSize=24, texturePath='res:/UI/Texture/Icons/replay.png', func=self.UpdateTable, hint='Update table') ButtonIcon(name='ClearWrecks', parent=buttonGrid, align=uiconst.TOLEFT, width=20, height=20, iconSize=32, padLeft=15, texturePath='res:/UI/Texture/Icons/44_32_37.png', func=self.ClearWrecks, hint='Clear wrecks') self.UpdateTable()
def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.SetWndIcon('res:/ui/Texture/WindowIcons/Settings.png', mainTop=-6) self.SetMainIconSize(64) self.width = 350 self.height = 400 self.MakeUnResizeable() self.currentComboValue = localization.settings.bilingualSettings.GetValue( 'localizationImportantNames') WndCaptionLabel( text=GetByLabel('UI/LanguageWindow/BilingualFunctionalityHeader'), parent=self.sr.topParent, align=uiconst.RELATIVE) self.autoSizeMain = ContainerAutoSize( parent=self.sr.main, name='autoSizeMain', align=uiconst.TOTOP, callback=self.OnAutoSizeMainResize, padLeft=2, padRight=2) text = GetByLabel('UI/LanguageWindow/BodyText') EveLabelMedium(text=text, parent=self.autoSizeMain, align=uiconst.TOTOP, padding=(10, 4, 10, 0)) self.btnGroup = ButtonGroup(parent=self.sr.main, idx=0) self.btnGroup.AddButton(GetByLabel('UI/Commands/Apply'), self.Save) self.btnGroup.AddButton(GetByLabel('UI/Common/Close'), self.Cancel) grid = LayoutGrid(parent=self.autoSizeMain, align=uiconst.TOTOP, columns=2, name='grid', padTop=10, padLeft=20, cellSpacing=4) languageID = ConvertLanguageIDToMLS(session.languageID) self.currentLanguageString = GetByLabel( mlsToDisplayNamePaths[languageID]) text = GetByLabel('UI/SystemMenu/Language/Display') comboLabel = EveLabelMedium(text=text, parent=grid, align=uiconst.TOPLEFT, state=uiconst.UI_NORMAL) comboLabel.hint = GetByLabel( 'UI/SystemMenu/Language/ImportantNamesExplanation') options = [(self.currentLanguageString, 0), (GetByLabel('UI/SystemMenu/Language/EnglishReplacement'), IMPORTANT_EN_OVERRIDE)] self.displayCombo = Combo( label='', parent=grid, options=options, name='displayCombo', select=self.currentComboValue, width=115, pos=(10, 0, 0, 0), align=uiconst.TOPLEFT, callback=self.OnComboChanged, hint=GetByLabel( 'UI/SystemMenu/Language/ImportantNamesExplanation')) tooltipText = self.GetTooltipCheckboxText() checked = localization.settings.bilingualSettings.GetValue( 'languageTooltip') self.tooltipCB = Checkbox(text=tooltipText, parent=None, configName='tooltipsCB', checked=checked, align=uiconst.TOPLEFT, width=300) grid.AddCell(cellObject=self.tooltipCB, colSpan=grid.columns) hiliteImportantText = GetByLabel( 'UI/SystemMenu/Language/HighlightImportantNames') checked = localization.settings.bilingualSettings.GetValue( 'localizationHighlightImportant') self.importantCB = Checkbox(text=hiliteImportantText, parent=None, configName='importantNamesCB', checked=checked, align=uiconst.TOPLEFT, width=300) grid.AddCell(cellObject=self.importantCB, colSpan=grid.columns) text = localization.GetByLabel('UI/LanguageWindow/ChangeSettingsInEsc') EveLabelMedium(text=text, parent=self.autoSizeMain, align=uiconst.TOTOP, padding=(10, 10, 10, 0)) Line(parent=self.autoSizeMain, align=uiconst.TOTOP, color=(1, 1, 1, 0.1), padTop=4, padBottom=2) text = GetByLabel('UI/Messages/TxtSuppress2Body') self.suppressCb = Checkbox(text=text, parent=self.autoSizeMain, configName='importantNamesCB', retval=0, checked=0, align=uiconst.TOTOP, padLeft=6)
class WindowManager(Window): __guid__ = 'form.WindowManager' default_windowID = 'WindowManager' def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.SetWndIcon(None) self.SetCaption('Window manager') self.SetTopparentHeight(10) self.SetMinSize([360, 220]) options = [] for wndCls in Window.__subclasses__(): options.append((wndCls.__name__, wndCls)) options.sort() topCont = Container(name='params', parent=self.sr.main, align=uiconst.TOTOP, pad=(5, 5, 5, 5), pos=(0, 10, 0, 30)) self.mainCont = Container(name='params', parent=self.sr.main, align=uiconst.TOTOP, pos=(0, 0, 0, 50), padding=(5, 15, 5, 5)) self.extrasCont = Container(name='params', parent=self.sr.main, align=uiconst.TOALL, padding=(5, 15, 5, 5)) self.combo = Combo(parent=topCont, label='Select window', options=options, name='', select=settings.user.ui.Get('windowManagerOpenWindow'), callback=self.OnComboChanged, pos=(5, 0, 0, 0), width=150, align=uiconst.TOPLEFT) self.startupArgs = SinglelineEdit(name='', label='attributes', parent=topCont, setvalue='', align=uiconst.TOPLEFT, left=165, width=100) Button(parent=topCont, label='Load', align=uiconst.RELATIVE, func=self.OpenWindow, pos=(300, 0, 0, 0)) self.filenameEdit = SinglelineEdit(name='', label='Location', parent=self.mainCont, setvalue='', align=uiconst.TOTOP, top=15, readonly=True) Label(text='RELOAD', parent=self.extrasCont, top=10, state=uiconst.UI_NORMAL) Line(parent=self.extrasCont, align=uiconst.TOTOP) buttonCont = Container(name='buttonCont', parent=self.extrasCont, align=uiconst.TOTOP, pos=(0, 30, 0, 30)) Button(parent=buttonCont, label='ShipUI', align=uiconst.TOLEFT, func=self.ReloadShipUI) Button(parent=buttonCont, label='NEOCOM', align=uiconst.TOLEFT, func=self.ReloadNeocom, padLeft=1) Button(parent=buttonCont, label='Info Panels', align=uiconst.TOLEFT, func=self.ReloadInfoPanels, padLeft=1) Button(parent=buttonCont, label='Lobby', align=uiconst.TOLEFT, func=self.ReloadLobby, padLeft=1) Button(parent=buttonCont, label='Overview', align=uiconst.TOLEFT, func=self.ReloadOverview, padLeft=1) Button(parent=buttonCont, label='Mapbrowser', align=uiconst.TOLEFT, func=self.ReloadMapBrowser, padLeft=1) self.UpdateInfo(self.combo.GetKey(), self.combo.GetValue()) def OnComboChanged(self, combo, key, wndCls): self.UpdateInfo(key, wndCls) def UpdateInfo(self, key, wndCls): self.filenameEdit.SetValue(wndCls.ApplyAttributes.func_code.co_filename) settings.user.ui.Set('windowManagerOpenWindow', wndCls) def OpenWindow(self, *args): windowClass = self.combo.GetValue() windowClass.CloseIfOpen() attributes = {} try: attributesStr = self.startupArgs.GetValue() if attributesStr: for s in attributesStr.split(','): keyword, value = s.split('=') keyword = keyword.strip() value = value.strip() try: if value.find('.') != -1: value = float(value) else: value = int(value) except ValueError: pass if value == 'None': value = None attributes[keyword] = value except: eve.Message('CustomInfo', {'info': 'attributes must be on the form: attr1=1, attr2=Some random text'}) raise windowClass.Open(**attributes) def ReloadShipUI(self, *args): if eve.session.stationid is None: uicore.layer.shipui.CloseView() uicore.layer.shipui.OpenView() def ReloadNeocom(self, *args): sm.GetService('neocom').Reload() def ReloadInfoPanels(self, *args): sm.GetService('infoPanel').Reload() def ReloadLobby(self, *args): if session.stationid or session.structureid: from eve.client.script.ui.shared.dockedUI import ReloadLobbyWnd ReloadLobbyWnd() def ReloadMapBrowser(self, *args): MapBrowserWnd.CloseIfOpen() uicore.cmd.OpenMapBrowser() def ReloadOverview(self, *args): OverView.CloseIfOpen() if session.solarsystemid: sm.GetService('tactical').InitOverview() ActiveItem.CloseIfOpen() if session.solarsystemid: sm.GetService('tactical').InitSelectedItem() DroneView.CloseIfOpen() if session.solarsystemid: sm.GetService('tactical').InitDrones()
class FormAlliancesSovereignty(Container): def CreateWindow(self): self.primeTimeInfo = None topCont = Container(parent=self, height=24, align=uiconst.TOTOP, padding=const.defaultPadding) FillThemeColored(parent=topCont, colorType=uiconst.COLORTYPE_UIHEADER, opacity=0.15) EveLabelSmall( parent=topCont, text=GetByLabel('UI/Sovereignty/DefaultVulnerabilityTimeLabel'), align=uiconst.CENTERLEFT, left=const.defaultPadding) menuCont = Container(parent=topCont, align=uiconst.TORIGHT, width=18) self.primeTimeMenu = UtilMenu(parent=menuCont, align=uiconst.CENTERRIGHT, menuAlign=uiconst.TOPRIGHT, GetUtilMenu=self.PrimeTimeMenu) menuCont.display = False execCorpID = sm.GetService('alliance').GetAlliance( session.allianceid).executorCorpID timeTextLeft = const.defaultPadding if self._IsDirectorInExecCorp(execCorpID): timeTextLeft = 18 menuCont.display = True self.timeLabel = EveLabelSmall(parent=topCont, align=uiconst.CENTERRIGHT, left=timeTextLeft) uthread.new(self.UpdatePrimeInfo) self.sovDashBoard = SovDashboard(parent=self) self.sovDashBoard.CreateWindow() def UpdatePrimeInfo(self): self.primeTimeInfo = sm.GetService('alliance').GetPrimeTimeInfo() self.UpdateText() def UpdateText(self): if self.primeTimeInfo is None or self.primeTimeInfo.currentPrimeHour is None: text = GetByLabel('UI/Common/Unknown') else: newPrimeHour = self.primeTimeInfo.newPrimeHour validAfter = self.primeTimeInfo.newPrimeHourValidAfter now = blue.os.GetWallclockTime() if newPrimeHour is not None and now < validAfter: text = GetByLabel( 'UI/Sovereignty/VulnerabilityTimeWithFutureChange', hour=self.primeTimeInfo.currentPrimeHour, newHour=self.primeTimeInfo.newPrimeHour, validAfterDate=self.primeTimeInfo.newPrimeHourValidAfter) else: currentPrimeHour = self.GetCurrentPrimeHour() text = GetByLabel('UI/Sovereignty/VulnerabilityTime', hour=currentPrimeHour) self.timeLabel.SetText(text) def PrimeTimeMenu(self, menuParent): headerCont = menuParent.AddContainer(align=uiconst.TOTOP, height=20, padding=const.defaultPadding) EveLabelLargeBold(parent=headerCont, text=GetByLabel('UI/Sovereignty/SetSovereigntyHour'), align=uiconst.TOTOP) menuParent.AddSpace(height=10) text = menuParent.AddText( GetByLabel('UI/Sovereignty/SetNewVulnerabilityTimeDescription')) text.GetEntryWidth = lambda mc=text: 250 cont = menuParent.AddContainer(align=uiconst.TOTOP, height=60, padding=const.defaultPadding) myCont = Container(name='myCont', parent=cont, align=uiconst.TOTOP, height=22, padTop=10) currentPrimeHour = self.GetCurrentPrimeHour() self.primeTimeCombo = Combo(name='primeTimeCombo', parent=myCont, options=self.GetTimeComboOptions(), select=currentPrimeHour, width=150) setBtn = Button(name='SetPrimeTimeBtn', align=uiconst.TOPRIGHT, parent=myCont, label=GetByLabel('UI/Common/CommandSet'), func=self.SetPrimeTime) def SetPrimeTime(self, *args): primeTimeNewValue = self.primeTimeCombo.GetValue() if self.primeTimeInfo and self.primeTimeInfo.newPrimeHour: newPrimeHour = self.primeTimeInfo.newPrimeHour validAfter = self.primeTimeInfo.newPrimeHourValidAfter newerPrimeHour = blue.os.GetWallclockTime( ) + CHANGE_PRIMETIME_DELAY if eve.Message( 'updateNewPrimeTime', { 'currentPendingTime': '%s:00' % newPrimeHour, 'currentPendingDate': FmtDate(validAfter, 'ss'), 'newPendingTime': '%s:00' % primeTimeNewValue, 'newPendingDate': FmtDate(newerPrimeHour, 'ss') }, uiconst.YESNO) != uiconst.ID_YES: return sm.GetService('alliance').SetPrimeHour(primeTimeNewValue) self.UpdatePrimeInfo() self.primeTimeMenu.CloseMenu() def GetTimeComboOptions(self): return [(GetByLabel('UI/Sovereignty/VulnerabilityTime', hour=i), i) for i in xrange(24)] def GetCurrentPrimeHour(self): currentPrimeHour = 0 if self.primeTimeInfo and self.primeTimeInfo.currentPrimeHour is not None: currentPrimeHour = self.primeTimeInfo.currentPrimeHour return currentPrimeHour def _IsDirectorInExecCorp(self, executorCorpID): if session.allianceid is None: return False if IsNPC(session.corpid): return False if session.corpid != executorCorpID: return False if corpRoleDirector & session.corprole != corpRoleDirector: return False return True