Moved dialogs into subfolder, refactored dialogs to use new Dialog class, removed pre-redesign Interface and Game states/pages

This commit is contained in:
2023-11-19 13:03:05 -06:00
parent d83a439ad1
commit 6988702db2
10 changed files with 449 additions and 1156 deletions

View File

@@ -1,6 +1,6 @@
class W3DHub
class States
class ConfirmDialog < CyberarmEngine::GuiState
class ConfirmDialog < Dialog
def setup
window.show_cursor = true
@@ -36,14 +36,6 @@ class W3DHub
end
end
end
def draw
previous_state&.draw
Gosu.flush
super
end
end
end
end

View File

@@ -1,6 +1,6 @@
class W3DHub
class States
class DirectConnectDialog < CyberarmEngine::GuiState
class DirectConnectDialog < Dialog
def setup
window.show_cursor = true
W3DHub::Store[:asterisk_config] ||= Asterisk::Config.new
@@ -214,14 +214,6 @@ class W3DHub
end
end
def draw
previous_state&.draw
Gosu.flush
super
end
def populate_from_server_profile(profile)
@server_nickname.value = profile.nickname
@server_password.value = Base64.strict_decode64(profile.password)

View File

@@ -1,6 +1,6 @@
class W3DHub
class States
class MessageDialog < CyberarmEngine::GuiState
class MessageDialog < Dialog
def setup
window.show_cursor = true
@@ -28,14 +28,6 @@ class W3DHub
end
end
end
def draw
previous_state&.draw
Gosu.flush
super
end
end
end
end

View File

@@ -1,6 +1,6 @@
class W3DHub
class States
class PromptDialog < CyberarmEngine::GuiState
class PromptDialog < Dialog
def setup
window.show_cursor = true
@@ -65,14 +65,6 @@ class W3DHub
end
end
end
def draw
previous_state&.draw
Gosu.flush
super
end
end
end
end

View File

@@ -1,163 +0,0 @@
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

