z_mirror/BlueprintTools
git clone https://git.raiguard.me/z_mirror/BlueprintTools
d93cdd3
clipboards
1local gui =require ( "__flib__.gui-beta" ) 2local mod_gui =require ( "__core__.lualib.mod-gui" ) 3 4local buttons_gui ={} 5 6local function mod_gui_button ( color , action ) 7return { 8type ="sprite-button" , 9style ="bpt_mod_gui_button_" .. color , 10sprite ="bpt_" .. action .. "_white" , 11tooltip ={ "bpt-gui." .. string . gsub ( string . gsub ( action , "bpt_" , "" ), "_" , "-" ) .. "-tooltip" } , 12elem_mods ={ visible =false } , 13actions ={ 14on_click ={ gui ="buttons" , action =action } 15} , 16ref ={ action } 17} 18end 19 20function buttons_gui . refresh ( player , player_table ) 21local button_flow =mod_gui . get_button_flow ( player ) 22 23for _ , button in pairs ( player_table . guis . blueprint_buttons or {} ) do 24button . destroy () 25end 26player_table . guis . blueprint_buttons =gui . build ( button_flow , { 27-- mod_gui_button("blue", "flip_horizontally"), 28-- mod_gui_button("blue", "flip_vertically"), 29mod_gui_button ( "blue" , "swap_wire_colors" ), 30mod_gui_button ( "blue" , "set_tiles" ), 31mod_gui_button ( "blue" , "quick_grid" ), 32mod_gui_button ( "blue" , "configure" ) 33} ) 34 35for _ , button in pairs ( player_table . guis . upgrade_planner_buttons or {} ) do 36button . destroy () 37end 38player_table . guis . upgrade_planner_buttons =gui . build ( button_flow , { 39mod_gui_button ( "green" , "configure" ) 40} ) 41 42for _ , button in pairs ( player_table . guis . deconstruction_planner_buttons or {} ) do 43button . destroy () 44end 45player_table . guis . deconstruction_planner_buttons =gui . build ( button_flow , { 46mod_gui_button ( "red" , "configure" ) 47} ) 48end 49 50function buttons_gui . show ( player_table , button_type ) 51for _ , button in pairs ( player_table . guis [ button_type .. "_buttons" ]) do 52button . visible =true 53end 54player_table . flags [ button_type .. "_buttons_shown" ] =true 55end 56 57function buttons_gui . hide ( player_table , button_type ) 58for _ , button in pairs ( player_table . guis [ button_type .. "_buttons" ]) do 59button . visible =false 60end 61player_table . flags [ button_type .. "_buttons_shown" ] =false 62end 63 64return buttons_gui