Esempio n. 1
0
    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 _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 __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)
Esempio n. 4
0
    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)
Esempio n. 5
0
    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()
Esempio n. 6
0
    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)