mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-09-19 14:53:49 +00:00
Initial support for importing games
This commit is contained in:
@@ -40,12 +40,16 @@ module W3DHubLauncher
|
||||
|
||||
def present_item(item)
|
||||
unless item.url.empty?
|
||||
link item.name, tip: item.url, margin_left: PADDING, font: FONT_BOLD
|
||||
link item.name, tip: item.url, margin_left: PADDING, font: FONT_BOLD do
|
||||
SDL.OpenURL(item.url)
|
||||
end
|
||||
else
|
||||
tagline item.name, margin_left: PADDING
|
||||
end
|
||||
para item.description, margin_left: LARGE_PADDING
|
||||
link item.license, tip: item.license_url, margin_left: PADDING + LARGE_PADDING unless item.license.empty?
|
||||
link item.license, tip: item.license_url, margin_left: PADDING + LARGE_PADDING unless item.license.empty? do
|
||||
SDL.OpenURL(item.license_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
77
lib/dialogs/import_application.rb
Normal file
77
lib/dialogs/import_application.rb
Normal file
@@ -0,0 +1,77 @@
|
||||
module W3DHubLauncher
|
||||
class Dialog
|
||||
class ImportApplication < W3DHubLauncher::Dialog
|
||||
def setup
|
||||
super
|
||||
|
||||
@application = @options[:application]
|
||||
@channel = @options[:channel]
|
||||
|
||||
stack(width: 1.0, max_width: 600, height: 1.0, max_height: 600, h_align: :center, v_align: :center, background_nine_slice: NINE_SLICE_ROUNDED, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: 0xee_63452c) do
|
||||
flow(width: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_TOP, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: 0) do
|
||||
banner "Import Application", width: 1.0, text_align: :center
|
||||
end
|
||||
|
||||
stack(width: 1.0, fill: true, scroll: true, margin_left: PADDING, margin_right: PADDING, padding: HALF_PADDING, background_nine_slice: NINE_SLICE_ROUNDED, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: ALPHA_BLACK) do
|
||||
title format("%s (%s)", @application.name, @channel.name)
|
||||
caption "Path to application executable:"
|
||||
@path_input = edit_line "", width: 1.0
|
||||
button "Browse..." do
|
||||
Gosu.choose_file do |file_list|
|
||||
pp file_list
|
||||
|
||||
unless file_list.empty?
|
||||
@path_input.value = file_list.first
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@path_input.subscribe(:changed) do |e, value|
|
||||
found = false
|
||||
|
||||
if File.directory?(File.dirname(value))
|
||||
Dir.glob("#{File.dirname(value)}/game*.exe").each do |file|
|
||||
if File.exist?(file)
|
||||
found = true
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@import_button.enabled = found
|
||||
end
|
||||
end
|
||||
|
||||
flow(width: 1.0, padding: PADDING, background_nine_slice: NINE_SLICE_ROUNDED_BOTTOM, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: 0) do
|
||||
button "Close" do
|
||||
pop_state
|
||||
end
|
||||
|
||||
flow(fill: true)
|
||||
|
||||
@import_button = button "Import", enabled: false, **CTA_BUTTON_THEME do
|
||||
pop_state
|
||||
|
||||
app = Worker::Api::Settings::Application.create(
|
||||
id: @application.id,
|
||||
channel: @channel.id,
|
||||
version: @channel.version,
|
||||
installation_path: File.dirname(@path_input.value),
|
||||
wine_prefix_path: "",
|
||||
launch_command: "%COMMAND%",
|
||||
timestamp: Time.now.to_i
|
||||
)
|
||||
|
||||
MemCache[:settings].applications << app
|
||||
|
||||
Worker::Api.update_settings(MemCache[:settings])
|
||||
|
||||
# FIXME: broadcast app installed on CyberarmEngine::EventBus
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -183,6 +183,7 @@ module W3DHubLauncher
|
||||
populate_game_info
|
||||
end
|
||||
end
|
||||
|
||||
flow(width: 1.0, height: 60) do
|
||||
if application
|
||||
button "JOIN", tip: "Join most populated or lowest ping server", fill: true, height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_LEFT, **CTA_BUTTON_THEME
|
||||
@@ -191,18 +192,25 @@ module W3DHubLauncher
|
||||
end
|
||||
button safe_get_image("#{ROOT_PATH}/media/icons/gear.png"), tip: "Options", image_height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_RIGHT, **CTA_BUTTON_THEME do |btn|
|
||||
menu(parent: btn) do
|
||||
menu_item("Game Settings")
|
||||
menu_item("Show in Explorer")
|
||||
menu_item("Repair Installation")
|
||||
menu_item("Check for Updates")
|
||||
stack(width: 1.0, height: 4, background: 0xff_bbbbbb)
|
||||
menu_item("Move Installation")
|
||||
menu_item("Uninstall")
|
||||
menu_item("v#{application.version}", enabled: false, disabled: { color: 0xdd_ffffff }, tip: "Installed application version")
|
||||
stack(width: 1.0, height: 2, background: 0xff_bbbbbb)
|
||||
menu_item("Installation Folder", tip: "Open application installation folder:\n#{application.installation_path}")
|
||||
menu_item("Screenshots Folder", tip: "Open application installation folder:\n#{Dir.home}/Documents/W3D Hub/#{application.id}-#{application.channel}/Screenshots")
|
||||
stack(width: 1.0, height: 2, background: 0xff_bbbbbb)
|
||||
menu_item("Application Settings", tip: "Edit application launch options")
|
||||
menu_item("Repair Installation", tip: "Attempt to fix and repair installation")
|
||||
menu_item("Check for Updates", tip: "Manually check for application updates")
|
||||
stack(width: 1.0, height: 2, background: 0xff_bbbbbb)
|
||||
menu_item("Move Installation", tip: "Move application installation to a different directory or disk")
|
||||
menu_item("Unlink Installation", tip: "The application will be removed from the launcher\nbut the application's files will not be touched")
|
||||
menu_item("Uninstall", tip: "Uninstall application and delete files")
|
||||
end.show
|
||||
end
|
||||
elsif @current_app.servicable?
|
||||
# pp @current_app
|
||||
button "Import", enabled: false, tip: "Import existing application installation", fill: true, height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_LEFT, **CTA_BUTTON_THEME
|
||||
button "Import", tip: "Import existing application installation", fill: true, height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_LEFT, **CTA_BUTTON_THEME do |btn|
|
||||
dialog(Dialog::ImportApplication, application: @current_app, channel: @current_channel)
|
||||
end
|
||||
button "Download", tip: "Download and install application", fill: true, height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_RIGHT, **CTA_BUTTON_THEME do |btn|
|
||||
btn.enabled = false
|
||||
|
||||
@@ -214,8 +222,6 @@ module W3DHubLauncher
|
||||
button "Import", enabled: false, tip: "Import existing application installation", fill: true, height: 1.0, **CTA_BUTTON_THEME
|
||||
end
|
||||
end
|
||||
|
||||
inscription "Version: #{application.version}", margin_top: PADDING, tip: "Installed version" if application
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user