Initial presets editing support

This commit is contained in:
2021-02-09 23:38:01 -06:00
parent ab55e8db5b
commit e27f1d1dca
3 changed files with 51 additions and 17 deletions

View File

@@ -48,6 +48,8 @@ module TAC
populate_groups_list
})
else
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to clone group, no group selected.")
end
end
@@ -61,6 +63,8 @@ module TAC
window.toast("Saved Group Preset", "Saved preset: #{name}")
})
else
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to create group preset, no group selected.")
end
end
end
@@ -77,7 +81,7 @@ module TAC
if @active_group
push_state(TAC::Dialog::ActionDialog, title: "Create Action", list: @active_group.actions, callback_method: method(:create_action))
else
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to create action,\nno group selected.")
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to create action, no group selected.")
end
end
@@ -92,6 +96,8 @@ module TAC
populate_actions_list(@active_group)
})
else
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to clone action, no action selected.")
end
end
@@ -105,6 +111,8 @@ module TAC
window.toast("Saved Action Preset", "Saved preset: #{name}")
})
else
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to create action preset, no action selected.")
end
end
end
@@ -133,6 +141,23 @@ module TAC
populate_groups_list
if @options[:group_is_preset]
@active_group = @options[:group]
@active_group_label.value = @active_group.name
populate_actions_list(@active_group)
@groups_menu.hide
elsif @options[:action_is_preset]
@active_action = @options[:action]
@active_action_label.value = @active_action.name
populate_variables_list(@options[:action])
@groups_menu.hide
@actions_menu.hide
else
if @options[:group]
@active_group = @options[:group]
@active_group_label.value = @active_group.name
@@ -150,6 +175,7 @@ module TAC
end
end
end
end
body.root.subscribe(:window_size_changed) do
set_list_heights
@@ -241,7 +267,11 @@ module TAC
end
def populate_groups_list
groups = []
unless @options[:group_is_preset] || @options[:action_is_preset]
groups = window.backend.config.groups
end
@groups_list.clear do
groups.each_with_index do |group, i|
@@ -262,7 +292,7 @@ module TAC
push_state(Dialog::NamePromptDialog, title: "Rename Group", renaming: group, list: window.backend.config.groups, callback_method: method(:update_group))
end
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete group", **THEME_DANGER_BUTTON do
push_state(Dialog::ConfirmDialog, title: "Are you sure?", message: "Delete group and all\nof its actions and variables?", callback_method: proc { delete_group(group) })
push_state(Dialog::ConfirmDialog, title: "Are you sure?", message: "Delete group and all of its actions and variables?", callback_method: proc { delete_group(group) })
end
end
end

View File

@@ -29,7 +29,9 @@ module TAC
flow(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
background i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
button group.name, width: 0.895
button group.name, width: 0.895 do
page(TAC::Pages::Editor,{ group: group, group_is_preset: true })
end
button get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit group preset" do
push_state(
@@ -60,7 +62,9 @@ module TAC
flow(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
background i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
button action.name, width: 0.895
button action.name, width: 0.895 do
page(TAC::Pages::Editor,{ action: action, action_is_preset: true })
end
button get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit action preset" do
push_state(

View File

@@ -13,11 +13,11 @@ require_relative "lib/backend"
require_relative "lib/config"
require_relative "lib/settings"
require_relative "lib/states/boot"
require_relative "lib/states/editor"
require_relative "lib/states/new_editor"
require_relative "lib/states/simulator"
require_relative "lib/states/manage_presets"
require_relative "lib/states/manage_configurations"
# require_relative "lib/states/editor"
# require_relative "lib/states/simulator"
# require_relative "lib/states/manage_presets"
# require_relative "lib/states/manage_configurations"
require_relative "lib/page"
require_relative "lib/pages/home"
require_relative "lib/pages/editor"