def SetDefaultDist(key): if not key: return minDist, maxDist = {'Orbit': (500, 1000000), 'KeepAtRange': (50, 1000000), 'WarpTo': (const.minWarpEndDistance, const.maxWarpEndDistance)}.get(key, (500, 1000000)) current = sm.GetService('menu').GetDefaultActionDistance(key) current = current or '' fromDist = util.FmtAmt(minDist) toDist = util.FmtAmt(maxDist) if key == 'KeepAtRange': hint = localization.GetByLabel('UI/Inflight/SetDefaultKeepAtRangeDistanceHint', fromDist=fromDist, toDist=toDist) caption = localization.GetByLabel('UI/Inflight/SetDefaultKeepAtRangeDistance') elif key == 'Orbit': hint = localization.GetByLabel('UI/Inflight/SetDefaultOrbitDistanceHint', fromDist=fromDist, toDist=toDist) caption = localization.GetByLabel('UI/Inflight/SetDefaultOrbitDistance') elif key == 'WarpTo': hint = localization.GetByLabel('UI/Inflight/SetDefaultWarpWithinDistanceHint', fromDist=fromDist, toDist=toDist) caption = localization.GetByLabel('UI/Inflight/SetDefaultWarpWithinDistance') else: hint = '' caption = '' r = uix.QtyPopup(maxvalue=maxDist, minvalue=minDist, setvalue=current, hint=hint, caption=caption, label=None, digits=0) if r: newRange = max(minDist, min(maxDist, r['qty'])) defaultRangeUtils.UpdateRangeSetting(key, newRange)
def OnTabOffices(self): scrolllist = [] scrollHeaders = [localization.GetByLabel('UI/Corporations/Common/Offices'), localization.GetByLabel('UI/Station/OfficeNumber'), localization.GetByLabel('UI/Station/StationManagment/OfficeRentedBy'), localization.GetByLabel('UI/Station/StationManagment/RentStartDate'), localization.GetByLabel('UI/Station/StationManagment/RentPeriod'), localization.GetByLabel('UI/Station/StationManagment/RentPeriodCost'), localization.GetByLabel('UI/Station/StationManagment/RentBalanceDue')] for each in self.rentableItems: if each.typeID == const.typeOfficeFolder: pass else: log.LogError('Unknown typeID on Corporation Folder %s (typeID) %s (CorpID)' % each.typeID, eve.session.corpid) continue rname = '' if each.rentedToID is not None: rname = localization.GetByLabel('UI/Station/StationManagment/OfficesTableRentedBy', rentername=cfg.eveowners.Get(each.rentedToID).name) dataLabel = '<t>'.join([localization.GetByLabel('UI/Station/StationManagment/OfficesTablePubliclyAvailable'), util.FmtAmt(each.number), rname, util.FmtDate(each.startDate, 'ln') if each.startDate else u'', util.FmtAmt(each.rentPeriodInDays) if each.rentPeriodInDays else u'', util.FmtISK(each.periodCost) if each.periodCost else u'', util.FmtDate(each.balanceDueDate, 'ln') if each.balanceDueDate else u'']) data = {'label': dataLabel, 'checked': each.publiclyAvailable, 'cfgname': 'offices', 'retval': 'type%s_number%s' % (each.typeID, each.number), 'OnChange': self.CheckBoxChange, 'name': 'offices_type%s_number%s' % (each.typeID, each.number)} scrolllist.append(listentry.Get('Checkbox', data)) self.ddxFunction = self.DDXTabOffices self.sr.scroll2.Load(fixedEntryHeight=24, contentList=scrolllist, headers=scrollHeaders)
def GetDefaultDist(key, itemID = None, minDist = 500, maxDist = 1000000): drange = sm.GetService('menu').GetDefaultActionDistance(key) if drange is None: dist = '' if itemID: bp = sm.StartService('michelle').GetBallpark() if not bp: return ball = bp.GetBall(itemID) if not ball: return dist = long(max(minDist, min(maxDist, ball.surfaceDist))) fromDist = util.FmtAmt(minDist) toDist = util.FmtAmt(maxDist) if key == 'KeepAtRange': hint = localization.GetByLabel('UI/Inflight/SetDefaultKeepAtRangeDistanceHint', fromDist=fromDist, toDist=toDist) caption = localization.GetByLabel('UI/Inflight/SetDefaultKeepAtRangeDistance') elif key == 'Orbit': hint = localization.GetByLabel('UI/Inflight/SetDefaultOrbitDistanceHint', fromDist=fromDist, toDist=toDist) caption = localization.GetByLabel('UI/Inflight/SetDefaultOrbitDistance') elif key == 'WarpTo': hint = localization.GetByLabel('UI/Inflight/SetDefaultWarpWithinDistanceHint', fromDist=fromDist, toDist=toDist) caption = localization.GetByLabel('UI/Inflight/SetDefaultWarpWithinDistance') else: hint = '' caption = '' r = uix.QtyPopup(maxvalue=maxDist, minvalue=minDist, setvalue=dist, hint=hint, caption=caption, label=None, digits=0) if r: newRange = max(minDist, min(maxDist, r['qty'])) defaultRangeUtils.UpdateRangeSetting(key, newRange) else: return return drange
def RenderTable(self): scroll = uicontrols.Scroll(parent=self, padding=(1, 1, 1, 1)) scroll.sr.id = 'pricehistoryscroll' scroll.smartSort = 0 scroll.OnColumnChanged = self.OnColumnChanged history = sm.GetService('marketQuote').GetPriceHistory( self.typerecord.typeID) windowData = settings.user.ui.Get('pricehistorytime', 90) if len(history) > windowData: history = history[-(windowData + 1):] scrolllist = [] for rec in history: text = '%s<t>%s<t>%s<t>%s<t>%s<t>%s' % ( util.FmtDate(rec[0]), util.FmtAmt(rec[5]), util.FmtAmt( rec[4]), util.FmtCurrency(rec[1], currency=None), util.FmtCurrency(rec[2], currency=None), util.FmtCurrency(rec[3], currency=None)) data = util.KeyVal() data.label = text data.Set( 'sort_%s' % localization.GetByLabel('UI/Market/PriceHistory/Quantity'), rec[4]) data.Set( 'sort_%s' % localization.GetByLabel('UI/Market/PriceHistory'), rec[5]) data.Set( 'sort_%s' % localization.GetByLabel('UI/Market/PriceHistory/LowestPrice'), rec[1]) data.Set( 'sort_%s' % localization.GetByLabel('UI/Market/PriceHistory/HighestPrice'), rec[2]) data.Set( 'sort_%s' % localization.GetByLabel('UI/Market/PriceHistory/AveragePrice'), rec[3]) data.Set('sort_%s' % localization.GetByLabel('UI/Common/Date'), rec[0]) scrolllist.append(listentry.Get('Generic', data=data)) headers = [ localization.GetByLabel('UI/Common/Date'), localization.GetByLabel('UI/Market/PriceHistory'), localization.GetByLabel('UI/Market/PriceHistory/Quantity'), localization.GetByLabel('UI/Market/PriceHistory/LowestPrice'), localization.GetByLabel('UI/Market/PriceHistory/HighestPrice'), localization.GetByLabel('UI/Market/PriceHistory/AveragePrice') ] scroll.Load(fixedEntryHeight=18, contentList=scrolllist, headers=headers)
def _Update(self, multiplier): cap = self.GetCapacity() if not cap: return if not self or self.destroyed: return cap2 = cap.capacity * multiplier color = '<color=0xc0ffffff>' if multiplier != 1.0: color = '<color=0xffffff00>' used = util.FmtAmt(cap.used, showFraction=1) cap2 = util.FmtAmt(cap2, showFraction=1) self.SetStatusText(used, cap2, color)
def _Update(self): cap = self.GetCapacity() if not cap: return if not self or self.destroyed: return capacityInfo = self.GetCapacityInfo() cap2 = capacityInfo.value used = util.FmtAmt(cap.used, showFraction=1) cap2 = util.FmtAmt(cap2, showFraction=1) coloredText = GetColoredText(isBetter=capacityInfo.isBetterThanBefore, text=cap2) self.SetStatusText(used, coloredText, '')
def ConstructLayout(self): contName = 'group_%d' % self.groupID self.sr.selected = uiprimitives.Fill(bgParent=self, color=(1.0, 1.0, 1.0, 0.15), state=uiconst.UI_HIDDEN) self.sr.hilite = uiprimitives.Fill(parent=self, color=(1.0, 1.0, 1.0, 0.1), state=uiconst.UI_HIDDEN) self.OnMouseEnter = self.BarOnMouseEnter self.OnMouseExit = self.BarOnMouseExit attackerName = cfg.eveowners.Get(self.attackerID).name defenderName = cfg.eveowners.Get(self.defenderID).name hintText = localization.GetByLabel( 'UI/Corporations/Wars/AggressorDefenderKillsHint', aggressorName=attackerName, aggressorKillsIsk=util.FmtISK(self.attackerKillsIsk, 0), aggressorKills=util.FmtAmt(self.attackerKills), defenderName=defenderName, defenderKillsIsk=util.FmtISK(self.defenderKillsIsk, 0), defenderKills=util.FmtAmt(self.defenderKills)) self.hint = hintText topbar = uiprimitives.Container(name='topbar', parent=self, align=uiconst.TOTOP, height=5, padTop=4) try: redwith = float(self.attackerKillsIsk) / float(self.maxKills) except: redwith = 0.0 redbar = uiprimitives.Container(parent=topbar, align=uiconst.TOLEFT_PROP, width=redwith, height=5, bgColor=ATTACKER_COLOR) bottombar = uiprimitives.Container(name='bluebar', parent=self, align=uiconst.TOBOTTOM, height=5, padBottom=4) try: bluewith = float(self.defenderKillsIsk) / float(self.maxKills) except: bluewith = 0.0 bluebar = uiprimitives.Container(parent=bottombar, align=uiconst.TOLEFT_PROP, width=bluewith, height=5, bgColor=DEFENDER_COLOR)
def UpdateUI(self): wnd = self.GetWnd() if not wnd or wnd.destroyed: return hd, li = blue.pyos.ProbeStuff() info = util.Row(list(hd), li) virtualMem = info.pagefileUsage / 1024 if self.lastVM is None: self.lastVM = virtualMem delta = virtualMem - self.lastVM self.totalVMDelta += delta self.lastVM = virtualMem delta = delta or self.lastVMDelta self.lastVMDelta = delta dc = ['<color=0xff00ff00>', '<color=0xffff0000>'][delta > 0] tdc = ['<color=0xff00ff00>', '<color=0xffff0000>'][self.totalVMDelta > 0] try: dev = trinity.device iml = '' if blue.logInMemory.isActive: iml = 'In-memory logging <color=0xff00ff00>active</color> (%s / %s)' % ( LOGTYPE_MAPPING.get( blue.logInMemory.threshold, ('Unknown', ''))[0], blue.logInMemory.capacity) fps = 'Fps: %.1f - %s' % (blue.os.fps, iml) if wnd.sr.fpsText.text != fps: wnd.sr.fpsText.text = fps vm = 'VM Size/D/TD: %sK / %s%sK<color=0xffffffff> / %s%sK<color=0xffb0b0b0> - totalVidMem: %sM' % ( util.FmtAmt(virtualMem), dc, util.FmtAmt(delta), tdc, util.FmtAmt(self.totalVMDelta), self.totalVidMem) if wnd.sr.vmText.text != vm: wnd.sr.vmText.text = vm inUse = util.FmtAmt(blue.motherLode.memUsage / 1024) total = util.FmtAmt(blue.motherLode.maxMemUsage / 1024) num = blue.motherLode.size() vm = 'Resource Cache Usage: %sK / %sK - %s objects' % (inUse, total, num) if wnd.sr.cacheText.text != vm: wnd.sr.cacheText.text = vm spaceMgr = sm.StartService('space') mo = 'Lazy Queue: %s' % getattr(spaceMgr, 'lazyLoadQueueCount', 0) if session.role & service.ROLEMASK_ELEVATEDPLAYER: mo += ' - Preload Queue: %s' % getattr(spaceMgr, 'preloadQueueCount', 22) if wnd.sr.queueText.text != mo: wnd.sr.queueText.text = mo except Exception as e: print 'e', e self.uitimer = None sys.exc_clear()
def GetFittingInfoScrollList(self, fitting): scrolllist = [] typesByRack = self.GetTypesByRack(fitting) for key, effectID in [('hiSlots', const.effectHiPower), ('medSlots', const.effectMedPower), ('lowSlots', const.effectLoPower), ('rigSlots', const.effectRigSlot), ('subSystems', const.effectSubSystem)]: slots = typesByRack[key] if len(slots) > 0: label = cfg.dgmeffects.Get(effectID).displayName scrolllist.append(listentry.Get('Header', {'label': label})) for type, qty in slots.iteritems(): data = util.KeyVal() data.typeID = type data.showinfo = 1 data.label = str(util.FmtAmt(qty)) + 'x ' + cfg.invtypes.Get(type).typeName scrolllist.append(listentry.Get('FittingModuleEntry', data=data)) charges = typesByRack['charges'] if len(charges) > 0: scrolllist.append(listentry.Get('Header', {'label': localization.GetByLabel('UI/Generic/Charges')})) for type, qty in charges.iteritems(): data = util.KeyVal() data.typeID = type data.showinfo = 1 data.label = str(util.FmtAmt(qty)) + 'x ' + cfg.invtypes.Get(type).typeName scrolllist.append(listentry.Get('FittingModuleEntry', data=data)) ice = typesByRack['ice'] if len(ice) > 0: scrolllist.append(listentry.Get('Header', {'label': localization.GetByLabel('UI/Inflight/MoonMining/Processes/Fuel')})) for type, qty in ice.iteritems(): data = util.KeyVal() data.typeID = type data.showinfo = 1 data.label = str(util.FmtAmt(qty)) + 'x ' + cfg.invtypes.Get(type).typeName scrolllist.append(listentry.Get('FittingModuleEntry', data=data)) drones = typesByRack['drones'] if len(drones) > 0: scrolllist.append(listentry.Get('Header', {'label': localization.GetByLabel('UI/Drones/Drones')})) for type, qty in drones.iteritems(): data = util.KeyVal() data.typeID = type data.showinfo = 1 data.label = str(util.FmtAmt(qty)) + 'x ' + cfg.invtypes.Get(type).typeName scrolllist.append(listentry.Get('FittingModuleEntry', data=data)) return scrolllist
def UpdateInfo(self): self.fpsLabel.text = 'Fps: %6.2f (%5.1fms)' % ( self.fpsStat.value / 100.0, self.frameTimeStat.value * 1000.0) self.workingSetLabel.text = 'Working set: ' + GetMemoryLabel( self.workingSetStat.value, self.lastWorkingSetSize, self.baseWorkingSetSize) self.commitSizeLabel.text = 'Commit size: ' + GetMemoryLabel( self.commitSizeStat.value, self.lastCommitSize, self.baseCommitSize) self.lastWorkingSetSize = self.workingSetStat.value self.lastCommitSize = self.commitSizeStat.value inUse = util.FmtAmt(blue.motherLode.memUsage / 1024) total = util.FmtAmt(blue.motherLode.maxMemUsage / 1024) num = blue.motherLode.size() self.resCacheLabel.text = 'Resource Cache Usage: %sK / %sK - %s objects' % ( inUse, total, num)
def GetTypeSubContent(self, nodedata, newitems=0): scrolllist = [] bp = sm.GetService('michelle').GetBallpark() for ballID, qty in nodedata.groupItems: try: dist = bp.DistanceBetween(eve.session.shipid, ballID) except: dist = 0 import traceback traceback.print_exc() sys.exc_clear() data = util.KeyVal() data.label = evetypes.GetName( nodedata.typeID) + '<t>' + util.FmtAmt( qty) + '<t>' + util.FmtDist(dist) data.itemID = ballID data.typeID = nodedata.typeID data.GetMenu = self.OnGetEntryMenu data.OnClick = self.OnEntryClick data.showinfo = 1 data.isTarget = ballID in nodedata.currentTargetIDs data.sublevel = 1 data.Set('sort_' + localization.GetByLabel('UI/Common/Distance'), dist) data.Set('sort_' + localization.GetByLabel('UI/Common/Quantity'), qty) entry = listentry.Get(None, data=data, decoClass=SurveyScanEntry) scrolllist.append(entry) return scrolllist
def GetLine(self, text, header, data): temp = '%s<t>' % text for each in header: temp = '%s%s<t>' % (temp, util.FmtAmt(data.get(each, 0), fmt='sn')) temp = temp[:-3] return temp
def GetFittingSlotEntry(self, slotInfo, moduleCount): slotCount = self.GetTotalSlotCount(slotInfo) if slotCount <= 0 and moduleCount <= 0: return else: isMyActiveShip = self.itemID is not None and util.GetActiveShip( ) == self.itemID isOwnedByMe = self.item is not None and self.item.ownerID == session.charid if isMyActiveShip or isOwnedByMe: data = { 'label': self.GetFittingSlotEntryLabel(slotInfo), 'text': GetByLabel('UI/InfoWindow/FittingSlotsUsedAndTotal', usedSlots=moduleCount, slotCount=slotCount), 'iconID': cfg.dgmattribs.Get(slotInfo['attributeID']).iconID, 'line': 1 } entry = listentry.Get(decoClass=FittingSlotEntry, data=data) return entry data = { 'label': self.GetFittingSlotEntryLabel(slotInfo), 'text': util.FmtAmt(slotCount), 'iconID': cfg.dgmattribs.Get(slotInfo['attributeID']).iconID, 'line': 1 } entry = listentry.Get('LabelTextSides', data) return entry
def GetObjects(self, num=1000000, drill=None, textDrill=None, b=0, e=100): wnd = self.GetWnd() if not wnd or wnd.destroyed: return dict = {} import weakref for object in gc.get_objects(): tp = type(object) if not isinstance(object, weakref.ProxyType): try: tp = object.__class__ except AttributeError: sys.exc_clear() dict[tp] = dict.get(tp, 0) + 1 dict2 = {} for k, v in dict.iteritems(): n = k.__module__ + '.' + k.__name__ dict2[n] = dict2.get(n, 0) + v scrolllist = [] items = dict2.items() items.sort() for tp, inst in items: scrolllist.append( uicls.ScrollEntryNode(decoClass=uicls.SE_Generic, OnDblClick=self.ClickEntry, instType=tp, label='%s<t>%s' % (tp, util.FmtAmt(inst)))) wnd.sr.scroll.Load(contentList=scrolllist, headers=['type', 'instances'], fixedEntryHeight=18)
def Load(self, node): ContractEntrySearch.Load(self, node) c = node.contract self.sr.contractLabel.text = '<color=0xFFFFA600>%s</color>' % self.GetLocationText( c.startSolarSystemID, c.startRegionID, c.startStationID) self.sr.toLabel.text = '<color=0xFFFFA600>%s</color>' % self.GetLocationText( c.endSolarSystemID, None, c.endStationID) routeLength = node.routeLength self.sr.volumeLabel.text = '%s m\xb3' % util.FmtAmt( c.volume, showFraction=0 if c.volume > 10 else 2) self.sr.rewardLabel.text = '<color=white>%s</color>' % [ localization.GetByLabel('UI/Contracts/ContractEntry/NoneParen'), FmtISKWithDescription(c.reward, True) ][c.reward > 0] self.sr.collateralLabel.text = '<color=white>%s</color>' % [ localization.GetByLabel('UI/Contracts/ContractEntry/NoneParen'), FmtISKWithDescription(c.collateral, True) ][c.collateral > 0] if int(routeLength) > cc.NUMJUMPS_UNREACHABLE: numJumpsTxt = '<color=0xffff6666>%s</color>' % localization.GetByLabel( 'UI/Generic/Unreachable').upper() elif routeLength == 0: numJumpsTxt = localization.GetByLabel( 'UI/Contracts/ContractEntry/SameSystem') elif routeLength == 1: numJumpsTxt = localization.GetByLabel( 'UI/Contracts/ContractEntry/NextSystem') else: numJumpsTxt = localization.GetByLabel( 'UI/Contracts/ContractEntry/NumJumps', numJumps=routeLength) self.sr.routeLabel.text = '<color=white>%s</color>' % numJumpsTxt self.sr.issuerLabel.text = node.issuer self.sr.createdLabel.text = '%s' % util.FmtDate(node.dateIssued, 'ss') self.sr.infoLabel.text = c.title
def _CountRotations(self, curYaw): """ Count the number of full ship rotations that have occurred. fetch positive or negative from direction (float) fetch the yaw from the camera rotation quaternion """ spinDirection = mathCommon.GetLesserAngleBetweenYaws( self.prevYaw, curYaw) if spinDirection == 0.0: return if self.prevDirection is None: self.prevDirection = spinDirection if self.prevDirection * spinDirection < 0.0: self.prevYaw = self.startYaw = curYaw self.prevDirection = spinDirection caughtSpin = False if self.prevYaw < curYaw: caughtSpin = self.prevYaw < self.startYaw < curYaw and spinDirection > 0.0 elif self.prevYaw > curYaw: caughtSpin = self.prevYaw > self.startYaw > curYaw and spinDirection < 0.0 if caughtSpin: self.numSpins += 1 self.spinCounterLabel.text = util.FmtAmt(self.numSpins) self.spinCounterTimer = AutoTimer(30000, self.HideSpinCounter) if self.numSpins >= self.spinCounterLabel.startSpinCount + 10 and not self.spinCounterLabel.displayTriggered: self.spinCounterLabel.Show() uicore.animations.BlinkIn(self.spinCounterLabel, duration=0.5, endVal=0.6, loops=2) self.spinCounterLabel.displayTriggered = True elif self.numSpins % 1000 == 0 and self.spinCounterLabel.displayTriggered: uicore.animations.SpColorMorphTo(self.spinCounterLabel, startColor=(1.0, 1.0, 1.0, 0.6), endColor=(0.0, 1.0, 1.0, 1.0), duration=1.0, sleep=True) uicore.animations.SpColorMorphTo(self.spinCounterLabel, startColor=(0.0, 1.0, 1.0, 1.0), endColor=(1.0, 1.0, 1.0, 0.6), duration=1.0) elif self.numSpins % 100 == 0 and self.spinCounterLabel.displayTriggered: uicore.animations.SpColorMorphTo(self.spinCounterLabel, startColor=(1.0, 1.0, 1.0, 0.6), endColor=(1.0, 1.0, 1.0, 1.0), duration=0.75, sleep=True) uicore.animations.SpColorMorphTo(self.spinCounterLabel, startColor=(1.0, 1.0, 1.0, 1.0), endColor=(1.0, 1.0, 1.0, 0.6), duration=0.75) self.prevYaw = curYaw
def ApplyAttributes(self, attributes): uicls.Window.ApplyAttributes(self, attributes) self.homeStation = None self.potentialHomeStations = None self.cloneTypeID = None sm.RegisterNotify(self) self.SetWndIcon('ui_18_128_3', mainTop=-8) self.SetMinSize([350, 270]) self.SetCaption(localization.GetByLabel('UI/Medical/Medical')) currentSkillPoints = sm.GetService('skills').GetSkillPoints() uicls.WndCaptionLabel( text=localization.GetByLabel('UI/Medical/Cloning'), subcaption=localization.GetByLabel( 'UI/Medical/Clone/CurrentSkillPoints', skillPoints=util.FmtAmt(currentSkillPoints)), parent=self.sr.topParent, align=uiconst.RELATIVE) self.scope = 'station' cloneButtons = [ ('medicalServicesChangeStationBtn', localization.GetByLabel('UI/Medical/Clone/ChangeStation'), self.PickNewHomeStation, None, 81), ('medicalServicesUpgradeCloneBtn', localization.GetByLabel('UI/Medical/Clone/UpgradeClone'), self.PickNewCloneType, None, 81) ] btns = uicls.ButtonGroup(btns=cloneButtons, line=1, forcedButtonNames=True) self.sr.main.children.append(btns) self.sr.cloneBtns = btns btns = uicls.ButtonGroup(btns=[ (localization.GetByLabel('UI/Medical/JumpClone/Install'), self.InstallClone, (), 84), (localization.GetByLabel('UI/Medical/JumpClone/Destroy'), self.DestroyClone, (), 84) ], line=1) self.sr.main.children.append(btns) self.sr.jumpcloneBtns = btns tabs = ([ localization.GetByLabel('UI/Medical/Clone'), self.sr.main, self, 'podclone', self.sr.cloneBtns ], [ localization.GetByLabel('UI/Medical/JumpClone'), self.sr.main, self, 'jumpclone', self.sr.jumpcloneBtns ]) self.maintabs = uicls.TabGroup(name='tabparent', parent=self.sr.main, idx=1) self.maintabs.Startup(tabs, 'clonespanel') self.sr.scroll = uicls.Scroll( parent=self.sr.main, padding=(const.defaultPadding, const.defaultPadding, const.defaultPadding, const.defaultPadding))
def GetMemoryLabel(memory, last, base): RED = '0xffff0000' GREEN = '0xff00ff00' delta = last - memory if delta < 0: delta = -delta deltaColor = RED else: deltaColor = GREEN totalDelta = base - memory if totalDelta < 0: totalDelta = -totalDelta totalDeltaColor = RED else: totalDeltaColor = GREEN memoryStr = util.FmtAmt(memory / 1024) deltaStr = util.FmtAmt(delta / 1024) totalDeltaStr = util.FmtAmt(totalDelta / 1024) text = '%s / <color=%s>%s</color> / <color=%s>%s</color>' % ( memoryStr, deltaColor, deltaStr, totalDeltaColor, totalDeltaStr) return text
def Load(self, node): listentry.Generic.Load(self, node) self.sr.node = node data = node if node.indented: self.itemCont.padLeft = 16 self.sr.node.typeID = int(node.typeID) self.typeID = int(data.typeID) qtyDestroyed = data.qtyDestroyed qtyDropped = data.qtyDropped singleton = data.singleton flag = data.flag typeName = cfg.invtypes.Get(self.typeID).typeName isCopy = False categoryID = cfg.invtypes.Get(self.typeID).categoryID if categoryID == inventoryConst.categoryBlueprint: self.sr.icon.top = 0 if singleton == singletonBlueprintCopy: isCopy = True typeName += ' (%s)' % localization.GetByLabel('UI/Generic/Copy').lower() else: typeName += ' (%s)' % localization.GetByLabel('UI/Generic/Original').lower() self.sr.label.text = typeName if qtyDropped > 0: self.bgColor.state = uiconst.UI_DISABLED self.sr.qtyLabel.text = util.FmtAmt(qtyDropped) else: self.bgColor = uiconst.UI_HIDDEN self.sr.qtyLabel.text = util.FmtAmt(qtyDestroyed) self.sr.techIcon.state = uiconst.UI_HIDDEN if self.typeID: self.sr.icon.state = uiconst.UI_NORMAL if flag == inventoryConst.flagImplant: self.sr.icon.LoadIcon(cfg.invtypes.Get(self.typeID).iconID, ignoreSize=True) else: self.sr.icon.LoadIconByTypeID(typeID=self.typeID, size=24, ignoreSize=True, isCopy=isCopy) self.sr.icon.SetSize(24, 24) self.sr.label.left = self.height + 16 techSprite = uix.GetTechLevelIcon(self.sr.techIcon, 1, self.typeID) techSprite.SetSize(12, 12)
def _CountRotations(self, curYaw): spinDirection = mathCommon.GetLesserAngleBetweenYaws( self.prevYaw, curYaw) if spinDirection == 0.0: return if self.prevDirection is None: self.prevDirection = spinDirection if self.prevDirection * spinDirection < 0.0: self.prevYaw = self.startYaw = curYaw self.prevDirection = spinDirection caughtSpin = False if self.prevYaw < curYaw: caughtSpin = self.prevYaw < self.startYaw < curYaw and spinDirection > 0.0 elif self.prevYaw > curYaw: caughtSpin = self.prevYaw > self.startYaw > curYaw and spinDirection < 0.0 if caughtSpin: self.numSpins += 1 self.spinCounterLabel.text = util.FmtAmt(self.numSpins) self.spinCounterTimer = base.AutoTimer(30000, self.HideSpinCounter) if self.numSpins >= self.spinCounterLabel.startSpinCount + 10 and not self.spinCounterLabel.displayTriggered: self.spinCounterLabel.Show() uicore.animations.BlinkIn(self.spinCounterLabel, duration=0.5, endVal=0.6, loops=2) self.spinCounterLabel.displayTriggered = True elif self.numSpins % 1000 == 0 and self.spinCounterLabel.displayTriggered: uicore.animations.SpColorMorphTo(self.spinCounterLabel, startColor=(1.0, 1.0, 1.0, 0.6), endColor=(0.0, 1.0, 1.0, 1.0), duration=1.0, sleep=True) uicore.animations.SpColorMorphTo(self.spinCounterLabel, startColor=(0.0, 1.0, 1.0, 1.0), endColor=(1.0, 1.0, 1.0, 0.6), duration=1.0) elif self.numSpins % 100 == 0 and self.spinCounterLabel.displayTriggered: uicore.animations.SpColorMorphTo(self.spinCounterLabel, startColor=(1.0, 1.0, 1.0, 0.6), endColor=(1.0, 1.0, 1.0, 1.0), duration=0.75, sleep=True) uicore.animations.SpColorMorphTo(self.spinCounterLabel, startColor=(1.0, 1.0, 1.0, 1.0), endColor=(1.0, 1.0, 1.0, 0.6), duration=0.75) self.prevYaw = curYaw
def _CreateYAxis(self): self.yAxisCont.Flush() NUMYAXISLABELS = 5 if self.maxValue == 0: return for i in xrange(NUMYAXISLABELS): value = float(i) / (NUMYAXISLABELS - 1) YLabel(parent=self.yAxisCont, width=self.yAxisCont.width, value=value, text=util.FmtAmt(value * self.maxValue)) yAxisFill = uiprimitives.Fill(parent=self.yAxisCont, color=util.Color.WHITE) uthread.new(uicore.effect.Fade, 0.2, 0.0, yAxisFill, 300.0)
def GetLine(self, text, header, data): """ returns a line for a scroll (for browse scroll) use: GetLine(text, header, data) pre: text is the the label for the line (what is being measured) header is a list of strings that are valid keys in data data is a dictionary whose keys are in the header post: returns a string that is ready to be set as label in a scroll """ temp = '%s<t>' % text for each in header: temp = '%s%s<t>' % (temp, util.FmtAmt(data.get(each, 0), fmt='sn')) temp = temp[:-3] return temp
def UpdateLabel(self, new=0): InvItem.UpdateLabel(self, new) if util.GetAttrs(self, 'sr', 'node', 'remote'): return volume = GetItemVolume(self.rec) self.sr.node.Set( 'sort_%s' % localization.GetByLabel('UI/Inventory/ItemVolume'), volume) u = cfg.dgmunits.Get(const.unitVolume) unit = u.displayName label = '<t>%s %s' % (util.FmtAmt(volume), unit) if self.sr.node.viewMode in ('list', 'details'): self.sr.label.text += label label = self.sr.label.text else: self.sr.label.text += label label = self.sr.label.text self.sr.node.label = label
def ApplyAttributes(self, attributes): VGoodsBuyWindow.ApplyAttributes(self, attributes) self.totalColor = '0xff05adae' windowText = localization.GetByLabel( 'UI/VirtualGoodsStore/ExchangePlexCaption') self.exchangeRate = self.rate = sm.GetService( 'store').GetPlexToAURExchangeRate() self.localPlexes = sm.GetService('store').GetAvailableLocalPlexes() self.topImage.SetTexturePath('res:/UI/Texture/Icons/7_64_12.png') self.SetCaption(windowText) self.captionLabel.text = windowText self.firstLabel.text = localization.GetByLabel( 'UI/VirtualGoodsStore/ExchangeRate') self.firstValue.text = localization.GetByLabel( 'UI/VirtualGoodsStore/AURperPLEX', numAUR=self.exchangeRate) numLocalPlexes = sum((i.stacksize for i in self.localPlexes)) if numLocalPlexes > 0: initialQty = 1 else: initialQty = 0 self.qtyEdit.SetValue(initialQty) self.qtyEdit.IntMode(0, numLocalPlexes) self.qtyAvailLabel.text = localization.GetByLabel( 'UI/VirtualGoodsStore/PlexAvailableInHangar', numPLEX=numLocalPlexes) self.totalLabel.text = localization.GetByLabel( 'UI/VirtualGoodsStore/Payout') initialTotalValue = initialQty * self.exchangeRate totalText = util.FmtAmt(initialTotalValue) self.totalText = self.GetTotalText(initialTotalValue) self.totalValueLabel.text = self.totalText self.btns = uicls.ButtonGroup( btns=[[ localization.GetByLabel( 'UI/VirtualGoodsStore/Buttons/Exchange'), self.Sell, (), None ], [ localization.GetByLabel('UI/Common/Buttons/Cancel'), self.Cancel, (), None ]], parent=self.sr.main, idx=0) self.CheckHeights()
def ClickEntry(self, entry, *args): typeName = entry.sr.node.instType.__name__ inst = gc.get_objects() alldict = {} for object in inst: s = type(object) alldict.setdefault(s, []).append(object) attrs = { 'BlueWrapper': ['__typename__', '__guid__'], 'instance': ['__class__', '__guid__'], 'class': ['__guid__', '__class__', '__repr__'] } attr = attrs.get(typeName, None) if attr is None: return dict = {} for i in alldict[entry.sr.node.instType]: stringval = '' for a in attr: stringval += str(getattr(i, a, None))[:24] + '<t>' dict.setdefault(stringval, []).append(i) scrolllist = [] for tp, inst in dict.iteritems(): if tp == 'None<t>' * len(attr): continue scrolllist.append( uicls.ScrollEntryNode(decoClass=uicls.SE_Generic, label='%s%s' % (tp, util.FmtAmt(len(inst))))) wnd = self.GetWnd() if not wnd or wnd.destroyed: return wnd.wnd.sr.scroll.Load(contentList=scrolllist, headers=attr + ['instances'], fixedEntryHeight=18)
def ShowMedicalInfo(self): homeStationID = self.GetHomeStation() cloneTypeID = self.GetCloneTypeID() cloneType = cfg.invtypes.Get(cloneTypeID) currentCloneGodmaInfo = sm.GetService('godma').GetType(cloneTypeID) scrolllist = [] data = { 'line': 1, 'label': localization.GetByLabel('UI/Medical/Clone/CloneType'), 'text': cloneType.name, 'typeID': cloneTypeID, 'iconID': cloneType.iconID } scrolllist.append(listentry.Get('LabelTextTop', data)) data = { 'line': 1, 'label': localization.GetByLabel('UI/Medical/Clone/SkillPoints'), 'text': localization.GetByLabel( 'UI/Medical/Clone/KeepsSkillPoints', skillPointsSaved=util.FmtAmt( currentCloneGodmaInfo.skillPointsSaved)), 'iconID': cfg.invtypes.Get(const.typeScience).iconID } scrolllist.append(listentry.Get('LabelTextTop', data)) data = { 'line': 1, 'label': localization.GetByLabel('UI/Medical/Clone/Location'), 'text': cfg.evelocations.Get(homeStationID).name, 'isStation': 1, 'itemID': homeStationID } scrolllist.append(listentry.Get('LabelTextTop', data)) self.sr.scroll.Load(contentList=scrolllist) if not scrolllist: self.SetHint('_nothing found')
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 GetTypeSubContent(self, nodedata, newitems = 0): scrolllist = [] bp = sm.GetService('michelle').GetBallpark() for ballID, qty in nodedata.groupItems: try: dist = bp.DistanceBetween(eve.session.shipid, ballID) except: dist = 0 import traceback traceback.print_exc() sys.exc_clear() data = util.KeyVal() data.label = cfg.invtypes.Get(nodedata.typeID).name + '<t>' + util.FmtAmt(qty) + '<t>' + util.FmtDist(dist) data.itemID = ballID data.typeID = nodedata.typeID data.GetMenu = self.OnGetEntryMenu data.OnClick = self.OnEntryClick data.showinfo = 1 data.Set('sort_' + localization.GetByLabel('UI/Common/Distance'), dist) data.Set('sort_' + localization.GetByLabel('UI/Common/Quantity'), qty) scrolllist.append(listentry.Get('Generic', data=data)) return scrolllist
def UpdateServerStatus(self, allowPatch = True): self.SetStatusText(localization.GetByLabel('UI/Login/CheckingStatus')) self.serverStatusTextFunc = None blue.pyos.synchro.Yield() try: int(self.serverPort) except Exception as e: log.LogError(e) sys.exc_clear() self.SetStatusText(localization.GetByLabel('UI/Login/InvalidPortNumber', port=self.serverPort)) self.serverStatusTextFunc = None return serverUserCount = serverversion = serverbuild = servercodename = None patch = sm.GetService('patch') if boot.region == 'optic': isAutoPatch = self.serverIP == LIVE_SERVER1 or self.serverIP == LIVE_SERVER2 or self.serverIP in [TEST_SERVER1, TEST_SERVER2, TEST_SERVER3] or prefs.GetValue('forceAutopatch', 0) == 1 else: isAutoPatch = self.serverIP == LIVE_SERVER or self.serverIP in [TEST_SERVER1, TEST_SERVER2, TEST_SERVER3] or prefs.GetValue('forceAutopatch', 0) == 1 if isAutoPatch == False and [ arg for arg in blue.pyos.GetArg() if arg.lower().startswith('/patchinfourl:') ]: isAutoPatch = True if not allowPatch: isAutoPatch = False try: log.LogInfo('checking status of %s' % self.serverIP) try: if self.firstCheck: forceQueueCheck = True self.firstCheck = False else: forceQueueCheck = False statusMessage, serverStatus = sm.GetService('machoNet').GetServerStatus('%s:%s' % (self.serverIP, self.serverPort), forceQueueCheck=forceQueueCheck) except UserError as e: if e.msg == 'AlreadyConnecting': sys.exc_clear() return raise if not self.isopen: return self.serverStatus[self.serverIP] = (serverStatus.get('cluster_usercount', None), serverStatus.get('boot_version', None), serverStatus.get('boot_build', None), str(serverStatus.get('boot_codename', const.responseUnknown)), serverStatus.get('update_info', const.responseUnknown)) serverUserCount, serverversion, serverbuild, servercodename, updateinfo = self.serverStatus[self.serverIP] self.serverStatusTextFunc = None if serverUserCount: uthread.new(self.StartXFire, str(util.FmtAmt(serverUserCount))) if type(statusMessage) in (types.LambdaType, types.FunctionType, types.MethodType): self.serverStatusTextFunc = (statusMessage, serverversion, serverbuild, serverUserCount) else: self.serverStatusTextFunc = (lambda : statusMessage, serverversion, serverbuild, serverUserCount) self.__SetServerStatusText() statusMessage = apply(self.serverStatusTextFunc[0]) user = self.usernameEditCtrl.GetValue() if serverversion and serverbuild: if statusMessage is not None and 'Incompatible' in statusMessage[0] or '%.2f' % serverversion != '%.2f' % boot.version or serverbuild > boot.build: if serverbuild > boot.build and isAutoPatch: patch.Patch(user, self.serverIP, isForce=True) patch.HandleProtocolMismatch() else: if isAutoPatch: patch.Patch(user, self.serverIP, isForce=False) reasonMessage = None if callable(self.serverStatusTextFunc[0]): reasonMessage = self.serverStatusTextFunc[0]() else: reasonMessage = self.serverStatusTextFunc[0] if reasonMessage is not None and 'IncompatibleProtocol' in reasonMessage[0]: patch.HandleProtocolMismatch() if updateinfo != const.responseUnknown: try: patch.CheckServerUpgradeInfo(updateinfo) except Exception: log.LogException() sys.exc_clear() except Exception as e: log.LogError(e) sys.exc_clear() self.SetStatusText(localization.GetByLabel('UI/Login/UnableToConnect', IP=self.serverIP, port=self.serverPort)) self.serverStatusTextFunc = None if isAutoPatch: patch.Patch('', self.serverIP, isForce=False) patch.HandleProtocolMismatch()
def CreateWindow(self): wndOutputArea = uiprimitives.Container(name='output', parent=self, align=uiconst.TOTOP, height=48) captionparent = uiprimitives.Container(name='captionparent', parent=wndOutputArea, align=uiconst.TOTOP, width=136, height=16) self.labelResults = uicontrols.EveLabelMedium( text=localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/FindMemberInRole/SimpleView/ResultsLabel' ), parent=captionparent, align=uiconst.TOTOP, height=16, state=uiconst.UI_NORMAL) wndResultsBar = uiprimitives.Container(name='results', parent=wndOutputArea, align=uiconst.TOTOP, height=16) wndNavBtns = uiprimitives.Container(name='sidepar', parent=wndResultsBar, align=uiconst.TORIGHT, width=52) label = uiprimitives.Container(name='text', parent=wndResultsBar, align=uiconst.TOLEFT, width=150, height=16) uicontrols.EveLabelMedium(text=localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/FindMemberInRole/SimpleView/MembersPerPage' ), parent=label, align=uiconst.TOTOP, state=uiconst.UI_NORMAL) optlist = [[util.FmtAmt(10), 10], [util.FmtAmt(25), 25], [util.FmtAmt(50), 50], [util.FmtAmt(100), 100], [util.FmtAmt(500), 500]] countcombo = uicontrols.Combo(label='', parent=wndResultsBar, options=optlist, name='membersperpage', callback=self.OnComboChange, width=146, pos=(150, 0, 0, 0)) countcombo.sr.label.width = 200 countcombo.sr.label.top = -16 self.sr.MembersPerPage = countcombo btn = uix.GetBigButton(24, wndNavBtns, 0, 0) btn.OnClick = (self.Navigate, -1) btn.hint = localization.GetByLabel('UI/Common/Previous') btn.state = uiconst.UI_HIDDEN btn.sr.icon.LoadIcon('ui_23_64_1') self.backBtn = btn btn = uix.GetBigButton(24, wndNavBtns, 24, 0) btn.OnClick = (self.Navigate, 1) btn.hint = localization.GetByLabel('UI/Common/ViewMore') btn.state = uiconst.UI_HIDDEN btn.sr.icon.LoadIcon('ui_23_64_2') self.fwdBtn = btn uiprimitives.Container(name='push', parent=wndOutputArea, align=uiconst.TOTOP, height=24) self.outputScrollContainer = uiprimitives.Container( name='output', parent=self, align=uiconst.TOALL, pos=(0, 0, 0, 0)) self.scroll = uicontrols.Scroll(parent=self.outputScrollContainer)