def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     self.showNavigationBar = settings.user.ui.Get('browserShowNavBar', True)
     self.showStatusBar = settings.user.ui.Get('browserShowStatusBar', True)
     self.SetCaption(localization.GetByLabel('UI/Browser/BrowserSettings/BrowserSettingsCaption'))
     self.SetButtons(uiconst.OKCLOSE, okLabel=localization.GetByLabel('UI/Browser/BrowserSettings/SaveChanges'), okFunc=self.Save, okModalResult=uiconst.ID_NONE)
     main = self.GetMainArea()
     main.clipChildren = 0
     main.padding = 6
     c = Container(name='homeCont', parent=main, align=uiconst.TOTOP, height=32)
     l = Container(name='left', parent=c, align=uiconst.TOLEFT, width=100, state=uiconst.UI_PICKCHILDREN)
     r = Container(name='right', parent=c, align=uiconst.TORIGHT, width=80, state=uiconst.UI_PICKCHILDREN)
     text = Label(text=localization.GetByLabel('UI/Browser/BrowserSettings/Homepage'), align=uiconst.TOALL, state=uiconst.UI_DISABLED, parent=l, left=0, top=4, width=2)
     top = (text.textheight - 16) / 2 + 2 if text.textheight > 16 else 0
     totalTop = top
     btn = Button(parent=r, label=localization.GetByLabel('UI/Browser/BrowserSettings/ResetHomepage'), func=self.ResetHomePage, pos=(0,
      top,
      0,
      0), align=uiconst.TOPRIGHT)
     if btn.width > 80:
         r.width = btn.width
     self.homeEdit = SinglelineEdit(name='homeEdit', setvalue=settings.user.ui.Get('HomePage2', browserutil.DefaultHomepage()), align=uiconst.TOTOP, pos=(0,
      top,
      0,
      0), parent=c)
     Line(parent=main, align=uiconst.TOTOP, color=(0.5, 0.5, 0.5, 0.75))
     self.showHideContainer = Container(name='showHideContainer', parent=main, align=uiconst.TOTOP, height=35, top=0, state=uiconst.UI_PICKCHILDREN)
     self.showStatusBarCbx = Checkbox(text=localization.GetByLabel('UI/Browser/BrowserSettings/ShowStatusBar'), parent=self.showHideContainer, configName='', retval=0, checked=self.showStatusBar)
     self.showNavBarCbx = Checkbox(text=localization.GetByLabel('UI/Browser/BrowserSettings/ShowNavigationBar'), parent=self.showHideContainer, configName='', retval=0, checked=self.showNavigationBar)
     Line(parent=main, align=uiconst.TOTOP, color=(0.5, 0.5, 0.5, 0.75))
     self.cacheContainer = Container(name='cacheContainer', parent=main, align=uiconst.TOTOP, height=26, top=8, state=uiconst.UI_PICKCHILDREN)
     l = Container(name='cacheLeft', parent=self.cacheContainer, align=uiconst.TOLEFT, width=100, state=uiconst.UI_PICKCHILDREN)
     r = Container(name='cacheRight', parent=self.cacheContainer, align=uiconst.TORIGHT, width=80, state=uiconst.UI_PICKCHILDREN)
     if not blue.win32.IsTransgaming():
         text = Label(text=localization.GetByLabel('UI/Browser/BrowserSettings/CacheLocation'), align=uiconst.TOLEFT, state=uiconst.UI_DISABLED, parent=l, padding=(2, 4, 2, 4))
         top = (text.textheight - 16) / 2 + 2 if text.textheight > 16 else 0
         totalTop += top
         btn = Button(parent=r, label=localization.GetByLabel('UI/Browser/BrowserSettings/ResetCacheLocation'), func=self.ResetCacheLocation, pos=(0,
          top,
          0,
          0), align=uiconst.TOPRIGHT)
         if btn.width > r.width:
             r.width = btn.width
         if text.textwidth > l.width:
             l.width = text.textwidth + 4
         self.cacheEdit = SinglelineEdit(name='cacheEdit', setvalue=settings.public.generic.Get('BrowserCache', corebrowserutil.DefaultCachePath()), align=uiconst.TOTOP, pos=(0,
          top,
          0,
          0), parent=self.cacheContainer)
         explainContainer = Container(name='cacheExplainContainer', parent=main, align=uiconst.TOTOP, height=26)
         Label(text=localization.GetByLabel('UI/Browser/BrowserSettings/CacheCaption'), align=uiconst.TOALL, state=uiconst.UI_DISABLED, parent=explainContainer, padLeft=4, fontsize=10)
         totalTop += 26
         clearCacheContainer = Container(name='clearCacheContainer', parent=main, align=uiconst.TOTOP, height=14)
         btn = Button(parent=clearCacheContainer, label=localization.GetByLabel('UI/Browser/BrowserSettings/ClearCache'), func=self.ClearCache)
         btn.hint = (localization.GetByLabel('UI/Browser/BrowserSettings/ClearCacheHint'),)
         totalTop += 16
     else:
         totalTop -= 32
     self.SetMinSize((500, 204 + totalTop))
     sm.StartService('sites')
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     self.showNavigationBar = settings.user.ui.Get('browserShowNavBar', True)
     self.showStatusBar = settings.user.ui.Get('browserShowStatusBar', True)
     self.SetCaption(localization.GetByLabel('UI/Browser/BrowserSettings/BrowserSettingsCaption'))
     self.SetButtons(uiconst.OKCLOSE, okLabel=localization.GetByLabel('UI/Browser/BrowserSettings/SaveChanges'), okFunc=self.Save, okModalResult=uiconst.ID_NONE)
     main = self.GetMainArea()
     main.clipChildren = 0
     main.padding = 6
     c = Container(name='homeCont', parent=main, align=uiconst.TOTOP, height=32)
     l = Container(name='left', parent=c, align=uiconst.TOLEFT, width=100, state=uiconst.UI_PICKCHILDREN)
     r = Container(name='right', parent=c, align=uiconst.TORIGHT, width=80, state=uiconst.UI_PICKCHILDREN)
     text = Label(text=localization.GetByLabel('UI/Browser/BrowserSettings/Homepage'), align=uiconst.TOALL, state=uiconst.UI_DISABLED, parent=l, left=0, top=4, width=2)
     top = (text.textheight - 16) / 2 + 2 if text.textheight > 16 else 0
     totalTop = top
     btn = Button(parent=r, label=localization.GetByLabel('UI/Browser/BrowserSettings/ResetHomepage'), func=self.ResetHomePage, pos=(0,
      top,
      0,
      0), align=uiconst.TOPRIGHT)
     if btn.width > 80:
         r.width = btn.width
     self.homeEdit = SinglelineEdit(name='homeEdit', setvalue=settings.user.ui.Get('HomePage2', browserutil.DefaultHomepage()), align=uiconst.TOTOP, pos=(0,
      top,
      0,
      0), parent=c)
     Line(parent=main, align=uiconst.TOTOP, color=(0.5, 0.5, 0.5, 0.75))
     self.showHideContainer = Container(name='showHideContainer', parent=main, align=uiconst.TOTOP, height=35, top=0, state=uiconst.UI_PICKCHILDREN)
     self.showStatusBarCbx = Checkbox(text=localization.GetByLabel('UI/Browser/BrowserSettings/ShowStatusBar'), parent=self.showHideContainer, configName='', retval=0, checked=self.showStatusBar)
     self.showNavBarCbx = Checkbox(text=localization.GetByLabel('UI/Browser/BrowserSettings/ShowNavigationBar'), parent=self.showHideContainer, configName='', retval=0, checked=self.showNavigationBar)
     Line(parent=main, align=uiconst.TOTOP, color=(0.5, 0.5, 0.5, 0.75))
     self.cacheContainer = Container(name='cacheContainer', parent=main, align=uiconst.TOTOP, height=26, top=8, state=uiconst.UI_PICKCHILDREN)
     l = Container(name='cacheLeft', parent=self.cacheContainer, align=uiconst.TOLEFT, width=100, state=uiconst.UI_PICKCHILDREN)
     r = Container(name='cacheRight', parent=self.cacheContainer, align=uiconst.TORIGHT, width=80, state=uiconst.UI_PICKCHILDREN)
     if not blue.sysinfo.isTransgaming:
         text = Label(text=localization.GetByLabel('UI/Browser/BrowserSettings/CacheLocation'), align=uiconst.TOLEFT, state=uiconst.UI_DISABLED, parent=l, padding=(2, 4, 2, 4))
         top = (text.textheight - 16) / 2 + 2 if text.textheight > 16 else 0
         totalTop += top
         btn = Button(parent=r, label=localization.GetByLabel('UI/Browser/BrowserSettings/ResetCacheLocation'), func=self.ResetCacheLocation, pos=(0,
          top,
          0,
          0), align=uiconst.TOPRIGHT)
         if btn.width > r.width:
             r.width = btn.width
         if text.textwidth > l.width:
             l.width = text.textwidth + 4
         self.cacheEdit = SinglelineEdit(name='cacheEdit', setvalue=settings.public.generic.Get('BrowserCache', corebrowserutil.DefaultCachePath()), align=uiconst.TOTOP, pos=(0,
          top,
          0,
          0), parent=self.cacheContainer)
         explainContainer = Container(name='cacheExplainContainer', parent=main, align=uiconst.TOTOP, height=26)
         Label(text=localization.GetByLabel('UI/Browser/BrowserSettings/CacheCaption'), align=uiconst.TOALL, state=uiconst.UI_DISABLED, parent=explainContainer, padLeft=4, fontsize=10)
         totalTop += 26
         clearCacheContainer = Container(name='clearCacheContainer', parent=main, align=uiconst.TOTOP, height=14)
         btn = Button(parent=clearCacheContainer, label=localization.GetByLabel('UI/Browser/BrowserSettings/ClearCache'), func=self.ClearCache)
         btn.hint = (localization.GetByLabel('UI/Browser/BrowserSettings/ClearCacheHint'),)
         totalTop += 16
     else:
         totalTop -= 32
     self.SetMinSize((500, 204 + totalTop))
     sm.StartService('sites')
