Example #1
0
 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
                     })
Example #2
0
 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})
Example #3
0
 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)
Example #4
0
    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))
Example #5
0
    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))
Example #6
0
File: World.py Project: vemel/fofix
 def resetWorld(self):
     if self.scene:
         self.engine.view.popLayer(self.scene)
         self.engine.removeTask(self.scene)
     for layer in self.engine.view.layers:
         if isinstance(layer, Dialogs.LoadingSplashScreen):
             Dialogs.hideLoadingSplashScreen(self.engine, layer)
     self.scene = None
     self.sceneName = ""
     self.players = []
     self.songQueue.reset()
     self.engine.mainMenu.restartGame()
Example #7
0
 def resetWorld(self):
     if self.scene:
         self.engine.view.popLayer(self.scene)
         self.engine.removeTask(self.scene)
     for layer in self.engine.view.layers:
         if isinstance(layer, Dialogs.LoadingSplashScreen):
             Dialogs.hideLoadingSplashScreen(self.engine, layer)
     self.scene = None
     self.sceneName = ""
     self.players = []
     self.songQueue.reset()
     self.engine.mainMenu.restartGame()
Example #8
0
File: World.py Project: vemel/fofix
 def finishGame(self):
     if self.done:
         return
     self.players = []
     if self.scene:
         self.engine.view.popLayer(self.scene)
         self.engine.removeTask(self.scene)
     for layer in self.engine.view.layers:
         if isinstance(layer, Dialogs.LoadingSplashScreen):
             Dialogs.hideLoadingSplashScreen(self.engine, layer)
     self.scene = None
     self.done = True
     self.engine.finishGame()
Example #9
0
 def finishGame(self):
     if self.done:
         return
     self.players = []
     if self.scene:
         self.engine.view.popLayer(self.scene)
         self.engine.removeTask(self.scene)
     for layer in self.engine.view.layers:
         if isinstance(layer, Dialogs.LoadingSplashScreen):
             Dialogs.hideLoadingSplashScreen(self.engine, layer)
     self.scene   = None
     self.done    = True
     self.engine.finishGame()
Example #10
0
    def loading(self):
        """Loading state loop."""
        done = self.doRun()
        self.clearScreen()

        if self.data.essentialResourcesLoaded():
            if not self.loadingScreenShown:
                self.loadingScreenShown = True
                Dialogs.showLoadingScreen(self, self.data.resourcesLoaded)
                if self.startupLayer:
                    self.view.pushLayer(self.startupLayer)
                self.mainloop = self.main
            self.view.render()
        self.video.flip()
        return done
Example #11
0
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
Example #12
0
 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)
Example #13
0
    def loadItemLabel(self, i, preload = False):
        # Load the item label if it isn't yet loaded
        item = self.items[i]
        if self.itemLabels[i] is None:
            if isinstance(item, Song.SongInfo):
                if self.labelType == 1: #CD covers
                    f = "label.png"
                else:
                    f = "album.png"
                if self.texturedLabels:
                    label = self.engine.resource.fileName(item.libraryNam, item.songName, f)
                    if os.path.exists(label):
                        self.itemLabels[i] = Texture(label)
                    else:
                        self.itemLabels[i] = False
                else:
                    self.itemLabels[i] = self.engine.loadImgDrawing(None, "label", os.path.join(item.libraryNam, item.songName, f))

            elif isinstance(item, Song.LibraryInfo):
                if self.texturedLabels:
                    label = self.engine.resource.fileName(item.libraryName, "label.png")
                    if os.path.exists(label):
                        self.itemLabels[i] = Texture(label)
                    else:
                        self.itemLabels[i] = False
                else:
                    self.itemLabels[i] = self.engine.loadImgDrawing(None, "label", os.path.join(item.libraryName, "label.png"))
            elif isinstance(item, Song.RandomSongInfo):
                self.itemLabels[i] = "Random"
            else:
                return
            if preload:
                if time.time() - self.loadStartTime > 3:
                    self.loadStartTime = time.time()
                    percent = (i*100)/len(self.items)
                    Dialogs.changeLoadingSplashScreenText(self.engine, self.splash, _("Loading Album Artwork...") + " %d%%" % percent)
Example #14
0
 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
Example #15
0
 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!"))
Example #16
0
    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()
Example #17
0
    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()
Example #18
0
 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
Example #19
0
 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
Example #20
0
    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
Example #21
0
 def progressCallback(self, percent):
     if time.time() - self.loadStartTime > 7:
         Dialogs.changeLoadingSplashScreenText(self.engine, self.splash, _("Browsing Collection...") + ' (%d%%)' % (percent*100))
