Esempio n. 1
0
 def UpdateTraining(self, skill):
     if not self or self.destroyed:
         return
     spm = skill.spm
     ETA = skill.skillTrainingEnd
     spHi = skill.spHi
     level = skill.skillLevel
     if not self or self.destroyed or util.GetAttrs(
             self, 'sr', 'node', 'skill', 'itemID') != skill.itemID:
         return
     if ETA:
         time = ETA - blue.os.GetWallclockTime()
         secs = time / 10000000L
     else:
         time = 0
         secs = 0
     currentPoints = 0
     if spHi is not None:
         currentPoints = spHi - secs / 60.0 * spm
     if util.GetAttrs(self, 'sr', 'node', 'trainToLevel') != level:
         if util.GetAttrs(self, 'sr', 'node', 'timeLeft'):
             time = self.sr.node.timeLeft
         else:
             time = None
     self.SetTimeLeft(time)
     if ETA:
         self.endOfTraining = ETA
     else:
         self.endOfTraining = None
     self.lasttime = blue.os.GetWallclockTime()
     self.lastsecs = secs
     self.lastpoints = currentPoints
     self.timer = base.AutoTimer(1000, self.UpdateProgress)
     return currentPoints
Esempio n. 2
0
 def UpdateOnlineDisplay(self):
     if getattr(self, 'module', None) is not None and self.IsOnlineable():
         isActive = const.effectOnline in self.shell.dogmaStaticMgr.effectsByType[
             self.module.typeID]
         if self.module.IsOnline():
             self.sr.flagIcon.SetRGBA(1.0, 1.0, 1.0, 1.0)
             if util.GetAttrs(
                     self, 'sr', 'onlineButton'
             ) and self.sr.onlineButton.hint == localization.GetByLabel(
                     'UI/Fitting/PutOnline'):
                 self.sr.onlineButton.hint = localization.GetByLabel(
                     'UI/Fitting/PutOffline')
         else:
             self.sr.flagIcon.SetRGBA(1.0, 1.0, 1.0, 0.25)
             if util.GetAttrs(
                     self, 'sr', 'onlineButton'
             ) and self.sr.onlineButton.hint == localization.GetByLabel(
                     'UI/Fitting/PutOffline'):
                 self.sr.onlineButton.hint = localization.GetByLabel(
                     'UI/Fitting/PutOnline')
     elif self.sr.flagIcon:
         shipID = self.GetShipID()
         if self.module is None or self.shell.SlotExists(
                 shipID, self.module.flagID):
             self.sr.flagIcon.SetRGBA(1.0, 1.0, 1.0, 1.0)
         else:
             self.sr.flagIcon.SetRGBA(0.7, 0.0, 0.0, 0.5)
Esempio n. 3
0
 def UpdateTraining(self, skill):
     if not self or self.destroyed:
         return
     ETA = self._GetEndOfTraining(skill.typeID)
     level = skill.skillLevel
     if not self or self.destroyed or util.GetAttrs(
             self, 'sr', 'node', 'skill', 'typeID') != skill.typeID:
         return
     if ETA:
         time = ETA - gametime.GetWallclockTime()
         secs = time / 10000000L
     else:
         time = 0
         secs = 0
     currentPoints = sm.GetService(
         'skillqueue').GetEstimatedSkillPointsTrained(skill.typeID)
     if util.GetAttrs(self, 'sr', 'node', 'trainToLevel') != level:
         if util.GetAttrs(self, 'sr', 'node', 'timeLeft'):
             time = self.sr.node.timeLeft
         else:
             time = None
     self.SetTimeLeft(time)
     if ETA:
         self.endOfTraining = ETA
     else:
         self.endOfTraining = None
     self.lasttime = gametime.GetWallclockTime()
     self.lastsecs = secs
     self.lastpoints = currentPoints
     self.timer = base.AutoTimer(1000, self.UpdateProgress)
     return currentPoints