Exemple #3
0
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     if hasattr(self, 'SetTopparentHeight'):
         self.SetTopparentHeight(0)
         self.container = Container(parent=self.sr.main,
                                    align=uiconst.TOALL)
     else:
         self.container = Container(parent=self.sr.content,
                                    align=uiconst.TOALL)
     from carbonui.primitives.gridcontainer import GridContainer
     self.optionsContainer = Container(parent=self.container,
                                       align=uiconst.TOTOP,
                                       height=40)
     self.cppCaptureChk = Checkbox(
         parent=self.optionsContainer,
         text='C++ capture',
         checked=blue.statistics.isCppCaptureEnabled,
         callback=self._OnCppCaptureChk,
         align=uiconst.TOTOP)
     self.gpuCaptureChk = Checkbox(
         parent=self.optionsContainer,
         text='GPU capture',
         checked=trinity.settings.GetValue('gpuTelemetryEnabled'),
         callback=self._OnGpuCaptureChk,
         align=uiconst.TOTOP)
     self.buttonContainer = GridContainer(parent=self.container,
                                          align=uiconst.TOALL,
                                          columns=2,
                                          rows=2)
     self.startBtn = Button(parent=self.buttonContainer,
                            align=uiconst.TOALL,
                            label='Start',
                            func=self._Start)
     self.stopBtn = Button(parent=self.buttonContainer,
                           align=uiconst.TOALL,
                           label='Stop',
                           func=self._Stop)
     self.pauseBtn = Button(parent=self.buttonContainer,
                            align=uiconst.TOALL,
                            label='Pause',
                            func=self._Pause)
     self.resumeBtn = Button(parent=self.buttonContainer,
                             align=uiconst.TOALL,
                             label='Resume',
                             func=self._Resume)
     uthread.new(self._CheckStatus)
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     initialUrl = attributes.initialUrl
     self.SetCaption(localization.GetByLabel('UI/Browser/TrustedSites'))
     self.SetMinSize((368, 300))
     mainArea = self.GetMainArea()
     mainArea.top = 2
     self.inputContainer = Container(name='inputContainer', parent=mainArea, align=uiconst.TOTOP, height=50)
     self.bodyContainer = Container(name='bodyContainer', parent=mainArea, align=uiconst.TOALL, pos=(0, 0, 0, 0))
     self.trustContainer = Container(name='trustContainer', parent=self.bodyContainer, align=uiconst.TOTOP, height=76)
     self.ignoreContainer = Container(name='ignoreContainer', parent=self.bodyContainer, align=uiconst.TOBOTTOM, height=76)
     urlInputContainer = Container(name='urlInputContainer', parent=self.inputContainer, align=uiconst.TOTOP, height=22, top=3)
     inputButtonContainer = Container(name='urlInputButtonContainer', parent=self.inputContainer, align=uiconst.TOBOTTOM, height=20, padRight=4)
     self.urlText = Label(text=localization.GetByLabel('UI/Browser/EditBookmarks/URL'), parent=urlInputContainer, align=uiconst.TOLEFT, padLeft=6, state=uiconst.UI_DISABLED, uppercase=1, fontsize=10, letterspace=1)
     self.urlInput = SinglelineEdit(name='urlInput', parent=urlInputContainer, align=uiconst.TOTOP, padRight=const.defaultPadding, padLeft=const.defaultPadding)
     self.trustBtn = Button(parent=inputButtonContainer, label=localization.GetByLabel('UI/Browser/TrustSite'), align=uiconst.TORIGHT, padLeft=4, padBottom=3, func=self.TrustSite)
     self.trustBtn.hint = localization.GetByLabel('UI/Browser/TrustManagementTrustHint')
     self.ignoreBtn = Button(parent=inputButtonContainer, label=localization.GetByLabel('UI/Browser/IgnoreSite'), align=uiconst.TORIGHT, padLeft=4, padBottom=3, func=self.IgnoreSite)
     self.ignoreBtn.hint = localization.GetByLabel('UI/Browser/TrustManagementIgnoreHint')
     trustBtnContainer = Container(name='trustBtnContainer', parent=self.trustContainer, align=uiconst.TOBOTTOM, height=22, padRight=4)
     trustRemoveBtn = Button(parent=trustBtnContainer, label=localization.GetByLabel('UI/Commands/Remove'), align=uiconst.TORIGHT, padLeft=4, padBottom=3, func=self.RemoveTrustedSite)
     trustRemoveBtn.hint = localization.GetByLabel('UI/Browser/TrustManagementRemoveTrustHint')
     trustTextContainer = Container(name='trustTextContainer', parent=self.trustContainer, align=uiconst.TOTOP, height=14)
     Label(text=localization.GetByLabel('UI/Browser/TrustedSites'), parent=trustTextContainer, state=uiconst.UI_DISABLED, fontsize=10, left=10, top=3)
     trustScrollContainer = Container(name='trustScrollContainer', parent=self.trustContainer, align=uiconst.TOALL)
     self.trustScroll = Scroll(parent=trustScrollContainer, padding=(const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding))
     ignoreBtnContainer = Container(name='ignoreBtnContainer', parent=self.ignoreContainer, align=uiconst.TOBOTTOM, height=22, padRight=4)
     ignoreRemoveBtn = Button(parent=ignoreBtnContainer, label=localization.GetByLabel('UI/Commands/Remove'), align=uiconst.TORIGHT, padLeft=4, padBottom=3, func=self.RemoveIgnoredSite)
     ignoreRemoveBtn.hint = localization.GetByLabel('UI/Browser/TrustManagementRemoveIgnoredHint')
     ignoreTextContainer = Container(name='ignoreTextContainer', parent=self.ignoreContainer, align=uiconst.TOTOP, height=14)
     Label(text=localization.GetByLabel('UI/Browser/IgnoredSites'), parent=ignoreTextContainer, state=uiconst.UI_DISABLED, fontsize=10, left=10, top=3)
     ignoreScrollContainer = Container(name='ignoreScrollContainer', parent=self.ignoreContainer, align=uiconst.TOALL)
     self.ignoreScroll = Scroll(parent=ignoreScrollContainer, padding=(const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding))
     self.inited = 1
     self.sitesSvc = sm.GetService('sites')
     self.RefreshSites()
     if initialUrl is not None:
         self.urlInput.SetValue(initialUrl)
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     name = attributes.bookmarkName
     url = attributes.url
     self.SetCaption(localization.GetByLabel('UI/Browser/EditBookmarks/Caption'))
     self.SetButtons(uiconst.OKCLOSE, okLabel=localization.GetByLabel('UI/Browser/EditBookmarks/Remove', selectedItems=0), okFunc=self.Remove, okModalResult=uiconst.ID_NONE)
     self.SetMinSize((256, 256))
     main = self.GetMainArea()
     main.clipChildren = 0
     Container(name='errorParent', parent=main, align=uiconst.TOBOTTOM, height=16, state=uiconst.UI_HIDDEN)
     toppar = Container(name='toppar', align=uiconst.TOTOP, height=66, parent=main, idx=0, padding=(const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding))
     c = Container(name='namecont', parent=toppar, align=uiconst.TOTOP, height=20, padBottom=5)
     label = Label(text=localization.GetByLabel('UI/Browser/EditBookmarks/Name'), fontsize=9, letterspace=2, state=uiconst.UI_DISABLED, parent=c, align=uiconst.CENTERLEFT, left=4)
     edit = SinglelineEdit(name='nameEdit', parent=c, align=uiconst.CENTERLEFT, width=150)
     edit.OnReturn = self.OnEnter
     self.nameEdit = edit
     c = Container(name='urlcont', parent=toppar, align=uiconst.TOTOP, height=20, padBottom=5)
     label2 = Label(text=localization.GetByLabel('UI/Browser/EditBookmarks/URL'), fontsize=9, letterspace=2, state=uiconst.UI_DISABLED, parent=c, align=uiconst.CENTERLEFT, left=4, uppercase=True)
     edit = SinglelineEdit(name='urlEdit', parent=c, align=uiconst.CENTERLEFT, width=150)
     edit.OnReturn = self.OnEnter
     self.urlEdit = edit
     self.nameEdit.left = self.urlEdit.left = max(35, label.textwidth + 6, label2.textwidth + 6)
     b = Button(parent=toppar, label=localization.GetByLabel('UI/Browser/EditBookmarks/Add'), func=self.OnEnter, align=uiconst.BOTTOMRIGHT)
     editBtn = Button(parent=toppar, label=localization.GetByLabel('UI/Browser/EditBookmarks/Edit'), pos=(b.width + const.defaultPadding,
      0,
      0,
      0), func=self.OnEdit, align=uiconst.BOTTOMRIGHT)
     editBtn.state = uiconst.UI_HIDDEN
     self.editBtn = editBtn
     name = StripTags(name).strip()
     if name:
         self.nameEdit.SetValue(name)
     if url:
         self.urlEdit.SetValue(url)
     self.scroll = Scroll(parent=main, padding=(const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding))
     sm.GetService('sites')
     self.RefreshSites()
 def ApplyAttributes(self, attributes):
     super(CameraDebugWindow, self).ApplyAttributes(attributes)
     self.SetMinSize([self.default_width, self.default_height])
     self.SetCaption('Camera Debug Window')
     self.sr.content.padding = (5, 16, 5, 5)
     self.debugSelectionClient = sm.GetService('debugSelectionClient')
     self.cameraDebugClient = sm.GetService('cameraDebugClient')
     self.cameraClient = sm.GetService('cameraClient')
     self.cameraStack = Label(parent=self.sr.content, align=uiconst.TOPLEFT, text=self.PrintCameraStack())
     buttonContainer = Container(parent=self.sr.content, align=uiconst.TOBOTTOM, height=70, padding=(150, 0, 150, 0))
     self.toggleCamera = Button(parent=buttonContainer, align=uiconst.TOBOTTOM, label='Activate Normal Camera', func=self.OnToggleDebugCamera)
     self.toggleCamUpdate = Button(parent=buttonContainer, align=uiconst.TOBOTTOM, label='Toggle Camera Update', func=self.OnToggleDebugCameraUpdate, hint='Toggle between updating the debug, and normal camera.')
     self.showCamCheckBox = Checkbox(parent=buttonContainer, aligh=uiconst.TOBOTTOM, text='Show Normal Camera', checked=False, callback=self.OnSnowNormalCameraCheckbox)
     import cameras
     self.cameraClient.AddSharedCamera('Debug Camera', cameras.DebugCamera())
     if type(self.cameraClient.GetActiveCamera()) is cameras.DebugCamera:
         self.DisableDebugCamera()
     self.EnableDebugCamera()
     sm.GetService('navigation').hasControl = False
Exemple #7
0
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     name = attributes.bookmarkName
     url = attributes.url
     self.SetCaption(localization.GetByLabel('UI/Browser/EditBookmarks/Caption'))
     self.SetButtons(uiconst.OKCLOSE, okLabel=localization.GetByLabel('UI/Browser/EditBookmarks/Remove', selectedItems=0), okFunc=self.Remove, okModalResult=uiconst.ID_NONE)
     self.SetMinSize((256, 256))
     main = self.GetMainArea()
     main.clipChildren = 0
     Container(name='errorParent', parent=main, align=uiconst.TOBOTTOM, height=16, state=uiconst.UI_HIDDEN)
     toppar = Container(name='toppar', align=uiconst.TOTOP, height=66, parent=main, idx=0, padding=(const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding))
     c = Container(name='namecont', parent=toppar, align=uiconst.TOTOP, height=20, padBottom=5)
     label = Label(text=localization.GetByLabel('UI/Browser/EditBookmarks/Name'), fontsize=9, letterspace=2, state=uiconst.UI_DISABLED, parent=c, align=uiconst.CENTERLEFT, left=4)
     edit = SinglelineEdit(name='nameEdit', parent=c, align=uiconst.CENTERLEFT, width=150)
     edit.OnReturn = self.OnEnter
     self.nameEdit = edit
     c = Container(name='urlcont', parent=toppar, align=uiconst.TOTOP, height=20, padBottom=5)
     label2 = Label(text=localization.GetByLabel('UI/Browser/EditBookmarks/URL'), fontsize=9, letterspace=2, state=uiconst.UI_DISABLED, parent=c, align=uiconst.CENTERLEFT, left=4, uppercase=True)
     edit = SinglelineEdit(name='urlEdit', parent=c, align=uiconst.CENTERLEFT, width=150)
     edit.OnReturn = self.OnEnter
     self.urlEdit = edit
     self.nameEdit.left = self.urlEdit.left = max(35, label.textwidth + 6, label2.textwidth + 6)
     b = Button(parent=toppar, label=localization.GetByLabel('UI/Browser/EditBookmarks/Add'), func=self.OnEnter, align=uiconst.BOTTOMRIGHT)
     editBtn = Button(parent=toppar, label=localization.GetByLabel('UI/Browser/EditBookmarks/Edit'), pos=(b.width + const.defaultPadding,
      0,
      0,
      0), func=self.OnEdit, align=uiconst.BOTTOMRIGHT)
     editBtn.state = uiconst.UI_HIDDEN
     self.editBtn = editBtn
     name = StripTags(name).strip()
     if name:
         self.nameEdit.SetValue(name)
     if url:
         self.urlEdit.SetValue(url)
     self.scroll = Scroll(parent=main, padding=(const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding))
     sm.GetService('sites')
     self.RefreshSites()
