mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-15 08:42:34 +00:00
Can now join a server and launch installed games (Play Now does nothing special yet)
This commit is contained in:
@@ -83,6 +83,17 @@ class W3DHub
|
||||
end
|
||||
end
|
||||
|
||||
def join_server(app_id, channel, server, password = nil)
|
||||
if installed?(app_id, channel) && window.settings[:server_list_username].to_s.length.positive?
|
||||
run(
|
||||
app_id, channel,
|
||||
"+connect #{server.address}:#{server.port}",
|
||||
"+netplayername \"#{window.settings[:server_list_username]}\"",
|
||||
password ? "+password \"#{password}\"" : ""
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def installed!(task)
|
||||
# install_dir
|
||||
# installed_version
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
class W3DHub
|
||||
class ApplicationManager
|
||||
class Importer < Task
|
||||
def initialize(app_id, channel, path)
|
||||
def initialize(app_id, channel, path = nil)
|
||||
super(app_id, channel)
|
||||
|
||||
@path = path
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,54 +5,40 @@ class W3DHub
|
||||
body.clear do
|
||||
stack(width: 1.0, height: 1.0, padding: 8) do
|
||||
stack(width: 1.0, height: 0.15) do
|
||||
tagline "<b>Welcome to the W3D Hub Launcher</b>"
|
||||
para "The W3D Hub launcher is a one-stop shop for your W3D gamings needs, providing game downloads and automatic updating, an intregrated server browser, centralized management of in-game options and many other features."
|
||||
tagline "<b>Welcome to the #{W3DHub::NAME}</b>"
|
||||
para "The #{W3DHub::NAME} is a one-stop shop for your W3D gaming needs, providing game downloads, automatic updating, an integrated server browser, and centralized management of in-game options."
|
||||
end
|
||||
|
||||
flow(width: 1.0, height: 0.1, margin_top: 24) do
|
||||
flow(width: 0.375, height: 1.0) do
|
||||
flow(width: 1.0, height: 0.15, margin_bottom: 24) do
|
||||
flow(width: (1.0 - 0.27) / 2, height: 1.0) do
|
||||
end
|
||||
|
||||
flow(width: 0.25, height: 1.0) do
|
||||
image "#{GAME_ROOT_PATH}/media/icons/apb.png", height: 1.0
|
||||
image "#{GAME_ROOT_PATH}/media/icons/ren.png", height: 1.0, margin_left: 32
|
||||
image "#{GAME_ROOT_PATH}/media/icons/tsr.png", height: 1.0, margin_left: 32
|
||||
image "#{GAME_ROOT_PATH}/media/icons/w3dhub.png", height: 1.0, margin_left: 32
|
||||
end
|
||||
|
||||
flow(width: 0.375, height: 1.0) do
|
||||
flow(width: 0.27, height: 1.0) do
|
||||
image "#{GAME_ROOT_PATH}/media/icons/w3dhub.png", height: 1.0, hover: { color: 0xaa_ffffff }, tip: "W3D Hub Forums" do
|
||||
Launchy.open("https://w3dhub.com/forum/")
|
||||
end
|
||||
image "#{GAME_ROOT_PATH}/media/social_media_icons/discord.png", hover: { color: 0xaa_ffffff }, height: 1.0, margin_left: 32, tip: "W3D Hub Discord Server" do
|
||||
Launchy.open("https://discord.com/invite/GYhW7eV")
|
||||
end
|
||||
image "#{GAME_ROOT_PATH}/media/social_media_icons/facebook.png", hover: { color: 0xaa_ffffff }, height: 1.0, margin_left: 32, tip: "W3D Hub Facebook Page" do
|
||||
Launchy.open("https://www.facebook.com/w3dhub")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
stack(width: 1.0, height: 0.6, scroll: true) do
|
||||
stack(width: 1.0, height: 0.55, scroll: true) do
|
||||
tagline "<b>Latest Updates</b>"
|
||||
para "<b>Beta 12</b>", margin_left: 16
|
||||
para "- Server Browser: Added detailed information for selection server", margin_left: 32
|
||||
|
||||
para "<b>Beta 11.6</b>", margin_left: 16, margin_top: 16
|
||||
para "- Localisation: Added Korean translations (unknown author)", margin_left: 32
|
||||
para "- Localisation: Added Spanish translations (thanks to Silverlight and URKA)", margin_left: 32
|
||||
para "- Localisation: Added Spanish translations (thanks to darkyuri-cz)", margin_left: 32
|
||||
|
||||
para "<b>Beta 11.0</b>", margin_left: 16, margin_top: 16
|
||||
para "- Localisation: Added partial Chinese (Simplified) translations and Polish (thanks to DoDoCat and TrollekPL on the W3D Hub forums for providing translations)", margin_left: 32
|
||||
para "- Performance: Reduced CPU and GPU usage during game installs and updates", margin_left: 32
|
||||
para "- Settings: Added new setting menu for the launcher - click on the [gear] icon in the titlebar. Incluudes:", margin_left: 32
|
||||
para "- Manually choose language, rather than using default based on OS", margin_left: 48
|
||||
para "- Choose package cache folder location", margin_left: 48
|
||||
para "- Choose default folder into which games are installed", margin_left: 48
|
||||
para "- Server Browser: Now receives push notifications so it shows changes to maps, player counts, etc. as soon as they are available", margin_left: 32
|
||||
para "- Server Browser: Now lists servers with players in above empty ones", margin_left: 32
|
||||
para "- Server Browser: Game filter options are now saved", margin_left: 32
|
||||
para "Hello World " * 100
|
||||
end
|
||||
|
||||
stack(width: 1.0, height: 0.15) do
|
||||
stack(width: 1.0, height: 0.15, margin_top: 16) do
|
||||
tagline "<b>Help & Support</b>"
|
||||
flow(width: 1.0) do
|
||||
para "For help and support using this launcher or playing any W3D Hub game visit the"
|
||||
link("W3D Hub forums", text_size: 16) { Launchy.open("https://w3dhub.com/forum/") }
|
||||
para "or join us in"
|
||||
link("[discord]#tech-support", text_size: 16) { Launchy.open("https://w3dhub.com/forum/") }
|
||||
image "#{GAME_ROOT_PATH}/media/social_media_icons/discord.png", height: 16, padding_top: 4
|
||||
link("#tech-support", text_size: 16) { Launchy.open("https://discord.com/invite/GYhW7eV") }
|
||||
para "on the W3D Hub Discord server"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,9 +47,18 @@ class W3DHub
|
||||
end
|
||||
|
||||
flow(width: 0.249, height: 1.0) do
|
||||
inscription "Nickname:"
|
||||
inscription "Cyberarm"
|
||||
image "#{GAME_ROOT_PATH}/media/ui_icons/wrench.png", height: 16
|
||||
inscription "Nickname:", width: 0.32
|
||||
@nickname_label = inscription "#{window.settings[:server_list_username]}", width: 0.6
|
||||
image "#{GAME_ROOT_PATH}/media/ui_icons/wrench.png", height: 16, hover: { color: 0xaa_ffffff }, tip: "Set nickname" do
|
||||
# Prompt for player name
|
||||
prompt_for_nickname(
|
||||
accept_callback: proc do |entry|
|
||||
@nickname_label.value = entry
|
||||
window.settings[:server_list_username] = entry
|
||||
window.settings.save_settings
|
||||
end
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -180,7 +189,33 @@ class W3DHub
|
||||
end
|
||||
|
||||
stack(width: 1.0, height: 0.25) do
|
||||
button "<b>Join Server</b>", enabled: window.application_manager.installed?(server.game, window.applications.games.find { |g| g.id == server.game }.channels.first)
|
||||
game_installed = window.application_manager.installed?(server.game, window.applications.games.find { |g| g.id == server.game }.channels.first.id)
|
||||
|
||||
button "<b>Join Server</b>", enabled: !game_installed.nil? do
|
||||
# Check for nickname
|
||||
# prompt for nickname
|
||||
# !abort unless nickname set
|
||||
# Launch game
|
||||
if window.settings[:server_list_username].to_s.length.zero?
|
||||
prompt_for_nickname(
|
||||
accept_callback: proc do |entry|
|
||||
@nickname_label.value = entry
|
||||
window.settings[:server_list_username] = entry
|
||||
window.settings.save_settings
|
||||
|
||||
window.application_manager.join_server(
|
||||
server.game,
|
||||
window.applications.games.find { |g| g.id == server.game }.channels.first.id, server
|
||||
)
|
||||
end
|
||||
)
|
||||
else
|
||||
window.application_manager.join_server(
|
||||
server.game,
|
||||
window.applications.games.find { |g| g.id == server.game }.channels.first.id, server
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
stack(width: 1.0, height: 0.55, margin_top: 16) do
|
||||
@@ -281,6 +316,18 @@ class W3DHub
|
||||
"C&C Renegade"
|
||||
end
|
||||
end
|
||||
|
||||
def prompt_for_nickname(accept_callback: nil, cancel_callback: nil)
|
||||
push_state(
|
||||
W3DHub::States::PromptDialog,
|
||||
title: "Set Nickname",
|
||||
message: "Set a nickname that will be used when joining a server:",
|
||||
prefill: window.settings[:server_list_username],
|
||||
accept_callback: accept_callback,
|
||||
cancel_callback: cancel_callback,
|
||||
valid_callback: proc { |entry| entry.length.positive? }
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ class W3DHub
|
||||
wine_command: "wine",
|
||||
create_wine_prefixes: true,
|
||||
allow_diagnostic_reports: false,
|
||||
server_list_username: nil,
|
||||
server_list_username: "",
|
||||
account: {},
|
||||
applications: {},
|
||||
games: {}
|
||||
@@ -53,6 +53,10 @@ class W3DHub
|
||||
@settings.dig(*args)
|
||||
end
|
||||
|
||||
def []=(key, value)
|
||||
@settings[key] = value
|
||||
end
|
||||
|
||||
def load_settings
|
||||
@settings = JSON.parse(File.read(SETTINGS_FILE_PATH), symbolize_names: true)
|
||||
end
|
||||
|
||||
52
lib/states/prompt_dialog.rb
Normal file
52
lib/states/prompt_dialog.rb
Normal file
@@ -0,0 +1,52 @@
|
||||
class W3DHub
|
||||
class States
|
||||
class PromptDialog < CyberarmEngine::GuiState
|
||||
def setup
|
||||
window.show_cursor = true
|
||||
|
||||
theme(W3DHub::THEME)
|
||||
|
||||
background 0xee_444444
|
||||
|
||||
stack(width: 1.0, height: 1.0, margin: 128, background: 0xee_222222) do
|
||||
flow(width: 1.0, height: 0.1, padding: 8) do
|
||||
background 0x88_000000
|
||||
|
||||
image "#{GAME_ROOT_PATH}/media/ui_icons/question.png", width: 0.04, align: :center, color: 0xff_ff8800
|
||||
|
||||
tagline "<b>#{@options[:title]}</b>", width: 0.9, text_align: :center
|
||||
end
|
||||
|
||||
stack(width: 1.0, height: 0.78, padding: 16) do
|
||||
para @options[:message], width: 1.0
|
||||
@prompt_entry = edit_line @options[:prefill].to_s, margin_top: 24, width: 1.0, focus: true
|
||||
end
|
||||
|
||||
flow(width: 1.0, height: 0.1, padding: 8) do
|
||||
button "Cancel", width: 0.25 do
|
||||
pop_state
|
||||
@options[:cancel_callback]&.call(@prompt_entry.value)
|
||||
end
|
||||
|
||||
stack(width: 0.5)
|
||||
|
||||
button "Accept", width: 0.25 do
|
||||
if @options[:valid_callback]&.call(@prompt_entry.value)
|
||||
pop_state
|
||||
@options[:accept_callback]&.call(@prompt_entry.value)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def draw
|
||||
previous_state&.draw
|
||||
|
||||
Gosu.flush
|
||||
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
BIN
media/social_media_icons/discord.png
Normal file
BIN
media/social_media_icons/discord.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
BIN
media/social_media_icons/facebook.png
Normal file
BIN
media/social_media_icons/facebook.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -38,6 +38,7 @@ require_relative "lib/application_manager/tasks/importer"
|
||||
require_relative "lib/states/boot"
|
||||
require_relative "lib/states/interface"
|
||||
require_relative "lib/states/message_dialog"
|
||||
require_relative "lib/states/prompt_dialog"
|
||||
|
||||
require_relative "lib/api"
|
||||
require_relative "lib/api/service_status"
|
||||
|
||||
Reference in New Issue
Block a user