mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-16 05:42:35 +00:00
Updates to support latest version of CyberarmEngine
This commit is contained in:
@@ -101,7 +101,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def refresh_tacnet_status
|
def refresh_tacnet_status
|
||||||
$window.current_state.refresh_tacnet_status
|
CyberarmEngine::Window.instance.current_state.refresh_tacnet_status
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ module TAC
|
|||||||
|
|
||||||
@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 = previous_state
|
||||||
|
|
||||||
@dialog_root = stack width: 0.25, 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
|
||||||
@@ -122,7 +122,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def close
|
def close
|
||||||
$window.pop_state
|
CyberarmEngine::Window.instance.pop_state
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -3,14 +3,14 @@ module TAC
|
|||||||
class TACNETStatusDialog < Dialog
|
class TACNETStatusDialog < Dialog
|
||||||
def build
|
def build
|
||||||
background Gosu::Color::GRAY
|
background Gosu::Color::GRAY
|
||||||
@message_label = label $window.backend.tacnet.full_status
|
@message_label = label CyberarmEngine::Window.instance.backend.tacnet.full_status
|
||||||
|
|
||||||
button "Close", width: 1.0, margin_top: THEME_DIALOG_BUTTON_PADDING do
|
button "Close", width: 1.0, margin_top: THEME_DIALOG_BUTTON_PADDING do
|
||||||
try_commit
|
try_commit
|
||||||
end
|
end
|
||||||
|
|
||||||
@timer = CyberarmEngine::Timer.new(1000.0) do
|
@timer = CyberarmEngine::Timer.new(1000.0) do
|
||||||
@message_label.value = $window.backend.tacnet.full_status
|
@message_label.value = CyberarmEngine::Window.instance.backend.tacnet.full_status
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ module TAC
|
|||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@title = CyberarmEngine::Text.new("FIRST TECH CHALLENGE", size: TITLE_SIZE, text_shadow: true, y: 10, color: Gosu::Color::GRAY)
|
@title = CyberarmEngine::Text.new("FIRST TECH CHALLENGE", size: TITLE_SIZE, text_shadow: true, y: 10, color: Gosu::Color::GRAY)
|
||||||
@title.x = $window.width / 2 - @title.width / 2
|
@title.x = CyberarmEngine::Window.instance.width / 2 - @title.width / 2
|
||||||
|
|
||||||
@text = CyberarmEngine::Text.new(":1234567890", size: CLOCK_SIZE, text_border: true, border_size: 2, border_color: Gosu::Color::GRAY)
|
@text = CyberarmEngine::Text.new(":1234567890", size: CLOCK_SIZE, text_border: true, border_size: 2, border_color: Gosu::Color::GRAY)
|
||||||
@text.width # trigger font-eager loading
|
@text.width # trigger font-eager loading
|
||||||
@@ -28,7 +28,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@title.x = $window.width / 2 - @title.width / 2
|
@title.x = CyberarmEngine::Window.instance.width / 2 - @title.width / 2
|
||||||
|
|
||||||
if @controller
|
if @controller
|
||||||
@text.color = @controller.display_color
|
@text.color = @controller.display_color
|
||||||
@@ -38,8 +38,8 @@ module TAC
|
|||||||
@text.text = "0:00"
|
@text.text = "0:00"
|
||||||
end
|
end
|
||||||
|
|
||||||
@text.x = $window.width / 2 - @text.textobject.text_width("0:00") / 2
|
@text.x = CyberarmEngine::Window.instance.width / 2 - @text.textobject.text_width("0:00") / 2
|
||||||
@text.y = $window.height / 2 - @text.height / 2
|
@text.y = CyberarmEngine::Window.instance.height / 2 - @text.height / 2
|
||||||
|
|
||||||
@controller&.update
|
@controller&.update
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def start_clock(mode)
|
def start_clock(mode)
|
||||||
return if @clock.active? || $window.current_state.is_a?(Randomizer)
|
return if @clock.active? || CyberarmEngine::Window.instance.current_state.is_a?(Randomizer)
|
||||||
|
|
||||||
@clock.controller = case mode
|
@clock.controller = case mode
|
||||||
when :full_match
|
when :full_match
|
||||||
@@ -45,7 +45,7 @@ module TAC
|
|||||||
|
|
||||||
def set_clock_title(string)
|
def set_clock_title(string)
|
||||||
@clock.title.text = string.to_s
|
@clock.title.text = string.to_s
|
||||||
@clock.title.x = $window.width / 2 - @clock.title.width / 2
|
@clock.title.x = CyberarmEngine::Window.instance.width / 2 - @clock.title.width / 2
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_clock_title(string)
|
def get_clock_title(string)
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ module TAC
|
|||||||
def handle_shutdown(packet)
|
def handle_shutdown(packet)
|
||||||
unless @host_is_a_connection
|
unless @host_is_a_connection
|
||||||
# RemoteControl.server.close
|
# RemoteControl.server.close
|
||||||
# $window.close
|
# CyberarmEngine::Window.instance.close
|
||||||
Gosu::Song.current_song&.stop
|
Gosu::Song.current_song&.stop
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@particles.each { |part| part.update($window.dt) }
|
@particles.each { |part| part.update(CyberarmEngine::Window.instance.dt) }
|
||||||
@particles.delete_if { |part| part.die? }
|
@particles.delete_if { |part| part.die? }
|
||||||
|
|
||||||
spawn_particles
|
spawn_particles
|
||||||
@@ -27,28 +27,28 @@ module TAC
|
|||||||
def spawn_particles
|
def spawn_particles
|
||||||
# !clock_active? &&
|
# !clock_active? &&
|
||||||
if @particles.count < @max_particles && Gosu.milliseconds - @last_spawned >= @interval
|
if @particles.count < @max_particles && Gosu.milliseconds - @last_spawned >= @interval
|
||||||
screen_midpoint = CyberarmEngine::Vector.new($window.width / 2, $window.height / 2)
|
screen_midpoint = CyberarmEngine::Vector.new(CyberarmEngine::Window.instance.width / 2, CyberarmEngine::Window.instance.height / 2)
|
||||||
scale = rand(0.25..1.0)
|
scale = rand(0.25..1.0)
|
||||||
image_name = @image_options.sample
|
image_name = @image_options.sample
|
||||||
|
|
||||||
return unless image_name
|
return unless image_name
|
||||||
|
|
||||||
image = $window.current_state.get_image(image_name)
|
image = CyberarmEngine::Window.instance.current_state.get_image(image_name)
|
||||||
position = CyberarmEngine::Vector.new(0, 0)
|
position = CyberarmEngine::Vector.new(0, 0)
|
||||||
|
|
||||||
r = rand
|
r = rand
|
||||||
if r < 0.25 # LEFT
|
if r < 0.25 # LEFT
|
||||||
position.x = -image.width * scale
|
position.x = -image.width * scale
|
||||||
position.y = rand(0..($window.height - image.height * scale))
|
position.y = rand(0..(CyberarmEngine::Window.instance.height - image.height * scale))
|
||||||
elsif r < 0.5 # RIGHT
|
elsif r < 0.5 # RIGHT
|
||||||
position.x = $window.width + (image.width * scale)
|
position.x = CyberarmEngine::Window.instance.width + (image.width * scale)
|
||||||
position.y = rand(0..($window.height - image.height * scale))
|
position.y = rand(0..(CyberarmEngine::Window.instance.height - image.height * scale))
|
||||||
elsif r < 0.75 # TOP
|
elsif r < 0.75 # TOP
|
||||||
position.x = rand(0..($window.width - image.width * scale))
|
position.x = rand(0..(CyberarmEngine::Window.instance.width - image.width * scale))
|
||||||
position.y = -image.height * scale
|
position.y = -image.height * scale
|
||||||
else #BOTTOM
|
else #BOTTOM
|
||||||
position.x = rand(0..($window.width - image.width * scale))
|
position.x = rand(0..(CyberarmEngine::Window.instance.width - image.width * scale))
|
||||||
position.y = $window.height + image.height * scale
|
position.y = CyberarmEngine::Window.instance.height + image.height * scale
|
||||||
end
|
end
|
||||||
|
|
||||||
position.x ||= 0
|
position.x ||= 0
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def draw
|
def draw
|
||||||
window.previous_state.draw
|
previous_state.draw
|
||||||
|
|
||||||
Gosu.flush
|
Gosu.flush
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
window.previous_state&.update_non_gui
|
previous_state&.update_non_gui
|
||||||
|
|
||||||
@ducks.each { |o| o.update(@size) }
|
@ducks.each { |o| o.update(@size) }
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ module TAC
|
|||||||
|
|
||||||
def handle_handshake(packet)
|
def handle_handshake(packet)
|
||||||
if @host_is_a_connection
|
if @host_is_a_connection
|
||||||
$window.backend.tacnet.client.uuid = packet.body
|
CyberarmEngine::Window.instance.backend.tacnet.client.uuid = packet.body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ module TAC
|
|||||||
def handle_error(packet)
|
def handle_error(packet)
|
||||||
if @host_is_a_connection
|
if @host_is_a_connection
|
||||||
title, message = packet.body.split(Packet::PROTOCOL_SEPERATOR, 2)
|
title, message = packet.body.split(Packet::PROTOCOL_SEPERATOR, 2)
|
||||||
$window.push_state(TAC::Dialog::TACNETDialog, title: title, message: message)
|
CyberarmEngine::Window.instance.push_state(TAC::Dialog::TACNETDialog, title: title, message: message)
|
||||||
else
|
else
|
||||||
log.e(TAG, "Remote error: #{title}: #{message}")
|
log.e(TAG, "Remote error: #{title}: #{message}")
|
||||||
end
|
end
|
||||||
@@ -73,11 +73,11 @@ module TAC
|
|||||||
if data.is_a?(Hash) && data.dig(:config, :spec_version) == TAC::CONFIG_SPEC_VERSION
|
if data.is_a?(Hash) && data.dig(:config, :spec_version) == TAC::CONFIG_SPEC_VERSION
|
||||||
File.open("#{TAC::CONFIGS_PATH}/#{config_name}.json", "w") { |f| f.write json }
|
File.open("#{TAC::CONFIGS_PATH}/#{config_name}.json", "w") { |f| f.write json }
|
||||||
|
|
||||||
if $window.backend.config&.name == config_name
|
if CyberarmEngine::Window.instance.backend.config&.name == config_name
|
||||||
$window.backend.load_config(config_name)
|
CyberarmEngine::Window.instance.backend.load_config(config_name)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
$window.push_state(TAC::Dialog::AlertDialog, title: "Invalid Config", message: "Supported config spec: v#{TAC::CONFIG_SPEC_VERSION} got v#{data.dig(:config, :spec_version)}")
|
CyberarmEngine::Window.instance.push_state(TAC::Dialog::AlertDialog, title: "Invalid Config", message: "Supported config spec: v#{TAC::CONFIG_SPEC_VERSION} got v#{data.dig(:config, :spec_version)}")
|
||||||
end
|
end
|
||||||
|
|
||||||
rescue JSON::ParserError => e
|
rescue JSON::ParserError => e
|
||||||
@@ -97,7 +97,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
if @host_is_a_connection
|
if @host_is_a_connection
|
||||||
$window.backend.tacnet.puts(pkt)
|
CyberarmEngine::Window.instance.backend.tacnet.puts(pkt)
|
||||||
else
|
else
|
||||||
$server.active_client.puts(pkt)
|
$server.active_client.puts(pkt)
|
||||||
end
|
end
|
||||||
@@ -119,20 +119,20 @@ module TAC
|
|||||||
config = Config.new(name)
|
config = Config.new(name)
|
||||||
|
|
||||||
if config.configuration.revision < revision
|
if config.configuration.revision < revision
|
||||||
$window.backend.tacnet.puts( PacketHandler.packet_download_config(name) )
|
CyberarmEngine::Window.instance.backend.tacnet.puts( PacketHandler.packet_download_config(name) )
|
||||||
elsif config.configuration.revision > revision
|
elsif config.configuration.revision > revision
|
||||||
$window.backend.tacnet.puts( PacketHandler.packet_upload_config(name, JSON.dump( config )) )
|
CyberarmEngine::Window.instance.backend.tacnet.puts( PacketHandler.packet_upload_config(name, JSON.dump( config )) )
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
$window.backend.tacnet.puts( PacketHandler.packet_download_config(name) )
|
CyberarmEngine::Window.instance.backend.tacnet.puts( PacketHandler.packet_download_config(name) )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
_diff.each do |name|
|
_diff.each do |name|
|
||||||
config = Config.new(name)
|
config = Config.new(name)
|
||||||
|
|
||||||
$window.backend.tacnet.puts( PacketHandler.packet_upload_config(name, JSON.dump( config )) )
|
CyberarmEngine::Window.instance.backend.tacnet.puts( PacketHandler.packet_upload_config(name, JSON.dump( config )) )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if $server.active_client && $server.active_client.connected?
|
if $server.active_client && $server.active_client.connected?
|
||||||
@@ -144,43 +144,43 @@ module TAC
|
|||||||
def handle_select_config(packet)
|
def handle_select_config(packet)
|
||||||
config_name = packet.body
|
config_name = packet.body
|
||||||
|
|
||||||
$window.backend.settings.config = config_name
|
CyberarmEngine::Window.instance.backend.settings.config = config_name
|
||||||
$window.backend.save_settings
|
CyberarmEngine::Window.instance.backend.save_settings
|
||||||
$window.backend.load_config(config_name)
|
CyberarmEngine::Window.instance.backend.load_config(config_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_add_config(packet)
|
def handle_add_config(packet)
|
||||||
config_name = packet.body
|
config_name = packet.body
|
||||||
|
|
||||||
if $window.backend.configs_list.include?(config_name)
|
if CyberarmEngine::Window.instance.backend.configs_list.include?(config_name)
|
||||||
unless @host_is_a_connection
|
unless @host_is_a_connection
|
||||||
if $server.active_client&.connected?
|
if $server.active_client&.connected?
|
||||||
$server.active_client.puts(PacketHandler.packet_error("Config already exists!", "A config with the name #{config_name} already exists over here."))
|
$server.active_client.puts(PacketHandler.packet_error("Config already exists!", "A config with the name #{config_name} already exists over here."))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
$window.backend.write_new_config(config_name)
|
CyberarmEngine::Window.instance.backend.write_new_config(config_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_update_config(packet)
|
def handle_update_config(packet)
|
||||||
old_config_name, new_config_name = packet.body.split(PROTOCOL_SEPERATOR, 2)
|
old_config_name, new_config_name = packet.body.split(PROTOCOL_SEPERATOR, 2)
|
||||||
|
|
||||||
if $window.backend.configs_list.include?(config_name)
|
if CyberarmEngine::Window.instance.backend.configs_list.include?(config_name)
|
||||||
unless @host_is_a_connection
|
unless @host_is_a_connection
|
||||||
if $server.active_client&.connected?
|
if $server.active_client&.connected?
|
||||||
$server.active_client.puts(PacketHandler.packet_error("Config already exists!", "A config with the name #{config_name} already exists over here."))
|
$server.active_client.puts(PacketHandler.packet_error("Config already exists!", "A config with the name #{config_name} already exists over here."))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
$window.backend.move_config(old_config_name, new_config_name)
|
CyberarmEngine::Window.instance.backend.move_config(old_config_name, new_config_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_delete_config(packet)
|
def handle_delete_config(packet)
|
||||||
config_name = packet.body
|
config_name = packet.body
|
||||||
|
|
||||||
$window.backend.delete_config(config_name)
|
CyberarmEngine::Window.instance.backend.delete_config(config_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.packet_handshake(client_uuid)
|
def self.packet_handshake(client_uuid)
|
||||||
|
|||||||
Reference in New Issue
Block a user