Ejemplo n.º 1
0
def add_sound_group(args):
    if project.get_project_dir(os.getcwd()):
        proj_json = json.load(open(os.path.join(project.get_project_dir(os.getcwd()), "assets/minecraft/sounds.json")))
        if args.group not in proj_json:
            new_group = {}
            category = args.category
            if args.category == "":
                category = input_.options(Fore.LIGHTBLUE_EX + "Please select a category:", [
                    "master", "ambient", "weather", "player", "neutral", "hostile", "block", "record", "music"
                ])
            new_group["category"] = category
            new_group["sounds"] = []
            proj_json[args.group] = new_group
            if args.remove:
                del proj_json[args.group]
            json.dump(proj_json,
                      open(os.path.join(project.get_project_dir(os.getcwd()), "assets/minecraft/sounds.json"), "w"),
                      indent=4)
            if not args.remove:
                print Fore.GREEN + "Added sound group " + Fore.WHITE + args.group + Fore.GREEN + " successfully!"
            else:
                print Fore.GREEN + "Removed sound group " + Fore.WHITE + args.group + Fore.GREEN + " successfully!"
        else:
            if args.remove:
                del proj_json[args.group]
                json.dump(proj_json,
                          open(os.path.join(project.get_project_dir(os.getcwd()), "assets/minecraft/sounds.json"), "w"),
                          indent=4)
                print Fore.GREEN + "Removed sound group " + Fore.WHITE + args.group + Fore.GREEN + " successfully!"
                return
            print Fore.RED + "Sound group already exists!" + Fore.CYAN + \
                  " (maybe you wanted mcrsrctool addsoundtogroup?)"
    else:
        print Fore.RED + "Could not find project"
Ejemplo n.º 2
0
def refresh_sound(file_):
    choice = input_.options_retnum(
            Fore.LIGHTBLUE_EX + "What do you want to do with " + Fore.WHITE + " " + file_ + "? " + Fore.CYAN, [
                "Create a new sound group and add the file to it",
                "Add the file to an existing sound group",
                "Ignore it completely (you will not be able to use it in-game)"
            ])
    if choice == 0:
        group_name = raw_input(Fore.LIGHTBLUE_EX + "What shall I call the new sound group? " + Fore.CYAN)
        add_sound_group(argparse.Namespace(category="", group=group_name, remove=False))
    if choice == 1:
        group_name = raw_input(Fore.LIGHTBLUE_EX + "To which group should I add this sound? " + Fore.CYAN)
    if choice in (0, 1):
        print Fore.LIGHTBLUE_EX + "Leave any option blank for default"
        weight = input_.defaulted_in(Fore.LIGHTBLUE_EX + "Sound weight? " + Fore.CYAN, 1.0, float)
        pitch = input_.defaulted_in(Fore.LIGHTBLUE_EX + "Sound pitch? " + Fore.CYAN, 1.0, float)
        volume = input_.defaulted_in(Fore.LIGHTBLUE_EX + "Sound volume? " + Fore.CYAN, 1.0, float)
        type = input_.options(Fore.LIGHTBLUE_EX + "Sound type? (use 0 for default)", ["sound", "event"])
        stream = input_.get_yn(Fore.LIGHTBLUE_EX + "Stream sound (default is N) ")
        add_to_sound_group(
                argparse.Namespace(group=group_name, weight=weight, pitch=pitch, volume=volume, type=type,
                                   stream=stream,
                                   sound=file_, remove=False))
    elif choice == 2:
        return False
    return True
Ejemplo n.º 3
0
def add_sound_group(args):
    if project.get_project_dir(os.getcwd()):
        proj_json = json.load(
            open(
                os.path.join(project.get_project_dir(os.getcwd()),
                             "assets/minecraft/sounds.json")))
        if args.group not in proj_json:
            new_group = {}
            category = args.category
            if args.category == "":
                category = input_.options(
                    Fore.LIGHTBLUE_EX + "Please select a category:", [
                        "master", "ambient", "weather", "player", "neutral",
                        "hostile", "block", "record", "music"
                    ])
            new_group["category"] = category
            new_group["sounds"] = []
            proj_json[args.group] = new_group
            if args.remove:
                del proj_json[args.group]
            json.dump(proj_json,
                      open(
                          os.path.join(project.get_project_dir(os.getcwd()),
                                       "assets/minecraft/sounds.json"), "w"),
                      indent=4)
            if not args.remove:
                print Fore.GREEN + "Added sound group " + Fore.WHITE + args.group + Fore.GREEN + " successfully!"
            else:
                print Fore.GREEN + "Removed sound group " + Fore.WHITE + args.group + Fore.GREEN + " successfully!"
        else:
            if args.remove:
                del proj_json[args.group]
                json.dump(proj_json,
                          open(
                              os.path.join(
                                  project.get_project_dir(os.getcwd()),
                                  "assets/minecraft/sounds.json"), "w"),
                          indent=4)
                print Fore.GREEN + "Removed sound group " + Fore.WHITE + args.group + Fore.GREEN + " successfully!"
                return
            print Fore.RED + "Sound group already exists!" + Fore.CYAN + \
                  " (maybe you wanted mcrsrctool addsoundtogroup?)"
    else:
        print Fore.RED + "Could not find project"
Ejemplo n.º 4
0
def refresh_sound(file_):
    choice = input_.options_retnum(
        Fore.LIGHTBLUE_EX + "What do you want to do with " + Fore.WHITE + " " +
        file_ + "? " + Fore.CYAN, [
            "Create a new sound group and add the file to it",
            "Add the file to an existing sound group",
            "Ignore it completely (you will not be able to use it in-game)"
        ])
    if choice == 0:
        group_name = raw_input(Fore.LIGHTBLUE_EX +
                               "What shall I call the new sound group? " +
                               Fore.CYAN)
        add_sound_group(
            argparse.Namespace(category="", group=group_name, remove=False))
    if choice == 1:
        group_name = raw_input(Fore.LIGHTBLUE_EX +
                               "To which group should I add this sound? " +
                               Fore.CYAN)
    if choice in (0, 1):
        print Fore.LIGHTBLUE_EX + "Leave any option blank for default"
        weight = input_.defaulted_in(
            Fore.LIGHTBLUE_EX + "Sound weight? " + Fore.CYAN, 1.0, float)
        pitch = input_.defaulted_in(
            Fore.LIGHTBLUE_EX + "Sound pitch? " + Fore.CYAN, 1.0, float)
        volume = input_.defaulted_in(
            Fore.LIGHTBLUE_EX + "Sound volume? " + Fore.CYAN, 1.0, float)
        type = input_.options(
            Fore.LIGHTBLUE_EX + "Sound type? (use 0 for default)",
            ["sound", "event"])
        stream = input_.get_yn(Fore.LIGHTBLUE_EX +
                               "Stream sound (default is N) ")
        add_to_sound_group(
            argparse.Namespace(group=group_name,
                               weight=weight,
                               pitch=pitch,
                               volume=volume,
                               type=type,
                               stream=stream,
                               sound=file_,
                               remove=False))
    elif choice == 2:
        return False
    return True