def toggleAutoPlay(self): self.autoPlay = not self.autoPlay if self.autoPlay: Dialogs.showMessage(self.engine, _("Jurgen will show you how it is done.")) else: Dialogs.showMessage(self.engine, _("Jurgen has left the building.")) return self.autoPlay
def keyPressed(self, key, unicode): ret = SceneClient.keyPressed(self, key, unicode) c = self.controls.keyPressed(key) if self.song and (c in [Player.KEY1, Player.KEY2, Player.CANCEL, Player.ACTION1, Player.ACTION2] or key == pygame.K_RETURN): scores = self.song.info.getHighscores(self.player.difficulty) if not scores or self.player.score > scores[-1][0] or len(scores) < 5: if self.player.cheating: Dialogs.showMessage(self.engine, _("No highscores for cheaters!")) else: name = Dialogs.getText(self.engine, _("%d points is a new high score! Please enter your name:") % self.player.score, self.player.name) if name: self.player.name = name self.highscoreIndex = self.song.info.addHighscore(self.player.difficulty, self.player.score, self.stars, self.player.name) self.song.info.save() if self.engine.config.get("game", "uploadscores"): self.uploadingScores = True fn = lambda: self.song.info.uploadHighscores(self.engine.config.get("game", "uploadurl"), self.song.getHash()) self.engine.resource.load(self, "uploadResult", fn) self.showHighscores = True self.engine.view.pushLayer(self.menu) return True return ret
def _getFileText(self, fileName): f = os.path.join(self.path, fileName) if fileName == "..": return _("[Parent Folder]") if os.path.isdir(f): return _("%s [Folder]") % fileName return fileName
def loadControls(): global controllerDict controllers = [] allcontrollers = os.listdir(controlpath) default = ["defaultd.ini", "defaultg.ini", "defaultm.ini"] for name in allcontrollers: if name.lower().endswith(".ini") and len(name) > 4: if name in default: continue controllers.append(name[0:len(name)-4]) i = len(controllers) controllerDict = dict([(str(controllers[n]),controllers[n]) for n in range(0, i)]) controllerDict["defaultg"] = _("Default Guitar") controllerDict["defaultd"] = _("Default Drum") defMic = None if Microphone.supported: controllerDict["defaultm"] = _("Default Microphone") defMic = "defaultm" tsControl = _("Controller %d") tsControlTip = _("Select the controller for slot %d") i = 1 Config.define("game", "control0", str, "defaultg", text = tsControl % 1, options = controllerDict, tipText = tsControlTip % 1) controllerDict["None"] = None Config.define("game", "control1", str, "defaultd", text = tsControl % 2, options = controllerDict, tipText = tsControlTip % 2) Config.define("game", "control2", str, defMic, text = tsControl % 3, options = controllerDict, tipText = tsControlTip % 3) Config.define("game", "control3", str, None, text = tsControl % 4, options = controllerDict, tipText = tsControlTip % 4)
def createClient(self, libraryName, songName, players = None): self.libraryName = libraryName self.songName = songName self.stars = [0 for i in players] self.accuracy = [0 for i in players] self.counter = 0 self.showHighscores = False self.highscoreIndex = [None for i in players] self.taunt = None self.uploadingScores = False self.nextScene = None self.offset = None self.pauseScroll = None self.scorePart = None self.scoreDifficulty = None self.playerList = players self.spinnyDisabled = self.engine.config.get("game", "disable_spinny") items = [ (_("Replay"), self.replay), (_("Change Song"), self.changeSong), (_("Quit to Main Menu"), self.quit), ] self.menu = Menu(self.engine, items, onCancel = self.quit, pos = (.2, .5)) self.engine.resource.load(self, "song", lambda: Song.loadSong(self.engine, songName, library = self.libraryName, notesOnly = True, part = [player.part for player in self.playerList]), onLoad = self.songLoaded) self.engine.loadSvgDrawing(self, "background", "gameresults.svg") phrase = random.choice(Theme.resultsPhrase.split(",")) if phrase == "None": phrase = _("Chilling...") Dialogs.showLoadingScreen(self.engine, lambda: self.song, text = phrase)
def shown(self): self.engine.view.pushLayer(self.menu) shaders.checkIfEnabled() if not self.shownOnce: self.shownOnce = True if hasattr(sys, 'frozen'): #stump: Check whether this is a non-svn binary being run from an svn working copy. if os.path.isdir(os.path.join( 'src', '.svn')) and 'development' not in Version.version(): Dialogs.showMessage( self.engine, _('This binary release is being run from a Subversion working copy. This is not the correct way to run FoFiX from Subversion. Please see one of the following web pages to set your Subversion working copy up correctly:' ) + '\n\nhttp://code.google.com/p/fofix/wiki/RunningUnderPython26' + '\nhttp://code.google.com/p/fofix/wiki/RequiredSourceModules' ) #stump: Check whether this is an svn binary not being run from an svn working copy elif not os.path.isdir(os.path.join( 'src', '.svn')) and 'development' in Version.version(): Dialogs.showMessage( self.engine, _('This binary was built from a Subversion working copy but is not running from one. The FoFiX Team will not provide any support whatsoever for this binary. Please see the following site for official binary releases:' ) + '\n\nhttp://code.google.com/p/fofix/')
def __init__(self, engine, songName = None, libraryName = DEFAULT_LIBRARY): self.engine = engine self.time = 0.0 self.guitar = Guitar(self.engine, editorMode = True) self.controls = Player.Controls() self.camera = Camera() self.pos = 0.0 self.snapPos = 0.0 self.scrollPos = 0.0 self.scrollSpeed = 0.0 self.newNotes = None self.newNotePos = 0.0 self.song = None self.engine.loadSvgDrawing(self, "background", "editor.svg") self.modified = False self.songName = songName self.libraryName = libraryName self.heldFrets = set() mainMenu = [ (_("Save Song"), self.save), (_("Set Song Name"), self.setSongName), (_("Set Artist Name"), self.setArtistName), (_("Set Beats per Minute"), self.setBpm), (_("Estimate Beats per Minute"), self.estimateBpm), (_("Set A/V delay"), self.setAVDelay), (_("Set Cassette Color"), self.setCassetteColor), (_("Set Cassette Label"), self.setCassetteLabel), (_("Editing Help"), self.help), (_("Quit to Main Menu"), self.quit), ] self.menu = Menu(self.engine, mainMenu)
def save(self): #Checks whether the editor made a change or not. if not self.modified: """ If the editor has not made any change in sound editing for FOF, Displays the message that there are no changes to be saved. """ Dialogs.showMessage(self.engine, _("There are no changes to save.")) return def save(): #The sound first edited is saved. self.song.save() #If you turn off the changes. self.modified = False #Activates the section that allows the file to be saved. self.engine.resource.load(function=save) #Loads the loading screen with their texts. Dialogs.showLoadingScreen(self.engine, lambda: not self.modified, text=_("Saving...")) #Loads the message indicating that the file was saved. Dialogs.showMessage(self.engine, _("'%s' saved.") % self.song.info.name)
def change(self): o = self.config.prototype[self.section][self.option] if isinstance(o.options, dict): for k, v in o.options.items(): if v == value: value = k break key = Dialogs.getKey(self.engine, _("Press a key for '%s' or Escape to cancel.") % (o.text)) if key: #------------------------------------------ #myfingershurt: key conflict checker operation mode if self.keyCheckerMode == 2: #enforce; do not allow conflicting key assignments, force reversion # glorandwarf: sets the new key mapping and checks for a conflict if self.engine.input.setNewKeyMapping(self.section, self.option, key) == False: # key mapping would conflict, warn the user Dialogs.showMessage(self.engine, _("That key is already in use. Please choose another.")) self.engine.input.reloadControls() elif self.keyCheckerMode == 1: #just notify, but allow the change # glorandwarf: sets the new key mapping and checks for a conflict if self.engine.input.setNewKeyMapping(self.section, self.option, key) == False: # key mapping would conflict, warn the user Dialogs.showMessage(self.engine, _("A key conflict exists somewhere. You should fix it.")) self.engine.input.reloadControls() else: #don't even check. # glorandwarf: sets the new key mapping and checks for a conflict temp = self.engine.input.setNewKeyMapping(self.section, self.option, key) # key mapping would conflict, warn the user self.engine.input.reloadControls()
def run(self, ticks): if self.wizardStarted: return self.wizardStarted = True name = "" while True: masks = ["*.ogg"] name = Dialogs.getText(self.engine, prompt = _("Enter a name for the song."), text = name) if not name: self.engine.view.popLayer(self) return path = os.path.abspath(self.engine.resource.fileName("songs", name)) if os.path.isdir(path): Dialogs.showMessage(self.engine, _("That song already exists.")) else: break guitarTrack = Dialogs.chooseFile(self.engine, masks = masks, prompt = _("Choose the Instrument Track (OGG format).")) if not guitarTrack: self.engine.view.popLayer(self) return backgroundTrack = Dialogs.chooseFile(self.engine, masks = masks, prompt = _("Choose the Background Track (OGG format) or press Escape to skip.")) # Create the song loader = self.engine.resource.load(self, "song", lambda: createSong(self.engine, name, guitarTrack, backgroundTrack)) Dialogs.showLoadingScreen(self.engine, lambda: self.song or loader.exception, text = _("Importing...")) if not loader.exception: self.songName = name self.engine.view.popLayer(self)
def createClient(self, libraryName, songName): self.libraryName = libraryName self.songName = songName self.stars = 0 self.accuracy = 0 self.counter = 0 self.showHighscores = False self.highscoreIndex = None self.taunt = None self.uploadingScores = False self.nextScene = None items = [ (_("Replay"), self.replay), (_("Change Song"), self.changeSong), (_("Quit to Main Menu"), self.quit), ] self.menu = Menu(self.engine, items, onCancel=self.quit, pos=(.2, .5)) self.engine.resource.load( self, "song", lambda: Song.loadSong(self.engine, songName, library=self.libraryName, notesOnly=True), onLoad=self.songLoaded) self.engine.loadSvgDrawing(self, "background", "keyboard.svg") Dialogs.showLoadingScreen(self.engine, lambda: self.song, text=_("Chilling..."))
def shown(self): self.engine.view.pushLayer(self.menu) shaders.checkIfEnabled() if not self.shownOnce: self.shownOnce = True if hasattr(sys, 'frozen'): # Check whether this is a release binary being run from an svn/git # working copy or whether this is an svn/git binary not being run # from an corresponding working copy. currentVcs, buildVcs = None, None if VFS.isdir('/gameroot/.git'): currentVcs = 'git' elif VFS.isdir('/gameroot/src/.svn'): currentVcs = 'Subversion' if 'git' in Version.version(): buildVcs = 'git' elif 'svn' in Version.version(): buildVcs = 'Subversion' if currentVcs != buildVcs: if buildVcs is None: msg = _('This binary release is being run from a %(currentVcs)s working copy. This is not the correct way to run FoFiX from %(currentVcs)s. Please see one of the following web pages to set your %(currentVcs)s working copy up correctly:') + \ '\n\nhttp://code.google.com/p/fofix/wiki/RunningUnderPython26' + \ '\nhttp://code.google.com/p/fofix/wiki/RequiredSourceModules' else: msg = _('This binary was built from a %(buildVcs)s working copy but is not running from one. The FoFiX Team will not provide any support whatsoever for this binary. Please see the following site for official binary releases:') + \ '\n\nhttp://code.google.com/p/fofix/' Dialogs.showMessage(self.engine, msg % {'buildVcs': buildVcs, 'currentVcs': currentVcs})
def run(self, ticks): if self.wizardStarted: return self.wizardStarted = True name = "" while 1: masks = ["*.ogg"] name = Dialogs.getText(self.engine, prompt = _("Enter a name for the song."), text = name) if not name: self.engine.view.popLayer(self) return path = os.path.abspath(self.engine.resource.fileName("songs", name)) if os.path.isdir(path): Dialogs.showMessage(self.engine, _("That song already exists.")) else: break guitarTrack = Dialogs.chooseFile(self.engine, masks = masks, prompt = _("Choose the Instrument Track (OGG format).")) if not guitarTrack: self.engine.view.popLayer(self) return backgroundTrack = Dialogs.chooseFile(self.engine, masks = masks, prompt = _("Choose the Background Track (OGG format) or press Escape to skip.")) # Create the song loader = self.engine.resource.load(self, "song", lambda: createSong(self.engine, name, guitarTrack, backgroundTrack)) Dialogs.showLoadingScreen(self.engine, lambda: self.song or loader.exception, text = _("Importing...")) if not loader.exception: self.songName = name self.engine.view.popLayer(self)
def __init__(self, engine, songName=None, libraryName=DEFAULT_LIBRARY): self.engine = engine self.time = 0.0 self.guitar = Guitar(self.engine, editorMode=True) self.controls = Player.Controls() self.camera = Camera() self.pos = 0.0 self.snapPos = 0.0 self.scrollPos = 0.0 self.scrollSpeed = 0.0 self.newNotes = None self.newNotePos = 0.0 self.song = None self.engine.loadSvgDrawing(self, "background", "editor.svg") self.modified = False self.songName = songName self.libraryName = libraryName self.heldFrets = set() self.spinnyDisabled = self.engine.config.get("game", "disable_spinny") mainMenu = [ (_("Save Song"), self.save), (_("Set Song Name"), self.setSongName), (_("Set Artist Name"), self.setArtistName), (_("Set Beats per Minute"), self.setBpm), (_("Estimate Beats per Minute"), self.estimateBpm), (_("Set A/V delay"), self.setAVDelay), (_("Set Cassette Color"), self.setCassetteColor), (_("Set Cassette Label"), self.setCassetteLabel), (_("Editing Help"), self.help), (_("Quit to Main Menu"), self.quit), ] self.menu = Menu(self.engine, mainMenu)
def checkParts(self): info = Song.loadSongInfo(self.engine, self.songName, library=self.libraryName) guitars = [] drums = [] vocals = [] for part in info.parts: if part.id == 4 or part.id == 7: drums.append(part) elif part.id == 5: vocals.append(part) else: guitars.append(part) if len(drums) == 0 and self.engine.input.gameDrums > 0: Dialogs.showMessage( self.engine, _("There are no drum parts in this song. Change your controllers to play.") ) return False if len(guitars) == 0 and self.engine.input.gameGuitars > 0: Dialogs.showMessage( self.engine, _("There are no guitar parts in this song. Change your controllers to play.") ) return False if len(vocals) == 0 and self.engine.input.gameMics > 0: Dialogs.showMessage( self.engine, _("There are no vocal parts in this song. Change your controllers to play.") ) return False return True
def setBpm(self): bpm = Dialogs.getText(self.engine, _("Enter Beats per Minute Value"), unicode(self.song.bpm)) if bpm: try: self.song.setBpm(float(bpm)) self.modified = True except ValueError: Dialogs.showMessage(self.engine, _("That isn't a number."))
def setAVDelay(self): delay = Dialogs.getText(self.engine, _("Enter A/V delay in milliseconds"), unicode(self.song.info.delay)) if delay: try: self.song.info.delay = int(delay) self.modified = True except ValueError: Dialogs.showMessage(self.engine, _("That isn't a number."))
def deleteCharacter(self): tsYes = _("Yes") q = Dialogs.chooseItem(self.engine, [tsYes, _("No")], _("Are you sure you want to delete this player?")) if q == tsYes: if self.player: Player.deletePlayer(self.player) self.engine.view.popLayer(self) self.engine.input.removeKeyListener(self)
def render(self, visibility, topMost): if not self.song: return v = 1.0 - ((1 - visibility)**2) # render the background t = self.time / 100 + 34 w, h, = self.engine.view.geometry[2:4] r = .5 if self.spinnyDisabled != True and Theme.spinnyEditorDisabled: self.background.transform.reset() self.background.transform.translate( w / 2 + math.sin(t / 2) * w / 2 * r, h / 2 + math.cos(t) * h / 2 * r) self.background.transform.rotate(-t) self.background.transform.scale( math.sin(t / 8) + 2, math.sin(t / 8) + 2) self.background.draw() self.camera.target = (2, 0, 5.5) self.camera.origin = (-2, 9, 5.5) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(60, 4.0 / 3.0, 0.1, 1000) glMatrixMode(GL_MODELVIEW) glLoadIdentity() self.camera.apply() self.guitar.render(v, self.song, self.scrollPos, self.controls) self.engine.view.setOrthogonalProjection(normalize=True) font = self.engine.data.font try: Theme.setSelectedColor() w, h = font.getStringSize(" ") if self.song.isPlaying(): status = _("Playing") else: status = _("Stopped") t = "%d.%02d'%03d" % (self.pos / 60000, (self.pos % 60000) / 1000, self.pos % 1000) font.render(t, (.05, .05 - h / 2)) font.render(status, (.05, .05 + h / 2)) font.render(unicode(self.song.difficulty[0]), (.05, .05 + 3 * h / 2)) Theme.setBaseColor() text = self.song.info.name + (self.modified and "*" or "") Dialogs.wrapText(font, (.5, .05 - h / 2), text) finally: self.engine.view.resetProjection()
def render(self, visibility, topMost): if not visibility: self.active = False return if not self.active and not self.first: self.getPlayers() self.active = True self.first = False if self.singlePlayer: self.renderLocalLobby(visibility, topMost) return self.engine.view.setOrthogonalProjection(normalize=True) font = self.engine.data.font try: v = 1.0 - ((1 - visibility)**2) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE) glEnable(GL_COLOR_MATERIAL) text = _("Lobby (%d players)") % len(self.session.world.players) w, h = font.getStringSize(text) x = .5 - w / 2 d = 0.0 c = 1 - .25 * v y = .1 - (1.0 - v) * .2 for i, ch in enumerate(text): w, h = font.getStringSize(ch) c = i * .05 glColor3f(*colorsys.hsv_to_rgb(.75, c, 1)) glPushMatrix() s = .25 * (math.sin(i / 2 + self.time / 4) + 2) glTranslate(-s * w / 2, -s * h / 2, 0) font.render(ch, (x, y), scale=0.002 * s) glPopMatrix() x += w x = .1 y = .2 + (1 - v) / 4 glColor4f(1, 1, 1, v) for player in self.session.world.players: font.render(player.name, (x, y)) y += .08 if self.canStartGame(): s = _("Press Enter to Start Game") sz = 0.0013 w, h = font.getStringSize(s, scale=sz) font.render(s, (.5 - w / 2, .65), scale=sz) finally: self.engine.view.resetProjection()
def resetStats(self): if not self.player: return tsYes = _("Yes") q = Dialogs.chooseItem( self.engine, [tsYes, _("No")], _("Are you sure you want to reset all stats for this player?")) if q == tsYes: Player.resetStats(self.player)
def deleteCharacter(self): tsYes = _("Yes") q = Dialogs.chooseItem( self.engine, [tsYes, _("No")], _("Are you sure you want to delete this player?")) if q == tsYes: if self.player: Player.deletePlayer(self.player) self.engine.view.popLayer(self) self.engine.input.removeKeyListener(self)
def loadLibrary(self): Log.debug("Loading libraries in %s" % self.library) self.loaded = False self.tiersPresent = False if self.splash: Dialogs.changeLoadingSplashScreenText(self.engine, self.splash, _("Browsing Collection...")) else: self.splash = Dialogs.showLoadingSplashScreen(self.engine, _("Browsing Collection...")) self.loadStartTime = time.time() self.engine.resource.load(self, "libraries", lambda: Song.getAvailableLibraries(self.engine, self.library), onLoad = self.loadSongs, synch = True)
def createClient(self, libraryName, songName, players = 1): #players = None Log.debug("GameResultsSceneClient class init...") self.libraryName = libraryName self.songName = songName self.stars = [0 for i in players] self.accuracy = [0 for i in players] self.counter = 0 self.showHighscores = False self.highscoreIndex = [-1 for i in players] self.taunt = None self.uploadingScores = False self.uploadResult = None self.nextScene = None self.offset = None self.pauseScroll = None self.scorePart = None self.scoreDifficulty = None self.playerList = players self.spinnyDisabled = True#NO SPINNY!!! #myfingershurt: reordering so default is Change Song. items = [ (_("Continue"), self.changeSong), (_("Replay"), self.replay), (_("Quit"), self.quit), ] self.menu = Menu(self.engine, items, onCancel = self.quit, pos = (.2, .5)) self.engine.resource.load(self, "song", lambda: Song.loadSong(self.engine, songName, library = self.libraryName, notesOnly = True, part = [player.part for player in self.playerList]), onLoad = self.songLoaded) #Get theme themename = self.engine.data.themeLabel #now theme determination logic is only in data.py: self.theme = self.engine.data.theme self.starScoring = self.engine.config.get("game", "star_scoring")#MFH self.Congratphrase = self.engine.config.get("game", "congrats")#blazingamer self.resultCheerLoop = self.engine.config.get("game", "result_cheer_loop")#MFH self.cheerLoopDelay = self.engine.config.get("game", "cheer_loop_delay")#MFH self.cheerLoopCounter = self.cheerLoopDelay #MFH - starts out ready to cheer self.engine.loadImgDrawing(self, "background", os.path.join("themes",themename,"gameresults.png")) phrase = random.choice(Theme.resultsPhrase.split("_")) if phrase == "None": i = random.randint(0,5) if i == 0: phrase = _("Relax, it was an excellent show.") elif i == 1: phrase = _("Truly Amazing!") elif i == 2: phrase = _("Thanks for playing!") elif i == 3: phrase = _("One more song can't hurt, can it?") elif i == 4: phrase = _("What an amazing performance!") else: phrase = _("That's how it's done!") Dialogs.showLoadingScreen(self.engine, lambda: self.song, text = phrase)
def __init__(self, engine, songName = None): self.engine = engine self.time = 0.0 self.nextLayer = None self.visibility = 0.0 self.songName = songName self.engine.loadImgDrawing(self, "background", "keyboard.png") self.engine.loadImgDrawing(self, "guy", "pose.png") self.engine.loadImgDrawing(self, "logo", "logo.png") self.song = audio.Sound(self.engine.resource.fileName("menu.ogg")) self.song.setVolume(self.engine.config.get("audio", "songvol")) self.song.play(-1) editorMenu = Menu(self.engine, [ (_("Edit Existing Song"), self.startEditor), (_("Import New Song"), self.startImporter), (_("Import Guitar Hero(tm) Songs"), self.startGHImporter), ]) settingsMenu = Settings.SettingsMenu(self.engine) mainMenu = [ (_("Play Game"), self.newSinglePlayerGame), (_("Tutorial"), self.showTutorial), (_("Song Editor"), editorMenu), (_("Settings >"), settingsMenu), (_("Credits"), self.showCredits), (_("Quit"), self.quit), ] self.menu = Menu(self.engine, mainMenu, onClose = lambda: self.engine.view.popLayer(self))
def _getFileText(self, fileName): f = os.path.join(self.path, fileName) if fileName == "..": return _("[Parent Folder]") if self.dirSelect == True: for mask in self.masks: if fnmatch.fnmatch(fileName, mask): return _("[Accept Folder]") if os.path.isdir(f): return _("%s [Folder]") % fileName return fileName
def getPlayers(self): self.playerNames = Player.playername self.playerPrefs = Player.playerpref self.options = [_("Create New Player"), _("Saved Characters")] self.options.extend(self.playerNames) if self.selected >= len(self.options): self.selected = len(self.options) - 1 self.avatars = [None for i in self.options] self.avatarScale = [None for i in self.options] self.necks = [None for i in self.options] self.neckScale = [None for i in self.options]
def shown(self): self.engine.input.addKeyListener(self) self.isRunning = True if not self.singlePlayer: n = self.session.id or 1 name = Dialogs.getText(self.engine, _("Enter your name:"), _("Player #%d") % n) if name: self.session.world.createPlayer(name) else: self.engine.view.popLayer(self)
def save(self): if not self.modified: Dialogs.showMessage(self.engine, _("There are no changes to save.")) return def save(): self.song.save() self.modified = False self.engine.resource.load(function = save) Dialogs.showLoadingScreen(self.engine, lambda: not self.modified, text = _("Saving...")) Dialogs.showMessage(self.engine, _("'%s' saved.") % self.song.info.name)
def setCassetteColor(self): if self.song.info.cassetteColor: color = Theme.colorToHex(self.song.info.cassetteColor) else: color = "" color = Dialogs.getText(self.engine, _("Enter cassette color in HTML (#RRGGBB) format."), color) if color: try: self.song.info.setCassetteColor(Theme.hexToColor(color)) self.modified = True except ValueError: Dialogs.showMessage(self.engine, _("That isn't a color."))
def keyPressed(self, key, unicode): ret = SceneClient.keyPressed(self, key, unicode) c = self.controls.keyPressed(key) if self.song and (c in [Player.KEY1, Player.KEY2, Player.CANCEL, Player.ACTION1, Player.ACTION2, Player.DRUM1A, Player.DRUM4A] or key == pygame.K_RETURN): for i,player in enumerate(self.playerList): scores = self.song.info.getHighscores(player.difficulty, part = player.part) if not scores or player.score > scores[-1][0] or len(scores) < 5: if player.cheating: Dialogs.showMessage(self.engine, _("No highscores for cheaters!")) elif player.score == 0: #trinidude4 Dialogs.showMessage(self.engine, _("No highscore")) #trinidude4 else: #alarian name = Dialogs.getText(self.engine, _("%d points is a new high score! Player " + str(i+1) + " enter your name") % player.score, player.name) name = Dialogs.getText(self.engine, _("%d points is a new high score! Enter your name") % player.score, player.name) if name: player.name = name #myfingershurt: don't separate chords for drum part totals: if player.part.text == "Drums": notesTotal = len([1 for time, event in self.song.track[i].getAllEvents() if isinstance(event, Song.Note)]) else: notesTotal = len(set(time for time, event in self.song.track[i].getAllEvents() if isinstance(event, Song.Note))) modOptions1 = self.engine.config.getModOptions1(player.twoChord, 0) modOptions2 = self.engine.config.getModOptions2() scoreExt = (player.notesHit, notesTotal, player.longestStreak, Version.branchVersion(), modOptions1, modOptions2) self.highscoreIndex[i] = self.song.info.addHighscore(player.difficulty, player.score, self.stars[i], player.name, part = player.part, scoreExt = scoreExt) self.song.info.save() if self.engine.config.get("game", "uploadscores") and not player.cheating: self.uploadingScores[i] = True # evilynux - New url starting 20080902 fn = lambda: self.song.info.uploadHighscores(self.engine.config.get("game", "uploadurl_w67_starpower"), self.song.getHash(), part = player.part) #self.engine.resource.load(self, "uploadResult", fn) self.engine.resource.load(self, "uploadResult", fn, onLoad = self.handleWorldChartRanking) #MFH if len(self.playerList) > 1 and self.playerList[0].part == self.playerList[1].part and self.playerList[0].difficulty == self.playerList[1].difficulty and self.highscoreIndex[0] != -1 and self.highscoreIndex[1] != -1 and self.highscoreIndex[1] <= self.highscoreIndex[0]: self.highscoreIndex[0] += 1 if self.song.info.count: count = int(self.song.info.count) else: count = 0 count += 1 self.song.info.count = "%d" % count self.song.info.save() self.showHighscores = True self.engine.view.pushLayer(self.menu) return True return ret
def Info(self): AutoTimer, NameSat, Data, Type, Personal, DowDate = Load() if str(Data) == '0': newdate = ('') else: newdate = (' - ' + ConverDate(Data)) if str(DowDate) == '0': newDowDate = (_('Last Update: Unregistered')) else: newDowDate = (_('Last Update: ') + DowDate) self['namesat'].setText(NameSat + newdate) self['dataDow'].setText(newDowDate)
def Info(self): AutoTimer, NameSat, Data, Type, Personal, DowDate = Load() if str(Data) == '0': newdate = '' else: newdate = ' - ' + ConverDate(Data) if str(DowDate) == '0': newDowDate = _('Last Update: Unregistered') else: newDowDate = _('Last Update: ') + DowDate self['namesat'].setText(NameSat + newdate) self['dataDow'].setText(newDowDate)
def keyPressed(self, key, unicode): ret = SceneClient.keyPressed(self, key, unicode) c = self.controls.keyPressed(key) if self.song and (c in [Player.KEY1, Player.KEY2, Player.CANCEL, Player.ACTION1, Player.ACTION2, Player.DRUM1A, Player.DRUM4A] or key == pygame.K_RETURN): for i,player in enumerate(self.playerList): scores = self.song.info.getHighscores(player.difficulty, part = player.part) if not scores or player.score > scores[-1][0] or len(scores) < 5: if player.cheating: Dialogs.showMessage(self.engine, _("No highscores for cheaters!")) elif player.score == 0: #trinidude4 Dialogs.showMessage(self.engine, _("No highscore")) #trinidude4 else: #alarian name = Dialogs.getText(self.engine, _("%d points is a new high score! Player " + str(i+1) + " enter your name") % player.score, player.name) name = Dialogs.getText(self.engine, _("%d points is a new high score! Enter your name") % player.score, player.name) if name: player.name = name #myfingershurt: don't separate chords for drum part totals: if player.part.text == "Drums": notesTotal = len([1 for time, event in self.song.track[i].getAllEvents() if isinstance(event, Song.Note)]) else: notesTotal = len(set(time for time, event in self.song.track[i].getAllEvents() if isinstance(event, Song.Note))) modOptions1 = self.engine.config.getModOptions1(player.twoChord, 0) modOptions2 = self.engine.config.getModOptions2() scoreExt = (player.notesHit, notesTotal, player.longestStreak, Version.branchVersion(), modOptions1, modOptions2) self.highscoreIndex[i] = self.song.info.addHighscore(player.difficulty, player.score, self.stars[i], player.name, part = player.part, scoreExt = scoreExt) self.song.info.save() if self.engine.config.get("game", "uploadscores") and not player.cheating: self.uploadingScores = True #myfingershurt: ensuring new SP highscore upload URL is used from Divra (set to default in gameengine.py) # evilynux - New url starting 20080902 fn = lambda: self.song.info.uploadHighscores(self.engine.config.get("game", "uploadurl_w67_starpower"), self.song.getHash(), part = player.part) self.engine.resource.load(self, "uploadResult", fn) if len(self.playerList) > 1 and self.playerList[0].part == self.playerList[1].part and self.playerList[0].difficulty == self.playerList[1].difficulty and self.highscoreIndex[0] != -1 and self.highscoreIndex[1] != -1 and self.highscoreIndex[1] <= self.highscoreIndex[0]: self.highscoreIndex[0] += 1 if self.song.info.count: count = int(self.song.info.count) else: count = 0 count += 1 self.song.info.count = "%d" % count self.song.info.save() self.showHighscores = True self.engine.view.pushLayer(self.menu) return True return ret
def render(self, visibility, topMost): if not self.song: return v = 1.0 - ((1 - visibility) ** 2) # render the background t = self.time / 100 + 34 w, h, = self.engine.view.geometry[2:4] r = .5 if self.spinnyDisabled != True and Theme.spinnyEditorDisabled: self.background.transform.reset() self.background.transform.translate(w / 2 + math.sin(t / 2) * w / 2 * r, h / 2 + math.cos(t) * h / 2 * r) self.background.transform.rotate(-t) self.background.transform.scale(math.sin(t / 8) + 2, math.sin(t / 8) + 2) self.background.draw() self.camera.target = ( 2, 0, 5.5) self.camera.origin = (-2, 9, 5.5) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(60, 4.0 / 3.0, 0.1, 1000) glMatrixMode(GL_MODELVIEW) glLoadIdentity() self.camera.apply() self.guitar.render(v, self.song, self.scrollPos, self.controls) self.engine.view.setOrthogonalProjection(normalize = True) font = self.engine.data.font try: Theme.setSelectedColor() w, h = font.getStringSize(" ") if self.song.isPlaying(): status = _("Playing") else: status = _("Stopped") t = "%d.%02d'%03d" % (self.pos / 60000, (self.pos % 60000) / 1000, self.pos % 1000) font.render(t, (.05, .05 - h / 2)) font.render(status, (.05, .05 + h / 2)) font.render(unicode(self.song.difficulty[0]), (.05, .05 + 3 * h / 2)) Theme.setBaseColor() text = self.song.info.name + (self.modified and "*" or "") Dialogs.wrapText(font, (.5, .05 - h / 2), text) finally: self.engine.view.resetProjection()
def getPlayers(self): self.playerNames = Player.playername self.playerPrefs = Player.playerpref self.options = [_("Create New Player"), _("Saved Characters")] self.options.extend(self.playerNames) for i in range(4): if self.selected[i] >= len(self.options): self.selected[i] = len(self.options) - 1 self.blockedItems = [1] for i in self.selectedItems: self.blockedItems.append(self.options.index(i)) self.avatars = [None for i in self.options] self.avatarScale = [None for i in self.options] self.getStartingSelected()
def render(self, visibility, topMost): if self.singlePlayer: return self.engine.view.setOrthogonalProjection(normalize = True) font = self.engine.data.font try: v = 1.0 - ((1 - visibility) ** 2) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE) glEnable(GL_COLOR_MATERIAL) text = _("Lobby (%d players)") % len(self.engine.world.players) w, h = font.getStringSize(text) x = .5 - w / 2 d = 0.0 c = 1 - .25 * v y = .1 - (1.0 - v) * .2 for i, ch in enumerate(text): w, h = font.getStringSize(ch) c = i * .05 glColor3f(*colorsys.hsv_to_rgb(.75, c, 1)) glPushMatrix() s = .25 * (math.sin(i / 2 + self.time / 4) + 2) glTranslate(-s * w / 2, -s * h / 2, 0) font.render(ch, (x, y), scale = 0.002 * s) glPopMatrix() x += w x = .1 y = .2 + (1 - v) / 4 glColor4f(1, 1, 1, v) for player in self.engine.world.players: font.render(player.name, (x, y)) y += .08 if self.canStartGame(): s = _("Press Enter to Start Game") sz = 0.0013 w, h = font.getStringSize(s, scale = sz) font.render(s, (.5 - w / 2, .65), scale = sz) finally: self.engine.view.resetProjection()
def shown(self): self.engine.view.pushLayer(self.menu) shaders.checkIfEnabled() if not self.shownOnce: self.shownOnce = True if hasattr(sys, 'frozen'): #stump: Check whether this is a non-svn binary being run from an svn working copy. if os.path.isdir(os.path.join('src', '.svn')) and 'development' not in Version.version(): Dialogs.showMessage(self.engine, _('This binary release is being run from a Subversion working copy. This is not the correct way to run FoFiX from Subversion. Please see one of the following web pages to set your Subversion working copy up correctly:') + '\n\nhttp://code.google.com/p/fofix/wiki/RunningUnderPython26' + '\nhttp://code.google.com/p/fofix/wiki/RequiredSourceModules') #stump: Check whether this is an svn binary not being run from an svn working copy elif not os.path.isdir(os.path.join('src', '.svn')) and 'development' in Version.version(): Dialogs.showMessage(self.engine, _('This binary was built from a Subversion working copy but is not running from one. The FoFiX Team will not provide any support whatsoever for this binary. Please see the following site for official binary releases:') + '\n\nhttp://code.google.com/p/fofix/')
def render(self, visibility, topMost): v = (1 - visibility) ** 2 self.engine.view.setOrthogonalProjection(normalize = True) font = self.engine.data.font fadeScreen(v) try: glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glEnable(GL_COLOR_MATERIAL) Theme.setBaseColor(1 - v) wrapText(font, (.1, .2 - v), self.prompt) for n, c in enumerate(Guitar.KEYS): if self.controls.getState(c): glColor3f(*self.fretColors[n]) else: glColor3f(.4, .4, .4) font.render("#%d" % (n + 1), (.5 - .15 * (2 - n), .4 + v)) if self.controls.getState(Player.ACTION1) or \ self.controls.getState(Player.ACTION2): Theme.setSelectedColor(1 - v) else: glColor3f(.4, .4, .4) font.render(_("Pick!"), (.45, .5 + v)) finally: self.engine.view.resetProjection()
def run(self, ticks): SceneClient.run(self, ticks) if not self.wizardStarted: self.wizardStarted = True if not self.songName: while True: self.libraryName, self.songName = \ Dialogs.chooseSong(self.engine, \ selectedLibrary = Config.get("game", "selected_library"), selectedSong = Config.get("game", "selected_song")) if not self.songName: self.session.world.finishGame() return Config.set("game", "selected_library", self.libraryName) Config.set("game", "selected_song", self.songName) info = Song.loadSongInfo(self.engine, self.songName, library = self.libraryName) d = Dialogs.chooseItem(self.engine, info.difficulties, _("Choose a difficulty:"), selected = self.player.difficulty) if d: self.player.difficulty = d break else: info = Song.loadSongInfo(self.engine, self.songName, library = self.libraryName) # Make sure the difficulty we chose is available if not self.player.difficulty in info.difficulties: self.player.difficulty = info.difficulties[0] self.session.world.deleteScene(self) self.session.world.createScene("GuitarScene", libraryName = self.libraryName, songName = self.songName)
def shown(self): self.engine.input.addKeyListener(self) if self.singlePlayer: self.session.world.createPlayer(_("Player")) if self.songName: self.session.world.startGame(libraryName = Song.DEFAULT_LIBRARY, songName = self.songName) else: self.session.world.startGame() else: n = self.session.id or 1 name = Dialogs.getText(self.engine, _("Enter your name:"), _("Player #%d") % n) if name: self.session.world.createPlayer(name) else: self.engine.view.popLayer(self)
def showTutorial(self): # evilynux - Make sure tutorial exists before launching #tutorialpath = self.engine.getPath(os.path.join("songs","tutorial")) tutorialpath = self.engine.tutorialFolder if not os.path.isdir(self.engine.resource.fileName(tutorialpath)): Log.debug("No folder found: %s" % tutorialpath) Dialogs.showMessage(self.engine, _("No tutorials found!")) return if self.engine.isServerRunning(): return players = Dialogs.activateControllers(self.engine, 1) #akedrou if players == 0: return Config.set("game","game_mode", 0) #MFH - ensure tutorial can work with new logic that depends on this mode variable Config.set("game","multiplayer_mode", 0) #MFH - ensure tutorial can work with new logic that depends on this mode variable Config.set("game", "players", 1) Config.set("game", "tut", True) #Config.set("game","game_mode", 1) #MFH - don't force practice mode.... this is problematic. self.engine.startServer() self.engine.resource.load(self, "session", lambda: self.engine.connect("127.0.0.1"), synch = True) if Dialogs.showLoadingScreen(self.engine, lambda: self.session and self.session.isConnected): self.launchLayer(lambda: Lobby(self.engine, self.session, singlePlayer = True))
def showLoadingScreen(engine, condition, text=_("Loading..."), allowCancel=False): """ Show a loading screen until a condition is met. @param engine: Game engine @param condition: A function that will be polled until it returns a true value @param text: Text shown to the user @type allowCancel: bool @param allowCancel: Can the loading be canceled @return: True if the condition was met, Fales if the loading was canceled. """ # poll the condition first for some time n = 0 while n < 32: n += 1 if condition(): return True engine.run() d = LoadingScreen(engine, condition, text, allowCancel) _runDialog(engine, d) return d.ready
def getAvailableMics(): result = {-1: _('[Default Microphone]')} for devnum in range(pa.get_device_count()): devinfo = pa.get_device_info_by_index(devnum) if devinfo['maxInputChannels'] > 0: result[devnum] = devinfo['name'] return result
def showTutorial(self): # evilynux - Make sure tutorial exists before launching tutorialpath = self.engine.getPath(os.path.join("songs", "tutorial")) if not os.path.exists(tutorialpath): Dialogs.showMessage(self.engine, _("No tutorial found in your song library!")) return if self.engine.isServerRunning(): return Config.set( "player0", "mode_1p", 0 ) #MFH - ensure tutorial can work with new logic that depends on this mode variable Config.set( "player0", "mode_2p", 0 ) #MFH - ensure tutorial can work with new logic that depends on this mode variable Config.set("game", "players", 1) self.engine.startServer() self.engine.resource.load(self, "session", lambda: self.engine.connect("127.0.0.1"), synch=True) if Dialogs.showLoadingScreen( self.engine, lambda: self.session and self.session.isConnected): self.launchLayer(lambda: Lobby( self.engine, self.session, singlePlayer=True, tutorial=True))
def init(engine): # define configuration keys for all available mods for m in getAvailableMods(engine): Config.define("mods", "mod_" + m, bool, False, text=m, options={ False: _("Off"), True: _("On") }) # init all active mods for m in getActiveMods(engine): activateMod(engine, m)
def init(engine): # define configuration keys for all available mods for m in getAvailableMods(engine): Config.define("mods", "mod_" + m, bool, False, text = m, options = {False: _("Off"), True: _("On")}) # init all active mods for m in getActiveMods(engine): activateMod(engine, m)