def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.sr.main.clipChildren = True self.MakeUnMinimizable() self.HideHeader() descText = attributes.missingText self.faildToLoadInfo = attributes.faildToLoadInfo title = GetByLabel('UI/Common/Information') caption = EveCaptionLarge(text=title, align=uiconst.CENTERLEFT, parent=self.sr.topParent, left=64, width=270) self.SetTopparentHeight(max(56, caption.textheight + 16)) self.SetWndIcon('res:/ui/Texture/WindowIcons/info.png') descLabel = EveLabelMedium(parent=self.sr.main, text=descText, align=uiconst.TOTOP, padding=(11, 11, defaultPadding, defaultPadding)) buttonGroup = ButtonGroup(parent=self.sr.main, unisize=1, idx=0) buyAllBtn = buttonGroup.AddButton( GetByLabel('UI/Market/MarketQuote/BuyAll'), self.BuyAll) closeBtn = buttonGroup.AddButton(GetByLabel('/Carbon/UI/Common/Close'), self.Close) if session.role & ROLE_GMH == ROLE_GMH: buttonGroup.AddButton('GM: Give all', self.GiveAllGM) self.typeScroll = Scroll(name='typeScroll', parent=self.sr.main, padding=(defaultPadding, 0, defaultPadding, 0)) self.LoadTypes(self.faildToLoadInfo)
def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) uicore.layer.systemmenu.FadeBGOut() uicore.layer.systemmenu.Hide() uicore.layer.inflight.Disable() mainCont = Container(name='mainCont', parent=self.sr.main, align=uiconst.CENTER, state=uiconst.UI_NORMAL, width=200, height=60) self.savedValue = gfxsettings.Get(gfxsettings.GFX_BRIGHTNESS) self.currentValue = self.savedValue self.gammaSlider = Slider(name='gammaSlider', parent=mainCont, minValue=0.5, maxValue=1.5, startValue=1.0, onsetvaluefunc=self.OnMySliderMoved, setlabelfunc=self.UpdateSliderLabel) self.gammaSlider.SetValue(self.ConvertValue(self.currentValue), True) buttonGroup = ButtonGroup(name='buttonGroup', parent=mainCont, align=uiconst.CENTERBOTTOM, buttonPadding=10) buttonGroup.AddButton( localization.GetByLabel('UI/Common/Buttons/Save'), self.Save) buttonGroup.AddButton( localization.GetByLabel('UI/SystemMenu/ResetSettings/Reset'), self.Reset) buttonGroup.AddButton( localization.GetByLabel('UI/Common/Buttons/Cancel'), self.Cancel)
def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.marketQuoteSvc = sm.GetService('marketQuote') self.InitializeVariables(attributes) self.SetCaption(GetByLabel(self.captionTextPath)) self.scope = 'station_inflight' self.SetTopparentHeight(0) self.mainCont = mainCont = Container(parent=self.sr.main, name='mainCont', padding=4) self.infoCont = Container(parent=mainCont, name='bottomCont', align=uiconst.TOBOTTOM, height=88, padTop=4) Line(parent=self.infoCont, align=uiconst.TOTOP) self.bottomLeft = Container(parent=self.infoCont, name='bottomLeft', padLeft=6, padTop=6) self.bottomRight = Container(parent=self.infoCont, name='bottomRight', align=uiconst.TORIGHT, width=250, padRight=6, padTop=6) self.dropCont = Container(parent=mainCont, name='dropCont', align=uiconst.TOTOP, height=28, state=uiconst.UI_NORMAL, padBottom=4) self.dropLabel = EveCaptionSmall(text=GetByLabel(self.dropLabelPath), parent=self.dropCont, align=uiconst.CENTER) self.dropLabel.opacity = 0.6 self.fakeItemsCont = Container(parent=self.dropCont, align=uiconst.TOALL, clipChildren=True) self.locationCont = Container(parent=mainCont, name='locationCont', align=uiconst.TOTOP) scrollCont = Container(parent=mainCont, name='scrollCont') self.itemsScroll = ScrollContainer(parent=scrollCont, id=self.scrollId) btnGroup = ButtonGroup(parent=self.sr.main, idx=0, line=False) btnGroup.AddButton(GetByLabel(self.tradeTextPath), self.PerformTrade, isDefault=self.tradeOnConfirm) btnGroup.AddButton(GetByLabel('UI/Generic/Cancel'), self.Cancel) self.DrawNumbers() corpAcctName = self._CanTradeForCorp() if corpAcctName is not None: self.DrawCheckBox(corpAcctName) self.globalDragHover = uicore.event.RegisterForTriuiEvents( uiconst.UI_MOUSEHOVER, self.OnGlobalMouseHover)
class NameAndDescBaseWnd(Window): default_name = 'nameAndDescBaseWnd' default_windowID = 'NameAndDescBaseWnd' default_width = 200 default_height = 200 default_topParentHeight = 0 confirmLabelPath = '' nameLabelPath = '' descriptionLabelPath = '' def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.MakeUnResizeable() self.controller = attributes.controller self.btnGroup = ButtonGroup(parent=self.sr.main, idx=0, line=True) self.btnGroup.AddButton(GetByLabel(self.confirmLabelPath), self.OnConfirmClicked) self.btnGroup.AddButton(GetByLabel('UI/Commands/Cancel'), self.Cancel) self.groupNameField = SinglelineEdit(parent=self.sr.main, align=uiconst.TOTOP, label=GetByLabel( self.nameLabelPath), padding=4, top=10, maxLength=30) EveLabelSmall(name='titleHeader', parent=self.sr.main, text=GetByLabel(self.descriptionLabelPath), align=uiconst.TOTOP, top=6, padLeft=4) self.groupDescField = EditPlainText(parent=self.sr.main, padding=(4, 0, 4, 4), maxLength=200) self.PopulateFields() def PopulateFields(self): pass def OnConfirmClicked(self, *args): name = self.groupNameField.GetValue().strip() desc = self.groupDescField.GetValue().strip() if name: self.Confirm(name, desc) self.CloseByUser() else: uicore.Message('uiwarning03') def Confirm(self, name, desc): pass def Cancel(self, *args): self.CloseByUser()
class PreviewCharacterWnd(Window): __guid__ = 'form.PreviewCharacterWnd' default_windowID = 'previewCharacterWnd' default_topParentHeight = 0 default_minSize = (420, 320) def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.charID = attributes.charID self.dna = attributes.dna self.btnGroup = ButtonGroup(parent=self.sr.main, idx=0) self.btnGroup.AddButton( localization.GetByLabel('UI/Preview/ViewPortrait'), self.SwitchToPortrait, (self.charID, )) self.previewContainer = PreviewContainer(parent=self.sr.main) self.PreviewCharacter(self.charID, dna=self.dna) def PreviewCharacter(self, charID, dna): self.charID = charID self.dna = dna caption = localization.GetByLabel('UI/InfoWindow/PortraitCaption', character=charID) self.SetCaption(caption) uthread.new(self.previewContainer.PreviewCharacter, charID, dna=dna) self.Maximize() def SwitchToPortrait(self, charID): from eve.client.script.ui.shared.info.infoWindow import PortraitWindow PortraitWindow.CloseIfOpen() portraitWnd = PortraitWindow.Open(charID=charID) portraitWnd.Maximize() self.CloseByUser() def _OnResize(self, *args, **kw): self.previewContainer.UpdateViewPort()
def BuildUI(self, thisWeek, nextWeek): self.topCont = ContainerAutoSize(name='topCont', parent=self.sr.main, alignMode=uiconst.TOTOP, align=uiconst.TOTOP, padTop=6) LineThemeColored(parent=self.topCont, align=uiconst.TOBOTTOM) self.topCont.GetAutoSize = self.GetTopContAutoSize self.comboCont = Container(parent=self.topCont, align=uiconst.TORIGHT) text = GetByLabel('UI/Structures/Deployment/ModifyingVulnerabilitySchedule', count=len(self.infoOnStructures)) EveLabelLarge(parent=self.topCont, align=uiconst.TOTOP, left=10, top=4, text=text) self.AddCombos() btnGroup = ButtonGroup(parent=self.sr.main, idx=0) saveBtn = btnGroup.AddButton(GetByLabel('UI/Common/Buttons/Save'), func=self.Save) parent = Container(parent=self.sr.main, padding=(10, 10, 10, 0)) mouseParent = Container(parent=parent, align=uiconst.TOBOTTOM, height=46) mouseCont = MouseCont(parent=mouseParent, inMoveMode=False, align=uiconst.TORIGHT_PROP, width=0.5) labelCont = GridContainer(parent=parent, align=uiconst.TOTOP, columns=2, lines=1, height=30) lableSubCont1 = Container(parent=labelCont) lableSubCont2 = Container(parent=labelCont) EveLabelMedium(parent=lableSubCont1, text=GetByLabel('UI/StructureProfiles/ThisWeek'), align=uiconst.CENTERLEFT) EveLabelMedium(parent=lableSubCont2, text=GetByLabel('UI/StructureProfiles/NextWeek'), align=uiconst.CENTERLEFT) self.leftSide = Container(parent=parent, width=0.5, align=uiconst.TOLEFT_PROP) self.rightSide = Container(parent=parent, align=uiconst.TOALL) thisWeekSchedule = structures.Schedule(thisWeek, required=self.requiredHours) w1 = VulnerabilitySchedulerWithReinforcement(parent=self.leftSide, canModify=False, schedule=thisWeekSchedule, frame=False, padRight=10) Sprite(name='lock', parent=w1.weekContParent, pos=(0, 0, 54, 64), align=uiconst.CENTER, texturePath='res:/UI/Texture/Classes/StructureDeployment/lock.png', state=uiconst.UI_DISABLED) w1.opacity = 0.3 self.nextWeekSchedule = structures.Schedule(nextWeek, required=self.requiredHours) self.w2 = VulnerabilitySchedulerWithReinforcement(parent=self.rightSide, canModify=True, schedule=self.nextWeekSchedule, frame=False, padRight=10) self.ChangeSignalConnection(connect=True)
class ConfirmTakeControl(Window): __guid__ = 'ConfirmTakeControl' default_captionLabelPath = 'UI/Station/PilotInControl' def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.MakeUnResizeable() self.controller = attributes.controller charInControl = attributes.charInControl self.SetTopparentHeight(0) self.btnGroup = ButtonGroup(parent=self.sr.main, idx=0) self.btnGroup.AddButton( localization.GetByLabel('UI/Commands/TakeStructureControl'), self.TakeControl) self.btnGroup.AddButton(localization.GetByLabel('UI/Generic/Cancel'), self.Cancel) self.playerCont = PlayerInControlCont(parent=self.sr.main, align=uiconst.CENTERTOP, addHeader=False, charID=charInControl, callback=self.OnContainerResized) self.SetCaption(localization.GetByLabel('UI/Station/PilotInControl')) self.ShowModal() def OnContainerResized(self): w, h = self.playerCont.GetAutoSize() self.height = self.btnGroup.height + h + self.sr.headerParent.height self.width = max(w, 300) def TakeControl(self, *args): try: self.controller.TakeControl() finally: self.Close() def Cancel(self, *args): self.CloseByUser()
def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.yaw = 0.0 self.pitch = 0.0 def GetModel(): selectedID = sm.GetService('state').GetExclState(state.selected) ball = sm.GetService('michelle').GetBall(selectedID) return getattr(ball, 'model', None) def Start(): self.scene = sm.GetService('space').GetScene() self.sunBallCache = self.scene.sunBall self.scene.sunBall = None self.scene.sunDirection = (0.0, 0.0, -1.0) model = GetModel() GoToX(model, 10000000000.0) Label(name='goLabel', parent=self.sr.main, align=uiconst.TOTOP, text='Fly') def GoToX(model, offset): print 'GoToX', offset model.translationCurve.gotoX = model.translationCurve.x + offset model.translationCurve.gotoY = model.translationCurve.y model.translationCurve.gotoZ = model.translationCurve.z print model.translationCurve.gotoX def FlyLeft(_): model = GetModel() GoToX(model, -10000000000.0) def FlyRight(_): model = GetModel() GoToX(model, +10000000000.0) buttonGroup = ButtonGroup(name='flyButtons', parent=self.sr.main, align=uiconst.TOTOP) buttonGroup.AddButton('Left', FlyLeft) buttonGroup.AddButton('Right', FlyRight) def Orbit(): camera = sm.GetService('sceneManager').GetActiveCamera() camera.SetOrbit(self.yaw, self.pitch) Label(name='cameraLabel', parent=self.sr.main, align=uiconst.TOTOP, text='Camera Yaw') def Yaw(button): yawDeg = float(button.name.split('_')[0]) self.yaw = DegToRad(yawDeg) Orbit() buttonGroup = ButtonGroup(name='yawButtons', parent=self.sr.main, align=uiconst.TOTOP) buttonGroup.AddButton('-135', Yaw) buttonGroup.AddButton('-90', Yaw) buttonGroup.AddButton('-45', Yaw) buttonGroup.AddButton('0', Yaw) buttonGroup.AddButton('45', Yaw) buttonGroup.AddButton('90', Yaw) buttonGroup.AddButton('135', Yaw) buttonGroup.AddButton('180', Yaw) Label(name='cameraLabel', parent=self.sr.main, align=uiconst.TOTOP, text='Camera Pitch') def Pitch(button): yawDeg = float(button.name.split('_')[0]) self.pitch = -DegToRad(yawDeg) Orbit() buttonGroup = ButtonGroup(name='pitchButtons', parent=self.sr.main, align=uiconst.TOTOP) buttonGroup.AddButton('-89', Pitch) buttonGroup.AddButton('-45', Pitch) buttonGroup.AddButton('0', Pitch) buttonGroup.AddButton('45', Pitch) buttonGroup.AddButton('89', Pitch) Label(name='controlLabel', parent=self.sr.main, align=uiconst.TOTOP, text='Sunlight') def SunDirection(button): angle = float(button.name.split('_')[0]) angleRad = DegToRad(-angle) - math.pi / 2.0 self.scene.sunDirection = (math.cos(angleRad), 0.0, math.sin(angleRad)) buttonGroup = ButtonGroup(name='sunlightButtons', parent=self.sr.main, align=uiconst.TOTOP) buttonGroup.AddButton('-135', SunDirection) buttonGroup.AddButton('-90', SunDirection) buttonGroup.AddButton('-45', SunDirection) buttonGroup.AddButton('0', SunDirection) buttonGroup.AddButton('45', SunDirection) buttonGroup.AddButton('90', SunDirection) buttonGroup.AddButton('135', SunDirection) buttonGroup.AddButton('180', SunDirection) Start()
def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.updateChatFiltersFunc = attributes.get('updateChatFiltersFunc') bannedWordsList = attributes.get('bannedWords', []) highlightWordsList = attributes.get('highlightWords', []) blinkOnHighlightWords = attributes.get('blinkOnHighlightWords', False) self.SetTopparentHeight(0) self.SetCaption( localization.GetByLabel('UI/Chat/ChannelWindow/ChatWordFilters')) self.SetMinSize([self.default_width, self.default_height]) btnGroup = ButtonGroup(btns=[], parent=self.sr.main, idx=0, line=True) btnGroup.AddButton( label=localization.GetByLabel('UI/Common/Buttons/Save'), func=self.Save, args=(), isDefault=True) btnGroup.AddButton( label=localization.GetByLabel('UI/Common/Buttons/Cancel'), func=self.Cancel, isDefault=False) padding = 4 bannedWordsCont = DragResizeCont(name='bannedWordsCont', parent=self.sr.main, align=uiconst.TOTOP_PROP, minSize=0.3, maxSize=0.7, defaultSize=0.45, padding=padding) Line(parent=bannedWordsCont.dragArea, align=uiconst.TOTOP, padLeft=-3, padRight=-3, color=(1, 1, 1, 0.15)) Line(parent=bannedWordsCont.dragArea, align=uiconst.TOBOTTOM, padLeft=-3, padRight=-3, color=(1, 1, 1, 0.15)) self.bannedWordsLabel = EveLabelMedium( parent=bannedWordsCont, name='bannedWordsLabel', align=uiconst.TOTOP, state=uiconst.UI_DISABLED, text=localization.GetByLabel( 'UI/Chat/ChannelWindow/BannedWordText'), padTop=2, padLeft=2) bannedWords = SPLITTER.join(bannedWordsList) self.bannedWordsField = EditPlainText( name='bannedWordsField', parent=bannedWordsCont, align=uiconst.TOALL, ignoreTags=True, setvalue=bannedWords, padBottom=8, hintText=localization.GetByLabel( 'UI/Chat/ChannelWindow/WordSeparatorText')) lowerCont = Container(parent=self.sr.main, name='lowerCont', align=uiconst.TOALL, padLeft=padding, padRight=padding, padTop=8, padBottom=6) self.highlightWordsLabel = EveLabelMedium( parent=lowerCont, name='highlightWordsLabel', align=uiconst.TOTOP, state=uiconst.UI_DISABLED, text=localization.GetByLabel( 'UI/Chat/ChannelWindow/HighlightWordText'), padLeft=2) self.blinkOnHighlightWordsCb = Checkbox( parent=lowerCont, name='blinkCb', checked=blinkOnHighlightWords, align=uiconst.TOBOTTOM, text=localization.GetByLabel('UI/Chat/ChannelWindow/AlwaysBlink')) highlightWords = SPLITTER.join(highlightWordsList) self.highlightWordsField = EditPlainText( name='highlightWordsField', parent=lowerCont, align=uiconst.TOALL, ignoreTags=True, setvalue=highlightWords, hintText=localization.GetByLabel( 'UI/Chat/ChannelWindow/WordSeparatorText'))
class ControlCatalogWindow(Window): default_windowID = 'ControlCatalogWindow' default_topParentHeight = 0 default_caption = 'UI Control Catalog' default_width = 900 default_height = 800 def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.entriesByID = {} self.currClassData = None self.currSampleNum = 1 self.numSamples = 0 uthread.new(self.ConstuctLayout) def ConstuctLayout(self): self.leftCont = DragResizeCont( name='leftCont', parent=self.sr.main, align=uiconst.TOLEFT_PROP, settingsID='ControlCatalogWindowLeftCont') self.infoCont = ContainerAutoSize(name='infoCont', parent=self.sr.main, align=uiconst.TOTOP, padding=6) self.topCont = DragResizeCont( name='topCont', parent=self.sr.main, align=uiconst.TOTOP_PROP, settingsID='ControlCatalogWindowSampleCont', minSize=0.3, maxSize=0.9, defaultSize=0.5, clipChildren=True) tabCont = ContainerAutoSize(name='tabCont', parent=self.topCont.mainCont, align=uiconst.TOBOTTOM) self.mainButtonGroup = ButtonGroup(name='mainButtonGroup', parent=self.sr.main) self.editCont = Container(name='editCont', parent=self.sr.main) GradientSprite(bgParent=self.leftCont, rotation=0, rgbData=[(0, (1.0, 1.0, 1.3))], alphaData=[(0.8, 0.0), (1.0, 0.05)]) self.controlScroll = ScrollContainer(parent=self.leftCont) self.PopulateScroll() self.leftButtonGroup = ButtonGroup(name='leftButtonGroup', parent=self.leftCont, idx=0) self.ConstructLeftButtonGroup() self.classNameLabel = Label(parent=self.infoCont, align=uiconst.TOTOP, fontsize=15, bold=True) self.classDocLabel = EveLabelSmall(parent=self.infoCont, align=uiconst.TOTOP) GradientSprite(align=uiconst.TOTOP, parent=self.infoCont, rotation=-math.pi / 2, height=16, padding=(-4, -10, -4, 0), rgbData=[(0, (1.0, 1.0, 1.3))], alphaData=[(0.0, 0.0), (1.0, 0.03)]) GradientSprite(align=uiconst.TOTOP, parent=tabCont, state=uiconst.UI_DISABLED, rotation=math.pi / 2, height=16, padding=(-4, 0, -4, -10), rgbData=[(0, (1.0, 1.0, 1.3))], alphaData=[(0.0, 0.0), (1.0, 0.03)]) self.sampleNameLabel = EveLabelSmall(parent=tabCont, align=uiconst.TOTOP, padBottom=5) self.tabs = ToggleButtonGroup(parent=Container(parent=tabCont, align=uiconst.TOTOP, height=16), align=uiconst.CENTER, height=16, callback=self.OnTabSelected) sampleParent = Container(name='sampleParent', parent=self.topCont.mainCont, clipChildren=True) self.sampleCont = ContainerAutoSize(name='sampleCont', parent=sampleParent, align=uiconst.CENTER) self.codeEdit = EditPlainText(parent=self.editCont, align=uiconst.TOALL, fontcolor=(1, 1, 1, 1), ignoreTags=True) self.codeEdit.OnKeyDown = self.OnCodeEditKeyDown self.ConstructMainButtonGroup() uthread.new(self._SpyOnSampleCodeReloadThread) def OnSampleFileReload(self, path): self.PopulateScroll() self.SetSelectedControl(self.currClassData) def _SpyOnSampleCodeReloadThread(self): try: from eve.common.modules.sake.platform.win32.win32api import Waitables from eve.common.modules.sake.autocompile import SpyFolder class ControlCatalogSpyFolder(SpyFolder): def __init__(self, callback, *args, **kw): SpyFolder.__init__(self, *args, **kw) self.callback = callback def process_folder(self, path): try: self.callback(path) except Exception as e: log.LogException(e) spy = ControlCatalogSpyFolder( self.OnSampleFileReload, Waitables(), (os.path.abspath(os.path.dirname(__file__)), )) while not self.destroyed: spy.waitables.Wait(0) blue.pyos.synchro.Sleep(50) except ImportError: pass def ConstructLeftButtonGroup(self): for label, func in (('Browse', self.BrowseControls), ): self.leftButtonGroup.AddButton(label, func) def ConstructMainButtonGroup(self): for label, func, hint in (('Reload', self.ReloadSamples, 'Reload all sample code [ctrl+s]'), ('Edit module', self.OpenModuleCodeInEditor, 'Open module containing class in editor'), ('Edit samples', self.OpenSampleCodeInEditor, 'Open sample code in editor')): self.mainButtonGroup.AddButton(label, func, hint=hint) def OpenSampleCodeInEditor(self, *args): self.currClassData.OpenSampleCodeInEditor() def BrowseControls(self, *args): controlData.BrowseControls() def OpenModuleCodeInEditor(self, *args): self.currClassData.OpenModuleCodeInEditor() def PopulateScroll(self): self.controlScroll.Flush() for data in controlData.GetControlData(): TreeViewEntry(parent=self.controlScroll, data=data, eventListener=self) if self.currClassData and self.currClassData.GetID() == data.GetID( ): self.currClassData = data def RegisterID(self, entry, entryID): if entryID in self.entriesByID: raise ValueError('Same entry registered again: %s' % entryID) self.entriesByID[entryID] = entry def UnregisterID(self, entryID): self.entriesByID.pop(entryID) def OnTreeViewClick(self, selected): if selected.data.HasChildren(): selected.ToggleChildren() else: for entry in self.entriesByID.values(): entry.UpdateSelectedState((selected.data.GetID(), )) self.currSampleNum = 1 self.SetSelectedControl(selected.data) def SetSelectedControl(self, data): self.codeEdit.Clear() self.sampleCont.Flush() self.codeEdit.SetText(data.GetCode(), html=False) self.currClassData = data self.UpdateInfoCont() self.ReloadSamples() def UpdateInfoCont(self): cls = self.currClassData.GetBaseClass() if not hasattr(cls, '__module__'): raise RuntimeError( 'Unable to identify sample class. IMPORTANT: Make sure the first line in the example imports the example class itself.' ) self.classNameLabel.text = '<center>' + cls.__module__ + '.' + cls.__name__ doc = cls.__doc__ or '' self.classDocLabel.text = '<center>' + doc.strip() if 'depricated' in doc.lower(): self.classNameLabel.text = '<color=red>' + self.classNameLabel.text self.classDocLabel.text = '<color=red>' + self.classDocLabel.text def GetCodeText(self): return self.codeEdit.GetAllText() def ReloadSamples(self, *args): numSamples = controlData.GetNumSamples(self.GetCodeText()) if numSamples != self.numSamples: self.numSamples = numSamples self.ReconstructTabs() self.tabs.SelectByID(self.currSampleNum) def ReconstructTabs(self): self.tabs.ClearButtons() for i in xrange(1, self.numSamples + 1): self.tabs.AddButton(i, 'Sample %s' % i) self.tabs.width = self.numSamples * 65 def OnTabSelected(self, sampleNum): self.currSampleNum = sampleNum self.ReloadCurrentSample() def ReloadCurrentSample(self): self.sampleCont.Flush() uicore.animations.FadeTo(self.sampleCont, 0.0, 1.0, 0.1) if self.numSamples: exec(self.GetCodeText() + '\n', globals()) exec 'Sample%s(parent=self.sampleCont)' % self.currSampleNum sampleName = None exec 'sampleName = Sample%s.__doc__' % self.currSampleNum if sampleName: self.sampleNameLabel.Show() self.sampleNameLabel.text = '<center>' + sampleName else: self.sampleNameLabel.Hide() self.sampleNameLabel.text = '' def OnCodeEditKeyDown(self, key, flag): if uicore.uilib.Key(uiconst.VK_CONTROL) and key == uiconst.VK_S: self.ReloadSamples() else: return EditPlainText.OnKeyDown(self.codeEdit, key, flag)
class LanguageWindow(Window): __guid__ = 'LanguageWindow' default_windowID = 'bilingualWindow' default_captionLabelPath = 'UI/LanguageWindow/BilingualFunctionalityHeader' default_iconNum = 'res:/ui/Texture/WindowIcons/Settings.png' def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.SetWndIcon('res:/ui/Texture/WindowIcons/Settings.png', mainTop=-6) self.SetMainIconSize(64) self.width = 350 self.height = 400 self.MakeUnResizeable() self.currentComboValue = localization.settings.bilingualSettings.GetValue( 'localizationImportantNames') WndCaptionLabel( text=GetByLabel('UI/LanguageWindow/BilingualFunctionalityHeader'), parent=self.sr.topParent, align=uiconst.RELATIVE) self.autoSizeMain = ContainerAutoSize( parent=self.sr.main, name='autoSizeMain', align=uiconst.TOTOP, callback=self.OnAutoSizeMainResize, padLeft=2, padRight=2) text = GetByLabel('UI/LanguageWindow/BodyText') EveLabelMedium(text=text, parent=self.autoSizeMain, align=uiconst.TOTOP, padding=(10, 4, 10, 0)) self.btnGroup = ButtonGroup(parent=self.sr.main, idx=0) self.btnGroup.AddButton(GetByLabel('UI/Commands/Apply'), self.Save) self.btnGroup.AddButton(GetByLabel('UI/Common/Close'), self.Cancel) grid = LayoutGrid(parent=self.autoSizeMain, align=uiconst.TOTOP, columns=2, name='grid', padTop=10, padLeft=20, cellSpacing=4) languageID = ConvertLanguageIDToMLS(session.languageID) self.currentLanguageString = GetByLabel( mlsToDisplayNamePaths[languageID]) text = GetByLabel('UI/SystemMenu/Language/Display') comboLabel = EveLabelMedium(text=text, parent=grid, align=uiconst.TOPLEFT, state=uiconst.UI_NORMAL) comboLabel.hint = GetByLabel( 'UI/SystemMenu/Language/ImportantNamesExplanation') options = [(self.currentLanguageString, 0), (GetByLabel('UI/SystemMenu/Language/EnglishReplacement'), IMPORTANT_EN_OVERRIDE)] self.displayCombo = Combo( label='', parent=grid, options=options, name='displayCombo', select=self.currentComboValue, width=115, pos=(10, 0, 0, 0), align=uiconst.TOPLEFT, callback=self.OnComboChanged, hint=GetByLabel( 'UI/SystemMenu/Language/ImportantNamesExplanation')) tooltipText = self.GetTooltipCheckboxText() checked = localization.settings.bilingualSettings.GetValue( 'languageTooltip') self.tooltipCB = Checkbox(text=tooltipText, parent=None, configName='tooltipsCB', checked=checked, align=uiconst.TOPLEFT, width=300) grid.AddCell(cellObject=self.tooltipCB, colSpan=grid.columns) hiliteImportantText = GetByLabel( 'UI/SystemMenu/Language/HighlightImportantNames') checked = localization.settings.bilingualSettings.GetValue( 'localizationHighlightImportant') self.importantCB = Checkbox(text=hiliteImportantText, parent=None, configName='importantNamesCB', checked=checked, align=uiconst.TOPLEFT, width=300) grid.AddCell(cellObject=self.importantCB, colSpan=grid.columns) text = localization.GetByLabel('UI/LanguageWindow/ChangeSettingsInEsc') EveLabelMedium(text=text, parent=self.autoSizeMain, align=uiconst.TOTOP, padding=(10, 10, 10, 0)) Line(parent=self.autoSizeMain, align=uiconst.TOTOP, color=(1, 1, 1, 0.1), padTop=4, padBottom=2) text = GetByLabel('UI/Messages/TxtSuppress2Body') self.suppressCb = Checkbox(text=text, parent=self.autoSizeMain, configName='importantNamesCB', retval=0, checked=0, align=uiconst.TOTOP, padLeft=6) def OnAutoSizeMainResize(self): headerHeight = self.GetCollapsedHeight() captionHeight = self.topParentHeight if getattr(self, 'btnGroup', None): buttonHeight = self.btnGroup.height else: buttonHeight = 0 autoContainerSize = self.autoSizeMain.height + self.autoSizeMain.padTop + self.autoSizeMain.padBottom + buttonHeight newheight = headerHeight + captionHeight + autoContainerSize if newheight != self.height: self.height = newheight self.SetFixedHeight(self.height) def GetTooltipCheckboxText(self): if self.currentComboValue == localization.const.IMPORTANT_EN_OVERRIDE: tooltipText = GetByLabel( 'UI/SystemMenu/Language/ShowTooltipInLanguage', language=self.currentLanguageString) else: english = GetByLabel(mlsToDisplayNamePaths['EN']) tooltipText = GetByLabel( 'UI/SystemMenu/Language/ShowTooltipInLanguage', language=english) return tooltipText def OnComboChanged(self, combo, key, value, *args): self.currentComboValue = value tooltipText = self.GetTooltipCheckboxText() self.tooltipCB.SetLabel(tooltipText) def Save(self, *args): changeMade = False importantNamesLocalized = self.displayCombo.GetValue() if self.GetLanguageSetting( 'localizationImportantNames') != importantNamesLocalized: changeMade = True self.SetLanguageSetting('localizationImportantNames', importantNamesLocalized) tooltipChecked = self.tooltipCB.checked if self.GetLanguageSetting('languageTooltip') != tooltipChecked: changeMade = True self.SetLanguageSetting('languageTooltip', tooltipChecked) importantNameChecked = self.importantCB.checked if self.GetLanguageSetting( 'localizationHighlightImportant') != importantNameChecked: changeMade = True self.SetLanguageSetting('localizationHighlightImportant', importantNameChecked) localization.ClearImportantNameSetting() self.StoreSuppressSettingAndCloseWindow() if changeMade: localization.settings.bilingualSettings.UpdateAndSaveSettings() sm.ChainEvent('ProcessUIRefresh') sm.ScatterEvent('OnUIRefresh') def Cancel(self, *args): self.StoreSuppressSettingAndCloseWindow() def StoreSuppressSettingAndCloseWindow(self): suppressedChecked = self.suppressCb.checked if suppressedChecked: settings.user.suppress.Set('suppress.Bilingual_suppressMessage', True) self.CloseByUser() def GetLanguageSetting(self, configName): return localization.settings.bilingualSettings.GetValue(configName) def SetLanguageSetting(self, configName, value): return localization.settings.bilingualSettings.SetValue( configName, value)
class BrowserJobs(Container): default_name = 'BrowserJobs' __notifyevents__ = [ 'OnIndustryJob', 'OnFacilityReload', 'OnSessionChanged' ] def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) sm.RegisterNotify(self) self.callback = attributes.callback self.isInitialized = False def _OnClose(self, *args): sm.UnregisterNotify(self) def OnTabSelect(self): if self.isInitialized: self.UpdateOwnerCombo() self.UpdateInstallerCombo() self.UpdateScroll() return self.isInitialized = True self.topPanel = Container(name='topPanel', parent=self, align=uiconst.TOTOP, height=20, padding=(0, 6, 0, 6)) self.bottomButtons = ButtonGroup(parent=self) self.deliverSelectedBtn = self.bottomButtons.AddButton( localization.GetByLabel('UI/Industry/DeliverSelectedJobs'), self.DeliverSelectedJobs) self.deliverAllBtn = self.bottomButtons.AddButton( localization.GetByLabel('UI/Industry/DeliverAllJobs'), self.DeliverAllJobs) self.scroll = Scroll(parent=self, id='JobBrowser') self.scroll.OnSelectionChange = self.OnScrollSelectionChange self.scroll.Confirm = self.OnScrollReturn self.viewModeButtons = ViewModeButtons( parent=self.topPanel, align=uiconst.TORIGHT, controller=self, settingsID='IndustryBlueprintBrowserViewMode') self.ownerCombo = Combo(name='ownerCombo', parent=self.topPanel, align=uiconst.TOLEFT, callback=self.OnOwnerCombo, width=120, padRight=4) self.statusCombo = Combo(name='statusCombo', parent=self.topPanel, align=uiconst.TOLEFT, prefsKey='IndustryJobStatus', callback=self.OnStatusCombo, width=120, padRight=4) self.activityCombo = Combo(name='activityCombo', parent=self.topPanel, align=uiconst.TOLEFT, prefsKey='IndustryBlueprintActivity', callback=self.OnActivityCombo, options=self.GetActivityOptions(), width=120, padRight=4) self.installerCombo = Combo(name='installerCombo', parent=self.topPanel, align=uiconst.TOLEFT, callback=self.OnInstallerCombo, options=self.GetInstallerOptions(), width=140, padRight=4) self.filterEdit = QuickFilterEdit( name='searchField', parent=self.topPanel, hinttext=localization.GetByLabel('UI/Inventory/Filter'), maxLength=64, align=uiconst.TORIGHT, OnClearFilter=self.OnFilterEditCleared, padRight=4) self.filterEdit.ReloadFunction = self.OnFilterEdit self.UpdateStatusCombo() self.UpdateOwnerCombo() self.UpdateInstallerCombo() self.UpdateScroll() uthread.new(self._UpdateJobCountersThread) def OnTabDeselect(self): if self.isInitialized: self.scroll.Clear() def OnScrollSelectionChange(self, entries): if entries: self.callback(entries[0].jobData) self.UpdateDeliverButtons() def OnScrollReturn(self, *args): self.DeliverJobs(self.scroll.GetSelected()) def OnFilterEdit(self): self.UpdateScroll() def OnFilterEditCleared(self): self.UpdateScroll() def OnViewModeChanged(self, viewMode): self.UpdateScroll() def OnIndustryJob(self, jobID, ownerID, blueprintID, installerID, status, successfulRuns): """ Server telling us that a job changed it's state """ if self.destroyed or self.IsHidden(): return if self.isInitialized and self.display: self.UpdateJobEntry(jobID, status, successfulRuns) self.UpdateDeliverButtons() def OnFacilityReload(self, facilityID): """ Server telling us a facility was modified. If this applies to any jobs currently displayed then we should reload the scroll. """ if self.destroyed or self.IsHidden(): return if self.isInitialized and self.display: for node in self.scroll.GetNodes(): if facilityID is None or node.jobData.facilityID == facilityID: self.UpdateScroll() return def OnSessionChanged(self, isRemote, session, change): """ If we change solarsystem then reload the jobs tab. """ if 'solarsystemid2' in change or 'stationid2' in change: self.UpdateScroll() if 'corpid' in change: self.UpdateOwnerCombo() self.UpdateScroll() def UpdateJobEntry(self, jobID, status, successfulRuns): """ Update the state of an individual job entry """ for node in self.scroll.GetNodes(): if node.jobData.jobID == jobID and node.panel: node.panel.OnStatusChanged(status, successfulRuns) break else: self.UpdateScroll() def IsSomeJobReady(self): for node in self.scroll.GetNodes(): if node.jobData.status == industry.STATUS_READY: return True return False def IsSomeReadyJobSelected(self): for node in self.scroll.GetSelected(): if node.jobData.status == industry.STATUS_READY: return True return False def UpdateDeliverButtons(self): self.deliverAllBtn.display = self.IsSomeJobReady() self.bottomButtons.display = self.deliverAllBtn.display self.deliverSelectedBtn.display = self.IsSomeReadyJobSelected() self.bottomButtons.ResetLayout() def UpdateScroll(self): if not self.isInitialized: return statusFilter = self.statusCombo.selectedValue jobs = self.GetJobData(statusFilter == STATUS_COMPLETED) scrollList = self.GetScrollList(jobs) self.scroll.sr.defaultColumnWidth = JobEntry.GetDefaultColumnWidth() isPersonalJob = self.ownerCombo.GetValue() == OWNER_ME self.scroll.LoadContent( contentList=scrollList, headers=JobEntry.GetHeaders(isPersonalJob=isPersonalJob), noContentHint=localization.GetByLabel('UI/Industry/NoJobsFound')) self.UpdateDeliverButtons() def GetJobData(self, includeCompleted): if self.IsCorpSelected(): jobs = sm.GetService('industrySvc').GetCorporationJobs( includeCompleted) else: jobs = sm.GetService('industrySvc').GetCharacterJobs( includeCompleted) return jobs def GetScrollList(self, jobs): scrollList = [] for jobData in jobs: if self.IsFilteredOut(jobData): continue node = Bunch(jobData=jobData, decoClass=JobEntry, sortValues=JobEntry.GetColumnSortValues( jobData, jobData.distance), viewMode=self.viewModeButtons.GetViewMode(), jumps=max(0, jobData.distance)) scrollList.append(node) return scrollList def IsFilteredOut(self, jobData): statusFilter = self.statusCombo.selectedValue if statusFilter == STATUS_INCOMPLETE and jobData.completed or statusFilter == STATUS_READY and not jobData.status == industry.STATUS_READY or statusFilter == STATUS_INSTALLED and not jobData.status == industry.STATUS_INSTALLED or statusFilter == STATUS_COMPLETED and not jobData.completed or statusFilter == STATUS_PAUSED and not jobData.status == industry.STATUS_PAUSED: return True if self.IsCorpSelected(): installerType = self.installerCombo.GetValue() if installerType == INSTALLER_ME and jobData.installerID != session.charid: return True if installerType == INSTALLER_CORPMATE and jobData.installerID == session.charid: return True filterText = self.filterEdit.GetValue().strip().lower() if filterText: text = jobData.blueprint.GetName() + jobData.GetFacilityName( ) + jobData.GetInstallerName() if text.lower().find(filterText) == -1: return True activityValue = self.activityCombo.GetValue() if activityValue and activityValue != jobData.activityID: return True return False def OnStatusCombo(self, combo, key, value): settings.user.ui.Set('IndustryJobBrowserStatus', value) self.UpdateScroll() def UpdateStatusCombo(self): options = ((localization.GetByLabel('UI/Industry/StatusAllActiveJobs'), STATUS_INCOMPLETE), (localization.GetByLabel('UI/Industry/StatusInProgress'), STATUS_INSTALLED, None, STATUS_ICONS[STATUS_INSTALLED]), (localization.GetByLabel('UI/Industry/StatusReady'), STATUS_READY, None, STATUS_ICONS[STATUS_READY]), (localization.GetByLabel('UI/Industry/StatusHalted'), STATUS_PAUSED, None, STATUS_ICONS[STATUS_PAUSED]), (localization.GetByLabel('UI/Industry/StatusHistory'), STATUS_COMPLETED, None, STATUS_ICONS[STATUS_COMPLETED])) select = settings.user.ui.Get('IndustryJobBrowserStatus', STATUS_INCOMPLETE) self.statusCombo.LoadOptions(options, select=select) def OnActivityCombo(self, *args): self.UpdateScroll() def GetActivityOptions(self): ret = [ (localization.GetByLabel(ACTIVITY_NAMES[activityID]), activityID, None, industryUIConst.ACTIVITY_ICONS_SMALL[activityID]) for activityID in industry.ACTIVITIES ] ret.insert(0, (localization.GetByLabel('UI/Industry/AllActivities'), 0)) return ret def GetInstallerOptions(self): return ((localization.GetByLabel('UI/Industry/InstalledByAnyone'), INSTALLER_ANY), (localization.GetByLabel('UI/Industry/InstalledByMe'), INSTALLER_ME, None, 'res:/UI/Texture/classes/Industry/iconPersonal.png'), (localization.GetByLabel('UI/Industry/InstalledByCorpmates'), INSTALLER_CORPMATE, None, 'res:/UI/Texture/classes/Industry/iconCorp.png')) def OnInstallerCombo(self, combo, key, value): settings.user.ui.Set('IndustryJobsBrowserInstaller', value) self.UpdateScroll() def UpdateInstallerCombo(self): self.installerCombo.display = self.IsCorpSelected() value = settings.user.ui.Get('IndustryJobsBrowserInstaller', INSTALLER_ANY) self.installerCombo.SelectItemByValue(value) def OnOwnerCombo(self, combo, key, value): settings.user.ui.Set('IndustryBlueprintBrowserOwner', value) self.UpdateInstallerCombo() self.UpdateScroll() def IsCorpSelected(self): return self.ownerCombo.GetValue() == OWNER_CORP def UpdateOwnerCombo(self): options = [(localization.GetByLabel('UI/Industry/OwnedByMe'), OWNER_ME) ] if sm.GetService('blueprintSvc').CanSeeCorpBlueprints(): options.append((localization.GetByLabel('UI/Industry/OwnedByCorp'), OWNER_CORP, None, 'res:/UI/Texture/classes/Industry/iconCorp.png')) select = settings.user.ui.Get('IndustryBlueprintBrowserOwner', OWNER_ME) self.ownerCombo.LoadOptions(options, select=select) def _UpdateJobCountersThread(self): msecs = 0 while not self.destroyed: animate = False msecs += INTERVAL_UPDATE if msecs >= INTERVAL_FLASH: msecs = 0 animate = True nodes = self.scroll.GetVisibleNodes() for i, node in enumerate(nodes): if node.panel: node.panel.UpdateValues(animate, i) blue.synchro.SleepWallclock(INTERVAL_UPDATE) def DeliverAllJobs(self, *args): self.DeliverJobs(self.scroll.GetNodes()) def DeliverSelectedJobs(self, *args): self.DeliverJobs(self.scroll.GetSelected()) def DeliverJobs(self, nodes): jobIDs = [ node.jobData.jobID for node in nodes if node.jobData.status == industry.STATUS_READY ] sm.GetService('industrySvc').CompleteJobs(jobIDs) sm.GetService('audio').SendUIEvent('ind_jobDelivered')
class TwitchStreaming(Window): __guid__ = 'form.TwitchStreaming' __notifyevents__ = ['OnTwitchStreamingStateChange'] default_topParentHeight = 0 default_windowID = 'Twitch' default_captionLabelPath = 'Tooltips/Neocom/Twitch' default_descriptionLabelPath = 'Tooltips/Neocom/Twitch_description' default_iconNum = 'res:/UI/Texture/windowIcons/twitch.png' default_fixedWidth = 260 default_fixedHeight = 440 def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) sm.RegisterNotify(self) self.streamBtn = None self.topCont = ContainerAutoSize(name='topCont', parent=self.sr.main, align=uiconst.TOTOP, padding=(10, 10, 10, 0)) self.loginCont = Container(name='loginCont', parent=self.sr.main, align=uiconst.TOTOP, height=120, padding=5) self.settingsCont = ContainerAutoSize(name='settingsCont', parent=self.sr.main, align=uiconst.TOTOP, padding=5) self.ConstructTopCont() self.ConstructLoginCont() self.ConstructSettingsCont() self.ConstructBottomButtons() self.bottomGradient = GradientSprite(bgParent=self.btnGroup, rotation=-pi / 2, rgbData=[(0, (0.3, 0.3, 0.3))], alphaData=[(0, 0.3), (0.9, 0.0)]) self.UpdateState() self.CheckEnableStreamBtn() if bool(session.role & ROLE_PROGRAMMER): self.debugLabel = Label(parent=self.topCont, align=uiconst.TOPLEFT, top=120) def ConstructTopCont(self): Sprite(name='twitchLogo', parent=self.topCont, texturePath='res:/UI/Texture/Classes/Twitch/logo.png', pos=(0, 0, 200, 69)) self.stateIcon = TwitchStateIcon(parent=self.topCont, align=uiconst.TOPLEFT, pos=(0, 80, 32, 32), func=self.OnStateIconClick, controller=self) self.loadingWheel = LoadingWheel(parent=self.topCont, align=uiconst.TOPLEFT, pos=(-16, 64, 64, 64), opacity=0.0) self.stateLabel = EveCaptionMedium(parent=self.topCont, pos=(40, 87, 210, 0)) def OnStateIconClick(self): blue.os.ShellExecute(self.GetTwitchChannelURL()) def GetTwitchChannelURL(self): return '%s/%s' % (TWITCH_URL, self.usernameCont.GetValue()) def ConstructLoginCont(self): Line(parent=self.loginCont, align=uiconst.TOTOP, padBottom=10, opacity=0.1) EveCaptionSmall(parent=self.loginCont, align=uiconst.TOTOP, text=GetByLabel('UI/Twitch/LoginCaption')) twitchSvc = sm.GetService('twitch') username = twitchSvc.GetUsername() if username is None or not twitchSvc.HasToken(): password = None else: password = PASSWORD_IF_HAS_TOKEN self.usernameCont = EditWithLabel(parent=self.loginCont, text=GetByLabel('UI/Login/Username'), value=username, OnChange=self.CheckEnableStreamBtn) self.passwordCont = EditWithLabel(parent=self.loginCont, text=GetByLabel('UI/Login/Password'), OnReturn=self.StartStream, OnChange=self.CheckEnableStreamBtn, OnSetFocus=self.OnPasswordContFocus) self.passwordCont.edit.SetPasswordChar(u'\u2022') self.passwordCont.edit.SetValue(password) Label(parent=self.loginCont, align=uiconst.TOTOP, state=uiconst.UI_NORMAL, padding=(LABELWIDTH, 7, 0, 0), text=GetByLabel('UI/Twitch/SignupLink'), fontsize=10) Line(parent=self.loginCont, align=uiconst.TOBOTTOM, idx=0, opacity=0.1) def ConstructSettingsCont(self): EveCaptionSmall(parent=self.settingsCont, align=uiconst.TOTOP, text=GetByLabel('UI/Twitch/StreamSettings')) title = sm.GetService('twitch').GetTitle() self.streamTitleCont = EditWithLabel( parent=self.settingsCont, text=GetByLabel('UI/Twitch/StreamTitle'), value=title, OnReturn=self.StartStream) self.resolutionCombo = ComboWithLabel( name='resolutionCombo', parent=self.settingsCont, text=GetByLabel('UI/Twitch/Resolution'), options=sm.GetService('twitch').GetResolutionOptions(), callback=self.OnResolutionCombo) currResolution = (uicore.desktop.width, uicore.desktop.height) self.resolutionCombo.combo.SelectItemByValue(currResolution) self.fpsCombo = ComboWithLabel( name='resolutionCombo', parent=self.settingsCont, text=GetByLabel('UI/Twitch/Framerate'), options=sm.GetService('twitch').GetFramerateOptions(), select=sm.GetService('twitch').GetFPS()) def ConstructBottomButtons(self): self.btnGroup = ButtonGroup(parent=self.sr.main, idx=0, line=False) self.btnGroup.AddButton(GetByLabel('UI/Generic/Close'), self.CloseByUser) self.streamBtn = self.btnGroup.AddButton( GetByLabel('UI/Twitch/StartStream'), self.StartStream) def UpdateState(self): state, stateName = twitch.get_api_state() if state <= twitch.api.STATE.FOUND_INGEST_SERVER: text = GetByLabel('UI/Twitch/StreamingInactive') btnLabel = GetByLabel('UI/Twitch/StartStream') btnFunc = self.StartStream color = COLOR_STOPPED self.EnableInputFields() elif state == twitch.api.STATE.STREAMING: text = GetByLabel('UI/Twitch/StreamingToTwitch') btnLabel = GetByLabel('UI/Twitch/StopStream') btnFunc = self.StopStream color = COLOR_STREAMING self.DisableInputFields() uicore.animations.FadeTo(self.stateLabel, 0.7, 1.2, loops=ANIM_REPEAT, curveType=ANIM_WAVE, duration=3.6) else: raise RuntimeError('unhandled state: %s (%s)' % (state, stateName)) self.stateIcon.icon.SetRGBA(*color) self.stateLabel.text = text self.stateLabel.SetRGBA(*color) self.streamBtn.SetLabel(btnLabel) self.streamBtn.func = btnFunc def CheckEnableStreamBtn(self, *args): if not self.streamBtn: return if self.IsUsernameOrPasswordBlank(): self.streamBtn.Disable() else: self.streamBtn.Enable() def OnPasswordContFocus(self, *args): self.passwordCont.edit.SetValue(u'') def IsUsernameOrPasswordBlank(self): return not self.usernameCont.GetValue( ) or not self.passwordCont.GetValue() def GetInputFields(self): return (self.loginCont, self.settingsCont) def EnableInputFields(self): for uiObj in self.GetInputFields(): uiObj.Enable() uiObj.opacity = 1.0 def DisableInputFields(self): for uiObj in self.GetInputFields(): uiObj.Disable() uiObj.opacity = 0.3 def StartStream(self, *args): username = str(self.usernameCont.GetValue()) password = str(self.passwordCont.GetValue(raw=True)) if not username or not password: return self.UpdateResolution() try: self.ShowLoading() if password == PASSWORD_IF_HAS_TOKEN: password = None title = self.streamTitleCont.GetValue() fps = self.fpsCombo.GetValue() sm.GetService('twitch').StartStream(username, password, title, fps) self.passwordCont.edit.SetValue(PASSWORD_IF_HAS_TOKEN) self.usernameCont.SetCorrect() self.passwordCont.SetCorrect() except Exception as e: self.passwordCont.edit.SetValue(u'') self.usernameCont.SetIncorrect() self.passwordCont.SetIncorrect() if str(e) != 'TTV_EC_API_REQUEST_FAILED': raise finally: self.HideLoading(delay=3000) self.UpdateState() def StopStream(self, *args): try: self.ShowLoading() sm.GetService('twitch').StopStream() finally: self.HideLoading() self.UpdateState() def OnResolutionCombo(self, combo, label, resolution): self.UpdateResolution() def UpdateResolution(self): width, height = self.resolutionCombo.GetValue() deviceSvc = sm.GetService('device') settings = deviceSvc.GetSettings().copy() if settings.BackBufferWidth == width and settings.BackBufferHeight == height: return settings.BackBufferWidth = width settings.BackBufferHeight = height deviceSvc.SetDevice(settings, userModified=True) def ShowLoading(self): self.streamBtn.Disable() uicore.animations.FadeOut(self.stateIcon) uicore.animations.FadeOut(self.stateLabel) uicore.animations.FadeIn(self.loadingWheel, timeOffset=0.3) def HideLoading(self, delay=None): uicore.animations.FadeOut(self.loadingWheel) uicore.animations.FadeIn(self.stateIcon, timeOffset=0.3) uicore.animations.FadeIn(self.stateLabel, timeOffset=0.6) if delay: uthread.new(self.EnableStreamBtnWithDelay, delay) else: self.streamBtn.Enable() def EnableStreamBtnWithDelay(self, delay): blue.synchro.SleepWallclock(delay) self.streamBtn.Enable() def OnTwitchStreamingStateChange(self, state): self.UpdateState() if bool(session.role & ROLE_PROGRAMMER): _, stateName = twitch.get_api_state() self.debugLabel.text = 'DEBUG INFO: %s' % stateName def GetNeocomButtonType(self): return BTNTYPE_TWITCH
class ChannelPasswordWindow(Window): MAX_TRIES = 3 def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.title = attributes.title self.channelID = attributes.channelID self.channelName = attributes.channelName self.displayName = attributes.displayName self.SetMinSize([250, 250]) self.SetCaption(localization.GetByLabel('UI/Menusvc/PasswordRequired')) self.SetTopparentHeight(0) self.tries = 0 settings.user.ui.Set('%sPassword' % self.channelName, '') parentGrid = LayoutGrid(parent=self.sr.main, columns=1, state=uiconst.UI_PICKCHILDREN, align=uiconst.TOPLEFT, left=10, top=4) topLabel = EveLabelMedium(text=attributes.title, state=uiconst.UI_DISABLED, align=uiconst.TOPLEFT, width=300) parentGrid.AddCell(cellObject=topLabel) passwordLabel = localization.GetByLabel( 'UI/Menusvc/PleaseEnterPassword') self.passwordLabel = EveLabelMedium(text=passwordLabel, state=uiconst.UI_DISABLED, align=uiconst.TOPLEFT, padTop=10) parentGrid.AddCell(cellObject=self.passwordLabel) self.passwordEdit = SinglelineEdit(name='passwordEdit', align=uiconst.TOTOP, passwordCharacter=u'\u2022', top=4) parentGrid.AddCell(cellObject=self.passwordEdit) savePasswordLabel = localization.GetByLabel('UI/Chat/SavePassword') self.rememberPwdCb = Checkbox(text=savePasswordLabel, configName='rememberPwdCb', retval=1, checked=0, groupname=None, align=uiconst.TOTOP) parentGrid.AddCell(cellObject=self.rememberPwdCb) parentGrid.RefreshGridLayout() self.btnGroup = ButtonGroup(parent=self.sr.main, idx=0) self.btnGroup.AddButton( localization.GetByLabel('UI/Chat/ChannelWindow/JoinChannel'), self.TryPassword, ()) self.btnGroup.AddButton(localization.GetByLabel('UI/Common/Cancel'), self.Close, ()) self.height = self.btnGroup.height + parentGrid.height + self.sr.headerParent.height + parentGrid.top + 10 self.width = parentGrid.width + 2 * parentGrid.left self.MakeUnResizeable() self.MakeUnMinimizable() self.MakeUncollapseable() def TryPassword(self): password = self.passwordEdit.GetValue() password = password.strip() if len(password) < 1: eve.Message('CustomInfo', { 'info': localization.GetByLabel('UI/Common/PleaseTypeSomething') }) return self.tries += 1 savePassword = self.rememberPwdCb.GetValue() didWork = sm.GetService('LSC').TryOpenChannel(self.channelID, self.channelName, password, savePassword) if didWork is True: self.Close() return self.passwordEdit.SetValue('') uicore.Message('uiwarning03') self.passwordLabel.text = localization.GetByLabel( 'UI/Menusvc/PleaseTryEnteringPasswordAgain') if self.tries >= self.MAX_TRIES: if didWork is False and password is not None: sm.GetService('LSC').OpenChannel( self.channelID, 0, ('LSCWrongPassword', { 'channelName': self.displayName })) self.Close()