Exemple #1
0
    def _UpdateScroll(self):
        blue.synchro.SleepWallclock(250)
        if self.destroyed:
            return
        scrolllist = []
        scrolllist.append(
            uicls.ScrollEntryNode(decoClass=uicls.SE_Generic,
                                  label='Ancestors',
                                  fontsize=18,
                                  showline=True))
        for i, (c, h, color) in enumerate(self.ancestorConts):
            scrolllist.append(self.GetScrollEntry(c, h, color))

        scrolllist.append(
            uicls.ScrollEntryNode(decoClass=uicls.SE_Generic,
                                  label='Selected',
                                  fontsize=18,
                                  showline=True))
        scrolllist.append(self.GetScrollEntry(*self.selectedCont))
        scrolllist.append(
            uicls.ScrollEntryNode(decoClass=uicls.SE_Generic,
                                  label='Children',
                                  fontsize=18,
                                  showline=True))
        for i, (c, h, color) in enumerate(self.childrenConts):
            scrolllist.append(self.GetScrollEntry(c, h, color))

        self.scroll.Load(contentList=scrolllist,
                         headers=self.GetScrollHeaders(),
                         ignoreSort=True)
Exemple #2
0
 def ApplyAttributes(self, attributes):
     super(uicls.EntityMonitor, self).ApplyAttributes(attributes)
     self.SetMinSize([self.default_width, self.default_height])
     self.SetHeight(self.default_height)
     self.entityID = attributes.get('entID', 0)
     self.SetCaption('Entity Monitor for %d' % self.entityID)
     self.entityClient = sm.GetService('entityClient')
     self.sr.content.scroll = uicls.Scroll(parent=self.sr.content,
                                           top=14,
                                           padding=5)
     self.componentNodes = {}
     self.componentDataNodes = {}
     clientNodeData = {
         'decoClass': uicls.SE_ListGroupCore,
         'GetSubContent': self.GetClientNodes,
         'label': 'Client',
         'id': ('location', 'Client'),
         'showicon': 'hide',
         'showlen': False,
         'state': 'locked'
     }
     self.clientNode = uicls.ScrollEntryNode(**clientNodeData)
     serverNodeData = {
         'decoClass': uicls.SE_ListGroupCore,
         'GetSubContent': self.GetServerNodes,
         'label': 'Server',
         'id': ('location', 'Server'),
         'showicon': 'hide',
         'showlen': False,
         'state': 'locked'
     }
     self.serverNode = uicls.ScrollEntryNode(**serverNodeData)
     self.thread = uthread.new(self.LoadEntityThread)
Exemple #3
0
    def PopulateScroll(self, *args):
        typesIncluded = []
        if self.showTimersChk.GetValue():
            typesIncluded.append('time')
        if self.showMemoryChk.GetValue():
            typesIncluded.append('memory')
        if self.showLowCountersChk.GetValue():
            typesIncluded.append('counterLow')
        if self.showHighCountersChk.GetValue():
            typesIncluded.append('counterHigh')
        statsObject = blue.CcpStatistics()
        stats = statsObject.GetValues()
        desc = statsObject.GetDescriptions()
        contentList = []
        for key, value in desc.iteritems():
            type = value[1]
            if type in typesIncluded:
                peak = stats[key][1]
                if type == 'memory':
                    label = '%s<t>%s<t>%s' % (key, FormatMemory(peak), value[0])
                elif type.startswith('counter'):
                    label = '%s<t>%s<t>%s' % (key, niceNum(peak, 1), value[0])
                elif type == 'time':
                    label = '%s<t>%s<t>%s' % (key, niceNum(peak, 1e-10), value[0])
                listEntry = uicls.ScrollEntryNode(decoClass=uicls.SE_Generic, id=id, name=key, peak=peak, desc=value[0], label=label, GetMenu=self.GetListEntryMenu, OnDblClick=self.OnListEntryDoubleClicked)
                contentList.append(listEntry)

        self.scroll.Load(contentList=contentList, headers=['Name', 'Peak', 'Description'], noContentHint='No Data available')
