Compare commits

..

3 Commits

13 changed files with 291 additions and 41 deletions

View File

@@ -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

View File

@@ -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
View 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

View File

@@ -306,7 +306,7 @@ class W3DHub
install_directory = Cache.install_path(task.application, task.channel) install_directory = Cache.install_path(task.application, task.channel)
application_data = { application_data = {
install_directory: install_directory, install_directory: install_directory,
installed_version: task.channel.current_version, installed_version: task.target_version,
install_path: "#{install_directory}/game.exe", install_path: "#{install_directory}/game.exe",
wine_prefix: task.wine_prefix wine_prefix: task.wine_prefix
} }

View File

@@ -8,7 +8,7 @@ class W3DHub
include CyberarmEngine::Common include CyberarmEngine::Common
attr_reader :app_id, :release_channel, :application, :channel, attr_reader :app_id, :release_channel, :application, :channel, :target_version,
:manifests, :packages, :files, :wine_prefix, :status :manifests, :packages, :files, :wine_prefix, :status
def initialize(app_id, release_channel) def initialize(app_id, release_channel)
@@ -20,6 +20,8 @@ class W3DHub
@application = Store.applications.games.find { |g| g.id == app_id } @application = Store.applications.games.find { |g| g.id == app_id }
@channel = @application.channels.find { |c| c.id == release_channel } @channel = @application.channels.find { |c| c.id == release_channel }
@target_version = type == :repairer ? Store.settings[:games][:"#{app_id}_#{@channel.id}"][:installed_version] : @channel.current_state
@packages_to_download = [] @packages_to_download = []
@total_bytes_to_download = -1 @total_bytes_to_download = -1
@bytes_downloaded = -1 @bytes_downloaded = -1
@@ -203,8 +205,8 @@ class W3DHub
@status.step = :fetching_manifests @status.step = :fetching_manifests
if fetch_manifest("games", app_id, "manifest.xml", @channel.current_version) if fetch_manifest("games", app_id, "manifest.xml", @target_version)
manifest = load_manifest("games", app_id, "manifest.xml", @channel.current_version) manifest = load_manifest("games", app_id, "manifest.xml", @target_version)
@manifests << manifest @manifests << manifest
until(manifest.full?) until(manifest.full?)

View File

@@ -33,7 +33,7 @@ class W3DHub
stack(margin_left: 8, width: 0.75) do stack(margin_left: 8, width: 0.75) do
@application_name_label = tagline "#{task.application.name}" @application_name_label = tagline "#{task.application.name}"
@application_version_label = inscription "Version: #{task.channel.current_version} (#{task.channel.id})" @application_version_label = inscription "Version: #{task.target_version} (#{task.channel.id})"
end end
end end

View File

