mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-15 13:32:33 +00:00
Updates to support latest version of CyberarmEngine
This commit is contained in:
@@ -101,7 +101,7 @@ module TAC
|
||||
end
|
||||
|
||||
def refresh_tacnet_status
|
||||
$window.current_state.refresh_tacnet_status
|
||||
CyberarmEngine::Window.instance.current_state.refresh_tacnet_status
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ module TAC
|
||||
|
||||
@title = @options[:title] ? @options[:title] : "#{self.class}"
|
||||
@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
|
||||
# Title bar
|
||||
@@ -122,7 +122,7 @@ module TAC
|
||||
end
|
||||
|
||||
def close
|
||||
$window.pop_state
|
||||
CyberarmEngine::Window.instance.pop_state
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -3,14 +3,14 @@ module TAC
|
||||
class TACNETStatusDialog < Dialog
|
||||
def build
|
||||
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
|
||||
try_commit
|
||||
end
|
||||
|
||||
@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
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ module TAC
|
||||
|
||||
def initialize
|
||||
@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.width # trigger font-eager loading
|
||||
@@ -28,7 +28,7 @@ module TAC
|
||||
end
|
||||
|
||||
def update
|
||||
@title.x = $window.width / 2 - @title.width / 2
|
||||
@title.x = CyberarmEngine::Window.instance.width / 2 - @title.width / 2
|
||||
|
||||
if @controller
|
||||
@text.color = @controller.display_color
|
||||
@@ -38,8 +38,8 @@ module TAC
|
||||
@text.text = "0:00"
|
||||
end
|
||||
|
||||
@text.x = $window.width / 2 - @text.textobject.text_width("0:00") / 2
|
||||
@text.y = $window.height / 2 - @text.height / 2
|
||||
@text.x = CyberarmEngine::Window.instance.width / 2 - @text.textobject.text_width("0:00") / 2
|
||||
@text.y = CyberarmEngine::Window.instance.height / 2 - @text.height / 2
|
||||
|
||||
@controller&.update
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ module TAC
|
||||
end
|
||||
|
||||
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
|
||||
when :full_match
|
||||
@@ -45,7 +45,7 @@ module TAC
|
||||
|
||||
def set_clock_title(string)
|
||||
@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
|
||||
|
||||
def get_clock_title(string)
|
||||
|
||||
@@ -225,7 +225,7 @@ module TAC
|
||||
def handle_shutdown(packet)
|
||||
unless @host_is_a_connection
|
||||
# RemoteControl.server.close
|
||||
# $window.close
|
||||
# CyberarmEngine::Window.instance.close
|
||||
Gosu::Song.current_song&.stop
|
||||
exit
|
||||
end
|
||||
|
||||
@@ -18,7 +18,7 @@ module TAC
|
||||
end
|
||||
|
||||
def update
|
||||
@particles.each { |part| part.update($window.dt) }
|
||||
@particles.each { |part| part.update(CyberarmEngine::Window.instance.dt) }
|
||||
@particles.delete_if { |part| part.die? }
|
||||
|
||||
spawn_particles
|
||||
@@ -27,28 +27,28 @@ module TAC
|
||||
def spawn_particles
|
||||
# !clock_active? &&
|
||||
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)
|
||||
image_name = @image_options.sample
|
||||
|
||||
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)
|
||||
|
||||
r = rand
|
||||
if r < 0.25 # LEFT
|
||||
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
|
||||
position.x = $window.width + (image.width * scale)
|
||||
position.y = rand(0..($window.height - image.height * scale))
|
||||
position.x = CyberarmEngine::Window.instance.width + (image.width * scale)
|
||||
position.y = rand(0..(CyberarmEngine::Window.instance.height - image.height * scale))
|
||||
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
|
||||
else #BOTTOM
|
||||
position.x = rand(0..($window.width - image.width * scale))
|
||||
position.y = $window.height + image.height * scale
|
||||
position.x = rand(0..(CyberarmEngine::Window.instance.width - image.width * scale))
|
||||
position.y = CyberarmEngine::Window.instance.height + image.height * scale
|
||||
end
|
||||
|
||||
position.x ||= 0
|
||||
|
||||
@@ -35,7 +35,7 @@ module TAC
|
||||
end
|
||||
|
||||
def draw
|
||||
window.previous_state.draw
|
||||
previous_state.draw
|
||||
|
||||
Gosu.flush
|
||||
|
||||
@@ -56,7 +56,7 @@ module TAC
|
||||
end
|
||||
|
||||
def update
|
||||
window.previous_state&.update_non_gui
|
||||
previous_state&.update_non_gui
|
||||
|
||||
@ducks.each { |o| o.update(@size) }
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ module TAC
|
||||
|
||||
def handle_handshake(packet)
|
||||
if @host_is_a_connection
|
||||
$window.backend.tacnet.client.uuid = packet.body
|
||||
CyberarmEngine::Window.instance.backend.tacnet.client.uuid = packet.body
|
||||
end
|
||||
end
|
||||
|
||||
@@ -59,7 +59,7 @@ module TAC
|
||||
def handle_error(packet)
|
||||
if @host_is_a_connection
|
||||
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
|
||||
log.e(TAG, "Remote error: #{title}: #{message}")
|
||||
end
|
||||
@@ -73,11 +73,11 @@ module TAC
|
||||
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 }
|
||||
|
||||
if $window.backend.config&.name == config_name
|
||||
$window.backend.load_config(config_name)
|
||||
if CyberarmEngine::Window.instance.backend.config&.name == config_name
|
||||
CyberarmEngine::Window.instance.backend.load_config(config_name)
|
||||
end
|
||||
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
|
||||
|
||||
rescue JSON::ParserError => e
|
||||
@@ -97,7 +97,7 @@ module TAC
|
||||
end
|
||||
|
||||
if @host_is_a_connection
|
||||
$window.backend.tacnet.puts(pkt)
|
||||
CyberarmEngine::Window.instance.backend.tacnet.puts(pkt)
|
||||
else
|
||||
$server.active_client.puts(pkt)
|
||||
end
|
||||
@@ -119,20 +119,20 @@ module TAC
|
||||
config = Config.new(name)
|
||||
|
||||
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
|
||||
$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
|
||||
|
||||
else
|
||||
$window.backend.tacnet.puts( PacketHandler.packet_download_config(name) )
|
||||
CyberarmEngine::Window.instance.backend.tacnet.puts( PacketHandler.packet_download_config(name) )
|
||||
end
|
||||
end
|
||||
|
||||
_diff.each do |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
|
||||
else
|
||||
if $server.active_client && $server.active_client.connected?
|
||||
@@ -144,43 +144,43 @@ module TAC
|
||||
def handle_select_config(packet)
|
||||
config_name = packet.body
|
||||
|
||||
$window.backend.settings.config = config_name
|
||||
$window.backend.save_settings
|
||||
$window.backend.load_config(config_name)
|
||||
CyberarmEngine::Window.instance.backend.settings.config = config_name
|
||||
CyberarmEngine::Window.instance.backend.save_settings
|
||||
CyberarmEngine::Window.instance.backend.load_config(config_name)
|
||||
end
|
||||
|
||||
def handle_add_config(packet)
|
||||
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
|
||||
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."))
|
||||
end
|
||||
end
|
||||
else
|
||||
$window.backend.write_new_config(config_name)
|
||||
CyberarmEngine::Window.instance.backend.write_new_config(config_name)
|
||||
end
|
||||
end
|
||||
|
||||
def handle_update_config(packet)
|
||||
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
|
||||
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."))
|
||||
end
|
||||
end
|
||||
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
|
||||
|
||||
def handle_delete_config(packet)
|
||||
config_name = packet.body
|
||||
|
||||
$window.backend.delete_config(config_name)
|
||||
CyberarmEngine::Window.instance.backend.delete_config(config_name)
|
||||
end
|
||||
|
||||
def self.packet_handshake(client_uuid)
|
||||
|
||||
Reference in New Issue
Block a user