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)
Exemplo n.º 2
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 __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)
Exemplo 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)