mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-16 13:52:34 +00:00
Updated Field/Robot/Simulator to use parent container's z index to remove need for Gosu.flush and causing Field to be drawn on top of tooltip's and menus, Added Power Play field, replaced font, enabled static option for text to improve rendering appearance, misc. bug fixes and tweaks.
This commit is contained in:
@@ -16,12 +16,14 @@ module TAC
|
||||
end
|
||||
|
||||
status_bar.clear do
|
||||
label "Current Configuration: "
|
||||
@config_label = label window.backend.settings.config
|
||||
flow(width: 1.0, max_width: 720, h_align: :center) do
|
||||
label "Current Configuration: "
|
||||
@config_label = label window.backend.settings.config
|
||||
end
|
||||
end
|
||||
|
||||
body.clear do
|
||||
@configs_list = stack width: 1.0, height: 1.0, scroll: true do
|
||||
@configs_list = stack width: 1.0, height: 1.0, margin_top: 36, max_width: 720, h_align: :center, scroll: true do
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,11 +36,12 @@ module TAC
|
||||
|
||||
@configs_list.clear do
|
||||
@config_files.each_with_index do |config_file, i|
|
||||
flow width: 1.0, **THEME_ITEM_CONTAINER_PADDING do
|
||||
background i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
|
||||
flow width: 1.0, height: 36, **THEME_ITEM_CONTAINER_PADDING do
|
||||
name = File.basename(config_file, ".json")
|
||||
|
||||
background i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR unless name == window.backend.settings.config
|
||||
background THEME_HIGHLIGHTED_COLOR if name == window.backend.settings.config
|
||||
|
||||
button "#{name}", fill: true, text_size: THEME_ICON_SIZE - 3 do
|
||||
change_config(name)
|
||||
|
||||
@@ -92,6 +95,8 @@ module TAC
|
||||
window.backend.load_config(name)
|
||||
|
||||
@config_label.value = name.to_s
|
||||
|
||||
populate_configs
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,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_right: 1, border_color: [0, Gosu::Color::BLACK, 0, 0] do
|
||||
@groups_menu = flow(width: 1.0) do
|
||||
stack fill: true, height: 1.0, padding_left: 2, padding_right: 2, border_thickness_right: 1, border_color: Gosu::Color::BLACK do
|
||||
@groups_menu = flow(width: 1.0, height: 36) do
|
||||
label "Groups", text_size: THEME_SUBHEADING_TEXT_SIZE, fill: true, text_align: :center
|
||||
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: THEME_ICON_SIZE, tip: "Add group" do
|
||||
@@ -84,12 +84,12 @@ module TAC
|
||||
end
|
||||
end
|
||||
|
||||
@groups_list = stack width: 1.0, scroll: true do
|
||||
@groups_list = stack width: 1.0, fill: true, scroll: true do
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
stack fill: true, height: 1.0, padding_left: 2, padding_right: 2, border_thickness_right: 1, border_color: Gosu::Color::BLACK do
|
||||
@actions_menu = flow(width: 1.0, height: 36) do
|
||||
label "Actions", text_size: THEME_SUBHEADING_TEXT_SIZE, fill: true, text_align: :center
|
||||
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: THEME_ICON_SIZE, tip: "Add action" do
|
||||
@@ -151,12 +151,12 @@ module TAC
|
||||
end
|
||||
end
|
||||
|
||||
@actions_list = stack width: 1.0, scroll: true do
|
||||
@actions_list = stack width: 1.0, fill: true, scroll: true do
|
||||
end
|
||||
end
|
||||
|
||||
stack width: 0.331, height: 1.0 do
|
||||
@variables_menu = flow(width: 1.0) do
|
||||
stack fill: true, height: 1.0, padding_left: 2, padding_right: 2 do
|
||||
@variables_menu = flow(width: 1.0, height: 36) do
|
||||
label "Variables", text_size: THEME_SUBHEADING_TEXT_SIZE, fill: true, text_align: :center
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: THEME_ICON_SIZE, tip: "Add variable" do
|
||||
if @active_action
|
||||
@@ -167,7 +167,7 @@ module TAC
|
||||
end
|
||||
end
|
||||
|
||||
@variables_list = stack width: 1.0, scroll: true do
|
||||
@variables_list = stack width: 1.0, fill: true, scroll: true do
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -210,16 +210,6 @@ module TAC
|
||||
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)
|
||||
@@ -244,8 +234,10 @@ module TAC
|
||||
window.backend.config_changed!
|
||||
|
||||
@active_group = nil
|
||||
@active_group_container = nil
|
||||
@active_group_label.value = ""
|
||||
@active_action = nil
|
||||
@active_active_container = nil
|
||||
@active_action_label.value = ""
|
||||
@actions_list.clear
|
||||
@variables_list.clear
|
||||
@@ -320,13 +312,20 @@ module TAC
|
||||
|
||||
@groups_list.clear do
|
||||
groups.each_with_index do |group, i|
|
||||
flow width: 1.0, **THEME_ITEM_CONTAINER_PADDING do
|
||||
flow width: 1.0, height: 36, **THEME_ITEM_CONTAINER_PADDING do |container|
|
||||
background i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
|
||||
button group.name, fill: true, text_size: THEME_ICON_SIZE - 3 do
|
||||
if (old_i = groups.index(@active_group))
|
||||
@active_group_container.style.default[:background] = old_i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
end
|
||||
|
||||
@active_group = group
|
||||
@active_group_container = container
|
||||
@active_group_container.style.default[:background] = THEME_HIGHLIGHTED_COLOR
|
||||
@active_group_label.value = group.name
|
||||
@active_action = nil
|
||||
@active_action_container = nil
|
||||
@active_action_label.value = ""
|
||||
|
||||
populate_actions_list(group)
|
||||
@@ -342,8 +341,6 @@ module TAC
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set_list_heights
|
||||
end
|
||||
|
||||
def populate_actions_list(group)
|
||||
@@ -353,12 +350,18 @@ module TAC
|
||||
|
||||
@actions_list.clear do
|
||||
actions.each_with_index do |action, i|
|
||||
stack width: 1.0, **THEME_ITEM_CONTAINER_PADDING do
|
||||
stack width: 1.0, height: action.comment.empty? ? 36 : 72, **THEME_ITEM_CONTAINER_PADDING do |container|
|
||||
background i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
|
||||
flow width: 1.0 do
|
||||
flow width: 1.0, height: 36 do
|
||||
button action.name, fill: true, text_size: THEME_ICON_SIZE - 3 do
|
||||
if (old_i = actions.index(@active_action))
|
||||
@active_action_container.style.default[:background] = old_i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
end
|
||||
|
||||
@active_action = action
|
||||
@active_action_container = container
|
||||
@active_action_container.style.default[:background] = THEME_HIGHLIGHTED_COLOR
|
||||
@active_action_label.value = action.name
|
||||
|
||||
populate_variables_list(action)
|
||||
@@ -379,12 +382,14 @@ module TAC
|
||||
end
|
||||
end
|
||||
|
||||
caption "#{action.comment}", width: 1.0, text_wrap: :word_wrap unless action.comment.empty?
|
||||
unless action.comment.empty?
|
||||
stack(width: 1.0, fill: true, scroll: true) do
|
||||
caption action.comment.to_s, width: 1.0, text_wrap: :word_wrap, text_border: true, text_border_size: 1, text_border_color: 0xaa_000000
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set_list_heights
|
||||
end
|
||||
|
||||
def populate_variables_list(action)
|
||||
@@ -394,10 +399,10 @@ module TAC
|
||||
|
||||
@variables_list.clear do
|
||||
variables.each_with_index do |variable, i|
|
||||
stack width: 1.0, **THEME_ITEM_CONTAINER_PADDING do
|
||||
stack width: 1.0, height: 96, **THEME_ITEM_CONTAINER_PADDING do
|
||||
background i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
|
||||
flow(width: 1.0) do
|
||||
flow(width: 1.0, fill: true) do
|
||||
button "#{variable.name}", fill: true, text_size: THEME_ICON_SIZE - 3, tip: "Edit variable" do
|
||||
push_state(Dialog::VariableDialog, title: "Edit Variable", variable: variable, callback_method: method(:update_variable))
|
||||
end
|
||||
@@ -412,8 +417,6 @@ module TAC
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set_list_heights
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,6 +35,11 @@ module TAC
|
||||
@nodes.clear
|
||||
refresh_panel
|
||||
end
|
||||
|
||||
list_box items: ["Power Play", "Freight Frenzy", "Ultimate Goal", "Skystone"], width: 200, height: 1.0 do |item|
|
||||
season = item.downcase.gsub(" ", "_").to_sym
|
||||
@field = TAC::Simulator::Field.new(container: @field_container, season: season, simulation: nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,7 +66,7 @@ module TAC
|
||||
end
|
||||
end
|
||||
|
||||
@field = TAC::Simulator::Field.new(container: @field_container, season: :freight_frenzy, simulation: nil)
|
||||
@field = TAC::Simulator::Field.new(container: @field_container, season: :power_play, simulation: nil)
|
||||
@nodes ||= []
|
||||
@unit = :inches
|
||||
@total_distance = 0
|
||||
@@ -77,16 +82,12 @@ module TAC
|
||||
end
|
||||
|
||||
def draw
|
||||
super
|
||||
|
||||
@field.draw
|
||||
|
||||
display_path
|
||||
end
|
||||
|
||||
def update
|
||||
super
|
||||
|
||||
@field.update
|
||||
|
||||
measure_path
|
||||
@@ -133,7 +134,7 @@ module TAC
|
||||
Gosu.draw_circle(
|
||||
current_node.x * @field.scale + @field_container.x,
|
||||
current_node.y * @field.scale + @field_container.y,
|
||||
@node_radius, 7, mouse_near ? @node_hover_color : @node_color, 10
|
||||
@node_radius, 7, mouse_near ? @node_hover_color : @node_color, @field_container.z + 1
|
||||
)
|
||||
|
||||
next if i.zero?
|
||||
@@ -153,7 +154,8 @@ module TAC
|
||||
(@field_container.y + last_node.y * @field.scale) - distance,
|
||||
@segment_thickness,
|
||||
distance,
|
||||
@segment_color
|
||||
@segment_color,
|
||||
@field_container.z + 1
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ module TAC
|
||||
|
||||
body.clear do
|
||||
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
|
||||
@group_presets = stack(fill: true, height: 1.0, scroll: true, padding_left: 2, padding_top: 2, padding_right: 2, border_thickness_right: 1, border_color: Gosu::Color::BLACK) do
|
||||
end
|
||||
|
||||
@action_presets = stack(width: 0.49995, height: 1.0, scroll: true) do
|
||||
@action_presets = stack(fill: true, height: 1.0, scroll: true, padding_left: 2, padding_top: 2, padding_right: 2) do
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -26,11 +26,11 @@ module TAC
|
||||
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
|
||||
flow(width: 1.0, height: 36, **THEME_ITEM_CONTAINER_PADDING) do
|
||||
background i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
|
||||
button group.name, width: 0.895 do
|
||||
page(TAC::Pages::Editor,{ group: group, group_is_preset: true })
|
||||
button group.name, fill: true, text_size: THEME_ICON_SIZE - 3 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
|
||||
@@ -59,11 +59,11 @@ module TAC
|
||||
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
|
||||
flow(width: 1.0, height: 36, **THEME_ITEM_CONTAINER_PADDING) do
|
||||
background i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
|
||||
button action.name, width: 0.895 do
|
||||
page(TAC::Pages::Editor,{ action: action, action_is_preset: true })
|
||||
button action.name, fill: true, text_size: THEME_ICON_SIZE - 3 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
|
||||
|
||||
@@ -8,7 +8,7 @@ module TAC
|
||||
search = edit_line "", fill: true, height: 1.0
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/zoom.png"), image_height: 1.0 do
|
||||
unless search.value.strip.empty?
|
||||
search_results = search_config(search.value.downcase.strip)
|
||||
search_results = search_config(search.value.strip)
|
||||
|
||||
status_bar.clear do
|
||||
if search_results.results.size.zero?
|
||||
@@ -89,7 +89,6 @@ module TAC
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if search_results.action_presets.size.positive?
|
||||
title "Action Presets"
|
||||
|
||||
@@ -152,7 +151,7 @@ module TAC
|
||||
|
||||
def search_groups(query, search_results)
|
||||
window.backend.config.groups.each do |group|
|
||||
if group.name.downcase.include?(query)
|
||||
if group.name.downcase.include?(query.downcase)
|
||||
result = SearchResult.new(group: group, query: query, is_group: true, is_from_name: true)
|
||||
search_results.results << result
|
||||
end
|
||||
@@ -162,12 +161,12 @@ module TAC
|
||||
def search_actions(query, search_results)
|
||||
window.backend.config.groups.each do |group|
|
||||
group.actions.each do |action|
|
||||
if action.name.downcase.include?(query)
|
||||
if action.name.downcase.include?(query.downcase)
|
||||
result = SearchResult.new(group: group, action: action, query: query, is_action: true, is_from_name: true)
|
||||
search_results.results << result
|
||||
end
|
||||
|
||||
if action.comment.downcase.include?(query)
|
||||
if action.comment.downcase.include?(query.downcase)
|
||||
result = SearchResult.new(group: group, action: action, query: query, is_action: true, is_from_comment: true)
|
||||
search_results.results << result
|
||||
end
|
||||
@@ -179,12 +178,12 @@ module TAC
|
||||
window.backend.config.groups.each do |group|
|
||||
group.actions.each do |action|
|
||||
action.variables.each do |variable|
|
||||
if variable.name.downcase.include?(query)
|
||||
if variable.name.downcase.include?(query.downcase)
|
||||
result = SearchResult.new(group: group, action: action, variable: variable, is_variable: true, query: query, is_from_name: true)
|
||||
search_results.results << result
|
||||
end
|
||||
|
||||
if variable.value.downcase.include?(query)
|
||||
if variable.value.downcase.include?(query.downcase)
|
||||
result = SearchResult.new(group: group, action: action, variable: variable, is_variable: true, query: query, is_from_value: true)
|
||||
search_results.results << result
|
||||
end
|
||||
@@ -195,29 +194,29 @@ module TAC
|
||||
|
||||
def search_presets(query, search_results)
|
||||
window.backend.config.presets.groups.each do |group|
|
||||
if group.name.downcase.include?(query)
|
||||
if group.name.downcase.include?(query.downcase)
|
||||
result = SearchResult.new(group: group, query: query, is_group: true, is_from_name: true, is_preset: true)
|
||||
search_results.results << result
|
||||
end
|
||||
|
||||
group.actions.each do |action|
|
||||
if action.name.downcase.include?(query)
|
||||
if action.name.downcase.include?(query.downcase)
|
||||
result = SearchResult.new(group: group, action: action, query: query, is_action: true, is_from_name: true, is_preset: true)
|
||||
search_results.results << result
|
||||
end
|
||||
|
||||
if action.comment.downcase.include?(query)
|
||||
if action.comment.downcase.include?(query.downcase)
|
||||
result = SearchResult.new(group: group, action: action, query: query, is_action: true, is_from_comment: true, is_preset: true)
|
||||
search_results.results << result
|
||||
end
|
||||
|
||||
action.variables.each do |variable|
|
||||
if variable.name.downcase.include?(query)
|
||||
if variable.name.downcase.include?(query.downcase)
|
||||
result = SearchResult.new(group: group, action: action, variable: variable, is_variable: true, query: query, is_from_name: true, is_preset: true)
|
||||
search_results.results << result
|
||||
end
|
||||
|
||||
if variable.value.downcase.include?(query)
|
||||
if variable.value.downcase.include?(query.downcase)
|
||||
result = SearchResult.new(group: group, action: action, variable: variable, is_variable: true, query: query, is_from_value: true, is_preset: true)
|
||||
search_results.results << result
|
||||
end
|
||||
@@ -226,27 +225,27 @@ module TAC
|
||||
end
|
||||
|
||||
window.backend.config.presets.actions.each do |action|
|
||||
if action.name.downcase.include?(query)
|
||||
result = SearchResult.new(group: nil, action: action, query: query, is_action: true, is_from_name: true, is_preset: true)
|
||||
if action.name.downcase.include?(query.downcase)
|
||||
result = SearchResult.new(group: nil, action: action, query: query, is_action: true, is_from_name: true, is_preset: true)
|
||||
search_results.results << result
|
||||
end
|
||||
|
||||
if action.comment.downcase.include?(query.downcase)
|
||||
result = SearchResult.new(group: nil, action: action, query: query, is_action: true, is_from_comment: true, is_preset: true)
|
||||
search_results.results << result
|
||||
end
|
||||
|
||||
action.variables.each do |variable|
|
||||
if variable.name.downcase.include?(query.downcase)
|
||||
result = SearchResult.new(group: nil, action: action, variable: variable, is_variable: true, query: query, is_from_name: true, is_preset: true)
|
||||
search_results.results << result
|
||||
end
|
||||
|
||||
if action.comment.downcase.include?(query)
|
||||
result = SearchResult.new(group: nil, action: action, query: query, is_action: true, is_from_comment: true, is_preset: true)
|
||||
if variable.value.downcase.include?(query.downcase)
|
||||
result = SearchResult.new(group: nil, action: action, variable: variable, is_variable: true, query: query, is_from_value: true, is_preset: true)
|
||||
search_results.results << result
|
||||
end
|
||||
|
||||
action.variables.each do |variable|
|
||||
if variable.name.downcase.include?(query)
|
||||
result = SearchResult.new(group: nil, action: action, variable: variable, is_variable: true, query: query, is_from_name: true, is_preset: true)
|
||||
search_results.results << result
|
||||
end
|
||||
|
||||
if variable.value.downcase.include?(query)
|
||||
result = SearchResult.new(group: nil, action: action, variable: variable, is_variable: true, query: query, is_from_value: true, is_preset: true)
|
||||
search_results.results << result
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -332,7 +331,8 @@ module TAC
|
||||
end
|
||||
|
||||
def highlight(string)
|
||||
string.gsub(/#{@query}/i, "<b><c=ff00ff>#{@query}</c></b>")
|
||||
match = string.match(/#{@query}/i)
|
||||
string.gsub(/#{@query}/i, "<b><c=ff00ff>#{match}</c></b>")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ module TAC
|
||||
begin
|
||||
@simulation = TAC::Simulator::Simulation.new(source_code: @source_code.value, field_container: @field_container)
|
||||
@simulation.start
|
||||
rescue SyntaxError, NameError, NoMethodError, TypeError, ArgumentError => e
|
||||
rescue SyntaxError, NameError, NoMethodError, TypeError, ArgumentError, StandardError => e
|
||||
puts e.backtrace.reverse.join("\n")
|
||||
puts e
|
||||
push_state(Dialog::AlertDialog, title: "#{e.class}", message: e)
|
||||
|
||||
Reference in New Issue
Block a user