Exemple #4
0
    def GetSceneListEntries(self, data, *args):
        scene = data['scene']
        self.sceneDataNodes[scene.sceneID] = {}
        for entityID, entity in scene.entities.iteritems():
            for componentName in self.componentFilters:
                if not entity.HasComponent(componentName):
                    break
            else:
                name = self.GetEntityName(entity)
                spawnID = self.GetEntitySpawnID(entity)
                recipeID = self.GetEntityRecipeID(entity)
                data = {
                    'decoClass':
                    uicls.SE_EntityBrowserEntry,
                    'label':
                    '%s<t>%s<t>%s<t>%s<t>%s' %
                    (entityID, name,
                     const.cef.ENTITY_STATE_NAMES[entity.state], spawnID,
                     recipeID),
                    'entityID':
                    entityID,
                    'OnDblClick':
                    self.DblClickEntry
                }
                node = uicls.ScrollEntryNode(**data)
                self.sceneDataNodes[scene.sceneID][entityID] = node

        return self.sceneDataNodes[scene.sceneID].values()
    def LoadHistory(self):
        self.selected = None
        scrolllist = []
        for each in sm.GetService('urlhistory').GetHistory():
            if each is not None:
                try:
                    label = localization.GetByLabel(
                        'UI/Browser/BrowserHistory/Row',
                        title=each.title,
                        url=each.url,
                        date=each.ts)
                    scrolllist.append(
                        uicls.ScrollEntryNode(decoClass=uicls.SE_Generic,
                                              label=label,
                                              retval=each,
                                              OnClick=self.OnEntryClick,
                                              OnDblClick=self.OnEntryDblClick))
                except:
                    continue

        self.scroll.sr.id = 'history_window_scroll_id'
        self.scroll.Load(
            contentList=scrolllist,
            headers=[
                localization.GetByLabel('UI/Browser/BrowserHistory/Title'),
                localization.GetByLabel('UI/Browser/BrowserHistory/URL'),
                localization.GetByLabel('UI/Browser/BrowserHistory/Date')
            ])
Exemple #6
0
    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)
Exemple #7
0
    def GetScrollEntryNormal(self, c, h, color):
        try:
            cCol = c.color.GetRGBA()
        except:
            cCol = '-'

        if c.destroyed:
            color.SetRGB(0.5, 0.5, 0.5, 0.3)
        return uicls.ScrollEntryNode(
            decoClass=uicls.SE_Generic,
            label=
            '<color=%s>%s</color><t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s'
            % (color.GetHex(), c.name, c.left, c.top, c.width, c.height,
               self.GetAlignAsString(c), self.GetStateAsString(c),
               getattr(c, 'padLeft', '-'), getattr(c, 'padTop', '-'),
               getattr(c, 'padRight', '-'), getattr(c, 'padBottom', '-'),
               getattr(c, 'opacity', '-'), cCol, getattr(c, '__guid__', '-'),
               getattr(c.__renderObject__, '__name__', '-')),
            OnMouseEnter=self.OnListentryMouseEnter,
            OnMouseExit=self.OnListentryMouseExit,
            OnDblClick=self.OnListentryDblClick,
            OnClick=self.OnListentryClick,
            OnGetMenu=self.ListentryGetMenu,
            cont=c,
            highlightCont=h,
            hint=self._GetLabelRecurs('', c))
