Ejemplo n.º 1
0
def loadPlayers():
    global playername, playerpref, playerstat
    playername = []
    playerpref = []
    playerstat = []
    allplayers = VFS.listdir(playerpath)
    for name in allplayers:
        if name == "default.ini":
            continue
        if name.lower().endswith(".ini") and len(name) > 4:
            playername.append(name[0:len(name)-4])
            pref = _playerDB.execute('SELECT * FROM `players` WHERE `name` = ?', [playername[-1]]).fetchone()
            try:
                if len(pref) == 14:
                    playerpref.append((pref[1], pref[2], pref[3], pref[4], pref[5], pref[6], pref[7], pref[8], pref[9], pref[10]))
            except TypeError:
                try:
                    c = Config.load(VFS.resolveRead(_makePlayerIniName(name[:-4])), type = 2)
                    lefty  = c.get("player","leftymode")
                    drumf  = c.get("player","drumflip")
                    autok  = c.get("player","auto_kick")
                    assist = c.get("player","assist_mode")
                    twoch  = c.get("player","two_chord_max")
                    neck   = c.get("player","neck")
                    neckt  = c.get("player","necktype")
                    part   = c.get("player","part")
                    diff   = c.get("player","difficulty")
                    upname = c.get("player","name")
                    control= c.get("player","controller")
                    del c
                    _playerDB.execute('INSERT INTO `players` VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 1)', [playername[-1], lefty, drumf, autok, assist, twoch, neckt, neck, part, diff, upname, control])
                    playerpref.append((lefty, drumf, autok, assist, twoch, neckt, neck, part, diff, upname))
                except IOError:
                    _playerDB.execute('INSERT INTO `players` VALUES (?, 0, 0, 0, 0, 0, 0, ``, 0, 2, ``, 0, 0, 1)', [playername[-1]])
                    playerpref.append((0, 0, 0, 0, 0, 0, '', 0, 2, '', 0))
            _playerDB.execute('UPDATE `players` SET `loaded` = 1 WHERE `name` = ?', [playername[-1]])
            _playerDB.commit()
    return 1
