TACNET is now able to dynamically sync configs on initial connection, added error sound, made tacnet status dialog update stats, made simulator clock stop after all robots have run out of 'states' to run, changed some dialogs titlebar and borders to be different colors, misc. other changes.

This commit is contained in:
2020-09-08 19:25:04 -05:00
parent 08ada79e5b
commit 9dc3caca0f
17 changed files with 257 additions and 41 deletions

View File

@@ -0,0 +1,52 @@
module TAC
class Dialog
class ActionDialog < Dialog
def build
background Gosu::Color::GRAY
@type = @options[:action].type if @options[:action]
label "Name"
@name_error = label "Error", color: TAC::Palette::TACNET_CONNECTION_ERROR
@name_error.hide
@name = edit_line @options[:action] ? @options[:action].name : "", width: 1.0
label "Comment"
@comment = edit_line @options[:action] ? @options[:action].comment : "", width: 1.0
flow width: 1.0 do
button "Cancel", width: 0.475 do
close
end
button @options[:action] ? "Update" : "Add", width: 0.475 do |b|
if valid?
if @options[:action]
@options[:callback_method].call(@options[:action], @name.value.strip, @comment.value.strip)
else
@options[:callback_method].call(@name.value.strip, @comment.value.strip)
end
close
end
end
end
end
def valid?
valid = true
if @name.value.strip.empty?
@name_error.value = "Error: Name cannot be blank\n or only whitespace."
@name_error.show
valid = false
else
@name_error.value = ""
@name_error.hide
end
return valid
end
end
end
end

View File

@@ -2,6 +2,9 @@ module TAC
class Dialog
class ConfirmDialog < Dialog
def build
@dialog_root.style.border_color = [ Palette::ALERT, darken(Palette::ALERT, 50) ]
@titlebar.style.background = [ Palette::ALERT, darken(Palette::ALERT, 50) ]
background Gosu::Color::GRAY
label @options[:message]
@@ -9,7 +12,7 @@ module TAC
button "Cancel", width: 0.475 do
close
end
button "Okay", width: 0.475 do
button "Okay", width: 0.475, **TAC::THEME_DANGER_BUTTON do
close
@options[:callback_method].call

View File

@@ -0,0 +1,25 @@
module TAC
class Dialog
class TACNETDialog < Dialog
def build
@dialog_root.style.border_color = [ Palette::TACNET_PRIMARY, Palette::TACNET_SECONDARY ]
@titlebar.style.background = [ Palette::TACNET_PRIMARY, Palette::TACNET_SECONDARY ]
background Gosu::Color::GRAY
label @options[:message]
@sound = Gosu::Sample.new(TAC::ROOT_PATH + "/media/error_alarm.ogg").play(1, 1, true)
button "Close", width: 1.0 do
close
end
end
def close
super
@sound.stop
end
end
end
end

View File

@@ -0,0 +1,24 @@
module TAC
class Dialog
class TACNETStatusDialog < Dialog
def build
background Gosu::Color::GRAY
@message_label = label $window.backend.tacnet.full_status
button "Close", width: 1.0 do
close
end
@timer = CyberarmEngine::Timer.new(1000.0) do
@message_label.value = $window.backend.tacnet.full_status
end
end
def update
super
@timer.update
end
end
end
end