Esempio n. 4
0
 def OnFleetJoin_Local(self, memberInfo, state='Active'):
     if self.destroyed:
         return
     myID = util.GetAttrs(self, 'sr', 'node', 'charID')
     charID = memberInfo.charID
     if myID is not None and charID == myID:
         uthread.new(self.SetRelationship, self.sr.node)
Esempio n. 5
0
 def OnFleetLeave_Local(self, memberInfo):
     if self.destroyed:
         return
     myID = util.GetAttrs(self, 'sr', 'node', 'charID')
     charID = memberInfo.charID
     if myID is not None and charID == myID or charID == session.charid:
         uthread.new(self.SetRelationship, self.sr.node)
Esempio n. 6
0
 def SetPointer(self, pointer, reposition=1):
     self.sr.p0.state = uiconst.UI_HIDDEN
     self.sr.p1.state = uiconst.UI_HIDDEN
     self.sr.p2.state = uiconst.UI_HIDDEN
     self.sr.p3.state = uiconst.UI_HIDDEN
     self.sr.p4.state = uiconst.UI_HIDDEN
     self.sr.p5.state = uiconst.UI_HIDDEN
     if pointer is not None:
         p = self.sr.Get('p%s' % pointer, None)
         p.state = uiconst.UI_DISABLED
         if pointer in (0, 3):
             left = self.parent.width / 2 + 2
         elif pointer in (2, 5):
             left = self.parent.width / 2 - self.width - 2
         elif pointer in (1, 4):
             left = (self.parent.width - self.width) / 2 + 1
         sidePointerIdx = pointer
         if pointer in (0, 1, 2):
             top = self.parent.height / 2 - self.height - 18
         elif pointer in (3, 4, 5):
             top = self.parent.height / 2 + 20
         if reposition:
             self.left = left
             self.top = top
     elif util.GetAttrs(self, 'parent') is not None:
         self.left = self.parent.width / 2 + 12
         self.top = self.parent.height / 2 - 8
Esempio n. 7
0
 def OnSuspectsAndCriminalsUpdate(self, criminalizedCharIDs,
                                  decriminalizedCharIDs):
     if self.destroyed:
         return
     charID = util.GetAttrs(self, 'sr', 'node', 'charID')
     if charID is not None and (charID in criminalizedCharIDs
                                or charID in decriminalizedCharIDs):
         uthread.new(self.SetRelationship, self.sr.node)
Esempio n. 8
0
 def ApplyContentPortion(self):
     if not util.GetAttrs(self, 'sr', 'stationsoutpostsResults') or getattr(
             self, '_ignorePortion', False) or not uiutil.IsVisible(
                 self.sr.stationsoutpostsResults) or not util.GetAttrs(
                     self, 'sr', 'infrastructurehubs'):
         return
     portion = settings.user.ui.Get('stationsoutpostsPortion', 0.5)
     minResultSpace = self.sr.infrastructurehubs.height + 18
     if self.sr.infrastructurehubsResults.state != uiconst.UI_HIDDEN:
         minResultSpace += 50
     else:
         portion = 1.0
     sl, st, sw, sh = self.sr.regionalOverview.GetAbsolute()
     rcl, rct, rcw, rch = self.sr.infrastructurehubsResults.GetAbsolute()
     spread = sh - self.sr.stationsoutposts.height - self.sr.header.height
     height = int(spread * portion)
     self.sr.stationsoutpostsResults.height = min(height,
                                                  spread - minResultSpace)
Esempio n. 9
0
    def OnChildClick(self, object, *args):
        for each in self.sr.main.children:
            selector = util.GetAttrs(each, 'sr', 'obj', 'SetSelected')
            if selector is not None:
                selector()

        object.SetSelected(True)
        self.sr.dad.LoadData(object.data, self.sr.dadlayer)
        self.PostOnClick(self)