Exemple #8
0
 def GetScrollEntryAlignmentDebug(self, c, h, color):
     if c.display:
         display = 'True'
     else:
         display = '<color=red>False</color>'
     if c._alignmentDirty:
         _alignmentDirty = '<color=red>True</color>'
     else:
         _alignmentDirty = 'False'
     if c._displayDirty:
         _displayDirty = '<color=red>True</color>'
     else:
         _displayDirty = 'False'
     return uicls.ScrollEntryNode(
         decoClass=uicls.SE_Generic,
         label=
         '<color=%s>%s</color><t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s'
         %
         (color.GetHex(), c.name, c.left, c.top, c.width, c.height,
          self.GetAlignAsString(c), display, c.displayX, c.displayY,
          c.displayWidth, c.displayHeight, _alignmentDirty, _displayDirty),
         OnMouseEnter=self.OnListentryMouseEnter,
         OnMouseExit=self.OnListentryMouseExit,
         OnDblClick=self.OnListentryDblClick,
         OnClick=self.OnListentryClick,
         OnGetMenu=self.ListentryGetMenu,
         cont=c,
         highlightCont=h)
Exemple #9
0
    def _GetCombatLogLines(self, bForceUpdate=False):
        serverLineNumber = self.zactionLoggerSvc.GetLineNumber()
        serverComboElementVersion = self.zactionLoggerSvc.GetComboElementVersion(
        )
        if bForceUpdate or serverLineNumber != self.lineNumber:
            self.lineNumber = serverLineNumber
            contentList = []
            logLines = self.zactionLoggerSvc.GetCombatLog(
                self.selectedEntity, self.selectedCategory)
            for entry in logLines:
                subbedChat, entID, logCategory = entry
                data = {
                    'label': subbedChat,
                    'hideNoItem': True,
                    'OnDblClick': self._FilterSelectedEntity,
                    'entID': entID,
                    'logCategory': logCategory
                }
                contentList.append(uicls.ScrollEntryNode(**data))

            contentList.reverse()
            self.combatLogLines.LoadContent(contentList=contentList,
                                            keepPosition=True)
        if bForceUpdate or serverComboElementVersion != self.comboElementVersion:
            self.comboElementVersion = serverComboElementVersion
            self._UpdateComboBoxes()
Exemple #10
0
    def _GetAvailableActions(self):
        contentList = []
        actionTreeInstance = self.zactionClient.GetActionTree().GetTreeInstanceByEntID(self.selectedEntID)
        if not actionTreeInstance:
            return contentList
        availableActions = actionTreeInstance.GetAvailableActionsList(self.zactionClient.GetClientProperties())
        for actionID, isSibling, isActive, canRequest in availableActions:
            actionNode = self.zactionClient.GetActionTree().GetTreeNodeByID(actionID)
            actionLabel = '%s(%d)' % (actionNode.name, actionNode.ID)
            data = {'text': actionLabel,
             'label': actionLabel,
             'id': actionID,
             'actionID': actionID,
             'isActive': isActive,
             'isSibling': isSibling,
             'canRequest': canRequest,
             'showicon': 'hide',
             'showlen': False,
             'openByDefault': False,
             'hideNoItem': True,
             'disableToggle': True,
             'OnClick': self.SelectDoAction,
             'OnDblClick': self.SelectDoAction}
            contentList.append(uicls.ScrollEntryNode(**data))

        contentList.sort(lambda x, y: cmp(x.text, y.text))
        return contentList
Exemple #11
0
    def _UpdateScroll(self):
        if self.isPaused:
            return
        wndAbove = uiutil.GetWindowAbove(uicore.uilib.mouseOver)
        if isinstance(wndAbove,
                      form.UIEventListener) and uicore.uilib.rightbtn:
            return
        scrolllist = []
        lastTime = None
        for time, event in self.events[:self.showMax]:
            if lastTime == time:
                time = ''
            else:
                lastTime = time
            label = time + '<t>' + self.GetScrollLabel(event)
            scrolllist.append(
                uicls.ScrollEntryNode(decoClass=uicls.SE_Generic,
                                      label=label,
                                      fontsize=14,
                                      event=event,
                                      OnGetMenu=self.GetScrollEntryMenu))

        self.scroll.Load(contentList=scrolllist,
                         headers=self.SCROLL_HEADERS,
                         ignoreSort=True)
