From 26a3d98d676de6c934ce44a1d37462cfdfc43f75 Mon Sep 17 00:00:00 2001 From: Cyberarm Date: Mon, 25 Apr 2022 16:24:22 -0500 Subject: [PATCH] Tweaked layout for Interface and Games page, initial work on offline mode (will crash atm if offline mode is triggered) --- lib/pages/games_redesign.rb | 153 ++++++++++++++++++++----------- lib/states/boot.rb | 10 +- lib/states/interface_redesign.rb | 2 +- lib/theme.rb | 4 +- locales/en.yml | 1 + media/banners/.gitkeep | 0 w3d_hub_linux_launcher.rb | 1 + 7 files changed, 116 insertions(+), 55 deletions(-) create mode 100644 media/banners/.gitkeep diff --git a/lib/pages/games_redesign.rb b/lib/pages/games_redesign.rb index 6917e7e..8e9e06d 100644 --- a/lib/pages/games_redesign.rb +++ b/lib/pages/games_redesign.rb @@ -3,21 +3,28 @@ class W3DHub class Games < Page def setup @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" } - @focused_channel ||= @focused_game.channels.find { |c| c.id == Store.settings[:last_selected_channel] } - @focused_channel ||= @focused_game.channels.first + + # 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 == "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 - # Games List - @games_list_container = stack(width: 148, height: 1.0, scroll: true, border_thickness_right: 1, border_color_right: 0xff_656565) do - end + stack(width: 1.0, height: 1.0) do + # Games List + @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_page_container = stack(fill: true, height: 1.0) do + # Game Menu + @game_page_container = stack(width: 1.0, fill: true) do + end end end + # return if Store.offline_mode + populate_game_page(@focused_game, @focused_channel) populate_games_list end @@ -29,22 +36,23 @@ class W3DHub Store.applications.games.each do |game| selected = game == @focused_game - game_button = stack(width: 1.0, border_thickness_left: 4, - border_color_left: selected ? 0xff_00acff : 0x00_000000, + game_button = stack(width: 64, height: 1.0, border_thickness_bottom: 4, + border_color_bottom: selected ? 0xff_00acff : 0x00_000000, 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 - flow(width: 1.0, height: 48) 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/import.png", width: 0.5, color: 0x88_ffffff unless Store.application_manager.installed?(game.id, game.channels.first.id) - end + flow(width: 1.0, height: 1.0, padding: 8) 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/import.png", width: 0.5, color: 0x88_ffffff unless Store.application_manager.installed?(game.id, game.channels.first.id) + # 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 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 - inscription game.name, width: 1.0, text_align: :center + + # inscription game.name, width: 1.0, text_align: :center, text_size: 14 end def game_button.hit_element?(x, y) @@ -77,10 +85,17 @@ class W3DHub stack(width: 360, height: 1.0, padding: 8, scroll: true) do # background 0xff_550055 - flow(width: 1.0, height: 200) do + # Game Banner + stack(width: 360, height: 200, padding: 8) do # 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 if Store.application_manager.installed?(game.id, channel.id) @@ -123,7 +138,7 @@ class W3DHub # background 0xff_444411 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 }) end @@ -131,23 +146,24 @@ class W3DHub end # 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 if Store.application_manager.installed?(game.id, channel.id) if Store.application_manager.updateable?(game.id, channel.id) - button "#{I18n.t(:"interface.install_update")}", margin_left: 24, **UPDATE_BUTTON do + button "#{I18n.t(:"interface.install_update")}", text_size: 32, **UPDATE_BUTTON do Store.application_manager.update(game.id, channel.id) end else - button "#{I18n.t(:"interface.play_now")}", margin_left: 24 do + button "#{I18n.t(:"interface.play")}", fill: true, text_size: 32, padding_left: 32, padding_right: 32 do Store.application_manager.play_now(game.id, channel.id) end end - button "#{I18n.t(:"interface.single_player")}", 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) end + else installing = Store.application_manager.task?(:installer, game.id, channel.id) @@ -166,9 +182,20 @@ class W3DHub end end - # Game News - @game_news_container = flow(fill: true, height: 1.0, padding: 8, scroll: true) do - # background 0xff_005500 + stack(fill: true, height: 1.0) do + # Game Description + 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 @@ -217,39 +244,63 @@ class W3DHub if (feed = @game_news[game.id]) @game_news_container.clear do - flow(width: 1.0, height: 150) do - background 0xaa_444400 + # Patch Notes + 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 "Patch 2.0 is now out!" + + 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 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 - # background 0x88_000000 + flow(width: 346, height: 346, margin: 8, border_thickness: 1, border_color: game.color) do + background 0x88_000000 path = Cache.path(item.image) 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 - image BLACK_IMAGE, width: 0.4, padding: 4 - end - - stack(width: 0.6, height: 1.0) do - stack(width: 1.0, height: 112) do - link "#{item.title}", 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 + 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 + Launchy.open(item.uri) end end + + para "#{item.title}", 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 diff --git a/lib/states/boot.rb b/lib/states/boot.rb index f5d9d9e..0def1fe 100644 --- a/lib/states/boot.rb +++ b/lib/states/boot.rb @@ -21,6 +21,8 @@ class W3DHub server_list: { started: false, complete: false } } + @offline_mode = false + @task_index = 0 stack(width: 1.0, height: 1.0, border_thickness: 1, border_color: 0xff_aaaaaa) do @@ -52,7 +54,9 @@ class W3DHub @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]] @@ -115,6 +119,10 @@ class W3DHub @tasks[:service_status][:complete] = true else 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 diff --git a/lib/states/interface_redesign.rb b/lib/states/interface_redesign.rb index 988f1b4..a7e5735 100644 --- a/lib/states/interface_redesign.rb +++ b/lib/states/interface_redesign.rb @@ -23,7 +23,7 @@ class W3DHub @page = nil @pages = {} - Store.application_manager.auto_import + Store.application_manager.auto_import # unless Store.offline_mode theme(W3DHub::THEME) diff --git a/lib/theme.rb b/lib/theme.rb index 8758f61..37da598 100644 --- a/lib/theme.rb +++ b/lib/theme.rb @@ -48,8 +48,8 @@ class W3DHub Button: { text_size: 18, padding_top: 8, - padding_left: 32, - padding_right: 32, + padding_left: 16, + padding_right: 16, padding_bottom: 8, border_color: Gosu::Color::NONE, background: 0xff_00acff, diff --git a/locales/en.yml b/locales/en.yml index 46f10d2..14a8383 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -17,6 +17,7 @@ en: download_manager: Download Manager downloads: Downloads play_now: Play Now + play: Play install_update: Install Update single_player: Single Player import: Import diff --git a/media/banners/.gitkeep b/media/banners/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/w3d_hub_linux_launcher.rb b/w3d_hub_linux_launcher.rb index 71ea1ed..d1c8c30 100644 --- a/w3d_hub_linux_launcher.rb +++ b/w3d_hub_linux_launcher.rb @@ -110,6 +110,7 @@ end 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: 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! # Wait for BackgroundWorker to return