mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-15 21:32:35 +00:00
Tweaks to simulator robot, made start up animation skippable, made NamePromptDialog able to detect duplicate names, enabled cloning of groups and actions
This commit is contained in:
@@ -7,15 +7,24 @@ module TAC
|
|||||||
label "Name", width: 0.25, text_size: 18
|
label "Name", width: 0.25, text_size: 18
|
||||||
@name = edit_line @options[:renaming] ? @options[:renaming].name : "", width: 0.70, text_size: 18
|
@name = edit_line @options[:renaming] ? @options[:renaming].name : "", width: 0.70, text_size: 18
|
||||||
end
|
end
|
||||||
|
@name_error = label "", text_size: 18, color: TAC::Palette::TACNET_CONNECTION_ERROR
|
||||||
|
@name_error.hide
|
||||||
|
|
||||||
flow width: 1.0 do
|
flow width: 1.0 do
|
||||||
button "Cancel", width: 0.475, text_size: 18 do
|
button "Cancel", width: 0.475, text_size: 18 do
|
||||||
close
|
close
|
||||||
end
|
end
|
||||||
|
|
||||||
button @options[:renaming] ? "Update" : "Add", width: 0.475, text_size: 18 do
|
accept_label = @options[:renaming] ? "Update" : "Add"
|
||||||
|
accept_label = @options[:accept_label] if @options[:accept_label]
|
||||||
|
|
||||||
|
button accept_label, width: 0.475, text_size: 18 do
|
||||||
if @name.value.strip.empty?
|
if @name.value.strip.empty?
|
||||||
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Name cannot be blank.\nName cannot only be whitespace.")
|
@name_error.value = "Name cannot be blank.\nName cannot only be whitespace."
|
||||||
|
@name_error.show
|
||||||
|
elsif @options[:list] && @options[:list].find { |i| i.name == @name.value.strip }
|
||||||
|
@name_error.value = "Name is not unique!"
|
||||||
|
@name_error.show
|
||||||
else
|
else
|
||||||
if @options[:renaming]
|
if @options[:renaming]
|
||||||
@options[:callback_method].call(@options[:renaming], @name.value.strip)
|
@options[:callback_method].call(@options[:renaming], @name.value.strip)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ module TAC
|
|||||||
class Simulator
|
class Simulator
|
||||||
class Robot
|
class Robot
|
||||||
attr_accessor :position, :angle
|
attr_accessor :position, :angle
|
||||||
|
attr_reader :width, :depth
|
||||||
def initialize(width:, depth:)
|
def initialize(width:, depth:)
|
||||||
@width, @depth = width, depth
|
@width, @depth = width, depth
|
||||||
|
|
||||||
|
|||||||
@@ -119,8 +119,8 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def draw
|
def draw
|
||||||
Gosu.draw_line(@robot.position.x, @robot.position.y, Gosu::Color::GREEN, @goal.x, @goal.y, Gosu::Color::GREEN)
|
Gosu.draw_line(@robot.position.x + @robot.width / 2, @robot.position.y + @robot.depth / 2, Gosu::Color::GREEN, @goal.x + @robot.width / 2, @goal.y + @robot.depth / 2, Gosu::Color::GREEN)
|
||||||
Gosu.draw_rect(@goal.x, @goal.y, 16, 16, Gosu::Color::RED)
|
Gosu.draw_rect(@goal.x + (@robot.width / 2 - 2), @goal.y + (@robot.depth / 2 - 2), 4, 4, Gosu::Color::RED)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update(dt)
|
def update(dt)
|
||||||
|
|||||||
@@ -31,6 +31,12 @@ module TAC
|
|||||||
|
|
||||||
push_state(Editor) if @transition_color.alpha >= 255
|
push_state(Editor) if @transition_color.alpha >= 255
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def button_up(id)
|
||||||
|
super
|
||||||
|
|
||||||
|
push_state(Editor)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -8,7 +8,7 @@ module TAC
|
|||||||
theme(THEME)
|
theme(THEME)
|
||||||
|
|
||||||
stack width: 1.0, height: 1.0 do
|
stack width: 1.0, height: 1.0 do
|
||||||
stack width: 1.0, height: 0.1 do
|
stack width: 1.0, height: 0.1, border_thickness: 1, border_color: [0, 0, Gosu::Color::BLACK, 0] do
|
||||||
background [TAC::Palette::TIMECRAFTERS_PRIMARY, TAC::Palette::TIMECRAFTERS_SECONDARY]
|
background [TAC::Palette::TIMECRAFTERS_PRIMARY, TAC::Palette::TIMECRAFTERS_SECONDARY]
|
||||||
|
|
||||||
flow width: 1.0, height: 1.0 do
|
flow width: 1.0, height: 1.0 do
|
||||||
@@ -86,45 +86,76 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
flow width: 1.0, height: 0.9 do
|
flow width: 1.0, height: 0.9 do
|
||||||
stack width: 0.333, height: 1.0 do
|
stack width: 0.333, height: 1.0, border_thickness: 1, border_color: [0, Gosu::Color::BLACK, 0, 0] do
|
||||||
background TAC::Palette::GROUPS_PRIMARY
|
background TAC::Palette::GROUPS_PRIMARY
|
||||||
flow do
|
flow do
|
||||||
label "Groups"
|
label "Groups"
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: 18, tip: "Add group" do
|
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: 18, tip: "Add group" do
|
||||||
push_state(TAC::Dialog::NamePromptDialog, title: "Create Group", callback_method: method(:create_group))
|
push_state(TAC::Dialog::NamePromptDialog, title: "Create Group", list: window.backend.config.groups, callback_method: method(:create_group))
|
||||||
|
end
|
||||||
|
button get_image("#{TAC::ROOT_PATH}/media/icons/button2.png"), image_width: 18, tip: "Clone currently selected group" do
|
||||||
|
if @active_group
|
||||||
|
push_state(Dialog::NamePromptDialog, title: "Clone Group", renaming: @active_group, accept_label: "Clone", list: window.backend.config.groups, callback_method: proc { |group, name|
|
||||||
|
clone = TAC::Config::Group.from_json( JSON.parse( @active_group.to_json, symbolize_names: true ))
|
||||||
|
clone.name = "#{name}"
|
||||||
|
window.backend.config.groups << clone
|
||||||
|
window.backend.config_changed!
|
||||||
|
|
||||||
|
populate_groups_list
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/button2.png"), image_width: 18, tip: "Clone currently selected group"
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/save.png"), image_width: 18, tip: "Save group as preset"
|
button get_image("#{TAC::ROOT_PATH}/media/icons/save.png"), image_width: 18, tip: "Save group as preset"
|
||||||
end
|
end
|
||||||
|
|
||||||
@groups_list = stack width: 1.0 do
|
@groups_list = stack width: 1.0 do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
stack width: 0.333, height: 1.0 do
|
stack width: 0.333, height: 1.0, border_thickness: 1, border_color: [0, Gosu::Color::BLACK, 0, 0] do
|
||||||
background TAC::Palette::ACTIONS_PRIMARY
|
background TAC::Palette::ACTIONS_PRIMARY
|
||||||
flow do
|
flow do
|
||||||
label "Actions"
|
label "Actions"
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: 18, tip: "Add action" do
|
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: 18, tip: "Add action" do
|
||||||
if @active_group
|
if @active_group
|
||||||
push_state(TAC::Dialog::NamePromptDialog, title: "Create Action", callback_method: method(:create_action))
|
push_state(TAC::Dialog::NamePromptDialog, title: "Create Action", list: @active_group.actions, callback_method: method(:create_action))
|
||||||
else
|
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,\nno group selected.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/button2.png"), image_width: 18, tip: "Clone currently selected action"
|
button get_image("#{TAC::ROOT_PATH}/media/icons/button2.png"), image_width: 18, tip: "Clone currently selected action" do
|
||||||
|
if @active_action
|
||||||
|
clone = TAC::Config::Action.from_json( JSON.parse( @active_action.to_json, symbolize_names: true ))
|
||||||
|
clone.name = "#{clone.name}_copy"
|
||||||
|
@active_group.actions << clone
|
||||||
|
window.backend.config_changed!
|
||||||
|
|
||||||
|
populate_actions_list(@active_group)
|
||||||
|
end
|
||||||
|
|
||||||
|
if @active_group
|
||||||
|
push_state(Dialog::NamePromptDialog, title: "Clone Action", renaming: @active_action, accept_label: "Clone", list: @active_group.actions, callback_method: proc { |action, name|
|
||||||
|
clone = TAC::Config::Action.from_json( JSON.parse( @active_action.to_json, symbolize_names: true ))
|
||||||
|
clone.name = name
|
||||||
|
@active_group.actions << clone
|
||||||
|
window.backend.config_changed!
|
||||||
|
|
||||||
|
populate_actions_list(@active_group)
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/save.png"), image_width: 18, tip: "Save action as preset"
|
button get_image("#{TAC::ROOT_PATH}/media/icons/save.png"), image_width: 18, tip: "Save action as preset"
|
||||||
end
|
end
|
||||||
|
|
||||||
@actions_list = stack width: 1.0 do
|
@actions_list = stack width: 1.0 do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
stack width: 0.333, height: 1.0 do
|
stack width: 0.331, height: 1.0 do
|
||||||
background TAC::Palette::VARIABLES_PRIMARY
|
background TAC::Palette::VARIABLES_PRIMARY
|
||||||
flow do
|
flow do
|
||||||
label "Values"
|
label "Variables"
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: 18, tip: "Add variable" do
|
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: 18, tip: "Add variable" do
|
||||||
if @active_action
|
if @active_action
|
||||||
push_state(TAC::Dialog::VariableDialog, title: "Create Value", callback_method: method(:create_variable))
|
push_state(TAC::Dialog::VariableDialog, title: "Create Variable", callback_method: method(:create_variable))
|
||||||
else
|
else
|
||||||
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to create variable,\nno action selected.")
|
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to create variable,\nno action selected.")
|
||||||
end
|
end
|
||||||
@@ -265,7 +296,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/wrench.png"), image_width: 18, tip: "Edit group" do
|
button get_image("#{TAC::ROOT_PATH}/media/icons/wrench.png"), image_width: 18, tip: "Edit group" do
|
||||||
push_state(Dialog::NamePromptDialog, title: "Rename Group", renaming: group, callback_method: method(:update_group))
|
push_state(Dialog::NamePromptDialog, title: "Rename Group", renaming: group, list: window.backend.config.groups, callback_method: method(:update_group))
|
||||||
end
|
end
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: 18, tip: "Delete group" do
|
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: 18, tip: "Delete group" 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\nof its actions and variables?", callback_method: proc { delete_group(group) })
|
||||||
@@ -289,7 +320,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/wrench.png"), image_width: 18, tip: "Edit action" do
|
button get_image("#{TAC::ROOT_PATH}/media/icons/wrench.png"), image_width: 18, tip: "Edit action" do
|
||||||
push_state(Dialog::NamePromptDialog, title: "Rename Action", renaming: action, callback_method: method(:update_action))
|
push_state(Dialog::NamePromptDialog, title: "Rename Action", renaming: action, list: @active_group.actions, callback_method: method(:update_action))
|
||||||
end
|
end
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: 18, tip: "Delete action" do
|
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: 18, tip: "Delete action" do
|
||||||
push_state(Dialog::ConfirmDialog, title: "Are you sure?", message: "Delete action and all\nof its variables?", callback_method: proc { delete_action(action) })
|
push_state(Dialog::ConfirmDialog, title: "Are you sure?", message: "Delete action and all\nof its variables?", callback_method: proc { delete_action(action) })
|
||||||
@@ -304,17 +335,22 @@ module TAC
|
|||||||
|
|
||||||
@variables_list.clear do
|
@variables_list.clear do
|
||||||
variables.each_with_index do |variable, i|
|
variables.each_with_index do |variable, i|
|
||||||
flow width: 1.0 do
|
stack width: 1.0 do
|
||||||
|
background TAC::Palette::VARIABLES_PRIMARY if i.even?
|
||||||
background TAC::Palette::VARIABLES_SECONDARY if i.odd?
|
background TAC::Palette::VARIABLES_SECONDARY if i.odd?
|
||||||
|
|
||||||
label variable.name, text_size: 18, width: 0.855
|
flow width: 1.0 do
|
||||||
|
label variable.name, text_size: 18, width: 0.855
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/wrench.png"), image_width: 18, tip: "Edit variable" do
|
button get_image("#{TAC::ROOT_PATH}/media/icons/wrench.png"), image_width: 18, tip: "Edit variable" do
|
||||||
push_state(Dialog::VariableDialog, title: "Edit Variable", variable: variable, callback_method: method(:update_variable))
|
push_state(Dialog::VariableDialog, title: "Edit Variable", variable: variable, callback_method: method(:update_variable))
|
||||||
end
|
end
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: 18, tip: "Delete variable" do
|
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: 18, tip: "Delete variable" do
|
||||||
push_state(Dialog::ConfirmDialog, title: "Are you sure?", message: "Delete variable?", callback_method: proc { delete_variable(variable) })
|
push_state(Dialog::ConfirmDialog, title: "Are you sure?", message: "Delete variable?", callback_method: proc { delete_variable(variable) })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
label "Type: #{variable.type}, Value: #{variable.value}", text_size: 18
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user