Ejemplo n.º 1
0
def assemble_sfx_option(f, internal_name: str, sound_hook: sfx.SoundHooks,
                        display_name: str):
    options = sfx.get_setting_choices(sound_hook).keys()
    sfx_to_id = {
        sound.replace('-', '_'): index
        for index, sound in enumerate(options)
    }
    docstring = 'Choose a sound effect. "random_choice" selects a random option. "random_ear_safe" selects a random safe option. "completely_random" selects any random sound.'

    f.write(f"class {internal_name}(Choice):\n")
    f.write(f"    \"\"\"{docstring}\"\"\"\n")
    f.write(f"    display_name = \"{display_name}\"\n")
    for sound, id in sfx_to_id.items():
        f.write(f"    option_{sound} = {id}\n")
    f.write(f"\n\n\n")