mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-16 05:42:35 +00:00
Use scrolling in editor, fixed border in editor, started work on presets, jump to group/action/variable from search is mostly working (may add highlighted background and scroll to in future)
This commit is contained in:
@@ -13,8 +13,6 @@ module TAC
|
||||
populate_configs
|
||||
})
|
||||
end
|
||||
|
||||
# label "Manage Configurations", text_size: 36
|
||||
end
|
||||
|
||||
status_bar.clear do
|
||||
@@ -23,7 +21,7 @@ module TAC
|
||||
end
|
||||
|
||||
body.clear do
|
||||
@configs_list = stack width: 1.0 do
|
||||
@configs_list = stack width: 1.0, height: 1.0, scroll: true do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -7,7 +7,13 @@ module TAC
|
||||
@active_action = nil
|
||||
|
||||
menu_bar.clear do
|
||||
title "Editing configuration: #{window.backend.config.name}"
|
||||
if @options[:group_is_preset]
|
||||
title "Editing group preset: #{@options[:group].name}"
|
||||
elsif @options[:action_is_preset]
|
||||
title "Editing action preset: #{@options[:action].name}"
|
||||
else
|
||||
title "Editing configuration: #{window.backend.config.name}"
|
||||
end
|
||||
end
|
||||
|
||||
status_bar.clear do
|
||||
@@ -24,8 +30,8 @@ module TAC
|
||||
|
||||
body.clear do
|
||||
flow(width: 1.0, height: 1.0) do
|
||||
stack width: 0.33333, height: 1.0, border_thickness: 1, border_color: [0, Gosu::Color::BLACK, 0, 0] do
|
||||
flow(width: 1.0) do
|
||||
stack width: 0.33333, height: 1.0, border_thickness_right: 1, border_color: [0, Gosu::Color::BLACK, 0, 0] do
|
||||
@groups_menu = flow(width: 1.0) do
|
||||
label "Groups", text_size: THEME_SUBHEADING_TEXT_SIZE
|
||||
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: THEME_ICON_SIZE, tip: "Add group" do
|
||||
@@ -53,12 +59,12 @@ module TAC
|
||||
end
|
||||
end
|
||||
|
||||
@groups_list = stack width: 1.0 do
|
||||
@groups_list = stack width: 1.0, scroll: true do
|
||||
end
|
||||
end
|
||||
|
||||
stack width: 0.33333, height: 1.0, border_thickness: 1, border_color: [0, Gosu::Color::BLACK, 0, 0] do
|
||||
flow(width: 1.0) do
|
||||
stack width: 0.33333, height: 1.0, border_thickness_right: 1, border_color: [0, Gosu::Color::BLACK, 0, 0] do
|
||||
@actions_menu = flow(width: 1.0) do
|
||||
label "Actions", text_size: THEME_SUBHEADING_TEXT_SIZE
|
||||
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: THEME_ICON_SIZE, tip: "Add action" do
|
||||
@@ -91,12 +97,12 @@ module TAC
|
||||
end
|
||||
end
|
||||
|
||||
@actions_list = stack width: 1.0 do
|
||||
@actions_list = stack width: 1.0, scroll: true do
|
||||
end
|
||||
end
|
||||
|
||||
stack width: 0.331, height: 1.0 do
|
||||
flow(width: 1.0) do
|
||||
@variables_menu = flow(width: 1.0) do
|
||||
label "Variables", text_size: THEME_SUBHEADING_TEXT_SIZE
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: THEME_ICON_SIZE, tip: "Add variable" do
|
||||
if @active_action
|
||||
@@ -107,13 +113,41 @@ module TAC
|
||||
end
|
||||
end
|
||||
|
||||
@variables_list = stack width: 1.0 do
|
||||
@variables_list = stack width: 1.0, scroll: true do
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
populate_groups_list
|
||||
|
||||
if @options[:group]
|
||||
@active_group = @options[:group]
|
||||
@active_group_label.value = @active_group.name
|
||||
|
||||
populate_actions_list(@active_group)
|
||||
|
||||
if @options[:action]
|
||||
@active_action = @options[:action]
|
||||
@active_action_label.value = @active_action.name
|
||||
|
||||
populate_variables_list(@active_action)
|
||||
|
||||
if @options[:variable]
|
||||
# Scroll into view?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
body.root.subscribe(:window_size_changed) do
|
||||
set_list_heights
|
||||
end
|
||||
end
|
||||
|
||||
def set_list_heights
|
||||
@groups_list.style.height = body.height - @groups_menu.height
|
||||
@actions_list.style.height = body.height - @actions_menu.height
|
||||
@variables_list.style.height = body.height - @variables_menu.height
|
||||
end
|
||||
|
||||
def create_group(name)
|
||||
@@ -221,6 +255,8 @@ module TAC
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set_list_heights
|
||||
end
|
||||
|
||||
def populate_actions_list(group)
|
||||
@@ -258,6 +294,8 @@ module TAC
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set_list_heights
|
||||
end
|
||||
|
||||
def populate_variables_list(action)
|
||||
@@ -283,6 +321,8 @@ module TAC
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set_list_heights
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,8 +4,84 @@ module TAC
|
||||
def setup
|
||||
header_bar("Manage Presets")
|
||||
|
||||
status_bar.clear do
|
||||
tagline "Group Presets", width: 0.495
|
||||
tagline "Action Presets", width: 0.495
|
||||
end
|
||||
|
||||
body.clear do
|
||||
label "Not Yet Implemented"
|
||||
flow(width: 1.0, height: 1.0) do
|
||||
@group_presets = stack(width: 0.49995, height: 1.0, scroll: true, border_thickness_right: 1, border_color: [0, Gosu::Color::BLACK, 0, 0]) do
|
||||
end
|
||||
|
||||
@action_presets = stack(width: 0.49995, height: 1.0, scroll: true) do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
populate_group_presets
|
||||
populate_action_presets
|
||||
end
|
||||
|
||||
def populate_group_presets
|
||||
@group_presets.clear do
|
||||
window.backend.config.presets.groups.each_with_index do |group, i|
|
||||
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 get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit group" do
|
||||
push_state(
|
||||
Dialog::NamePromptDialog,
|
||||
title: "Rename Group",
|
||||
renaming: group,
|
||||
list: window.backend.config.presets.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 of its actions and variables?",
|
||||
callback_method: proc { delete_group(group) }
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def populate_action_presets
|
||||
@action_presets.clear do
|
||||
window.backend.config.presets.actions.each_with_index do |action, i|
|
||||
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 get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit group" do
|
||||
push_state(
|
||||
Dialog::NamePromptDialog,
|
||||
title: "Rename Group",
|
||||
renaming: group,
|
||||
list: window.backend.config.presets.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 of its actions and variables?",
|
||||
callback_method: proc { delete_group(group) }
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,16 +10,18 @@ module TAC
|
||||
unless search.value.strip.empty?
|
||||
search_results = search_config(search.value.downcase.strip)
|
||||
|
||||
status_bar.clear do
|
||||
if search_results.results.size.zero?
|
||||
subtitle "No results for: \"#{search.value.strip}\""
|
||||
else
|
||||
subtitle "Search results for: \"#{search.value.strip}\""
|
||||
end
|
||||
end
|
||||
|
||||
body.clear do
|
||||
flow(width: 1.0, height: 1.0) do
|
||||
stack(width: 0.495, height: 1.0) do
|
||||
stack(width: 0.495, height: 1.0, scroll: true) do
|
||||
shared_index = 0
|
||||
if search_results.results.size.zero?
|
||||
subtitle "No results for: \"#{search.value.strip}\""
|
||||
else
|
||||
subtitle "Search results for: \"#{search.value.strip}\""
|
||||
end
|
||||
|
||||
if search_results.groups.size.positive?
|
||||
title "Groups"
|
||||
|
||||
@@ -70,7 +72,7 @@ module TAC
|
||||
end
|
||||
end
|
||||
|
||||
stack(width: 0.495, height: 1.0) do
|
||||
stack(width: 0.495, height: 1.0, scroll: true) do
|
||||
if search_results.group_presets.size.positive?
|
||||
title "Group Presets"
|
||||
|
||||
|
||||
@@ -60,6 +60,8 @@ module TAC
|
||||
if @host_is_a_connection
|
||||
title, message = packet.body.split(Packet::PROTOCOL_SEPERATOR, 2)
|
||||
$window.push_state(TAC::Dialog::TACNETDialog, title: title, message: message)
|
||||
else
|
||||
log.e(TAG, "Remote error: #{title}: #{message}")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -75,7 +77,9 @@ module TAC
|
||||
$window.backend.load_config(config_name)
|
||||
else
|
||||
$window.push_state(TAC::Dialog::AlertDialog, title: "Invalid Config", message: "Supported config spec: v#{TAC::CONFIG_SPEC_VERSION} got v#{data.dig(:config, :spec_version)}")
|
||||
end
|
||||
end
|
||||
else
|
||||
raise "Invalid Config!"
|
||||
end
|
||||
|
||||
rescue JSON::ParserError => e
|
||||
|
||||
Reference in New Issue
Block a user