mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 09:12:35 +00:00
Added confirm dialog, clicking uninstall game now triggers confirmation
This commit is contained in:
@@ -123,8 +123,8 @@ class W3DHub
|
|||||||
|
|
||||||
# /apis/w3dhub/1/get-news
|
# /apis/w3dhub/1/get-news
|
||||||
# Client sends an Authorization header bearer token which is received from logging in (Optional)
|
# Client sends an Authorization header bearer token which is received from logging in (Optional)
|
||||||
# Client requests news for a specific application/game e.g.: data={"category":"ia"}
|
# Client requests news for a specific application/game e.g.: data={"category":"ia"} ("launcher-home" retrieves the weekly hub updates)
|
||||||
# Response is a JSON hash with a "highlighted" and "news" keys; the "news" on seems to be the desired one
|
# Response is a JSON hash with a "highlighted" and "news" keys; the "news" one seems to be the desired one
|
||||||
def self.news(category)
|
def self.news(category)
|
||||||
response = W3DHUB_API_CONNECTION.post(
|
response = W3DHUB_API_CONNECTION.post(
|
||||||
path: "apis/w3dhub/1/get-news",
|
path: "apis/w3dhub/1/get-news",
|
||||||
|
|||||||
@@ -84,11 +84,20 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def uninstall(app_id, channel)
|
def uninstall(app_id, channel)
|
||||||
puts "Uninstall Request: #{app_idchannel}"
|
puts "Uninstall Request: #{app_id} #{channel}"
|
||||||
|
|
||||||
return false if !installed?(app_id, channel) || installing?(app_id, channel)
|
return false if !installed?(app_id, channel) || installing?(app_id, channel)
|
||||||
|
|
||||||
@tasks.push(Uninstaller.new(app_id, channel))
|
return false unless (game = Store.applications.games.find { |g| g.id == app_id})
|
||||||
|
|
||||||
|
push_state(
|
||||||
|
States::ConfirmDialog,
|
||||||
|
title: "Uninstall #{game.name}?",
|
||||||
|
message: "Are you sure you want to uninstall #{game.name} (#{channel})?",
|
||||||
|
accept_callback: proc {
|
||||||
|
@tasks.push(Uninstaller.new(app_id, channel))
|
||||||
|
}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_folder(app_id, channel, type)
|
def show_folder(app_id, channel, type)
|
||||||
|
|||||||
49
lib/states/confirm_dialog.rb
Normal file
49
lib/states/confirm_dialog.rb
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
class W3DHub
|
||||||
|
class States
|
||||||
|
class ConfirmDialog < CyberarmEngine::GuiState
|
||||||
|
def setup
|
||||||
|
window.show_cursor = true
|
||||||
|
|
||||||
|
theme(W3DHub::THEME)
|
||||||
|
|
||||||
|
background 0xee_444444
|
||||||
|
|
||||||
|
stack(width: 1.0, height: 1.0, margin: 128, background: 0xee_222222) do
|
||||||
|
flow(width: 1.0, height: 0.1, padding: 8) do
|
||||||
|
background 0x88_000000
|
||||||
|
|
||||||
|
image "#{GAME_ROOT_PATH}/media/ui_icons/question.png", width: 0.04, align: :center, color: 0xaa_ff0000
|
||||||
|
|
||||||
|
tagline "<b>#{@options[:title]}</b>", width: 0.9, text_align: :center
|
||||||
|
end
|
||||||
|
|
||||||
|
stack(width: 1.0, height: 0.78, padding: 16) do
|
||||||
|
para @options[:message], width: 1.0, text_align: :center
|
||||||
|
end
|
||||||
|
|
||||||
|
flow(width: 1.0, height: 0.1, padding: 8) do
|
||||||
|
button "Cancel", width: 0.25 do
|
||||||
|
pop_state
|
||||||
|
@options[:cancel_callback]&.call
|
||||||
|
end
|
||||||
|
|
||||||
|
stack(width: 0.5)
|
||||||
|
|
||||||
|
button "Confirm", width: 0.25, background: 0xff_800000, hover: { background: 0xff_d00000 }, active: { background: 0xff_600000, color: 0xff_ffffff } do
|
||||||
|
pop_state
|
||||||
|
@options[:accept_callback]&.call
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def draw
|
||||||
|
previous_state&.draw
|
||||||
|
|
||||||
|
Gosu.flush
|
||||||
|
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -44,6 +44,7 @@ require_relative "lib/states/boot"
|
|||||||
require_relative "lib/states/interface"
|
require_relative "lib/states/interface"
|
||||||
require_relative "lib/states/message_dialog"
|
require_relative "lib/states/message_dialog"
|
||||||
require_relative "lib/states/prompt_dialog"
|
require_relative "lib/states/prompt_dialog"
|
||||||
|
require_relative "lib/states/confirm_dialog"
|
||||||
|
|
||||||
require_relative "lib/api"
|
require_relative "lib/api"
|
||||||
require_relative "lib/api/service_status"
|
require_relative "lib/api/service_status"
|
||||||
|
|||||||
Reference in New Issue
Block a user