def OnRouteEntryClick(self, *args): if not self or self.destroyed: return selectedRoutes = self.routeScroll.GetSelected() if len(selectedRoutes) < 1: self.routeInfo.state = uiconst.UI_HIDDEN self.showRoutesCont.height = 168 self.ResizeActionCont(self.showRoutesCont.height) return selectedRouteData = selectedRoutes[0] selectedRouteID = None for routeID in self.pin.link.routesTransiting: if routeID == selectedRouteData.routeID: selectedRouteID = routeID break if selectedRouteID is None: return colony = sm.GetService('planetUI').GetCurrentPlanet().GetColony( self.pin.link.endpoint1.ownerID) selectedRoute = colony.GetRoute(selectedRouteID) if selectedRoute is None: return sourcePin = colony.GetPin(selectedRoute.GetSourcePinID()) self.routeInfoSource.SetSubtext( planetCommon.GetGenericPinName(sourcePin.typeID, sourcePin.id)) destPin = colony.GetPin(selectedRoute.GetDestinationPinID()) self.routeInfoDest.SetSubtext( planetCommon.GetGenericPinName(destPin.typeID, destPin.id)) routeTypeID = selectedRoute.GetType() routeQty = selectedRoute.GetQuantity() self.routeInfoType.SetSubtext( localization.GetByLabel( 'UI/PI/Common/ItemAmount', itemName=cfg.invtypes.Get(routeTypeID).name, amount=int(routeQty))) bandwidthAttr = cfg.dgmattribs.Get(const.attributeLogisticalCapacity) self.routeInfoBandwidth.SetSubtext( localization.GetByLabel('UI/PI/Common/CapacityAmount', amount=selectedRoute.GetBandwidthUsage())) self.routeInfo.opacity = 0.0 self.routeInfo.state = uiconst.UI_PICKCHILDREN self.showRoutesCont.height = 168 + self.routeInfo.height self.ResizeActionCont(self.showRoutesCont.height) self.uiEffects.MorphUI(self.routeInfo, 'opacity', 1.0, time=125.0, float=1, newthread=0, maxSteps=1000)
def LoadDestComboOptions(self): colony = self.planet.GetColony(session.charid) if colony is None: self.sr.spaceportCombo.LoadOptions([ (localization.GetByLabel('UI/PI/Common/NoDestinationsFound'), None) ]) return self.endpoints = colony.GetImportEndpoints() if len(self.endpoints) < 1: self.sr.spaceportCombo.LoadOptions([ (localization.GetByLabel('UI/PI/Common/NoDestinationsFound'), None) ]) return options = [] for endpoint in self.endpoints: pin = self.planet.GetPin(endpoint.id) options.append( (planetCommon.GetGenericPinName(pin.typeID, pin.id), endpoint.id)) if self.spaceportPinID is None: self.spaceportPinID = options[0][1] self.sr.spaceportCombo.LoadOptions(options, select=self.spaceportPinID)
def LoadLinkScroll(self): scrolllist = [] planet = sm.GetService('planetUI').GetCurrentPlanet() colony = planet.GetColony(session.charid) links = colony.colonyData.GetLinksForPin(self.pin.id) for linkedPinID in links: link = colony.GetLink(self.pin.id, linkedPinID) linkedPin = colony.GetPin(linkedPinID) distance = link.GetDistance() bandwidthUsed = link.GetBandwidthUsage() percentageUsed = 100 * (bandwidthUsed / link.GetTotalBandwidth()) data = util.KeyVal() data.label = '%s<t>%s<t>%s' % (planetCommon.GetGenericPinName( linkedPin.typeID, linkedPin.id), util.FmtDist(distance), localization.GetByLabel( 'UI/Common/Percentage', percentage=percentageUsed)) data.hint = '' data.OnMouseEnter = self.OnLinkEntryHover data.OnMouseExit = self.OnLinkEntryExit data.OnDblClick = self.OnLinkListentryDblClicked data.id = (link.endpoint1.id, link.endpoint2.id) sortBy = linkedPinID scrolllist.append((sortBy, listentry.Get('Generic', data=data))) scrolllist = uiutil.SortListOfTuples(scrolllist) self.linkScroll.Load( contentList=scrolllist, noContentHint=localization.GetByLabel( 'UI/PI/Common/NoLinksPresent'), headers=[ localization.GetByLabel('UI/PI/Common/Destination'), localization.GetByLabel('UI/Common/Distance'), localization.GetByLabel('UI/PI/Common/CapacityUsed') ])
def ApplyAttributes(self, attributes): uicls.Window.ApplyAttributes(self, attributes) self.planet = attributes.planet self.path = attributes.path if not self.path or len(self.path) < 2: raise UserError('CreateRouteTooShort') colony = self.planet.GetColony(session.charid) self.sourcePin = colony.GetPin(self.path[0]) self.destinationPin = None minBandwidth = None prevID = None pin = None for pinID in self.path: pin = colony.GetPin(pinID) if not pin: raise UserError('RouteFailedValidationPinDoesNotExist') if prevID is None: prevID = pinID continue link = colony.GetLink(pin.id, prevID) if link is None: raise UserError('RouteFailedValidationLinkDoesNotExist') if minBandwidth is None or minBandwidth > link.GetTotalBandwidth(): minBandwidth = link.GetTotalBandwidth() prevID = pinID self.availableBandwidth = minBandwidth sourceName = planetCommon.GetGenericPinName(self.sourcePin.typeID, self.sourcePin.id) self.SetCaption( localization.GetByLabel('UI/PI/Common/ExpeditedTransferFrom', sourceName=sourceName)) self.SetMinSize([500, 400]) self.SetWndIcon('ui_7_64_16') self.MakeUnstackable() uicls.WndCaptionLabel(text=localization.GetByLabel( 'UI/PI/Common/PreparingExpeditedTransferOrder'), subcaption=localization.GetByLabel( 'UI/PI/Common/ExpeditedTransferSubHeading'), parent=self.sr.topParent, align=uiconst.RELATIVE) self.ConstructLayout() self.SetSourcePinGaugeInfo() self.scope = 'station_inflight' self.ResetPinContents() self.SetDestination(colony.GetPin(self.path[-1])) self.OnResizeUpdate() self.updateTimer = base.AutoTimer(100, self.SetNextTransferText)
def UpdatePanelCreateRoute(self): if not self.currentRoute or len(self.currentRoute) < 2: destName = localization.GetByLabel( 'UI/PI/Common/NoDestinationSelected') self.routeMaxAmount = self.sourceMaxAmount self.currRouteCycleTime = self.pin.GetCycleTime() else: self.routeDestPin = sm.GetService( 'planetUI').GetCurrentPlanet().GetColony( session.charid).GetPin(self.currentRoute[-1]) isValid, invalidTxt, self.currRouteCycleTime = planetCommon.GetRouteValidationInfo( self.pin, self.routeDestPin, self.commodityToRoute) destName = planetCommon.GetGenericPinName(self.routeDestPin.typeID, self.routeDestPin.id) if not isValid: destName = localization.GetByLabel( 'UI/PI/Common/InvalidDestination', destName=destName, reason=invalidTxt) if not isValid: self.routeMaxAmount = 0 elif self.routeDestPin.IsProcessor( ) and self.commodityToRoute in self.routeDestPin.GetConsumables(): destMaxAmount = self.routeDestPin.GetConsumables().get( self.commodityToRoute) if self.pin.IsStorage(): self.routeMaxAmount = destMaxAmount else: self.routeMaxAmount = min(destMaxAmount, self.commoditySourceMaxAmount) else: self.routeMaxAmount = self.commoditySourceMaxAmount self.routeAmountEdit.SetText(self.routeMaxAmount) self.routeAmountEdit.IntMode(0, self.routeMaxAmount) self.routeAmountText.text = localization.GetByLabel( 'UI/PI/Common/RoutedPortion', maxAmount=self.routeMaxAmount) self.OnRouteAmountEditChanged(self.routeMaxAmount) self.routeDestText.SetSubtext(destName)
def ConstructLayout(self): pad = const.defaultPadding self.sr.footer = uicls.Container(name='footer', parent=self.sr.main, align=uiconst.TOBOTTOM, pos=(0, 0, 0, 25), padding=(pad, pad, pad, pad)) self.sr.cols = uicls.Container(name='col1', parent=self.sr.main, align=uiconst.TOALL) uicls.Line(parent=self.sr.cols, align=uiconst.TOTOP) uicls.Line(parent=self.sr.cols, align=uiconst.TOBOTTOM) self.sr.col1 = uicls.Container(name='col1', parent=self.sr.cols, align=uiconst.TOLEFT, padding=(pad, pad, pad, pad), clipChildren=True) self.sr.col2 = uicls.Container(name='col1', parent=self.sr.cols, align=uiconst.TOLEFT, padding=(pad, pad, pad, pad), clipChildren=True) uicls.Line(parent=self.sr.cols, align=uiconst.TOLEFT) self.sr.col3 = uicls.Container(name='col1', parent=self.sr.cols, align=uiconst.TOLEFT, padding=(pad, pad, pad, pad), clipChildren=True) colTopHeight = 60 self.sr.sourcePinHeader = uicls.Container(name='pinHeader', parent=self.sr.col1, align=uiconst.TOTOP, padding=(pad, 0, pad, pad), pos=(0, 0, 0, colTopHeight)) self.sr.sourcePinList = uicls.Container(name='pinList', parent=self.sr.col1, align=uiconst.TOALL, state=uiconst.UI_PICKCHILDREN) self.sr.transferHeader = uicls.Container(name='transferHeader', parent=self.sr.col2, align=uiconst.TOTOP, padding=(pad, 0, pad, pad), pos=(0, 0, 0, colTopHeight)) self.sr.transferList = uicls.Container(name='transferList', parent=self.sr.col2, align=uiconst.TOALL, state=uiconst.UI_PICKCHILDREN) self.sr.destPinHeader = uicls.Container(name='destPinHeader', parent=self.sr.col3, align=uiconst.TOTOP, padding=(pad, 0, pad, pad), pos=(0, 0, 0, colTopHeight)) self.sr.destPinList = uicls.Container(name='destPinList', parent=self.sr.col3, align=uiconst.TOALL, state=uiconst.UI_PICKCHILDREN) self.sr.footerLeft = uicls.Container(name='footerLeft', parent=self.sr.footer, align=uiconst.TOLEFT) self.sr.footerRight = uicls.Container(name='footerRight', parent=self.sr.footer, align=uiconst.TORIGHT) btns = [(localization.GetByLabel('UI/PI/Common/ExecuteTransfer'), self.GoForTransfer, (), None)] uicls.ButtonGroup(btns=btns, parent=self.sr.footerRight, line=0) self.sr.volumeText = uicls.EveLabelSmall(text='', parent=self.sr.transferHeader, left=0, top=20, state=uiconst.UI_NORMAL) self.sr.timeText = uicls.EveLabelSmall(text='', parent=self.sr.transferHeader, left=0, top=35, state=uiconst.UI_NORMAL) self.sr.timeText.hint = localization.GetByLabel( 'UI/PI/Common/ExpeditedTransferProcessingHint') self.sr.cooldownTimeText = uicls.EveLabelSmall( parent=self.sr.transferHeader, left=0, top=46) self.sr.cooldownTimeText.hint = localization.GetByLabel( 'UI/PI/Common/CoolDownTimeHint') btns = [(localization.GetByLabel('UI/PI/Common/Add'), self.AddBtnClicked, (), None), (localization.GetByLabel('UI/PI/Common/Remove'), self.RemoveBtnClicked, (), None)] btns = uicls.ButtonGroup(btns=btns, parent=self.sr.footerLeft, line=0) for b in btns.children[0].children: b.SetHint( localization.GetByLabel( 'UI/PI/Common/ExpeditedTransferSplitHint')) self.OnResizeUpdate() self.sr.sourcePinHeaderText = uicls.Label( text=planetCommon.GetGenericPinName(self.sourcePin.typeID, self.sourcePin.id), parent=self.sr.sourcePinHeader, align=uiconst.TOPLEFT, fontsize=16, left=0, state=uiconst.UI_NORMAL) self.sr.sourcePinSubGauge = uicls.Gauge( parent=self.sr.sourcePinHeader, value=0.0, color=planetCommon.PLANET_COLOR_STORAGE, label=localization.GetByLabel('UI/PI/Common/Capacity'), left=0, top=24, state=uiconst.UI_NORMAL) self.sr.sourcePinListScroll = uicls.Scroll( parent=self.sr.sourcePinList, name='pinList') content = self.sr.sourcePinListScroll.sr.content content.OnDropData = self.OnSourceScrollDropData self.sr.transferHeaderText = uicls.Label( text=localization.GetByLabel('UI/PI/Common/ToBeTransferred'), parent=self.sr.transferHeader, align=uiconst.TOPLEFT, fontsize=16, left=0, state=uiconst.UI_NORMAL) self.sr.transferListScroll = uicls.Scroll(parent=self.sr.transferList, name='transferList') content = self.sr.transferListScroll.sr.content content.OnDropData = self.OnTransferScrollDropData self.sr.destPinText = uicls.Label(text='', parent=self.sr.destPinHeader, align=uiconst.TOTOP, fontsize=16, state=uiconst.UI_NORMAL, maxLines=1) self.sr.destPinSubText = uicls.EveLabelLarge( text='', parent=self.sr.destPinHeader, align=uiconst.TOTOP, top=5, state=uiconst.UI_HIDDEN) self.sr.destPinSubGauge = uicls.Gauge( parent=self.sr.destPinHeader, value=0.0, color=planetCommon.PLANET_COLOR_STORAGE, label=localization.GetByLabel('UI/PI/Common/Capacity'), left=0, top=24, state=uiconst.UI_HIDDEN) self.sr.destPinListScroll = uicls.Scroll(parent=self.sr.destPinList)
def RefreshDestinationPinInfo(self): self.sr.destPinSubText.state = uiconst.UI_HIDDEN self.sr.destPinSubGauge.state = uiconst.UI_HIDDEN if not self.destPin: self.sr.destPinText.text = localization.GetByLabel( 'UI/PI/Common/NoOriginSelected') self.sr.destPinSubText.text = '' self.sr.destPinSubText.state = uiconst.UI_DISABLED self.sr.destPinListScroll.Load( contentList=[], noContentHint=localization.GetByLabel( 'UI/PI/Common/NoOriginSelected')) return self.sr.destPinText.text = localization.GetByLabel( 'UI/PI/Common/TransferDestinationName', typeName=planetCommon.GetGenericPinName(self.destPin.typeID, self.destPin.id)) scrollHeaders = [] scrollContents = [] scrollNoContentText = '' if self.destPin.IsConsumer(): self.sr.destPinSubText.state = uiconst.UI_DISABLED if self.destPin.schematicID is None: self.sr.destPinSubText.text = localization.GetByLabel( 'UI/PI/Common/NoSchematicInstalled') scrollNoContentText = localization.GetByLabel( 'UI/PI/Common/NoSchematicInstalled') else: self.sr.destPinSubText.text = localization.GetByLabel( 'UI/PI/Common/SchematicName', schematicName=cfg.schematics.Get( self.destPin.schematicID).schematicName) scrollHeaders = [] demands = self.destPin.GetConsumables() for typeID, qty in demands.iteritems(): remainingSpace = self.destPin.CanAccept(typeID, -1) scrollContents.append( listentry.Get( 'StatusBar', { 'label': cfg.invtypes.Get(typeID).name, 'status': qty - remainingSpace, 'total': qty })) elif self.destPin.IsStorage(): self.sr.destPinSubGauge.state = uiconst.UI_DISABLED self.sr.destPinSubGauge.SetText( localization.GetByLabel('UI/PI/Common/Capacity')) usageRatio = self.destPin.capacityUsed / self.destPin.GetCapacity() self.sr.destPinSubGauge.SetSubText( localization.GetByLabel('UI/PI/Common/CapacityProportionUsed', capacityUsed=self.destPin.capacityUsed, capacityMax=self.destPin.GetCapacity(), percentage=usageRatio * 100.0)) self.sr.destPinSubGauge.SetValue(usageRatio) scrollHeaders = [ localization.GetByLabel('UI/Common/Type'), localization.GetByLabel('UI/Common/Name'), localization.GetByLabel('UI/Common/Quantity') ] contents = self.destPin.GetContents() for typeID, qty in contents.iteritems(): lbl = '<t>%s<t>%d' % (cfg.invtypes.Get(typeID).name, qty) scrollContents.append( listentry.Get( 'DraggableItem', { 'itemID': None, 'typeID': typeID, 'label': lbl, 'getIcon': 1, 'quantity': qty })) scrollNoContentText = localization.GetByLabel( 'UI/PI/Common/StorehouseIsEmpty') self.sr.destPinListScroll.Load(contentList=scrollContents, headers=scrollHeaders, noContentHint=scrollNoContentText)
def GMInstallProgram(self, pinID): colony = self.GetColonyByPinID(pinID) if colony is None: raise RuntimeError('Unable to find colony for pinID') pin = colony.GetPin(pinID) resourceInfo = self.remoteHandler.GetPlanetResourceInfo() typeOptions = [(cfg.invtypes.Get(typeID).name, typeID) for typeID in resourceInfo.keys()] format = [{ 'type': 'combo', 'key': 'typeID', 'label': 'Type', 'options': typeOptions, 'frame': 0, 'labelwidth': 80 }, { 'type': 'edit', 'key': 'qtyPerCycle', 'label': 'Output per cycle', 'setvalue': '100', 'frame': 0, 'labelwidth': 140, 'required': True }, { 'type': 'btline' }, { 'type': 'edit', 'key': 'cycleTime', 'label': 'Cycle time (seconds)', 'setvalue': '60', 'frame': 0, 'labelwidth': 140, 'required': True }, { 'type': 'edit', 'key': 'lifetime', 'label': 'Lifetime (hours)', 'setvalue': '24', 'frame': 0, 'labelwidth': 140, 'required': True }] icon = 'ui_35_64_11' retval = uix.HybridWnd( format, 'Deposit designer: %s' % planetCommon.GetGenericPinName(pin.typeID, pin.id), 1, None, uiconst.OKCANCEL, minW=300, minH=132, icon=icon) if retval is None: return typeID, qtyPerCycle, cycleTime, lifetimeHours = (retval['typeID'], retval['qtyPerCycle'], retval['cycleTime'], retval['lifetime']) typeID = int(typeID) qtyPerCycle = int(qtyPerCycle) cycleTime = long(cycleTime) * SEC lifetimeHours = int(lifetimeHours) headRadius = 1.0 if typeID not in resourceInfo or qtyPerCycle < 0 or cycleTime < 10 * SEC or lifetimeHours < 1 or headRadius <= 0.0: return self.remoteHandler.GMForceInstallProgram(pinID, typeID, cycleTime, lifetimeHours, qtyPerCycle, headRadius)
def OnRouteEntryClick(self, *args): if not self or self.destroyed: return selectedRoutes = self.routeScroll.GetSelected() if len(selectedRoutes) < 1: self.routeInfo.state = uiconst.UI_HIDDEN self.showRoutesCont.height = 168 self.ResizeActionCont(self.showRoutesCont.height) return selectedRouteData = selectedRoutes[0] selectedRoute = None colony = self.planetUISvc.GetCurrentPlanet().GetColony(session.charid) links = colony.colonyData.GetLinksForPin(self.pin.id) for linkedPinID in links: link = colony.GetLink(self.pin.id, linkedPinID) for routeID in link.routesTransiting: if routeID == selectedRouteData.routeID: selectedRoute = route = colony.GetRoute(routeID) break if selectedRoute is None or selectedRoute.GetType( ) not in cfg.invtypes: return if selectedRoute.GetSourcePinID() == self.pin.id: self.routeInfoSource.SetSubtext( localization.GetByLabel('UI/PI/Common/ThisStructure')) else: sourcePin = sm.GetService('planetUI').planet.GetPin( selectedRoute.GetSourcePinID()) self.routeInfoSource.SetSubtext( planetCommon.GetGenericPinName(sourcePin.typeID, sourcePin.id)) if selectedRoute.GetDestinationPinID() == self.pin.id: self.routeInfoDest.SetSubtext( localization.GetByLabel('UI/PI/Common/ThisStructure')) else: destPin = sm.GetService('planetUI').planet.GetPin( selectedRoute.GetDestinationPinID()) self.routeInfoDest.SetSubtext( planetCommon.GetGenericPinName(destPin.typeID, destPin.id)) routeTypeID = route.GetType() routeQty = route.GetQuantity() self.routeInfoType.SetSubtext( localization.GetByLabel( 'UI/PI/Common/ItemAmount', itemName=cfg.invtypes.Get(routeTypeID).name, amount=int(routeQty))) bandwidthAttr = cfg.dgmattribs.Get(const.attributeLogisticalCapacity) infoSvc = sm.GetService('info') self.routeInfoBandwidth.SetSubtext( infoSvc.GetFormatAndValue(bandwidthAttr, selectedRoute.GetBandwidthUsage())) createRouteBtn = self.routeInfoBtns.GetBtnByLabel( localization.GetByLabel('UI/PI/Common/CreateRoute')) if createRouteBtn: if selectedRoute.GetDestinationPinID() == self.pin.id: createRouteBtn.state = uiconst.UI_NORMAL else: createRouteBtn.state = uiconst.UI_HIDDEN self.routeInfo.opacity = 0.0 self.routeInfo.state = uiconst.UI_PICKCHILDREN self.showRoutesCont.height = 168 + self.routeInfo.height self.ResizeActionCont(self.showRoutesCont.height) self.uiEffects.MorphUI(self.routeInfo, 'opacity', 1.0, time=125.0, float=1, newthread=0, maxSteps=1000)
def _GetPinName(self): return planetCommon.GetGenericPinName(self.pin.typeID, self.pin.id)
def ApplyAttributes(self, attributes): uicls.Window.ApplyAttributes(self, attributes) self.ecuPinID = attributes.get('ecuPinID') self.barGraphUpdating = False self.planetUISvc = sm.GetService('planetUI') self.planet = self.planetUISvc.planet self.pin = self.planet.GetPin(self.ecuPinID) self.extractionHeadValues = {} self.resourceTypeIDs = self.planet.remoteHandler.GetPlanetResourceInfo( ).keys() self.currResourceTypeID = self.pin.programType self.outputVals = [] self.programCycleTime = None self.dragThread = None self.flashStateColorThread = None self.currCycleTime = None self.sh = None if self.currResourceTypeID is not None: inRange, self.sh = self.planetUISvc.planet.GetResourceData( self.currResourceTypeID) self.revertToResource = self.planetUISvc.selectedResourceTypeID self.currentResource = None self.editsEnabled = self.pin.GetExtractionType( ) is None or self.pin.GetTimeToExpiry() <= 0 if self.editsEnabled: self.planetUISvc.myPinManager.UnlockHeads(self.pin.id) self.barTimeIndicatorThread = None self.overlapValues = {} self.stateColor = None self.pinData = None if self.pin.IsInEditMode(): self.pinData = self.pin.Serialize() self.SetTopparentHeight(10) self.MakeUnResizeable() captionTxt = localization.GetByLabel( 'UI/PI/Common/SurveyingProgram', pinName=planetCommon.GetGenericPinName(self.pin.typeID, self.pin.id)) self.SetCaption(captionTxt) self.bottomCont = uicls.Container(name='bottomCont', parent=self.sr.main, align=uiconst.TOBOTTOM, height=30) self.leftCont = uicls.Container(name='leftCont', parent=self.sr.main, align=uiconst.TOLEFT, width=130, padding=(6, 0, 3, 0)) self.rightCont = uicls.Container(name='rightCont', parent=self.sr.main, align=uiconst.TORIGHT, width=145, padding=(10, 5, 5, 5)) self.centerCont = uicls.Container(name='centerCont', parent=self.sr.main, align=uiconst.TOALL, padTop=3) self._ConstructLeftContainer() self._ConstructCenterContainer() self._ConstructRightContainer() self._ConstructBottomContainer()