Exemple #12
0
    def LoadEntries(self, entries):
        scrolllist = []
        for entryName, entryValue, selected in entries:
            scrolllist.append(
                uicls.ScrollEntryNode(label=entryName,
                                      value=entryValue,
                                      isSelected=selected))

        self.LoadContent(contentList=scrolllist)
Exemple #13
0
    def LoadEntity(self):
        entity = self.entityClient.FindEntityByID(self.entityID)
        if not entity:
            self.SetCaption('Entity Monitor for %d (NOT FOUND)' %
                            self.entityID)
            self.componentNodes = {}
            self.componentDataNodes = {}
            self.sr.content.scroll.LoadContent(contentList=[])
            return
        newComponents = {}
        newComponents['client'] = entity.components.keys()
        newComponents['server'] = []
        if not self.entityClient.IsClientSideOnly(entity.scene.sceneID):
            newComponents['server'] = sm.RemoteSvc(
                'entityServer').GetServerComponentNames(
                    self.entityID) or newComponents['server']
        requiresUpdate = False
        for componentLocation in newComponents:
            for componentName in newComponents[componentLocation]:
                nodeName = '%s - %s' % (componentName,
                                        componentLocation.upper())
                if nodeName not in self.componentNodes:
                    requiresUpdate = True
                    data = {
                        'decoClass': uicls.SE_ListGroupCore,
                        'GetSubContent': self.GetComponentListEntries,
                        'label': componentName,
                        'id': ('component', nodeName),
                        'showicon': 'hide',
                        'showlen': False,
                        'componentName': componentName,
                        'location': componentLocation,
                        'sublevel': 1,
                        'state': 'locked'
                    }
                    node = uicls.ScrollEntryNode(**data)
                    self.componentNodes[nodeName] = node
                if nodeName in self.componentDataNodes:
                    if componentLocation == 'client':
                        state = self.entityClient.GetComponentStateByID(
                            self.entityID, componentName)
                    elif componentLocation == 'server':
                        state = self.entityClient.ServerReportState(
                            self.entityID, componentName)
                    if state:
                        for name, value in state.iteritems():
                            label = '%s<t>%s' % (name, value)
                            if name in self.componentDataNodes[nodeName]:
                                if self.componentDataNodes[nodeName][
                                        name].panel:
                                    self.componentDataNodes[nodeName][
                                        name].panel.sr.label.SetText(label)

        if requiresUpdate:
            self.sr.content.scroll.LoadContent(
                contentList=[self.clientNode, self.serverNode],
                headers=['name', 'value'])
Exemple #14
0
    def Expand(self):
        if self._expanding:
            return
        self._expanding = True
        log.LogInfo('Combo', self.name, 'expanding')
        uicore.Message('ComboExpand')
        menu, scroll, entryClass = self.Prepare_OptionMenu_()
        showEntryIndex = None
        scrolllist = []
        for entryIndex, (label, returnValue, hint) in enumerate(self.entries):
            isChecked = self.IsSelectedValue(returnValue)
            if isChecked and showEntryIndex is None:
                showEntryIndex = entryIndex
            scrolllist.append(
                uicls.ScrollEntryNode(decoClass=entryClass,
                                      OnClick=self.OnEntryClick,
                                      data=(label, returnValue),
                                      fontStyle=self.fontStyle,
                                      fontFamily=self.fontFamily,
                                      fontPath=self.fontPath,
                                      fontsize=self.fontsize,
                                      hint=hint,
                                      isChecked=isChecked,
                                      label=label))

        l, t, w, h = self.GetAbsolute()
        endWidth = max(self.GetMaxEntryTextWidth() + 40, w)
        scroll.width = endWidth + 2
        scroll.LoadContent(contentList=scrolllist)
        endHeight = sum([each.height for each in scroll.sr.nodes[:6]])
        menu.left = l
        menu.top = min(t + h + 1, uicore.desktop.height - menu.height - 8)
        menu.width = endWidth
        scroll.height = endHeight + 2
        scroll.left = -1
        scroll.top = -1
        scroll.OnKillFocus = self.OnScrollFocusLost
        scroll.Confirm = self.Confirm
        scroll.OnUp = self.OnUp
        scroll.OnDown = self.OnDown
        scroll.OnRight = self.Confirm
        scroll.OnLeft = self.Confirm
        self._comboDropDown = _weakref.ref(menu)
        self.sr.cookie = uicore.event.RegisterForTriuiEvents(
            uiconst.UI_MOUSEUP, self.OnGlobalClick)
        self._expanding = False
        uicore.animations.FadeIn(scroll, duration=0.5)
        uicore.animations.MorphScalar(menu,
                                      'height',
                                      startVal=10,
                                      endVal=endHeight,
                                      duration=0.125)
        if showEntryIndex is not None:
            scroll.SetSelected(showEntryIndex)
            uthread.new(self.ShowSelected, showEntryIndex)
