Using a menu to allow user presets

Andrew Finch
Andrew Finch Member Posts: 17 Newcomer

Hi Guys,

I am working on an instrument at the moment and am trying to have a menu that lets you choose between 6 presets that when selected let you choose the states of 4 buttons for that preset. Looking at the code below, I could just create 6 x 4 buttons and hide the ones I am not using when I select a certain preset but I think I remember reading somewhere that there is a way to do the above by only declaring 4 buttons (not 24!). Is there any way to remember the button states for each preset if I am only declaring 4 buttons?

Thanks in advance

on init

    set_script_title("Menu Buttons")
    set_ui_height_px(100)

    {-----------------Buttons--------------------}


    declare ui_switch $button1
    move_control_px($button1,220,40)
    set_control_par(get_ui_id($button1),$CONTROL_PAR_WIDTH,20)
    set_control_par(get_ui_id($button1),$CONTROL_PAR_HEIGHT,20)
    set_text($button1,"")


    declare ui_switch $button2
    move_control_px($button2,240,40)
    set_control_par(get_ui_id($button2),$CONTROL_PAR_WIDTH,20)
    set_control_par(get_ui_id($button2),$CONTROL_PAR_HEIGHT,20)
    set_text($button2,"")


    declare ui_switch $button3
    move_control_px($button3,260,40)
    set_control_par(get_ui_id($button3),$CONTROL_PAR_WIDTH,20)
    set_control_par(get_ui_id($button3),$CONTROL_PAR_HEIGHT,20)
    set_text($button3,"")


    declare ui_switch $button4
    move_control_px($button4,280,40)
    set_control_par(get_ui_id($button4),$CONTROL_PAR_WIDTH,20)
    set_control_par(get_ui_id($button4),$CONTROL_PAR_HEIGHT,20)
    set_text($button4,"")


    {--------------Menu---------------}


    declare ui_menu $preset_menu
    add_menu_item($preset_menu,"P1",0) 
    add_menu_item($preset_menu,"P2",1)
    add_menu_item($preset_menu,"P3",2) 
    add_menu_item($preset_menu,"P4",3)
    add_menu_item($preset_menu,"P5",4) 
    add_menu_item($preset_menu,"P6",5)


    move_control_px($preset_menu,320,40)
    set_control_par(get_ui_id($preset_menu),$CONTROL_PAR_WIDTH,40)

end on


Answers

  • EvilDragon
    EvilDragon Moderator Posts: 1,023 mod

    You would use an array that holds the preset states for your buttons, then read from that array and set the button values appropriately.

Back To Top