Esempio n. 10
0
    def Startup(self,
                sliderID,
                minValue,
                maxValue,
                config=None,
                displayName=None,
                increments=None,
                usePrefs=0,
                startVal=None):
        self.sliderID = sliderID
        self.minValue = minValue
        self.maxValue = maxValue
        self.config = config
        self.usePrefs = usePrefs
        for each in self.parent.children:
            if each.name == 'label':
                self.label = each

        self.displayName = displayName
        if increments:
            self.SetIncrements(increments)
        if config:
            if len(config) == 3:
                cfgName, prefsType, defaultValue = config
                if prefsType:
                    rec = util.GetAttrs(settings, *prefsType)
                    if rec is not None:
                        value = rec.Get(cfgName, defaultValue)
                    else:
                        value = defaultValue
                else:
                    value = defaultValue
                self.name = config[0]
            else:
                if usePrefs:
                    value = prefs.GetValue(config, (maxValue - minValue) * 0.5)
                else:
                    value = settings.user.ui.Get(config,
                                                 (maxValue - minValue) * 0.5)
                if value is None:
                    value = 0.0
                else:
                    value = max(minValue, min(maxValue, value))
                self.name = config
            nval = (float(value) - self.minValue) / (self.maxValue -
                                                     self.minValue)
            self.SlideTo(nval, 1)
            self.SetValue(nval)
        elif startVal is not None:
            self.SlideTo(startVal, 1)
            self.SetValue(startVal)
        else:
            self.state = uiconst.UI_NORMAL
Esempio n. 11
0
 def ApplyAttributes(self, attributes):
     uicontrols.Window.ApplyAttributes(self, attributes)
     node = attributes.node
     caption = attributes.caption or 'List window'
     self.SetScope('station_inflight')
     self.SetMinSize((200, 200))
     self.SetTopparentHeight(0)
     self.sr.data = node.copy()
     main = uiutil.GetChild(self, 'main')
     main.Flush()
     icon = getattr(self.sr.data, 'showicon', '')
     if icon == 'hide':
         self.SetCaption(caption)
         self.SetWndIcon('ui_9_64_14')
     elif icon and icon[0] == '_':
         self.SetWndIcon(icon[1:], 1, size=32)
         self.SetCaption(caption)
     else:
         self.SetCaption(caption)
         self.SetWndIcon('res:/ui/Texture/WindowIcons/smallfolder.png', 1, size=32)
         if icon:
             mainicon = uiutil.GetChild(self, 'mainicon')
             mainicon.LoadIcon(icon, ignoreSize=True)
             mainicon.SetSize(32, 32)
             mainicon.state = uiconst.UI_DISABLED
         else:
             self.SetWndIcon('res:/ui/Texture/WindowIcons/smallfolder.png', 1, size=32)
     self.sr.scroll = uicontrols.Scroll(name='scroll', parent=main, padding=(const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding), align=uiconst.TOALL)
     self.sr.scroll.sr.iconMargin = getattr(self.sr.data, 'iconMargin', 0)
     ignoreTabTrimming = util.GetAttrs(node, 'scroll', 'sr', 'ignoreTabTrimming') or 0
     self.sr.scroll.sr.ignoreTabTrimming = ignoreTabTrimming
     minColumnWidth = util.GetAttrs(node, 'scroll', 'sr', 'minColumnWidth') or {}
     self.sr.scroll.sr.minColumnWidth = minColumnWidth
     self.sr.scroll.sr.content.OnDropData = self.OnDropData
 def OnStateChange(self, itemID, flag, isActive, *args):
     if util.GetAttrs(self, 'sr', 'node') is None:
         return
     if self.sr.node.itemID != itemID:
         return
     if flag == state.mouseOver:
         if isActive:
             self.ShowHilite()
         else:
             self.HideHilite()
     elif flag == state.selected:
         if isActive:
             self.Select()
         else:
             self.Deselect()
Esempio n. 13
0
 def OnMouseUp(self, *blah):
     uicore.uilib.UnclipCursor()
     self.dragging = 0
     if self.config:
         if len(self.config) == 3:
             cfgName, prefsType, defaultValue = self.config
             if prefsType:
                 rec = util.GetAttrs(settings, *prefsType)
                 if rec is not None:
                     value = rec.Set(cfgName, self.value)
         if self.usePrefs:
             prefs.SetValue(self.config, self.value)
         else:
             settings.user.ui.Set(self.config, self.value)
     if self.EndSetSliderValue:
         self.EndSetSliderValue(self)
