mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-15 13:32:33 +00:00
Remove no longer needed clipboard and ffi gems, use new CyberarmEngine::GuiState#needs_repaint? method to only paint when needed- should avoid wasting CPU/GPU time (gain a bit more battery life?), make TACNET connection error visually change UI and also trigger a TACNET dialog when not on the TACNET page
This commit is contained in:
@@ -77,6 +77,7 @@ robot.forward 100"
|
||||
@simulation.update
|
||||
|
||||
unless @simulation.robots.all? { |robot| robot.queue.empty? } # Only update clock if simulation is running
|
||||
current_state.request_repaint
|
||||
@simulation_status.value = "Time: #{(@simulation.simulation_time).round(1)} seconds"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,9 +11,9 @@ module TAC
|
||||
@title_font = CyberarmEngine::Text.new(TAC::NAME, z: 100, size: 72, border: true, border_size: 2, border_color: 0xff_000000, font: THEME[:TextBlock][:font], static: true)
|
||||
@logo = Gosu::Image.new("#{TAC::ROOT_PATH}/media/logo.png")
|
||||
|
||||
@title_animator = CyberarmEngine::Animator.new(start_time: 0, duration: 750, from: 0.0, to: 1.0, tween: :swing_from_to)
|
||||
@logo_animator = CyberarmEngine::Animator.new(start_time: 750, duration: 1_000, from: 0.0, to: 1.0, tween: :swing_to)
|
||||
@transition_animator = CyberarmEngine::Animator.new(start_time: 2_250, duration: 750, from: 0, to: 255, tween: :ease_out)
|
||||
@title_animator = CyberarmEngine::Animator.new(start_time: Gosu.milliseconds + 0, duration: 750, from: 0.0, to: 1.0, tween: :swing_from_to)
|
||||
@logo_animator = CyberarmEngine::Animator.new(start_time: Gosu.milliseconds + 750, duration: 1_000, from: 0.0, to: 1.0, tween: :swing_to)
|
||||
@transition_animator = CyberarmEngine::Animator.new(start_time: Gosu.milliseconds + 2_250, duration: 750, from: 0, to: 255, tween: :ease_out)
|
||||
@transition_color = Gosu::Color.new(0x00_111111)
|
||||
|
||||
@next_state = Editor
|
||||
|
||||
@@ -8,6 +8,8 @@ class Editor < CyberarmEngine::GuiState
|
||||
@window_width = 0
|
||||
@window_height = 0
|
||||
|
||||
@last_tacnet_status = nil
|
||||
|
||||
@pages = {}
|
||||
@page = nil
|
||||
|
||||
@@ -34,9 +36,9 @@ class Editor < CyberarmEngine::GuiState
|
||||
@header_bar = flow(width: 1.0, height: 36) do
|
||||
background 0xff_006000
|
||||
|
||||
@header_bar_label = label TAC::NAME, width: 1.0, text_align: :center, text_size: 32, font: TAC::THEME_BOLD_FONT
|
||||
@header_bar_label = label TAC::NAME, fill: true, text_align: :center, text_size: 32, font: TAC::THEME_BOLD_FONT, margin_left: BORDERLESS ? 36 * 3 : 0
|
||||
|
||||
@window_controls = flow(x: window.width - 36 * 2, y: 0, height: 1.0) do
|
||||
@window_controls = flow(width: 36 * 3, height: 1.0) do
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/minus.png"), tip: "Minimize", image_height: 1.0 do
|
||||
window.minimize if window.respond_to?(:minimize)
|
||||
end
|
||||
@@ -138,15 +140,32 @@ class Editor < CyberarmEngine::GuiState
|
||||
|
||||
@page.update if @page
|
||||
|
||||
case window.backend.tacnet.status
|
||||
when :not_connected
|
||||
@tacnet_button.style.color = Gosu::Color::WHITE
|
||||
when :connecting
|
||||
@tacnet_button.style.color = TAC::Palette::TACNET_CONNECTING
|
||||
when :connected
|
||||
@tacnet_button.style.color = TAC::Palette::TACNET_CONNECTED
|
||||
when :connection_error
|
||||
@tacnet_button.style.color = TAC::Palette::TACNET_CONNECTION_ERROR
|
||||
if @last_tacnet_status != window.backend.tacnet.status
|
||||
@last_tacnet_status = window.backend.tacnet.status
|
||||
|
||||
case window.backend.tacnet.status
|
||||
when :not_connected, :connected
|
||||
@tacnet_button.style.color = Gosu::Color::WHITE
|
||||
@header_bar.style.background = 0xff_006000
|
||||
when :connecting
|
||||
@tacnet_button.style.color = TAC::Palette::TACNET_CONNECTING
|
||||
@header_bar.style.background = TAC::Palette::TACNET_CONNECTING
|
||||
when :connection_error
|
||||
@tacnet_button.style.color = TAC::Palette::TACNET_CONNECTION_ERROR
|
||||
@header_bar.style.background = TAC::Palette::TACNET_CONNECTION_ERROR
|
||||
|
||||
unless @page.is_a?(TAC::Pages::TACNET)
|
||||
push_state(TAC::Dialog::TACNETDialog, title: "TACNET Connection Error", message: window.backend.tacnet.full_status)
|
||||
end
|
||||
end
|
||||
|
||||
@tacnet_button.style.default[:color] = @tacnet_button.style.color
|
||||
@header_bar.style.default[:background] = @header_bar.style.background
|
||||
|
||||
@tacnet_button.recalculate
|
||||
@header_bar.recalculate
|
||||
|
||||
request_repaint
|
||||
end
|
||||
|
||||
window.width = Gosu.available_width / 2 if window.width < Gosu.available_width / 2
|
||||
|
||||
@@ -11,6 +11,8 @@ module TAC
|
||||
|
||||
if ARGV.join.include?("--game-clock-remote-display")
|
||||
push_state(PracticeGameClock::View, remote_control_mode: true)
|
||||
elsif ARGV.join.include?("--intro")
|
||||
push_state(CyberarmEngine::IntroState, forward: TAC::States::Boot)
|
||||
else
|
||||
push_state(TAC::States::Boot)
|
||||
end
|
||||
@@ -29,6 +31,14 @@ module TAC
|
||||
@notification_manager.update
|
||||
end
|
||||
|
||||
def needs_redraw?
|
||||
if current_state.is_a?(Editor)
|
||||
current_state.needs_repaint? || @notification_manager.instance_variable_get(:@drivers).size.positive?
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def toast(title, message = nil)
|
||||
@notification_manager.create_notification(
|
||||
priority: GosuNotifications::Notification::PRIORITY_HIGH,
|
||||
|
||||
Reference in New Issue
Block a user