mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-09-19 14:53:49 +00:00
Compare commits
4 Commits
969a82a262
...
915e643a98
| Author | SHA1 | Date | |
|---|---|---|---|
| 915e643a98 | |||
| 6823f9bade | |||
| 8c14ecffc1 | |||
| a7ae460446 |
4
Gemfile
4
Gemfile
@@ -8,7 +8,8 @@ gem "json"
|
||||
|
||||
# "game" library gem
|
||||
gem "cyberarm_engine"
|
||||
gem "sdl2-bindings"
|
||||
gem "sdl3-bindings"
|
||||
gem "gosu", '1.5.0' # temporary, manually built, stand-in for SDL3 supporting gosu
|
||||
|
||||
# networking libs
|
||||
gem "async"
|
||||
@@ -19,3 +20,4 @@ gem "async-websocket"
|
||||
gem "digest-crc"
|
||||
gem "ircparser"
|
||||
gem "rubyzip"
|
||||
gem "chunky_png"
|
||||
|
||||
107
Gemfile.lock
107
Gemfile.lock
@@ -1,24 +1,20 @@
|
||||
GEM
|
||||
remote: https://gem.coop/
|
||||
specs:
|
||||
async (2.39.0)
|
||||
async (2.45.1)
|
||||
console (~> 1.29)
|
||||
fiber-annotation
|
||||
io-event (~> 1.11)
|
||||
metrics (~> 0.12)
|
||||
traces (~> 0.18)
|
||||
async-http (0.95.1)
|
||||
async (>= 2.10.2)
|
||||
async-pool (~> 0.11)
|
||||
io-endpoint (~> 0.14)
|
||||
io-stream (~> 0.6)
|
||||
metrics (~> 0.12)
|
||||
protocol-http (~> 0.62)
|
||||
protocol-http1 (~> 0.39)
|
||||
protocol-http2 (~> 0.26)
|
||||
io-event (~> 1.21)
|
||||
async-http (0.103.0)
|
||||
async (>= 2.35.1)
|
||||
async-pool (~> 0.12)
|
||||
io-endpoint (~> 0.18)
|
||||
io-stream (~> 0.14)
|
||||
protocol-http (~> 0.66)
|
||||
protocol-http1 (~> 0.41)
|
||||
protocol-http2 (~> 0.28)
|
||||
protocol-url (~> 0.2)
|
||||
traces (~> 0.10)
|
||||
async-pool (0.11.2)
|
||||
async-pool (0.12.0)
|
||||
async (>= 2.0)
|
||||
async-websocket (0.30.1)
|
||||
async-http (~> 0.76)
|
||||
@@ -26,7 +22,8 @@ GEM
|
||||
protocol-rack (~> 0.7)
|
||||
protocol-websocket (~> 0.17)
|
||||
base64 (0.3.0)
|
||||
console (1.36.0)
|
||||
chunky_png (1.4.0)
|
||||
console (1.37.0)
|
||||
fiber-annotation
|
||||
fiber-local (~> 1.1)
|
||||
json
|
||||
@@ -39,35 +36,37 @@ GEM
|
||||
fiber-local (1.1.0)
|
||||
fiber-storage
|
||||
fiber-storage (1.0.1)
|
||||
gosu (1.4.6)
|
||||
io-endpoint (0.17.2)
|
||||
io-event (1.16.2)
|
||||
io-stream (0.13.1)
|
||||
gosu (1.5.0-x86_64-linux)
|
||||
ffi (~> 1.12)
|
||||
io-endpoint (0.18.0)
|
||||
openssl (>= 3.3.0)
|
||||
io-event (1.21.1)
|
||||
io-stream (0.14.0)
|
||||
openssl (>= 3.3)
|
||||
ircparser (1.0.0)
|
||||
json (2.19.9)
|
||||
json (3.0.1)
|
||||
logger (1.7.0)
|
||||
metrics (0.15.0)
|
||||
openssl (4.0.2)
|
||||
protocol-hpack (1.5.1)
|
||||
protocol-http (0.62.2)
|
||||
protocol-http1 (0.39.0)
|
||||
protocol-http (~> 0.62)
|
||||
protocol-http2 (0.26.0)
|
||||
protocol-http (0.71.0)
|
||||
protocol-http1 (0.41.0)
|
||||
protocol-http (~> 0.68)
|
||||
protocol-http2 (0.28.0)
|
||||
protocol-hpack (~> 1.4)
|
||||
protocol-http (~> 0.62)
|
||||
protocol-rack (0.22.1)
|
||||
io-stream (>= 0.10)
|
||||
protocol-http (~> 0.58)
|
||||
rack (>= 1.0)
|
||||
protocol-url (0.4.0)
|
||||
protocol-websocket (0.21.1)
|
||||
protocol-url (0.19.0)
|
||||
protocol-websocket (0.21.2)
|
||||
protocol-http (~> 0.2)
|
||||
rack (3.2.6)
|
||||
rack (3.2.7)
|
||||
rake (13.4.2)
|
||||
rexml (3.4.4)
|
||||
rubyzip (3.4.0)
|
||||
sdl2-bindings (0.2.3)
|
||||
ffi (~> 1.15)
|
||||
traces (0.18.2)
|
||||
rubyzip (3.6.0)
|
||||
sdl3-bindings (1.0.4)
|
||||
ffi (~> 1.16)
|
||||
|
||||
PLATFORMS
|
||||
x86_64-linux
|
||||
@@ -77,49 +76,51 @@ DEPENDENCIES
|
||||
async-http
|
||||
async-websocket
|
||||
base64
|
||||
chunky_png
|
||||
cyberarm_engine
|
||||
digest-crc
|
||||
gosu (= 1.5.0)
|
||||
ircparser
|
||||
json
|
||||
logger
|
||||
rexml
|
||||
rubyzip
|
||||
sdl2-bindings
|
||||
sdl3-bindings
|
||||
|
||||
CHECKSUMS
|
||||
async (2.39.0) sha256=df18730073f2bbb45788077dfa20cb365ecc1b9453969f44de6796b5191a00aa
|
||||
async-http (0.95.1) sha256=0c3dd458c204c06d5c4b20b01bbec4794a1203db627fb2ce536e1799ec14786c
|
||||
async-pool (0.11.2) sha256=0a43a17b02b04d9c451b7d12fafa9a50e55dc6dd00d4369aca00433f16a7e3ed
|
||||
async (2.45.1) sha256=95849f7432eca535146c69f3078dab3c7228d0075ed71f48733f3e585dd7c267
|
||||
async-http (0.103.0) sha256=137e3d5d419f7d72d5fa33cf04f30232e79c57b690025a650b8f9e48ece8bc41
|
||||
async-pool (0.12.0) sha256=5580493dc024bd704dab2ed0bf1307100722e49cbb825c7965f8501194f58506
|
||||
async-websocket (0.30.1) sha256=54bb8a8f184e4aa64434c7a78ecc55850a67a3d1dcd02e3ae787376e2c673936
|
||||
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
|
||||
console (1.36.0) sha256=45599ea906cf80a73d8941f03abf873fe66a6a954e0bac5bc1c01e2cdc406f07
|
||||
chunky_png (1.4.0) sha256=89d5b31b55c0cf4da3cf89a2b4ebc3178d8abe8cbaf116a1dba95668502fdcfe
|
||||
console (1.37.0) sha256=8093b286c2595a063849c098594fee5155ecc7967d36f3aa8cbe7569c8f3efd7
|
||||
cyberarm_engine (0.25.1) sha256=6f851a2ed0a32bdd25fc619172b546a8e26eefeb13a62c509f226337170d0efe
|
||||
digest-crc (0.7.0) sha256=64adc23a26a241044cbe6732477ca1b3c281d79e2240bcff275a37a5a0d78c07
|
||||
ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d
|
||||
fiber-annotation (0.2.0) sha256=7abfadf1d119f508867d4103bf231c0354d019cc39a5738945dec2edadaf6c03
|
||||
fiber-local (1.1.0) sha256=c885f94f210fb9b05737de65d511136ea602e00c5105953748aa0f8793489f06
|
||||
fiber-storage (1.0.1) sha256=f48e5b6d8b0be96dac486332b55cee82240057065dc761c1ea692b2e719240e1
|
||||
gosu (1.4.6) sha256=80c7fa48cf61f4960ef067fdd1c000d98b4adc8e11faeaa486543d00908a5c15
|
||||
io-endpoint (0.17.2) sha256=3feaf766c116b35839c11fac68b6aaadc47887bb488902a57bf8e1d288fb3338
|
||||
io-event (1.16.2) sha256=9f9cb0a96ea5c3850a672606c65f27bc96d7621399ef6196acbfe2be0cd1279c
|
||||
io-stream (0.13.1) sha256=570d7c4dfb0fbd767480b4a222048a2be6d9b78febc1ec68258d0e0a4cde20de
|
||||
gosu (1.5.0-x86_64-linux)
|
||||
io-endpoint (0.18.0) sha256=720d186bcd584e8ba490bfc91dab332cc3c5ffee848b5b03894555cb275151aa
|
||||
io-event (1.21.1) sha256=b3088f89ad67edf9be9fc2f48a5fae0790e92862487551eeb337b49098eb99e6
|
||||
io-stream (0.14.0) sha256=07d9b13ea2066ccbbc761fff8d69ad5a31e47561d31e02cc271f3ed9c1a8f1cd
|
||||
ircparser (1.0.0) sha256=0d4598f691172e2ad078207c50ba62c0d3428ae841836b0a682e6cd01d62878d
|
||||
json (2.19.9) sha256=9b9025b7cdddafa38d316eca0b2358488e42d417045c1b90d216a9fefe46b79a
|
||||
json (3.0.1) sha256=c80f74a3570c3a310cd41c526904e7ef8363abdece4432f31fe97d812bc4a39e
|
||||
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
|
||||
metrics (0.15.0) sha256=61ded5bac95118e995b1bc9ed4a5f19bc9814928a312a85b200abbdac9039072
|
||||
openssl (4.0.2) sha256=1037ad2868ae58df9ad917891c0c0f9815a1172f6846d4bcdd508e4c2ee747c2
|
||||
protocol-hpack (1.5.1) sha256=6feca238b8078da1cd295677d6f306c6001af92d75fe0643d33e6956cbc3ad91
|
||||
protocol-http (0.62.2) sha256=e1c1f2f56029c1af8c4e2b8a67d0d096c76620f3afd8d99d1dcd2f6b8ffa773b
|
||||
protocol-http1 (0.39.0) sha256=e49b3f4cda6f5d94c76a323d2b7f6977cba3ebd082d2da437039594da77ad8eb
|
||||
protocol-http2 (0.26.0) sha256=bac89cd78082b241ccd0cf7246f5160e4bb0c9c975fb4bf7deef5f88cc317486
|
||||
protocol-http (0.71.0) sha256=38577bf3df0bf0c3f7ee7e21b43fcb4bd7624e36f697dbe9c3eea344f14bd9ba
|
||||
protocol-http1 (0.41.0) sha256=9863874a1228948a896c3e7ea16d13a680c8f3ed50706007c78b7033018b0ea3
|
||||
protocol-http2 (0.28.0) sha256=b7c6195dcfa80ec2484670e9fd8fc21024cc654a391aa0792433aff1188c1691
|
||||
protocol-rack (0.22.1) sha256=1185d245927ef9849a603700d6991ca353bc89724fbf98efa4a4333ed62a9fc3
|
||||
protocol-url (0.4.0) sha256=64d4c03b6b51ad815ac6fdaf77a1d91e5baf9220d26becb846c5459dacdea9e1
|
||||
protocol-websocket (0.21.1) sha256=34325e4325697f0956877e67784bcc838cfd51ebbf4f8e9e5201be292041ee61
|
||||
rack (3.2.6) sha256=5ed78e1f73b2e25679bec7d45ee2d4483cc4146eb1be0264fc4d94cb5ef212c2
|
||||
protocol-url (0.19.0) sha256=3f6b9f6aa742a259a0b3610fbbd9685dcd9506adf6734f428ff96259faabfb21
|
||||
protocol-websocket (0.21.2) sha256=cbe35be8e045597b221874fba5928d7cd2483884126e3e36faece4741dc88eb7
|
||||
rack (3.2.7) sha256=93e13e1c24f93556671d85d2d79fa228c3485815c50d7e2f265b5330c6528fb7
|
||||
rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
|
||||
rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142
|
||||
rubyzip (3.4.0) sha256=6de39bc9eba302b635a476d16c9e16b0872ad24517c2f98f2b3a7ea23caff57b
|
||||
sdl2-bindings (0.2.3) sha256=878c0755a4bea1aed0fa85c01596effd1c2b7d1878141ceec5bef808038bd309
|
||||
traces (0.18.2) sha256=80f1649cb4daace1d7174b81f3b3b7427af0b93047759ba349960cb8f315e214
|
||||
rubyzip (3.6.0) sha256=268994d44d62282d1cfd99bf10eae48d7267199158ad7ea3e1fee2da9458b695
|
||||
sdl3-bindings (1.0.4) sha256=326f497c30e6a5cab402e6178403b30c9df4a11a4e109e08c5da6e920c7bb55b
|
||||
|
||||
BUNDLED WITH
|
||||
4.0.8
|
||||
|
||||
36
lib/gosu_ext.rb
Normal file
36
lib/gosu_ext.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
module Gosu
|
||||
# ! nonblocking
|
||||
def self.choose_file(&block)
|
||||
callback_id = "gc_protect_#{Gosu.milliseconds}"
|
||||
|
||||
callback = lambda do |user_data, file_list, filter|
|
||||
data = nil
|
||||
|
||||
if file_list
|
||||
data = file_list.read_array_of_string
|
||||
end
|
||||
|
||||
block.call(data)
|
||||
|
||||
W3DHubLauncher::MemCache.delete(callback_id)
|
||||
end
|
||||
|
||||
W3DHubLauncher::MemCache[callback_id] = callback
|
||||
|
||||
SDL.ShowOpenFileDialog(
|
||||
callback,
|
||||
nil,
|
||||
CyberarmEngine::Window.instance.sdl_window,
|
||||
nil,
|
||||
0,
|
||||
W3DHubLauncher::CACHE_PATH,
|
||||
false
|
||||
)
|
||||
end
|
||||
|
||||
def self.choose_folder()
|
||||
end
|
||||
|
||||
def self.save_file()
|
||||
end
|
||||
end
|
||||
@@ -122,7 +122,8 @@ module W3DHubLauncher
|
||||
end
|
||||
end
|
||||
|
||||
Gosu::Image.from_blob(image.width, image.height, blob)
|
||||
# Gosu::Image.from_blob(image.width, image.height, blob)
|
||||
ChunkyPNG::Canvas.from_rgba_stream(image.width, image.height, blob)
|
||||
end
|
||||
|
||||
def image_data(image)
|
||||
|
||||
@@ -6,6 +6,8 @@ module W3DHubLauncher
|
||||
def setup
|
||||
@games_filter = []
|
||||
|
||||
CyberarmEngine::EventBus.subscribe("game_server_pings", self, :handle_game_server_pings)
|
||||
|
||||
# game bar container
|
||||
flow(width: 1.0, height: 60) do
|
||||
widget(width: 220, height: 1.0, style_class: [:all_button]) do |w|
|
||||
@@ -49,9 +51,17 @@ module W3DHubLauncher
|
||||
populate_server_list
|
||||
end
|
||||
|
||||
def blur
|
||||
CyberarmEngine::EventBus.unsubscribe("game_server_pings", self)
|
||||
end
|
||||
|
||||
def handle_game_server_pings(payload)
|
||||
# TODO: Update displayed server ping
|
||||
end
|
||||
|
||||
def populate_server_list
|
||||
@servers_container.clear do
|
||||
(MemCache[:servers] || []).select { |s| @games_filter.empty? ? true : @games_filter.include?(s.game) }.sort_by { |s| s.player_count }.reverse.each do |server|
|
||||
(MemCache[:servers] || []).select { |s| @games_filter.empty? ? true : @games_filter.include?(s.game) }.sort_by { |s| [s.player_count, -s.ping] }.reverse.each do |server|
|
||||
app = MemCache[:applications].find { |a| a.id == server.game }
|
||||
|
||||
widget(width: 1.0, height: 48, padding_top: HALF_PADDING, padding_bottom: HALF_PADDING, margin_bottom: HALF_PADDING, background_nine_slice: NINE_SLICE_ROUNDED, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: server.channel == "release" ? ALPHA_GRAY : 0xaa_c64600, hover: { background_nine_slice_color: 0xff_5e5c64 } , active: { background_nine_slice_color: 0xaa_5e5c64 }) do
|
||||
@@ -87,10 +97,10 @@ module W3DHubLauncher
|
||||
# server ping
|
||||
flow(width: 96, height: 1.0, margin_left: HALF_PADDING, margin_right: HALF_PADDING) do
|
||||
stack(fill: true, height: 1.0, v_align: :center) do
|
||||
caption rand > 0.85 ? "?" : format("%d ms", rand(16..360)), width: 1.0, text_align: :center
|
||||
caption server.ping == Worker::Api::GameServer::BAD_OR_UNKNOWN_PING ? "?" : server.ping, width: 1.0, text_align: :center, tip: server.ping == Worker::Api::GameServer::BAD_OR_UNKNOWN_PING ? "Server has not replied yet or did not reply to ICMP Echo Request.\nPing unknown." : ""
|
||||
inscription "ping", text_wrap: :none, width: 1.0, text_align: :center, margin_top: -HALF_PADDING
|
||||
end
|
||||
stack(width: 8, height: rand(0.25..1.0), v_align: :center, min_height: 8, background_nine_slice: NINE_SLICE_ROUNDED_SMALL, background_nine_slice_from_edge: NINE_SLICE_EDGE_SMALL, background_nine_slice_color: [0xff_26a269, 0xff_e5a50a, 0xff_a51d2d, 0xff_3d3846].sample)
|
||||
stack(width: 8, height: server.ping_score_ratio, v_align: :center, min_height: 8, background_nine_slice: NINE_SLICE_ROUNDED_SMALL, background_nine_slice_from_edge: NINE_SLICE_EDGE_SMALL, background_nine_slice_color: server.ping_score_color)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,6 +6,10 @@ module W3DHubLauncher
|
||||
|
||||
@main_thread_queue = []
|
||||
|
||||
CyberarmEngine::EventBus.subscribe("game_server_pings", self) do |payload|
|
||||
MemCache[:game_server_pings] = payload
|
||||
end
|
||||
|
||||
push_state(States::Boot)
|
||||
# push_state(States::Interface)
|
||||
end
|
||||
|
||||
@@ -4,6 +4,7 @@ module W3DHubLauncher
|
||||
["user-agent", W3DHubLauncher::USER_AGENT]
|
||||
].freeze
|
||||
DEFAULT_NETWORK_TIMEOUT = 30
|
||||
RESPONSE_SEPARATOR = "\04".freeze
|
||||
|
||||
Response = Data.define(:status, :request_id, :result)
|
||||
|
||||
@@ -13,6 +14,7 @@ module W3DHubLauncher
|
||||
def connect
|
||||
puts :connect
|
||||
|
||||
@buffer = StringIO.new
|
||||
@socket = UNIXSocket.new(IPC_PATH)
|
||||
end
|
||||
|
||||
@@ -28,6 +30,8 @@ module W3DHubLauncher
|
||||
@threads = []
|
||||
@requests = []
|
||||
|
||||
@client = nil
|
||||
|
||||
@settings = 0# Settings.new
|
||||
@game_servers = []
|
||||
@host_pings = {}
|
||||
@@ -44,6 +48,8 @@ module W3DHubLauncher
|
||||
Async do |task|
|
||||
UNIXServer.open(IPC_PATH) do |server|
|
||||
while(socket = server.accept)
|
||||
@client = socket
|
||||
|
||||
task.async do
|
||||
while(data = socket.gets)
|
||||
json = JSON.parse(data)
|
||||
@@ -55,7 +61,9 @@ module W3DHubLauncher
|
||||
response = send(query.type, query)
|
||||
# pp [:server_to_client, response]
|
||||
payload = { status: response.status, request_id: response.request_id, data: response.result.data, error: response.result.error }.to_json
|
||||
socket.puts(payload)
|
||||
socket.write(payload)
|
||||
socket.write(RESPONSE_SEPARATOR)
|
||||
socket.flush
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -111,6 +119,8 @@ module W3DHubLauncher
|
||||
# puts "Timed out waiting for: #{echo_requests.values.select { |v| v[:replied] == false }.map { |v| v[:address] }.join(', ')}"
|
||||
end
|
||||
|
||||
broadcast(:game_server_pings, data: @host_pings)
|
||||
|
||||
sleep 5
|
||||
end
|
||||
end
|
||||
@@ -119,6 +129,14 @@ module W3DHubLauncher
|
||||
socket&.close
|
||||
end
|
||||
|
||||
def broadcast(type, data:)
|
||||
payload = { type: :eventbus, request_id: -1, data: { type: type, data: data } }.to_json
|
||||
|
||||
@client&.write(payload)
|
||||
@client&.write(RESPONSE_SEPARATOR)
|
||||
@client&.flush
|
||||
end
|
||||
|
||||
# Send request to server
|
||||
def request(query)
|
||||
# pp [:client_request, query]
|
||||
@@ -133,22 +151,36 @@ module W3DHubLauncher
|
||||
|
||||
def service
|
||||
data = @socket.read_nonblock(1_048_576) # 1 MB
|
||||
# pp [:CLIENT, data]
|
||||
json = JSON.parse(data)
|
||||
request = W3DHubLauncher::Worker::Request.requests.find { |r| r.request_id == json["request_id"] }
|
||||
@buffer << data
|
||||
|
||||
# pp [json, request]
|
||||
return unless request
|
||||
@buffer.rewind
|
||||
payloads = @buffer.readlines(RESPONSE_SEPARATOR, chomp: true)
|
||||
@buffer.reopen(@buffer.string[@buffer.pos..@buffer.length])
|
||||
@buffer.pos = @buffer.length
|
||||
|
||||
CyberarmEngine::Window.instance&.add_to_queue(proc {
|
||||
request.handle_event(
|
||||
json["status"],
|
||||
CyberarmEngine::Result.new(data: json["data"], error: json["error"])
|
||||
)
|
||||
})
|
||||
payloads.each do |payload|
|
||||
# pp [:CLIENT, data]
|
||||
json = JSON.parse(payload)
|
||||
request = W3DHubLauncher::Worker::Request.requests.find { |r| r.request_id == json["request_id"] }
|
||||
|
||||
rescue JSON::ParserError => e
|
||||
puts "This should never happen!?!?!"
|
||||
# pp [json, request]
|
||||
if request.nil? && json["request_id"] && json["type"] == "eventbus"
|
||||
CyberarmEngine::Window.instance&.add_to_queue(proc {
|
||||
CyberarmEngine::EventBus.publish(json["data"]["type"], json["data"]["data"])
|
||||
})
|
||||
else
|
||||
CyberarmEngine::Window.instance&.add_to_queue(proc {
|
||||
request.handle_event(
|
||||
json["status"],
|
||||
CyberarmEngine::Result.new(data: json["data"], error: json["error"])
|
||||
)
|
||||
})
|
||||
end
|
||||
|
||||
rescue JSON::ParserError => e
|
||||
puts "This should never happen!?!?!"
|
||||
pp data, payload
|
||||
end
|
||||
|
||||
rescue Errno::EWOULDBLOCK
|
||||
end
|
||||
|
||||
@@ -3,6 +3,8 @@ module W3DHubLauncher
|
||||
class Api
|
||||
# Designed to work with cyberarm's Game Server Hub service data, may work with W3D Hub's service with degraded metadata.
|
||||
class GameServer
|
||||
BAD_OR_UNKNOWN_PING = 1_000_000
|
||||
|
||||
attr_reader :id, :game, :channel, :address, :port, :region,
|
||||
:name, :password, :current_map, :player_count, :max_players,
|
||||
:match_start_time, :estimated_end_time, :match_remaining_time,
|
||||
@@ -55,6 +57,35 @@ module W3DHubLauncher
|
||||
def password?
|
||||
@password
|
||||
end
|
||||
|
||||
def ping
|
||||
MemCache.dig(:game_server_pings, @address) || BAD_OR_UNKNOWN_PING
|
||||
end
|
||||
|
||||
def ping_score_ratio
|
||||
# under 50 is best, over 200 is worst
|
||||
case ping
|
||||
when 0..49
|
||||
return 1.0
|
||||
when 50..200
|
||||
1.0 - (ping / 200.0) + 0.1
|
||||
else
|
||||
return 0.1
|
||||
end
|
||||
end
|
||||
|
||||
def ping_score_color
|
||||
case ping
|
||||
when 0..49 # gentle green
|
||||
0xff_26a269
|
||||
when 50..149 # rich orange
|
||||
0xff_e5a50a
|
||||
when 150..200 # dark red
|
||||
0xff_a51d2d
|
||||
else # dark gray
|
||||
0xff_3d3846
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Team
|
||||
|
||||
@@ -18,6 +18,10 @@ require "async/websocket"
|
||||
require "digest/crc"
|
||||
require "ircparser"
|
||||
require "zip"
|
||||
require "chunky_png"
|
||||
require "sdl3"
|
||||
|
||||
require_relative "lib/gosu_ext"
|
||||
|
||||
require_relative "lib/version"
|
||||
require_relative "lib/constants"
|
||||
@@ -68,6 +72,13 @@ module W3DHubLauncher
|
||||
WORKER.connect
|
||||
end
|
||||
|
||||
SDL.load_lib("SDL3")
|
||||
|
||||
window = W3DHubLauncher::Window.new(width: 1280, height: 800, resizable: true)
|
||||
# window = W3DHubLauncher::Window.new(width: 1920, height: 1080, resizable: true)
|
||||
|
||||
# Gosu.choose_file do |files|
|
||||
# pp files
|
||||
# end
|
||||
|
||||
window.show
|
||||
|
||||
Reference in New Issue
Block a user