mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-09-19 14:53:49 +00:00
Settings are now set
This commit is contained in:
@@ -17,37 +17,44 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
flow(width: 1.0, height: 40, margin_top: PADDING) do
|
flow(width: 1.0, height: 40, margin_top: PADDING) do
|
||||||
tagline "Nickname", height: 1.0, text_v_align: :center
|
tagline "Nickname", height: 1.0, text_v_align: :center
|
||||||
edit_line Etc.getlogin, fill: true
|
@nickname = edit_line Etc.getlogin, fill: true
|
||||||
end
|
end
|
||||||
inscription "Nickname to use when joining servers.", margin_left: PADDING
|
inscription "Nickname to use when joining servers.", margin_left: PADDING
|
||||||
|
|
||||||
flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do
|
flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do
|
||||||
tagline "Launcher package cache directory", height: 1.0, text_v_align: :center
|
tagline "Launcher package cache directory", height: 1.0, text_v_align: :center
|
||||||
edit_line DEFAULT_PACKAGE_CACHE_PATH, fill: true
|
@launcher_package_cache_directory = edit_line DEFAULT_PACKAGE_CACHE_PATH, fill: true
|
||||||
button "Browse..."
|
button "Browse..."
|
||||||
end
|
end
|
||||||
inscription "Location where the launcher will download application packages.", margin_left: PADDING
|
inscription "Location where the launcher will download application packages.", margin_left: PADDING
|
||||||
|
|
||||||
flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do
|
flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do
|
||||||
tagline "Application installation directory", height: 1.0, text_v_align: :center
|
tagline "Application installation directory", height: 1.0, text_v_align: :center
|
||||||
edit_line DEFAULT_APPLICATIONS_PATH, fill: true
|
@application_installation_directory = edit_line DEFAULT_APPLICATIONS_PATH, fill: true
|
||||||
button "Browse..."
|
button "Browse..."
|
||||||
end
|
end
|
||||||
inscription "Location where the launcher will install new applications.", margin_left: PADDING
|
inscription "Location where the launcher will install new applications.", margin_left: PADDING
|
||||||
|
|
||||||
flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do
|
flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do
|
||||||
tagline "Wine context", height: 1.0, text_v_align: :center
|
tagline "Wine prefix path", height: 1.0, text_v_align: :center
|
||||||
edit_line "", fill: true
|
@wine_prefix_path = edit_line "", fill: true
|
||||||
button "Browse..."
|
button "Browse..."
|
||||||
end
|
end
|
||||||
inscription "Location of wine context to use. Leave blank to use default.", margin_left: PADDING
|
inscription "Location of wine prefix to use. Leave blank to use default.", margin_left: PADDING
|
||||||
|
|
||||||
flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do
|
flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do
|
||||||
tagline "Wine command", height: 1.0, text_v_align: :center
|
tagline "Wine command", height: 1.0, text_v_align: :center
|
||||||
edit_line "wine", fill: true
|
@wine_command = edit_line "wine", fill: true
|
||||||
button "Browse..."
|
button "Browse..."
|
||||||
end
|
end
|
||||||
inscription "Path to wine executable. Use <c=f80>wine</c> for system installed wine.", margin_left: PADDING
|
inscription "Path to wine executable. Use <c=f80>wine</c> for system installed wine.", margin_left: PADDING
|
||||||
|
|
||||||
|
flow(width: 1.0, height: 40, margin_top: HALF_PADDING) do
|
||||||
|
tagline "Winetricks command", height: 1.0, text_v_align: :center
|
||||||
|
@winetricks_command = edit_line "winetricks", fill: true
|
||||||
|
button "Browse..."
|
||||||
|
end
|
||||||
|
inscription "Path to winetricks executable. Use <c=f80>winetricks</c> for system installed winetricks.", margin_left: PADDING
|
||||||
end
|
end
|
||||||
|
|
||||||
flow(width: 1.0, padding_top: PADDING) do
|
flow(width: 1.0, padding_top: PADDING) do
|
||||||
@@ -55,14 +62,27 @@ module W3DHubLauncher
|
|||||||
button "Accept", **CTA_BUTTON_THEME do |btn|
|
button "Accept", **CTA_BUTTON_THEME do |btn|
|
||||||
btn.enabled = false
|
btn.enabled = false
|
||||||
|
|
||||||
Worker::Api.update_settings({}) do |result|
|
# initialize default settings
|
||||||
|
settings = Worker::Api::Settings.new({})
|
||||||
|
|
||||||
|
# update user preferences
|
||||||
|
settings.preferences.nickname = @nickname.value.strip
|
||||||
|
settings.preferences.launcher_package_cache_directory = @launcher_package_cache_directory.value.strip
|
||||||
|
settings.preferences.application_installation_directory = @application_installation_directory.value.strip
|
||||||
|
settings.preferences.wine_prefix_path = @wine_prefix_path.value.strip
|
||||||
|
settings.preferences.wine_command = @wine_command.value.strip
|
||||||
|
settings.preferences.winetricks_command = @winetricks_command.value.strip
|
||||||
|
|
||||||
|
Worker::Api.update_settings(settings) do |result|
|
||||||
if result.okay?
|
if result.okay?
|
||||||
on_main_thread(proc { page(Page::Boot::StartUp) })
|
on_main_thread(proc {
|
||||||
|
MemCache[:settings] = settings
|
||||||
|
page(Page::Boot::StartUp)
|
||||||
|
})
|
||||||
else
|
else
|
||||||
|
# FIXME: Somehow something went wrong... show an error message.
|
||||||
btn.enabled = true
|
btn.enabled = true
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "NOW!"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -28,7 +28,18 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
page(Page::Boot::Terms)
|
Worker::Api.load_settings do |result|
|
||||||
|
if result.okay?
|
||||||
|
on_main_thread( proc {
|
||||||
|
MemCache[:settings] = Worker::Api::Settings.new(JSON.parse(result.data))
|
||||||
|
page(Page::Boot::StartUp)
|
||||||
|
})
|
||||||
|
else
|
||||||
|
on_main_thread( proc {
|
||||||
|
page(Page::Boot::Terms)
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -165,12 +165,37 @@ module W3DHubLauncher
|
|||||||
deliver_response(result, query)
|
deliver_response(result, query)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def load_settings(query)
|
||||||
|
result = CyberarmEngine::Result.new
|
||||||
|
|
||||||
|
path = "#{W3DHubLauncher::CONFIG_PATH}/settings.json"
|
||||||
|
begin
|
||||||
|
if File.exist?(path) && File.size(path).positive?
|
||||||
|
json = File.read(path)
|
||||||
|
result.data = json
|
||||||
|
else
|
||||||
|
result.error = RuntimeError.new("Launcher settings file does not exist or is empty.")
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
result.error = e
|
||||||
|
end
|
||||||
|
|
||||||
|
deliver_response(result, query)
|
||||||
|
end
|
||||||
|
|
||||||
def update_settings(query)
|
def update_settings(query)
|
||||||
result = CyberarmEngine::Result.new
|
result = CyberarmEngine::Result.new
|
||||||
|
|
||||||
FileUtils.mkdir_p(W3DHubLauncher::CONFIG_PATH) # FIXME: FAILABLE!
|
begin
|
||||||
File.write("#{W3DHubLauncher::CONFIG_PATH}/settings.json", query.data) # FIXME: FAILABLE!
|
@settings = Api::Settings.new(JSON.parse(query.data))
|
||||||
result.data = query.data
|
FileUtils.mkdir_p(W3DHubLauncher::CONFIG_PATH)
|
||||||
|
File.write("#{W3DHubLauncher::CONFIG_PATH}/settings.json", query.data)
|
||||||
|
|
||||||
|
result.data = query.data
|
||||||
|
rescue => e
|
||||||
|
result.error = e
|
||||||
|
end
|
||||||
|
|
||||||
deliver_response(result, query)
|
deliver_response(result, query)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ module W3DHubLauncher
|
|||||||
def self.settings
|
def self.settings
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns raw json of launcher settings
|
||||||
|
def self.load_settings(&block)
|
||||||
|
Worker::Request.new(:load_settings, "", &block)
|
||||||
|
end
|
||||||
|
|
||||||
# write updated launcher settings
|
# write updated launcher settings
|
||||||
def self.update_settings(settings, &block)
|
def self.update_settings(settings, &block)
|
||||||
Worker::Request.new(:update_settings, settings.to_json, &block)
|
Worker::Request.new(:update_settings, settings.to_json, &block)
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ module W3DHubLauncher
|
|||||||
def initialize(data)
|
def initialize(data)
|
||||||
@schema = data["schema"] || SCHEMA
|
@schema = data["schema"] || SCHEMA
|
||||||
|
|
||||||
|
raise "Data is not a hash!" unless data.is_a?(Hash)
|
||||||
|
|
||||||
@last_selected_app = data["last_selected_app"] || "ren"
|
@last_selected_app = data["last_selected_app"] || "ren"
|
||||||
@last_selected_app_channel = data["last_selected_app_channel"] || "release"
|
@last_selected_app_channel = data["last_selected_app_channel"] || "release"
|
||||||
@last_selected_server_app = data["last_selected_server_app"] || ""
|
@last_selected_server_app = data["last_selected_server_app"] || ""
|
||||||
@@ -20,7 +22,7 @@ module W3DHubLauncher
|
|||||||
@account = Account.new(data["account"])
|
@account = Account.new(data["account"])
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_json(context = nil)
|
def to_json(options = {})
|
||||||
{
|
{
|
||||||
schema: @schema,
|
schema: @schema,
|
||||||
last_selected_app: @last_selected_app,
|
last_selected_app: @last_selected_app,
|
||||||
@@ -29,7 +31,7 @@ module W3DHubLauncher
|
|||||||
preferences: @preferences,
|
preferences: @preferences,
|
||||||
applications: @applications,
|
applications: @applications,
|
||||||
account: @account
|
account: @account
|
||||||
}.to_json(context)
|
}.to_json(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
# User explictly set options
|
# User explictly set options
|
||||||
@@ -53,7 +55,7 @@ module W3DHubLauncher
|
|||||||
@winetricks_command = data["winetricks_command"] || "winetricks"
|
@winetricks_command = data["winetricks_command"] || "winetricks"
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_json(context = nil)
|
def to_json(options = {})
|
||||||
{
|
{
|
||||||
schema: @schema,
|
schema: @schema,
|
||||||
language: @language,
|
language: @language,
|
||||||
@@ -63,7 +65,7 @@ module W3DHubLauncher
|
|||||||
wine_prefix_path: @wine_prefix_path,
|
wine_prefix_path: @wine_prefix_path,
|
||||||
wine_command: @wine_command,
|
wine_command: @wine_command,
|
||||||
winetricks_command: @winetricks_command
|
winetricks_command: @winetricks_command
|
||||||
}.to_json(context)
|
}.to_json(options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -99,7 +101,7 @@ module W3DHubLauncher
|
|||||||
@launch_command = data["launch_command"]
|
@launch_command = data["launch_command"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_json(context = nil)
|
def to_json(options = {})
|
||||||
{
|
{
|
||||||
schema: @schema,
|
schema: @schema,
|
||||||
id: @id,
|
id: @id,
|
||||||
@@ -108,7 +110,7 @@ module W3DHubLauncher
|
|||||||
installation_path: @installation_path,
|
installation_path: @installation_path,
|
||||||
wine_prefix_path: @wine_prefix_path,
|
wine_prefix_path: @wine_prefix_path,
|
||||||
launch_command: @launch_command
|
launch_command: @launch_command
|
||||||
}.to_json(context)
|
}.to_json(options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -152,7 +154,7 @@ module W3DHubLauncher
|
|||||||
@user_id.positive?
|
@user_id.positive?
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_json(context = nil)
|
def to_json(options = {})
|
||||||
{
|
{
|
||||||
schema: @schema,
|
schema: @schema,
|
||||||
user_id: @user_id,
|
user_id: @user_id,
|
||||||
@@ -162,7 +164,7 @@ module W3DHubLauncher
|
|||||||
access_token: @access_token,
|
access_token: @access_token,
|
||||||
refresh_token: @refresh_token,
|
refresh_token: @refresh_token,
|
||||||
access_token_expiration_time: @access_token_expiration_time.to_i
|
access_token_expiration_time: @access_token_expiration_time.to_i
|
||||||
}.to_json(context)
|
}.to_json(options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ require_relative "lib/worker"
|
|||||||
require_relative "lib/worker/api"
|
require_relative "lib/worker/api"
|
||||||
require_relative "lib/worker/api/application"
|
require_relative "lib/worker/api/application"
|
||||||
require_relative "lib/worker/api/game_server"
|
require_relative "lib/worker/api/game_server"
|
||||||
|
require_relative "lib/worker/api/settings"
|
||||||
require_relative "lib/worker/request"
|
require_relative "lib/worker/request"
|
||||||
require_relative "lib/worker/w3dhub_api"
|
require_relative "lib/worker/w3dhub_api"
|
||||||
require_relative "lib/worker/task"
|
require_relative "lib/worker/task"
|
||||||
|
|||||||
Reference in New Issue
Block a user