Esempio n. 14
0
 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
Esempio n. 15
0
 def SetInfoCont(self, entry):
     selected = util.GetAttrs(entry.sr.node, 'selected')
     if not selected:
         self.ClearInfoCont()
         return
     fleet = entry.sr.node.fleet
     self.sr.infoCont.isOpen = True
     if self.Height() >= SIZE_FULLUI[1]:
         self.sr.infoCont.state = uiconst.UI_PICKCHILDREN
     caption = fleet.fleetName or localization.GetByLabel(
         'UI/Fleet/FleetRegistry/UnnamedFleet')
     self.sr.caption.text = caption
     text = self.GetFleetDetailsEntry(fleet)
     self.sr.infoText.text = text
     self.sr.detailsText.padTop = self.sr.infoText.height + 2
     desc = fleet.description
     self.sr.detailsText.state = [uiconst.UI_NORMAL,
                                  uiconst.UI_HIDDEN][desc == '']
     self.sr.detailsText.SetValue(desc)
     self.sr.joinBtn.state = [uiconst.UI_NORMAL,
                              uiconst.UI_HIDDEN][fleet.joinNeedsApproval]
     self.sr.joinRequestBtn.state = [uiconst.UI_NORMAL, uiconst.UI_HIDDEN
                                     ][not fleet.joinNeedsApproval]
Esempio n. 16
0
 def SetPointer(self, pointer, reposition=1):
     r"""
     SetPointer, positions the bubble depending on the pointerflag
     
     Pointer flags identify from where the pointer should point from.
     Flag 3 is top/left, flag 4 top/center etc...
     \  |  /
      3 4 5
      0 1 2
     /  |          """
     self.sr.p0.state = uiconst.UI_HIDDEN
     self.sr.p1.state = uiconst.UI_HIDDEN
     self.sr.p2.state = uiconst.UI_HIDDEN
     self.sr.p3.state = uiconst.UI_HIDDEN
     self.sr.p4.state = uiconst.UI_HIDDEN
     self.sr.p5.state = uiconst.UI_HIDDEN
     if pointer is not None:
         p = self.sr.Get('p%s' % pointer, None)
         p.state = uiconst.UI_DISABLED
         if pointer in (0, 3):
             left = self.parent.width / 2 + 2
         elif pointer in (2, 5):
             left = self.parent.width / 2 - self.width - 2
         elif pointer in (1, 4):
             left = (self.parent.width - self.width) / 2 + 1
         sidePointerIdx = pointer
         if pointer in (0, 1, 2):
             top = self.parent.height / 2 - self.height - 18
         elif pointer in (3, 4, 5):
             top = self.parent.height / 2 + 20
         if reposition:
             self.left = left
             self.top = top
     elif util.GetAttrs(self, 'parent') is not None:
         self.left = self.parent.width / 2 + 12
         self.top = self.parent.height / 2 - 8