Exemple #8
0
    def ApplyAttributes(self, attributes):
        Window.ApplyAttributes(self, attributes)
        self.SetTopparentHeight(4)
        self.collectingFpsStats = False
        self.fpsStats = []
        self.fpsLabel = Label(parent=self.sr.main,
                              left=4,
                              width=80,
                              fontsize=18)
        self.platformLabel = Label(parent=self.sr.main,
                                   left=4,
                                   top=24,
                                   width=80,
                                   fontsize=12,
                                   text=trinity.platform)
        self.fpsStat = blue.statistics.Find('FPS')
        self.frameTimeStat = blue.statistics.Find('Trinity/FrameTime')
        self.toggleDisplayResults = False
        self.legendContainer = GridContainer(parent=self.sr.main,
                                             align=uiconst.TORIGHT,
                                             width=28,
                                             columns=1,
                                             padRight=4,
                                             padBottom=4)
        self.startStatsBtn = Button(parent=self.sr.main,
                                    align=uiconst.BOTTOMLEFT,
                                    label='Start Collecting Stats',
                                    left=5,
                                    top=10,
                                    func=self.StartCollectingData)
        self.stopStatsBtn = Button(parent=self.sr.main,
                                   align=uiconst.BOTTOMLEFT,
                                   label='Stop Collecting Stats',
                                   left=5,
                                   top=10,
                                   func=self.StopCollectingData,
                                   state=uiconst.UI_HIDDEN)
        self.timeLabel = Label(parent=self.sr.main,
                               align=uiconst.BOTTOMLEFT,
                               left=142,
                               top=11,
                               width=100,
                               fontsize=12)
        self.displayResultsCheckbox = Checkbox(
            parent=self.sr.main,
            align=uiconst.BOTTOMRIGHT,
            left=10,
            top=10,
            callback=self.ToggleDisplayResults,
            width=100)
        self.labels = []
        for i in xrange(4):
            label = Label(parent=self.legendContainer,
                          align=uiconst.TOTOP,
                          width=20,
                          top=-4)
            self.labels.append(label)

        graphContainer = Container(parent=self.sr.main,
                                   align=uiconst.TOALL,
                                   padLeft=4,
                                   padRight=4,
                                   padBottom=4)
        gr = GraphRenderer(parent=graphContainer, align=uiconst.TOALL)
        self.renderer = gr.renderer
        self.renderer.scaleChangeCallback = self.ScaleChangeHandler
        if self.fpsStat:
            uthread.new(self.UpdateFpsLabel)
