Пример #1
0
def loadControls():
    global controllerDict
    controllers = []
    allcontrollers = VFS.listdir(controlpath)
    default = ["defaultd.ini", "defaultg.ini", "defaultm.ini"]
    for name in allcontrollers:
        if name.lower().endswith(".ini") and len(name) > 4:
            if name in default:
                continue
            controllers.append(name[0:len(name)-4])

    i = len(controllers)
    controllerDict = dict([(str(controllers[n]),controllers[n]) for n in range(0, i)])
    controllerDict["defaultg"] = _("Default Guitar")
    controllerDict["defaultd"] = _("Default Drum")
    defMic = None
    if Microphone.supported:
        controllerDict["defaultm"] = _("Default Microphone")
        defMic = "defaultm"
    tsControl    = _("Controller %d")
    tsControlTip = _("Select the controller for slot %d")
    i = 1
    Config.define("game", "control0",           str,   "defaultg", text = tsControl % 1,                options = controllerDict, tipText = tsControlTip % 1)

    controllerDict[_("None")] = None

    Config.define("game", "control1",           str,   "defaultd", text = tsControl % 2,                options = controllerDict, tipText = tsControlTip % 2)
    Config.define("game", "control2",           str,   defMic,     text = tsControl % 3,                options = controllerDict, tipText = tsControlTip % 3)
    Config.define("game", "control3",           str,   None,       text = tsControl % 4,                options = controllerDict, tipText = tsControlTip % 4)
Пример #2
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