mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-15 21:32:35 +00:00
Updated VariableDialog to use list_box instead of several buttons, make Variable store real type instead of mashing everything into value
This commit is contained in:
@@ -4,31 +4,27 @@ module TAC
|
||||
def build
|
||||
background Gosu::Color::GRAY
|
||||
|
||||
@type = @options[:variable].raw_type if @options[:variable]
|
||||
@type = @options[:variable].type if @options[:variable]
|
||||
|
||||
label "Name"
|
||||
@name_error = label "Error", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
||||
@name_error.hide
|
||||
@name = edit_line @options[:variable] ? @options[:variable].name : ""
|
||||
@name = edit_line @options[:variable] ? @options[:variable].name : "", width: 1.0
|
||||
|
||||
label "Type"
|
||||
@type_error = label "Error", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
||||
@type_error.hide
|
||||
# TODO: Add dropdown menus to CyberarmEngine
|
||||
flow width: 1.0 do
|
||||
[:float, :double, :integer, :long, :string, :boolean].each do |btn|
|
||||
button btn do
|
||||
@type = btn
|
||||
@value_container.show
|
||||
end
|
||||
end
|
||||
|
||||
@var_type = list_box items: [:float, :double, :integer, :long, :string, :boolean], choose: @type ? @type : :double, width: 1.0 do |item|
|
||||
@type = item
|
||||
end
|
||||
|
||||
@value_container = stack width: 1.0 do
|
||||
label "Value"
|
||||
@value_error = label "Error", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
||||
@value_error.hide
|
||||
@value = edit_line @options[:variable] ? @options[:variable].raw_value : ""
|
||||
@value = edit_line @options[:variable] ? @options[:variable].value : "", width: 1.0
|
||||
@value_boolean = check_box "Variable", checked: @options[:variable] ? @options[:variable].value == true : false
|
||||
end
|
||||
|
||||
flow width: 1.0 do
|
||||
@@ -39,9 +35,9 @@ module TAC
|
||||
button @options[:variable] ? "Update" : "Add", width: 0.475 do |b|
|
||||
if valid?
|
||||
if @options[:variable]
|
||||
@options[:callback_method].call(@options[:variable], @name.value.strip, "#{TAC::Config::Variable.encode_type(@type)}x#{@value.value.strip}")
|
||||
@options[:callback_method].call(@options[:variable], @name.value.strip, @type, @value.value.strip)
|
||||
else
|
||||
@options[:callback_method].call(@name.value.strip, "#{TAC::Config::Variable.encode_type(@type)}x#{@value.value.strip}")
|
||||
@options[:callback_method].call(@name.value.strip, @type, @value.value.strip)
|
||||
end
|
||||
|
||||
close
|
||||
@@ -76,6 +72,7 @@ module TAC
|
||||
@value_error.value = "Error: Value cannot be blank\n or only whitespace."
|
||||
@value_error.show
|
||||
valid = false
|
||||
|
||||
elsif [:integer, :long].include?(@type)
|
||||
begin
|
||||
Integer(@value.value.strip)
|
||||
@@ -84,6 +81,7 @@ module TAC
|
||||
@value_error.show
|
||||
valid = false
|
||||
end
|
||||
|
||||
elsif [:float, :double].include?(@type)
|
||||
begin
|
||||
Float(@value.value.strip)
|
||||
@@ -96,16 +94,19 @@ module TAC
|
||||
@value_error.value = ""
|
||||
@value_error.hide
|
||||
end
|
||||
|
||||
elsif @type == :string
|
||||
if @value.value.strip.empty?
|
||||
@value_error.value = "Error: Value cannot be blank\n or only whitespace."
|
||||
@value_error.show
|
||||
valid = false
|
||||
end
|
||||
|
||||
elsif @type == :boolean
|
||||
@value_error.value = "Error: Boolean not yet supported."
|
||||
@value_error.show
|
||||
valid = false
|
||||
|
||||
else
|
||||
@value_error.value = "Error: Type not set."
|
||||
@value_error.show
|
||||
@@ -116,4 +117,4 @@ module TAC
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user