Exemple #9
0
class FpsMonitor(Window):
    __guid__ = 'uicls.FpsMonitor'
    default_caption = 'FPS Monitor'
    default_windowID = 'fpsMonitor'

    def ApplyAttributes(self, attributes):
        Window.ApplyAttributes(self, attributes)
        self.SetTopparentHeight(4)
        self.collectingFpsStats = False
        self.fpsStats = []
        self.fpsLabel = Label(parent=self.sr.main,
                              left=4,
                              width=80,
                              fontsize=18)
        self.platformLabel = Label(parent=self.sr.main,
                                   left=4,
                                   top=24,
                                   width=80,
                                   fontsize=12,
                                   text=trinity.platform)
        self.fpsStat = blue.statistics.Find('FPS')
        self.frameTimeStat = blue.statistics.Find('Trinity/FrameTime')
        self.toggleDisplayResults = False
        self.legendContainer = GridContainer(parent=self.sr.main,
                                             align=uiconst.TORIGHT,
                                             width=28,
                                             columns=1,
                                             padRight=4,
                                             padBottom=4)
        self.startStatsBtn = Button(parent=self.sr.main,
                                    align=uiconst.BOTTOMLEFT,
                                    label='Start Collecting Stats',
                                    left=5,
                                    top=10,
                                    func=self.StartCollectingData)
        self.stopStatsBtn = Button(parent=self.sr.main,
                                   align=uiconst.BOTTOMLEFT,
                                   label='Stop Collecting Stats',
                                   left=5,
                                   top=10,
                                   func=self.StopCollectingData,
                                   state=uiconst.UI_HIDDEN)
        self.timeLabel = Label(parent=self.sr.main,
                               align=uiconst.BOTTOMLEFT,
                               left=142,
                               top=11,
                               width=100,
                               fontsize=12)
        self.displayResultsCheckbox = Checkbox(
            parent=self.sr.main,
            align=uiconst.BOTTOMRIGHT,
            left=10,
            top=10,
            callback=self.ToggleDisplayResults,
            width=100)
        self.labels = []
        for i in xrange(4):
            label = Label(parent=self.legendContainer,
                          align=uiconst.TOTOP,
                          width=20,
                          top=-4)
            self.labels.append(label)

        graphContainer = Container(parent=self.sr.main,
                                   align=uiconst.TOALL,
                                   padLeft=4,
                                   padRight=4,
                                   padBottom=4)
        gr = GraphRenderer(parent=graphContainer, align=uiconst.TOALL)
        self.renderer = gr.renderer
        self.renderer.scaleChangeCallback = self.ScaleChangeHandler
        if self.fpsStat:
            uthread.new(self.UpdateFpsLabel)

    def ToggleDisplayResults(self, chkb):
        if chkb._checked:
            self.toggleDisplayResults = True
        else:
            self.toggleDisplayResults = False

    def ScaleChangeHandler(self):
        numLabels = len(self.labels)
        label = 1.0
        labelStep = 1.0 / float(numLabels)
        for i in xrange(numLabels):
            labelValue = int(label / self.renderer.scale *
                             self.renderer.legendScale + 0.5)
            self.labels[i].SetText(str(labelValue))
            label -= labelStep

    def StartCollectingData(self, *args):
        self.fpsStats = []
        self.statsData = {'fps': [], 'frametime': []}
        self.startStatsBtn.Hide()
        self.stopStatsBtn.Show()
        uthread.new(self.CollectDataThread)

    def CollectDataThread(self):
        MAX_STATS = 36000
        self.collectingFpsStats = blue.os.GetWallclockTime()
        while self.collectingFpsStats:
            deltaTime = blue.os.GetWallclockTime() - self.collectingFpsStats
            self.fpsStats.append((deltaTime, self.fpsStat.value))
            fps = self.fpsStat.value
            frametime = self.frameTimeStat.value
            if fps:
                self.statsData['fps'].append(fps)
            if frametime:
                self.statsData['frametime'].append(frametime)
            if deltaTime > const.HOUR:
                self.StopCollectingData()
                return
            blue.synchro.SleepWallclock(200)

    def UpdateFpsLabel(self):
        while not self.destroyed:
            self.fpsLabel.text = '%6.2f' % self.fpsStat.value
            blue.synchro.SleepWallclock(500)
            if self.collectingFpsStats:
                deltaTime = blue.os.GetWallclockTime(
                ) - self.collectingFpsStats
                self.timeLabel.text = '%s' % util.FmtTime(deltaTime)

    def StopCollectingData(self, *args):
        self.startStatsBtn.Show()
        self.stopStatsBtn.Hide()
        self.collectingFpsStats = None
        txt = ''
        for t, value in self.fpsStats:
            txt += '%.1f\t%6.2f\n' % (t / float(const.SEC), value)

        print txt
        if self.toggleDisplayResults:
            self.DisplayAverageResults()
        blue.pyos.SetClipboardData(txt)
        self.fpsStats = []
        uicore.Message('CustomNotify',
                       {'notify': 'FPS Stats have been exported to clipboard'})

    def DisplayAverageResults(self):
        """
        This function (mean) averages all the gathered metric data gathered
            during collection and displays them in a Message Window.
        """
        avg = lambda x: sum(x) / len(x)
        avgfps = avg(self.statsData['fps'])
        avgframetime = avg(self.statsData['frametime'])
        uicore.Message(
            'CustomInfo', {
                'info':
                'Mean FPS: %6.2f<br />Mean Frametime:%6.2f' %
                (avgfps, avgframetime * 1000)
            })
