diff --git a/Gemfile.lock b/Gemfile.lock index 0ea19d6..eac69b9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,7 +3,7 @@ GEM specs: addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) - async (1.30.2) + async (1.30.3) console (~> 1.10) nio4r (~> 2.3) timers (~> 4.1) @@ -34,15 +34,16 @@ GEM gosu_more_drawables (~> 0.3) digest-crc (0.6.4) rake (>= 12.0.0, < 14.0.0) - excon (0.92.3) + excon (0.92.4) ffi (1.15.5) ffi (1.15.5-x64-mingw-ucrt) ffi (1.15.5-x64-mingw32) fiber-local (1.0.0) gosu (1.4.3) gosu_more_drawables (0.3.1) - i18n (1.10.0) + i18n (1.12.0) concurrent-ruby (~> 1.0) + ircparser (1.0.0) launchy (2.5.0) addressable (~> 2.7) nio4r (2.5.8) @@ -76,9 +77,10 @@ DEPENDENCIES digest-crc ffi i18n + ircparser launchy rexml thread-local BUNDLED WITH - 2.3.3 + 2.3.17 diff --git a/lib/application_manager.rb b/lib/application_manager.rb index e0f3e33..3f660e6 100644 --- a/lib/application_manager.rb +++ b/lib/application_manager.rb @@ -234,6 +234,34 @@ class W3DHub join_server(app_id, channel, server) end + def favorive(app_id, bool) + Store.settings[:favorites] ||= {} + + if bool + Store.settings[:favorites][app_id.to_sym] = true + else + Store.settings[:favorites].delete(app_id.to_sym) + end + end + + def favorite?(app_id) + Store.settings[:favorites] ||= {} + + Store.settings[:favorites][app_id.to_sym] + end + + def app_order(app_id, int) + Store.settings[:app_order] ||= {} + + Store.settings[:app_order][app_id.to_sym] = int + end + + def app_order_index(app_id) + Store.settings[:app_order] ||= {} + + Store.settings[:app_order][app_id.to_sym] + end + def auto_import return unless W3DHub.windows? diff --git a/lib/pages/games_redesign.rb b/lib/pages/games_redesign.rb index 4446b71..aaa7683 100644 --- a/lib/pages/games_redesign.rb +++ b/lib/pages/games_redesign.rb @@ -36,14 +36,18 @@ class W3DHub stack(width: 128, height: 1.0) do flow(fill: true) - button "All Games", enabled: false, tip: "Under Construction" do + button "All Games" do populate_all_games_view end flow(fill: true) end + has_favorites = Store.settings[:favorites].size.positive? + Store.applications.games.each do |game| + next if has_favorites && !Store.application_manager.favorite?(game.id) + selected = game == @focused_game game_button = stack(width: 64, height: 1.0, border_thickness_bottom: 4, @@ -299,13 +303,13 @@ class W3DHub end flow(width: 1.0, height: 48, margin_top: 8) do - button "Installed", width: 280 + button "Installed", enabled: false, width: 280 tagline "0", fill: true, text_align: :right end flow(width: 1.0, height: 48, margin_top: 8) do - button "Favorites", width: 280 - tagline "0", fill: true, text_align: :right + button "Favorites", enabled: false, width: 280 + tagline Store.settings[:favorites].count, fill: true, text_align: :right end end @@ -315,20 +319,42 @@ class W3DHub flow(width: 1.0, fill: true, scroll: true) do Store.applications.games.each do |game| - stack(width: 150, height: 200, padding: 8, margin: 8, background: 0x88_151515, border_color: game.color, border_thickness: 1) do - flow(width: 1.0, height: 24) do + stack(width: 166, height: 224, margin: 8, background: 0x88_151515, border_color: game.color, border_thickness: 1) do + flow(width: 1.0, height: 24, padding: 8) do para "Favorite", fill: true - toggle_button checked: false, height: 1.0, padding_top: 3, padding_right: 3, padding_bottom: 3, padding_left: 3 + toggle_button checked: Store.application_manager.favorite?(game.id), text_size: 18, padding_top: 3, padding_right: 3, padding_bottom: 3, padding_left: 3 do |btn| + Store.application_manager.favorive(game.id, btn.value) + Store.settings.save_settings + + populate_games_list + 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" - flow(width: 1.0, margin_top: 8) do - flow(fill: true) - image image_path, width: 0.5 - flow(fill: true) + container = stack(fill: true, width: 1.0, padding: 8) do + 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" + flow(width: 1.0, margin_top: 8) do + flow(fill: true) + image image_path, width: 0.5 + flow(fill: true) + end + + caption game.name, margin_top: 8 end - caption game.name, margin_top: 8 + def container.hit_element?(x, y) + return unless hit?(x, y) + + self + end + + container.subscribe(:clicked_left_mouse_button) do |element| + populate_game_page(game, game.channels.first) + populate_games_list + end + + container.subscribe(:enter) do |element| + element.background = 0x88_454545 + end end end end diff --git a/lib/settings.rb b/lib/settings.rb index dd8f8e9..45d4def 100644 --- a/lib/settings.rb +++ b/lib/settings.rb @@ -15,6 +15,8 @@ class W3DHub account: {}, applications: {}, games: {}, + favorites: {}, + app_order: {}, last_selected_app: "ren", last_selected_channel: "release" } diff --git a/lib/window.rb b/lib/window.rb index 0c8ef32..47d1a7e 100644 --- a/lib/window.rb +++ b/lib/window.rb @@ -9,6 +9,9 @@ class W3DHub Store[:main_thread_queue] = [] + # Repair/Upgrade schema + Store.settings[:favorites] ||= {} + Store.settings.save_settings begin