예제 #1
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)
예제 #2
0
 def quit(self):
     # evilynux - self.audio.close() crashes when we attempt to restart
     if not self.restartRequested:
         self.audio.close()
     Player.savePlayers()
     for taskData in list(self.task.tasks):
         self.task.removeTask(taskData['task'])
     self.running = False
예제 #3
0
 def quit(self):
     # evilynux - self.audio.close() crashes when we attempt to restart
     if not self.restartRequested:
         self.audio.close()
     Player.savePlayers()
     for taskData in list(self.task.tasks):
         self.task.removeTask(taskData['task'])
     self.running = False
예제 #4
0
 def quit(self):
     """ Quit the game (audio and video) """
     # self.audio.close() crashes when we attempt to restart
     if not self.restartRequested:
         self.audio.close()
     Player.savePlayers()
     for taskData in list(self.task.tasks):
         self.task.removeTask(taskData['task'])
     self.running = False
예제 #5
0
 def pluginControls(self):
     self.gameDrums = 0
     self.gameGuitars = 0
     self.gameMics = 0
     Player.pluginControls(self.activeGameControls)
     for i in self.activeGameControls:
         if self.controls.type[i] == -1:
             self.gameBots += 1
         elif self.controls.type[i] in Player.DRUMTYPES:
             self.gameDrums += 1
         elif self.controls.type[i] in Player.MICTYPES:
             self.gameMics += 1
         elif self.controls.type[i] in Player.GUITARTYPES:
             self.gameGuitars += 1
예제 #6
0
파일: Input.py 프로젝트: fofix/fofix
 def pluginControls(self):
     self.gameDrums = 0
     self.gameGuitars = 0
     self.gameMics = 0
     Player.pluginControls(self.activeGameControls)
     for i in self.activeGameControls:
         if self.controls.type[i] == -1:
             self.gameBots += 1
         elif self.controls.type[i] in Player.DRUMTYPES:
             self.gameDrums += 1
         elif self.controls.type[i] in Player.MICTYPES:
             self.gameMics += 1
         elif self.controls.type[i] in Player.GUITARTYPES:
             self.gameGuitars += 1
예제 #7
0
파일: Lobby.py 프로젝트: ycaihua/fofix
 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!"))
예제 #8
0
 def createPlayer(self, name):
     playerNum = len(self.players)
     player = Player.Player(name, playerNum)
     player.controller = self.engine.input.activeGameControls[playerNum]
     player.controlType = self.engine.input.controls.type[player.controller]
     player.keyList = Player.playerkeys[playerNum]
     player.configController()
     player.practiceMode = (self.gameMode == 1)
     self.players.append(player)
     self.songQueue.parts.append(player.part.id)
     self.songQueue.diffs.append(player.getDifficultyInt())
     if self.scene:
         self.scene.addPlayer(player)
예제 #9
0
파일: Lobby.py 프로젝트: ME7ROPOLIS/fofix
 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!"))
예제 #10
0
 def setNewKeyMapping(self, section, option, key, control):
     return Player.setNewKeyMapping(section, option, key, control)
예제 #11
0
파일: Input.py 프로젝트: fofix/fofix
 def setNewKeyMapping(self, section, option, key, control):
     return Player.setNewKeyMapping(section, option, key, control)
예제 #12
0
    #myfingershurt: default theme must be an existing one!
    Config.define(
        "coffee",
        "themename",
        str,
        defaultTheme,
        text=_("Theme"),
        options=dict([(str(themes[n]), themes[n]) for n in range(0, i)]),
        tipText=
        _("Sets the overall graphical feel of the game. You can find and download many more at https://fretsonfire.org"
          ))


_init_allthemes()

Player.loadControls()


class FullScreenSwitcher(KeyListener):
    """
    A keyboard listener that looks for special built-in key combinations,
    such as the fullscreen toggle (Alt-Enter).
    """
    def __init__(self, engine):
        self.engine = engine
        self.altStatus = False

    def keyPressed(self, key, unicode):
        if key == pygame.K_LALT:
            self.altStatus = True
        elif key == pygame.K_RETURN and self.altStatus:
