Added support for favoriting games like Battle.net

This commit is contained in:
2022-07-31 10:31:17 -05:00
parent af82432348
commit 6055e8f65c
5 changed files with 78 additions and 17 deletions

View File

@@ -3,7 +3,7 @@ GEM
specs: specs:
addressable (2.8.0) addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0) public_suffix (>= 2.0.2, < 5.0)
async (1.30.2) async (1.30.3)
console (~> 1.10) console (~> 1.10)
nio4r (~> 2.3) nio4r (~> 2.3)
timers (~> 4.1) timers (~> 4.1)
@@ -34,15 +34,16 @@ GEM
gosu_more_drawables (~> 0.3) gosu_more_drawables (~> 0.3)
digest-crc (0.6.4) digest-crc (0.6.4)
rake (>= 12.0.0, < 14.0.0) rake (>= 12.0.0, < 14.0.0)
excon (0.92.3) excon (0.92.4)
ffi (1.15.5) ffi (1.15.5)
ffi (1.15.5-x64-mingw-ucrt) ffi (1.15.5-x64-mingw-ucrt)
ffi (1.15.5-x64-mingw32) ffi (1.15.5-x64-mingw32)
fiber-local (1.0.0) fiber-local (1.0.0)
gosu (1.4.3) gosu (1.4.3)
gosu_more_drawables (0.3.1) gosu_more_drawables (0.3.1)
i18n (1.10.0) i18n (1.12.0)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
ircparser (1.0.0)
launchy (2.5.0) launchy (2.5.0)
addressable (~> 2.7) addressable (~> 2.7)
nio4r (2.5.8) nio4r (2.5.8)
@@ -76,9 +77,10 @@ DEPENDENCIES
digest-crc digest-crc
ffi ffi
i18n i18n
ircparser
launchy launchy
rexml rexml
thread-local thread-local
BUNDLED WITH BUNDLED WITH
2.3.3 2.3.17

View File

@@ -234,6 +234,34 @@ class W3DHub
join_server(app_id, channel, server) join_server(app_id, channel, server)
end 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 def auto_import
return unless W3DHub.windows? return unless W3DHub.windows?

View File

@@ -36,14 +36,18 @@ class W3DHub
stack(width: 128, height: 1.0) do stack(width: 128, height: 1.0) do
flow(fill: true) flow(fill: true)
button "All Games", enabled: false, tip: "Under Construction" do button "All Games" do
populate_all_games_view populate_all_games_view
end end
flow(fill: true) flow(fill: true)
end end
has_favorites = Store.settings[:favorites].size.positive?
Store.applications.games.each do |game| Store.applications.games.each do |game|
next if has_favorites && !Store.application_manager.favorite?(game.id)
selected = game == @focused_game selected = game == @focused_game
game_button = stack(width: 64, height: 1.0, border_thickness_bottom: 4, game_button = stack(width: 64, height: 1.0, border_thickness_bottom: 4,
@@ -299,13 +303,13 @@ class W3DHub
end end
flow(width: 1.0, height: 48, margin_top: 8) do 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 tagline "0", fill: true, text_align: :right
end end
flow(width: 1.0, height: 48, margin_top: 8) do flow(width: 1.0, height: 48, margin_top: 8) do
button "Favorites", width: 280 button "Favorites", enabled: false, width: 280
tagline "0", fill: true, text_align: :right tagline Store.settings[:favorites].count, fill: true, text_align: :right
end end
end end
@@ -315,20 +319,42 @@ class W3DHub
flow(width: 1.0, fill: true, scroll: true) do flow(width: 1.0, fill: true, scroll: true) do
Store.applications.games.each do |game| 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 stack(width: 166, height: 224, margin: 8, background: 0x88_151515, border_color: game.color, border_thickness: 1) do
flow(width: 1.0, height: 24) do flow(width: 1.0, height: 24, padding: 8) do
para "Favorite", fill: true 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 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" container = stack(fill: true, width: 1.0, padding: 8) do
flow(width: 1.0, margin_top: 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(fill: true) flow(width: 1.0, margin_top: 8) do
image image_path, width: 0.5 flow(fill: true)
flow(fill: true) image image_path, width: 0.5
flow(fill: true)
end
caption game.name, margin_top: 8
end 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 end
end end

View File

@@ -15,6 +15,8 @@ class W3DHub
account: {}, account: {},
applications: {}, applications: {},
games: {}, games: {},
favorites: {},
app_order: {},
last_selected_app: "ren", last_selected_app: "ren",
last_selected_channel: "release" last_selected_channel: "release"
} }

View File

@@ -9,6 +9,9 @@ class W3DHub
Store[:main_thread_queue] = [] Store[:main_thread_queue] = []
# Repair/Upgrade schema
Store.settings[:favorites] ||= {}
Store.settings.save_settings Store.settings.save_settings
begin begin