Exemple #10
0
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     initialUrl = attributes.initialUrl
     self.SetCaption(localization.GetByLabel('UI/Browser/TrustedSites'))
     self.SetMinSize((368, 300))
     mainArea = self.GetMainArea()
     mainArea.top = 2
     self.inputContainer = Container(name='inputContainer',
                                     parent=mainArea,
                                     align=uiconst.TOTOP,
                                     height=50)
     self.bodyContainer = Container(name='bodyContainer',
                                    parent=mainArea,
                                    align=uiconst.TOALL,
                                    pos=(0, 0, 0, 0))
     self.trustContainer = Container(name='trustContainer',
                                     parent=self.bodyContainer,
                                     align=uiconst.TOTOP,
                                     height=76)
     self.ignoreContainer = Container(name='ignoreContainer',
                                      parent=self.bodyContainer,
                                      align=uiconst.TOBOTTOM,
                                      height=76)
     urlInputContainer = Container(name='urlInputContainer',
                                   parent=self.inputContainer,
                                   align=uiconst.TOTOP,
                                   height=22,
                                   top=3)
     inputButtonContainer = Container(name='urlInputButtonContainer',
                                      parent=self.inputContainer,
                                      align=uiconst.TOBOTTOM,
                                      height=20,
                                      padRight=4)
     self.urlText = Label(
         text=localization.GetByLabel('UI/Browser/EditBookmarks/URL'),
         parent=urlInputContainer,
         align=uiconst.TOLEFT,
         padLeft=6,
         state=uiconst.UI_DISABLED,
         uppercase=1,
         fontsize=10,
         letterspace=1)
     self.urlInput = SinglelineEdit(name='urlInput',
                                    parent=urlInputContainer,
                                    align=uiconst.TOTOP,
                                    padRight=const.defaultPadding,
                                    padLeft=const.defaultPadding)
     self.trustBtn = Button(
         parent=inputButtonContainer,
         label=localization.GetByLabel('UI/Browser/TrustSite'),
         align=uiconst.TORIGHT,
         padLeft=4,
         padBottom=3,
         func=self.TrustSite)
     self.trustBtn.hint = localization.GetByLabel(
         'UI/Browser/TrustManagementTrustHint')
     self.ignoreBtn = Button(
         parent=inputButtonContainer,
         label=localization.GetByLabel('UI/Browser/IgnoreSite'),
         align=uiconst.TORIGHT,
         padLeft=4,
         padBottom=3,
         func=self.IgnoreSite)
     self.ignoreBtn.hint = localization.GetByLabel(
         'UI/Browser/TrustManagementIgnoreHint')
     trustBtnContainer = Container(name='trustBtnContainer',
                                   parent=self.trustContainer,
                                   align=uiconst.TOBOTTOM,
                                   height=22,
                                   padRight=4)
     trustRemoveBtn = Button(
         parent=trustBtnContainer,
         label=localization.GetByLabel('UI/Commands/Remove'),
         align=uiconst.TORIGHT,
         padLeft=4,
         padBottom=3,
         func=self.RemoveTrustedSite)
     trustRemoveBtn.hint = localization.GetByLabel(
         'UI/Browser/TrustManagementRemoveTrustHint')
     trustTextContainer = Container(name='trustTextContainer',
                                    parent=self.trustContainer,
                                    align=uiconst.TOTOP,
                                    height=14)
     Label(text=localization.GetByLabel('UI/Browser/TrustedSites'),
           parent=trustTextContainer,
           state=uiconst.UI_DISABLED,
           fontsize=10,
           left=10,
           top=3)
     trustScrollContainer = Container(name='trustScrollContainer',
                                      parent=self.trustContainer,
                                      align=uiconst.TOALL)
     self.trustScroll = Scroll(
         parent=trustScrollContainer,
         padding=(const.defaultPadding, const.defaultPadding,
                  const.defaultPadding, const.defaultPadding))
     ignoreBtnContainer = Container(name='ignoreBtnContainer',
                                    parent=self.ignoreContainer,
                                    align=uiconst.TOBOTTOM,
                                    height=22,
                                    padRight=4)
     ignoreRemoveBtn = Button(
         parent=ignoreBtnContainer,
         label=localization.GetByLabel('UI/Commands/Remove'),
         align=uiconst.TORIGHT,
         padLeft=4,
         padBottom=3,
         func=self.RemoveIgnoredSite)
     ignoreRemoveBtn.hint = localization.GetByLabel(
         'UI/Browser/TrustManagementRemoveIgnoredHint')
     ignoreTextContainer = Container(name='ignoreTextContainer',
                                     parent=self.ignoreContainer,
                                     align=uiconst.TOTOP,
                                     height=14)
     Label(text=localization.GetByLabel('UI/Browser/IgnoredSites'),
           parent=ignoreTextContainer,
           state=uiconst.UI_DISABLED,
           fontsize=10,
           left=10,
           top=3)
     ignoreScrollContainer = Container(name='ignoreScrollContainer',
                                       parent=self.ignoreContainer,
                                       align=uiconst.TOALL)
     self.ignoreScroll = Scroll(
         parent=ignoreScrollContainer,
         padding=(const.defaultPadding, const.defaultPadding,
                  const.defaultPadding, const.defaultPadding))
     self.inited = 1
     self.sitesSvc = sm.GetService('sites')
     self.RefreshSites()
     if initialUrl is not None:
         self.urlInput.SetValue(initialUrl)