Ejemplo n.º 2
0
    def __init__(self):

        self.logClassInits = Config.get("game", "log_class_inits")
        if self.logClassInits == 1:
            Log.debug("Controls class init (Player.py)...")
        self.controls = []
        self.controls.append(Config.get("game", "control0"))
        self.controls.append(Config.get("game", "control1"))
        self.controls.append(Config.get("game", "control2"))
        self.controls.append(Config.get("game", "control3"))
        self.config = []
        self.controlList = []
        self.maxplayers = 0
        self.guitars    = 0
        self.drums      = 0
        self.mics       = 0
        self.overlap    = []

        self.p2Nav = Config.get("game", "p2_menu_nav")
        self.drumNav = Config.get("game", "drum_navigation")

        self.keyCheckerMode = Config.get("game","key_checker_mode")

        if VFS.isfile(_makeControllerIniName(self.controls[0])):
            self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName(self.controls[0])), type = 1))
            if VFS.isfile(_makeControllerIniName(self.controls[1])) and self.controls[1] != "None":
                self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName(self.controls[1])), type = 1))
            else:
                self.config.append(None)
                Config.set("game", "control1", None)
                self.controls[1] = "None"
            if VFS.isfile(_makeControllerIniName(self.controls[2])) and self.controls[2] != "None":
                self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName(self.controls[2])), type = 1))
            else:
                self.config.append(None)
                Config.set("game", "control2", None)
                self.controls[2] = "None"
            if VFS.isfile(_makeControllerIniName(self.controls[3])) and self.controls[3] != "None":
                self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName(self.controls[3])), type = 1))
            else:
                self.config.append(None)
                Config.set("game", "control3", None)
                self.controls[3] = "None"
        else:
            confM = None
            if Microphone.supported:
                confM = Config.load(VFS.resolveRead(_makeControllerIniName("defaultm")), type = 1)
            self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName("defaultg")), type = 1))
            self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName("defaultd")), type = 1))
            self.config.append(confM)
            self.config.append(None)
            Config.set("game", "control0", "defaultg")
            Config.set("game", "control1", "defaultd")
            self.controls = ["defaultg", "defaultd"]
            if confM is not None:
                Config.set("game", "control2", "defaultm")
                self.controls.append("defaultm")
            else:
                Config.set("game", "control2", None)
                self.controls.append("None")
            Config.set("game", "control3", None)
            self.controls.append("None")

        self.type       = []
        self.analogKill = []
        self.analogSP   = []
        self.analogSPThresh = []
        self.analogSPSense  = []
        self.analogDrum = [] #FIXME: Analog Drum
        self.analogSlide = []
        self.analogFX   = [] #FIXME: Analog FX
        self.twoChord   = []
        self.micDevice  = []  #stump
        self.micTapSensitivity = []
        self.micPassthroughVolume = []

        self.flags = 0

        for i in self.config:
            if i:
                type = i.get("controller", "type")
                if type == 5:
                    self.mics += 1
                elif type > 1:
                    self.guitars += 1
                else:
                    self.drums += 1
                self.type.append(type)
                self.analogKill.append(i.get("controller", "analog_kill"))
                self.analogSP.append(i.get("controller", "analog_sp"))
                self.analogSPThresh.append(i.get("controller", "analog_sp_threshold"))
                self.analogSPSense.append(i.get("controller", "analog_sp_sensitivity"))
                self.analogDrum.append(i.get("controller", "analog_drum")) #FIXME: Analog Drum
                self.analogSlide.append(i.get("controller", "analog_slide"))
                self.analogFX.append(i.get("controller", "analog_fx")) #FIXME: Analog FX
                self.micDevice.append(i.get("controller", "mic_device"))  #stump
                self.micTapSensitivity.append(i.get("controller", "mic_tap_sensitivity"))
                self.micPassthroughVolume.append(i.get("controller", "mic_passthrough_volume"))
                self.twoChord.append(i.get("controller", "two_chord_max"))
                self.controlList.append(i.get("controller", "name"))
            else:
                self.type.append(None)
                self.analogKill.append(None)
                self.analogSP.append(None)
                self.analogFX.append(None) #FIXME: Analog FX
                self.twoChord.append(None)

        def keycode(name, config):
            if not config:
                return "None"
            k = config.get("controller", name)
            if k == "None":
                return "None"
            try:
                return int(k)
            except:
                return getattr(pygame, k)

        self.controlMapping = {}
        global menuUp, menuDown, menuNext, menuPrev, menuYes, menuNo
        global drum1s, drum2s, drum3s, drum4s, drum5s, bassdrums
        global key1s, key2s, key3s, key4s, key5s, keysolos, action1s, action2s, kills
        menuUp = []
        menuDown = []
        menuNext = []
        menuPrev = []
        menuYes = []
        menuNo = []
        drum1s = []
        drum2s = []
        drum3s = []
        drum4s = []
        drum5s = []
        bassdrums = []
        key1s = []
        key2s = []
        key3s = []
        key4s = []
        key5s = []
        keysolos = []
        action1s = []
        action2s = []
        kills = []

        for i, config in enumerate(self.config):
            if self.type[i] in DRUMTYPES: #drum set
                drum1s.extend([CONTROLS[i][DRUM1], CONTROLS[i][DRUM1A]])
                drum2s.extend([CONTROLS[i][DRUM2], CONTROLS[i][DRUM2A]])
                drum3s.extend([CONTROLS[i][DRUM3], CONTROLS[i][DRUM3A]])
                drum4s.extend([CONTROLS[i][DRUM4], CONTROLS[i][DRUM4A]])
                drum5s.extend([CONTROLS[i][DRUM5], CONTROLS[i][DRUM5A]])
                bassdrums.extend([CONTROLS[i][DRUMBASS], CONTROLS[i][DRUMBASSA]])
                if self.p2Nav == 1 or (self.p2Nav == 0 and i == 0):
                    if self.drumNav:
                        menuUp.extend([CONTROLS[i][DRUM2], CONTROLS[i][DRUM2A]])
                        if self.type[i] == 3:
                            menuDown.extend([CONTROLS[i][DRUM4], CONTROLS[i][DRUM4A]])
                        else:
                            menuDown.extend([CONTROLS[i][DRUM3], CONTROLS[i][DRUM3A]])
                        menuYes.extend([CONTROLS[i][DRUM5], CONTROLS[i][DRUM5A]])
                        menuNo.extend([CONTROLS[i][DRUM1], CONTROLS[i][DRUM1A]])
                    menuYes.append(CONTROLS[i][START])
                    menuNo.append(CONTROLS[i][CANCEL])
                    menuUp.append(CONTROLS[i][UP])
                    menuDown.append(CONTROLS[i][DOWN])
                    menuNext.append(CONTROLS[i][RIGHT])
                    menuPrev.append(CONTROLS[i][LEFT])
            elif self.type[i] in MICTYPES:  #stump: it's a mic
                if self.p2Nav == 1 or (self.p2Nav == 0 and i == 0):
                    menuUp.append(CONTROLS[i][UP])
                    menuDown.append(CONTROLS[i][DOWN])
                    menuNext.append(CONTROLS[i][RIGHT])
                    menuPrev.append(CONTROLS[i][LEFT])
                    menuYes.append(CONTROLS[i][START])
                    menuNo.append(CONTROLS[i][CANCEL])
            elif self.type[i] in GUITARTYPES:
                if self.type[i] == 0:
                    key1s.extend([CONTROLS[i][KEY1], CONTROLS[i][KEY1A]])
                else:
                    key1s.extend([CONTROLS[i][KEY1]])
                key2s.extend([CONTROLS[i][KEY2], CONTROLS[i][KEY2A]])
                key3s.extend([CONTROLS[i][KEY3], CONTROLS[i][KEY3A]])
                key4s.extend([CONTROLS[i][KEY4], CONTROLS[i][KEY4A]])
                key5s.extend([CONTROLS[i][KEY5], CONTROLS[i][KEY5A]])
                keysolos.extend([CONTROLS[i][KEY1A], CONTROLS[i][KEY2A], CONTROLS[i][KEY3A], CONTROLS[i][KEY4A], CONTROLS[i][KEY5A]])
                action1s.extend([CONTROLS[i][ACTION1]])
                action2s.extend([CONTROLS[i][ACTION2]])
                kills.extend([CONTROLS[i][KILL]])
                if self.p2Nav == 1 or (self.p2Nav == 0 and i == 0):
                    menuUp.extend([CONTROLS[i][ACTION1], CONTROLS[i][UP]])
                    menuDown.extend([CONTROLS[i][ACTION2], CONTROLS[i][DOWN]])
                    menuNext.extend([CONTROLS[i][RIGHT], CONTROLS[i][KEY4], CONTROLS[i][KEY4A]])
                    menuPrev.extend([CONTROLS[i][LEFT], CONTROLS[i][KEY3], CONTROLS[i][KEY3A]])
                    menuYes.extend([CONTROLS[i][KEY1], CONTROLS[i][KEY1A], CONTROLS[i][START]])
                    menuNo.extend([CONTROLS[i][KEY2], CONTROLS[i][KEY2A], CONTROLS[i][CANCEL]])

            if self.type[i] == 3:
                controlMapping = { #akedrou - drums do not need special declarations!
                  keycode("key_left", config):          CONTROLS[i][LEFT],
                  keycode("key_right", config):         CONTROLS[i][RIGHT],
                  keycode("key_up", config):            CONTROLS[i][UP],
                  keycode("key_down", config):          CONTROLS[i][DOWN],
                  keycode("key_star", config):          CONTROLS[i][STAR],
                  keycode("key_cancel", config):        CONTROLS[i][CANCEL],
                  keycode("key_1a", config):            CONTROLS[i][DRUM5A], #order is important. This minimizes key conflicts.
                  keycode("key_2a", config):            CONTROLS[i][DRUM1A],
                  keycode("key_3a", config):            CONTROLS[i][DRUM2A],
                  keycode("key_4a", config):            CONTROLS[i][DRUM3A],
                  keycode("key_5a", config):            CONTROLS[i][DRUM4A],
                  keycode("key_action2", config):       CONTROLS[i][DRUMBASSA],
                  keycode("key_1", config):             CONTROLS[i][DRUM5],
                  keycode("key_2", config):             CONTROLS[i][DRUM1],
                  keycode("key_3", config):             CONTROLS[i][DRUM2],
                  keycode("key_4", config):             CONTROLS[i][DRUM3],
                  keycode("key_5", config):             CONTROLS[i][DRUM4],
                  keycode("key_action1", config):       CONTROLS[i][DRUMBASS],
                  keycode("key_start", config):         CONTROLS[i][START],
                }
            elif self.type[i] == 2:
                controlMapping = { #akedrou - drums do not need special declarations!
                  keycode("key_left", config):          CONTROLS[i][LEFT],
                  keycode("key_right", config):         CONTROLS[i][RIGHT],
                  keycode("key_up", config):            CONTROLS[i][UP],
                  keycode("key_down", config):          CONTROLS[i][DOWN],
                  keycode("key_star", config):          CONTROLS[i][STAR],
                  keycode("key_cancel", config):        CONTROLS[i][CANCEL],
                  keycode("key_1a", config):            CONTROLS[i][DRUM5A], #order is important. This minimizes key conflicts.
                  keycode("key_2a", config):            CONTROLS[i][DRUM1A],
                  keycode("key_3a", config):            CONTROLS[i][DRUM2A],
                  keycode("key_4a", config):            CONTROLS[i][DRUM3A],
                  keycode("key_action2", config):       CONTROLS[i][DRUMBASSA],
                  keycode("key_1", config):             CONTROLS[i][DRUM5],
                  keycode("key_2", config):             CONTROLS[i][DRUM1],
                  keycode("key_3", config):             CONTROLS[i][DRUM2],
                  keycode("key_4", config):             CONTROLS[i][DRUM3],
                  keycode("key_action1", config):       CONTROLS[i][DRUMBASS],
                  keycode("key_start", config):         CONTROLS[i][START],
                }
            elif self.type[i] > -1:
                controlMapping = { #akedrou - drums do not need special declarations!
                  keycode("key_left", config):          CONTROLS[i][LEFT],
                  keycode("key_right", config):         CONTROLS[i][RIGHT],
                  keycode("key_up", config):            CONTROLS[i][UP],
                  keycode("key_down", config):          CONTROLS[i][DOWN],
                  keycode("key_cancel", config):        CONTROLS[i][CANCEL],
                  keycode("key_star", config):          CONTROLS[i][STAR],
                  keycode("key_kill", config):          CONTROLS[i][KILL],
                  keycode("key_1a", config):            CONTROLS[i][KEY1A], #order is important. This minimizes key conflicts.
                  keycode("key_2a", config):            CONTROLS[i][KEY2A],
                  keycode("key_3a", config):            CONTROLS[i][KEY3A],
                  keycode("key_4a", config):            CONTROLS[i][KEY4A],
                  keycode("key_5a", config):            CONTROLS[i][KEY5A],
                  keycode("key_1", config):             CONTROLS[i][KEY1],
                  keycode("key_2", config):             CONTROLS[i][KEY2],
                  keycode("key_3", config):             CONTROLS[i][KEY3],
                  keycode("key_4", config):             CONTROLS[i][KEY4],
                  keycode("key_5", config):             CONTROLS[i][KEY5],
                  keycode("key_action2", config):       CONTROLS[i][ACTION2],
                  keycode("key_action1", config):       CONTROLS[i][ACTION1],
                  keycode("key_start", config):         CONTROLS[i][START],
                }
            else:
                controlMapping = {}
            controlMapping = self.checkMapping(controlMapping, i)
            self.controlMapping.update(controlMapping)

        self.reverseControlMapping = dict((value, key) for key, value in self.controlMapping.iteritems() )

        # Multiple key support
        self.heldKeys = {}
