def __init__(self, *args, **kwargs): self._useTeams = False self._tutorialActivityInstance = None bs.Session.__init__(self, teamNames=None, teamColors=None, useTeamColors=False, minPlayers=1, maxPlayers=self.getMaxPlayers()) self._haveShownControlsHelpOverlay = False self._seriesLength = 1 self._ffaSeriesLength = 1 # which game activity we're on self._gameNumber = 0 self._playlist = SimplePlaylist(self._config, self._gameType) config["selected"] = self._gameType.__name__ config["config"] = self._config bs.writeConfig() # get a game on deck ready to go self._currentGameSpec = None self._nextGameSpec = self._playlist.pullNext() self._nextGame = self._nextGameSpec["resolvedType"] # go ahead and instantiate the next game we'll use so it has lots of time to load self._instantiateNextGame() # start in our custom join screen self.setActivity(bs.newActivity(bsTeamGame.TeamJoiningActivity))
def setComplete(self, complete=True, announce=True, sound=True, writeConfig=True): config = self._getConfig() if complete != config['Complete']: config['Complete'] = complete if writeConfig: bs.writeConfig()
def setComplete(self, complete=True, announce=True, sound=True, writeConfig=True): config = self._getConfig() if complete != config['Complete']: config['Complete'] = complete # report achievements to the game-service when initially achieving #bsInternal._reportAchievement(self._name) # if complete and announce: # # if we're being freshly complete, display/report it and whatnot # if not [self,sound] in gAchievementsToDisplay: # gAchievementsToDisplay.append([self,sound]) # # if there's no achievement display timer going, kick one off # # (if one's already running it will pick this up before it dies) # global gAchievementDisplayTimer # global gLastAchievementDisplayTime # # need to check last time too; its possible our timer wasn't able to clear itself if an # # activity died and took it down with it.. # if ((gAchievementDisplayTimer is None or bs.getRealTime()-gLastAchievementDisplayTime > 2000) # and bs.getActivity(exceptionOnNone=False) is not None): # gAchievementDisplayTimer = bs.Timer(1000,_displayNextAchievement,repeat=True,timeType='net') # _displayNextAchievement() # show the first immediately if writeConfig: bs.writeConfig()
def setAutoUpdate(self, val): # FIXME: properly disable checkbox if not self.checkUpdates.value: bs.playSound(bs.getSound("error")) self.autoUpdates.value = False return config["auto-update-old-mods"] = bool(val) bs.writeConfig()
def setCompletedAchievements(achs): #print 'LOCALLY SETTING COMPLETED TO',achs # clear all then fill these in bs.getConfig()['Achievements'] = {} for aName in achs: getAchievement(aName).setComplete(announce=False, writeConfig=False) # write config in one fell swoop.. bs.writeConfig()
def _setReady(self,ready): import bsInternal profileName = self.profileNames[self.profileIndex] # handle '_edit' as a special case if profileName == '_edit' and ready: import bsUI with bs.Context('UI'): bsUI.PlayerProfilesWindow(inMainMenu=False) # give their input-device UI ownership too # (prevent someone else from snatching it in crowded games) bsInternal._setUIInputDevice(self._player.getInputDevice()) return if not ready: self._player.assignInputCall('leftPress',bs.Call(self.handleMessage,bsLobby.ChangeMessage('team',-1))) self._player.assignInputCall('rightPress',bs.Call(self.handleMessage,bsLobby.ChangeMessage('team',1))) self._player.assignInputCall('bombPress',bs.Call(self.handleMessage,bsLobby.ChangeMessage('character',1))) self._player.assignInputCall('upPress',bs.Call(self.handleMessage,bsLobby.ChangeMessage('profileIndex',-1))) self._player.assignInputCall('downPress',bs.Call(self.handleMessage,bsLobby.ChangeMessage('profileIndex',1))) self._player.assignInputCall(('jumpPress','pickUpPress','punchPress'), bs.Call(self.handleMessage,bsLobby.ChangeMessage('ready',1))) self.ready = False self._updateText() self._player.setName('untitled',real=False) else: self._player.assignInputCall(('leftPress','rightPress', 'upPress','downPress', 'jumpPress','bombPress','pickUpPress'),self._doNothing) self._player.assignInputCall(('jumpPress','bombPress','pickUpPress','punchPress'), bs.Call(self.handleMessage,bsLobby.ChangeMessage('ready',0))) # store the last profile picked by this input for reuse inputDevice = self._player.getInputDevice() name = inputDevice.getName() uniqueID = inputDevice.getUniqueIdentifier() try: deviceProfiles = bs.getConfig()['Default Player Profiles'] except Exception: deviceProfiles = bs.getConfig()['Default Player Profiles'] = {} # make an exception if we have no custom profiles and are set to random; # in that case we'll want to start picking up custom profiles if/when one is made # so keep our setting cleared haveCustomProfiles = True if [p for p in self.profiles if p not in ('_random','_edit','__account__')] else False if profileName == '_random' and not haveCustomProfiles: try: del(deviceProfiles[name+' '+uniqueID]) except Exception: pass else: deviceProfiles[name+' '+uniqueID] = profileName bs.writeConfig() # set this player's short and full name self._player.setName(self._getName(),self._getName(full=True),real=True) self.ready = True self._updateText() # inform the session that this player is ready bs.getSession().handleMessage(bsLobby.PlayerReadyMessage(self))
def cb(data): newBranch = branch if data: bs.screenMessage('ok') else: bs.screenMessage('failed to fetch branch') newBranch = "master" bs.screenMessage("set branch to " + newBranch) config["branch"] = newBranch bs.writeConfig() if self.branch.exists(): bs.textWidget(edit=self.branch, text=newBranch) self.modManagerWindow._cb_refresh()
def popupMenuSelectedChoice(self, popupWindow, choice): def getIndex(): for i in bsInternal._getGameRoster(): if i['clientID'] == self._popupPartyMemberClientID: return bsInternal._getGameRoster().index(i) if self._popupType == 'partyMemberPress': if choice in [ 'Kick', 'Vote to Kick', 'Изгнать', 'Голосовать за вылет' ]: if self._popupPartyMemberIsHost: bs.playSound(bs.getSound('error')) bs.screenMessage( bs.Lstr(resource='internal.cantKickHostError'), color=(1, 0, 0)) else: result = bsInternal._disconnectClient( self._popupPartyMemberClientID) if not result: bs.playSound(bs.getSound('error')) bs.screenMessage( bs.Lstr(resource='getTicketsWindow.unavailableText'), color=(1, 0, 0)) elif choice in ['Departure without a vote', 'Вылет без голосования']: bsInternal._chatMessage('/kick ' + str(self._popupPartyMemberClientID)) elif choice in ['Ban for teaming', 'Бан за тиминг']: bsInternal._chatMessage('/ban' + ' device ' + eval( bsInternal._getGameRoster()[getIndex()]['specString'])['n'] + ' team') elif choice in ['Ban for bad words', 'Бан за плохие слова']: bsInternal._chatMessage('/ban' + ' device ' + eval( bsInternal._getGameRoster()[getIndex()]['specString'])['n'] + ' badwords') elif choice in [ 'Ban for exile without reason', 'Бан за изгнание без причины' ]: bsInternal._chatMessage('/ban' + ' device ' + eval( bsInternal._getGameRoster()[getIndex()]['specString'])['n'] + ' freeKick') elif choice in ['Account profile', 'Профиль аккаунта']: for i in bsInternal._getGameRoster(): if i['clientID'] == self._popupPartyMemberClientID: bs.screenMessage(i['displayString']) else: if choice in ['Defrost', 'Разморозить']: _choice = 'thaw' elif choice in ['Turn into box', 'Превратить в коробку']: _choice = 'box' elif choice in ['Remove from game', 'Убрать из игры']: _choice = 'remove' elif choice in ['Cure', 'Вылечить']: _choice = 'heal' elif choice in ['Rainbow skin', 'Радужный скин']: _choice = 'rainbow' elif choice in ['Put to sleep', 'Усыпить']: _choice = 'sleep' elif choice in ['To freeze', 'Заморозить']: _choice = 'freeze' elif choice in ['To revive', 'Возродить']: _choice = 'rise' elif choice in ['Invisibility', 'Невидимость']: _choice = 'inv' elif choice in ['Fly', 'Полет']: _choice = 'fly' elif choice in ['New fly', 'Новый полет']: _choice = 'fly3d' elif choice in ['Kill', 'Убить']: _choice = 'kill' elif choice in ['Curse', 'Проклятие']: _choice = 'curse' elif choice in ['God mode', 'Режим бога']: _choice = 'gm' bsInternal._chatMessage('/' + _choice + ' device ' + eval( bsInternal._getGameRoster()[getIndex()]['specString'])['n']) elif self._popupType == 'menu': if choice in ('mute', 'unmute'): bsConfig = bs.getConfig() bsConfig['Chat Muted'] = (choice == 'mute') bs.writeConfig() bs.applySettings() self._update() elif choice == 'favoritesChatMenuAddButton': configLastServer = bs.getConfig()['BombDash Last Server'] configFavoritesServers = bs.getConfig( )['BombDash Favorites Servers'] if not configLastServer: bs.screenMessage(bs.Lstr(resource='favoritesLastServerNone'), (1, 0, 0)) elif configLastServer in configFavoritesServers: bs.screenMessage( bs.Lstr(resource='favoritesLastServerInFavorites'), (1, 0, 0)) else: bs.getConfig()['BombDash Favorites Servers'].append( configLastServer) bs.writeConfig() bs.screenMessage(bs.Lstr(resource='favoritesLastServerAdded'), (0, 1, 0)) else: print 'unhandled popup type: ' + str(self._popupType)
def _setDeathEffect(self,m): bs.getConfig()["effectsMod"]["deathEffect"] = m bs.writeConfig()
PlayWindow_restoreState = PlayWindow._restoreState def _prepare_reload(): PlayWindow.__init__ = PlayWindow__init__ PlayWindow._saveState = PlayWindow_saveState PlayWindow._restoreState = PlayWindow_restoreState # TODO: support other gametypes than free-for-all if "quickGameButton" in bs.getConfig(): config = bs.getConfig()["quickGameButton"] else: config = {"selected": None, "config": None} bs.getConfig()["quickGameButton"] = config bs.writeConfig() def startGame(session, fadeout=True): def callback(): if fadeout: bsInternal._unlockAllInput() try: bsInternal._newHostSession(session) except Exception: import bsMainMenu bs.printException("exception running session", session) # drop back into a main menu session.. bsInternal._newHostSession(bsMainMenu.MainMenuSession) if fadeout:
def _setSetting(self,setting,m): bs.getConfig()["effectsMod"][setting] = False if m==0 else True bs.writeConfig()
import copy _supports_auto_reloading = True _auto_reloader_type = "patching" PlayWindow__init__ = PlayWindow.__init__ def _prepare_reload(): PlayWindow.__init__ = PlayWindow__init__ # TODO: support other gametypes than free-for-all if "quickGameButton" in bs.getConfig(): config = bs.getConfig()["quickGameButton"] else: config = {"selected": None, "config": None} bs.getConfig()["quickGameButton"] = config bs.writeConfig() def startGame(session, fadeout=True): def callback(): if fadeout: bsInternal._unlockAllInput() try: bsInternal._newHostSession(session) except Exception: import bsMainMenu bs.printException("exception running session", session) # drop back into a main menu session.. bsInternal._newHostSession(bsMainMenu.MainMenuSession) if fadeout: bsInternal._fadeScreen(False, time=250, endCall=callback)
def doIt(): bs.getConfig()["effectsMod"] = getDefaultSettings() bs.writeConfig() self._setTab("general") bs.screenMessage("Ajustes restaurados" if bs.getLanguage() == "Spanish" else "Settings restored")
def _setSpawnEffect(self,m): bs.getConfig()["effectsMod"]["spawnEffect"] = m bs.writeConfig()
def setCheckUpdate(self, val): config["auto-check-updates"] = bool(val) bs.writeConfig() self.checkAutoUpdateState()
def cache(data): if data: web_cache[url] = (data, time.time()) bs.writeConfig()
def _cb_sorting(self): self.sortMode = self.sortModes[self.sortMode['next']] config['sortMode'] = self.sortMode['name'] bs.writeConfig() self.sortButton.label = "Sorting:\n" + self.sortMode['name'] self._cb_refresh()
def popupMenuSelectedChoice(self, popupWindow, choice): if choice == "kickOrg": if self._popupPartyMemberIsHost: bs.playSound(bs.getSound('error')) bs.screenMessage(bs.Lstr(resource='internal.cantKickHostError'), color=(1, 0, 0)) else: #print self._popupPartyMemberClientID result = bsInternal._disconnectClient( self._popupPartyMemberClientID) if not result: bs.playSound(bs.getSound('error')) bs.screenMessage( bs.Lstr(resource='getTicketsWindow.unavailableText'), color=(1, 0, 0)) elif choice == "kick": bsInternal._chatMessage("/" + choice + " " + (str(self._popupPartyMemberClientID))) elif choice == "ban": for client in bsInternal._getGameRoster(): if client['clientID'] == self._popupPartyMemberClientID: try: bsInternal._chatMessage("/" + choice + " " + str(client['players'][0]['name'])) except: pass elif choice == "unban": for client in bsInternal._getGameRoster(): if client['clientID'] == self._popupPartyMemberClientID: try: bsInternal._chatMessage("/" + choice + " " + str(client['players'][0]['name'])) except: pass elif choice == "remove": for client in bsInternal._getGameRoster(): if client['clientID'] == self._popupPartyMemberClientID: try: bsInternal._chatMessage("/" + choice + " " + str(client['players'][0]['name'])) except: pass elif choice == "curse": for client in bsInternal._getGameRoster(): if client['clientID'] == self._popupPartyMemberClientID: try: bsInternal._chatMessage("/" + choice + " " + str(client['players'][0]['name'])) except: pass elif choice == "celebrate": for client in bsInternal._getGameRoster(): if client['clientID'] == self._popupPartyMemberClientID: try: bsInternal._chatMessage("/" + choice + " " + str(client['players'][0]['name'])) except: pass elif choice == "freeze": for client in bsInternal._getGameRoster(): if client['clientID'] == self._popupPartyMemberClientID: try: bsInternal._chatMessage("/" + choice + " " + str(client['players'][0]['name'])) except: pass elif choice == "thaw": for client in bsInternal._getGameRoster(): if client['clientID'] == self._popupPartyMemberClientID: try: bsInternal._chatMessage("/" + choice + " " + str(client['players'][0]['name'])) except: pass elif choice == "kill": for client in bsInternal._getGameRoster(): if client['clientID'] == self._popupPartyMemberClientID: try: bsInternal._chatMessage("/" + choice + " " + str(client['players'][0]['name'])) except: pass elif choice == "knock": for client in bsInternal._getGameRoster(): if client['clientID'] == self._popupPartyMemberClientID: try: bsInternal._chatMessage("/" + choice + " " + str(client['players'][0]['name'])) except: pass elif choice == "punch": for client in bsInternal._getGameRoster(): if client['clientID'] == self._popupPartyMemberClientID: try: bsInternal._chatMessage("/" + choice + " " + str(client['players'][0]['name'])) except: pass elif choice == "headless": for client in bsInternal._getGameRoster(): if client['clientID'] == self._popupPartyMemberClientID: try: bsInternal._chatMessage("/" + choice + " " + str(client['players'][0]['name'])) except: pass elif choice == "heal": for client in bsInternal._getGameRoster(): if client['clientID'] == self._popupPartyMemberClientID: try: bsInternal._chatMessage("/" + choice + " " + str(client['players'][0]['name'])) except: pass elif choice == "shield": for client in bsInternal._getGameRoster(): if client['clientID'] == self._popupPartyMemberClientID: try: bsInternal._chatMessage("/" + choice + " " + str(client['players'][0]['name'])) except: pass elif choice == "list": bsInternal._chatMessage("/" + choice) elif choice == "camera": bsInternal._chatMessage("/" + choice) elif choice == "slow": bsInternal._chatMessage("/" + choice) elif choice == "amnesty": bsInternal._chatMessage("/" + choice) elif choice == "help": bsInternal._chatMessage("/" + choice) elif choice == "end": bsInternal._chatMessage("/" + choice) elif choice == "headlessall": bsInternal._chatMessage("/" + choice) elif choice == "killall": bsInternal._chatMessage("/" + choice) elif choice == "freezeall": bsInternal._chatMessage("/" + choice) elif choice == "curseall": bsInternal._chatMessage("/" + choice) elif choice == "shieldall": bsInternal._chatMessage("/" + choice) elif choice == "healall": bsInternal._chatMessage("/" + choice) elif choice == "knockall": bsInternal._chatMessage("/" + choice) elif choice == "thawall": bsInternal._chatMessage("/" + choice) elif choice == "punchall": bsInternal._chatMessage("/" + choice) elif choice == "celebrateall": bsInternal._chatMessage("/" + choice) elif self._popupType == 'menu': if choice in ('mute', 'unmute'): bsConfig = bs.getConfig() bsConfig['Chat Muted'] = (choice == 'mute') bs.writeConfig() bs.applySettings() self._update() else: bs.textWidget(edit=self._textField, text='')
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)