Hey all,
I am working on a script that allows the user to save a preset to a specific button. So far I have 4 buttons which should be selected in any combination then by pressing the dropdown menu you can save or load. This all works fine but now I want to implement the 'Save to P1' and 'Save to P2' idea. By selecting either of these with the current button combination I want to be able to save the combination to the button so that when it is pressed it will load the combination. Further to this the idea, I want the user to be able to save their own combinations to the preset buttons meaning that you should be able to overide the previous selected preset. Below is what I have so far, any suggestions or ideas would be gratefully recieved:
{Load/Save Test}
on init
message("")
set_script_title("Save/Load Test")
{------------------------------------------Save/Load----------------------------------}
declare $count
declare %combination_buttons[4]
declare $sync_id
{---Save combinations of these buttons---}
declare ui_switch $button1
declare ui_switch $button2
declare ui_switch $button3
declare ui_switch $button4
make_persistent($button1)
make_persistent($button2)
make_persistent($button3)
make_persistent($button4)
{---Preset Buttons---}
declare ui_switch $preset1
declare ui_switch $preset2
make_persistent($preset1)
make_persistent($preset2)
move_control_px($preset1,66,25)
move_control_px($preset2,158,25)
{---Dropdown menu to give options: Save, Load, Save to P1, Save to P2---}
declare ui_menu $load_save_menu
make_persistent($load_save_menu)
add_menu_item($load_save_menu,"Save",0)
add_menu_item($load_save_menu,"Load",1)
add_menu_item($load_save_menu,"Save to P1",2)
add_menu_item($load_save_menu,"Save to P2",3)
move_control_px($load_save_menu,500,2)
end on
on async_complete
if ($NI_ASYNC_ID = $sync_id)
$sync_id := -1
end if
end on
on ui_control ($load_save_menu)
select ($load_save_menu)
case 0
save_array (%combination_buttons,0)
case 1
$sync_id := load_array (%combination_buttons,0)
while ($sync_id # -1)
wait (1)
end while
$button1 := %combination_buttons[0]
$button2 := %combination_buttons[1]
$button3 := %combination_buttons[2]
$button4 := %combination_buttons[3]
end select
end on
on ui_control($button1)
%combination_buttons[0] := $button1
end on
on ui_control($button2)
%combination_buttons[1] := $button2
end on
on ui_control($button3)
%combination_buttons[2] := $button3
end on
on ui_control($button4)
%combination_buttons[3] := $button4
end on