Exemple #15
0
    def _UpdateIgnoreScroll(self):
        scrolllist = []
        for id, name in self.ignoreEvents.iteritems():
            scrolllist.append(
                uicls.ScrollEntryNode(decoClass=uicls.SE_Generic,
                                      label=name,
                                      id=id,
                                      fontsize=14,
                                      OnMouseDown=self.RemoveEventFromIgnore))

        self.ignoreScroll.Load(contentList=scrolllist)
Exemple #16
0
    def UpdateOutstanding(self):
        wnd = self.GetWnd()
        if not wnd or wnd.destroyed:
            return
        scrolllist = []
        for ct in base.outstandingCallTimers:
            method = ct[0]
            t = ct[1]
            label = '%s<t>%s<t>%s' % (method, util.FmtDate(
                t, 'nl'), util.FmtTime(blue.os.GetWallclockTimeNow() - t))
            scrolllist.append(
                uicls.ScrollEntryNode(decoClass=uicls.SE_Generic, label=label))

        wnd.sr.scroll.Load(contentList=scrolllist,
                           headers=['method', 'time', 'dt'])
Exemple #17
0
    def LoadScroll(self):
        scrolllist = []
        for funcName in dir(uicore.animations):
            if funcName.startswith('_'):
                continue
            func = getattr(uicore.animations, funcName)
            if not callable(func):
                continue
            node = uicls.ScrollEntryNode(
                decoClass=uicls.SE_TestAnimationsCheckbox,
                label=funcName,
                animFunc=func)
            scrolllist.append(node)

        self.scroll.Load(contentList=scrolllist)
Exemple #18
0
    def _GetAvailableEncounters(self):
        encounters = self.encounterSpawnServer.GetMyEncounters()
        contentList = []
        for encounter in encounters:
            data = {
                'text': encounter['encounterName'],
                'label': encounter['encounterName'],
                'id': encounter['encounterID'],
                'encounterID': encounter['encounterID'],
                'disableToggle': True,
                'hint': encounter['encounterName']
            }
            contentList.append(uicls.ScrollEntryNode(**data))

        return contentList
Exemple #19
0
    def UpdateTimers(self):
        wnd = self.GetWnd()
        if not wnd or wnd.destroyed:
            return
        scrolllist = []
        for timer in base.AutoTimer.autoTimers.iterkeys():
            label = str(timer.method)
            label = label[1:]
            label = label.split(' ')
            label = ' '.join(label[:3])
            scrolllist.append(
                uicls.ScrollEntryNode(decoClass=uicls.SE_Generic,
                                      label='%s<t>%s<t>%s' %
                                      (label, timer.interval, timer.run)))

        wnd.sr.scroll.Load(contentList=scrolllist,
                           headers=['method', 'interval', 'run'],
                           fixedEntryHeight=18)