Esempio n. 17
0
    def OnOK(self, *args):
        if not self.ValidateOK():
            return
        items = []
        lockedItemIDs = []
        fromLocation = None
        try:
            for entry in self.sr.itemscroll.GetNodes():
                if entry is None or not entry.checked:
                    continue
                itemID = entry.itemID
                if itemID == util.GetActiveShip():
                    eve.Message('CannotReprocessActive')
                if not self.quotes.has_key(itemID):
                    continue
                item = self.items[itemID]
                if fromLocation is None:
                    fromLocation = item.locationID
                if fromLocation != item.locationID:
                    continue
                if item.categoryID == const.categoryAsteroid or item.groupID == const.groupHarvestableCloud:
                    msg = 'lockRefining'
                else:
                    msg = 'lockReprocessing'
                sm.GetService('invCache').TryLockItem(
                    item.itemID, msg, {'itemType': item.typeID}, 1)
                lockedItemIDs.append(item.itemID)
                items.append(itemID)

            try:
                if len(items):
                    ownerID, flag = self.outputOwnerAndFlag
                    self.reprocessing = 1
                    self.sr.textContainer.state = uiconst.UI_DISABLED
                    skipChecks = []
                    while True:
                        try:
                            sm.GetService(
                                'reprocessing').GetReprocessingSvc().Reprocess(
                                    items, fromLocation, ownerID, flag, True,
                                    skipChecks)
                        except UserError as e:
                            sys.exc_clear()
                            buttons = uiconst.YESNO
                            default = uiconst.ID_YES
                            msg = cfg.GetMessage(e.msg,
                                                 e.dict,
                                                 onNotFound='return')
                            if msg.type not in ('warning', 'question'):
                                buttons = None
                                default = None
                            ret = eve.Message(e.msg,
                                              e.dict,
                                              buttons=buttons,
                                              default=default)
                            if ret == uiconst.ID_YES:
                                skipChecks.append(e.msg)
                                continue

                        break

            except:
                sys.exc_clear()
            finally:
                self.Unregister()
                self.reprocessing = 0
                self.CloseByUser()

        finally:
            for itemID in lockedItemIDs:
                sm.GetService('invCache').UnlockItem(itemID)

            if util.GetAttrs(self, 'sr', 'textContainer') is not None:
                self.sr.textContainer.state = uiconst.UI_HIDDEN
Esempio n. 18
0
 def OnCrimewatchEngagementUpdated(self, otherCharId, timeout):
     if self.destroyed:
         return
     charID = util.GetAttrs(self, 'sr', 'node', 'charID')
     if charID is not None and charID == otherCharId:
         uthread.new(self.SetRelationship, self.sr.node)
Esempio n. 19
0
 def deco(self, *args, **kw):
     if util.GetAttrs(self, *check) is None:
         return
     if self.destroyed:
         return
     return fn(self, *args, **kw)
Esempio n. 20
0
 def LoadTechLevelIcon(self, typeID=None):
     tlicon = uix.GetTechLevelIcon(self.sr.tlicon, 0, typeID)
     if tlicon is not None and util.GetAttrs(tlicon, 'parent') is None:
         self.sr.tlicon = tlicon
         tlicon.SetParent(self, 0)