class TelemetryPanel(Window):
    __guid__ = 'form.TelemetryPanel'
    default_caption = 'Telemetry Panel'

    def ApplyAttributes(self, attributes):
        Window.ApplyAttributes(self, attributes)
        if hasattr(self, 'SetTopparentHeight'):
            self.SetTopparentHeight(0)
            self.container = Container(parent=self.sr.main,
                                       align=uiconst.TOALL)
        else:
            self.container = Container(parent=self.sr.content,
                                       align=uiconst.TOALL)
        self.optionsContainer = Container(parent=self.container,
                                          align=uiconst.TOTOP,
                                          height=32)
        self.cppCaptureChk = Checkbox(
            parent=self.optionsContainer,
            text='C++ capture',
            checked=blue.statistics.isCppCaptureEnabled,
            callback=self._OnCppCaptureChk,
            align=uiconst.TOTOP)
        from carbonui.primitives.gridcontainer import GridContainer
        self.buttonContainer = GridContainer(parent=self.container,
                                             align=uiconst.TOALL,
                                             columns=2,
                                             rows=2)
        self.startBtn = Button(parent=self.buttonContainer,
                               align=uiconst.TOALL,
                               label='Start',
                               func=self._Start)
        self.stopBtn = Button(parent=self.buttonContainer,
                              align=uiconst.TOALL,
                              label='Stop',
                              func=self._Stop)
        self.pauseBtn = Button(parent=self.buttonContainer,
                               align=uiconst.TOALL,
                               label='Pause',
                               func=self._Pause)
        self.resumeBtn = Button(parent=self.buttonContainer,
                                align=uiconst.TOALL,
                                label='Resume',
                                func=self._Resume)
        uthread.new(self._CheckStatus)

    def _OnCppCaptureChk(self, checkbox):
        blue.statistics.isCppCaptureEnabled = checkbox.GetValue()

    def _Start(self, args):
        print 'Starting Telemetry'
        blue.statistics.StartTelemetry('localhost')

    def _Stop(self, args):
        print 'Stopping Telemetry'
        blue.statistics.StopTelemetry()

    def _Pause(self, args):
        print 'Pausing Telemetry'
        blue.statistics.PauseTelemetry()

    def _Resume(self, args):
        print 'Resuming Telemetry'
        blue.statistics.ResumeTelemetry()

    def _CheckStatus(self):
        while not self.destroyed:
            self.cppCaptureChk.SetChecked(blue.statistics.isCppCaptureEnabled,
                                          report=False)
            if blue.statistics.isTelemetryConnected:
                self.startBtn.Disable()
                self.stopBtn.Enable()
                if blue.statistics.isTelemetryPaused:
                    self.pauseBtn.Disable()
                    self.resumeBtn.Enable()
                else:
                    self.pauseBtn.Enable()
                    self.resumeBtn.Disable()
            else:
                self.startBtn.Enable()
                self.stopBtn.Disable()
                self.pauseBtn.Disable()
                self.resumeBtn.Disable()
            blue.synchro.SleepWallclock(500)