Exemple #20
0
    def UpdateMethodCalls(self):
        wnd = self.GetWnd()
        if not wnd or wnd.destroyed:
            return
        scrolllist = []
        history = list(base.methodCallHistory)
        history.reverse()
        for ct in history[:100]:
            method = ct[0]
            t = ct[1]
            label = '%s<t>%s<t>%s' % (method, util.FmtDate(
                t, 'nl'), ct[2] / const.MSEC)
            scrolllist.append(
                uicls.ScrollEntryNode(decoClass=uicls.SE_Generic, label=label))

        wnd.sr.scroll.Load(contentList=scrolllist,
                           headers=['method', 'time', 'ms'])
        wnd.sr.scroll.sr.notSortableColumns = ['method']
Exemple #21
0
    def UpdateROT(self, force=False):
        wnd = self.GetWnd()
        if wnd:
            try:
                rot = blue.classes.LiveCount()
                if not getattr(self, 'rotinited', 0) or force:
                    scrolllist = []
                    for k, v in rot.iteritems():
                        scrolllist.append(
                            uicls.ScrollEntryNode(decoClass=uicls.SE_Generic,
                                                  totalDelta=0,
                                                  typeName=k,
                                                  peakValue=v,
                                                  lastValue=v,
                                                  label='%s<t>%s<t>%s<t>%s' %
                                                  (k, 0, v, v)))

                    wnd.sr.scroll.Load(
                        contentList=scrolllist,
                        headers=['type', 'delta', 'instances', 'peak'],
                        fixedEntryHeight=18)
                    self.showing = 'rot'
                    self.rotinited = 1
                    return
                for entry in wnd.sr.scroll.GetNodes():
                    v = rot[entry.typeName]
                    d = v - entry.lastValue
                    td = d + entry.totalDelta
                    entry.totalDelta = td
                    peak = self.maxPeaks.get(entry.typeName, -1)
                    p = max(peak, v)
                    self.maxPeaks[entry.typeName] = p
                    c = ['<color=0xff00ff00>', '<color=0xffff0000>'][td > 0]
                    entry.label = '%s<t>%s%s<color=0xffffffff><t>%s<t>%s' % (
                        entry.typeName, c, td, v, p)
                    if entry.panel:
                        entry.panel.sr.label.text = entry.label
                    entry.lastValue = v

                wnd.sr.scroll.RefreshSort()
            except:
                self.timer = None
                sys.exc_clear()
Exemple #22
0
    def _GetAllActions(self):
        contentList = []
        allActions = self.zactionClient.GetActionTree().GetAllTreeNodesList()
        for actionNode in allActions:
            if actionNode.actionType != const.ztree.NODE_FOLDER:
                actionLabel = '%s(%d)' % (actionNode.name, actionNode.ID)
                data = {'text': actionLabel,
                 'label': actionLabel,
                 'id': actionNode.ID,
                 'actionID': actionNode.ID,
                 'showicon': 'hide',
                 'showlen': False,
                 'openByDefault': False,
                 'hideNoItem': True,
                 'disableToggle': True,
                 'OnClick': self.SelectForceAction,
                 'OnDblClick': self.SelectForceAction}
                contentList.append(uicls.ScrollEntryNode(**data))

        contentList.sort(lambda x, y: cmp(x.text, y.text))
        return contentList
Exemple #23
0
    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)
Exemple #24
0
    def GetComponentListEntries(self, data, *args):
        componentName = data['componentName']
        location = data['location']
        nodeName = '%s - %s' % (componentName, location.upper())
        self.componentDataNodes[nodeName] = {}
        if location == 'client':
            state = self.entityClient.GetComponentStateByID(
                self.entityID, componentName)
        elif location == 'server':
            state = self.entityClient.ServerReportState(
                self.entityID, componentName)
        if state:
            for name, value in state.iteritems():
                data = {
                    'label': '%s<t>%s' % (name, value),
                    'sublevel': 1,
                    'id': (nodeName, name)
                }
                node = uicls.ScrollEntryNode(**data)
                self.componentDataNodes[nodeName][name] = node

        return self.componentDataNodes[nodeName].values()
