Compare commits

...

2 Commits

9 changed files with 78 additions and 85 deletions

View File

@@ -36,6 +36,13 @@ class W3DHub
color = @data[:"extended-data"].find { |h| h[:name] == "colour" }[:value].sub("#", "")
@color = "ff#{color}".to_i(16)
cfg = @data[:"extended-data"].find { |h| h[:name] == "usesEngineCfg" }
@uses_engine_cfg = (cfg && cfg[:value].downcase.strip == "true") == true # explicit truthy compare to prevent return `nil`
end
def uses_engine_cfg?
@uses_engine_cfg
end
class Channel

View File

@@ -1,52 +0,0 @@
module CyberarmEngine
class GuiState < CyberarmEngine::GameState
def menu(host_element, items:, width: 200)
container = CyberarmEngine::Element::Stack.new(
parent: host_element.parent,
width: width,
theme: W3DHub::THEME,
border_color: 0xff_000000,
border_thickness: 1
)
container.instance_variable_set(:"@__menu", host_element)
container.define_singleton_method(:recalculate_menu) do
@x = @__menu.x
@y = @__menu.y + @__menu.height
@y = @__menu.y - height if @y + height > window.height
end
def container.recalculate
super
recalculate_menu
end
items.each do |item|
btn = CyberarmEngine::Element::Button.new(
item[:label],
{
parent: container,
width: 1.0,
text_align: :left,
theme: W3DHub::THEME,
border_thickness: 0,
margin: 0
},
proc do
item[:block]&.call
end
)
container.add(btn)
end
container.recalculate
container.recalculate
container.recalculate
show_menu(container)
end
end
end

View File

@@ -47,9 +47,5 @@ class W3DHub
def button_up(id)
end
def menu(host_element, items:)
@host.menu(host_element, items: items)
end
end
end

View File

@@ -187,20 +187,36 @@ class W3DHub
end
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 { push_state(States::GameSettingsDialog, app_id: game.id, channel: channel.id) } } #, 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"
items << { label: I18n.t(:"games.repair_installation"), block: proc { Store.application_manager.repair(game.id, channel.id) } } unless Store.offline_mode
items << { label: I18n.t(:"games.uninstall_game"), block: proc { Store.application_manager.uninstall(game.id, channel.id) } } unless Store.offline_mode
menu(parent: btn) do
menu_item(I18n.t(:"games.game_settings")) do
if game.uses_engine_cfg?
push_state(States::GameSettingsDialog, app_id: game.id, channel: channel.id)
else
Store.application_manager.wwconfig(game.id, channel.id)
end
end
# From gui_state_ext.rb
# TODO: Implement in engine proper
menu(btn, items: items)
if W3DHub.unix?
menu_item(I18n.t(:"games.wine_configuration")) do
Store.application_manager.wine_configuration(game.id, channel.id)
end
end
unless Store.offline_mode
menu_item(I18n.t(:"games.game_modifications")) do
populate_game_modifications(game, channel)
end
if game.id != "ren"
menu_item(I18n.t(:"games.repair_installation")) do
Store.application_manager.repair(game.id, channel.id)
end
menu_item(I18n.t(:"games.uninstall_game")) do
Store.application_manager.uninstall(game.id, channel.id)
end
end
end
end.show
end
else

View File

