mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 09:12:35 +00:00
Updated gems, added server events to games page
This commit is contained in:
24
Gemfile.lock
24
Gemfile.lock
@@ -3,42 +3,43 @@ GEM
|
|||||||
specs:
|
specs:
|
||||||
addressable (2.8.0)
|
addressable (2.8.0)
|
||||||
public_suffix (>= 2.0.2, < 5.0)
|
public_suffix (>= 2.0.2, < 5.0)
|
||||||
async (1.30.1)
|
async (1.30.2)
|
||||||
console (~> 1.10)
|
console (~> 1.10)
|
||||||
nio4r (~> 2.3)
|
nio4r (~> 2.3)
|
||||||
timers (~> 4.1)
|
timers (~> 4.1)
|
||||||
async-http (0.56.5)
|
async-http (0.56.6)
|
||||||
async (>= 1.25)
|
async (>= 1.25)
|
||||||
async-io (>= 1.28)
|
async-io (>= 1.28)
|
||||||
async-pool (>= 0.2)
|
async-pool (>= 0.2)
|
||||||
protocol-http (~> 0.22.0)
|
protocol-http (~> 0.22.0)
|
||||||
protocol-http1 (~> 0.14.0)
|
protocol-http1 (~> 0.14.0)
|
||||||
protocol-http2 (~> 0.14.0)
|
protocol-http2 (~> 0.14.0)
|
||||||
|
traces (~> 0.4.0)
|
||||||
async-io (1.33.0)
|
async-io (1.33.0)
|
||||||
async
|
async
|
||||||
async-pool (0.3.9)
|
async-pool (0.3.10)
|
||||||
async (>= 1.25)
|
async (>= 1.25)
|
||||||
async-websocket (0.19.0)
|
async-websocket (0.19.0)
|
||||||
async-http (~> 0.54)
|
async-http (~> 0.54)
|
||||||
async-io (~> 1.23)
|
async-io (~> 1.23)
|
||||||
protocol-websocket (~> 0.7.0)
|
protocol-websocket (~> 0.7.0)
|
||||||
clipboard (1.3.6)
|
clipboard (1.3.6)
|
||||||
concurrent-ruby (1.1.9)
|
concurrent-ruby (1.1.10)
|
||||||
console (1.14.0)
|
console (1.15.3)
|
||||||
fiber-local
|
fiber-local
|
||||||
cyberarm_engine (0.20.0)
|
cyberarm_engine (0.21.0)
|
||||||
clipboard (~> 1.3)
|
clipboard (~> 1.3)
|
||||||
excon (~> 0.88)
|
excon (~> 0.88)
|
||||||
gosu (~> 1.1)
|
gosu (~> 1.1)
|
||||||
gosu_more_drawables (~> 0.3)
|
gosu_more_drawables (~> 0.3)
|
||||||
digest-crc (0.6.4)
|
digest-crc (0.6.4)
|
||||||
rake (>= 12.0.0, < 14.0.0)
|
rake (>= 12.0.0, < 14.0.0)
|
||||||
excon (0.92.0)
|
excon (0.92.3)
|
||||||
ffi (1.15.5)
|
ffi (1.15.5)
|
||||||
ffi (1.15.5-x64-mingw-ucrt)
|
ffi (1.15.5-x64-mingw-ucrt)
|
||||||
ffi (1.15.5-x64-mingw32)
|
ffi (1.15.5-x64-mingw32)
|
||||||
fiber-local (1.0.0)
|
fiber-local (1.0.0)
|
||||||
gosu (1.4.1)
|
gosu (1.4.3)
|
||||||
gosu_more_drawables (0.3.1)
|
gosu_more_drawables (0.3.1)
|
||||||
i18n (1.10.0)
|
i18n (1.10.0)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
@@ -46,8 +47,8 @@ GEM
|
|||||||
addressable (~> 2.7)
|
addressable (~> 2.7)
|
||||||
nio4r (2.5.8)
|
nio4r (2.5.8)
|
||||||
protocol-hpack (1.4.2)
|
protocol-hpack (1.4.2)
|
||||||
protocol-http (0.22.5)
|
protocol-http (0.22.6)
|
||||||
protocol-http1 (0.14.2)
|
protocol-http1 (0.14.4)
|
||||||
protocol-http (~> 0.22)
|
protocol-http (~> 0.22)
|
||||||
protocol-http2 (0.14.2)
|
protocol-http2 (0.14.2)
|
||||||
protocol-hpack (~> 1.4)
|
protocol-hpack (~> 1.4)
|
||||||
@@ -55,11 +56,12 @@ GEM
|
|||||||
protocol-websocket (0.7.5)
|
protocol-websocket (0.7.5)
|
||||||
protocol-http (~> 0.2)
|
protocol-http (~> 0.2)
|
||||||
protocol-http1 (~> 0.2)
|
protocol-http1 (~> 0.2)
|
||||||
public_suffix (4.0.6)
|
public_suffix (4.0.7)
|
||||||
rake (13.0.6)
|
rake (13.0.6)
|
||||||
rexml (3.2.5)
|
rexml (3.2.5)
|
||||||
thread-local (1.1.0)
|
thread-local (1.1.0)
|
||||||
timers (4.3.3)
|
timers (4.3.3)
|
||||||
|
traces (0.4.1)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
x64-mingw-ucrt
|
x64-mingw-ucrt
|
||||||
|
|||||||
15
lib/api.rb
15
lib/api.rb
@@ -207,6 +207,21 @@ class W3DHub
|
|||||||
Cache.fetch_package(package, block)
|
Cache.fetch_package(package, block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# /apis/w3dhub/1/get-events
|
||||||
|
#
|
||||||
|
# clients requests events: data={"serverPath":"apb"}
|
||||||
|
def self.events(app_id)
|
||||||
|
body = URI.encode_www_form("data": JSON.dump({ serverPath: app_id }))
|
||||||
|
response = post("#{ENDPOINT}/apis/w3dhub/1/get-server-events", FORM_ENCODED_HEADERS, body)
|
||||||
|
|
||||||
|
if response.success?
|
||||||
|
array = JSON.parse(response.read, symbolize_names: true)
|
||||||
|
array.map { |e| Event.new(e) }
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#! === Server List API === !#
|
#! === Server List API === !#
|
||||||
|
|
||||||
SERVER_LIST_ENDPOINT = "https://gsh.w3dhub.com".freeze
|
SERVER_LIST_ENDPOINT = "https://gsh.w3dhub.com".freeze
|
||||||
|
|||||||
33
lib/api/event.rb
Normal file
33
lib/api/event.rb
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
class W3DHub
|
||||||
|
class Api
|
||||||
|
class Event
|
||||||
|
def initialize(data)
|
||||||
|
@data = data
|
||||||
|
end
|
||||||
|
|
||||||
|
def server
|
||||||
|
@data[:server]
|
||||||
|
end
|
||||||
|
|
||||||
|
def title
|
||||||
|
@data[:title]
|
||||||
|
end
|
||||||
|
|
||||||
|
def start_time
|
||||||
|
@start_time ||= Time.parse(@data[:starttime]).localtime
|
||||||
|
end
|
||||||
|
|
||||||
|
def end_time
|
||||||
|
@end_time ||= Time.parse(@data[:endtime]).localtime
|
||||||
|
end
|
||||||
|
|
||||||
|
def date_time
|
||||||
|
@data[:dateTime]
|
||||||
|
end
|
||||||
|
|
||||||
|
def image
|
||||||
|
@data[:image]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -3,6 +3,7 @@ class W3DHub
|
|||||||
class Games < Page
|
class Games < Page
|
||||||
def setup
|
def setup
|
||||||
@game_news ||= {}
|
@game_news ||= {}
|
||||||
|
@game_events ||= {}
|
||||||
|
|
||||||
# unless Store.offline_mode
|
# unless Store.offline_mode
|
||||||
@focused_game ||= Store.applications.games.find { |g| g.id == Store.settings[:last_selected_app] }
|
@focused_game ||= Store.applications.games.find { |g| g.id == Store.settings[:last_selected_app] }
|
||||||
@@ -212,6 +213,10 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Game Events
|
||||||
|
@game_events_container = flow(width: 1.0, height: 128, padding: 8, visible: false) do
|
||||||
|
end
|
||||||
|
|
||||||
# Game News
|
# Game News
|
||||||
@game_news_container = flow(width: 1.0, fill: true, padding: 8, scroll: true) do
|
@game_news_container = flow(width: 1.0, fill: true, padding: 8, scroll: true) do
|
||||||
# background 0xff_005500
|
# background 0xff_005500
|
||||||
@@ -220,24 +225,40 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return if Cache.net_lock?("game_news_#{game.id}")
|
unless Cache.net_lock?("game_news_#{game.id}")
|
||||||
|
if @game_events[game.id]
|
||||||
if @game_news[game.id]
|
populate_game_events(game)
|
||||||
populate_game_news(game)
|
else
|
||||||
else
|
BackgroundWorker.foreground_job(
|
||||||
@game_news_container.clear do
|
-> { fetch_game_events(game) },
|
||||||
title I18n.t(:"games.fetching_news"), padding: 8
|
lambda do |result|
|
||||||
end
|
if result
|
||||||
|
populate_game_events(game)
|
||||||
BackgroundWorker.foreground_job(
|
Cache.release_net_lock(result)
|
||||||
-> { fetch_game_news(game) },
|
end
|
||||||
lambda do |result|
|
|
||||||
if result
|
|
||||||
populate_game_news(game)
|
|
||||||
Cache.release_net_lock(result)
|
|
||||||
end
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
unless Cache.net_lock?("game_events_#{game.id}")
|
||||||
|
if @game_news[game.id]
|
||||||
|
populate_game_news(game)
|
||||||
|
else
|
||||||
|
@game_news_container.clear do
|
||||||
|
title I18n.t(:"games.fetching_news"), padding: 8
|
||||||
end
|
end
|
||||||
)
|
|
||||||
|
BackgroundWorker.foreground_job(
|
||||||
|
-> { fetch_game_news(game) },
|
||||||
|
lambda do |result|
|
||||||
|
if result
|
||||||
|
populate_game_news(game)
|
||||||
|
Cache.release_net_lock(result)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -344,6 +365,41 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fetch_game_events(game)
|
||||||
|
lock = Cache.acquire_net_lock("game_events_#{game.id}")
|
||||||
|
return false unless lock
|
||||||
|
|
||||||
|
events = Api.events(game.id)
|
||||||
|
Cache.release_net_lock("game_events_#{game.id}") unless events
|
||||||
|
|
||||||
|
return false unless events
|
||||||
|
|
||||||
|
@game_events[game.id] = events
|
||||||
|
|
||||||
|
"game_events_#{game.id}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def populate_game_events(game)
|
||||||
|
return unless @focused_game == game
|
||||||
|
|
||||||
|
if (events = @game_events[game.id])
|
||||||
|
@game_events_container.show unless events.empty?
|
||||||
|
@game_events_container.hide if events.empty?
|
||||||
|
|
||||||
|
@game_events_container.clear do
|
||||||
|
events.flatten.each do |event|
|
||||||
|
stack(width: 300, height: 1.0, margin_left: 8, margin_right: 8, border_thickness: 1, border_color: lighten(Gosu::Color.new(game.color))) do
|
||||||
|
background 0xaa_222222
|
||||||
|
|
||||||
|
title event.title, width: 1.0, text_align: :center
|
||||||
|
tagline event.start_time.strftime("%A"), text_size: 36, width: 1.0, text_align: :center
|
||||||
|
caption event.start_time.strftime("%B %e, %Y %l:%M %p"), width: 1.0, text_align: :center
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def populate_game_modifications(application, channel)
|
def populate_game_modifications(application, channel)
|
||||||
@game_news_container.clear do
|
@game_news_container.clear do
|
||||||
([
|
([
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ require_relative "lib/api/server_list_server"
|
|||||||
require_relative "lib/api/server_list_updater"
|
require_relative "lib/api/server_list_updater"
|
||||||
require_relative "lib/api/account"
|
require_relative "lib/api/account"
|
||||||
require_relative "lib/api/package"
|
require_relative "lib/api/package"
|
||||||
|
require_relative "lib/api/event"
|
||||||
|
|
||||||
require_relative "lib/page"
|
require_relative "lib/page"
|
||||||
# require_relative "lib/pages/games"
|
# require_relative "lib/pages/games"
|
||||||
|
|||||||
Reference in New Issue
Block a user