Exemple #25
0
    def DoUpdateLogs(self, loggingToWindow=True):
        wnd = self.GetWnd()
        scrolllist = []
        entries = blue.logInMemory.GetEntries()
        logsToFile = []
        if entries:
            for i, e in enumerate(entries):
                if e == self.lastLogEntry:
                    break
                s = LOGTYPE_MAPPING.get(e[2], ('Unknown', '0xffeeeeee'))
                lineno = 0
                for line in e[4].split('\n'):
                    label = '%s<t>%s<t>%s::%s<t><color=%s>%s</color><t>%s' % (
                        str(e[3] + lineno)[-15:], util.FmtDate(e[3], 'nl'),
                        e[0], e[1], s[1], s[0], line.replace('<', '&lt;'))
                    scrolllist.append(
                        uicls.ScrollEntryNode(decoClass=uicls.SE_Generic,
                                              label=label))
                    lineno += 1

                txt = '%s\t%s::%s\t%s\t%s\n' % (util.FmtDate(
                    e[3], 'nl'), e[0], e[1], s[0], e[4])
                logsToFile.append(txt)

            if self.logSaveHandle:
                logsToFile.reverse()
                for l in logsToFile:
                    self.logSaveHandle.Write(l)

            self.lastLogEntry = entries[0]
            if scrolllist and loggingToWindow:
                wnd.sr.scroll.AddEntries(-1, scrolllist)
        MAXENTRIES = 5000
        if len(wnd.sr.scroll.GetNodes()) > MAXENTRIES * 2:
            self.LogInfo('Reached', len(wnd.sr.scroll.GetNodes()),
                         'log entries. Truncating down to %d' % MAXENTRIES)
            wnd.sr.scroll.RemoveEntries(wnd.sr.scroll.GetNodes()[:-MAXENTRIES])
Exemple #26
0
 def LoadInlines(self):
     self.Unload()
     if not self.sr.node.scroll:
         return
     scrollwidth = self.sr.node.scroll.GetContentWidth()
     linewidth = self.sr.node.Get('lineWidth', 0)
     lineHeight = self.sr.node.Get('maxBaseHeight', 12)
     leftMargin = self.sr.node.Get('lpush', self.sr.node.scroll.xmargin)
     rightMargin = self.sr.node.Get('rpush', self.sr.node.scroll.xmargin)
     self.sr.inlines.left = max(0, self.leftM)
     for inline, x in self.sr.node.Get('inlines', []):
         control = getattr(inline, 'control', None)
         if control and not control.destroyed:
             uiutil.Transplant(control, self.sr.inlines)
         else:
             if not hasattr(uicls, 'SE_' + inline.attrs.type):
                 continue
             decoClass = uicls.Get('SE_' + inline.attrs.type)
             control = self.sr.node.scroll.GetInline(uicls.ScrollEntryNode(decoClass=decoClass, attrs=inline.attrs))
             if not self or self.destroyed:
                 return
             uiutil.Transplant(control, self.sr.inlines)
             inline.control = control
         control.top = 0
         if inline.valign == html.ALIGNMIDDLE:
             control.top = (self.height - inline.inlineHeight) / 2
         elif inline.valign in (html.ALIGNBOTTOM, html.ALIGNSUB):
             control.top = self.height - inline.inlineHeight
         elif inline.valign == html.ALIGNBASELINE:
             control.top = self.sr.node.Get('maxBaseLine', 12) - inline.inlineHeight
         control.left = int(x)
         control.height = inline.inlineHeight
         control.width = inline.inlineWidth
         if hasattr(control, 'Load') and not control.loaded:
             control.Load()
         control.state = uiconst.UI_NORMAL