@@ -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
([ ([

View File

@@ -84,11 +84,11 @@ class W3DHub
def language_code(string) def language_code(string)
case string.downcase.strip case string.downcase.strip
when "german" when "deutsch"
"de" "de"
when "french" when "français"
"fr" "fr"
when "spanish" when "español"
"es" "es"
else else
"en" "en"
@@ -100,9 +100,11 @@ class W3DHub
when "en" when "en"
"English" "English"
when "de" when "de"
"German" "Deutsch"
when "fr" when "fr"
"French" "Français"
when "es"
"Español"
else else
raise "Unknown language error" raise "Unknown language error"
end end

View File

@@ -34,10 +34,14 @@ class W3DHub
end end
def gain_focus def gain_focus
super
self.update_interval = 1000.0 / 60 self.update_interval = 1000.0 / 60
end end
def lose_focus def lose_focus
super
self.update_interval = 1000.0 / 10 self.update_interval = 1000.0 / 10
end end

View File

@@ -1,9 +1,10 @@
---
en: en:
app_name: Cyberarm's Linux Friendly W3D Hub Launcher # W3D Hub Launcher app_name: Cyberarm's Linux Friendly W3D Hub Launcher
app_name_simple: W3D Hub Linux Launcher app_name_simple: W3D Hub Linux Launcher
boot: boot:
w3dhub_service_is_down: W3D Hub service is down. w3dhub_service_is_down: W3D Hub service is down.
checking_for_updates: Checking for updates... checking_for_updates: Checking for updates
interface: interface:
log_in: Log in log_in: Log in
register: Register register: Register
@@ -18,6 +19,8 @@ en:
downloads: Downloads downloads: Downloads
play_now: Play Now play_now: Play Now
play: Play play: Play
join_now: Join Now
join: Join
install_update: Install Update install_update: Install Update
single_player: Single Player single_player: Single Player
import: Import import: Import
@@ -36,7 +39,7 @@ en:
user_data_folder: User Data Folder user_data_folder: User Data Folder
view_screenshots: View Screenshots view_screenshots: View Screenshots
read_more: Read More read_more: Read More
fetching_news: Fetching news... fetching_news: Fetching news
channel: Channel channel: Channel
version: Version version: Version
server_browser: server_browser:
@@ -48,7 +51,7 @@ en:
max_players: Max Players max_players: Max Players
filters: Filters filters: Filters
region: Region region: Region
fetching_server_list: Fetching server list... fetching_server_list: Fetching server list
no_server_selected: No server selected no_server_selected: No server selected
hostname: Hostname hostname: Hostname
current_map: Current Map current_map: Current Map

71
locales/generate.rb Normal file
View File

@@ -0,0 +1,71 @@
require "csv"
require "yaml"
PATH = File.expand_path(".", __dir__)
TRANSLATIONS_PATH = "#{PATH}/translations.csv".freeze
puts "Loading translations.csv [Using ■ as column seperator]"
TRANSLATIONS = {}
LANGUAGES = []
i = 0
CSV.foreach("#{PATH}/translations.csv", col_sep: "") do |row|
key = row.delete(row.first)
if i.zero?
row.map { |language| language.split("-").first.downcase }.each do |language|
TRANSLATIONS[language] ||= {}
LANGUAGES << language
end
else
row.each_with_index do |translation, lang_id|
next unless translation
next if key.empty? || key.nil?
hash = TRANSLATIONS[LANGUAGES[lang_id]]
parts = key.split(".")
parts_size = parts.size
key = parts.delete(parts.last) if parts.size > 1
if parts_size > 1
parts.each do |part|
hash = hash[part] ||= {}
end
end
hash[key] = translation
end
end
i += 1
end
puts "Done."
puts
puts "Removing existing translations..."
Dir.glob("#{PATH}/*.yml") do |file|
File.delete(file)
end
puts "Done."
puts
puts "Writing out translations..."
written_languages = []
LANGUAGES.each do |language|
translations = TRANSLATIONS[language]
next unless translations.size.positive?
yaml = YAML.dump({ language => translations })
written_languages << language
File.write("#{PATH}/#{language}.yml", yaml)
end
puts "Done."
puts
puts "Wrote translations for: #{written_languages.join(', ')}"

61
locales/translations.csv Normal file
View File

@@ -0,0 +1,61 @@
__KEY__■EN-ENGLISH■DE-GERMAN■FR-FRENCH■ES-SPANISH■KO-KOREAN■JA-JAPANESE■ZH-CHINESE
app_name■Cyberarm's Linux Friendly W3D Hub Launcher■■■■■■
app_name_simple■W3D Hub Linux Launcher■■■■■■
boot.w3dhub_service_is_down■W3D Hub service is down.■■■■■■
boot.checking_for_updates■Checking for updates…■■■■■■
interface.log_in■Log in■■■■■■
interface.register■Register■■■■■■
interface.log_out■Log out■■■■■■
interface.not_logged_in■Not Logged In■■■■■■
interface.profile■Profile■■■■■■
interface.games■Games■■■■■■
interface.server_browser■Server Browser■■■■■■
interface.servers■Servers■■■■■■
interface.community■Community■■■■■■
interface.download_manager■Download Manager■■■■■■
interface.downloads■Downloads■■■■■■
interface.play_now■Play Now■■■■■■
interface.play■Play■■■■■■
interface.join_now■Join Now■■■■■■
interface.join■Join■■■■■■
interface.install_update■Install Update■■■■■■
interface.single_player■Single Player■■■■■■
interface.import■Import■■■■■■
interface.install■Install■■■■■■
interface.app_settings_tip■W3D Hub Launcher Settings■■■■■■
interface.settings■Settings■■■■■■
games.game_settings■Game Settings■■■■■■
games.game_options■Game Options■■■■■■
games.game_version■Game Version■■■■■■
games.wine_configuration■Wine Configuration■■■■■■
games.game_modifications■Game Modifications■■■■■■
games.repair_installation■Repair Installation■■■■■■
games.uninstall_game■Uninstall Game■■■■■■
games.install_folder■Install Folder■■■■■■
games.user_data_folder■User Data Folder■■■■■■
games.view_screenshots■View Screenshots■■■■■■
games.read_more■Read More■■■■■■
games.fetching_news■Fetching news…■■■■■■
games.channel■Channel■■■■■■
games.version■Version■■■■■■
server_browser.direct_connect■Direct Connect■■■■■■
server_browser.refresh■Refresh■■■■■■
server_browser.join_server■Join Server■■■■■■
server_browser.game■Game■■■■■■
server_browser.map■Map■■■■■■
server_browser.max_players■Max Players■■■■■■
server_browser.filters■Filters■■■■■■
server_browser.region■Region■■■■■■
server_browser.fetching_server_list■Fetching server list…■■■■■■
server_browser.no_server_selected■No server selected■■■■■■
server_browser.hostname■Hostname■■■■■■
server_browser.current_map■Current Map■■■■■■
server_browser.players■Players■■■■■■
server_browser.ping■Ping■■■■■■
server_browser.nickname■Nickname■■■■■■
server_browser.set_nickname■Set Nickname■■■■■■
server_browser.set_nickname_message■Set a nickname that will be used when joining a server■■■■■■
server_browser.enter_password■Enter Password■■■■■■
server_browser.enter_password_message■This server requires a password■■■■■■
server_browser.time■Time■■■■■■
server_browser.remaining■Remaining■■■■■■
1 __KEY__■EN-ENGLISH■DE-GERMAN■FR-FRENCH■ES-SPANISH■KO-KOREAN■JA-JAPANESE■ZH-CHINESE
2 app_name■Cyberarm's Linux Friendly W3D Hub Launcher■■■■■■
3 app_name_simple■W3D Hub Linux Launcher■■■■■■
4 boot.w3dhub_service_is_down■W3D Hub service is down.■■■■■■
5 boot.checking_for_updates■Checking for updates…■■■■■■
6 interface.log_in■Log in■■■■■■
7 interface.register■Register■■■■■■
8 interface.log_out■Log out■■■■■■
9 interface.not_logged_in■Not Logged In■■■■■■
10 interface.profile■Profile■■■■■■
11 interface.games■Games■■■■■■
12 interface.server_browser■Server Browser■■■■■■
13 interface.servers■Servers■■■■■■
14 interface.community■Community■■■■■■
15 interface.download_manager■Download Manager■■■■■■
16 interface.downloads■Downloads■■■■■■
17 interface.play_now■Play Now■■■■■■
18 interface.play■Play■■■■■■
19 interface.join_now■Join Now■■■■■■
20 interface.join■Join■■■■■■
21 interface.install_update■Install Update■■■■■■
22 interface.single_player■Single Player■■■■■■
23 interface.import■Import■■■■■■
24 interface.install■Install■■■■■■
25 interface.app_settings_tip■W3D Hub Launcher Settings■■■■■■
26 interface.settings■Settings■■■■■■
27 games.game_settings■Game Settings■■■■■■
28 games.game_options■Game Options■■■■■■
29 games.game_version■Game Version■■■■■■
30 games.wine_configuration■Wine Configuration■■■■■■
31 games.game_modifications■Game Modifications■■■■■■
32 games.repair_installation■Repair Installation■■■■■■
33 games.uninstall_game■Uninstall Game■■■■■■
34 games.install_folder■Install Folder■■■■■■
35 games.user_data_folder■User Data Folder■■■■■■
36 games.view_screenshots■View Screenshots■■■■■■
37 games.read_more■Read More■■■■■■
38 games.fetching_news■Fetching news…■■■■■■
39 games.channel■Channel■■■■■■
40 games.version■Version■■■■■■
41 server_browser.direct_connect■Direct Connect■■■■■■
42 server_browser.refresh■Refresh■■■■■■
43 server_browser.join_server■Join Server■■■■■■
44 server_browser.game■Game■■■■■■
45 server_browser.map■Map■■■■■■
46 server_browser.max_players■Max Players■■■■■■
47 server_browser.filters■Filters■■■■■■
48 server_browser.region■Region■■■■■■
49 server_browser.fetching_server_list■Fetching server list…■■■■■■
50 server_browser.no_server_selected■No server selected■■■■■■
51 server_browser.hostname■Hostname■■■■■■
52 server_browser.current_map■Current Map■■■■■■
53 server_browser.players■Players■■■■■■
54 server_browser.ping■Ping■■■■■■
55 server_browser.nickname■Nickname■■■■■■
56 server_browser.set_nickname■Set Nickname■■■■■■
57 server_browser.set_nickname_message■Set a nickname that will be used when joining a server■■■■■■
58 server_browser.enter_password■Enter Password■■■■■■
59 server_browser.enter_password_message■This server requires a password■■■■■■
60 server_browser.time■Time■■■■■■
61 server_browser.remaining■Remaining■■■■■■

View File

@@ -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"