diff --git a/lib/application_manager.rb b/lib/application_manager.rb
index b9c835f..7a9cd70 100644
--- a/lib/application_manager.rb
+++ b/lib/application_manager.rb
@@ -88,7 +88,7 @@ class W3DHub
return false if !installed?(app_id, channel) || installing?(app_id, channel)
- return false unless (game = Store.applications.games.find { |g| g.id == app_id})
+ return false unless (game = Store.applications.games.find { |g| g.id == app_id })
push_state(
States::ConfirmDialog,
@@ -255,6 +255,25 @@ class W3DHub
@tasks.find { |t| t.is_a?(Installer) && t.app_id == app_id && t.release_channel == channel }
end
+ def updateable?(app_id, channel)
+ installed_app = installed?(app_id, channel)
+
+ return false unless installed_app
+
+ listed_app = Store.applications.games.find { |g| g.id == app_id }
+
+ return false unless listed_app
+
+ listed_app_channel = listed_app&.channels&.find { |c| c.id == channel }
+
+ return false unless listed_app_channel
+
+ current_version = Gem::Version.new(installed_app[:installed_version])
+ listed_version = Gem::Version.new(listed_app_channel.current_version)
+
+ listed_version > current_version
+ end
+
# No application tasks are being done
def idle?
!busy?
diff --git a/lib/pages/games.rb b/lib/pages/games.rb
index d70dc57..0549152 100644
--- a/lib/pages/games.rb
+++ b/lib/pages/games.rb
@@ -128,8 +128,14 @@ class W3DHub
# background 0xff_551100
if Store.application_manager.installed?(game.id, channel.id)
- button "#{I18n.t(:"interface.play_now")}", margin_left: 24 do
- Store.application_manager.play_now(game.id, channel.id)
+ if Store.application_manager.updateable?(game.id, channel.id)
+ button "#{I18n.t(:"interface.update_now")}", margin_left: 24, background: 0xff_ffac00 do
+ # Store.application_manager.update(game.id, channel.id)
+ end
+ else
+ button "#{I18n.t(:"interface.play_now")}", margin_left: 24 do
+ Store.application_manager.play_now(game.id, channel.id)
+ end
end
button "#{I18n.t(:"interface.single_player")}", margin_left: 24 do
diff --git a/lib/pages/server_browser.rb b/lib/pages/server_browser.rb
index 5b8060d..0c7feff 100644
--- a/lib/pages/server_browser.rb
+++ b/lib/pages/server_browser.rb
@@ -204,8 +204,9 @@ class W3DHub
stack(width: 1.0, height: 0.25) do
game_installed = Store.application_manager.installed?(server.game, Store.applications.games.find { |g| g.id == server.game }.channels.first.id)
+ game_updated = Store.application_manager.updateable?(server.game, Store.applications.games.find { |g| g.id == server.game }.channels.first.id)
- button "#{I18n.t(:"server_browser.join_server")}", enabled: !game_installed.nil? do
+ button "#{I18n.t(:"server_browser.join_server")}", enabled: (game_installed && !game_updated) do
# Check for nickname
# prompt for nickname
# !abort unless nickname set
diff --git a/locales/en.yml b/locales/en.yml
index 11a3280..074aeb9 100644
--- a/locales/en.yml
+++ b/locales/en.yml
@@ -15,6 +15,7 @@ en:
community: Community
download_manager: Download Manager
play_now: Play Now
+ update_now: Update Now
single_player: Single Player
import: Import
install: Install