Exemple #27
0
    def LoadScenes(self, forceUpdate=False):
        newScenes = self.entityClient.scenes.iteritems()
        requiresUpdate = False
        if forceUpdate or len(
                set(self.sceneNodes.keys()) -
                set(self.entityClient.scenes.keys())) != 0:
            self.sceneNodes = {}
        for sceneID, scene in newScenes:
            if sceneID not in self.sceneNodes:
                requiresUpdate = True
                name = self.GetSceneName(sceneID)
                data = {
                    'decoClass': uicls.SE_EntityBrowserGroup,
                    'GetSubContent': self.GetSceneListEntries,
                    'label':
                    '%d<t>%s (%s)' % (sceneID, name, len(scene.entities)),
                    'id': ('scene', sceneID),
                    'state': 'locked',
                    'showlen': False,
                    'scene': scene
                }
                node = uicls.ScrollEntryNode(**data)
                self.sceneNodes[sceneID] = node
            if sceneID in self.sceneDataNodes:
                if len(scene.entities) != len(self.sceneDataNodes[sceneID]):
                    requiresUpdate = True
                else:
                    for entityID in scene.entities:
                        if entityID not in self.sceneDataNodes[sceneID]:
                            requiresUpdate = True
                            break

        if requiresUpdate or forceUpdate:
            self.sr.content.scroll.LoadContent(
                contentList=self.sceneNodes.values(),
                headers=['ID', 'Name', 'State', 'SpawnID', 'RecipeID'])
Exemple #28
0
    def Expand(self, position=None):
        if self._expanding:
            return
        self._expanding = True
        uicore.Message('ComboExpand')
        log.LogInfo('Combo', self.name, 'expanding')
        menu, scroll, entryClass = self.Prepare_OptionMenu_()
        i = 0
        maxw = 0
        selIdx = 0
        scrolllist = []
        for each in self.entries:
            label = each[0]
            if not label:
                continue
            returnValue = each[1]
            if len(each) > 2:
                hint = each[2]
            elif self.hints:
                hint = self.hints.get(label, '')
            else:
                hint = ''
            data = {}
            data['OnClick'] = self.OnEntryClick
            data['data'] = (label, returnValue)
            data['label'] = unicode(label)
            data['fontStyle'] = self.fontStyle
            data['fontFamily'] = self.fontFamily
            data['fontPath'] = self.fontPath
            data['fontsize'] = self.fontsize
            data['shadow'] = (self.shadow, )
            data['decoClass'] = entryClass
            data['hideLines'] = True
            data['hint'] = hint
            if returnValue == self.selectedValue:
                data['selected'] = True
                selIdx = i
            scrolllist.append(uicls.ScrollEntryNode(**data))
            maxw = max(
                maxw,
                uicore.font.GetTextWidth(data['label'],
                                         fontsize=self.fontsize,
                                         fontFamily=self.fontFamily,
                                         fontStyle=self.fontStyle,
                                         fontPath=self.fontPath))
            i += 1

        if position:
            l, t, w, h = position
        else:
            l, t, w, h = self.GetAbsolute()
        menu.width = max(maxw + 24, w)
        scroll.LoadContent(contentList=scrolllist)
        totalHeight = sum([each.height for each in scroll.sr.nodes[:6]])
        menu.height = totalHeight + 2 + scroll.padTop + scroll.padBottom
        menu.left = l
        menu.top = min(t + h + 1, uicore.desktop.height - menu.height - 8)
        scroll.SetSelected(selIdx)
        scroll.OnKillFocus = self.OnScrollFocusLost
        scroll.OnSelectionChange = self.OnScrollSelectionChange
        scroll.Confirm = self.Confirm
        scroll.OnUp = self.OnUp
        scroll.OnDown = self.OnDown
        scroll.OnRight = self.Confirm
        scroll.OnLeft = self.Confirm
        self._comboDropDown = _weakref.ref(menu)
        self._expanding = False
        uthread.new(self.ShowSelected, selIdx)
        return scroll