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 previewSong(self): self.previewLoaded = True if isinstance(self.selectedItem, Song.SongInfo): song = self.selectedItem.songName #TODO: SongDB else: return if self.careerMode and self.selectedItem.getLocked(): #TODO: SongDB if self.song: self.song.fadeout(1000) return if self.songLoader: try: self.songLoader.stop() except: self.songLoader = None self.songLoader = self.engine.resource.load(self, None, lambda: Song.loadSong(self.engine, song, playbackOnly = True, library = self.library), synch = True, onLoad = self.songLoaded, onCancel = self.songCanceled)
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 __init__(self, engine, libraryName = None, songName = None): Scene.__init__(self, engine) self.engine.world.sceneName = "SongChoosingScene" Song.updateSongDatabase(self.engine) self.wizardStarted = False self.libraryName = libraryName self.songName = songName if not self.libraryName: self.libraryName = self.engine.config.get("setlist", "selected_library") if not self.libraryName: self.libraryName = Song.DEFAULT_LIBRARY if not self.songName: self.songName = self.engine.config.get("setlist", "selected_song") self.gameMode = self.engine.world.gameMode self.careerMode = (self.gameMode == CAREER) self.practiceMode = (self.gameMode == PRACTICE) self.gameMode2p = self.engine.world.multiMode self.autoPreview = not self.engine.config.get("audio", "disable_preview") self.sortOrder = self.engine.config.get("game", "sort_order") self.tut = self.engine.world.tutorial self.playerList = self.players self.gameStarted = False self.gamePlayers = len(self.playerList) self.parts = [None for i in self.playerList] self.diffs = [None for i in self.playerList] self.time = 0 self.lastTime = 0 self.mode = 0 self.moreInfo = False self.moreInfoTime = 0 self.miniLobbyTime = 0 self.selected = 0 self.camera = Camera() self.cameraOffset = 0.0 self.song = None self.songLoader = None self.loaded = False text = _("Initializing Setlist...") if self.engine.cmdPlay == 2: text = _("Checking Command-Line Settings...") elif len(self.engine.world.songQueue) > 0: text = _("Checking Setlist Settings...") elif len(self.engine.world.songQueue) == 0: self.engine.world.playingQueue = False self.splash = Dialogs.showLoadingSplashScreen(self.engine, text) self.items = [] self.cmdPlay = False self.queued = True self.loadStartTime = time.time() if self.tut == True: self.library = self.engine.tutorialFolder else: self.library = os.path.join(self.engine.config.get("setlist", "base_library"), self.libraryName) if not os.path.isdir(self.engine.resource.fileName(self.library)): self.library = self.engine.resource.fileName(os.path.join(self.engine.config.get("setlist", "base_library"), Song.DEFAULT_LIBRARY)) self.searchText = "" #user configurables and input management self.listingMode = 0 #with libraries or List All self.preloadSongLabels = False self.showCareerTiers = 1+(self.careerMode and 1 or 0) #0-Never; 1-Career Only; 2-Always self.scrolling = 0 self.scrollDelay = self.engine.config.get("game", "scroll_delay") self.scrollRate = self.engine.config.get("game", "scroll_rate") self.scrollTime = 0 self.scroller = [lambda: None, self.scrollUp, self.scrollDown] self.scoreDifficulty = Song.difficulties[self.engine.config.get("game", "songlist_difficulty")] self.scorePart = Song.parts[self.engine.config.get("game", "songlist_instrument")] self.sortOrder = self.engine.config.get("game", "sort_order") self.queueFormat = self.engine.config.get("game", "queue_format") self.queueOrder = self.engine.config.get("game", "queue_order") self.queueParts = self.engine.config.get("game", "queue_parts") self.queueDiffs = self.engine.config.get("game", "queue_diff") self.nilShowNextScore = self.engine.config.get("songlist", "nil_show_next_score") #theme information self.themename = self.engine.data.themeLabel self.theme = self.engine.data.theme #theme configurables self.setlistStyle = self.engine.theme.setlist.setlistStyle #0 = Normal; 1 = List; 2 = Circular self.headerSkip = self.engine.theme.setlist.headerSkip #items taken up by header (non-static only) self.footerSkip = self.engine.theme.setlist.footerSkip #items taken up by footer (non-static only) self.itemSize = self.engine.theme.setlist.itemSize #delta (X, Y) (0..1) for each item (non-static only) self.labelType = self.engine.theme.setlist.labelType #Album covers (0) or CD labels (1) self.labelDistance = self.engine.theme.setlist.labelDistance #number of labels away to preload self.showMoreLabels = self.engine.theme.setlist.showMoreLabels #whether or not additional unselected labels are rendered on-screen self.texturedLabels = self.engine.theme.setlist.texturedLabels #render the art as a texture? self.itemsPerPage = self.engine.theme.setlist.itemsPerPage #number of items to show on screen self.followItemPos = (self.itemsPerPage+1)/2 self.showLockedSongs = self.engine.theme.setlist.showLockedSongs #whether or not to even show locked songs self.showSortTiers = self.engine.theme.setlist.showSortTiers #whether or not to show sorting tiers - career tiers take precedence. self.selectTiers = self.engine.theme.setlist.selectTiers #whether or not tiers should be selectable as a quick setlist. if self.engine.cmdPlay == 2: self.songName = Config.get("setlist", "selected_song") self.libraryName = Config.get("setlist", "selected_library") self.cmdPlay = self.checkCmdPlay() if self.cmdPlay: Dialogs.hideLoadingSplashScreen(self.engine, self.splash) return elif len(self.engine.world.songQueue) > 0: Dialogs.hideLoadingSplashScreen(self.engine, self.splash) return #variables for setlist management (Not that this is necessary here - just to see what exists.) self.songLoader = None #preview handling self.tiersPresent = False self.startingSelected = self.songName self.selectedIndex = 0 self.selectedItem = None self.selectedOffset = 0.0 self.previewDelay = 1000 self.previewLoaded = False self.itemRenderAngles = [0.0] self.itemLabels = [None] self.xPos = 0 self.yPos = 0 self.pos = 0 self.infoPage = 0 self.menu_force_reload = False self.menu_text_color = (1, 1, 1) self.menu_selected_color = (.66, .66, 0) self.menu_text_pos = (.2, .31) self.menu = Menu(self.engine, [ConfigChoice(self.engine, self.engine.config, "game", "queue_format", autoApply = True), ConfigChoice(self.engine, self.engine.config, "game", "queue_order", autoApply = True), ConfigChoice(self.engine, self.engine.config, "game", "queue_parts", autoApply = True), ConfigChoice(self.engine, self.engine.config, "game", "queue_diff", autoApply = True), ActiveConfigChoice(self.engine, self.engine.config, "game", "sort_order", onChange = self.forceReload), ActiveConfigChoice(self.engine, self.engine.config, "game", "sort_direction", onChange = self.forceReload), ActiveConfigChoice(self.engine, self.engine.config, "game", "songlist_instrument", onChange = self.forceReload), ActiveConfigChoice(self.engine, self.engine.config, "game", "songlist_difficulty", onChange = self.forceReload), ], name = "setlist", fadeScreen = False, onClose = self.resetQueueVars, font = self.engine.data.pauseFont, \ pos = self.menu_text_pos, textColor = self.menu_text_color, selectedColor = self.menu_selected_color) #now, load the first library self.loadLibrary() #load the images self.loadImages()
def startGame(self, fromQueue = False): #note this is not refined. if len(self.engine.world.songQueue) == 0: return showDialog = True if not fromQueue and self.queueFormat == 1 and len(self.engine.world.songQueue) > 1: self.engine.world.songQueue.setFullQueue() self.engine.world.playingQueue = True if self.queueOrder == 1: self.songName, self.libraryName = self.engine.world.songQueue.getRandomSong() else: self.songName, self.libraryName = self.engine.world.songQueue.getSong() 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) choose = [[] for i in self.players] for i, player in enumerate(self.players): j = self.engine.world.songQueue.getParts()[i] if player.controlType == 2 or player.controlType == 3: choose[i] = drums elif player.controlType == 5: choose[i] = vocals else: choose[i] = guitars if self.queued: showDialog = False for i, player in enumerate(self.players): if Song.parts[j] in choose[i]: p = Song.parts[j] elif self.queueParts == 0: if j == 0: for k in [3, 1, 2]: if Song.parts[k] in choose[i]: p = Song.parts[k] break elif j == 1: for k in [2, 0, 3]: if Song.parts[k] in choose[i]: p = Song.parts[k] break elif j == 2: for k in [1, 0, 3]: if Song.parts[k] in choose[i]: p = Song.parts[k] break elif j == 3: for k in [0, 1, 2]: if Song.parts[k] in choose[i]: p = Song.parts[k] break j = self.engine.world.songQueue.getDiffs()[i] if Song.difficulties[j] in info.partDifficulties[p.id]: d = Song.difficulties[j] elif self.queueDiffs == 0: if j == 0: for k in range(1,4): if Song.difficulties[k] in info.partDifficulties[p.id]: d = Song.difficulties[k] elif j == 1: for k in range(2,5): if Song.difficulties[k%4] in info.partDifficulties[p.id]: d = Song.difficulties[k%4] elif j == 2: if Song.difficulties[3] in info.partDifficulties[p.id]: d = Song.difficulties[3] else: for k in range(1, -1, -1): if Song.difficulties[k] in info.partDifficulties[p.id]: d = Song.difficulties[k] else: for k in range(2, -1, -1): if Song.difficulties[k] in info.partDifficulties[p.id]: d = Song.difficulties[k] elif self.queueDiffs == 1: if j == 3: for k in range(2,-1, -1): if Song.difficulties[k] in info.partDifficulties[p.id]: d = Song.difficulties[k] elif j == 2: for k in range(1,-2,-1): if Song.difficulties[k%4] in info.partDifficulties[p.id]: d = Song.difficulties[k%4] elif j == 1: if Song.difficulties[0] in info.partDifficulties[p.id]: d = Song.difficulties[0] else: for k in range(2,4): if Song.difficulties[k] in info.partDifficulties[p.id]: d = Song.difficulties[k] else: for k in range(1,4): if Song.difficulties[k] in info.partDifficulties[p.id]: d = Song.difficulties[k] if p and d: player.part = p player.difficulty = d else: showDialog = True if showDialog: ready = False while not ready: ready = Dialogs.choosePartDiffs(self.engine, choose, info, self.players) if not ready and not self.queued and not self.engine.cmdPlay: return False if self.engine.cmdPlay > 0: self.engine.cmdPlay = 3 self.freeResources() self.engine.world.createScene("GuitarScene", libraryName = self.libraryName, songName = self.songName) self.gameStarted = True
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 loadSongs(self, libraries): Log.debug("Loading songs in %s" % self.library) self.engine.resource.load(self, "songs", lambda: Song.getAvailableSongsAndTitles(self.engine, self.library, progressCallback=self.progressCallback), onLoad = self.prepareSetlist, synch = True)