New tacnet interface functional

This commit is contained in:
2020-12-09 09:18:52 -06:00
parent 691cafb697
commit d36211cb5e
5 changed files with 76 additions and 18 deletions

View File

@@ -5,12 +5,18 @@ module TAC
attr_reader :menu_bar, :status_bar, :body attr_reader :menu_bar, :status_bar, :body
def initialize(host:, header_bar_label:, menu_bar:, status_bar:, body:) def initialize(host:)
@host = host @host = host
@header_bar_label = header_bar_label @header_bar_label = host.header_bar_label
@menu_bar = menu_bar @menu_bar = host.menu_bar
@status_bar = status_bar @status_bar = host.status_bar
@body = body @body = host.body
@options = {}
end
def options=(options)
@options = options
end end
def page(klass) def page(klass)

View File

@@ -5,20 +5,70 @@ module TAC
header_bar("TimeCrafters Auxiliary Configuration Network") header_bar("TimeCrafters Auxiliary Configuration Network")
menu_bar.clear do menu_bar.clear do
label "Hostname" @connect_menu = flow(width: 1.0, height: 1.0) do
hostname = edit_line "192.168.49.1", width: 0.33, height: 1.0 label "Hostname", text_size: 28
label "Port" hostname = edit_line window.backend.settings.hostname, width: 0.33, height: 1.0, text_size: 28
port = edit_line "192.168.49.1", width: 0.33, height: 1.0 label "Port", text_size: 28
button "Connect", height: 1.0 do port = edit_line window.backend.settings.port, width: 0.33, height: 1.0, text_size: 28
status_bar.clear do button "Connect", height: 1.0, text_size: 28 do
label "Connecting to #{hostname.value}:#{port.value}" if hostname.value != window.backend.settings.hostname || port.value.to_i != window.backend.settings.port
window.backend.settings_changed!
end
window.backend.settings.hostname = hostname.value
window.backend.settings.port = port.value.to_i
window.backend.tacnet.connect(hostname.value, port.value.to_i)
end
end
@disconnect_menu = flow(width: 1.0, height: 1.0) do
button "Disconnect", height: 1.0, text_size: 28 do
window.backend.tacnet.close
end end
end end
end end
status_bar.clear do status_bar.clear do
image "#{TAC::ROOT_PATH}/media/icons/signal3.png", height: 1.0 @tacnet_icon = image "#{TAC::ROOT_PATH}/media/icons/signal3.png", height: 26
label "TACNET: Connected Pkt Sent: 00314 Pkt Received: 00313", text_size: 26 @status_label = label "TACNET: Not Connected", text_size: 26
end
body.clear do
@full_status_label = label ""
end
end
def update
case window.backend.tacnet.status
when :connected
sent = "#{window.backend.tacnet.client.packets_sent}".rjust(4, '0')
received = "#{window.backend.tacnet.client.packets_received}".rjust(4, '0')
@status_label.value = "TACNET: Connected Pkt Sent: #{sent} Pkt Received: #{received}"
@full_status_label.value = window.backend.tacnet.full_status
@tacnet_icon.style.color = TAC::Palette::TACNET_CONNECTED
@connect_menu.hide
@disconnect_menu.show
when :connecting
@status_label.value = "TACNET: Connecting..."
@tacnet_icon.style.color = TAC::Palette::TACNET_CONNECTING
@connect_menu.hide
@disconnect_menu.show
when :connection_error
@status_label.value = "TACNET: Connection Error"
@full_status_label.value = window.backend.tacnet.full_status
@tacnet_icon.style.color = TAC::Palette::TACNET_CONNECTION_ERROR
@connect_menu.show
@disconnect_menu.hide
when :not_connected
@status_label.value = "TACNET: Not Connected"
@full_status_label.value = ""
@tacnet_icon.style.color = 0xff_ffffff
@connect_menu.show
@disconnect_menu.hide
end end
end end
end end

View File

@@ -1,5 +1,6 @@
class NewEditor < CyberarmEngine::GuiState class NewEditor < CyberarmEngine::GuiState
include CyberarmEngine::Theme # get access to deep_merge method include CyberarmEngine::Theme # get access to deep_merge method
attr_reader :header_bar, :header_bar_label, :navigation, :content, :menu_bar, :status_bar, :body
def setup def setup
@window_width = 0 @window_width = 0
@@ -129,7 +130,7 @@ class NewEditor < CyberarmEngine::GuiState
request_recalculate request_recalculate
end end
def page(klass) def page(klass, options = {})
@menu_bar.clear @menu_bar.clear
@status_bar.clear @status_bar.clear
@body.clear @body.clear
@@ -146,9 +147,10 @@ class NewEditor < CyberarmEngine::GuiState
@page.blur if @page @page.blur if @page
@pages[klass] = klass.new(host: self, header_bar_label: @header_bar_label, menu_bar: @menu_bar, status_bar: @status_bar, body: @body) unless @pages[klass] @pages[klass] = klass.new(host: self) unless @pages[klass]
@page = @pages[klass] @page = @pages[klass]
@page.options = options
@page.setup @page.setup
@page.focus @page.focus
end end

View File

@@ -60,7 +60,7 @@ module TAC
end end
def client def client
@connection.client if connected? @connection.client
end end
def puts(packet) def puts(packet)

View File

@@ -17,7 +17,7 @@ module TAC
} }
}, },
EditLine: { EditLine: {
caret_color: Gosu::Color.new(0xff_434343), caret_color: Gosu::Color.new(0xff_88ef90),
}, },
ToggleButton: { ToggleButton: {
width: 18, width: 18,