예제 #13
0
    if os.name == 'posix':
        Log.error("No valid theme found!\n" +
                  "Make sure theme files are properly cased " +
                  "e.g. notes.png works, Notes.png doesn't\n")
    else:
        Log.error("No valid theme found!")
    sys.exit(1)

if defaultTheme is None:
    defaultTheme = themes[0]    #myfingershurt

#myfingershurt: default theme must be an existing one!
Config.define("coffee", "themename",           str,   defaultTheme,      text = _("Theme"),                options = dict([(str(themes[n]),themes[n]) for n in range(0, i)]), tipText = _("Sets the overall graphical feel of the game. You can find and download many more at fretsonfire.net"))

##Alarian: End Get unlimited themes by foldername
Player.loadControls()



class FullScreenSwitcher(KeyListener):
    """
    A keyboard listener that looks for special built-in key combinations,
    such as the fullscreen toggle (Alt-Enter).
    """
    def __init__(self, engine):
        self.engine = engine
        self.altStatus = False

    def keyPressed(self, key, unicode):
        if key == pygame.K_LALT:
            self.altStatus = True
예제 #14
0
파일: Data.py 프로젝트: mdsitton/fofix
    def __init__(self, resource, svg):

        self.logClassInits = Config.get("game", "log_class_inits")
        if self.logClassInits == 1:
            Log.debug("Data class init (Data.py)...")
        self.logLoadings = Config.get("game", "log_loadings")

        self.logImageNotFound = Config.get("log", "log_image_not_found")

        self.resource = resource
        self.svg      = svg

        self.sfxVolume    = Config.get("audio", "SFX_volume")
        self.crowdVolume  = Config.get("audio", "crowd_volume")

        #Get theme
        themename = Config.get("coffee", "themename")
        self.themeLabel = themename
        self.themeCoOp  = False

        self.players = None
        self.players = Player.loadPlayers()

        #myfingershurt: check for existence of theme path
        themepath = os.path.join(Version.dataPath(), "themes")
        self.themepath = themepath
        self.path = Version.dataPath()

        if not self.checkImgDrawing(os.path.join("themes",themename,"notes","notes.png")):
            #myfingershurt: here need to ensure an existing theme is selected
            themes = []
            defaultTheme = None           #myfingershurt
            allthemes = os.listdir(themepath)
            for name in allthemes:
                if self.checkImgDrawing(os.path.join("themes",name,"notes","notes.png")):
                    themes.append(name)
                    if name == "MegaLight V4":         #myfingershurt
                        defaultTheme = name     #myfingershurt
            if defaultTheme != "MegaLight V4":     #myfingershurt
                defaultTheme = themes[0]    #myfingershurt
            #not a valid theme if notes.png isn't there!  Force default theme:
            Config.set("coffee", "themename",defaultTheme)
            #re-init Data with new default
            themename = defaultTheme
            self.themeLabel = themename


        if not os.path.exists(os.path.join(Version.dataPath(), "themes", themename, "vocals")):
            self.vocalPath = "vocals"
        else:
            self.vocalPath = os.path.join("themes",themename,"vocals")

        self.theme = 2
        self.themeCoOp = True

        self.fontScreenBottom = 0.75      #from our current viewport's constant 3:4 aspect ratio (which is always stretched to fill the video resolution)

        self.loadPartImages()
        #myfingershurt: multi-OS compatibility file access fixes using os.path.join()
        # load font customization images

        #Worldrave - Use new defined Star3 and star4. Using star1 and star2 as a fallback.

        #MFH - no more custom glyphs, these are wasting memory.
        #MFH - but we do need these star1-4 images anyway.  Leaving them loaded here in the Data object.
        self.loadImgDrawing(self, "star1",   os.path.join("themes",themename,"star1.png"), textureSize = (128, 128))
        self.loadImgDrawing(self, "star2",   os.path.join("themes",themename,"star2.png"), textureSize = (128, 128))

        #MFH - let's not rely on errors here if we don't have to...
        if not self.loadImgDrawing(self, "star3",   os.path.join("themes",themename,"star3.png"), textureSize = (128, 128)):
            self.star3 = self.star1
        if not self.loadImgDrawing(self, "star4",   os.path.join("themes",themename,"star4.png"), textureSize = (128, 128)):
            self.star4 = self.star2


        if self.loadImgDrawing(self, "starPerfect",   os.path.join("themes",themename,"starperfect.png"), textureSize = (128, 128)):
            self.perfectStars = True
            self.maskStars = False
        else:
            self.starPerfect = self.star2
            self.fcStars   = False
            self.starFC     = self.star2
            self.maskStars = True
            self.perfectStars = False

        if self.perfectStars:
            if self.loadImgDrawing(self, "starFC",   os.path.join("themes",themename,"starfc.png"), textureSize = (128, 128)):
                self.fcStars   = True
            else:
                self.starFC = self.starPerfect
                self.fcStars = False

        # load misc images
        self.loadImgDrawing(self, "loadingImage", os.path.join("themes",themename,"loadingbg.png"), textureSize = (256,256))
        self.loadImgDrawing(self, "optionsBG", os.path.join("themes",themename,"menu","optionsbg.png"))
        if self.loadImgDrawing(self, "submenuSelect", os.path.join("themes",themename,"submenuselect.png")):
            subSelectImgW = self.submenuSelect.width1()
            self.submenuSelectFound = True
            self.subSelectWFactor = 640.000/subSelectImgW
            self.subSelectImgH = self.submenuSelect.height1()
        else:
            self.submenuSelectFound = False
            self.loadImgDrawing(self, "submenuSelect", os.path.join("themes",themename,"menu","selected.png"))
            self.subSelectWFactor = 0
        # load all the data in parallel
        # asciiOnly = not bool(Language.language) or Language.language == "Custom"
        # reversed  = _("__lefttoright__") == "__righttoleft__" and True or False
        asciiOnly = True
        reversed  = False
        scale     = 1
        # evilynux - Load bigger fonts so they're nicer when scaled, scaling readjusted
        fontSize  = [44, 132, 34, 32, 30]
        w, h = [int(s) for s in Config.get("video", "resolution").split("x")]
        aspectRatio = float(w)/float(h)

        self.fontList = [
          ["font1","font","default.ttf",fontSize[4]],
          ["font2","bigFont","title.ttf",fontSize[1]],
          ["font3","pauseFont","pause.ttf",fontSize[2]],
          ["font4","scoreFont","score.ttf",fontSize[3]],
          ["font5","streakFont","streak.ttf",fontSize[3]],
          ["font6","loadingFont","loading.ttf",fontSize[3]],
          ["font7","songFont","song.ttf",fontSize[4]],
          ["font8","songListFont","songlist.ttf",fontSize[3]],
          ["font9","shadowFont","songlist.ttf",fontSize[3]],
          ["font10","streakFont2","streakphrase.ttf",fontSize[2]]
        ]
        for f in self.fontList:
            if self.fileExists(os.path.join("themes",themename,"fonts",f[2])):
                fn = resource.fileName(os.path.join("themes",themename,"fonts",f[2]))
                f[0] = lambda: Font(fn, f[3], scale = scale*.5, reversed = reversed, systemFont = not asciiOnly, outline = False, aspectRatio = aspectRatio)
                resource.load(self,f[1],f[0], synch = True)
            elif self.fileExists(os.path.join("themes",themename,"fonts","default.ttf")):
                Log.debug("Theme font not found: " + f[2])
                fn = resource.fileName(os.path.join("themes",themename,"fonts","default.ttf"))
                f[0] = lambda: Font(fn, f[3], scale = scale*.5, reversed = reversed, systemFont = not asciiOnly, outline = False, aspectRatio = aspectRatio)
                resource.load(self,f[1],f[0], synch = True)
            else:
                Log.debug("Default theme font not found: %s - using built-in default" % str(f[2]))
                fn = resource.fileName(os.path.join("fonts","default.ttf"))
                f[0] = lambda: Font(fn, f[3], scale = scale*.5, reversed = reversed, systemFont = not asciiOnly, outline = False, aspectRatio = aspectRatio)
                resource.load(self,f[1],f[0], synch = True)


        self.fontDict = {"font": self.font, "bigFont": self.bigFont, "pauseFont": self.pauseFont, "scoreFont": self.scoreFont, \
                         "streakFont": self.streakFont, "songFont": self.songFont, "streakFont2": self.streakFont2, \
                         "songListFont": self.songListFont, "shadowFont": self.shadowFont, "loadingFont": self.loadingFont}

        assert self.fontDict['font'] == self.font

        # load sounds asynchronously
        resource.load(self, "screwUpsounds", self.loadScrewUpsounds)
        resource.load(self, "screwUpsoundsBass", self.loadScrewUpsoundsBass)
        resource.load(self, "screwUpsoundsDrums", self.loadScrewUpsoundsDrums)
        resource.load(self, "acceptSounds", self.loadAcceptSounds)
        resource.load(self, "cancelSounds", self.loadBackSounds)

        # loadSoundEffect asynchronously
        self.syncSounds = [
          ["bassDrumSound","bassdrum.ogg"],
          ["battleUsedSound","battleused.ogg"],
          ["CDrumSound","crash.ogg"],
          ["clapSound","clapsound.ogg"],
          ["coOpFailSound","coopfail.ogg"],
          #["crowdSound","crowdcheers.ogg"],
          ["failSound","failsound.ogg"],
          ["rescueSound","rescue.ogg"],
          ["rockSound","rocksound.ogg"],
          ["selectSound1","select1.ogg"],
          ["selectSound2","select2.ogg"],
          ["selectSound3","select3.ogg"],
          ["starActivateSound","staractivate.ogg"],
          ["starDeActivateSound","stardeactivate.ogg"],
          ["starDingSound","starding.ogg"],
          ["starLostSound","starlost.ogg"],
          ["starReadySound","starpowerready.ogg"],
          ["starSound","starpower.ogg"],
          ["startSound","start.ogg"],
          ["T1DrumSound","tom01.ogg"],
          ["T2DrumSound","tom02.ogg"],
          ["T3DrumSound","tom03.ogg"]
        ]
        for self.sounds in self.syncSounds:
            if self.fileExists(os.path.join("themes",themename,"sounds",self.sounds[1])):
                self.loadSoundEffect(self, self.sounds[0], os.path.join("themes",themename,"sounds",self.sounds[1]))
            elif self.fileExists(os.path.join("sounds", self.sounds[1])):
                Log.debug("Theme sound not found: " + self.sounds[1])
                self.loadSoundEffect(self, self.sounds[0], os.path.join("sounds",self.sounds[1]))
            else:
                Log.warn("File " + self.sounds[1] + " not found using default instead.")
                self.loadSoundEffect(self, self.sounds[0], os.path.join("sounds","default.ogg"))

        #TODO: Simplify crowdSound stuff so it can join the rest of us.
        #MFH - fallback on sounds/crowdcheers.ogg, and then starpower.ogg. Note if the fallback crowdcheers was used or not.
        if self.fileExists(os.path.join("themes",themename,"sounds","crowdcheers.ogg")):
            self.loadSoundEffect(self, "crowdSound", os.path.join("themes",themename,"sounds","crowdcheers.ogg"), crowd = True)
            self.cheerSoundFound = 2
        elif self.fileExists(os.path.join("sounds","crowdcheers.ogg")):
            self.loadSoundEffect(self, "crowdSound", os.path.join("sounds","crowdcheers.ogg"), crowd = True)
            self.cheerSoundFound = 1
            Log.warn(themename + "/sounds/crowdcheers.ogg not found -- using data/sounds/crowdcheers.ogg instead.")
        else:
            self.cheerSoundFound = 0
            Log.warn("crowdcheers.ogg not found -- no crowd cheering.")