@@ -56,6 +56,22 @@ class W3DHub
if @offline_mode || (@progressbar.value >= 1.0 && @task_index == @tasks.size)
pop_state
# --- Repair/Upgrade settings schema/data
Store.settings[:favorites] ||= {}
# add game colo[u]r and uses_engine_cfg to application data
unless @offline_mode
Store.settings[:games].each do |key, game|
application = Store.applications.games.find { |g| g.id == key.to_s.split("_", 2).first }
next unless application
game[:colour] = application.color
game[:uses_engine_cfg] = application.uses_engine_cfg?
end
end
Store.settings.save_settings
push_state(States::Interface)
end
@@ -228,7 +244,10 @@ class W3DHub
"studio-id": "",
channels: [],
"web-links": [],
"extended-data": [{ name: "colour", value: "#353535" }]
"extended-data": [
{ name: "colour", value: game[:colour] },
{ name: "usesEngineCfg", value: game[:uses_engine_cfg] },
]
}
channel = {

View File

@@ -2,6 +2,10 @@ class W3DHub
class States
class GameSettingsDialog < Dialog
BUTTON_STYLE = { text_size: 18, padding_top: 3, padding_bottom: 3, padding_left: 3, padding_right: 3, height: 18 }
LIST_ITEM_THEME = Marshal.load(Marshal.dump(THEME))
BUTTON_STYLE.each do |key, value|
LIST_ITEM_THEME[:Button][key] = value
end
def setup
window.show_cursor = true
@@ -88,7 +92,7 @@ class W3DHub
current_res = "#{@game_settings.get_value(:resolution_width)}x#{@game_settings.get_value(:resolution_height)}"
para "Resolution", fill: true, text_wrap: :none
list_box items: res_options, choose: current_res, width: 172, **BUTTON_STYLE do |value|
list_box items: res_options, choose: current_res, width: 172, theme: LIST_ITEM_THEME, **BUTTON_STYLE do |value|
w, h = value.split("x", 2)
@game_settings.set_value(:resolution_width, w.to_i)
@@ -98,7 +102,7 @@ class W3DHub
flow(width: 1.0, height: 28, margin: 4, margin_left: 10) do
para "Windowed Mode", fill: true, text_wrap: :none
list_box items: @game_settings.get(:windowed_mode).options.map { |v| v[0] }, choose: @game_settings.get_value(:windowed_mode), width: 172, **BUTTON_STYLE do |value|
list_box items: @game_settings.get(:windowed_mode).options.map { |v| v[0] }, choose: @game_settings.get_value(:windowed_mode), width: 172, theme: LIST_ITEM_THEME, **BUTTON_STYLE do |value|
@game_settings.set_value(:windowed_mode, value)
end
end
@@ -112,7 +116,7 @@ class W3DHub
flow(width: 1.0, height: 28, margin: 4, margin_left: 10) do
para "Anti-aliasing", fill: true, text_wrap: :none
list_box items: @game_settings.get(:anti_aliasing).options.map { |v| v[0] }, choose: @game_settings.get_value(:anti_aliasing), width: 72, **BUTTON_STYLE do |value|
list_box items: @game_settings.get(:anti_aliasing).options.map { |v| v[0] }, choose: @game_settings.get_value(:anti_aliasing), width: 72, theme: LIST_ITEM_THEME, **BUTTON_STYLE do |value|
@game_settings.set_value(:anti_aliasing, value)
end
end
@@ -191,35 +195,35 @@ class W3DHub
flow(width: 1.0, height: 28, margin: 4, margin_left: 10) do
para "Texture Detail", fill: true, text_wrap: :none
list_box items: @game_settings.get(:texture_detail).options.map { |v| v[0] }, choose: @game_settings.get_value(:texture_detail), width: 172, **BUTTON_STYLE do |value|
list_box items: @game_settings.get(:texture_detail).options.map { |v| v[0] }, choose: @game_settings.get_value(:texture_detail), width: 172, theme: LIST_ITEM_THEME, **BUTTON_STYLE do |value|
@game_settings.set_value(:texture_detail, value)
end
end
flow(width: 1.0, height: 28, margin: 4, margin_left: 10) do
para "Texture Filtering", fill: true, text_wrap: :none
list_box items: @game_settings.get(:texture_filtering).options.map { |v| v[0] }, choose: @game_settings.get_value(:texture_filtering), width: 172, **BUTTON_STYLE do |value|
list_box items: @game_settings.get(:texture_filtering).options.map { |v| v[0] }, choose: @game_settings.get_value(:texture_filtering), width: 172, theme: LIST_ITEM_THEME, **BUTTON_STYLE do |value|
@game_settings.set_value(:texture_filtering, value)
end
end
# flow(width: 1.0, height: 28, margin: 4, margin_left: 10) do
# para "Shader Detail", fill: true
# list_box items: @game_settings.get(:texture_filtering).options.map { |v| v[0] }, choose: @game_settings.get_value(:texture_filtering), width: 172, **BUTTON_STYLE do |value|
# list_box items: @game_settings.get(:texture_filtering).options.map { |v| v[0] }, choose: @game_settings.get_value(:texture_filtering), width: 172, theme: LIST_ITEM_THEME, **BUTTON_STYLE do |value|
# @game_settings.set_value(:texture_filtering, value)
# end
# end
# flow(width: 1.0, height: 28, margin: 4, margin_left: 10) do
# para "Post Processing Detail", fill: true
# list_box items: @game_settings.get(:texture_filtering).options.map { |v| v[0] }, choose: @game_settings.get_value(:texture_filtering), width: 172, **BUTTON_STYLE do |value|
# list_box items: @game_settings.get(:texture_filtering).options.map { |v| v[0] }, choose: @game_settings.get_value(:texture_filtering), width: 172, theme: LIST_ITEM_THEME, **BUTTON_STYLE do |value|
# @game_settings.set_value(:texture_filtering, value)
# end
# end
flow(width: 1.0, height: 28, margin: 4, margin_left: 10) do
para "Shadow Resolution", fill: true, text_wrap: :none
list_box items: @game_settings.get(:shadow_resolution).options.map { |v| v[0] }, choose: @game_settings.get_value(:shadow_resolution), width: 172, **BUTTON_STYLE do |value|
list_box items: @game_settings.get(:shadow_resolution).options.map { |v| v[0] }, choose: @game_settings.get_value(:shadow_resolution), width: 172, theme: LIST_ITEM_THEME, **BUTTON_STYLE do |value|
@game_settings.set_value(:shadow_resolution, value)
end
end
@@ -233,7 +237,7 @@ class W3DHub
flow(width: 1.0, height: 28, margin: 4, margin_left: 10) do
para "FPS Limit", fill: true, text_wrap: :none
list_box items: @game_settings.get(:fps).options.map { |v| v[0] }, choose: @game_settings.get_value(:fps), width: 172, **BUTTON_STYLE do |value|
list_box items: @game_settings.get(:fps).options.map { |v| v[0] }, choose: @game_settings.get_value(:fps), width: 172, theme: LIST_ITEM_THEME, **BUTTON_STYLE do |value|
@game_settings.set_value(:fps, value.to_i)
end
end

View File

@@ -142,6 +142,16 @@ class W3DHub
active: {
background: 0xff_005aad
}
},
Menu: {
width: 200,
border_color: 0xaa_efefef,
border_thickness: 1
},
MenuItem: {
width: 1.0,
text_left: :left,
margin: 0
}
}
end

View File

@@ -10,11 +10,6 @@ class W3DHub
Store[:main_thread_queue] = []
# Repair/Upgrade schema
Store.settings[:favorites] ||= {}
Store.settings.save_settings
begin
I18n.locale = Store.settings[:language]
rescue I18n::InvalidLocale

View File

@@ -85,8 +85,6 @@ I18n.load_path << Dir["#{W3DHub::GAME_ROOT_PATH}/locales/*.yml"]
I18n.default_locale = :en
# GUI_DEBUG = true
require_relative "lib/gui_state_ext"
require_relative "lib/win32_stub" unless Gem.win_platform?
require_relative "lib/version"