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 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 showTutorial(self): # evilynux - Make sure tutorial exists before launching 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 self.engine.startWorld(1, None, 0, 0, tutorial=True) self.launchLayer(lambda: Lobby(self.engine))
def showTutorial(self): # evilynux - Make sure tutorial exists before launching 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 self.engine.startWorld(1, None, 0, 0, tutorial = True) self.launchLayer(lambda: Lobby(self.engine))
def setNewKeyMapping(engine, config, section, option, key): oldKey = config.get(section, option) config.set(section, option, key) keyCheckerMode = Config.get("game", "key_checker_mode") if key == "None" or key is None: return True b = isKeyMappingOK(config, option) if b != 0: if keyCheckerMode > 0: from views import Dialogs Dialogs.showMessage(engine, _("This key conflicts with the following keys: %s") % str(b)) if keyCheckerMode == 2: #enforce no conflicts! config.set(section, option, oldKey) return False return True
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 saveCharacter(self): pref = self.choices[0:8] pref.insert(7, self.neck) if len(self.choices[0]) > 0: if self.choices[0].lower() == "default": Dialogs.showMessage(self.engine, _("That is a terrible name. Choose something not 'default'")) elif self.choices[0].lower() not in self.invalidNames or self.choices[0] == self.player: Player.updatePlayer(self.player, pref) self.updatedName = self.choices[0] if self.avatar is not None: shutil.copy(self.engine.resource.fileName(self.avatar),os.path.join(self.engine.data.path,"users","players",self.choices[0]+".png")) if self.oldName: if os.path.exists(self.engine.resource.fileName(os.path.join("users","players",self.oldName+".png"))) and self.oldName != self.choices[0]: if self.avatar is None: os.rename(self.engine.resource.fileName(os.path.join("users","players",self.oldName+".png")), os.path.join(self.engine.data.path,"users","players",self.choices[0]+".png")) else: os.remove(self.engine.resource.fileName(os.path.join("users","players",self.oldName+".png"))) self.engine.view.popLayer(self) self.engine.input.removeKeyListener(self) else: Dialogs.showMessage(self.engine, _("That name already exists!")) else: Dialogs.showMessage(self.engine, _("Please enter a name!"))
def checkCmdPlay(self): info = Song.loadSongInfo(self.engine, self.songName, library = self.libraryName) guitars = [] drums = [] vocals = [] autoPart = None 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 self.engine.cmdPlay == 2 and self.engine.cmdPart is not None and len(self.playerList) == 1: if self.engine.cmdPart == part.id: Log.debug("Command-line mode: Part found!") if part.id == 4 and self.engine.input.gameDrums > 0: autoPart = part.id elif part.id == 5 and self.engine.input.gameMics > 0: autoPart = part.id elif self.engine.input.gameGuitars > 0: autoPart = part.id if autoPart is None: if len(drums) == 0 and self.engine.input.gameDrums > 0: if self.splash: Dialogs.hideLoadingSplashScreen(self.engine, self.splash) self.splash = None Dialogs.showMessage(self.engine, _("There are no drum parts in this song. Change your controllers to play.")) if self.engine.cmdPlay == 2: self.engine.cmdPlay = 0 return False if len(guitars) == 0 and self.engine.input.gameGuitars > 0: if self.splash: Dialogs.hideLoadingSplashScreen(self.engine, self.splash) self.splash = None Dialogs.showMessage(self.engine, _("There are no guitar parts in this song. Change your controllers to play.")) if self.engine.cmdPlay == 2: self.engine.cmdPlay = 0 return False if len(vocals) == 0 and self.engine.input.gameMics > 0: if self.splash: Dialogs.hideLoadingSplashScreen(self.engine, self.splash) self.splash = None Dialogs.showMessage(self.engine, _("There are no vocal parts in this song. Change your controllers to play.")) if self.engine.cmdPlay == 2: self.engine.cmdPlay = 0 return False # Make sure the difficulty we chose is available p = self.playerList[0].part player = self.playerList[0] if self.engine.cmdDiff is not None: diff = Song.difficulties[self.engine.cmdDiff] if diff in info.partDifficulties[p.id]: self.playerList[0].difficulty = diff else: self.playerList[0].difficulty = info.partDifficulties[p.id][0] else: if self.splash: Dialogs.hideLoadingSplashScreen(self.engine, self.splash) self.splash = None self.playerList[0].difficulty = Dialogs.chooseItem(self.engine, info.partDifficulties[p.id], "%s \n %s" % (Song.removeSongOrderPrefixFromName(info.name), _("%s Choose a difficulty:") % player.name), selected = player.difficulty) return True
def prepareSetlist(self, songs): if self.songLoader: self.songLoader.stop() msg = self.engine.setlistMsg self.engine.setlistMsg = None self.selectedIndex = 0 if self.listingMode == 0 or self.careerMode: self.items = self.libraries + self.songs else: self.items = self.songs self.itemRenderAngles = [0.0] * len(self.items) self.itemLabels = [None] * len(self.items) self.searching = False self.searchText = "" shownItems = [] for item in self.items: #remove things we don't want to see. Some redundancy, but that's okay. if isinstance(item, Song.TitleInfo) or isinstance(item, Song.SortTitleInfo): if self.showCareerTiers == 2: if isinstance(item, Song.TitleInfo): if len(shownItems) > 0: if isinstance(shownItems[-1], Song.TitleInfo): shownItems.pop() shownItems.append(item) elif isinstance(item, Song.SortTitleInfo): continue else: if isinstance(item, Song.TitleInfo): continue elif isinstance(item, Song.SortTitleInfo): if not self.showSortTiers: continue if len(shownItems) > 0: if isinstance(shownItems[-1], Song.SortTitleInfo): shownItems.pop() shownItems.append(item) elif isinstance(item, Song.SongInfo): if self.careerMode and (not self.showLockedSongs) and item.getLocked(): continue else: shownItems.append(item) else: shownItems.append(item) if len(shownItems) > 0: if isinstance(shownItems[-1], Song.TitleInfo) or isinstance(shownItems[-1], Song.SortTitleInfo): shownItems.pop() if len(self.items) > 0 and len(shownItems) == 0: msg = _("No songs in this setlist are available to play!") if self.careerMode: msg = msg + " " + _("Make sure you have a working career pack!") Dialogs.showMessage(self.engine, msg) elif len(shownItems) > 0: for item in shownItems: if isinstance(item, Song.SongInfo) or isinstance(item, Song.LibraryInfo): self.items = shownItems #make sure at least one item is selectable break else: msg = _("No songs in this setlist are available to play!") if self.careerMode: msg = msg + " " + _("Make sure you have a working career pack!") Dialogs.showMessage(self.engine, msg) self.items = [] if self.items == []: #MFH: Catch when there ain't a damn thing in the current folder - back out! if self.library != Song.DEFAULT_LIBRARY: Dialogs.hideLoadingSplashScreen(self.engine, self.splash) self.splash = None self.startingSelected = self.library self.library = os.path.dirname(self.library) self.selectedItem = None self.loadLibrary() return Log.debug("Setlist loaded.") self.loaded = True if self.setlistStyle == 1: for i in range(self.headerSkip): self.items.insert(0, Song.BlankSpaceInfo()) for i in range(self.footerSkip): self.items.append(Song.BlankSpaceInfo()) if self.startingSelected is not None: for i, item in enumerate(self.items): if isinstance(item, Song.SongInfo) and self.startingSelected == item.songName: #TODO: SongDB self.selectedIndex = i break elif isinstance(item, Song.LibraryInfo) and self.startingSelected == item.libraryName: self.selectedIndex = i break for item in self.items: if isinstance(item, Song.SongInfo): item.name = Song.removeSongOrderPrefixFromName(item.name) #TODO: I don't like this. elif not self.tiersPresent and (isinstance(item, Song.TitleInfo) or isinstance(item, Song.SortTitleInfo)): self.tiersPresent = True while isinstance(self.items[self.selectedIndex], Song.BlankSpaceInfo) or ((isinstance(self.items[self.selectedIndex], Song.TitleInfo) or isinstance(self.items[self.selectedIndex], Song.SortTitleInfo)) and not self.selectTiers): self.selectedIndex += 1 if self.selectedIndex >= len(self.items): self.selectedIndex = 0 self.itemRenderAngles = [0.0] * len(self.items) self.itemLabels = [None] * len(self.items) if self.preloadSongLabels: for i in range(len(self.items)): self.loadStartTime = time.time() Dialogs.changeLoadingSplashScreenText(self.engine, self.splash, _("Loading Album Artwork...")) self.loadItemLabel(i, preload = True) self.updateSelection() Dialogs.hideLoadingSplashScreen(self.engine, self.splash) self.splash = None
def showMessages(self): msg = self.engine.startupMessages.pop() self.showStartupMessages = False Dialogs.showMessage(self.engine, msg)
def __init__(self, engine): if not engine.world: raise WorldNotStarted self.engine = engine self.minPlayers = self.engine.world.minPlayers self.maxPlayers = self.engine.world.maxPlayers self.tutorial = self.engine.world.tutorial self.gameMode = self.engine.world.gameMode self.multiMode = self.engine.world.multiMode self.time = 0.0 self.keyControl = 0 self.keyGrab = False self.scrolling = [0,0,0,0] self.rate = [0,0,0,0] self.delay = [0,0,0,0] self.scroller = [0, self.scrollUp, self.scrollDown] self.gameStarted = False self.done = True self.active = False self.blockedItems = [1] self.selectedItems = [] self.blockedPlayers = [] self.selectedPlayers = [] self.playerList = [None for i in range(4)] self.fullView = self.engine.view.geometry[2:4] self.music = True self.creator = CreateCharacter(self.engine) #key vars self.fontDict = self.engine.data.fontDict self.geometry = self.engine.view.geometry[2:4] self.fontScreenBottom = self.engine.data.fontScreenBottom self.aspectRatio = self.engine.view.aspectRatio self.drawStarScore = self.engine.drawStarScore self.gameModeText = self.engine.world.gameName self.yes = [] self.no = [] self.conf = [] self.up = [] self.down = [] self.controls = [j for j in self.engine.input.controls.controls] self.types = [] self.allowed = [True for i in range(4)] for i, type in enumerate(self.engine.input.controls.type): self.types.append(type) if type in GUITARTYPES: if not self.engine.world.allowGuitar: self.allowed[i] = False else: self.yes.extend([Player.CONTROLS[i][Player.KEY1], Player.CONTROLS[i][Player.KEY1A], Player.CONTROLS[i][Player.START]]) self.no.extend([Player.CONTROLS[i][Player.KEY2], Player.CONTROLS[i][Player.KEY2A], Player.CONTROLS[i][Player.CANCEL]]) self.conf.extend([Player.CONTROLS[i][Player.KEY3], Player.CONTROLS[i][Player.KEY3A]]) self.up.extend([Player.CONTROLS[i][Player.ACTION1], Player.CONTROLS[i][Player.UP]]) self.down.extend([Player.CONTROLS[i][Player.ACTION2], Player.CONTROLS[i][Player.DOWN]]) elif type in DRUMTYPES: if not self.engine.world.allowDrum: self.allowed[i] = False else: self.yes.extend([Player.CONTROLS[i][Player.DRUM5], Player.CONTROLS[i][Player.DRUM5A], Player.CONTROLS[i][Player.START]]) self.no.extend([Player.CONTROLS[i][Player.DRUM1], Player.CONTROLS[i][Player.DRUM1A], Player.CONTROLS[i][Player.CANCEL]]) self.conf.extend([Player.CONTROLS[i][Player.DRUMBASS], Player.CONTROLS[i][Player.DRUMBASSA]]) self.up.extend([Player.CONTROLS[i][Player.DRUM2], Player.CONTROLS[i][Player.DRUM2A], Player.CONTROLS[i][Player.UP]]) self.down.extend([Player.CONTROLS[i][Player.DRUM3], Player.CONTROLS[i][Player.DRUM3A], Player.CONTROLS[i][Player.DOWN]]) elif type in MICTYPES: if not self.engine.world.allowMic: self.allowed[i] = False else: self.yes.extend([Player.CONTROLS[i][Player.START]]) self.no.extend([Player.CONTROLS[i][Player.CANCEL]]) self.up.extend([Player.CONTROLS[i][Player.UP]]) self.down.extend([Player.CONTROLS[i][Player.DOWN]]) for i, control in enumerate(self.engine.input.controls.controls): if control == "None": self.controls[i] = _("No Controller") self.blockedPlayers.append(i) elif self.allowed[i] == False: self.controls[i] = _("Disabled Controller") self.blockedPlayers.append(i) elif control == "defaultg": self.controls[i] = _("Default Guitar") elif control == "defaultd": self.controls[i] = _("Default Drums") elif control == "defaultm": self.controls[i] = _("Default Microphone") if 4 - len(self.blockedPlayers) < self.minPlayers: Dialogs.showMessage(self.engine, _("Your controls are not properly set up for this mode. Please check your settings.")) #FIXME: Go back to the main menu (or the control menu) without screwing up the layers. self.engine.input.activeGameControls = [i for i in range(4) if i not in self.blockedPlayers] self.engine.input.pluginControls() self.panelOrder = range(4) self.oldOrder = range(4) themename = self.engine.data.themeLabel self.theme = self.engine.theme self.engine.data.loadAllImages(self, os.path.join("themes",themename,"lobby")) self.partImages = self.engine.data.partImages if not self.img_default_av: self.engine.data.loadImgDrawing(self, "img_default_av", os.path.join("users", "players", "default.png")) if not self.img_newchar_av: self.engine.data.loadImgDrawing(self, "img_newchar_av", os.path.join("users", "players", "newchar_av.png")) if self.img_default_av: imgheight = self.img_default_av.height1() imgwidth = self.img_default_av.width1() hFactor = self.theme.lobbyPanelAvatarDimension[1]/imgheight wFactor = self.theme.lobbyPanelAvatarDimension[0]/imgwidth self.defaultAvScale = min(hFactor, wFactor) if self.img_newchar_av: imgheight = self.img_newchar_av.height1() imgwidth = self.img_newchar_av.width1() hFactor = self.theme.lobbyPanelAvatarDimension[1]/imgheight wFactor = self.theme.lobbyPanelAvatarDimension[0]/imgwidth self.newCharAvScale = min(hFactor, wFactor) self.tsChooseChar = _("Choose Your Character") self.tsPlayerStr = _("Player %d") self.playerNum = 0 self.tsDrumFlip = (_("Regular Drums"), _("Flipped Drums")) self.tsAutoKick = (_("Pedal-Using"), _("Footless")) self.tsAssist = (_("Assist Mode Off"), _("Easy Assist"), _("Medium Assist")) self.tsTwoChord = (_("Chordmaster"), _("Two Notes Max")) self.tsInfo = _("Information:") self.tsList = [("0","1"), self.tsDrumFlip, self.tsAutoKick, self.tsAssist, self.tsTwoChord] self.controlDict = Player.controlDict self.selected = [0,0,0,0] self.panelMode = [0,0,0,0] #panel mode: 0 = select; 1 = create/edit self.screenOptions = self.engine.theme.lobbySelectLength self.pos = [(0, self.screenOptions), (0, self.screenOptions), (0, self.screenOptions), (0, self.screenOptions)] self.getPlayers()