def __init__(self, data): self._width = 350 self._height = 200 self._rootWidget = bs.containerWidget( size=(self._width, self._height), color=(0.45, 0.63, 0.15), transition='inScale', scale=1.8 if bsUI.gSmallUI else 1.35 if bsUI.gMedUI else 1.0) self._data = copy.deepcopy(data) bs.playSound(bs.getSound('cashRegister')) bs.playSound(bs.getSound('swish')) self._cancelButton = bs.buttonWidget(parent=self._rootWidget, scale=0.5, position=(40, self._height - 40), size=(50, 50), label='', onActivateCall=self.close, autoSelect=True, color=(0.45, 0.63, 0.15), icon=bs.getTexture('crossOut'), iconScale=1.2) bs.containerWidget(edit=self._rootWidget, cancelButton=self._cancelButton) t = bs.textWidget(parent=self._rootWidget, position=(self._width * 0.5, self._height * 0.5), size=(0, 0), color=(1.0, 3.0, 1.0), scale=2.0, hAlign="center", vAlign="center", text=data['code'], maxWidth=self._width * 0.85)
def _refresh(self, selectGetMoreGamesButton=False, selected=None): if self._column is not None: self._column.delete() # for c in self._column.getChildren(): # c.delete() self._column = bs.columnWidget(parent=self._scrollWidget) gameTypes = [gt for gt in bsUtils.getGameTypes() if gt.supportsSessionType(self._editSession._sessionType)] # sort in this language gameTypes.sort(key=lambda g:g.getNameLocalized()) for i, gameType in enumerate(gameTypes): t = bs.textWidget(parent=self._column,position=(0,0),size=(self._width-88,24),text=gameType.getNameLocalized(), hAlign="left",vAlign="center", color=(0.8,0.8,0.8,1.0), maxWidth=self._scrollWidth*0.8, onSelectCall=bs.Call(self._setSelectedGameType,gameType), alwaysHighlight=True, selectable=True,onActivateCall=bs.Call(bs.realTimer,100,self._selectButton.activate)) if i == 0: bs.widget(edit=t, upWidget=self._backButton) if gameType == selected: bs.containerWidget(edit=self._column,selectedChild=t,visibleChild=t) self._getMoreGamesButton = bs.buttonWidget(parent=self._column,autoSelect=True, label=self._R.getMoreGamesText, color=(0.54,0.52,0.67), textColor=(0.7,0.65,0.7), onActivateCall=self._onGetMoreGamesPress, size=(178,50)) if selectGetMoreGamesButton: bs.containerWidget(edit=self._column,selectedChild=self._getMoreGamesButton, visibleChild=self._getMoreGamesButton)
def _transitionOut(self): if not self._transitioningOut: self._transitioningOut = True self._saveState() bs.containerWidget(edit=self._rootWidget, transition='outScale') if self._onCloseCall is not None: self._onCloseCall()
def _refresh(self, selectGetMoreGamesButton=False, selected=None): if self._column is not None: self._column.delete() self._column = bs.columnWidget(parent=self._scrollWidget) gameTypes = [gt for gt in bsUtils.getGameTypes() if gt.supportsSessionType(self._editSession._sessionType)] # sort in this language gameTypes.sort(key=lambda g: g.getDisplayString()) for i, gameType in enumerate(gameTypes): t = bs.textWidget(parent=self._column, position=(0, 0), size=(self._width-88, 24), text=gameType.getDisplayString(), hAlign="left", vAlign="center", color=(0.8, 0.8, 0.8, 1.0), maxWidth=self._scrollWidth*0.8, onSelectCall=bs.Call(self._setSelectedGameType, gameType), alwaysHighlight=True, selectable=True, onActivateCall=bs.Call(bs.realTimer, 100, self._selectButton.activate)) if i == 0: bs.widget(edit=t, upWidget=self._backButton) if gameType == selected: bs.containerWidget(edit=self._column, selectedChild=t, visibleChild=t) self._getMoreGamesButton = bs.buttonWidget(parent=self._column, autoSelect=True, label=bs.Lstr(resource='addGameWindow.getMoreGamesText'), color=(0.54, 0.52, 0.67), textColor=(0.7, 0.65, 0.7), onActivateCall=self._onGetMoreGamesPress, size=(178, 50)) if selectGetMoreGamesButton: bs.containerWidget(edit=self._column, selectedChild=self._getMoreGamesButton, visibleChild=self._getMoreGamesButton)
def __init__(self, transition='inRight'): class EditSession: _sessionType = bs.FreeForAllSession def getSessionType(self): return self._sessionType self._editSession = EditSession() self._R = bs.getResource('addGameWindow') self._width = 650 self._height = 346 if gSmallUI else 380 if gMedUI else 440 topExtra = 30 if gSmallUI else 20 self._scrollWidth = 210 self._rootWidget = bs.containerWidget(size=(self._width, self._height+topExtra), transition=transition, scale=2.17 if gSmallUI else 1.5 if gMedUI else 1.0, stackOffset=(0, 1) if gSmallUI else (0, 0)) self._backButton = bs.buttonWidget(parent=self._rootWidget, position=(58, self._height-53), size=(165, 70), scale=0.75, textScale=1.2, label=bs.getResource('backText'), autoSelect=True, buttonType='back', onActivateCall=self._back) self._selectButton = selectButton = bs.buttonWidget(parent=self._rootWidget, position=(self._width-172, self._height-50), autoSelect=True, size=(160, 60), scale=0.75, textScale=1.2, label=bs.getResource('selectText'), onActivateCall=self._add) bs.textWidget(parent=self._rootWidget, position=(self._width*0.5, self._height-28), size=(0, 0), scale=1.0, text="Select Game", hAlign='center', color=gTitleColor, maxWidth=250, vAlign='center') v = self._height - 64 self._selectedTitleText = bs.textWidget(parent=self._rootWidget, position=(self._scrollWidth+50+30, v-15), size=(0, 0), scale=1.0, color=(0.7, 1.0, 0.7, 1.0), maxWidth=self._width-self._scrollWidth-150, hAlign='left', vAlign='center') v -= 30 self._selectedDescriptionText = bs.textWidget(parent=self._rootWidget, position=(self._scrollWidth+50+30, v), size=(0, 0), scale=0.7, color=(0.5, 0.8, 0.5, 1.0), maxWidth=self._width-self._scrollWidth-150, hAlign='left') scrollHeight = self._height-100 v = self._height - 60 self._scrollWidget = bs.scrollWidget(parent=self._rootWidget, position=(61, v-scrollHeight), size=(self._scrollWidth, scrollHeight)) bs.widget(edit=self._scrollWidget, upWidget=self._backButton, leftWidget=self._backButton, rightWidget=selectButton) self._column = None v -= 35 bs.containerWidget(edit=self._rootWidget, cancelButton=self._backButton, startButton=selectButton) self._selectedGameType = None bs.containerWidget(edit=self._rootWidget, selectedChild=self._scrollWidget) self._refresh() if config["selected"]: for gt in bsUtils.getGameTypes(): if not gt.supportsSessionType(self._editSession._sessionType): continue if gt.__name__ == config["selected"]: self._refresh(selected=gt) self._setSelectedGameType(gt)
def __init__(self, transition='inRight'): class EditSession: _sessionType = bs.FreeForAllSession def getSessionType(self): return self._sessionType self._editSession = EditSession() self._width = 650 self._height = 346 if gSmallUI else 380 if gMedUI else 440 topExtra = 30 if gSmallUI else 20 self._scrollWidth = 210 self._rootWidget = bs.containerWidget(size=(self._width, self._height+topExtra), transition=transition, scale=2.17 if gSmallUI else 1.5 if gMedUI else 1.0, stackOffset=(0, 1) if gSmallUI else (0, 0)) self._backButton = bs.buttonWidget(parent=self._rootWidget, position=(58, self._height-53), size=(165, 70), scale=0.75, textScale=1.2, label=bs.Lstr(resource='backText'), autoSelect=True, buttonType='back', onActivateCall=self._back) self._selectButton = selectButton = bs.buttonWidget(parent=self._rootWidget, position=(self._width-172, self._height-50), autoSelect=True, size=(160, 60), scale=0.75, textScale=1.2, label=bs.Lstr(resource='selectText'), onActivateCall=self._add) bs.textWidget(parent=self._rootWidget, position=(self._width*0.5, self._height-28), size=(0, 0), scale=1.0, text="Select Game", hAlign='center', color=gTitleColor, maxWidth=250, vAlign='center') v = self._height - 64 self._selectedTitleText = bs.textWidget(parent=self._rootWidget, position=(self._scrollWidth+50+30, v-15), size=(0, 0), scale=1.0, color=(0.7, 1.0, 0.7, 1.0), maxWidth=self._width-self._scrollWidth-150, hAlign='left', vAlign='center') v -= 30 self._selectedDescriptionText = bs.textWidget(parent=self._rootWidget, position=(self._scrollWidth+50+30, v), size=(0, 0), scale=0.7, color=(0.5, 0.8, 0.5, 1.0), maxWidth=self._width-self._scrollWidth-150, hAlign='left') scrollHeight = self._height-100 v = self._height - 60 self._scrollWidget = bs.scrollWidget(parent=self._rootWidget, position=(61, v-scrollHeight), size=(self._scrollWidth, scrollHeight)) bs.widget(edit=self._scrollWidget, upWidget=self._backButton, leftWidget=self._backButton, rightWidget=selectButton) self._column = None v -= 35 bs.containerWidget(edit=self._rootWidget, cancelButton=self._backButton, startButton=selectButton) self._selectedGameType = None bs.containerWidget(edit=self._rootWidget, selectedChild=self._scrollWidget) self._refresh() if config["selected"]: for gt in bsUtils.getGameTypes(): if not gt.supportsSessionType(self._editSession._sessionType): continue if gt.__name__ == config["selected"]: self._refresh(selected=gt) self._setSelectedGameType(gt)
def onEditGameDone(self, config): if config: CustomSession._config = config CustomSession._gameType = self._selectedGameType startGame(CustomSession) else: bs.containerWidget(edit=uiGlobals["mainMenuWindow"], transition='outRight') uiGlobals["mainMenuWindow"] = SelectGameWindow(transition="inLeft").getRootWidget()
def _restoreState(self): sel = None if self.__class__.__name__ in gWindowStates and 'selName' in gWindowStates[self.__class__.__name__]: selName = gWindowStates[self.__class__.__name__]['selName'] for k, v in statedict(self).items(): if selName == v: sel = k sel = sel or buttons[0]._buttonInstance bs.containerWidget(edit=self._rootWidget, selectedChild=sel)
def newInit(self, transition='inRight', originWidget=None): if originWidget is not None: self._transitionOut = 'outScale' scaleOrigin = originWidget.getScreenSpaceCenter() transition = 'inScale' else: self._transitionOut = 'outRight' scaleOrigin = None width = 600 if gSmallUI else 600 height = 360 if gSmallUI else 435 self._gOnlyHeight = height if any([b.textOnly for b in buttons]): if len(textbuttonlayouts[sum([b.textOnly for b in buttons])]) > 1: height += 80 if gSmallUI else 120 else: height += 60 if gSmallUI else 80 self._width, self._height = width, height buttonHeight = 42 R = bs.getResource('settingsWindow') topExtra = 20 if gSmallUI else 0 if originWidget is not None: self._rootWidget = bs.containerWidget(size=(width,height+topExtra),transition=transition, scaleOriginStackOffset=scaleOrigin, scale=1.75 if gSmallUI else 1.35 if gMedUI else 1.0, stackOffset=(0,-8) if gSmallUI else (0,0)) else: self._rootWidget = bs.containerWidget(size=(width,height+topExtra),transition=transition, scale=1.75 if gSmallUI else 1.35 if gMedUI else 1.0, stackOffset=(0,-8) if gSmallUI else (0,0)) self._backButton = b = bs.buttonWidget(parent=self._rootWidget,autoSelect=True,position=(40,height-55),size=(130,60),scale=0.8,textScale=1.2, label=bs.getResource('backText'),buttonType='back',onActivateCall=self._doBack) bs.containerWidget(edit=self._rootWidget, cancelButton=b) t = bs.textWidget(parent=self._rootWidget, position=(0, height-44), size=(width,25), text=R.titleText, color=gTitleColor, hAlign="center", vAlign="center", maxWidth=130) if gDoAndroidNav: bs.buttonWidget(edit=b, buttonType='backSmall', size=(60, 60), label=bs.getSpecialChar('logoFlat')) bs.textWidget(edit=t, hAlign='left', position=(93, height-44)) icon_buttons = sorted([b for b in buttons if b.icon], key=lambda b: b.sorting_position) for i, button in enumerate(icon_buttons): x, y = button._create_icon_button(self, i) text_buttons = sorted([b for b in buttons if b.textOnly], key=lambda b: b.sorting_position) for i, button in enumerate(text_buttons): button._create_text_button(self, i, y) for button in buttons: button.setLocals(self) self._restoreState()
def _cancelPress(self): if bs.getRealTime() - self._startTime < 1000: bs.playSound(bs.getSound('error')) return bsInternal._addTransaction({ 'type': 'DIALOG_RESPONSE', 'dialogID': self._dialogID, 'response': 0 }) bs.containerWidget(edit=self._rootWidget, transition='outScale')
def _restoreState(self): sel = None if self.__class__.__name__ in gWindowStates and 'selName' in gWindowStates[ self.__class__.__name__]: selName = gWindowStates[self.__class__.__name__]['selName'] for k, v in statedict(self).items(): if selName == v: sel = k sel = sel or buttons[0]._buttonInstance bs.containerWidget(edit=self._rootWidget, selectedChild=sel)
def __init__(self,transition='inRight'): self._width = width = 550 self._height = height = 420 self._scrollWidth = self._width*0.90 self._scrollHeight = self._height - 180 self._subWidth = self._scrollWidth*0.95; self._subHeight = 200 self._current_tab = bs.getConfig()['effectsMod']['tab'] txtFinal = "Ajustes de Effects Mod" if bs.getLanguage() == "Spanish" else "Effects Mod Settings" if bs.getLanguage() == "Spanish": self._credits = ("Modifica y aplica efectos\n" "personalizados a tus personajes.\n\n" "Programado por Froshlee14") else: self._credits = ("Modify and add custom\n" "effects to your characters.\n\n" "Mod made by SAHIL") self._rootWidget = bs.containerWidget(size=(width,height),transition=transition, scale=2.0 if gSmallUI else 1.4 if gMedUI else 1.0, stackOffset=(0,-30) if gSmallUI else (0,0)) self._backButton = b = bs.buttonWidget(parent=self._rootWidget,autoSelect=True,position=(60,self._height-75),size=(130,60), scale=0.8,textScale=1.2,label=bs.Lstr(resource='backText'),buttonType='back',onActivateCall=self._back) if gDoAndroidNav: bs.buttonWidget(edit=self._backButton,buttonType='backSmall',size=(60,60),label=bs.getSpecialChar('back')) bs.containerWidget(edit=self._rootWidget,cancelButton=b) t = bs.textWidget(parent=self._rootWidget,position=(0,height-70),size=(width,50), text=txtFinal, hAlign="center",color=gTitleColor, vAlign="center",maxWidth=width*0.5) v = self._subHeight - 55 v0 = height - 90 tabs = [['general','General' if bs.getLanguage() == "Spanish" else 'General'], ['effects','Efectos' if bs.getLanguage() == "Spanish" else 'Effects'], #['soon','Proximamente' if bs.getLanguage() == "Spanish" else 'Coming soon'], ['info',"Info" if bs.getLanguage() == "Spanish" else 'Info'],] self._tab_buttons = bsUI._createTabButtons( self._rootWidget, tabs, pos=(self._width*0.08,45+self._scrollHeight), size=(self._scrollWidth*0.93,30), onSelectCall=self._setTab) self._scrollWidget = bs.scrollWidget(parent=self._rootWidget,size=(self._subWidth,self._scrollHeight), highlight=False, position=(self._width*0.08,51),captureArrows=True) self._tabContainer = None self._setTab(self._current_tab)
def __init__(self, data): self._dialogID = data['dialogID'] txt = bs.Lstr(translate=('serverResponses', data['text']), subs=data.get('subs', [])).evaluate() txt = txt.strip() txtScale = 1.5 txtHeight = bsInternal._getStringHeight( txt, suppressWarning=True) * txtScale self._width = 500 self._height = 130 + min(200, txtHeight) self._rootWidget = bs.containerWidget( size=(self._width, self._height), transition='inScale', scale=1.8 if bsUI.gSmallUI else 1.35 if bsUI.gMedUI else 1.0) self._startTime = bs.getRealTime() bs.playSound(bs.getSound('swish')) t = bs.textWidget(parent=self._rootWidget, position=(self._width * 0.5, 70 + (self._height - 70) * 0.5), size=(0, 0), color=(1.0, 3.0, 1.0), scale=txtScale, hAlign="center", vAlign="center", text=txt, maxWidth=self._width * 0.85, maxHeight=(self._height - 110)) showCancel = data.get('showCancel', True) if showCancel: self._cancelButton = bs.buttonWidget( parent=self._rootWidget, position=(30, 30), size=(160, 60), autoSelect=True, label=bs.Lstr(resource='cancelText'), onActivateCall=self._cancelPress) else: self._cancelButton = None self._okButton = bs.buttonWidget( parent=self._rootWidget, position=((self._width - 182) if showCancel else (self._width * 0.5 - 80), 30), size=(160, 60), autoSelect=True, label=bs.Lstr(resource='okText'), onActivateCall=self._okPress) bs.containerWidget(edit=self._rootWidget, cancelButton=self._cancelButton, startButton=self._okButton, selectedChild=self._okButton)
def __init__(self, data, origin=(0, 0)): self._width = 450 self._height = 300 self._rootWidget = bs.containerWidget( size=(self._width, self._height), color=(0.45, 0.63, 0.15), transition='inScale', scale=1.8 if bsUI.gSmallUI else 1.35 if bsUI.gMedUI else 1.0) bs.playSound(bs.getSound('cashRegister')) bs.playSound(bs.getSound('swish')) self._cancelButton = bs.buttonWidget(parent=self._rootWidget, scale=0.7, position=(40, self._height - (40)), size=(50, 50), label='', onActivateCall=self.close, autoSelect=True, color=(0.45, 0.63, 0.15), icon=bs.getTexture('crossOut'), iconScale=1.2) bs.containerWidget(edit=self._rootWidget, cancelButton=self._cancelButton) t = bs.textWidget( parent=self._rootWidget, position=(self._width * 0.5, self._height * 0.645), size=(0, 0), color=bsUI.gInfoTextColor, scale=0.6, flatness=1.0, hAlign="center", vAlign="center", text=bs.Lstr(resource='importPlaylistCodeInstructionsText'), maxWidth=self._width * 0.85) t = bs.textWidget(parent=self._rootWidget, position=(self._width * 0.5, self._height * 0.445), size=(0, 0), color=(1.0, 3.0, 1.0), scale=2.0, hAlign="center", vAlign="center", text=data, maxWidth=self._width * 0.85)
def __init__(self, accountID, originWidget): self._width = 550 self._height = 220 self._accountID = accountID self._transitionOut = 'outScale' scaleOrigin = originWidget.getScreenSpaceCenter() transition = 'inScale' self._rootWidget = bs.containerWidget( size=(self._width, self._height), transition='inScale', scaleOriginStackOffset=scaleOrigin, scale=1.8 if bsUI.gSmallUI else 1.35 if bsUI.gMedUI else 1.0) self._cancelButton = bs.buttonWidget(parent=self._rootWidget, scale=0.7, position=(40, self._height - 50), size=(50, 50), label='', onActivateCall=self.close, autoSelect=True, color=(0.4, 0.4, 0.5), icon=bs.getTexture('crossOut'), iconScale=1.2) bs.containerWidget(edit=self._rootWidget, cancelButton=self._cancelButton) t = bs.textWidget(parent=self._rootWidget, position=(self._width * 0.5, self._height * 0.64), size=(0, 0), color=(1, 1, 1, 0.8), scale=1.2, hAlign="center", vAlign="center", text=bs.Lstr(resource='reportThisPlayerReasonText'), maxWidth=self._width * 0.85) bs.buttonWidget(parent=self._rootWidget, size=(235, 60), position=(20, 30), label=bs.Lstr(resource='reportThisPlayerLanguageText'), onActivateCall=self._onLanguagePress, autoSelect=True) bs.buttonWidget(parent=self._rootWidget, size=(235, 60), position=(self._width - 255, 30), label=bs.Lstr(resource='reportThisPlayerCheatingText'), onActivateCall=self._onCheatingPress, autoSelect=True)
def _onImportResponse(self, response): if response is None: bs.screenMessage(bs.Lstr(resource='errorText'), color=(1, 0, 0)) bs.playSound(bs.getSound('error')) return if response['playlistType'] == 'Team Tournament': playlistTypeName = bs.Lstr(resource='playModes.teamsText') elif response['playlistType'] == 'Free-for-All': playlistTypeName = bs.Lstr(resource='playModes.freeForAllText') else: playlistTypeName = bs.Lstr(value=response['playlistType']) playlistTypeName bs.screenMessage(bs.Lstr(resource='importPlaylistSuccessText', subs=[('${TYPE}', playlistTypeName), ('${NAME}', response['playlistName'])]), color=(0, 1, 0)) bs.playSound(bs.getSound('gunCocking')) if self._onSuccessCallback is not None: self._onSuccessCallback() bs.containerWidget(edit=self._rootWidget, transition=self._transitionOut)
def _restoreState(self): if not hasattr(self, "_quickGameButton"): return # ensure that our monkey patched init ran if self.__class__.__name__ not in gWindowStates: bs.containerWidget(edit=self._rootWidget, selectedChild=self._coopButton) return sel = states(self).get(gWindowStates[self.__class__.__name__], None) if sel: bs.containerWidget(edit=self._rootWidget, selectedChild=sel) else: bs.containerWidget(edit=self._rootWidget, selectedChild=self._coopButton) print('error restoring state (', gWindowStates[self.__class__.__name__], ') for', self.__class__)
def _transitionOut(self): if not self._transitioningOut: self._transitioningOut = True bs.containerWidget(edit=self._rootWidget, transition='outScale')
def doQuickGame(): uiGlobals["mainMenuWindow"] = SelectGameWindow().getRootWidget() bs.containerWidget(edit=self._rootWidget, transition='outLeft')
def _back(self): bs.containerWidget(edit=self._rootWidget, transition='outRight') uiGlobals["mainMenuWindow"] = PlayWindow(transition="inLeft").getRootWidget()
def _rebuildForState(self, newState): if self._state is not None: self._saveState() # clear out previous state (if any) children = self._rootWidget.getChildren() for c in children: c.delete() self._state = newState # print 'REBUILDING FOR STATE',self._state self._cancelButton = bs.buttonWidget(parent=self._rootWidget, position=(20, self._height - 30), size=(50, 50), scale=0.5, label='', color=self._bgColor, onActivateCall=self._onCancel, autoSelect=True, icon=bs.getTexture('crossOut'), iconScale=1.2) titleScale = 0.6 titleColor = (1, 1, 1, 0.4) showPrizes = False showLevel = False showForfeitButton = False if self._state == 'error': titleStr = bs.Lstr(resource='coopSelectWindow.challengesText') bs.textWidget(parent=self._rootWidget, position=(self._width * 0.5, self._height * 0.5), size=(0, 0), hAlign='center', vAlign='center', scale=0.7, text=bs.Lstr(resource='errorText'), maxWidth=self._width * 0.8) elif self._state == 'skipWaitNextChallenge': titleStr = bs.Lstr(resource='coopSelectWindow.nextChallengeText') #showLevel = True bWidth = 140 bHeight = 130 imgWidth = 80 imgHeight = 80 bPos = (self._width * 0.5, self._height * 0.52) b = bs.buttonWidget(parent=self._rootWidget, position=(bPos[0] - bWidth * 0.5, bPos[1] - bHeight * 0.5), onActivateCall=bs.WeakCall(self._load), label='', size=(bWidth, bHeight), buttonType='square', autoSelect=True) bs.containerWidget(edit=self._rootWidget, selectedChild=b) bs.textWidget( parent=self._rootWidget, drawController=b, hAlign='center', vAlign='center', text=bs.Lstr(resource='coopSelectWindow.skipWaitText'), size=(0, 0), maxWidth=bWidth * 0.8, color=(0.75, 1.0, 0.7), position=(bPos[0], bPos[1] - bHeight * 0.0), scale=0.9) bs.textWidget(parent=self._rootWidget, drawController=b, hAlign='center', vAlign='center', text=bs.getSpecialChar('ticket') + str(self._waitTickets), size=(0, 0), scale=0.6, color=(1, 0.5, 0), position=(bPos[0], bPos[1] - bHeight * 0.23)) # bs.imageWidget(parent=self._rootWidget,drawController=b,size=(80,80), # position=(bPos[0]-imgWidth*0.5,bPos[1]-imgHeight*0.5),texture=bs.getTexture('tickets')) #showPrizes = True elif self._state == 'skipWaitNextPlay': showLevel = True showForfeitButton = True bWidth = 140 bHeight = 130 imgWidth = 80 imgHeight = 80 bPos = (self._width * 0.5, self._height * 0.52) b = bs.buttonWidget(parent=self._rootWidget, position=(bPos[0] - bWidth * 0.5, bPos[1] - bHeight * 0.5), onActivateCall=bs.WeakCall(self._play), label='', size=(bWidth, bHeight), buttonType='square', autoSelect=True) bs.widget(edit=b, upWidget=self._cancelButton) bs.containerWidget(edit=self._rootWidget, selectedChild=b) bs.textWidget( parent=self._rootWidget, drawController=b, hAlign='center', vAlign='center', text=bs.Lstr(resource='coopSelectWindow.playNowText'), size=(0, 0), maxWidth=bWidth * 0.8, color=(0.75, 1.0, 0.7), position=(bPos[0], bPos[1] - bHeight * 0.0), scale=0.9) bs.textWidget(parent=self._rootWidget, drawController=b, hAlign='center', vAlign='center', text=bs.getSpecialChar('ticket') + str(self._waitTickets), size=(0, 0), scale=0.6, color=(1, 0.5, 0), position=(bPos[0], bPos[1] - bHeight * 0.23)) # bs.imageWidget(parent=self._rootWidget,drawController=b,size=(80,80), # position=(bPos[0]-imgWidth*0.5,bPos[1]-imgHeight*0.5),texture=bs.getTexture('tickets')) showPrizes = True elif self._state == 'freePlay': showLevel = True showForfeitButton = True bWidth = 140 bHeight = 130 b = bs.buttonWidget(parent=self._rootWidget, position=(self._width * 0.5 - bWidth * 0.5, self._height * 0.52 - bHeight * 0.5), onActivateCall=bs.WeakCall(self._play), label=bs.Lstr(resource='playText'), size=(bWidth, bHeight), buttonType='square', autoSelect=True) bs.widget(edit=b, upWidget=self._cancelButton) bs.containerWidget(edit=self._rootWidget, selectedChild=b) showPrizes = True elif self._state == 'ended': titleStr = bs.Lstr(resource='coopSelectWindow.challengesText') bs.textWidget(parent=self._rootWidget, position=(self._width * 0.5, self._height * 0.5), size=(0, 0), hAlign='center', vAlign='center', scale=0.7, text=bs.Lstr(resource='challengeEndedText'), maxWidth=self._width * 0.8) else: titleStr = '' print 'Unrecognized state for ChallengeEntryWindow:', self._state if showLevel: titleColor = (1, 1, 1, 0.7) titleStr = 'Meteor Shower Blah' titleScale = 0.7 bs.textWidget(parent=self._rootWidget, position=(self._width * 0.5, self._height * 0.86), size=(0, 0), hAlign='center', vAlign='center', color=(0.8, 0.8, 0.4, 0.7), flatness=1.0, scale=0.55, text=bs.Lstr(resource='levelText', subs=[('${NUMBER}', str(self._level))]), maxWidth=self._width * 0.8) self._titleText = bs.textWidget(parent=self._rootWidget, position=(self._width * 0.5, self._height - 20), size=(0, 0), hAlign='center', vAlign='center', scale=titleScale, text=titleStr, maxWidth=200, color=titleColor) if showForfeitButton: bWidth = 40 bHeight = 25 self._forfeitButton = bs.buttonWidget( parent=self._rootWidget, position=(self._width - bWidth - 16, self._height - bHeight - 10), label=bs.Lstr(resource='coopSelectWindow.forfeitText'), size=(bWidth, bHeight), buttonType='square', color=(0.6, 0.45, 0.6), onActivateCall=bs.WeakCall(self._onForfeitPress), textColor=(0.65, 0.55, 0.65), autoSelect=True) else: self._forfeitButton = None if showPrizes: bs.textWidget(parent=self._rootWidget, position=(self._width * 0.5, self._height * 0.24), size=(0, 0), hAlign='center', vAlign='center', flatness=1.0, scale=0.6, text=bs.Lstr(resource='coopSelectWindow.prizesText'), maxWidth=self._width * 0.8, color=(0.8, 0.8, 1, 0.5)), prizes = [] if self._prizeTrophy is not None: prizes.append( bs.getSpecialChar('trophy' + str(self._prizeTrophy))) if self._prizeTickets != 0: prizes.append( bs.getSpecialChar('ticketBacking') + str(self._prizeTickets)) bs.textWidget(parent=self._rootWidget, position=(self._width * 0.5, self._height * 0.13), size=(0, 0), hAlign='center', vAlign='center', scale=0.8, flatness=1.0, color=(0.7, 0.7, 0.7, 1), text=' '.join(prizes), maxWidth=self._width * 0.8) self._restoreState()
def _back(self): bs.containerWidget(edit=self._rootWidget,transition='outRight') self._colorTimer = None uiGlobals['mainMenuWindow'] = PlayerProfilesWindow(transition='inLeft').getRootWidget()
def _setTab(self,tab): self._colorTimer = None self._current_tab = tab bs.getConfig()['effectsMod']['tab'] = tab bs.writeConfig() bsUI._updateTabButtonColors(self._tab_buttons, tab) if self._tabContainer is not None and self._tabContainer.exists(): self._tabContainer.delete() self._tabData = {} if tab == 'info': subHeight = 200 self._tabContainer = c = bs.containerWidget(parent=self._scrollWidget,size=(self._subWidth,subHeight), background=False) bs.widget(edit=self._tabContainer,upWidget=self._backButton) v = subHeight - 40 cWidth = self._scrollWidth cHeight = min(self._scrollHeight, 200*1.0+100) self._timeDelayText = bs.textWidget( parent=c, position=(0,v), color=(0.1, 1.0, 0.1), scale=1.2, size=(self._subWidth, 0), maxWidth=cWidth * 0.9, maxHeight=cHeight * 0.9, hAlign='center', vAlign='center', text='EFFECTS MOD v1.1') v -= 100 t = bs.textWidget( parent=c, position=(0, v), color=(0.8, 0.8, 0.8), scale=0.8, size=(self._subWidth*0.95, 0), maxWidth=cWidth * 0.9, maxHeight=cHeight * 0.9, hAlign='center', vAlign='center', text=self._credits) v -= 140 elif tab == 'general': subHeight = 200 self._tabContainer = c = bs.containerWidget(parent=self._scrollWidget,size=(self._subWidth,subHeight), background=False) v = subHeight - 70 reset = bs.buttonWidget(parent=c, autoSelect=True,onActivateCall=self.restoreSettings, position=((self._scrollWidth*0.45)-150, v), size=(300,50),scale=1.0, textScale=1.2,textColor=(1,1,1), label="Restaurar ajustes por defecto" if bs.getLanguage() == "Spanish" else "Restore default settings") bs.buttonWidget(edit=reset,upWidget=self._backButton) v -= 70 self.bw = bs.checkBoxWidget(parent=c,position=(self._subWidth*0.1,v), value=bs.getConfig()["effectsMod"]["color"], onValueChangeCall=bs.Call(self._setSetting,'color'), maxWidth=self._scrollWidth*0.9, text='Aplicar color de perfiles' if bs.getLanguage() == 'Spanish' else 'Apply profile colors',autoSelect=True) elif tab == "effects": self._selected = None baseScale = 2.4 if gSmallUI else 1.5 if gMedUI else 1.0 popupMenuScale = baseScale*1.2 subHeight = 250 v = subHeight - 20 self._tabContainer = c = bs.containerWidget(parent=self._rootWidget,size=(self._subWidth,subHeight), background=False) spawnEffectsList = ['none','in','out','xplode','show'] if bs.getLanguage() == "Spanish": spawnEffectsListDisplay = ['Ninguno','Ondas adentro','Ondas afuera','Explosion','Mostrar circulo'] else: spawnEffectsListDisplay = ['None','Circles In','Circles Out','Circle Explode','Show circle'] t = bs.textWidget(parent=c,position=(self._subWidth*0.2,v), text="Efectos de spawn" if bs.getLanguage() == "Spanish" else "Spawn effects", maxWidth=self._scrollWidth,size=(self._subWidth*0.5,self._scrollHeight*0.1),color=(0.7,0.7,0.7),hAlign="left",scale=0.8,) sePopup = PopupMenu(parent=c,position=(self._subWidth*0.6,v-15),width=150,scale=popupMenuScale, choices=spawnEffectsList, choicesDisplay=spawnEffectsListDisplay, currentChoice= bs.getConfig()["effectsMod"]["spawnEffect"], onValueChangeCall=self._setSpawnEffect) bs.widget(edit=sePopup.getButtonWidget(),upWidget=self._backButton) v -= 60 effectsList = ['none','path','fire'] if bs.getLanguage() == "Spanish": effectsListDisplay = ['Ninguno','Linea punteda','Hombre de fuego'] else: effectsListDisplay = ['None','Dotted line','Fireman'] t = bs.textWidget(parent=c,position=(self._subWidth*0.2,v), text="Efectos in-Game" if bs.getLanguage() == "Spanish" else "In-Game ffects", maxWidth=self._scrollWidth,size=(self._subWidth*0.5,self._scrollHeight*0.1),color=(0.7,0.7,0.7),hAlign="left",scale=0.8,) ePopup = PopupMenu(parent=c,position=(self._subWidth*0.6,v-15),width=150,scale=popupMenuScale, choices=effectsList, choicesDisplay=effectsListDisplay, currentChoice= bs.getConfig()["effectsMod"]["effect"], onValueChangeCall=self._setEffect) v -= 60 deathEffectsList = ['none','in','out','xplode','show','bones','fly','skull'] if bs.getLanguage() == "Spanish": deathEffectsListDisplay = ['Ninguno','Ondas adentro','Ondas afuera','Explosion','Mostrar circulo','Huesos','Levitar','Calavera'] else: deathEffectsListDisplay = ['None','Circles In','Circles Out','Circle Explode','Show cirlce ','Become bones','Levitate','Show Skull'] t = bs.textWidget(parent=c,position=(self._subWidth*0.2,v), text="Efectos de muerte" if bs.getLanguage() == "Spanish" else "Death effects", maxWidth=self._scrollWidth,size=(self._subWidth*0.5,self._scrollHeight*0.1),color=(0.7,0.7,0.7),hAlign="left",scale=0.8,) dePopup = PopupMenu(parent=c,position=(self._subWidth*0.6,v-15),width=150,scale=popupMenuScale, choices=deathEffectsList, choicesDisplay=deathEffectsListDisplay, currentChoice= bs.getConfig()["effectsMod"]["deathEffect"], onValueChangeCall=self._setDeathEffect)
def newInit(self, transition='inRight', originWidget=None): if originWidget is not None: self._transitionOut = 'outScale' scaleOrigin = originWidget.getScreenSpaceCenter() transition = 'inScale' else: self._transitionOut = 'outRight' scaleOrigin = None width = 600 if gSmallUI else 600 height = 360 if gSmallUI else 435 self._gOnlyHeight = height if any([b.textOnly for b in buttons]): if len(textbuttonlayouts[sum([b.textOnly for b in buttons])]) > 1: height += 80 if gSmallUI else 120 else: height += 60 if gSmallUI else 80 self._width, self._height = width, height R = bs.getResource('settingsWindow') topExtra = 20 if gSmallUI else 0 if originWidget is not None: self._rootWidget = bs.containerWidget( size=(width, height + topExtra), transition=transition, scaleOriginStackOffset=scaleOrigin, scale=1.75 if gSmallUI else 1.35 if gMedUI else 1.0, stackOffset=(0, -8) if gSmallUI else (0, 0)) else: self._rootWidget = bs.containerWidget( size=(width, height + topExtra), transition=transition, scale=1.75 if gSmallUI else 1.35 if gMedUI else 1.0, stackOffset=(0, -8) if gSmallUI else (0, 0)) self._backButton = b = bs.buttonWidget(parent=self._rootWidget, autoSelect=True, position=(40, height - 55), size=(130, 60), scale=0.8, textScale=1.2, label=bs.getResource('backText'), buttonType='back', onActivateCall=self._doBack) bs.containerWidget(edit=self._rootWidget, cancelButton=b) t = bs.textWidget(parent=self._rootWidget, position=(0, height - 44), size=(width, 25), text=R.titleText, color=gTitleColor, hAlign="center", vAlign="center", maxWidth=130) if gDoAndroidNav: bs.buttonWidget(edit=b, buttonType='backSmall', size=(60, 60), label=bs.getSpecialChar('logoFlat')) bs.textWidget(edit=t, hAlign='left', position=(93, height - 44)) icon_buttons = sorted([b for b in buttons if b.icon], key=lambda b: b.sorting_position) for i, button in enumerate(icon_buttons): x, y = button._create_icon_button(self, i) text_buttons = sorted([b for b in buttons if b.textOnly], key=lambda b: b.sorting_position) for i, button in enumerate(text_buttons): button._create_text_button(self, i, y) for button in buttons: button.setLocals(self) self._restoreState()
def _doModManager(swinstance): swinstance._saveState() bs.containerWidget(edit=swinstance._rootWidget, transition='outLeft') mm_window = ModManagerWindow(backLocationCls=swinstance.__class__) uiGlobals['mainMenuWindow'] = mm_window.getRootWidget()
def _onGetMoreGamesPress(self): if not self._modal: bs.containerWidget(edit=self._rootWidget, transition='outLeft') mm_window = ModManagerWindow(modal=self._modal, backLocationCls=self.__class__, showTab="minigames") if not self._modal: uiGlobals['mainMenuWindow'] = mm_window.getRootWidget()
def close(self): bs.containerWidget(edit=self._rootWidget, transition='outScale')
def _cancel(self): bs.containerWidget(edit=self._rootWidget, transition=('outRight')) uiGlobals['mainMenuWindow'] = MainMenuWindow( transition='inLeft').getRootWidget() self.Timir = None fadeToBack()
def doQuickGame(): self._saveState() uiGlobals["mainMenuWindow"] = SelectGameWindow().getRootWidget() bs.containerWidget(edit=self._rootWidget, transition='outLeft')
def __init__(self, transition='inRight', originWidget=None): if originWidget is not None: self._transitionOut = 'outScale' scaleOrigin = originWidget.getScreenSpaceCenter() transition = 'inScale' else: self._transitionOut = 'outRight' scaleOrigin = None transition = 'inRight' bgColor = (0.4, 0.4, 0.5) self._width = 540 self._height = 330 baseScale = 2.0 if bsUI.gSmallUI else 1.6 if bsUI.gMedUI else 1.1 self._rootWidget = bs.containerWidget( size=(self._width, self._height), transition=transition, scale=baseScale, scaleOriginStackOffset=scaleOrigin, stackOffset=(0, -10) if bsUI.gSmallUI else (0, 0)) self._cancelButton = bs.buttonWidget(parent=self._rootWidget, position=(50, self._height - 30), size=(50, 50), scale=0.5, label='', color=bgColor, onActivateCall=self._cancel, autoSelect=True, icon=bs.getTexture('crossOut'), iconScale=1.2) bs.textWidget( parent=self._rootWidget, position=(self._width * 0.5, self._height * 0.57), size=(0, 0), text=bs.Lstr( resource='accountSettingsWindow.linkAccountsInstructionsText', subs=[('${COUNT}', str( bsInternal._getAccountMiscReadVal( 'maxLinkAccounts', 5)))]), maxWidth=self._width * 0.9, color=bsUI.gInfoTextColor, maxHeight=self._height * 0.6, hAlign='center', vAlign='center') bs.containerWidget(edit=self._rootWidget, cancelButton=self._cancelButton) bs.buttonWidget( parent=self._rootWidget, position=(40, 30), size=(200, 60), label=bs.Lstr( resource='accountSettingsWindow.linkAccountsGenerateCodeText'), autoSelect=True, onActivateCall=self._generatePress) self._enterCodeButton = bs.buttonWidget( parent=self._rootWidget, position=(self._width - 240, 30), size=(200, 60), label=bs.Lstr( resource='accountSettingsWindow.linkAccountsEnterCodeText'), autoSelect=True, onActivateCall=self._enterCodePress)
def _cancel(self): bs.containerWidget(edit=self._rootWidget, transition=self._transitionOut)
def doMenu(): bs.containerWidget(edit=self._rootWidget,transition=self._transitionOut) EffectsMenu()
def __init__(self): self.buttonChecker = False height = 200 width = 360 bs.containerWidget(edit=uiGlobals['mainMenuWindow'], transition='outLeft') self._rootWidget = bs.containerWidget( size=(width, height), transition=('inRight'), toolbarVisibility='MENU_MINIMAL_NOBACK', parent=bsInternal._getSpecialWidget('overlayStack'), scale=2.1 if gSmallUI else 1.5 if gMedUI else 1.3, color=(0.215, 0.278, 0.309)) self.lt = bs.textWidget(parent=self._rootWidget, position=(width / 2, height / 2), size=(0, 0), hAlign="center", vAlign="center", shadow=1.0, text=bs.Lstr(resource='loadingText'), scale=1.0, maxWidth=width * 0.9, maxHeight=height - 75) self.t = bs.textWidget(parent=self._rootWidget, position=(width * 0.5, height - 5 - (height - 75) * 0.25), shadow=1.0, size=(0, 0), hAlign="center", vAlign="center", text='', scale=1.0, maxWidth=250, maxHeight=height - 75) self.pt = bs.textWidget(parent=self._rootWidget, position=(width * 0.2, height - 5 - (height - 75) * 0.8), shadow=1.0, size=(0, 0), hAlign="center", vAlign="center", text='', scale=1.0, maxWidth=width * 0.9, maxHeight=height - 75) self.pvt = bs.textWidget(parent=self._rootWidget, shadow=1.0, position=(width * 0.30, height - 5 - (height - 75) * 0.8), size=(0, 0), hAlign="left", vAlign="center", text='', scale=1.0, maxWidth=width * 0.9, maxHeight=height - 75) self.ts = bs.textWidget(parent=self._rootWidget, shadow=1.0, position=(width * 0.75, height - 5 - (height - 75) * 0.8), size=(0, 0), hAlign="left", vAlign="center", text='', scale=1.0, maxWidth=width * 0.9, maxHeight=height - 75) self.tvs = bs.textWidget(parent=self._rootWidget, shadow=1.0, position=(width * 0.65, height - 5 - (height - 75) * 0.8), size=(0, 0), hAlign="center", vAlign="center", text='', scale=1.0, maxWidth=width * 0.9, maxHeight=height - 75) self.cb = b = bs.buttonWidget(parent=self._rootWidget, autoSelect=True, buttonType='backSmall', position=(20, 150), size=(30, 30), scale=1.0, textResScale=1.5, textColor=(0.9, 0.9, 0.9), label=bs.getSpecialChar('back'), color=(0.356, 0.760, 0.905), textScale=0.7, onActivateCall=self._cancel) bs.containerWidget(edit=self._rootWidget, cancelButton=b) self.Timir = bs.Timer(5000, bs.WeakCall(self._serverAddressFetchThread), repeat=True, timeType='real')
def _enterCodePress(self): bsUI.PromoCodeWindow(modal=True, originWidget=self._enterCodeButton) bs.containerWidget(edit=self._rootWidget, transition=self._transitionOut)