mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-16 13:52:34 +00:00
Dialog's no longer need a fixed height, misc. dialog tweaks.
This commit is contained in:
@@ -2,32 +2,32 @@ module TAC
|
|||||||
class Dialog < CyberarmEngine::GuiState
|
class Dialog < CyberarmEngine::GuiState
|
||||||
def setup
|
def setup
|
||||||
theme(THEME)
|
theme(THEME)
|
||||||
background Gosu::Color.new(0x88_000000)
|
background Gosu::Color.new(0xaa_000000)
|
||||||
|
|
||||||
@title = @options[:title] ? @options[:title] : "#{self.class}"
|
@title = @options[:title] ? @options[:title] : "#{self.class}"
|
||||||
@window_width, @window_height = window.width, window.height
|
@window_width, @window_height = window.width, window.height
|
||||||
@previous_state = window.previous_state
|
@previous_state = window.previous_state
|
||||||
|
|
||||||
@dialog_root = stack width: 250, height: 400, border_thickness: 2, border_color: [TAC::Palette::TIMECRAFTERS_PRIMARY, TAC::Palette::TIMECRAFTERS_SECONDARY] do
|
@dialog_root = stack width: 0.25, border_thickness: 2, border_color: [TAC::Palette::TIMECRAFTERS_PRIMARY, TAC::Palette::TIMECRAFTERS_SECONDARY] do
|
||||||
# Title bar
|
# Title bar
|
||||||
@titlebar = flow width: 1.0, height: 0.1 do
|
@titlebar = flow width: 1.0 do
|
||||||
background [TAC::Palette::TIMECRAFTERS_PRIMARY, TAC::Palette::TIMECRAFTERS_SECONDARY]
|
background [TAC::Palette::TIMECRAFTERS_PRIMARY, TAC::Palette::TIMECRAFTERS_SECONDARY]
|
||||||
|
|
||||||
# title
|
# title
|
||||||
flow width: 0.855 do
|
flow width: 0.9 do
|
||||||
label @title, text_size: THEME_SUBHEADING_TEXT_SIZE, text_shadow_color: Gosu::Color::BLACK
|
label @title, text_size: THEME_SUBHEADING_TEXT_SIZE, width: 1.0, text_align: :center, text_shadow: true, text_shadow_color: 0xff_222222, text_shadow_size: 1
|
||||||
end
|
end
|
||||||
|
|
||||||
# Buttons
|
# Buttons
|
||||||
flow width: 0.145 do
|
flow width: 0.0999 do
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/cross.png"), image_width: 24, **THEME_DANGER_BUTTON do
|
button get_image("#{TAC::ROOT_PATH}/media/icons/cross.png"), image_width: 1.0, **THEME_DANGER_BUTTON do
|
||||||
close
|
close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dialog body
|
# Dialog body
|
||||||
@dialog_content = stack width: 1.0, height: 0.9 do
|
@dialog_content = stack width: 1.0 do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -35,6 +35,10 @@ module TAC
|
|||||||
build
|
build
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@root_container.recalculate
|
||||||
|
@root_container.recalculate
|
||||||
|
@root_container.recalculate
|
||||||
|
|
||||||
center_dialog
|
center_dialog
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -42,8 +46,12 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def center_dialog
|
def center_dialog
|
||||||
@dialog_root.style.x = window.width / 2 - @dialog_root.style.width / 2
|
@dialog_root.style.x = window.width / 2 - @dialog_root.width / 2
|
||||||
@dialog_root.style.y = window.height / 2 - @dialog_root.style.height / 2
|
@dialog_root.style.y = window.height / 2 - @dialog_root.height / 2
|
||||||
|
end
|
||||||
|
|
||||||
|
def name_filter(text)
|
||||||
|
text.match(/[A-Za-z0-9._\- ]/) ? text : ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def draw
|
def draw
|
||||||
@@ -57,10 +65,12 @@ module TAC
|
|||||||
super
|
super
|
||||||
|
|
||||||
if window.width != @window_width or window.height != @window_height
|
if window.width != @window_width or window.height != @window_height
|
||||||
center_dialog
|
request_recalculate
|
||||||
|
|
||||||
@window_width, @window_height = window.width, window.height
|
@window_width, @window_height = window.width, window.height
|
||||||
end
|
end
|
||||||
|
|
||||||
|
center_dialog
|
||||||
end
|
end
|
||||||
|
|
||||||
def close
|
def close
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ module TAC
|
|||||||
def build
|
def build
|
||||||
background Gosu::Color::GRAY
|
background Gosu::Color::GRAY
|
||||||
|
|
||||||
label "Name"
|
label "Name", width: 1.0, text_align: :center
|
||||||
@name_error = label "Error", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
@name_error = label "Error", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
||||||
@name_error.hide
|
@name_error.hide
|
||||||
@name = edit_line @options[:action] ? @options[:action].name : "", width: 1.0
|
@name = edit_line @options[:action] ? @options[:action].name : "", filter: method(:name_filter), width: 1.0
|
||||||
|
|
||||||
label "Comment"
|
label "Comment", width: 1.0, text_align: :center
|
||||||
@comment = edit_line @options[:action] ? @options[:action].comment : "", width: 1.0
|
@comment = edit_line @options[:action] ? @options[:action].comment : "", width: 1.0
|
||||||
|
|
||||||
flow width: 1.0 do
|
flow width: 1.0, margin_top: THEME_DIALOG_BUTTON_PADDING do
|
||||||
button "Cancel", width: 0.475 do
|
button "Cancel", width: 0.475 do
|
||||||
close
|
close
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ module TAC
|
|||||||
background Gosu::Color::GRAY
|
background Gosu::Color::GRAY
|
||||||
label @options[:message]
|
label @options[:message]
|
||||||
|
|
||||||
button "Close", width: 1.0 do
|
button "Close", width: 1.0, margin_top: THEME_DIALOG_BUTTON_PADDING do
|
||||||
close
|
close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ module TAC
|
|||||||
background Gosu::Color::GRAY
|
background Gosu::Color::GRAY
|
||||||
label @options[:message]
|
label @options[:message]
|
||||||
|
|
||||||
flow width: 1.0 do
|
flow width: 1.0, margin_top: THEME_DIALOG_BUTTON_PADDING do
|
||||||
button "Cancel", width: 0.475 do
|
button "Cancel", width: 0.475 do
|
||||||
close
|
close
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,18 +5,16 @@ module TAC
|
|||||||
|
|
||||||
def build
|
def build
|
||||||
background Gosu::Color::GRAY
|
background Gosu::Color::GRAY
|
||||||
flow width: 1.0 do
|
label "Name", width: 1.0, text_align: :center
|
||||||
label "Name", width: 0.25
|
|
||||||
@name = edit_line @options[:renaming] ? @options[:renaming].name : "", filter: method(:filter), width: 0.70
|
|
||||||
end
|
|
||||||
@name_error = label "", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
@name_error = label "", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
||||||
@name_error.hide
|
@name_error.hide
|
||||||
|
@name = edit_line @options[:renaming] ? @options[:renaming].name : "", filter: method(:name_filter), width: 1.0
|
||||||
|
|
||||||
@name.subscribe(:changed) do |sender, value|
|
@name.subscribe(:changed) do |sender, value|
|
||||||
valid?
|
valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
flow width: 1.0 do
|
flow width: 1.0, margin_top: THEME_DIALOG_BUTTON_PADDING do
|
||||||
button "Cancel", width: 0.475 do
|
button "Cancel", width: 0.475 do
|
||||||
close
|
close
|
||||||
end
|
end
|
||||||
@@ -67,10 +65,6 @@ module TAC
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter(text)
|
|
||||||
text.match(/[A-Za-z0-9._\- ]/) ? text : ""
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -10,7 +10,7 @@ module TAC
|
|||||||
|
|
||||||
@sound = Gosu::Sample.new(TAC::ROOT_PATH + "/media/error_alarm.ogg").play(1, 1, true)
|
@sound = Gosu::Sample.new(TAC::ROOT_PATH + "/media/error_alarm.ogg").play(1, 1, true)
|
||||||
|
|
||||||
button "Close", width: 1.0 do
|
button "Close", width: 1.0, margin_top: THEME_DIALOG_BUTTON_PADDING do
|
||||||
close
|
close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ module TAC
|
|||||||
background Gosu::Color::GRAY
|
background Gosu::Color::GRAY
|
||||||
@message_label = label $window.backend.tacnet.full_status
|
@message_label = label $window.backend.tacnet.full_status
|
||||||
|
|
||||||
button "Close", width: 1.0 do
|
button "Close", width: 1.0, margin_top: THEME_DIALOG_BUTTON_PADDING do
|
||||||
close
|
close
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ module TAC
|
|||||||
|
|
||||||
@type = @options[:variable].type if @options[:variable]
|
@type = @options[:variable].type if @options[:variable]
|
||||||
|
|
||||||
label "Name"
|
label "Name", width: 1.0, text_align: :center
|
||||||
@name_error = label "Error", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
@name_error = label "Error", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
||||||
@name_error.hide
|
@name_error.hide
|
||||||
@name = edit_line @options[:variable] ? @options[:variable].name : "", width: 1.0
|
@name = edit_line @options[:variable] ? @options[:variable].name : "", filter: method(:name_filter), width: 1.0
|
||||||
|
|
||||||
label "Type"
|
label "Type", width: 1.0, text_align: :center
|
||||||
@type_error = label "Error", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
@type_error = label "Error", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
||||||
@type_error.hide
|
@type_error.hide
|
||||||
|
|
||||||
@@ -19,15 +19,17 @@ module TAC
|
|||||||
@type = item
|
@type = item
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@type ||= @var_type.value.to_sym
|
||||||
|
|
||||||
@value_container = stack width: 1.0 do
|
@value_container = stack width: 1.0 do
|
||||||
label "Value"
|
label "Value", width: 1.0, text_align: :center
|
||||||
@value_error = label "Error", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
@value_error = label "Error", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
||||||
@value_error.hide
|
@value_error.hide
|
||||||
@value = edit_line @options[:variable] ? @options[:variable].value : "", width: 1.0
|
@value = edit_line @options[:variable] ? @options[:variable].value : "", width: 1.0
|
||||||
@value_boolean = check_box "Variable", checked: @options[:variable] ? @options[:variable].value == true : false
|
@value_boolean = check_box "Variable", checked: @options[:variable] ? @options[:variable].value == true : false
|
||||||
end
|
end
|
||||||
|
|
||||||
flow width: 1.0 do
|
flow width: 1.0, margin_top: THEME_DIALOG_BUTTON_PADDING do
|
||||||
button "Cancel", width: 0.475 do
|
button "Cancel", width: 0.475 do
|
||||||
close
|
close
|
||||||
end
|
end
|
||||||
@@ -69,7 +71,7 @@ module TAC
|
|||||||
|
|
||||||
if [:integer, :float, :double, :long].include?(@type)
|
if [:integer, :float, :double, :long].include?(@type)
|
||||||
if @value.value.strip.empty?
|
if @value.value.strip.empty?
|
||||||
@value_error.value = "Error: Value cannot be blank\n or only whitespace."
|
@value_error.value = "Error: Numeric value cannot be\nblank or only whitespace."
|
||||||
@value_error.show
|
@value_error.show
|
||||||
valid = false
|
valid = false
|
||||||
|
|
||||||
@@ -108,7 +110,7 @@ module TAC
|
|||||||
valid = false
|
valid = false
|
||||||
|
|
||||||
else
|
else
|
||||||
@value_error.value = "Error: Type not set."
|
@value_error.value = "Error: Type not set or\ntype #{@var_type.value.inspect} is not valid."
|
||||||
@value_error.show
|
@value_error.show
|
||||||
valid = false
|
valid = false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ module TAC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
THEME_DIALOG_BUTTON_PADDING = 24
|
||||||
THEME_ICON_SIZE = 18
|
THEME_ICON_SIZE = 18
|
||||||
THEME_HEADING_TEXT_SIZE = 32
|
THEME_HEADING_TEXT_SIZE = 32
|
||||||
THEME_SUBHEADING_TEXT_SIZE = 28
|
THEME_SUBHEADING_TEXT_SIZE = 28
|
||||||
|
|||||||
Reference in New Issue
Block a user