@@ -23,91 +23,84 @@ class W3DHub
@page = nil
@pages = {}
Store.application_manager.auto_import
Store.application_manager.auto_import # unless Store.offline_mode
theme(W3DHub::THEME)
@interface_container = flow(width: 1.0, height: 1.0) do
# TODO: Override this background color to be a darkened version of the selected games
# or a default color
background 0xff_212121..0xff_111111
@interface_container = stack(width: 1.0, height: 1.0, border_thickness: 1, border_color: W3DHub::BORDER_COLOR) do
background 0xff_252525
flow(fill: true, height: 1.0)
@header_container = flow(width: 1.0, height: 84, padding: 4, border_thickness_bottom: 1, border_color_bottom: W3DHub::BORDER_COLOR) do
flow(width: 148, height: 1.0) do
flow(fill: true)
image "#{GAME_ROOT_PATH}/media/icons/app.png", height: 84
flow(fill: true)
end
stack(width: 1.0, max_width: MAX_PAGE_WIDTH, height: 1.0, border_thickness: 1, border_color: 0xff_aaaaaa) do
background 0xff_252525
@navigation_container = stack(fill: true, height: 1.0) do
flow(width: 1.0, fill: true) do
# background 0xff_666666
@header_container = flow(width: 1.0, height: 100, padding: 4) do
image "#{GAME_ROOT_PATH}/media/icons/app.png", width: 108
stack(fill: true, height: 1.0) do
# background 0xff_885500
@app_info_container = flow(width: 1.0, height: 0.65) do
# background 0xff_8855ff
stack(fill: true, height: 1.0) do
title "<b>#{I18n.t(:"app_name")}</b>", height: 0.5
flow(width: 1.0, height: 0.5) do
@application_taskbar_container = stack(width: 1.0, height: 1.0, margin_left: 16, margin_right: 16) do
flow(width: 1.0, height: 0.65) do
@application_taskbar_label = inscription "", width: 0.60, text_wrap: :none
@application_taskbar_status_label = inscription "", width: 0.40, text_align: :right, text_wrap: :none
end
@application_taskbar_progressbar = progress fraction: 0.0, height: 2, width: 1.0
end
end
end
@account_container = flow(width: 256, height: 1.0) do
stack(width: 1.0, height: 1.0) do
tagline "<b>#{I18n.t(:"interface.not_logged_in")}</b>", text_wrap: :none
flow(width: 1.0) do
link(I18n.t(:"interface.log_in"), text_size: 16, width: 0.5) { page(W3DHub::Pages::Login) }
link I18n.t(:"interface.register"), text_size: 16, width: 0.49 do
W3DHub.url("https://secure.w3dhub.com/forum/index.php?app=core&module=global&section=register")
end
end
end
end
link I18n.t(:"interface.games").upcase, text_size: 34 do
page(W3DHub::Pages::Games)
end
@navigation_container = flow(width: 1.0, height: 0.35) do
# background 0xff_666666
flow(width: 1.0, height: 1.0) do
flow(fill: true, height: 1.0) # Hacky centering
link I18n.t(:"interface.games") do
page(W3DHub::Pages::Games)
end
link I18n.t(:"interface.servers").upcase, text_size: 34, margin_left: 12 do
page(W3DHub::Pages::ServerBrowser)
end
link I18n.t(:"interface.server_browser"), margin_left: 18 do
page(W3DHub::Pages::ServerBrowser)
end
link I18n.t(:"interface.community").upcase, text_size: 34, margin_left: 12 do
page(W3DHub::Pages::Community)
end
link I18n.t(:"interface.community"), margin_left: 18 do
page(W3DHub::Pages::Community)
end
link I18n.t(:"interface.downloads").upcase, text_size: 34, margin_left: 12 do
page(W3DHub::Pages::DownloadManager)
end
link I18n.t(:"interface.downloads"), margin_left: 18 do
page(W3DHub::Pages::DownloadManager)
end
link I18n.t(:"interface.settings").upcase, text_size: 34, margin_left: 12 do
page(W3DHub::Pages::Settings)
end
end
link I18n.t(:"interface.settings"), margin_left: 18 do
page(W3DHub::Pages::Settings)
end
flow(fill: true, height: 1.0) # Hacky centering
# Installer task display
flow(width: 1.0, height: 0.5) do
@application_taskbar_container = stack(width: 1.0, height: 1.0, margin_left: 16, margin_right: 16) do
flow(width: 1.0, height: 0.65) do
@application_taskbar_label = inscription "", width: 0.60, text_wrap: :none
@application_taskbar_status_label = inscription "", width: 0.40, text_align: :right, text_wrap: :none
end
@application_taskbar_progressbar = progress fraction: 0.0, height: 2, width: 1.0
end
end
end
@content_container = flow(width: 1.0, fill: true) do
@account_container = flow(width: 256, height: 1.0) do
if Store.offline_mode
stack(width: 1.0, height: 1.0) do
flow(fill: true)
title "<b>OFFLINE</b>", text_wrap: :none, width: 1.0, text_align: :center
flow(fill: true)
end
else
stack(width: 1.0, height: 1.0) do
tagline "<b>#{I18n.t(:"interface.not_logged_in")}</b>", text_wrap: :none
flow(width: 1.0) do
link(I18n.t(:"interface.log_in"), text_size: 16, width: 0.5) { page(W3DHub::Pages::Login) }
link I18n.t(:"interface.register"), text_size: 16, width: 0.49 do
W3DHub.url("https://secure.w3dhub.com/forum/index.php?app=core&module=global&section=register")
end
end
end
end
end
end
flow(fill: true, height: 1.0)
@content_container = flow(width: 1.0, fill: true) do
end
end
if Store.account
@@ -172,6 +165,12 @@ class W3DHub
@page.refresh_server_list(server)
end
def update_server_ping(server)
return unless @page.is_a?(Pages::ServerBrowser)
@page.update_server_ping(server)
end
def show_application_taskbar
@application_taskbar_container.show
end

View File