Ejemplo n.º 3
0
Config.define("controller", "mic_passthrough_volume", float, 0.0, text = _("Passthrough Volume"), options=dict((n / 100.0, n) for n in range(101)), tipText = _("Sets how loud you hear yourself singing.")) #stump

Config.define("player", "name",          str,  "")
Config.define("player", "difficulty",    int,  Song.MED_DIF)
Config.define("player", "part",          int,  Song.GUITAR_PART)
Config.define("player", "neck",          str,  "")
Config.define("player", "necktype",      str,  2, text = _("Neck Type"),     options = {0: _("Default Neck"), 1: _("Theme Neck"), 2: _("Specific Neck")})
Config.define("player", "leftymode",     int,  0, text = _("Lefty Mode"),    options = {0: _("Off"), 1: _("On")})
Config.define("player", "drumflip",      int,  0, text = _("Drum Flip"),     options = {0: _("Off"), 1: _("On")})
Config.define("player", "two_chord_max", int,  0, text = _("Two-Chord Max"), options = {0: _("Off"), 1: _("On")})
Config.define("player", "assist_mode",   int,  0, text = _("Assist Mode"),   options = {0: _("Off"), 1: _("Easy Assist"), 2: _("Medium Assist")})
Config.define("player", "auto_kick",     int,  0, text = _("Auto Kick"),     options = {0: _("Off"), 1: _("On")})
Config.define("player", "controller",    int,  0)

# Overlay the users folder in /data with one in the user data folder.
VFS.mount(VFS.resolveRead('/data/users'), 'users')
VFS.mountWritable(VFS.resolveWrite('/userdata/users'), 'users')
controlpath = '/users/controllers'
playerpath = '/users/players'


def _makeControllerIniName(name):
    '''Turn a controller name into a virtual path to the appropriate ini.'''
    return '%s/%s.ini' % (controlpath, name)

def _makePlayerIniName(name):
    '''Turn a player name into a virtual path to the appropriate ini.'''
    return '%s/%s.ini' % (playerpath, name)

control0 = None
control1 = None