Prototyped Game Settings dialog and an All Games view, both disabled atm.

This commit is contained in:
2022-07-26 12:19:17 -05:00
parent 5fc42a3ce9
commit af82432348
5 changed files with 269 additions and 1 deletions

View File

@@ -50,6 +50,17 @@ class W3DHub
def settings(app_id, channel)
logger.info(LOG_TAG) { "Settings Request: #{app_id}-#{channel}" }
if (app_data = installed?(app_id, channel))
_application = Store.applications.games.find { |g| g.id == app_id }
_channel = _application.channels.find { |c| c.id == channel }
push_state(W3DHub::States::GameSettingsDialog, title: "#{_application.name} (#{_channel.name}) Settings", app_id: app_id, channel: channel)
end
end
def wwconfig(app_id, channel)
logger.info(LOG_TAG) { "WWConfig Request: #{app_id}-#{channel}" }
# open wwconfig.exe or config.exe for ecw
if (app_data = installed?(app_id, channel))

View File

@@ -33,6 +33,16 @@ class W3DHub
@games_list_container.clear do
background 0xff_121920
stack(width: 128, height: 1.0) do
flow(fill: true)
button "All Games", enabled: false, tip: "Under Construction" do
populate_all_games_view
end
flow(fill: true)
end
Store.applications.games.each do |game|
selected = game == @focused_game
@@ -170,7 +180,8 @@ class W3DHub
button get_image("#{GAME_ROOT_PATH}/media/ui_icons/gear.png"), tip: I18n.t(:"games.game_options"), image_height: 32, margin_left: 0 do |btn|
items = []
items << { label: I18n.t(:"games.game_settings"), block: proc { Store.application_manager.settings(game.id, channel.id) } }
items << { label: I18n.t(:"games.game_settings"), block: proc { Store.application_manager.wwconfig(game.id, channel.id) } }
# items << { label: I18n.t(:"games.game_settings"), block: proc { Store.application_manager.settings(game.id, channel.id) } }
items << { label: I18n.t(:"games.wine_configuration"), block: proc { Store.application_manager.wine_configuration(game.id, channel.id) } } if W3DHub.unix?
items << { label: I18n.t(:"games.game_modifications"), block: proc { populate_game_modifications(game, channel) } } unless Store.offline_mode
if game.id != "ren"
@@ -262,6 +273,70 @@ class W3DHub
end
end
def populate_all_games_view
@game_page_container.clear do
background 0x88_353535
@game_page_container.style.background_image_color = 0x88_353535
@game_page_container.style.default[:background_image_color] = 0x88_353535
@game_page_container.update_background_image
@focused_game = nil
@focused_channel = nil
populate_games_list
flow(width: 1.0, height: 1.0) do
games_view_container = nil
# Options
stack(width: 360, height: 1.0, padding: 8, scroll: true, border_thickness_right: 1, border_color_right: W3DHub::BORDER_COLOR) do
background 0x55_000000
flow(width: 1.0, height: 48) do
button "All Games", width: 280 do
# games_view_container.clear
end
tagline Store.applications.games.count.to_s, fill: true, text_align: :right
end
flow(width: 1.0, height: 48, margin_top: 8) do
button "Installed", 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
end
end
# Games list
games_view_container = stack(fill: true, height: 1.0, padding: 8, margin: 8) do
title "All Games"
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
para "Favorite", fill: true
toggle_button checked: false, height: 1.0, padding_top: 3, padding_right: 3, padding_bottom: 3, padding_left: 3
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)
end
caption game.name, margin_top: 8
end
end
end
end
end
end
end
def fetch_game_news(game)
lock = Cache.acquire_net_lock("game_news_#{game.id}")
return false unless lock

View File