@@ -1,223 +0,0 @@
class W3DHub
class States
class Interface < CyberarmEngine::GuiState
attr_accessor :interface_task_update_pending
@@instance = nil
def self.instance
@@instance
end
def setup
@@instance = self
window.show_cursor = true
@account = @options[:account]
@service_status = @options[:service_status]
@applications = @options[:applications]
@interface_task_update_pending = nil
@page = nil
@pages = {}
Store.application_manager.auto_import # unless Store.offline_mode
theme(W3DHub::THEME)
@interface_container = stack(width: 1.0, height: 1.0, border_thickness: 1, border_color: W3DHub::BORDER_COLOR) do
background 0xff_252525
@header_container = flow(width: 1.0, height: 84, padding: 4, border_thickness_bottom: 1, border_color_bottom: W3DHub::BORDER_COLOR) do
flow(width: 148, height: 1.0) do
flow(fill: true)
image "#{GAME_ROOT_PATH}/media/icons/app.png", height: 84
flow(fill: true)
end
@navigation_container = stack(fill: true, height: 1.0) do
flow(width: 1.0, fill: true) do
# background 0xff_666666
link I18n.t(:"interface.games").upcase, text_size: 34 do
page(W3DHub::Pages::Games)
end
link I18n.t(:"interface.servers").upcase, text_size: 34, margin_left: 12 do
page(W3DHub::Pages::ServerBrowser)
end
link I18n.t(:"interface.community").upcase, text_size: 34, margin_left: 12 do
page(W3DHub::Pages::Community)
end
link I18n.t(:"interface.downloads").upcase, text_size: 34, margin_left: 12 do
page(W3DHub::Pages::DownloadManager)
end
link I18n.t(:"interface.settings").upcase, text_size: 34, margin_left: 12 do
page(W3DHub::Pages::Settings)
end
end
# Installer task display
flow(width: 1.0, height: 0.5) do
@application_taskbar_container = stack(width: 1.0, height: 1.0, margin_left: 16, margin_right: 16) do
flow(width: 1.0, height: 0.65) do
@application_taskbar_label = inscription "", width: 0.60, text_wrap: :none
@application_taskbar_status_label = inscription "", width: 0.40, text_align: :right, text_wrap: :none
end
@application_taskbar_progressbar = progress fraction: 0.0, height: 2, width: 1.0
end
end
end
@account_container = flow(width: 256, height: 1.0) do
if Store.offline_mode
stack(width: 1.0, height: 1.0) do
flow(fill: true)
title "<b>OFFLINE</b>", text_wrap: :none, width: 1.0, text_align: :center
flow(fill: true)
end
else
stack(width: 1.0, height: 1.0) do
tagline "<b>#{I18n.t(:"interface.not_logged_in")}</b>", text_wrap: :none
flow(width: 1.0) do
link(I18n.t(:"interface.log_in"), text_size: 16, width: 0.5) { page(W3DHub::Pages::Login) }
link I18n.t(:"interface.register"), text_size: 16, width: 0.49 do
W3DHub.url("https://secure.w3dhub.com/forum/index.php?app=core&module=global&section=register")
end
end
end
end
end
end
@content_container = flow(width: 1.0, fill: true) do
end
end
if Store.account
page(W3DHub::Pages::Login)
else
page(W3DHub::Pages::Games)
end
hide_application_taskbar
end
def draw
super
@page&.draw
end
def update
super
@page&.update
update_interface_task_status(@interface_task_update_pending) if @interface_task_update_pending
end
def button_down(id)
super
@page&.button_down(id)
end
def button_up(id)
super
@page&.button_up(id)
end
def body
@content_container
end
def page(klass, options = {})
body.clear
@page.blur if @page
@pages[klass] = klass.new(host: self) unless @pages[klass]
@page = @pages[klass]
@page.options = options
@page.setup
@page.focus
end
def current_page
@page
end
def update_server_browser(server)
return unless @page.is_a?(Pages::ServerBrowser)
@page.refresh_server_list(server)
end
def update_server_ping(server)
return unless @page.is_a?(Pages::ServerBrowser)
@page.update_server_ping(server)
end
def show_application_taskbar
@application_taskbar_container.show
end
def hide_application_taskbar
@application_taskbar_container.hide
end
def update_interface_task_status(task)
@application_taskbar_label.value = task.status.label
@application_taskbar_status_label.value = "#{task.status.value} (#{format("%.2f%%", task.status.progress.clamp(0.0, 1.0) * 100.0)})"
@application_taskbar_progressbar.value = task.status.progress.clamp(0.0, 1.0)
return unless @page.is_a?(Pages::DownloadManager)
operation_info = @page.operation_info
operation_step = @page.operation_info[:___step]
if task.status.step != operation_step
@page.regenerate(task)
return
end
task.status.operations.each do |key, operation|
name_ = operation_info["#{key}_name"]
status_ = operation_info["#{key}_status"]
progress_ = operation_info["#{key}_progress"]
next if name_.value == operation.label &&
status_.value == operation.value &&
progress_.value == operation.value
name_.value = operation.label if operation.label
status_.value = operation.value if operation.value
if operation.progress
if operation.progress == Float::INFINITY
progress_.type = :marquee unless progress_.type == :marquee
else
progress_.type = :linear unless progress_.type == :linear
progress_.value = operation.progress.clamp(0.0, 1.0)
end
end
end
end
end
end
end