class CameraDebugWindow(Window):
    """ Window for debug camera control and feedback """
    __guid__ = 'uicls.CameraDebugWindow'
    default_windowID = 'CameraDebugWindow'
    default_width = 500
    default_height = 200

    def ApplyAttributes(self, attributes):
        super(CameraDebugWindow, self).ApplyAttributes(attributes)
        self.SetMinSize([self.default_width, self.default_height])
        self.SetCaption('Camera Debug Window')
        self.sr.content.padding = (5, 16, 5, 5)
        self.debugSelectionClient = sm.GetService('debugSelectionClient')
        self.cameraDebugClient = sm.GetService('cameraDebugClient')
        self.cameraClient = sm.GetService('cameraClient')
        self.cameraStack = Label(parent=self.sr.content, align=uiconst.TOPLEFT, text=self.PrintCameraStack())
        buttonContainer = Container(parent=self.sr.content, align=uiconst.TOBOTTOM, height=70, padding=(150, 0, 150, 0))
        self.toggleCamera = Button(parent=buttonContainer, align=uiconst.TOBOTTOM, label='Activate Normal Camera', func=self.OnToggleDebugCamera)
        self.toggleCamUpdate = Button(parent=buttonContainer, align=uiconst.TOBOTTOM, label='Toggle Camera Update', func=self.OnToggleDebugCameraUpdate, hint='Toggle between updating the debug, and normal camera.')
        self.showCamCheckBox = Checkbox(parent=buttonContainer, aligh=uiconst.TOBOTTOM, text='Show Normal Camera', checked=False, callback=self.OnSnowNormalCameraCheckbox)
        import cameras
        self.cameraClient.AddSharedCamera('Debug Camera', cameras.DebugCamera())
        if type(self.cameraClient.GetActiveCamera()) is cameras.DebugCamera:
            self.DisableDebugCamera()
        self.EnableDebugCamera()
        sm.GetService('navigation').hasControl = False

    def OnSnowNormalCameraCheckbox(self, checkBox):
        debugCam = self.cameraClient.GetSharedCamera('Debug Camera')
        debugCam.SetShowNormalCamera(checkBox.GetValue())

    def OnToggleDebugCamera(self, *args):
        activeCam = self.cameraClient.GetActiveCamera()
        debugCam = self.cameraClient.GetSharedCamera('Debug Camera')
        if activeCam is debugCam:
            self.DisableDebugCamera()
        else:
            self.EnableDebugCamera()

    def EnableDebugCamera(self):
        debugCamera = self.cameraClient.GetSharedCamera('Debug Camera')
        entity = self.debugSelectionClient.GetSelectedEntity()
        if entity is None:
            self.debugSelectionClient.SelectPlayer()
            entity = self.debugSelectionClient.GetSelectedEntity()
        if entity is not None:
            entPos = entity.position.position
            position = (entPos[0], entPos[1] + DEFAULT_Y_OFFSET, entPos[2])
            debugCamera.SetPointOfInterest(position)
            debugCamera.distance = 0.0
            if debugCamera not in self.cameraClient.GetCameraStack():
                self.cameraClient.PushActiveCamera(debugCamera)
        self.cameraStack.SetText(self.PrintCameraStack())
        self.toggleCamera.SetLabel('Activate Normal Camera')
        self.toggleCamUpdate.Enable()
        self.showCamCheckBox.Show()
        sm.GetService('navigation').hasControl = debugCamera.IsControlEnabled()
        debugCamera.SetShowNormalCamera(self.showCamCheckBox.GetValue())

    def DisableDebugCamera(self):
        self.cameraClient.PopActiveCamera()
        self.cameraStack.SetText(self.PrintCameraStack())
        self.toggleCamera.SetLabel('Activate Debug Camera')
        self.toggleCamUpdate.Disable()
        self.showCamCheckBox.Hide()
        sm.GetService('navigation').hasControl = True
        debugCam = self.cameraClient.GetSharedCamera('Debug Camera')
        debugCam.SetShowNormalCamera(False)

    def OnToggleDebugCameraUpdate(self, *args):
        self.cameraDebugClient.ToggleDebugCameraUpdate()

    def PrintCameraStack(self):
        """
        Print out each camera in the stack along with all of their behaviors.
        """
        stack = self.cameraClient.GetCameraStack()
        stackStr = ''
        for i, cam in enumerate(stack):
            stackStr += str(i) + ': ' + str(cam) + '\n'
            for behavior in cam.cameraBehaviors:
                stackStr += '\t' + str(behavior) + '\n'

        stackStr = stackStr.replace('<', '').replace('>', '')
        return stackStr

    def Close(self, *args, **kwds):
        import cameras
        if type(self.cameraClient.GetActiveCamera()) is cameras.DebugCamera:
            self.DisableDebugCamera()
        Window.Close(self, *args, **kwds)