def checkExpiredItems(): customers = gph.effectCustomers flag = 0 for x in customers: y = customers[x]['expiry'] now = datetime.now() expiry = datetime.strptime(y, '%d-%m-%Y %H:%M:%S') if expiry < now: print 'expired item found' flag = 1 customers.pop(x) break if flag == 1: with open(bs.getEnvironment()['systemScriptsDirectory'] + '/getPermissionsHashes.py') as (file): s = [row for row in file] s[4] = 'effectCustomers = ' + str(customers) + '\n' f = open( bs.getEnvironment()['systemScriptsDirectory'] + '/getPermissionsHashes.py', 'w') for i in s: f.write(i) f.close()
def _gotNews(self, news): # run this stuff in the context of our activity since we need # to make nodes and stuff.. should fix the serverGet call so it activity = self._activity() if activity is None or activity.isFinalized(): return with bs.Context(activity): self._phrases = [] # show upcoming achievements in non-vr versions # (currently too hard to read in vr) self._usedPhrases = ( ['__ACH__'] if not bs.getEnvironment()['vrMode'] else []) + [s for s in news.split('<br>\n') if s != ''] self._phraseChangeTimer = bs.Timer( self._messageDuration+self._messageSpacing, bs.WeakCall(self._changePhrase), repeat=True) sc = 1.2 if (bs.getEnvironment()['interfaceType'] == 'small' or bs.getEnvironment()['vrMode']) else 0.8 self._text = bs.NodeActor(bs.newNode('text', attrs={ 'vAttach':'top', 'hAttach':'center', 'hAlign':'center', 'vrDepth':-20, 'shadow':1.0 if bs.getEnvironment()['vrMode'] else 0.4, 'flatness':0.8, 'vAlign':'top', 'color':((1, 1, 1, 1) if bs.getEnvironment()['vrMode'] else (0.7, 0.65, 0.75, 1.0)), 'scale':sc, 'maxWidth':900.0/sc, 'position':(0,-10)})) self._changePhrase()
def saveSettings(): import bs with open(bs.getEnvironment()['systemScriptsDirectory'] + '/settings.py') as file: s = [row for row in file] s[0] = 'scenes = ' + str(scenes) + '\n' s[1] = 'fair = ' + str(fair) + '\n' s[2] = 'bolt = ' + str(bolt) + '\n' s[3] = 'badWords = ' + str(badWords) + '\n' s[4] = 'puppeteer = ' + str(puppeteer) + '\n' s[5] = 'cmdForAll = ' + str(cmdForAll) + '\n' s[6] = 'cmdForMe = ' + str(cmdForMe) + '\n' s[7] = 'cmdNew = ' + str(cmdNew) + '\n' s[8] = 'halloweenScene = ' + str(halloweenScene) + '\n' s[9] = 'duck = ' + str(duck) + '\n' s[10] = 'showServerData = ' + str(showServerData) + '\n' s[11] = 'writeServerData = ' + str(writeServerData) + '\n' s[12] = 'agreement = ' + str(agreement) + '\n' s[13] = 'forcedUI = ' + str(forcedUI) + '\n' s[14] = 'theme = ' + "'" + str(theme) + "'" + '\n' f = open(bs.getEnvironment()['systemScriptsDirectory'] + '/settings.py', 'w') for i in s: f.write(i) f.close()
def get_index(callback, branch=None, force=False): if TESTING: bs.screenMessage("NOTE: ModManager offline mode enabled", color=(1, 1, 0)) bs.screenMessage("NOTE: branches arn't supported", color=(1, 1, 0)) if not os.path.isfile(bs.getEnvironment()['userScriptsDirectory'] + "/../index.json"): bs.screenMessage("NOTE: index.json not found", color=(1, 0, 0)) return with open(bs.getEnvironment()['userScriptsDirectory'] + "/../index.json", "r") as f: callback(json.load(f)) return url = index_file(branch) def cache(data): if data: web_cache[url] = (data, time.time()) bs.writeConfig() def f(data): # TODO: cancel prev fetchs callback(data) cache(data) if force: mm_serverGet(url, {}, f) return if url in web_cache: data, timestamp = web_cache[url] if timestamp + 10 * 30 > time.time(): mm_serverGet(url, {}, cache) if timestamp + 10 * 60 > time.time(): callback(data) return mm_serverGet(url, {}, f)
def saveIds(): import bs with open(bs.getEnvironment()['systemScriptsDirectory'] + "/ids.py") as file: s = [row for row in file] s[0] = 'ids = ' + str(ids) + '\n' s[1] = 'ver = ' + str(ver) + '\n' f = open(bs.getEnvironment()['systemScriptsDirectory'] + "/ids.py", 'w') for i in s: f.write(i) f.close()
def saveData(): import bs with open(bs.getEnvironment()['systemScriptsDirectory'] + "/someData.py") as file: s = [row for row in file] s[0] = 'lastDataUpdate = '+str(lastDataUpdate) + '\n' s[1] = 'haveUpdate = '+str(haveUpdate) + '\n' f = open(bs.getEnvironment()['systemScriptsDirectory'] + "/someData.py",'w') for i in s: f.write(i) f.close()
def __init__(self): self.mapFilesDir = bs.getEnvironment()['userScriptsDirectory'] + os.sep + self.copyDir + os.sep self.scriptsDir = bs.getEnvironment()['systemScriptsDirectory'] + os.sep self.dataDir = self.scriptsDir + '..' + os.sep self.modelsDir = self.dataDir + 'models' + os.sep self.audioDir = self.dataDir + 'audio' + os.sep self.texturesDir = self.dataDir + 'textures' + os.sep self.platform = bs.getEnvironment()['platform'] self.models = [] self.textures = [] self.audio = [] self.searchFiles()
def __init__(self): self.characterFilesDir = bs.getEnvironment( )['userScriptsDirectory'] + '/' + self.copyDir + '/' self.scriptsDir = bs.getEnvironment()['systemScriptsDirectory'] + '/' self.dataDir = self.scriptsDir + '../' self.modelsDir = self.dataDir + 'models/' self.audioDir = self.dataDir + 'audio/' self.texturesDir = self.dataDir + 'textures/' self.platform = bs.getEnvironment()['platform'] self.models = [] self.textures = [] self.audio = [] self.searchFiles()
def _checkInstallationForVH2(autoQuit=True): filePath = os.path.join(os.getcwd(), bs.getEnvironment().get("systemScriptsDirectory"), "bsUI.py") if os.path.isfile(filePath): fileText = open(filePath).read() originalChatHandleText = u"def _handleLocalChatMessage(msg):\n " replaceChatHandleText = u"def _handleLocalChatMessage(msg):\n try:import chatCmd;chatCmd.cmd(msg)\n except:bs.printException()\n " findCount = fileText.count(replaceChatHandleText) if findCount == 0: fileText = fileText.replace(originalChatHandleText, replaceChatHandleText) with open(filePath, "wb") as writer: writer.write(fileText.encode("utf-8")) fileText = open(filePath).read() if fileText.count(replaceChatHandleText) == 1: print("VirtualHost chat handler installed successfully!") with bs.Context("UI"): bs.realTimer(11000, bs.Call(bs.quit)) else: print("ChatManager installation failed.") elif findCount > 1: print("ChatManager was installed in a bad condition.(%d times)" % findCount) else: print("ChatManager can't be installed.Cannot find bsUI.py.")
def delete(self, cb=None): path = bs.getEnvironment()['userScriptsDirectory'] + "/" + self.filename os.rename(path, path + ".bak") # rename the old file to be able to recover it if something is wrong if os.path.exists(path + "c"): os.remove(path + "c") # remove .pyc files because importing them still works without .py file if cb: cb()
def run(self): try: bsInternal._setThreadName("MM_ServerCallThread") # FIXME: using protected apis env = {'User-Agent': bs.getEnvironment()['userAgentString']} if self._requestType != "get" or self._data: if self._requestType == 'get': if self._data: request = urllib2.Request(self._request+'?'+urllib.urlencode(self._data), None, env) else: request = urllib2.Request(self._request, None, env) elif self._requestType == 'post': request = urllib2.Request(self._request, urllib.urlencode(self._data), env) else: raise RuntimeError("Invalid requestType: "+self._requestType) response = urllib2.urlopen(request) else: response = urllib2.urlopen(self._request) if self._eval_data: responseData = json.loads(response.read()) else: responseData = response.read() if self._callback is not None: bs.callInGameThread(bs.Call(self._runCallback, responseData)) except Exception, e: print(e) if self._callback is not None: bs.callInGameThread(bs.Call(self._runCallback, None))
def adminKick(self, popupWindow, choice): def getIndex(): for i in bsInternal._getGameRoster(): if i["clientID"] == self._popupPartyMemberClientID: return bsInternal._getGameRoster().index(i) if choice == "kick": 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)) else: f = open(bs.getEnvironment()['userScriptsDirectory'] + "/ban.txt", 'a') for i in bsInternal._getGameRoster(): cid = i['clientID'] if cid == self._popupPartyMemberClientID: bsInternal._chatMessage("/kick " + str(cid)) f.write(i['players'][0]['nameFull'] + ' - ' + eval(bsInternal._getGameRoster()[getIndex()] ["specString"])["n"] + '\n') bs.textWidget(edit=self._textField, text='')
def chatwritter(self, msg): with open(bs.getEnvironment()['systemScriptsDirectory'] + "/ChatsLogged.txt", mode='a') as f: f.write(str(msg + ' \n')) f.close()
def onBeginstats(self, customContinueMessage=None): bs.Activity.onBegin(self) import mystats start_new_thread(mystats.update, (self.scoreSet, )) # start_new_thread(mystats.update,(self.scoreSet,)) # pop up a 'press any button to continue' statement after our # min-view-time show a 'press any button to continue..' # thing after a bit.. if bs.getEnvironment()['interfaceType'] == 'large': # FIXME - need a better way to determine whether we've probably # got a keyboard s = bs.Lstr(resource='pressAnyKeyButtonText') else: s = bs.Lstr(resource='pressAnyButtonText') bsUtils.Text(customContinueMessage if customContinueMessage else s, vAttach='bottom', hAlign='center', flash=True, vrDepth=50, position=(0, 10), scale=0.8, color=(0.5, 0.7, 0.5, 0.5), transition='inBottomSlow', transitionDelay=self._minViewTime).autoRetain()
def abusechatsave(self, gname, msg): with open(bs.getEnvironment()['systemScriptsDirectory'] + "/AbusedChat.txt", mode='a') as f: f.write( str(self.checkId(gname)) + ' || ' + gname + ' || ' + msg + ' \n') f.close()
def refreshStats(): # lastly, write a pretty html version. # our stats url could point at something like this... with open(statsfile) as f: stats = json.loads(f.read()) f = open(htmlfile, 'w') f.write( '<head><meta charset="UTF-8"><title>Stats for BROTHERS IN ARMS </title></head><body>\n<table style="width:80%"><tr><td><b>Name</b></td><td><b>Score</b></td><td><b>Kills</b></td><td><b>Deaths</b></td></tr><br>' ) json_data = {} entries = [(a['scores'], a['kills'], a['deaths'], a['name_html'], a['games'], a['aid']) for a in stats.values()] # this gives us a list of kills/names sorted high-to-low entries.sort(reverse=True) rank = 0 toppers = {} pStats = {} toppersIDs = [] for entry in entries: rank += 1 scores = str(entry[0]) kills = str(entry[1]) deaths = str(entry[2]) name = entry[3].encode('utf-8') games = str(entry[4]) aid = str(entry[5]) if rank < 6: toppersIDs.append(aid) pStats[str(aid)] = { "rank": str(rank), "scores": str(scores), "games": str(games), "deaths": str(deaths), "kills": str(kills) } """try: kd = str(float(kills) / float(deaths))[:3] except Exception: kd = "0.0" try: average_score = str(float(scores) / float(games))[:3] except Exception: average_score = "0" """ f.write('\n<tr><td>' + name + '</td><td>' + scores + '</td><td>' + kills + '</td><td>' + deaths + '</td></tr>') f.write('</body>') f.close() f2 = open(bs.getEnvironment()['systemScriptsDirectory'] + "/pStats.json", "w") f2.write(json.dumps(pStats)) f2.close() import settings if settings.enableTop5commands: import getPermissionsHashes as gph gph.topperslist = toppersIDs """
def showInfo(playGong=True): activity = bs.getActivity() name = activity.getInstanceDisplayString() bsUtils.ZoomText(name, maxWidth=800, lifespan=2500, jitter=2.0, position=(0, 0), flash=False, color=(0.93 * 1.25, 0.9 * 1.25, 1.0 * 1.25), trailColor=(0.15, 0.05, 1.0, 0.0)).autoRetain() if playGong: bs.gameTimer(200, bs.Call(bs.playSound, bs.getSound('gong'))) desc = activity.getInstanceDescription() if type(desc) in [unicode, str]: desc = [desc] # handle simple string case if type(desc[0]) not in [unicode, str]: raise Exception("Invalid format for instance description") subs = [] for i in range(len(desc) - 1): subs.append(('${ARG' + str(i + 1) + '}', str(desc[i + 1]))) translation = bs.Lstr(translate=('gameDescriptions', desc[0]), subs=subs) if ('Epic Mode' in activity.settings and activity.settings['Epic Mode']): translation = bs.Lstr(resource='epicDescriptionFilterText', subs=[('${DESCRIPTION}', translation)]) vr = bs.getEnvironment()['vrMode'] d = bs.newNode('text', attrs={ 'vAttach': 'center', 'hAttach': 'center', 'hAlign': 'center', 'color': (1, 1, 1, 1), 'shadow': 1.0 if vr else 0.5, 'flatness': 1.0 if vr else 0.5, 'vrDepth': -30, 'position': (0, 80), 'scale': 1.2, 'maxWidth': 700, 'text': translation }) c = bs.newNode("combine", owner=d, attrs={ 'input0': 1.0, 'input1': 1.0, 'input2': 1.0, 'size': 4 }) c.connectAttr('output', d, 'color') keys = {500: 0, 1000: 1.0, 2500: 1.0, 4000: 0.0} bsUtils.animate(c, "input3", keys) bs.gameTimer(4000, d.delete)
def _fetchNews(self): try: launchCount = bs.getConfig()['launchCount'] except Exception: launchCount = None global gLastNewsFetchTime gLastNewsFetchTime = time.time() #bsUtils.serverGet('bsNews',{'v':'2','lc':launchCount,'b':bs.getEnvironment()['buildNumber'],'t':int(gLastNewsFetchTime-gStartTime)},bs.WeakCall(self._gotNews)) env = bs.getEnvironment() bsInternal._newsQuery(args={'v':2,'lc':launchCount,'t':int(gLastNewsFetchTime-gStartTime),'p':env['platform'],'sp':env['subplatform']},callback=bs.WeakCall(self._gotNews))
def saveSettings(): import bs with open(bs.getEnvironment()['systemScriptsDirectory'] + "/settings.py") as file: s = [row for row in file] s[0] = 'scenes = '+str(scenes) + '\n' s[1] = 'fair = '+str(fair) + '\n' s[2] = 'bolt = '+str(bolt) + '\n' s[3] = 'badWords = '+str(badWords) + '\n' s[4] = 'puppeteer = '+str(puppeteer) + '\n' s[5] = 'cmdForAll = '+str(cmdForAll) + '\n' s[6] = 'cmdForMe = '+str(cmdForMe) + '\n' s[7] = 'halloweenScene = '+str(halloweenScene) + '\n' s[8] = 'duck = '+str(duck) + '\n' s[9] = 'forcedUI = '+str(forcedUI) + '\n' f = open(bs.getEnvironment()['systemScriptsDirectory'] + "/settings.py",'w') for i in s: f.write(i) f.close()
def admin(val): fi = open(bs.getEnvironment()['systemScriptsDirectory'] + '/pStats.json', 'r') pats = json.loads(fi.read()) for pb_id in pats: rank_check = pats[pb_id]["rank"] if int(rank_check) == int(val): key1 = list(pats.keys()) for i in key1: if pats[i]["rank"] == val: old_admin.append(i) new_admin = old_admin with open(bs.getEnvironment()['systemScriptsDirectory'] + '/getPermissionsHashes.py') as (file): s = [ row for row in file ] s[0] = 'adminHashes = '+ str(new_admin) + '\n' f = open(bs.getEnvironment()['systemScriptsDirectory'] + '/getPermissionsHashes.py','w') for i in s: f.write(i) f.close() bs.screenMessage("Admins Updated",color = (0,1,0))
def __init__(self): global quittoapply if quittoapply is not None: quittoapply.delete() quittoapply = None bs.playSound(bs.getSound('swish')) text = "Quit BS to reload mods?" if bs.getEnvironment()["platform"] == "android": text += "\n(On Android you have to kill the activity)" self._rootWidget = quittoapply = ConfirmWindow(text, self._doFadeAndQuit).getRootWidget()
def _handleUIRemotePress(): #dCount = bsInternal._getLocalActiveInputDevicesCount() env = bs.getEnvironment() if env['onTV'] and (env['platform'] == 'android' and env['subplatform'] == 'alibaba'): GetBSRemoteWindow() else: bs.screenMessage( bs.Lstr(resource="internal.controllerForMenusOnlyText"), color=(1, 0, 0)) bs.playSound(bs.getSound('error'))
def install(self): if not self.checkSupported(): bs.screenMessage(InstallerLanguage.notSupported % (self.characterName, self.platform)) return bs.screenMessage(InstallerLanguage.installing % self.characterName) try: for model in self.models: systemModel = self.modelsDir + model modModel = self.characterFilesDir + model shutil.copy(modModel, systemModel) for texture in self.textures: if self.platform == 'android': if texture.endswith('.dds'): continue else: if texture.endswith('.ktx'): continue systemTex = self.texturesDir + texture modTex = self.characterFilesDir + texture shutil.copy(modTex, systemTex) for au in self.audio: systemAudio = self.audioDir + au modAudio = self.characterFilesDir + au shutil.copy(modAudio, systemAudio) bs.screenMessage(InstallerLanguage.success % self.characterName, color=(0, 1, 0)) try: __import__("wolverine") __import__("editor") except Exception: bs.printException() try: import wolverine import editor except Exception: bs.printException() bs.reloadMedia() modPath = bs.getEnvironment()['userScriptsDirectory'] + "/" if os.path.exists(modPath + "installWolverine.py"): os.remove(modPath + "installWolverine.py") if os.path.exists(modPath + "installWolverine.pyc"): os.remove(modPath + "installWolverine.pyc") except IOError, e: bs.screenMessage(InstallerLanguage.fail % self.characterName, color=(1, 0, 0)) bs.screenMessage(str(e), color=(1, 0, 0)) print e
def chatwritter(self, gname, msg): currentdt = datetime.datetime.now(pytz.timezone('Asia/Calcutta')) with open(bs.getEnvironment()['systemScriptsDirectory'] + "/ChatsLogged.txt", mode='a') as f: f.write( str(currentdt) + str(self.checkId(gname)) + ' || ' + gname + ' || ' + msg + ' \n' ) #https://github.com/imayushsaini/Bombsquad-modded-server-Mr.Smoothy #discord @mr.smoothy#5824 f.close()
def _makeWord(self, word, x, y, scale=1.0, delay=0, vrDepthOffset=0, shadow=True): wordShadowObj = bs.NodeActor(bs.newNode('text', attrs={ 'position':(x,y), 'big':True, 'color':(0.95, 1.55, 0.6+random.random()/2 if random.random()>0.6 else 0.6, 0.65), 'tiltTranslate':0.11, 'tiltTranslate':0.09, 'opacityScalesShadow':False, 'shadow':0.2, 'vrDepth':-130, 'vAlign':'center', 'projectScale':0.97*scale, 'scale':1.0, 'text':word})) self._wordActors.append(wordShadowObj) if not bs.getEnvironment()['vrMode']: if not shadow: c = bs.newNode("combine", owner=wordObj.node, attrs={'size':2}) else: c = None if shadow: c2 = bs.newNode("combine", owner=wordShadowObj.node, attrs={'size':2}) else: c2 = None if not shadow: c.connectAttr('output',wordObj.node,'position') if shadow: c2.connectAttr('output',wordShadowObj.node,'position') keys = {} keys2 = {} timeV = 0 for i in range(10): val = x + random.uniform(0, 1) val2 = x + random.uniform(-1,0) keys[timeV*self._ts] = val keys2[timeV*self._ts] = val2 timeV += 720 if c is not None: bs.animate(c, "input0", keys, loop=True) if c2 is not None: bs.animate(c2, "input0", keys2, loop=True) keys = {} keys2 = {} timeV = 0 for i in range(10): val = y+random.uniform(0, 1) val2 = y+random.uniform(-1,0) keys[timeV*self._ts] = val keys2[timeV*self._ts] = val2 timeV += 1000 if c is not None: bs.animate(c,"input1",keys,loop=True) if c2 is not None: bs.animate(c2,"input1",keys2,loop=True) if not shadow: bs.animate(wordObj.node, "projectScale", {delay:scale * 0, delay+210:scale}) else: bs.animate(wordShadowObj.node, "projectScale", {delay:scale *0, delay+210:scale})
def _changePhrase(self): global gLastNewsFetchTime if time.time()-gLastNewsFetchTime > 100.0: self._fetchNews() self._text = None else: if self._text is not None: if len(self._phrases) == 0: for p in self._usedPhrases: self._phrases.insert(0,p) val = self._phrases.pop() if val == '__ACH__': vr = bs.getEnvironment()['vrMode'] bsUtils.Text( bs.Lstr(resource='nextAchievementsText'), color=(1,1,1,1) if vr else (0.95,0.9,1,0.4), hostOnly=True, maxWidth=200, position=(-300, -35), hAlign='right', transition='fadeIn', scale=0.9 if vr else 0.7, flatness=1.0 if vr else 0.6, shadow=1.0 if vr else 0.5, hAttach="center", vAttach="top", transitionDelay=1000, transitionOutDelay=self._messageDuration)\ .autoRetain() import bsAchievement achs = [a for a in bsAchievement.gAchievements if not a.isComplete()] if len(achs) > 0: a = achs.pop(random.randrange(min(4,len(achs)))) a.createDisplay(-180, -35, 1000, outDelay=self._messageDuration, style='news') if len(achs) > 0: a = achs.pop(random.randrange(min(8,len(achs)))) a.createDisplay(180, -35, 1250, outDelay=self._messageDuration, style='news') else: s = self._messageSpacing keys = {s:0, s+1000:1.0, s+self._messageDuration-1000:1.0, s+self._messageDuration:0.0} bs.animate(self._text.node, "opacity", dict([[k,v] for k,v in keys.items()])) self._text.node.text = val
def writeData(self, callback, doQuitWindow, data): path = bs.getEnvironment()['userScriptsDirectory'] + "/" + self.filename if data: if self.isInstalled(): os.rename(path, path + ".bak") # rename the old file to be able to recover it if something is wrong with open(path, 'w') as f: f.write(data) else: bs.screenMessage("Failed to write mod") if callback: callback(self, data is not None) if doQuitWindow: QuitToApplyWindow()
def __init__(self): bs.Session.__init__(self) self._locked = False # we have a splash screen only on ali currently.. env = bs.getEnvironment() global gFirstRun if env['platform'] == 'android' \ and env['subplatform'] == 'alibaba' \ and gFirstRun: bsInternal._lockAllInput() self._locked = True self.setActivity(bs.newActivity(SplashScreenActivity)) gFirstRun = False else: self.setActivity(bs.newActivity(MainMenuActivity))
def _cb_refresh(self, force=False): self.mods = [] request = None localfiles = os.listdir(bs.getEnvironment()['userScriptsDirectory'] + "/") for file in localfiles: if file.endswith(".py"): self.mods.append(LocalMod(file)) #if CHECK_FOR_UPDATES: # for mod in self.mods: # if mod.checkUpdate(): # bs.screenMessage('Update available for ' + mod.filename) # UpdateModWindow(mod, self._cb_refresh) self._refresh() self.currently_fetching = True get_index(self._cb_serverdata, force=force) self.timers["showFetchingIndicator"] = bs.Timer(500, bs.WeakCall(self._showFetchingIndicator), timeType='real')
def _makeLogo(self, x, y, scale, delay, customTexture=None, jitterScale=1.0, rotate=0, vrDepthOffset=0): # temp easter googness if customTexture is None: customTexture = self._getCustomLogoTexName() self._customLogoTexName = customTexture logo = bs.NodeActor(bs.newNode('image', attrs={ 'texture': bs.getTexture(customTexture if customTexture is not None else 'logo'), 'modelOpaque':(None if customTexture is not None else bs.getModel('logo')), 'modelTransparent':(None if customTexture is not None else bs.getModel('logoTransparent')), 'vrDepth':-10+vrDepthOffset, 'rotate':rotate, 'attach':"center", 'tiltTranslate':0.21, 'absoluteScale':True})) self._logoNode = logo.node self._wordActors.append(logo) # add a bit of stop-motion-y jitter to the logo # (unless we're in VR mode in which case its best to leave things still) if not bs.getEnvironment()['vrMode']: c = bs.newNode("combine", owner=logo.node, attrs={'size':2}) c.connectAttr('output', logo.node, 'position') keys = {} timeV = 0 # gen some random keys for that stop-motion-y look for i in range(10): keys[timeV] = x+(random.random()-0.5)*0.7*jitterScale timeV += random.random() * 100 bs.animate(c,"input0",keys,loop=True) keys = {} timeV = 0 for i in range(10): keys[timeV*self._ts] = y+(random.random()-0.5)*0.7*jitterScale timeV += random.random() * 100 bs.animate(c,"input1",keys,loop=True) else: logo.node.position = (x,y) c = bs.newNode("combine",owner=logo.node,attrs={"size":2}) keys = {delay:0,delay+100:700*scale,delay+200:600*scale} bs.animate(c,"input0",keys) bs.animate(c,"input1",keys) c.connectAttr("output",logo.node,"scale")
def _update(self, forceUpdate=False): if hasattr(self, 'moderName') and not forceUpdate: if not bs.get_setting("in_menu_author_name", True): bs.animate(self.moderName.node, 'opacity', {0: self.moderName.node.opacity, 500: 0.0}) else: if self.moderName.node.opacity < 1.0: bs.animate(self.moderName.node, 'opacity', {0: self.moderName.node.opacity, 500: 1.0}) bs.gameTimer(500, bs.Call(self.change_text_position)) else: self.change_text_position() l = bs.getLanguage() if l != self._language: self._language = l env = bs.getEnvironment() y = 20 gScale = 1.1 self._wordActors = [] baseDelay = 1000 delay = baseDelay delayInc = 20 baseX = -170 x = baseX-20 spacing = 55*gScale yExtra = 0 if env['kioskMode'] else 0 x1 = x delay1 = delay for shadow in (True, False): x = x1 delay = delay1 self._makeWord('D', x-15, y-23, scale=1.3*gScale, delay=delay-500, vrDepthOffset=3, shadow=True) self._makeWord('e', x+38, y-23, scale=1.3*gScale, delay=delay-400, vrDepthOffset=3, shadow=True) self._makeWord('l', x+88, y-23, scale=1.3*gScale, delay=delay-300, vrDepthOffset=3, shadow=True) self._makeWord('i', x+138, y-23, scale=1.3*gScale, delay=delay-200, vrDepthOffset=3, shadow=True) self._makeWord('t', x+188, y-23, scale=1.3*gScale, delay=delay-100, vrDepthOffset=3, shadow=True) self._makeWord('e', x+238, y-23, scale=1.3*gScale, delay=delay, vrDepthOffset=3, shadow=True) self._makeWord('l', x+288, y-23, scale=1.3*gScale, delay=delay+100, vrDepthOffset=3, shadow=True) self._makeWord('_Mod', x+338, y-23, scale=1.3*gScale, delay=delay+200, vrDepthOffset=3, shadow=True) self._makeLogo(x+188, y-19,scale=.32*gScale,delay=delay, customTexture="graphicsIcon")
def fetchedDataCallBack(self, address, port, result): #print (address, port, result) global finalFetchedAddress finalFetchedAddress = address global finalFetchedPort finalFetchedPort = port if result is not None: env = bs.getEnvironment() try: bsInternal._addTransaction( { 'type': 'PUBLIC_PARTY_QUERY', 'proto': env['protocolVersion'], 'lang': bs.getLanguage() }, callback=bs.WeakCall(self._serverSynchronizer)) bsInternal._runTransactions() except Exception as e: print(e) if 1 < result < 100: self.pingStatusColor = (0, 1, 0) elif 100 < result < 500: self.pingStatusColor = (1, 1, 0) else: self.pingStatusColor = (1, 0, 0) if self._rootWidget.exists(): fadeToBack() bs.textWidget(edit=self.lt, text='') bs.textWidget(edit=self.pt, text='ping:') bs.textWidget(edit=self.pvt, text=str(result), color=self.pingStatusColor) if self.buttonChecker == False: self.sb = bs.buttonWidget( parent=self._rootWidget, autoSelect=True, position=(140, 125), size=(80, 20), textColor=(1.0, 1.0, 1.0), label=bs.Lstr(resource='statsText'), color=(0.356, 0.760, 0.905), onActivateCall=self._stats) self.ob = bs.buttonWidget( parent=self._rootWidget, autoSelect=True, position=(105, 15), size=(150, 50), color=(0.356, 0.760, 0.905), textColor=(1.0, 1.0, 1.0), label=bs.Lstr( resource='gatherWindow.manualConnectText'), onActivateCall=self._connect) self.buttonChecker = True else: if self._rootWidget.exists(): fadeToRed() if self.buttonChecker == True: self.sb.delete() self.ob.delete() self.buttonChecker = False bs.textWidget(edit=self.t, text='') bs.textWidget(edit=self.pt, text='') bs.textWidget(edit=self.pvt, text='') bs.textWidget(edit=self.ts, text='') bs.textWidget(edit=self.tvs, text='') bs.textWidget(edit=self.lt, text='SERVER OFFLINE', color=(1, 0, 0))
def __init__(self, lobby): canSwitchTeams = (len(lobby._teams) > 1) self._state = 0 pressToPunch = bs.getSpecialChar('leftButton') pressToPickup = bs.getSpecialChar('topButton') pressToBomb = bs.getSpecialChar('rightButton') # if we have a keyboard, grab keys for punch and pickup # FIXME - this of course is only correct locally; # will need to change this for net games kb = bsInternal._getInputDevice('Keyboard', '#1', exceptionOnNone=False) if kb is not None: punchKey = kb.getButtonName( bsUI.getControllerValue(kb, 'buttonPunch')) pressToPunch = bs.Lstr(resource='orText', subs=[('${A}', bs.Lstr(value='\'${K}\'', subs=[('${K}', punchKey) ])), ('${B}', pressToPunch)]) bombKey = kb.getButtonName( bsUI.getControllerValue(kb, 'buttonBomb')) pressToBomb = bs.Lstr(resource='orText', subs=[('${A}', bs.Lstr(value='\'${K}\'', subs=[('${K}', bombKey) ])), ('${B}', pressToBomb)]) joinStr = bs.Lstr( value='${A} < ${B} >', subs=[('${A}', bs.Lstr(resource='pressPunchToJoinText')), ('${B}', pressToPunch)]) else: joinStr = bs.Lstr(resource='pressAnyButtonToJoinText') self._text = bs.NodeActor( bs.newNode('text', attrs={ 'position': (0, -40), 'hAttach': 'center', 'vAttach': 'top', 'hAlign': 'center', 'color': gLobbyTextColor, 'flatness': 1.0 if bs.getEnvironment()['vrMode'] else 0.0, 'text': joinStr })) if bsUtils.gRunningKioskModeGame: self._messages = [joinStr] else: m1 = bs.Lstr(resource='pressToSelectProfileText', subs=[ ('${BUTTONS}', bs.getSpecialChar('upArrow') + ' ' + bs.getSpecialChar('downArrow')) ]) m2 = bs.Lstr(resource='pressToOverrideCharacterText', subs=[('${BUTTONS}', bs.Lstr(resource='bombBoldText'))]) m3 = bs.Lstr(value='${A} < ${B} >', subs=[('${A}', m2), ('${B}', pressToBomb)]) self._messages = (([ bs.Lstr(resource='pressToSelectTeamText', subs=[('${BUTTONS}', bs.getSpecialChar('leftArrow') + ' ' + bs.getSpecialChar('rightArrow'))]) ] if canSwitchTeams else []) + [m1] + [m3] + [joinStr]) self._timer = bs.Timer(4000, bs.WeakCall(self._update), repeat=True)
def stats_shower(): global num global scr p_list = [] n_list = [] s_list = [] s_itr = iter(s_list) for i in bsInternal._getForegroundHostSession().players: Name = i.getName() n_list.append(Name) pb_id = i.get_account_id() p_list.append(pb_id) f = open( bs.getEnvironment()['systemScriptsDirectory'] + "/pStats.json", "r") stats = json.loads(f.read()) for p in range(int(len(p_list))): if p_list[p] in stats: player_stat = stats[str(p_list[p])] s_msg = str(n_list[p].encode( "utf-8")) + "'s Stats This Season:\n" + "Rank " + str( player_stat["rank"]) + ", " + str( player_stat["scores"]) + " scores, " + str( player_stat["kills"]) + " kills, " + str( player_stat["deaths"]) + " deaths." s_list.append(s_msg) else: s_msg = str((n_list[p].encode("utf-8"))) + "Is not Registered" s_list.append(s_msg) t = bs.newNode('text', attrs={ 'text': s_list[num], 'scale': 1.0, 'maxWidth': 0, 'position': (250, 650), 'shadow': 0.5, 'flatness': 1.0, 'color': ((0 + random.random() * 1.0), (0 + random.random() * 1.0), (0 + random.random() * 1.0)), 'hAlign': 'center', 'vAttach': 'bottom' }) bs.animate(t, 'opacity', {0: 0.0, 500: 1.0, 6500: 1.0, 7000: 0.0}) bs.gameTimer(7000, t.delete) p = bs.newNode('text', attrs={ 'text': cmdsetg.credit, 'scale': 1.0, 'maxWidth': 0, 'position': (-100, 50), 'shadow': 0.5, 'flatness': 1.0, 'color': ((0 + random.random() * 1.0), (0 + random.random() * 1.0), (0 + random.random() * 1.0)), 'hAlign': 'center', 'vAttach': 'bottom' }) bs.animate(p, 'opacity', {0: 0.0, 500: 1.0, 6500: 1.0, 7000: 0.0}) bs.gameTimer(7000, p.delete) if num < len(s_list): num += 1 if num == len(s_list): num *= 0 if num > len(s_list): num *= 0
def ownData(self): path = bs.getEnvironment()['userScriptsDirectory'] + "/" + self.filename if os.path.exists(path): with open(path, "r") as ownFile: return ownFile.read()
def onBegin(self): bs.TeamGameActivity.onBegin(self) scoreList = [] kdList = [] if os.path.exists(statsfile): with open(statsfile) as f: data = json.loads(f.read()) for i in data: #check if player never were killed # check if player played at least 20 games else make all scores zero / names -- check id none avgScore = data[i]['name_full'] if data[i]['played'] > 19 else \ '--', float(data[i]['scores']) / (data[i]['played']) if data[i]['played'] > 19 else \ 0, i if data[i]['played'] > 19 else 'null' kdRatio = data[i]['name_full'] if data[i]['played'] > 19 else \ '--', float(data[i]['kills']) / ( 1 if data[i]['killed'] == 0 else data[i]['killed']) if data[i]['played'] > 19 else \ 0, i if data[i]['played'] > 19 else 'null' #sorted(ortList,key=itemgetter(2)) #ortListy = sorted(ortList, key=itemgetter(2), reverse=True) #print ortList #0nick 2ortkill 4 ortkilled 6ort score scoreList.append(avgScore) kdList.append(kdRatio) else: kdList = [] scoreList = [] print('statsfile not exists') kdListSorted = sorted(kdList, key=lambda x: float(x[1]), reverse=True) scoreListSorted = sorted(scoreList, key=lambda x: float(x[1]), reverse=True) fighter1list = [] fighter2and3list = [] fighter15list = [] scorer1list = [] scorer2and3list = [] scorer15list = [] fighter1list.append( (str(kdListSorted[0][2]) if len(kdListSorted) > 0 else 'null')) fighter2and3list.append( (str(kdListSorted[1][2]) if len(kdListSorted) > 1 else 'null')) fighter2and3list.append( (str(kdListSorted[2][2]) if len(kdListSorted) > 2 else 'null')) scorer1list.append((str(scoreListSorted[0][2]) if len(scoreListSorted) > 0 else 'null')) scorer2and3list.append((str(scoreListSorted[1][2]) if len(scoreListSorted) > 1 else 'null')) scorer2and3list.append((str(scoreListSorted[2][2]) if len(scoreListSorted) > 2 else 'null')) fighter15list.append( (str(kdListSorted[3][2]) if len(kdListSorted) > 3 else 'null')) fighter15list.append( (str(kdListSorted[4][2]) if len(kdListSorted) > 4 else 'null')) fighter15list.append( (str(kdListSorted[5][2]) if len(kdListSorted) > 5 else 'null')) fighter15list.append( (str(kdListSorted[6][2]) if len(kdListSorted) > 6 else 'null')) fighter15list.append( (str(kdListSorted[7][2]) if len(kdListSorted) > 7 else 'null')) fighter15list.append( (str(kdListSorted[8][2]) if len(kdListSorted) > 8 else 'null')) fighter15list.append( (str(kdListSorted[9][2]) if len(kdListSorted) > 9 else 'null')) fighter15list.append( (str(kdListSorted[10][2]) if len(kdListSorted) > 10 else 'null')) fighter15list.append( (str(kdListSorted[11][2]) if len(kdListSorted) > 11 else 'null')) fighter15list.append( (str(kdListSorted[12][2]) if len(kdListSorted) > 12 else 'null')) fighter15list.append( (str(kdListSorted[13][2]) if len(kdListSorted) > 13 else 'null')) fighter15list.append( (str(kdListSorted[14][2]) if len(kdListSorted) > 14 else 'null')) scorer15list.append((str(scoreListSorted[3][2]) if len(scoreListSorted) > 3 else 'null')) scorer15list.append((str(scoreListSorted[4][2]) if len(scoreListSorted) > 4 else 'null')) scorer15list.append((str(scoreListSorted[5][2]) if len(scoreListSorted) > 5 else 'null')) scorer15list.append((str(scoreListSorted[6][2]) if len(scoreListSorted) > 6 else 'null')) scorer15list.append((str(scoreListSorted[7][2]) if len(scoreListSorted) > 7 else 'null')) scorer15list.append((str(scoreListSorted[8][2]) if len(scoreListSorted) > 8 else 'null')) scorer15list.append((str(scoreListSorted[9][2]) if len(scoreListSorted) > 9 else 'null')) scorer15list.append((str(scoreListSorted[10][2]) if len(scoreListSorted) > 10 else 'null')) scorer15list.append((str(scoreListSorted[11][2]) if len(scoreListSorted) > 11 else 'null')) scorer15list.append((str(scoreListSorted[12][2]) if len(scoreListSorted) > 12 else 'null')) scorer15list.append((str(scoreListSorted[13][2]) if len(scoreListSorted) > 13 else 'null')) scorer15list.append((str(scoreListSorted[14][2]) if len(scoreListSorted) > 14 else 'null')) with open(bs.getEnvironment()['systemScriptsDirectory'] + "/MythBAdminList.py") as file: s = [row for row in file] s[1] = 'Fighter1stList = ' + str(fighter1list) + '\n' s[2] = 'Fighter2nd3rd = ' + str(fighter2and3list) + '\n' s[3] = 'FighterTop15List = ' + str(fighter15list) + '\n' s[4] = 'Scorer1stList = ' + str(scorer1list) + '\n' s[5] = 'Scorer2nd3rdList = ' + str(scorer2and3list) + '\n' s[6] = 'ScorerTop15List = ' + str(scorer15list) + '\n' f = open( bs.getEnvironment()['systemScriptsDirectory'] + "/MythBAdminList.py", 'w') for updates in s: f.write(updates) f.close() reload(mbal) #mbal.AdminList[1] = str(kdListSorted[0][2]) #print mbal.AdminList #background self._backgroundLogo = bs.newNode('image', delegate=self, attrs={ 'fillScreen': True, 'texture': bs.getTexture('menuBG'), 'tiltTranslate': -0.3, 'hasAlphaChannel': False, 'color': (1, 1, 1) }) #top10score textTopScore = ScreenLanguage.top15scoreLang posTopScore = (180, 210) scaleTopScore = 1.0 colorTopScore = (1.0, 0.6, 0.8, 1) maxWidthTopScore = 300 self.powerUpText(textTopScore, posTopScore, scaleTopScore, colorTopScore, maxWidthTopScore) #top10Fighter textTopFighter = ScreenLanguage.top15fighterLang posTopFighter = (-230, 210) scaleTopFighter = 1.0 colorTopFighter = (1.0, 0.6, 0.8, 1) maxWidthTopFighter = 300 self.powerUpText(textTopFighter, posTopFighter, scaleTopFighter, colorTopFighter, maxWidthTopFighter) #top10scoreRanktext textTopScoreRank = ScreenLanguage.rankLang posTopScoreRank = (180, 175) scaleTopScoreRank = 0.9 colorTopScoreRank = (0.9, 0.8, 1, 1) maxWidthTopScoreRank = 300 self.powerUpText(textTopScoreRank, posTopScoreRank, scaleTopScoreRank, colorTopScoreRank, maxWidthTopScoreRank) #top10ScoreAvgtext textTopScoreAVG = ScreenLanguage.avgPtsLang posTopScoreAVG = (490, 175) scaleTopScoreAVG = 0.9 colorTopScoreAVG = (0.9, 0.8, 1, 1) maxWidthTopScoreAVG = 300 self.powerUpText(textTopScoreAVG, posTopScoreAVG, scaleTopScoreAVG, colorTopScoreAVG, maxWidthTopScoreAVG) #top10FighterRanktext textTopFighterRank = ScreenLanguage.rankLang posTopFighterRank = (-230, 175) scaleTopFighterRank = 0.9 colorTopFighterRank = (0.9, 0.8, 1, 1) maxWidthTopFighterRank = 300 self.powerUpText(textTopFighterRank, posTopFighterRank, scaleTopFighterRank, colorTopFighterRank, maxWidthTopFighterRank) #top10FighterKDtext textTopFighterKD = ScreenLanguage.kdLang posTopFighterKD = (90, 175) scaleTopFighterKD = 0.9 colorTopFighterKD = (0.9, 0.8, 1, 1) maxWidthTopFighterKD = 300 self.powerUpText(textTopFighterKD, posTopFighterKD, scaleTopFighterKD, colorTopFighterKD, maxWidthTopFighterKD) #rank fighter fighterRank1 = bs.getSpecialChar('trophy4') + '1. ' + ( kdListSorted[0][0] if len(kdListSorted) > 0 else '--') fighterRank2 = bs.getSpecialChar('trophy3') + '2. ' + ( kdListSorted[1][0] if len(kdListSorted) > 1 else '--') fighterRank3 = bs.getSpecialChar('trophy3') + '3. ' + ( kdListSorted[2][0] if len(kdListSorted) > 2 else '--') fighterRank4 = bs.getSpecialChar('trophy2') + '4. ' + ( kdListSorted[3][0] if len(kdListSorted) > 3 else '--') fighterRank5 = bs.getSpecialChar('trophy2') + '5. ' + ( kdListSorted[4][0] if len(kdListSorted) > 4 else '--') fighterRank6 = bs.getSpecialChar('trophy2') + '6. ' + ( kdListSorted[5][0] if len(kdListSorted) > 5 else '--') fighterRank7 = bs.getSpecialChar('trophy2') + '7. ' + ( kdListSorted[6][0] if len(kdListSorted) > 6 else '--') fighterRank8 = bs.getSpecialChar('trophy2') + '8. ' + ( kdListSorted[7][0] if len(kdListSorted) > 7 else '--') fighterRank9 = bs.getSpecialChar('trophy2') + '9. ' + ( kdListSorted[8][0] if len(kdListSorted) > 8 else '--') fighterRank10 = bs.getSpecialChar('trophy2') + '10. ' + ( kdListSorted[9][0] if len(kdListSorted) > 9 else '--') fighterRank11 = bs.getSpecialChar('trophy2') + '11. ' + ( kdListSorted[10][0] if len(kdListSorted) > 10 else '--') fighterRank12 = bs.getSpecialChar('trophy2') + '12. ' + ( kdListSorted[11][0] if len(kdListSorted) > 11 else '--') fighterRank13 = bs.getSpecialChar('trophy2') + '13. ' + ( kdListSorted[12][0] if len(kdListSorted) > 12 else '--') fighterRank14 = bs.getSpecialChar('trophy2') + '14. ' + ( kdListSorted[13][0] if len(kdListSorted) > 13 else '--') fighterRank15 = bs.getSpecialChar('trophy2') + '15. ' + ( kdListSorted[14][0] if len(kdListSorted) > 14 else '--') #K/D ratio fighterKD1 = str("{0:.2f}".format(kdListSorted[0][1] ) if len(kdListSorted) > 0 else '--') fighterKD2 = str("{0:.2f}".format(kdListSorted[1][1] ) if len(kdListSorted) > 1 else '--') fighterKD3 = str("{0:.2f}".format(kdListSorted[2][1] ) if len(kdListSorted) > 2 else '--') fighterKD4 = str("{0:.2f}".format(kdListSorted[3][1] ) if len(kdListSorted) > 3 else '--') fighterKD5 = str("{0:.2f}".format(kdListSorted[4][1] ) if len(kdListSorted) > 4 else '--') fighterKD6 = str("{0:.2f}".format(kdListSorted[5][1] ) if len(kdListSorted) > 5 else '--') fighterKD7 = str("{0:.2f}".format(kdListSorted[6][1] ) if len(kdListSorted) > 6 else '--') fighterKD8 = str("{0:.2f}".format(kdListSorted[7][1] ) if len(kdListSorted) > 7 else '--') fighterKD9 = str("{0:.2f}".format(kdListSorted[8][1] ) if len(kdListSorted) > 8 else '--') fighterKD10 = str("{0:.2f}".format(kdListSorted[9][1]) if len(kdListSorted) > 9 else '--') fighterKD11 = str("{0:.2f}".format(kdListSorted[10][1]) if len(kdListSorted) > 10 else '--') fighterKD12 = str("{0:.2f}".format(kdListSorted[11][1]) if len(kdListSorted) > 11 else '--') fighterKD13 = str("{0:.2f}".format(kdListSorted[12][1]) if len(kdListSorted) > 12 else '--') fighterKD14 = str("{0:.2f}".format(kdListSorted[13][1]) if len(kdListSorted) > 13 else '--') fighterKD15 = str("{0:.2f}".format(kdListSorted[14][1]) if len(kdListSorted) > 14 else '--') #rank score scoreRank1 = bs.getSpecialChar('trophy4') + '1. ' + ( scoreListSorted[0][0] if len(scoreListSorted) > 0 else '--') scoreRank2 = bs.getSpecialChar('trophy3') + '2. ' + ( scoreListSorted[1][0] if len(scoreListSorted) > 1 else '--') scoreRank3 = bs.getSpecialChar('trophy3') + '3. ' + ( scoreListSorted[2][0] if len(scoreListSorted) > 2 else '--') scoreRank4 = bs.getSpecialChar('trophy2') + '4. ' + ( scoreListSorted[3][0] if len(scoreListSorted) > 3 else '--') scoreRank5 = bs.getSpecialChar('trophy2') + '5. ' + ( scoreListSorted[4][0] if len(scoreListSorted) > 4 else '--') scoreRank6 = bs.getSpecialChar('trophy2') + '6. ' + ( scoreListSorted[5][0] if len(scoreListSorted) > 5 else '--') scoreRank7 = bs.getSpecialChar('trophy2') + '7. ' + ( scoreListSorted[6][0] if len(scoreListSorted) > 6 else '--') scoreRank8 = bs.getSpecialChar('trophy2') + '8. ' + ( scoreListSorted[7][0] if len(scoreListSorted) > 7 else '--') scoreRank9 = bs.getSpecialChar('trophy2') + '9. ' + ( scoreListSorted[8][0] if len(scoreListSorted) > 8 else '--') scoreRank10 = bs.getSpecialChar('trophy2') + '10. ' + ( scoreListSorted[9][0] if len(scoreListSorted) > 9 else '--') scoreRank11 = bs.getSpecialChar('trophy2') + '11. ' + ( scoreListSorted[10][0] if len(scoreListSorted) > 10 else '--') scoreRank12 = bs.getSpecialChar('trophy2') + '12. ' + ( scoreListSorted[11][0] if len(scoreListSorted) > 11 else '--') scoreRank13 = bs.getSpecialChar('trophy2') + '13. ' + ( scoreListSorted[12][0] if len(scoreListSorted) > 12 else '--') scoreRank14 = bs.getSpecialChar('trophy2') + '14. ' + ( scoreListSorted[13][0] if len(scoreListSorted) > 13 else '--') scoreRank15 = bs.getSpecialChar('trophy2') + '15. ' + ( scoreListSorted[14][0] if len(scoreListSorted) > 14 else '--') #AVG score AVGscore1 = str("{0:.1f}".format(scoreListSorted[0][1]) if len(scoreListSorted) > 0 else '--') AVGscore2 = str("{0:.1f}".format(scoreListSorted[1][1]) if len(scoreListSorted) > 1 else '--') AVGscore3 = str("{0:.1f}".format(scoreListSorted[2][1]) if len(scoreListSorted) > 2 else '--') AVGscore4 = str("{0:.1f}".format(scoreListSorted[3][1]) if len(scoreListSorted) > 3 else '--') AVGscore5 = str("{0:.1f}".format(scoreListSorted[4][1]) if len(scoreListSorted) > 4 else '--') AVGscore6 = str("{0:.1f}".format(scoreListSorted[5][1]) if len(scoreListSorted) > 5 else '--') AVGscore7 = str("{0:.1f}".format(scoreListSorted[6][1]) if len(scoreListSorted) > 6 else '--') AVGscore8 = str("{0:.1f}".format(scoreListSorted[7][1]) if len(scoreListSorted) > 7 else '--') AVGscore9 = str("{0:.1f}".format(scoreListSorted[8][1]) if len(scoreListSorted) > 8 else '--') AVGscore10 = str("{0:.1f}".format(scoreListSorted[9][1]) if len(scoreListSorted) > 9 else '--') AVGscore11 = str("{0:.1f}".format(scoreListSorted[10][1]) if len(scoreListSorted) > 10 else '--') AVGscore12 = str("{0:.1f}".format(scoreListSorted[11][1]) if len(scoreListSorted) > 11 else '--') AVGscore13 = str("{0:.1f}".format(scoreListSorted[12][1]) if len(scoreListSorted) > 12 else '--') AVGscore14 = str("{0:.1f}".format(scoreListSorted[13][1]) if len(scoreListSorted) > 13 else '--') AVGscore15 = str("{0:.1f}".format(scoreListSorted[14][1]) if len(scoreListSorted) > 14 else '--') #fighter fighterPos1 = (-230, 130) fighterPos2 = (-230, 100) fighterPos3 = (-230, 70) fighterPos4 = (-230, 40) fighterPos5 = (-230, 10) fighterPos6 = (-230, -20) fighterPos7 = (-230, -50) fighterPos8 = (-230, -80) fighterPos9 = (-230, -110) fighterPos10 = (-230, -140) fighterPos11 = (-230, -170) fighterPos12 = (-230, -200) fighterPos13 = (-230, -230) fighterPos14 = (-230, -260) fighterPos15 = (-230, -290) #KD KDpos1 = (90, 130) KDpos2 = (90, 100) KDpos3 = (90, 70) KDpos4 = (90, 40) KDpos5 = (90, 10) KDpos6 = (90, -20) KDpos7 = (90, -50) KDpos8 = (90, -80) KDpos9 = (90, -110) KDpos10 = (90, -140) KDpos11 = (90, -170) KDpos12 = (90, -200) KDpos13 = (90, -230) KDpos14 = (90, -260) KDpos15 = (90, -290) #score scorePos1 = (180, 130) scorePos2 = (180, 100) scorePos3 = (180, 70) scorePos4 = (180, 40) scorePos5 = (180, 10) scorePos6 = (180, -20) scorePos7 = (180, -50) scorePos8 = (180, -80) scorePos9 = (180, -110) scorePos10 = (180, -140) scorePos11 = (180, -170) scorePos12 = (180, -200) scorePos13 = (180, -230) scorePos14 = (180, -260) scorePos15 = (180, -290) #AVGpos AVGpos1 = (490, 130) AVGpos2 = (490, 100) AVGpos3 = (490, 70) AVGpos4 = (490, 40) AVGpos5 = (490, 10) AVGpos6 = (490, -20) AVGpos7 = (490, -50) AVGpos8 = (490, -80) AVGpos9 = (490, -110) AVGpos10 = (490, -140) AVGpos11 = (490, -170) AVGpos12 = (490, -200) AVGpos13 = (490, -230) AVGpos14 = (490, -260) AVGpos15 = (490, -290) #call fighters list self.ranklists(fighterRank1, fighterPos1) self.ranklists(fighterRank2, fighterPos2) self.ranklists(fighterRank3, fighterPos3) self.ranklists(fighterRank4, fighterPos4) self.ranklists(fighterRank5, fighterPos5) self.ranklists(fighterRank6, fighterPos6) self.ranklists(fighterRank7, fighterPos7) self.ranklists(fighterRank8, fighterPos8) self.ranklists(fighterRank9, fighterPos9) self.ranklists(fighterRank10, fighterPos10) self.ranklists(fighterRank11, fighterPos11) self.ranklists(fighterRank12, fighterPos12) self.ranklists(fighterRank13, fighterPos13) self.ranklists(fighterRank14, fighterPos14) self.ranklists(fighterRank15, fighterPos15) #call KD list self.ranklists(fighterKD1, KDpos1) self.ranklists(fighterKD2, KDpos2) self.ranklists(fighterKD3, KDpos3) self.ranklists(fighterKD4, KDpos4) self.ranklists(fighterKD5, KDpos5) self.ranklists(fighterKD6, KDpos6) self.ranklists(fighterKD7, KDpos7) self.ranklists(fighterKD8, KDpos8) self.ranklists(fighterKD9, KDpos9) self.ranklists(fighterKD10, KDpos10) self.ranklists(fighterKD11, KDpos11) self.ranklists(fighterKD12, KDpos12) self.ranklists(fighterKD13, KDpos13) self.ranklists(fighterKD14, KDpos14) self.ranklists(fighterKD15, KDpos15) #call score list self.ranklists(scoreRank1, scorePos1) self.ranklists(scoreRank2, scorePos2) self.ranklists(scoreRank3, scorePos3) self.ranklists(scoreRank4, scorePos4) self.ranklists(scoreRank5, scorePos5) self.ranklists(scoreRank6, scorePos6) self.ranklists(scoreRank7, scorePos7) self.ranklists(scoreRank8, scorePos8) self.ranklists(scoreRank9, scorePos9) self.ranklists(scoreRank10, scorePos10) self.ranklists(scoreRank11, scorePos11) self.ranklists(scoreRank12, scorePos12) self.ranklists(scoreRank13, scorePos13) self.ranklists(scoreRank14, scorePos14) self.ranklists(scoreRank15, scorePos15) #call AVGscore List self.ranklists(AVGscore1, AVGpos1) self.ranklists(AVGscore2, AVGpos2) self.ranklists(AVGscore3, AVGpos3) self.ranklists(AVGscore4, AVGpos4) self.ranklists(AVGscore5, AVGpos5) self.ranklists(AVGscore6, AVGpos6) self.ranklists(AVGscore7, AVGpos7) self.ranklists(AVGscore8, AVGpos8) self.ranklists(AVGscore9, AVGpos9) self.ranklists(AVGscore10, AVGpos10) self.ranklists(AVGscore11, AVGpos11) self.ranklists(AVGscore12, AVGpos12) self.ranklists(AVGscore13, AVGpos13) self.ranklists(AVGscore14, AVGpos14) self.ranklists(AVGscore15, AVGpos15) #dönenler self.starlogo = bs.newNode( 'image', delegate=self, attrs={ 'texture': bs.getTexture( 'achievementOutline'), ##storeCharacter frameInset logo 'position': (470, 280), #(300,90) 'scale': (100, 100), 'tiltTranslate': 0, 'hasAlphaChannel': True, 'opacity': 1.0, 'color': (1, 1, 0) }) bsUtils.animate(self.starlogo, 'rotate', { 0: 0.0, 350: 360.0 }, loop=True) #dönenler self.starlogo2 = bs.newNode('image', delegate=self, attrs={ 'texture': bs.getTexture('achievementOutline'), 'position': (-470, 280), 'scale': (100, 100), 'tiltTranslate': 0, 'hasAlphaChannel': True, 'opacity': 1.0, 'color': (1, 1, 0) }) bsUtils.animate(self.starlogo2, 'rotate', { 0: 0.0, 350: -360.0 }, loop=True) #speed image imageTextSpeed = bs.getTexture('powerupSpeed') imagePosSpeed = (-560, 145) imageColorSpeed = (1, 1, 1) imageAlphaSpeed = True self.powerUpImage(imageTextSpeed, imagePosSpeed, imageColorSpeed, imageAlphaSpeed) #superStar image imageTextSuperStar = bs.getTexture('levelIcon') imagePosSuperStar = (-560, 45) imageColorSuperStar = (1, 1, 1) imageAlphaSuperStar = True self.powerUpImage(imageTextSuperStar, imagePosSuperStar, imageColorSuperStar, imageAlphaSuperStar) #iceCube image imageTextIceCube = bs.getTexture('softRect') imagePosIceCube = (-560, -50) imageColorIceCube = (0.9, 0.9, 1) imageAlphaIceCube = True self.powerUpImage(imageTextIceCube, imagePosIceCube, imageColorIceCube, imageAlphaIceCube) #surprise image imageTextSurprise = bs.getTexture('powerupHealth') imagePosSurprise = (-560, -150) imageColorSurprise = (1, 1, 1) imageAlphaSurprise = True self.powerUpImage(imageTextSurprise, imagePosSurprise, imageColorSurprise, imageAlphaSurprise) #martyrdom image imageTextMarty = bs.getTexture('achievementCrossHair') imagePosMarty = (-560, -255) imageColorMarty = (1, 1, 1) imageAlphaMarty = True self.powerUpImage(imageTextMarty, imagePosMarty, imageColorMarty, imageAlphaMarty) #custom Powerups #bsUtils.animate(self.customPowerUps, 'scale', {0: 1,120: 1,120: 1,120: 0.99},loop=True) textPowerUp = ScreenLanguage.customLang posPowerUp = (-560, 210) scalePowerUp = 1.0 colorPowerUp = (1.0, 0.6, 0.8, 1) maxWidthPowerUp = 180 self.powerUpText(textPowerUp, posPowerUp, scalePowerUp, colorPowerUp, maxWidthPowerUp) #info for players textTyFor = ScreenLanguage.infoLang posTyFor = (0, -320) scaleTyFor = 1.0 colorTyFor = (1.0, 0.6, 0.8, 1) maxWidthTyFor = 300 self.powerUpText(textTyFor, posTyFor, scaleTyFor, colorTyFor, maxWidthTyFor) #speed textSpeedInfo = ScreenLanguage.speedInfoLang posSpeedInfo = (-500, 135) scaleSpeedInfo = 0.8 colorSpeedInfo = (0.9, 0.9, 0.9, 1) maxWidthSpeedInfo = 250 textSpeed = ScreenLanguage.speedTextLang posSpeed = (-500, 170) scaleSpeed = 0.7 colorSpeed = (0.9, 0.8, 1, 1) maxWidthSpeed = 180 self.powerUpText(textSpeed, posSpeed, scaleSpeed, colorSpeed, maxWidthSpeed) self.powerUpText(textSpeedInfo, posSpeedInfo, scaleSpeedInfo, colorSpeedInfo, maxWidthSpeedInfo) #superStar textSuperStarInfo = ScreenLanguage.superStarInfoLang posSuperStarInfo = (-500, 35) scaleSuperStarInfo = 0.8 colorSuperStarInfo = (0.9, 0.9, 0.9, 1) maxWidthSuperStarInfo = 250 textSuperStar = ScreenLanguage.superStarTextLang posSuperStar = (-500, 70) scaleSuperStar = 0.7 colorSuperStar = (0.9, 0.8, 1, 1) maxWidthSuperStar = 180 self.powerUpText(textSuperStar, posSuperStar, scaleSuperStar, colorSuperStar, maxWidthSuperStar) self.powerUpText(textSuperStarInfo, posSuperStarInfo, scaleSuperStarInfo, colorSuperStarInfo, maxWidthSuperStarInfo) #iceCube textIceCubeInfo = ScreenLanguage.iceCubeInfoLang posIceCubeInfo = (-500, -63) scaleIceCubeInfo = 0.8 colorIceCubeInfo = (0.9, 0.9, 0.9, 1) maxWidthIceCubeInfo = 250 textIceCube = ScreenLanguage.iceCubeTextLang posIceCube = (-500, -23) scaleIceCube = 0.7 colorIceCube = (0.9, 0.8, 1, 1) maxWidthIceCube = 180 self.powerUpText(textIceCube, posIceCube, scaleIceCube, colorIceCube, maxWidthIceCube) self.powerUpText(textIceCubeInfo, posIceCubeInfo, scaleIceCubeInfo, colorIceCubeInfo, maxWidthIceCubeInfo) #surprise textSurpriseInfo = ScreenLanguage.surpriseInfoLang posSurpriseInfo = (-500, -165) scaleSurpriseInfo = 0.75 colorSurpriseInfo = (0.9, 0.9, 0.9, 1) maxWidthSurpriseInfo = 250 textSurprise = ScreenLanguage.surpriseTextLang posSurprise = (-500, -115) scaleSurprise = 0.7 colorSurprise = (0.9, 0.8, 1, 1) maxWidthSurprise = 180 self.powerUpText(textSurprise, posSurprise, scaleSurprise, colorSurprise, maxWidthSurprise) self.powerUpText(textSurpriseInfo, posSurpriseInfo, scaleSurpriseInfo, colorSurpriseInfo, maxWidthSurpriseInfo) #martyrdom textMartyInfo = ScreenLanguage.martyInfoLang posMartyInfo = (-500, -270) scaleMartyInfo = 0.75 colorMartyInfo = (0.9, 0.9, 0.9, 1) maxWidthMartyInfo = 250 textMarty = ScreenLanguage.martyTextLang posMarty = (-500, -220) scaleMarty = 0.7 colorMarty = (0.9, 0.8, 1, 1) maxWidthMarty = 180 self.powerUpText(textMarty, posMarty, scaleMarty, colorMarty, maxWidthMarty) self.powerUpText(textMartyInfo, posMartyInfo, scaleMartyInfo, colorMartyInfo, maxWidthMartyInfo) self._sound = bs.newNode('sound', attrs={ 'sound': bs.getSound('victoryMusic'), 'volume': 1.0 }) self._endGameTimer = bs.Timer(20000, bs.WeakCall(self.endGame)) #bsUtils.ZoomText('MYTHB', lifespan=22000, jitter=2.0, #position=(100,120), scale=0.6, maxWidth=800, #trail=True, color=(0.5,0.5,1)).autoRetain() bsUtils.ZoomText(ScreenLanguage.welcomeTextLang, lifespan=999000, jitter=2.0, position=(0, 270), scale=1.1, maxWidth=800, trail=False, color=(0.6, 0.6, 1)).autoRetain()
def onTransitionIn(self): bs.Activity.onTransitionIn(self) global gDidInitialTransition random.seed(123) try: import install except ImportError: pass else: # check needed methods if hasattr(bs, "get_setting") and hasattr(install, "update_modpack"): if bs.get_setting("auto-update", False): install.update_modpack(True) self._logoNode = None self._customLogoTexName = None self._wordActors = [] env = bs.getEnvironment() vrMode = bs.getEnvironment()['vrMode'] if not bs.getEnvironment().get('toolbarTest', True): self.myName = bs.NodeActor( bs.newNode( 'text', attrs={ 'vAttach': 'bottom', 'hAlign': 'center', 'color': (1, 1, 1, 1) if vrMode else (1, 1, 1, 1), 'flatness': 1.0, 'shadow': 1.0 if vrMode else 0.5, 'scale': (0.65 if (env['interfaceType'] == 'small' or vrMode) else 0.7), # FIXME need a node attr for this 'position': (0, 25), 'vrDepth': -10, 'text': u'\xa9 2019 Eric Froemling' })) fullScreen = bsInternal._getSetting("TV Border") if env['interfaceType'] != 'small' or env['vrMode']: if fullScreen: position = (0, -10) else: position = (-425, 10) else: if fullScreen: position = (0, -10) else: position = (-425, 35) self.moderName = bs.NodeActor( bs.newNode( 'text', attrs={ 'vAttach': 'bottom', 'hAlign': 'center', 'color': (0.8, 0.8, 0.8, 0.8) if vrMode else (0.8, 0.8, 0.8, 0.8), 'flatness': 1.0, 'shadow': 1.0 if vrMode else 0.5, 'scale': (0.55 if (env['interfaceType'] == 'small' or vrMode) else 0.7), # FIXME need a node attr for this 'position': position, 'vrDepth': -10, 'text': u'\xa9 ModPack is created by Daniil Rakhov' })) self._hostIsNavigatingText = bs.NodeActor( bs.newNode('text', attrs={ 'text': bs.Lstr(resource='hostIsNavigatingMenusText', subs=[ ('${HOST}', bsInternal._getAccountDisplayString()) ]), 'clientOnly': True, 'position': (0, -200), 'flatness': 1.0, 'hAlign': 'center' })) if not gDidInitialTransition: if hasattr(self, 'myName'): bs.animate(self.myName.node, 'opacity', {2300: 0, 3000: 1.0}) if hasattr(self, 'moderName'): bs.animate(self.moderName.node, 'opacity', { 2300: 0, 3300: 1.0 }) # FIXME - shouldn't be doing things conditionally based on whether # the host is vr mode or not (clients may not be or vice versa) # - any differences need to happen at the engine level # so everyone sees things in their own optimal way vrMode = env['vrMode'] interfaceType = env['interfaceType'] # in cases where we're doing lots of dev work lets # always show the build number forceShowBuildNumber = True if not bs.getEnvironment().get('toolbarTest', True): text = "BROODYs WORLD" try: from multiversion import get_version except ImportError: path = os.path.join(env["userScriptsDirectory"], "about_modpack.json") if os.path.exists(path): try: data = json.load(open(path)) except Exception: pass else: text += " v." + str( data.get("version", { "v": "???" }).get("v")) else: text += " v." + str(get_version()) if env['debugBuild'] or env['testBuild']: if env['debugBuild']: text += " [debug]" else: text += " [test]" if forceShowBuildNumber: text = "based on " + str(env['version']) + "\n" + text self.version = bs.NodeActor( bs.newNode('text', attrs={ 'vAttach': 'bottom', 'hAttach': 'right', 'hAlign': 'right', 'flatness': 1.0, 'vrDepth': -10, 'shadow': 0.5, 'color': (0.5, 0.6, 0.5, 0.7), 'scale': 0.7 if (interfaceType == 'small' or vrMode) else 0.85, 'position': (-260, 10) if vrMode else (-10, 30), 'text': text })) if not gDidInitialTransition: bs.animate(self.version.node, 'opacity', { 0: 0, 3000: 0, 4000: 1.0 }) # throw in beta info.. self.betaInfo = self.betaInfo2 = None if env['testBuild'] and not env['kioskMode']: self.betaInfo = bs.NodeActor( bs.newNode('text', attrs={ 'vAttach': 'center', 'hAlign': 'center', 'color': (1, 1, 1, 1), 'shadow': 0.5, 'flatness': 0.5, 'scale': 1, 'vrDepth': -60, 'position': (230, 125) if env['kioskMode'] else (230, 35), 'text': bs.Lstr(resource="testBuildText") })) if not gDidInitialTransition: bs.animate(self.betaInfo.node, 'opacity', {1300: 0, 1800: 1.0}) model = bs.getModel('thePadLevel') treesModel = bs.getModel('trees') bottomModel = bs.getModel('thePadLevelBottom') borModel = bs.getCollideModel('thePadLevelCollide') testColorTexture = bs.getTexture('thePadLevelColor') treesTexture = bs.getTexture('treesColor') bgTex = bs.getTexture('alwaysLandBGColor') bgModel = bs.getModel('alwaysLandBG') vrBottomFillModel = bs.getModel('thePadVRFillBottom') vrTopFillModel = bs.getModel('thePadVRFillTop') bsGlobals = bs.getSharedObject('globals') bsGlobals.cameraMode = 'rotate' bsGlobals.tint = (1.1, 1.1, 1.0) self.bottom = bs.NodeActor( bs.newNode('terrain', attrs={ 'model': bottomModel, 'lighting': False, 'reflection': 'soft', 'reflectionScale': [0.45], 'colorTexture': testColorTexture })) self.node = bs.newNode('terrain', delegate=self, attrs={ 'collideModel': borModel, 'model': model, 'colorTexture': testColorTexture, 'materials': [bs.getSharedObject('footingMaterial')] }) self.vrBottomFill = bs.NodeActor( bs.newNode('terrain', attrs={ 'model': vrBottomFillModel, 'lighting': False, 'vrOnly': True, 'colorTexture': testColorTexture })) self.vrTopFill = bs.NodeActor( bs.newNode('terrain', attrs={ 'model': vrTopFillModel, 'vrOnly': True, 'lighting': False, 'colorTexture': bgTex })) self.terrain = bs.NodeActor( bs.newNode('terrain', attrs={ 'model': model, 'colorTexture': testColorTexture, 'reflection': 'soft', 'reflectionScale': [0.3] })) self.trees = bs.NodeActor( bs.newNode('terrain', attrs={ 'model': treesModel, 'lighting': False, 'reflection': 'char', 'reflectionScale': [0.1], 'colorTexture': treesTexture })) self.bg = bs.NodeActor( bs.newNode('terrain', attrs={ 'model': bgModel, 'color': (0.92, 0.91, 0.9), 'lighting': False, 'background': True, 'colorTexture': bgTex })) textOffsetV = 0 self._ts = 0.86 self._language = None self._updateTimer = bs.Timer(2000, bs.Call(self._update, False), repeat=True) self._update(True) bs.gameTimer(55000, bs.Call(self.fireworks)) bsUtils.animateArray(bs.getSharedObject("globals"), "tint", 3, {0:(1.1,1.1,1.0), 7500:(1.25, 1.21, 1.075), 30000:(1.25, 1.21, 1.075), \ 57500:(1.1, 0.86, 0.74), 67500:(1.1, 0.86, 0.74), \ 90000:(0, 0.27, 0.51), 120000:(0, 0.27, 0.51), 142500:(1.3, 1.06, 1.02), \ 157500:(1.3, 1.06, 1.02), 180000:(1.3, 1.25, 1.2), 195500:(1.3, 1.25, 1.2), \ 220000:(1.1,1.1,1.0)}) bsInternal._addCleanFrameCallback(bs.WeakCall(self._startPreloads)) random.seed() class News(object): def __init__(self, activity): self._valid = True self._messageDuration = 10000 self._messageSpacing = 2000 self._text = None self._activity = weakref.ref(activity) self._fetchTimer = bs.Timer(1000, bs.WeakCall(self._tryFetchingNews), repeat=True) self._tryFetchingNews() def _tryFetchingNews(self): if bsInternal._getAccountState() == 'SIGNED_IN': self._fetchNews() self._fetchTimer = None def _fetchNews(self): try: launchCount = bs.getConfig()['launchCount'] except Exception: launchCount = None global gLastNewsFetchTime gLastNewsFetchTime = time.time() # UPDATE - we now just pull news from MRVs news = bsInternal._getAccountMiscReadVal('n', None) if news is not None: self._gotNews(news) def _changePhrase(self): global gLastNewsFetchTime if time.time() - gLastNewsFetchTime > 100.0: self._fetchNews() self._text = None else: if self._text is not None: if len(self._phrases) == 0: for p in self._usedPhrases: self._phrases.insert(0, p) val = self._phrases.pop() if val == '__ACH__': vr = bs.getEnvironment()['vrMode'] bsUtils.Text( bs.Lstr(resource='nextAchievementsText'), color=(1,1,1,1) if vr else (0.95,0.9,1,0.4), hostOnly=True, maxWidth=200, position=(-300, -35), hAlign='right', transition='fadeIn', scale=0.9 if vr else 0.7, flatness=1.0 if vr else 0.6, shadow=1.0 if vr else 0.5, hAttach="center", vAttach="top", transitionDelay=1000, transitionOutDelay=self._messageDuration)\ .autoRetain() import bsAchievement achs = [ a for a in bsAchievement.gAchievements if not a.isComplete() ] if len(achs) > 0: a = achs.pop( random.randrange(min(4, len(achs)))) a.createDisplay(-180, -35, 1000, outDelay=self._messageDuration, style='news') if len(achs) > 0: a = achs.pop( random.randrange(min(8, len(achs)))) a.createDisplay(180, -35, 1250, outDelay=self._messageDuration, style='news') else: s = self._messageSpacing keys = { s: 0, s + 1000: 1.0, s + self._messageDuration - 1000: 1.0, s + self._messageDuration: 0.0 } bs.animate(self._text.node, "opacity", dict([[k, v] for k, v in keys.items()])) self._text.node.text = val def _gotNews(self, news): # run this stuff in the context of our activity since we need # to make nodes and stuff.. should fix the serverGet call so it activity = self._activity() if activity is None or activity.isFinalized(): return with bs.Context(activity): self._phrases = [] # show upcoming achievements in non-vr versions # (currently too hard to read in vr) self._usedPhrases = ( ['__ACH__'] if not bs.getEnvironment()['vrMode'] else []) + [s for s in news.split('<br>\n') if s != ''] self._phraseChangeTimer = bs.Timer( self._messageDuration + self._messageSpacing, bs.WeakCall(self._changePhrase), repeat=True) sc = 1.2 if ( bs.getEnvironment()['interfaceType'] == 'small' or bs.getEnvironment()['vrMode']) else 0.8 self._text = bs.NodeActor( bs.newNode( 'text', attrs={ 'vAttach': 'top', 'hAttach': 'center', 'hAlign': 'center', 'vrDepth': -20, 'shadow': 1.0 if bs.getEnvironment()['vrMode'] else 0.4, 'flatness': 0.8, 'vAlign': 'top', 'color': ((1, 1, 1, 1) if bs.getEnvironment()['vrMode'] else (0.7, 0.65, 0.75, 1.0)), 'scale': sc, 'maxWidth': 900.0 / sc, 'position': (0, -10) })) self._changePhrase() if not env['kioskMode'] and not env.get('toolbarTest', True): self._news = News(self) # bring up the last place we were, or start at the main menu otherwise with bs.Context('UI'): try: mainWindow = bsUI.gMainWindow except Exception: mainWindow = None # when coming back from a kiosk-mode game, jump to # the kiosk start screen.. if bsUtils.gRunningKioskModeGame: if bs.getEnvironment()['kioskMode']: bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.KioskWindow().getRootWidget() # ..or in normal cases go back to the main menu else: if mainWindow == 'Gather': bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.GatherWindow(transition=None).getRootWidget() elif mainWindow == 'Watch': bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.WatchWindow(transition=None).getRootWidget() elif mainWindow == 'Team Game Select': bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.TeamsWindow(sessionType=bs.TeamsSession, transition=None).getRootWidget() elif mainWindow == 'Free-for-All Game Select': bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.TeamsWindow(sessionType=bs.FreeForAllSession, transition=None).getRootWidget() elif mainWindow == 'Coop Select': bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.CoopWindow(transition=None).getRootWidget() else: bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.MainMenuWindow(transition=None).getRootWidget() # attempt to show any pending offers immediately. # If that doesn't work, try again in a few seconds # (we may not have heard back from the server) # ..if that doesn't work they'll just have to wait # until the next opportunity. if not bsUI._showOffer(): def tryAgain(): if not bsUI._showOffer(): # try one last time.. bs.realTimer(2000, bsUI._showOffer) bs.realTimer(2000, tryAgain) gDidInitialTransition = True
def __init__(self, filename): self.filename = filename self.base = self.filename[:-3] self.name = filename + " (Local Only)" with open(bs.getEnvironment()['userScriptsDirectory'] + "/" + filename, "r") as ownFile: self.ownData = ownFile.read()
def isInstalled(self): return os.path.exists(bs.getEnvironment()['userScriptsDirectory'] + "/" + self.filename)
"_version": 1, "_name": "Auto Reload", "enabled": dict(_default=True, _name="Enable"), "check_interval": dict(_default=2.5, _min=1, _inc=0.5, _max=10, _name="Check interval"), "folder": dict(_default="auto_reloader_mods", _name="Folder") } if bs.getConfig().get("auto_reloader", default)["_version"] != default["_version"]: bs.getConfig()["auto_reloader"] = default bs.getConfig()["auto_reloader"] = bs.getConfig().get("auto_reloader", default) def cfg(key): return bs.getConfig()["auto_reloader"][key].get("_value", bs.getConfig()["auto_reloader"][key]["_default"]) CHECK_INTERVAL = int(cfg("check_interval") * 1000) IMPORT_FOLDER = bs.getEnvironment()['userScriptsDirectory'] + "/" + cfg("folder") + "/" sys.path.append(IMPORT_FOLDER) # FIXME class GameWrapper(object): _game = None _type = None _instances = weakref.WeakSet() def __init__(self, filename): self._filename = filename with open(IMPORT_FOLDER + self._filename, "r") as f: self._module_md5 = md5(f.read()).hexdigest() self._did_print_error = False self._import_module() if self._is_available() and self._type == "game": self._game = self._module.bsGetGames()[0] else:
import bs import bsInternal import threading import json import urllib2 import weakref import os import os.path import httplib SUPPORTS_HTTPS = hasattr(httplib, 'HTTPS') modPath = bs.getEnvironment()['userScriptsDirectory'] + "/" BRANCH = "master" USER_REPO = "Mrmaxmeier/BombSquad-Community-Mod-Manager" ENTRY_MOD = "modManager" def index_url(): if SUPPORTS_HTTPS: yield "https://raw.githubusercontent.com/{}/{}/index.json".format(USER_REPO, BRANCH) yield "https://rawgit.com/{}/{}/index.json".format(USER_REPO, BRANCH) yield "http://raw.githack.com/{}/{}/index.json".format(USER_REPO, BRANCH) yield "http://rawgit.com/{}/{}/index.json".format(USER_REPO, BRANCH) def mod_url(data): if "commit_sha" in data and "filename" in data: commit_hexsha = data["commit_sha"] filename = data["filename"] if SUPPORTS_HTTPS: