def ExpandActionMenu(self, itemID, x, y, clickedObject, **kwargs): if util.IsCharacter(itemID): kwargs['charID'] = itemID slimItem = util.SlimItemFromCharID(itemID) if slimItem: itemID = slimItem.itemID else: slimItem = uix.GetBallparkRecord(itemID) isRadialMenuButtonActive = spaceRadialMenuFunctions.IsRadialMenuButtonActive( ) if not isRadialMenuButtonActive: return uix.Flush(uicore.layer.menu) radialMenuClass = kwargs.get('radialMenuClass', uicls.RadialMenuSpace) radialMenu = radialMenuClass(name='radialMenu', parent=uicore.layer.menu, state=uiconst.UI_HIDDEN, align=uiconst.TOPLEFT, updateDisplayName=True, slimItem=slimItem, itemID=itemID, x=x, y=y, clickedObject=clickedObject, **kwargs) uicore.layer.menu.radialMenu = radialMenu uicore.uilib.SetMouseCapture(radialMenu) isRadialMenuButtonActive = spaceRadialMenuFunctions.IsRadialMenuButtonActive( ) if not isRadialMenuButtonActive: radialMenu.Close() return sm.StartService('state').SetState(itemID, state.mouseOver, 0) radialMenu.state = uiconst.UI_NORMAL sm.ScatterEvent('OnRadialMenuExpanded')
def TryLookAt(itemID, radius=None): slimItem = uix.GetBallparkRecord(itemID) isSiteBall = sm.GetService('sensorSuite').IsSiteBall(itemID) if not slimItem and not isSiteBall: return camera = sm.GetService('sceneManager').GetActiveCamera() camera.LookAt(itemID, objRadius=radius)
def _DoBallsAdded(self, lst): if not self or self.sr is None: return if self.logme: self.LogInfo('Tactical::DoBallsAdded', lst) self.LogInfo('Tactical - adding balls, num balls:', len(lst)) inCapsule = 0 mySlim = uix.GetBallparkRecord(eve.session.shipid) if mySlim and mySlim.groupID == const.groupCapsule: inCapsule = 1 checkDrones = 0 filtered = self.GetFilteredStatesFunctionNames() alwaysShown = self.GetAlwaysShownStatesFunctionNames() for each in lst: if each[1].itemID == eve.session.shipid: checkDrones = 1 if not checkDrones and not inCapsule and each[ 1].categoryID == const.categoryDrone: drone = sm.GetService('michelle').GetDroneState(each[1].itemID) if drone and (drone.ownerID == eve.session.charid or drone.controllerID == eve.session.shipid): checkDrones = 1 if not self.WantIt(each[1], filtered, alwaysShown): continue self.tacticalOverlay.AddConnector(each[0]) if checkDrones: droneview = self.GetPanel('droneview') if droneview: droneview.CheckDrones() else: self.CheckInitDrones()
def GetWarpDestinationName(self, id): name = None item = uix.GetBallparkRecord(id) if item is None or item.categoryID not in [const.groupAsteroid]: name = cfg.evelocations.Get(id).name if not name and item: name = cfg.invtypes.Get(item.typeID).typeName return name
def TryLookAt(itemID): slimItem = uix.GetBallparkRecord(itemID) if not slimItem: return try: sm.GetService('camera').LookAt(itemID) except Exception as e: sys.exc_clear()
def OnMouseHover(self, *args): return picktype, pickobject = self.GetPick() if pickobject and hasattr(pickobject, 'translationCurve') and hasattr( pickobject.translationCurve, 'id'): itemID = pickobject.translationCurve.id slimItem = uix.GetBallparkRecord(itemID) if slimItem: slimItemName = uix.GetSlimItemName(slimItem) if slimItemName: self.sr.hint = slimItemName
def OnMouseUp(self, button, *args): sm.ScatterEvent('OnCameraDragEnd') self.isMouseMoving = False if not (uicore.uilib.leftbtn or uicore.uilib.rightbtn): self._isPicked = False if not self.blockDisable and not uicore.cmd.IsUIHidden(): uicore.layer.main.state = uiconst.UI_PICKCHILDREN camera = sm.GetService('sceneManager').GetRegisteredCamera('default') if camera is None: return if not uicore.uilib.rightbtn: if self.zoomlooking and self.resetfov and camera.fieldOfView != self.prefov: uthread.new(self.ResetFov) if camera.__typename__ == 'EveCamera': if not sm.GetService('camera').targetTracker.tracking: camera.rotationOfInterest = geo2.QuaternionIdentity() self.zoomlooking = 0 if not uicore.uilib.leftbtn: self.looking = 0 self.fovready = 0 if button == 0 and not uicore.uilib.rightbtn: mt = self.GetMouseTravel() cameraSvc = sm.GetService('camera') freeLookMove = cameraSvc.dungeonHack.IsFreeLook( ) and uicore.uilib.Key(uiconst.VK_MENU) if not (mt and mt > 5 or freeLookMove): picktype, pickobject = self.GetPick() if pickobject and hasattr( pickobject, 'translationCurve') and hasattr( pickobject.translationCurve, 'id'): slimItem = uix.GetBallparkRecord( pickobject.translationCurve.id) if slimItem and slimItem.groupID not in const.nonTargetableGroups: itemID = pickobject.translationCurve.id sm.GetService('state').SetState( itemID, state.selected, 1) sm.GetService('menu').TacticalItemClicked(itemID) elif uicore.uilib.Key(uiconst.VK_MENU): sm.GetService('menu').TryLookAt(eve.session.shipid) if not uicore.uilib.leftbtn and not uicore.uilib.rightbtn: uicore.uilib.UnclipCursor() if uicore.uilib.GetCapture() == self: uicore.uilib.ReleaseCapture() elif uicore.uilib.leftbtn or uicore.uilib.rightbtn: uicore.uilib.SetCapture(self) if self.movingCursor: if sm.GetService('posAnchor').IsActive(): sm.GetService('posAnchor').StopMovingCursor() self.movingCursor = None return if eve.session.role & service.ROLE_CONTENT: if self.movingCursor: self.movingCursor = None self.downpos = None
def GetWarpDestinationName(self, id): """ returns the evelocations name if available, otherwise a typeName with some special-casing for specific groupID's """ name = None item = uix.GetBallparkRecord(id) if item is None or item.categoryID not in [const.groupAsteroid]: name = cfg.evelocations.Get(id).name if not name and item: name = cfg.invtypes.Get(item.typeID).typeName return name
def CheckInitDrones(self): mySlim = uix.GetBallparkRecord(eve.session.shipid) if not mySlim: return if mySlim.groupID == const.groupCapsule: return dronesInBay = sm.GetService('invCache').GetInventoryFromId( session.shipid).ListDroneBay() if dronesInBay: self.InitDrones() else: myDrones = sm.GetService('michelle').GetDrones() if myDrones: self.InitDrones()
def Test(self, *args): if eve.session.stationid: return self.Hide() def _Click(module): module.Click() while module.sr.glow.state == uiconst.UI_HIDDEN: blue.pyos.synchro.SleepWallclock(1) try: module.Click() except: pass def _Idle(module): return module.sr.glow.state == uiconst.UI_HIDDEN and module.sr.busy.state == uiconst.UI_HIDDEN and module.blinking == False and module.reloadingAmmo is False def _WaitForIdle(module, timeout=60000, reason=None): if reason: print 'WaitForIdle: %s' % reason blue.pyos.synchro.SleepWallclock(100) timeout -= 100 while not _Idle(module) and timeout > 0: blue.pyos.synchro.SleepWallclock(100) timeout -= 100 self.GetAmmo() t, a, p = self.GetModuleLists() ship = sm.GetService('godma').GetItem(eve.session.shipid) if eve.session.role & ROLE_PROGRAMMER: if ship.cpuOutput != 13371337: w = sm.RemoteSvc('slash') w.SlashCmd('/dogma me cpuOutput = 13371337') w.SlashCmd('/dogma me powerOutput = 10000000') w.SlashCmd('/dogma me hiSlots = 8') w.SlashCmd('/dogma me medSlots = 8') w.SlashCmd('/dogma me lowSlots = 8') w.SlashCmd('/dogma me rigSlots = 8') w.SlashCmd('/dogma me upgradeCapacity = 10000') w.SlashCmd('/dogma me turretSlotsLeft = 8') w.SlashCmd('/dogma me launcherSlotsLeft = 8') w.SlashCmd('/dogma me upgradeSlotsLeft = 8') w.SlashCmd('/dogma me capacity = 1000000') w.SlashCmd('/dogma me capacitorCapacity = 1000000') errors = [] t = filter(lambda x: self.testgroups[x[0].groupID], t + a) total = len(t) current = 0 while t: sm.RemoteSvc('slash').SlashCmd('/unload me all') slotsLeft = { 'hiPower': [x + const.flagHiSlot0 for x in range(int(ship.hiSlots))], 'medPower': [x + const.flagMedSlot0 for x in range(int(ship.medSlots))], 'loPower': [x + const.flagLoSlot0 for x in range(int(ship.lowSlots))], 'rigSlot': [x + const.flagRigSlot0 for x in range(int(ship.rigSlots))] } for item in t[:]: rec, effects = item Progress('Module Test', 'Fitting %d/%d: %s' % (current, total, rec.name), current, total) current += 1 try: slotType = [ eff.effectName for eff in effects if eff.effectName.endswith('Power') or eff.effectName == 'rigSlot' ][0] if slotsLeft[slotType]: sm.RemoteSvc('slash').SlashCmd('/fit me %s' % rec.typeID) t.remove(item) flag = slotsLeft[slotType].pop(0) module = [] while not module: blue.pyos.synchro.SleepSim(500) module = [ x for x in sm.GetService('godma').GetItem( eve.session.shipid).modules if x.flagID == flag ] if not eve.session.stationid: sm.RemoteSvc('slash').SlashCmd('/heal me capac=1') if slotsLeft.values() == [[], [], [], []]: break except UserError as e: errors.append((rec.typeID, str(e))) Progress('Module Test', 'Testing, hold on...', current, total) for itemID in sm.GetService('target').GetTargets(): slimItem = uix.GetBallparkRecord(itemID) if slimItem.typeID == 12403: break else: itemID = sm.RemoteSvc('slash').SlashCmd('/spawn 12403 victim') sm.GetService('target').ClearTargets() sm.GetService('target').LockTarget(itemID) slimItem = uix.GetBallparkRecord(itemID) if slimItem: sm.GetService('state').SetState(slimItem.itemID, state.selected, 1) sm.GetService('state').SetState(slimItem.itemID, state.activeTarget, 1) shipui = uicore.layer.shipui if not shipui: return for module in shipui.sr.modules.itervalues(): module.SetRepeat(1000) attr = sm.GetService('godma').GetType( module.sr.moduleInfo.typeID) groups = [] for x in range(1, 4): if attr.AttributeExists('chargeGroup%d' % x): groups.append(getattr(attr, 'chargeGroup%d' % x)) if groups: module.SetAutoReload(0) for gid in groups: for ammo in self.ammo[gid]: if ammo.chargeSize == attr.chargeSize and cfg.invtypes.Get( ammo.typeID).marketGroupID: print '%s <- %s' % ( cfg.invtypes.Get(attr.typeID).name, cfg.invtypes.Get(ammo.typeID).name) sm.RemoteSvc('slash').SlashCmd('/create %d' % ammo.typeID) try: module.ChangeAmmo(module.id, 1, ammo.typeID) _WaitForIdle(module, 2000, reason='pre-activate') if attr.chargeSize == 4: blue.pyos.synchro.SleepSim(5000) else: blue.pyos.synchro.SleepSim(1000) _Click(module) _WaitForIdle(module, reason='post-activate') except UserError as e: errors.append( (module.sr.moduleInfo.typeID, str(e))) sm.RemoteSvc('slash').SlashCmd( '/unload me %d' % ammo.typeID) break break else: try: _Click(module) except UserError as e: errors.append((module.sr.moduleInfo.typeID, str(e))) busy = True timeout = 30000 while busy and timeout > 0: blue.pyos.synchro.SleepSim(250) timeout -= 250 for module in shipui.sr.modules.itervalues(): if not _Idle(module): break else: busy = False Progress('Module Test', 'Done!', 3, 4) blue.pyos.synchro.Sleep(2000) Progress('Module Test', 'Done!', 4, 4) for typeID, errormsg in errors: self.LogError('%d: %s' % (typeID, errormsg))
def UpdateAll(self, updateActions=0): if not self or self.destroyed: return if eve.session.shipid in self.itemIDs: self.itemIDs.remove(eve.session.shipid) bp = sm.GetService('michelle').GetBallpark() if not self.ImVisible() or not bp or not self.itemIDs: self.sr.updateTimer = None self.FlushContent() return goForSlim = 1 slimItems = [] invItems = [] fleetMember = None for itemID in self.itemIDs: blue.pyos.BeNice() if sm.GetService('fleet').IsMember(itemID): fleetMember = cfg.eveowners.Get(itemID) break slimItem = None if goForSlim: slimItem = uix.GetBallparkRecord(itemID) if slimItem: slimItems.append(slimItem) if not slimItem: invItem = self.TryGetInvItem(itemID) if invItem: invItems.append(invItem) goForSlim = 0 if not slimItems and not invItems and not fleetMember: self.itemIDs = [] self.lastActionSerial = None self.lastActionDist = None self.FlushContent() return if not self or self.destroyed: return text = '' blue.pyos.BeNice() updateActions = updateActions or 0 typeID = None fleetSlim = None if fleetMember: multi = 1 text = fleetMember.name typeID = fleetMember.typeID fleetSlim = self.GetSlimItemForCharID(fleetMember.id) blue.pyos.BeNice() elif invItems: text = uix.GetItemName(invItems[0]) typeID = invItems[0].typeID multi = len(invItems) blue.pyos.BeNice() elif slimItems: text = uix.GetSlimItemName(slimItems[0]) typeID = slimItems[0].typeID multi = len(slimItems) if multi == 1: slimItem = slimItems[0] itemID = slimItem.itemID ball = bp.GetBall(itemID) if not ball: self.itemIDs = [] self.sr.updateTimer = None self.FlushContent() return dist = ball.surfaceDist if dist is not None: md = None myball = bp.GetBall(eve.session.shipid) if myball: md = myball.mode text += '<br>' + localization.GetByLabel( 'UI/Inflight/ActiveItem/SelectedItemDistance', distToItem=util.FmtDist(dist, maxdemicals=1)) if not self.lastActionDist or md != self.lastActionDist[ 1] or self.CheckDistanceUpdate( self.lastActionDist[0], dist): self.lastActionDist = (dist, md) updateActions = 1 sec = slimItem.securityStatus if sec: text += '<br>' + localization.GetByLabel( 'UI/Inflight/ActiveItem/SelectedItemSecurity', secStatus=sec) blue.pyos.BeNice() corpID = None charID = None categoryID = None bountyItemID = None bountyTypeID = None bountySlim = None displayUtilMenu = False if multi > 1: text += '<br>' + localization.GetByLabel( 'UI/Inflight/ActiveItem/MultipleItems', itemCount=multi) blue.pyos.BeNice() elif multi == 1: if slimItems: slim = slimItems[0] if slim.categoryID == const.categoryShip: if util.IsCharacter(slim.charID): charID = slim.charID categoryID = slim.categoryID if slim.categoryID == const.categoryEntity: bountyTypeID = slim.typeID elif slim.charID: bountyItemID = slim.charID bountySlim = slim killRightID, price = self.bountySvc.GetBestKillRight( slim.charID) self.utilMenu.UpdateKillRightInfo(killRightID, price, slim.charID, slim.itemID) stateSvc = sm.GetService('state') if killRightID is not None and not ( stateSvc.CheckSuspect(slim) or stateSvc.CheckCriminal(slim)): displayUtilMenu = True blue.pyos.BeNice() self.sr.utilMenuArea.display = displayUtilMenu self.utilMenu.display = displayUtilMenu if self.lastIcon != (typeID, itemID, charID): uthread.pool('ActiveItem::GetIcon', self.GetIcon, typeID, itemID, charID, corpID, categoryID) self.lastIcon = (typeID, itemID, charID) else: self.sr.iconpar.state = uiconst.UI_PICKCHILDREN if categoryID == const.categoryShip and charID: self.sr.chariconpar.state = uiconst.UI_PICKCHILDREN bountyHint = None reducedBountyIndication = None if (bountyItemID, bountyTypeID) != self.lastBountyCheck: bounty, bountyHint, reducedBountyIndication = self.CheckBounty( bountyTypeID, bountySlim) blue.pyos.BeNice() if bounty: self.bounty = localization.GetByLabel('UI/Common/BountyAmount', bountyAmount=util.FmtISK( bounty, 0)) else: self.bounty = None self.lastBountyCheck = (bountyItemID, bountyTypeID) self.lastBountyInfo = (bountyHint, reducedBountyIndication) else: bountyHint, reducedBountyIndication = self.lastBountyInfo if self.bounty: text += '<br>' text += self.bounty if reducedBountyIndication: text += reducedBountyIndication if updateActions: self.ReloadActions(slimItems, invItems, fleetMember, fleetSlim) else: self.CheckActions(1) self.SetText(text, bountyHint) self.ShowNoSelectedHint() blue.pyos.BeNice() self.laseUpdateWidth = self.absoluteRight - self.absoluteLeft if not self.sr.updateTimer and not invItems: self.sr.updateTimer = base.AutoTimer(500, self.UpdateAll)
def GetItem(self, itemID): item = uix.GetBallparkRecord(itemID) if not item: item = self.TryGetInvItem(itemID) return item