mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 01:02:34 +00:00
Tweaked layout for Interface and Games page, initial work on offline mode (will crash atm if offline mode is triggered)
This commit is contained in:
@@ -3,21 +3,28 @@ class W3DHub
|
|||||||
class Games < Page
|
class Games < Page
|
||||||
def setup
|
def setup
|
||||||
@game_news ||= {}
|
@game_news ||= {}
|
||||||
@focused_game ||= Store.applications.games.find { |g| g.id == Store.settings[:last_selected_app] }
|
|
||||||
@focused_game ||= Store.applications.games.find { |g| g.id == "ren" }
|
# unless Store.offline_mode
|
||||||
@focused_channel ||= @focused_game.channels.find { |c| c.id == Store.settings[:last_selected_channel] }
|
@focused_game ||= Store.applications.games.find { |g| g.id == Store.settings[:last_selected_app] }
|
||||||
@focused_channel ||= @focused_game.channels.first
|
@focused_game ||= Store.applications.games.find { |g| g.id == "ren" }
|
||||||
|
@focused_channel ||= @focused_game.channels.find { |c| c.id == Store.settings[:last_selected_channel] }
|
||||||
|
@focused_channel ||= @focused_game.channels.first
|
||||||
|
# end
|
||||||
|
|
||||||
body.clear do
|
body.clear do
|
||||||
# Games List
|
stack(width: 1.0, height: 1.0) do
|
||||||
@games_list_container = stack(width: 148, height: 1.0, scroll: true, border_thickness_right: 1, border_color_right: 0xff_656565) do
|
# Games List
|
||||||
end
|
@games_list_container = flow(width: 1.0, height: 64, scroll: true, border_thickness_bottom: 1, border_color_bottom: 0xff_656565, padding_left: 32, padding_right: 32) do
|
||||||
|
end
|
||||||
|
|
||||||
# Game Menu
|
# Game Menu
|
||||||
@game_page_container = stack(fill: true, height: 1.0) do
|
@game_page_container = stack(width: 1.0, fill: true) do
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# return if Store.offline_mode
|
||||||
|
|
||||||
populate_game_page(@focused_game, @focused_channel)
|
populate_game_page(@focused_game, @focused_channel)
|
||||||
populate_games_list
|
populate_games_list
|
||||||
end
|
end
|
||||||
@@ -29,22 +36,23 @@ class W3DHub
|
|||||||
Store.applications.games.each do |game|
|
Store.applications.games.each do |game|
|
||||||
selected = game == @focused_game
|
selected = game == @focused_game
|
||||||
|
|
||||||
game_button = stack(width: 1.0, border_thickness_left: 4,
|
game_button = stack(width: 64, height: 1.0, border_thickness_bottom: 4,
|
||||||
border_color_left: selected ? 0xff_00acff : 0x00_000000,
|
border_color_bottom: selected ? 0xff_00acff : 0x00_000000,
|
||||||
hover: { background: selected ? game.color : 0xff_444444 },
|
hover: { background: selected ? game.color : 0xff_444444 },
|
||||||
padding_top: 4, padding_bottom: 4) do
|
padding_left: 4, padding_right: 4, tip: game.name) do
|
||||||
background game.color if selected
|
background game.color if selected
|
||||||
|
|
||||||
flow(width: 1.0, height: 48) do
|
flow(width: 1.0, height: 1.0, padding: 8) do
|
||||||
stack(width: 0.3) do
|
# stack(width: 0.3) do
|
||||||
image "#{GAME_ROOT_PATH}/media/ui_icons/return.png", width: 1.0, color: Gosu::Color::GRAY if Store.application_manager.updateable?(game.id, game.channels.first.id)
|
# image "#{GAME_ROOT_PATH}/media/ui_icons/return.png", width: 1.0, color: Gosu::Color::GRAY if Store.application_manager.updateable?(game.id, game.channels.first.id)
|
||||||
image "#{GAME_ROOT_PATH}/media/ui_icons/import.png", width: 0.5, color: 0x88_ffffff unless Store.application_manager.installed?(game.id, game.channels.first.id)
|
# image "#{GAME_ROOT_PATH}/media/ui_icons/import.png", width: 0.5, color: 0x88_ffffff unless Store.application_manager.installed?(game.id, game.channels.first.id)
|
||||||
end
|
# end
|
||||||
image_path = File.exist?("#{GAME_ROOT_PATH}/media/icons/#{game.id}.png") ? "#{GAME_ROOT_PATH}/media/icons/#{game.id}.png" : "#{GAME_ROOT_PATH}/media/icons/default_icon.png"
|
image_path = File.exist?("#{GAME_ROOT_PATH}/media/icons/#{game.id}.png") ? "#{GAME_ROOT_PATH}/media/icons/#{game.id}.png" : "#{GAME_ROOT_PATH}/media/icons/default_icon.png"
|
||||||
|
|
||||||
image image_path, height: 48, color: Store.application_manager.installed?(game.id, game.channels.first.id) ? 0xff_ffffff : 0x88_ffffff
|
image image_path, height: 1.0, color: Store.application_manager.installed?(game.id, game.channels.first.id) ? 0xff_ffffff : 0x88_ffffff
|
||||||
end
|
end
|
||||||
inscription game.name, width: 1.0, text_align: :center
|
|
||||||
|
# inscription game.name, width: 1.0, text_align: :center, text_size: 14
|
||||||
end
|
end
|
||||||
|
|
||||||
def game_button.hit_element?(x, y)
|
def game_button.hit_element?(x, y)
|
||||||
@@ -77,10 +85,17 @@ class W3DHub
|
|||||||
stack(width: 360, height: 1.0, padding: 8, scroll: true) do
|
stack(width: 360, height: 1.0, padding: 8, scroll: true) do
|
||||||
# background 0xff_550055
|
# background 0xff_550055
|
||||||
|
|
||||||
flow(width: 1.0, height: 200) do
|
# Game Banner
|
||||||
|
stack(width: 360, height: 200, padding: 8) do
|
||||||
# background 0xff_1155aa
|
# background 0xff_1155aa
|
||||||
|
|
||||||
banner game.name + " [Banner image missing]"
|
path = "#{GAME_ROOT_PATH}/media/banners/#{game.id}.png"
|
||||||
|
|
||||||
|
if File.exist?(path)
|
||||||
|
image path, width: 1.0
|
||||||
|
else
|
||||||
|
banner game.name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if Store.application_manager.installed?(game.id, channel.id)
|
if Store.application_manager.installed?(game.id, channel.id)
|
||||||
@@ -123,7 +138,7 @@ class W3DHub
|
|||||||
# background 0xff_444411
|
# background 0xff_444411
|
||||||
flow(fill: true)
|
flow(fill: true)
|
||||||
|
|
||||||
list_box(width: 1.0, items: game.channels.map(&:name), choose: channel.name, enabled: game.channels.count > 1, margin_left: 24, margin_right: 24) do |value|
|
list_box(width: 1.0, items: game.channels.map(&:name), choose: channel.name, enabled: game.channels.count > 1) do |value|
|
||||||
populate_game_page(game, game.channels.find { |c| c.name == value })
|
populate_game_page(game, game.channels.find { |c| c.name == value })
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -131,23 +146,24 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Play buttons
|
# Play buttons
|
||||||
flow(width: 1.0, height: 48, padding_top: 6) do
|
flow(width: 1.0, height: 48, padding_top: 6, margin_bottom: 16) do
|
||||||
# background 0xff_551100
|
# background 0xff_551100
|
||||||
|
|
||||||
if Store.application_manager.installed?(game.id, channel.id)
|
if Store.application_manager.installed?(game.id, channel.id)
|
||||||
if Store.application_manager.updateable?(game.id, channel.id)
|
if Store.application_manager.updateable?(game.id, channel.id)
|
||||||
button "<b>#{I18n.t(:"interface.install_update")}</b>", margin_left: 24, **UPDATE_BUTTON do
|
button "<b>#{I18n.t(:"interface.install_update")}</b>", text_size: 32, **UPDATE_BUTTON do
|
||||||
Store.application_manager.update(game.id, channel.id)
|
Store.application_manager.update(game.id, channel.id)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
button "<b>#{I18n.t(:"interface.play_now")}</b>", margin_left: 24 do
|
button "<b>#{I18n.t(:"interface.play")}</b>", fill: true, text_size: 32, padding_left: 32, padding_right: 32 do
|
||||||
Store.application_manager.play_now(game.id, channel.id)
|
Store.application_manager.play_now(game.id, channel.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
button "<b>#{I18n.t(:"interface.single_player")}</b>", margin_left: 24 do
|
button get_image("#{GAME_ROOT_PATH}/media/ui_icons/singleplayer.png"), tip: I18n.t(:"interface.single_player"), image_height: 32, margin_left: 0 do
|
||||||
Store.application_manager.run(game.id, channel.id)
|
Store.application_manager.run(game.id, channel.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
installing = Store.application_manager.task?(:installer, game.id, channel.id)
|
installing = Store.application_manager.task?(:installer, game.id, channel.id)
|
||||||
|
|
||||||
@@ -166,9 +182,20 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Game News
|
stack(fill: true, height: 1.0) do
|
||||||
@game_news_container = flow(fill: true, height: 1.0, padding: 8, scroll: true) do
|
# Game Description
|
||||||
# background 0xff_005500
|
if false # description
|
||||||
|
# Height should match Game Banner container height
|
||||||
|
stack(width: 1.0, padding: 16) do
|
||||||
|
title "About #{game.name}", border_bottom_color: 0xff_666666, border_bottom_thickness: 1, width: 1.0
|
||||||
|
para "Command & Conquer: Tiberian Sun is a 1999 real-time stretegy video game by Westwood Studios, published by Electronic Arts, releaseed exclusively for Microsoft Windows on August 27th, 1999. The game is the sequel to the 1995 game Command & Conquer. It featured new semi-3D graphics, a more futuristic sci-fi setting, and new gameplay features such as vehicles capable of hovering and burrowing.", width: 1.0, text_size: 20
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Game News
|
||||||
|
@game_news_container = flow(width: 1.0, fill: true, padding: 8, scroll: true) do
|
||||||
|
# background 0xff_005500
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -217,39 +244,63 @@ class W3DHub
|
|||||||
|
|
||||||
if (feed = @game_news[game.id])
|
if (feed = @game_news[game.id])
|
||||||
@game_news_container.clear do
|
@game_news_container.clear do
|
||||||
flow(width: 1.0, height: 150) do
|
# Patch Notes
|
||||||
background 0xaa_444400
|
if false # Patch notes
|
||||||
|
flow(width: 1.0, max_width: 346 * 3 + (8 * 4), height: 346, margin: 8, margin_right: 32, border_thickness: 1, border_color: darken(Gosu::Color.new(game.color))) do
|
||||||
|
background darken(Gosu::Color.new(game.color), 10)
|
||||||
|
|
||||||
banner "Priority Notification Like Maintenance or Game Night"
|
stack(width: 346, height: 1.0, padding: 8) do
|
||||||
|
background 0xff_181d22
|
||||||
|
|
||||||
|
para "Patch Notes"
|
||||||
|
|
||||||
|
tagline "<b>Patch 2.0 is now out!</b>"
|
||||||
|
|
||||||
|
para "words go here " * 20
|
||||||
|
|
||||||
|
flow(fill: true)
|
||||||
|
|
||||||
|
button "Read More", width: 1.0
|
||||||
|
end
|
||||||
|
|
||||||
|
flow(fill: true)
|
||||||
|
|
||||||
|
title "Eye Candy Banner Goes Here."
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feed.items.sort_by { |i| i.timestamp }.reverse[0..9].each do |item|
|
feed.items.sort_by { |i| i.timestamp }.reverse[0..9].each do |item|
|
||||||
flow(width: 0.5, max_width: 312, height: 128, margin: 4) do
|
flow(width: 346, height: 346, margin: 8, border_thickness: 1, border_color: game.color) do
|
||||||
# background 0x88_000000
|
background 0x88_000000
|
||||||
|
|
||||||
path = Cache.path(item.image)
|
path = Cache.path(item.image)
|
||||||
|
|
||||||
if File.exist?(path)
|
if File.exist?(path)
|
||||||
image path, width: 0.4, padding: 4
|
button get_image(path), image_width: 1.0, padding_left: 0, padding_top: 0, padding_right: 0, padding_bottom: 0, border_thickness: 0, border_color: Gosu::Color::NONE, active: { color: 0xff_888888 } do
|
||||||
|
Launchy.open(item.uri)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
image BLACK_IMAGE, width: 0.4, padding: 4
|
button BLACK_IMAGE, image_width: 1.0, padding_left: 0, padding_top: 0, padding_right: 0, padding_bottom: 0, border_thickness: 0, border_color: Gosu::Color::NONE, active: { color: 0xff_888888 } do
|
||||||
end
|
Launchy.open(item.uri)
|
||||||
|
|
||||||
stack(width: 0.6, height: 1.0) do
|
|
||||||
stack(width: 1.0, height: 112) do
|
|
||||||
link "<b>#{item.title}</b>", text_size: 18 do
|
|
||||||
Launchy.open(item.uri)
|
|
||||||
end
|
|
||||||
inscription item.blurb.gsub(/\n+/, "\n").strip[0..180]
|
|
||||||
end
|
|
||||||
|
|
||||||
flow(width: 1.0) do
|
|
||||||
inscription item.timestamp.strftime("%Y-%m-%d"), width: 0.5
|
|
||||||
link I18n.t(:"games.read_more"), width: 0.5, text_align: :right, text_size: 14 do
|
|
||||||
Launchy.open(item.uri)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
para "<b>#{item.title}</b>", text_size: 18, width: 1.0, padding: 4, margin_top: -32, background: 0xaa_000000
|
||||||
|
|
||||||
|
# stack(width: 0.6, height: 1.0) do
|
||||||
|
# stack(width: 1.0, height: 112) do
|
||||||
|
# Launchy.open(item.uri)
|
||||||
|
# end
|
||||||
|
# inscription item.blurb.gsub(/\n+/, "\n").strip[0..180]
|
||||||
|
# end
|
||||||
|
|
||||||
|
# flow(width: 1.0) do
|
||||||
|
# inscription item.timestamp.strftime("%Y-%m-%d"), width: 0.5
|
||||||
|
# link I18n.t(:"games.read_more"), width: 0.5, text_align: :right, text_size: 14 do
|
||||||
|
# Launchy.open(item.uri)
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ class W3DHub
|
|||||||
server_list: { started: false, complete: false }
|
server_list: { started: false, complete: false }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@offline_mode = false
|
||||||
|
|
||||||
@task_index = 0
|
@task_index = 0
|
||||||
|
|
||||||
stack(width: 1.0, height: 1.0, border_thickness: 1, border_color: 0xff_aaaaaa) do
|
stack(width: 1.0, height: 1.0, border_thickness: 1, border_color: 0xff_aaaaaa) do
|
||||||
@@ -52,7 +54,9 @@ class W3DHub
|
|||||||
|
|
||||||
@progressbar.value = @fraction
|
@progressbar.value = @fraction
|
||||||
|
|
||||||
push_state(States::Interface) if @progressbar.value >= 1.0 && @task_index == @tasks.size
|
push_state(States::Interface) if @offline_mode || (@progressbar.value >= 1.0 && @task_index == @tasks.size)
|
||||||
|
|
||||||
|
return if @offline_mode
|
||||||
|
|
||||||
task = @tasks[@tasks.keys[@task_index]]
|
task = @tasks[@tasks.keys[@task_index]]
|
||||||
|
|
||||||
@@ -115,6 +119,10 @@ class W3DHub
|
|||||||
@tasks[:service_status][:complete] = true
|
@tasks[:service_status][:complete] = true
|
||||||
else
|
else
|
||||||
BackgroundWorker.foreground_job(-> {}, ->(_) { @status_label.value = I18n.t(:"boot.w3dhub_service_is_down") })
|
BackgroundWorker.foreground_job(-> {}, ->(_) { @status_label.value = I18n.t(:"boot.w3dhub_service_is_down") })
|
||||||
|
@tasks[:service_status][:complete] = true
|
||||||
|
|
||||||
|
@offline_mode = true
|
||||||
|
Store.offline_mode = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class W3DHub
|
|||||||
@page = nil
|
@page = nil
|
||||||
@pages = {}
|
@pages = {}
|
||||||
|
|
||||||
Store.application_manager.auto_import
|
Store.application_manager.auto_import # unless Store.offline_mode
|
||||||
|
|
||||||
theme(W3DHub::THEME)
|
theme(W3DHub::THEME)
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ class W3DHub
|
|||||||
Button: {
|
Button: {
|
||||||
text_size: 18,
|
text_size: 18,
|
||||||
padding_top: 8,
|
padding_top: 8,
|
||||||
padding_left: 32,
|
padding_left: 16,
|
||||||
padding_right: 32,
|
padding_right: 16,
|
||||||
padding_bottom: 8,
|
padding_bottom: 8,
|
||||||
border_color: Gosu::Color::NONE,
|
border_color: Gosu::Color::NONE,
|
||||||
background: 0xff_00acff,
|
background: 0xff_00acff,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ en:
|
|||||||
download_manager: Download Manager
|
download_manager: Download Manager
|
||||||
downloads: Downloads
|
downloads: Downloads
|
||||||
play_now: Play Now
|
play_now: Play Now
|
||||||
|
play: Play
|
||||||
install_update: Install Update
|
install_update: Install Update
|
||||||
single_player: Single Player
|
single_player: Single Player
|
||||||
import: Import
|
import: Import
|
||||||
|
|||||||
0
media/banners/.gitkeep
Normal file
0
media/banners/.gitkeep
Normal file
@@ -110,6 +110,7 @@ end
|
|||||||
logger.info(W3DHub::LOG_TAG) { "Launching window..." }
|
logger.info(W3DHub::LOG_TAG) { "Launching window..." }
|
||||||
# W3DHub::Window.new(width: 980, height: 720, borderless: false, resizable: true).show unless defined?(Ocra)
|
# W3DHub::Window.new(width: 980, height: 720, borderless: false, resizable: true).show unless defined?(Ocra)
|
||||||
W3DHub::Window.new(width: 1280, height: 800, borderless: false, resizable: true).show unless defined?(Ocra)
|
W3DHub::Window.new(width: 1280, height: 800, borderless: false, resizable: true).show unless defined?(Ocra)
|
||||||
|
# W3DHub::Window.new(width: 1920, height: 1080, borderless: false, resizable: true).show unless defined?(Ocra)
|
||||||
W3DHub::BackgroundWorker.shutdown!
|
W3DHub::BackgroundWorker.shutdown!
|
||||||
|
|
||||||
# Wait for BackgroundWorker to return
|
# Wait for BackgroundWorker to return
|
||||||
|
|||||||
Reference in New Issue
Block a user