Esempio n. 21
0
    def OnDropData(self, dragObj, nodes):
        if self.blinkBG:
            uicore.animations.FadeOut(self.blinkBG, duration=0.2)
        if len(nodes) and getattr(nodes[0], 'scroll', None):
            nodes[0].scroll.ClearSelection()
            if not nodes[0].rec:
                return
            if not hasattr(nodes[0].rec, 'locationID'):
                return
            locationID = nodes[0].rec.locationID
            if locationID != self.rec.locationID:
                if not sm.GetService('crimewatchSvc').CheckCanTakeItems(
                        locationID):
                    sm.GetService('crimewatchSvc').SafetyActivated(
                        const.shipSafetyLevelPartial)
                    return
        if self.isShip:
            if invCtrl.ShipCargo(self.rec.itemID).OnDropData(nodes):
                self.Blink()
            return
        if self.isContainer:
            if invCtrl.StationContainer(self.rec.itemID).OnDropData(nodes):
                self.Blink()
            return
        mergeToMe = []
        notUsed = []
        sourceID = None
        for node in nodes:
            if getattr(node, '__guid__',
                       None) not in ('xtriui.ShipUIModule', 'xtriui.InvItem',
                                     'listentry.InvItem'):
                notUsed.append(node)
                continue
            if node.item.itemID == self.sr.node.item.itemID:
                notUsed.append(node)
                continue
            if node.item.typeID == self.sr.node.item.typeID and not isinstance(
                    self.sr.node.item.itemID, tuple) and not getattr(
                        node.item, 'singleton',
                        False) and not self.sr.node.item.singleton:
                mergeToMe.append(node.item)
            else:
                notUsed.append(node)
            if sourceID is None:
                sourceID = node.rec.locationID

        if sourceID is None:
            log.LogInfo('OnDropData: Moot operation with ', nodes)
            return
        if mergeToMe:
            containerItem = sm.GetService('invCache').GetInventoryFromId(
                self.rec.locationID).GetItem()
            if session.solarsystemid and containerItem.itemID == mergeToMe[
                    0].locationID and containerItem.ownerID not in (
                        session.charid, session.corpid, session.allianceid):
                return
        shift = uicore.uilib.Key(uiconst.VK_SHIFT)
        mergeData = []
        stateMgr = sm.StartService('godma').GetStateManager()
        dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation()
        singletons = []
        for invItem in mergeToMe:
            if invItem.stacksize == 1:
                quantity = 1
            elif shift:
                ret = uix.QtyPopup(
                    invItem.stacksize, 1, 1, None,
                    localization.GetByLabel(
                        'UI/Inventory/ItemActions/StackItems'))
                if ret is not None:
                    quantity = ret['qty']
                else:
                    quantity = None
            else:
                quantity = invItem.stacksize
            if not quantity:
                continue
            if invItem.categoryID == const.categoryCharge and IsShipFittingFlag(
                    invItem.flagID):
                if type(invItem.itemID) is tuple:
                    flag = invItem.itemID[1]
                    chargeIDs = dogmaLocation.GetSubLocationsInBank(
                        invItem.locationID, invItem.itemID)
                    if chargeIDs:
                        for chargeID in chargeIDs:
                            charge = dogmaLocation.dogmaItems[chargeID]
                            mergeData.append(
                                (charge.itemID, self.rec.itemID,
                                 dogmaLocation.GetAttributeValue(
                                     chargeID,
                                     const.attributeQuantity), charge))

                    else:
                        mergeData.append((invItem.itemID, self.rec.itemID,
                                          quantity, invItem))
                else:
                    crystalIDs = dogmaLocation.GetCrystalsInBank(
                        invItem.locationID, invItem.itemID)
                    if crystalIDs:
                        for crystalID in crystalIDs:
                            crystal = dogmaLocation.GetItem(crystalID)
                            if crystal.singleton:
                                singletons.append(crystalID)
                            else:
                                mergeData.append(
                                    (crystal.itemID, self.rec.itemID,
                                     crystal.stacksize, crystal))

                    else:
                        mergeData.append((invItem.itemID, self.rec.itemID,
                                          quantity, invItem))
            else:
                mergeData.append(
                    (invItem.itemID, self.rec.itemID, quantity, invItem))

        if singletons and util.GetAttrs(self, 'sr', 'node', 'rec', 'flagID'):
            flag = self.sr.node.rec.flagID
            inv = sm.GetService('invCache').GetInventoryFromId(
                self.rec.locationID)
            if inv:
                inv.MultiAdd(singletons,
                             sourceID,
                             flag=flag,
                             fromManyFlags=True)
        if mergeData and util.GetAttrs(self, 'sr', 'node', 'container',
                                       'invController', 'MultiMerge'):
            invController = self.sr.node.container.invController
            sm.ScatterEvent('OnInvContDragExit', invController.GetInvID(), [])
            if invController.MultiMerge(mergeData, sourceID):
                sm.GetService('audio').SendUIEvent('ui_state_stack')
                self.Blink()
        if notUsed and util.GetAttrs(self, 'sr', 'node', 'container',
                                     'OnDropData'):
            self.sr.node.container.OnDropData(dragObj, notUsed)
Esempio n. 22
0
 def GetEntry(self, id_):
     for each in self.content.children:
         if util.GetAttrs(each, 'data', 'id') == id_:
             return each
Esempio n. 23
0
 def DblClickEntry(self, entry):
     entityID = util.GetAttrs(entry, 'sr', 'node', 'entityID')
     self.ViewEntity(entityID)
Esempio n. 24
0
 def OnFleetLeave(self, charID):
     if self.destroyed:
         return
     myID = util.GetAttrs(self, 'sr', 'node', 'charID')
     if myID is not None and charID == myID:
         uthread.new(self.SetRelationship, self.sr.node)