@@ -0,0 +1,163 @@
class W3DHub
class States
class GameSettingsDialog < CyberarmEngine::GuiState
BUTTON_STYLE = { text_size: 18, padding_top: 3, padding_bottom: 3, padding_left: 3, padding_right: 3 }
def setup
window.show_cursor = true
theme(W3DHub::THEME)
background 0xee_444444
stack(width: 1.0, max_width: 720, height: 1.0, max_height: 512, v_align: :center, h_align: :center, background: 0xee_222222) do
flow(width: 1.0, height: 0.1, padding: 8) do
background 0x88_000000
image "#{GAME_ROOT_PATH}/media/icons/#{@options[:app_id]}.png", width: 0.04, align: :center
tagline "<b>#{@options[:title]}</b>", width: 0.9, text_align: :center
end
stack(width: 1.0, fill: true, padding: 16) do
flow(width: 1.0, fill: true) do
stack(width: 0.5, height: 1.0) do
caption "General"
flow(width: 1.0, height: 24, margin: 4) do
para "Default to First Person", fill: true
toggle_button tip: "Default to First Person", **BUTTON_STYLE
end
flow(width: 1.0, height: 24, margin: 4) do
para "Enable Chat Log", fill: true
toggle_button tip: "Enable Chat Log", **BUTTON_STYLE
end
flow(width: 1.0, height: 24, margin: 4) do
para "Background Downloads", fill: true
toggle_button tip: "Background Downloads", **BUTTON_STYLE
end
flow(width: 1.0, height: 24, margin: 4) do
para "Show FPS", fill: true
toggle_button tip: "Show FPS", **BUTTON_STYLE
end
end
stack(width: 0.5, height: 1.0) do
caption "Video"
flow(width: 1.0, height: 24, margin: 4) do
para "Resolution", fill: true
list_box items: ["#{Gosu.screen_width}x#{Gosu.screen_height}"], width: 128, **BUTTON_STYLE
end
flow(width: 1.0, height: 24, margin: 4) do
para "Windowed Mode", fill: true
list_box items: ["Windowed", "Borderless", "Fullscreen"], width: 128, **BUTTON_STYLE
end
flow(width: 1.0, height: 24, margin: 4) do
para "Enable VSync", fill: true
toggle_button tip: "Enable VSync", **BUTTON_STYLE
end
flow(width: 1.0, height: 24, margin: 4) do
para "MSAA Mode", fill: true
list_box items: %w[0 2 4 8 16], width: 48, **BUTTON_STYLE
end
end
end
flow(width: 1.0, fill: true) do
stack(width: 0.5, height: 1.0) do
caption "Audio"
flow(width: 1.0, height: 24, margin: 4) do
para "Sound Effects", fill: true
slider height: 1.0, width: 172, margin_right: 8
toggle_button tip: "Sound Effects", checked: true, **BUTTON_STYLE
end
flow(width: 1.0, height: 24, margin: 4) do
para "Dialogue", fill: true
slider height: 1.0, width: 172, margin_right: 8
toggle_button tip: "Dialogue", checked: true, **BUTTON_STYLE
end
flow(width: 1.0, height: 24, margin: 4) do
para "Music", fill: true
slider height: 1.0, width: 172, margin_right: 8
toggle_button tip:"Music", checked: true, **BUTTON_STYLE
end
flow(width: 1.0, height: 24, margin: 4) do
para "Cinematic", fill: true
slider height: 1.0, width: 172, margin_right: 8
toggle_button tip: "Cinematic", checked: true, **BUTTON_STYLE
end
end
stack(width: 0.5, height: 1.0) do
caption "Performance"
flow(width: 1.0, height: 24, margin: 4) do
para "Texture Detail", fill: true
list_box items: ["Low", "Medium", "High"], width: 128, **BUTTON_STYLE
end
flow(width: 1.0, height: 24, margin: 4) do
para "Shader Detail", fill: true
list_box items: ["Low", "Medium", "High"], width: 128, **BUTTON_STYLE
end
flow(width: 1.0, height: 24, margin: 4) do
para "Post Proccessing Detail", fill: true
list_box items: ["Low", "Medium", "High"], width: 128, **BUTTON_STYLE
end
flow(width: 1.0, height: 24, margin: 4) do
para "Shadow Detail", fill: true
list_box items: ["Low", "Medium", "High"], width: 128, **BUTTON_STYLE
end
flow(width: 1.0, height: 24, margin: 4) do
para "High Quality Shadows", fill: true
toggle_button tip: "High Quality Shadows", **BUTTON_STYLE
end
end
end
end
flow(width: 1.0, height: 0.1, padding: 8) do
button "Cancel", width: 0.25 do
pop_state
@options[:cancel_callback]&.call
end
flow(fill: true)
button "WWConfig", width: 0.25 do
pop_state
Store.application_manager.wwconfig(@options[:app_id], @options[:channel])
end
flow(fill: true)
button "Save", width: 0.25 do
pop_state
@options[:accept_callback]&.call
end
end
end
end
def draw
previous_state&.draw
Gosu.flush
super
end
end
end
end

View File

@@ -76,6 +76,24 @@ class W3DHub
ListBox: {
padding_left: 8,
padding_right: 8
},
Slider: {
border_color: 0xff_00acff
},
Handle: {
text_size: 18,
padding_top: 8,
padding_left: 2,
padding_right: 2,
padding_bottom: 8,
border_color: Gosu::Color::NONE,
background: 0xff_00acff,
hover: {
background: 0xff_bee6fd
},
active: {
background: 0xff_add5ec
}
}
}
end

View File

@@ -87,6 +87,7 @@ require_relative "lib/states/message_dialog"
require_relative "lib/states/prompt_dialog"
require_relative "lib/states/confirm_dialog"
require_relative "lib/states/direct_connect_dialog"
require_relative "lib/states/game_settings_dialog"
require_relative "lib/api"
require_relative "lib/api/service_status"