Example #22
0
 def keyPressed(self, key, unicode):
     c = self.engine.input.controls.getMapping(key)
     if key == pygame.K_BACKSPACE and self.active:
         self.choices[self.selected] = self.choices[self.selected][:-1]
     elif unicode and ord(unicode) > 31 and self.active:
         if self.selected == 0 or self.selected == 7:
             if self.selected == 0 and (ord(unicode) in (34, 42, 47, 58, 60, 62, 63, 92, 124) or ord(unicode) > 126): #ascii only
                 self.engine.data.cancelSound.play()
                 return True
             if len(self.choices[self.selected]) > 24:
                 self.choices[self.selected] = self.choices[self.selected][:-1]
             self.choices[self.selected] += unicode
             return
     if c and not (c in Player.playerkeys[self.playerNum]):
         if key not in [pygame.K_RETURN, pygame.K_ESCAPE, pygame.K_DOWN, pygame.K_UP, pygame.K_LEFT, pygame.K_RIGHT]:
             return
     if c in Player.key1s or key == pygame.K_RETURN:
         self.scrolling = 0
         self.engine.data.acceptSound.play()
         if self.selected in (0, 7):
             if self.active:
                 self.active = False
             else:
                 self.blink  = 0
                 self.active = True
                 self.oldValue = self.choices[self.selected]
         elif self.selected == 6:
             if self.choices[6] == 2:
                 self.engine.view.pushLayer(Dialogs.NeckChooser(self.engine, player = self.player, owner = self))
                 self.keyActive = False
         elif self.selected == 8:
             self.avatar = Dialogs.chooseAvatar(self.engine)
         elif self.selected == 9:
             self.deleteCharacter()
         elif self.selected == 10:
             self.saveCharacter()
     elif c in Player.key2s + Player.cancels or key == pygame.K_ESCAPE:
         self.engine.data.cancelSound.play()
         if not self.active:
             if self.player:
                 self.updatedName  = self.oldName
             self.engine.view.popLayer(self)
             self.engine.input.removeKeyListener(self)
         else:
             self.choices[self.selected] = self.oldValue
             self.active = False
     elif (c in Player.action1s + Player.ups or key == pygame.K_UP):
         self.scrolling = 1
         self.delay = self.scrollDelay
         self.scrollUp()
     elif (c in Player.action2s + Player.downs or key == pygame.K_DOWN):
         self.scrolling = 2
         self.delay = self.scrollDelay
         self.scrollDown()
     elif (c in Player.key3s + Player.rights or key == pygame.K_RIGHT) and self.active:
         if len(self.choices[self.selected]) > 0:
             self.choices[self.selected] += self.choices[self.selected][len(self.choices[self.selected]) - 1]
             if c in Player.key3s:
                 self.engine.data.acceptSound.play()
     elif (c in Player.key4s + Player.lefts or key == pygame.K_LEFT) and self.active:
         self.choices[self.selected] = self.choices[self.selected][:-1]
         if c in Player.key4s:
             self.engine.data.cancelSound.play()
     elif c in Player.rights or key == pygame.K_RIGHT:
         if self.selected in (0, 7, 8, 9, 10):
             pass
         elif self.selected in [4, 6]:
             self.choices[self.selected]+=1
             if self.choices[self.selected] > 2:
                 self.choices[self.selected] = 0
         else:
             self.choices[self.selected] = 1 and (self.choices[self.selected] == 0) or 0
     elif c in Player.lefts or key == pygame.K_LEFT:
         if self.selected in (0, 7, 8, 9, 10):
             pass
         elif self.selected in [4, 6]:
             self.choices[self.selected]-=1
             if self.choices[self.selected] < 0:
                 self.choices[self.selected] = 2
         else:
             self.choices[self.selected] = 1 and (self.choices[self.selected] == 0) or 0
Example #23
0
 def restartGame(self):
     splash = Dialogs.showLoadingSplashScreen(self.engine, "")
     self.engine.view.pushLayer(Lobby(self.engine))
     Dialogs.hideLoadingSplashScreen(self.engine, splash)
Example #24
0
 def showMessages(self):
     msg = self.engine.startupMessages.pop()
     self.showStartupMessages = False
     Dialogs.showMessage(self.engine, msg)
Example #25
0
 def showMessages(self):
     msg = self.engine.startupMessages.pop()
     self.showStartupMessages = False
     Dialogs.showMessage(self.engine, msg)
Example #26
0
 def restartGame(self):
     splash = Dialogs.showLoadingSplashScreen(self.engine, "")
     self.engine.view.pushLayer(Lobby(self.engine))
     Dialogs.hideLoadingSplashScreen(self.engine, splash)