diff --git a/Gemfile b/Gemfile
index dbf5a76..b669e32 100644
--- a/Gemfile
+++ b/Gemfile
@@ -10,6 +10,7 @@ gem "async", "~>1.30.1"
gem "async-http"
gem "async-websocket"
gem "thread-local"
+gem "ircparser"
# group :windows_packaging do
# gem "rake"
diff --git a/lib/asterisk/irc_profile.rb b/lib/asterisk/irc_profile.rb
index fa8f30c..3e42e52 100644
--- a/lib/asterisk/irc_profile.rb
+++ b/lib/asterisk/irc_profile.rb
@@ -1,27 +1,40 @@
class W3DHub
class Asterisk
class IRCProfile
- attr_accessor :name, :nickname, :password, :server_hostname, :server_port, :server_bot
+ attr_accessor :name,
+ :username, :nickname, :password,
+ :server_hostname, :server_port, :server_ssl, :server_verify_ssl,
+ :bot_username, :bot_auth_username, :bot_auth_password
def initialize(hash = nil)
return unless hash
@name = hash[:name]
+ @username = hash[:username] || hash[:nickname]
@nickname = hash[:nickname]
@password = hash[:password]
@server_hostname = hash[:server_hostname]
@server_port = hash[:server_port]
- @server_bot = hash[:server_bot]
+ @server_ssl = hash[:server_ssl]
+ @server_verify_ssl = hash[:server_verify_ssl]
+ @bot_username = hash[:bot_username]
+ @bot_auth_username = hash[:bot_auth_username]
+ @bot_auth_password = hash[:bot_auth_password]
end
def to_json(options)
{
name: @name,
+ username: @username,
nickname: @nickname,
password: @password,
server_hostname: @server_hostname,
server_port: @server_port,
- server_bot: @server_bot
+ server_ssl: @server_ssl,
+ server_verify_ssl: @server_verify_ssl,
+ bot_username: @bot_username,
+ bot_auth_username: @bot_auth_username,
+ bot_auth_password: @bot_auth_password
}.to_json(options)
end
end
diff --git a/lib/asterisk/states/game_form.rb b/lib/asterisk/states/game_form.rb
index 4b48984..babe1c1 100644
--- a/lib/asterisk/states/game_form.rb
+++ b/lib/asterisk/states/game_form.rb
@@ -7,9 +7,9 @@ class W3DHub
theme W3DHub::THEME
- background 0xee_444444
+ background 0xaa_444444
- stack(width: 1.0, height: 1.0, margin: 256, background: 0xee_222222) do
+ stack(width: 1.0, max_width: 760, height: 1.0, max_height: 256, v_align: :center, h_align: :center, background: 0xff_222222) do
# Title bar
flow(width: 1.0, height: 32, padding: 8) do
background 0x88_000000
@@ -74,10 +74,6 @@ class W3DHub
@save_button.enabled = valid?
end
- def close
- pop_state
- end
-
def button_down(id)
super
diff --git a/lib/asterisk/states/irc_profile_form.rb b/lib/asterisk/states/irc_profile_form.rb
index 614f4f8..9252318 100644
--- a/lib/asterisk/states/irc_profile_form.rb
+++ b/lib/asterisk/states/irc_profile_form.rb
@@ -7,71 +7,113 @@ class W3DHub
theme W3DHub::THEME
- background 0xcc_000000
+ background 0xaa_444444
- stack(width: 1.0, height: 248, margin: 48, padding: 16) do
- caption @game ? "Update IRC Profile" : "Add IRC Profile", width: 1.0, text_align: :center
+ stack(width: 1.0, max_width: 760, height: 1.0, max_height: 560, v_align: :center, h_align: :center, background: 0xff_222222) do
+ # Title bar
+ flow(width: 1.0, height: 32, padding: 8) do
+ background 0x88_000000
- stack(width: 1.0, height: 60) do
- flow(width: 1.0, height: 1.0) do
- stack(width: 0.6, height: 1.0) do
- para "IRC Nickname:"
- @irc_nickname = edit_line "#{@profile&.nickname}", width: 1.0
- end
-
- stack(width: 0.4, height: 1.0) do
- para "IRC Password:"
- @irc_password = edit_line "#{@profile ? Base64.strict_decode64(@profile.password) : ''}", width: 1.0#, type: :password
- end
- end
+ # tagline "#{I18n.t(:"server_browser.direct_connect")}", fill: true, text_align: :center
+ tagline @profile ? "Update IRC Profile" : "Add IRC Profile", width: 1.0, text_align: :center
end
- stack(width: 1.0, height: 60) do
- flow(width: 1.0, height: 1.0) do
- stack(width: 0.75, height: 1.0) do
- para "IRC Server IP or Hostname:"
- @irc_hostname = edit_line "#{@profile&.server_hostname}", width: 1.0
- end
-
- stack(width: 0.249, height: 1.0) do
- para "IRC Port:"
- @irc_port = edit_line "#{@profile&.server_port || '6667'}", width: 1.0
- end
- end
- end
-
- stack(width: 1.0, height: 60) do
- para "IRC Bot Name:"
- @irc_bot = edit_line "#{@profile&.server_bot}", width: 1.0
- end
-
- flow(width: 1.0, margin_top: 8) do
- button "Cancel", width: 0.5, margin_right: 4 do
- pop_state
+ stack(width: 1.0, fill: true, padding_left: 8, padding_right: 8) do
+ stack(width: 1.0, height: 60) do
+ para "IRC Nickname:"
+ @irc_nickname = edit_line "#{@profile&.nickname}", width: 1.0
end
- @save_button = button "Save", width: 0.5, margin_left: 4, enabled: false do
- pop_state
- @options[:save_callback].call(
- @profile,
- @irc_nickname.value,
- @irc_password.value,
- @irc_hostname.value,
- @irc_port.value,
- @irc_bot.value
- )
+ stack(width: 1.0, height: 60) do
+ flow(width: 1.0, height: 1.0) do
+ stack(width: 0.5, height: 1.0) do
+ para "IRC Username:"
+ @irc_username = edit_line "#{@profile&.username}", width: 1.0
+ end
+
+ stack(width: 0.5, height: 1.0) do
+ para "IRC Server Password:"
+ @irc_password = edit_line @profile ? Base64.strict_decode64(@profile.password) : "", width: 1.0, type: :password
+ end
+ end
+ end
+
+ stack(width: 1.0, height: 60) do
+ flow(width: 1.0, height: 1.0) do
+ stack(width: 0.75, height: 1.0) do
+ para "IRC Server IP or Hostname:"
+ @irc_hostname = edit_line "#{@profile&.server_hostname}", width: 1.0
+ end
+
+ stack(width: 0.249, height: 1.0) do
+ para "IRC Server Port:"
+ @irc_port = edit_line "#{@profile&.server_port || '6667'}", width: 1.0
+ end
+ end
+ end
+
+ flow(width: 1.0, height: 60, margin_top: 8) do
+ flow(width: 0.5, height: 60) do
+ para "IRC Server Use SSL:", margin_top: 8
+ @irc_bot = check_box "#{@profile&.server_bot}"
+ end
+
+
+ flow(width: 0.5, height: 60) do
+ para "IRC Verify Server SSL Certificate:", margin_top: 8
+ @irc_bot = check_box "#{@profile&.server_bot}"
+ end
+ end
+
+ stack(width: 1.0, height: 60, margin_top: 32) do
+ para "Brenbot Bot Name:"
+ @irc_bot = edit_line "#{@profile&.server_bot}", width: 1.0
+ end
+
+ flow(width: 1.0, height: 60) do
+ stack(width: 0.5, height: 60) do
+ para "Brenbot Auth Username:"
+ @irc_bot = edit_line "#{@profile&.server_bot}", width: 1.0
+ end
+
+ stack(width: 0.5, height: 60) do
+ para "Brenbot Auth Password:"
+ @irc_password = edit_line @profile ? Base64.strict_decode64(@profile.password) : "", width: 1.0, type: :password
+ end
+ end
+
+ flow(fill: true)
+
+ flow(width: 1.0, margin_top: 8, height: 40, padding_bottom: 8) do
+ button "Cancel", fill: true, margin_right: 4 do
+ pop_state
+ end
+
+ flow(fill: true)
+
+ @save_button = button "Save", fill: true, margin_left: 4, enabled: false do
+ pop_state
+ @options[:save_callback].call(
+ @profile,
+ @irc_nickname.value,
+ @irc_password.value,
+ @irc_hostname.value,
+ @irc_port.value,
+ @irc_bot.value
+ )
+ end
end
end
end
end
- # def draw
- # previous_state&.draw
+ def draw
+ previous_state&.draw
- # Gosu.flush
+ Gosu.flush
- # super
- # end
+ super
+ end
def update
super
@@ -79,10 +121,6 @@ class W3DHub
@save_button.enabled = valid?
end
- def close
- pop_state
- end
-
def button_down(id)
super
diff --git a/lib/asterisk/states/server_profile_form.rb b/lib/asterisk/states/server_profile_form.rb
index c16f3a7..7c008e9 100644
--- a/lib/asterisk/states/server_profile_form.rb
+++ b/lib/asterisk/states/server_profile_form.rb
@@ -7,9 +7,9 @@ class W3DHub
theme W3DHub::THEME
- background 0xee_444444
+ background 0xaa_444444
- stack(width: 1.0, height: 1.0, margin: 256, background: 0xee_222222) do
+ stack(width: 1.0, max_width: 760, height: 1.0, max_height: 256, v_align: :center, h_align: :center, background: 0xff_222222) do
# Title bar
flow(width: 1.0, height: 32, padding: 8) do
background 0x88_000000
@@ -58,10 +58,6 @@ class W3DHub
super
end
- def close
- pop_state
- end
-
def button_down(id)
super
diff --git a/lib/pages/server_browser.rb b/lib/pages/server_browser.rb
index 92e9c9e..6ca521b 100644
--- a/lib/pages/server_browser.rb
+++ b/lib/pages/server_browser.rb
@@ -65,7 +65,7 @@ class W3DHub
flow(fill: true)
- button "Direct Connect", height: 1.0, padding_top: 4, padding_bottom: 4, enabled: false, tip: "Directly connect to a game server (under development)" do
+ button "Direct Connect", height: 1.0, padding_top: 4, padding_bottom: 4, enabled: W3DHUB_DEBUG && W3DHUB_DEVELOPER, tip: "Directly connect to a game server (under development)" do
push_state(W3DHub::States::DirectConnectDialog)
end
end
diff --git a/lib/states/confirm_dialog.rb b/lib/states/confirm_dialog.rb
index ff039d6..163874b 100644
--- a/lib/states/confirm_dialog.rb
+++ b/lib/states/confirm_dialog.rb
@@ -8,7 +8,7 @@ class W3DHub
background 0xee_444444
- stack(width: 1.0, height: 1.0, margin: 128, background: 0xee_222222) do
+ stack(width: 1.0, max_width: 720, height: 1.0, max_height: 480, v_align: :center, h_align: :center, background: 0xee_222222) do
flow(width: 1.0, height: 0.1, padding: 8) do
background 0x88_000000
diff --git a/lib/states/direct_connect_dialog.rb b/lib/states/direct_connect_dialog.rb
index 89806fc..7a42780 100644
--- a/lib/states/direct_connect_dialog.rb
+++ b/lib/states/direct_connect_dialog.rb
@@ -9,7 +9,7 @@ class W3DHub
background 0xee_444444
- stack(width: 1.0, height: 1.0, margin: 128, background: 0xee_222222) do
+ stack(width: 1.0, max_width: 720, height: 1.0, max_height: 512, v_align: :center, h_align: :center, background: 0xee_222222) do
# Title bar
flow(width: 1.0, height: 32, padding: 8) do
background 0x88_000000
@@ -138,22 +138,22 @@ class W3DHub
para "IRC Profile:"
flow(width: 1.0, fill: true) do
- @irc_profiles_list = list_box items: ["None"], fill: true, height: 1.0, enabled: false
+ @irc_profiles_list = list_box items: W3DHub::Store[:asterisk_config].irc_profiles.map {| pf| pf.name }.insert(0, "None"), fill: true, height: 1.0
@irc_profiles_list.subscribe(:changed) do |list|
@changes_made = true if @server_profiles_list.value.length.positive?
valid_for_multiplayer?
end
- button get_image("#{GAME_ROOT_PATH}/media/ui_icons/plus.png"), image_height: 1.0, tip: "Add IRC profile", enabled: false do
+ button get_image("#{GAME_ROOT_PATH}/media/ui_icons/plus.png"), image_height: 1.0, tip: "Add IRC profile" do
push_state(Asterisk::States::IRCProfileForm, save_callback: method(:save_irc_profile))
end
- @irc_delete_button = button get_image("#{GAME_ROOT_PATH}/media/ui_icons/minus.png"), image_height: 1.0, tip: "Remove selected IRC profile", enabled: false do
+ @irc_delete_button = button get_image("#{GAME_ROOT_PATH}/media/ui_icons/minus.png"), image_height: 1.0, tip: "Remove selected IRC profile" do
push_state(ConfirmDialog, message: "")
end
- @irc_edit_button = button get_image("#{GAME_ROOT_PATH}/media/ui_icons/gear.png"), image_height: 1.0, tip: "Edit selected IRC profile", enabled: false do
+ @irc_edit_button = button get_image("#{GAME_ROOT_PATH}/media/ui_icons/gear.png"), image_height: 1.0, tip: "Edit selected IRC profile" do
push_state(Asterisk::States::IRCProfileForm, editing: W3DHub::Store[:asterisk_config].irc_profiles.find { |pf| pf.name == @irc_profiles_list.value }, save_callback: method(:save_irc_profile))
end
end
@@ -206,11 +206,9 @@ class W3DHub
end
def draw
- if window.current_state == self
- previous_state&.draw
+ previous_state&.draw
- Gosu.flush
- end
+ Gosu.flush
super
end
@@ -222,7 +220,7 @@ class W3DHub
@server_port.value = profile.server_port
@games_list.choose = profile.game if @games_list.items.find { |game| game == profile.game }
- @launch_arguments.value = profile.launch_arguments
+ @launch_arguments.value = profile.launch_arguments
@irc_profiles_list.choose = profile.irc_profile if @irc_profiles_list.items.find { |irc| irc == profile.irc_profile }
end
@@ -250,17 +248,19 @@ class W3DHub
updated.launch_arguments = @launch_arguments.value
updated.irc_profile = @irc_profiles_list.value
else
- profile = Asterisk::ServerProfile.new({
- name: name,
- nickname: @server_nickname.value,
- password: Base64.strict_encode64(@server_password.value),
- server_profile: @server_profiles_list.value,
- server_hostname: @server_hostname.value,
- server_port: @server_port.value,
- game: @games_list.value,
- launch_arguments: @launch_arguments.value,
- irc_profile: @irc_profiles_list.value
- })
+ profile = Asterisk::ServerProfile.new(
+ {
+ name: name,
+ nickname: @server_nickname.value,
+ password: Base64.strict_encode64(@server_password.value),
+ server_profile: @server_profiles_list.value,
+ server_hostname: @server_hostname.value,
+ server_port: @server_port.value,
+ game: @games_list.value,
+ launch_arguments: @launch_arguments.value,
+ irc_profile: @irc_profiles_list.value
+ }
+ )
W3DHub::Store[:asterisk_config].server_profiles << profile
end
diff --git a/lib/states/message_dialog.rb b/lib/states/message_dialog.rb
index 2f6b03d..bbfad92 100644
--- a/lib/states/message_dialog.rb
+++ b/lib/states/message_dialog.rb
@@ -8,30 +8,24 @@ class W3DHub
background 0xee_444444
- flow(width: 1.0, height: 1.0) do
- flow(fill: true, height: 1.0)
+ stack(width: 1.0, max_width: 720, height: 1.0, max_height: 480, v_align: :center, h_align: :center, background: 0xee_222222) do
+ flow(width: 1.0, height: 32, padding: 8) do
+ background 0x88_000000
- stack(width: 1.0, height: 1.0, max_width: MAX_PAGE_WIDTH, margin: 128, background: 0xee_222222) do
- flow(width: 1.0, height: 32, padding: 8) do
- background 0x88_000000
+ image "#{GAME_ROOT_PATH}/media/ui_icons/warning.png", width: 32, align: :center, color: 0xff_ff8800
- image "#{GAME_ROOT_PATH}/media/ui_icons/warning.png", width: 32, align: :center, color: 0xff_ff8800
-
- tagline "#{@options[:title]}", width: 0.9, text_align: :center
- end
-
- stack(width: 1.0, fill: true, padding: 16) do
- para @options[:message], width: 1.0
- end
-
- stack(width: 1.0, height: 40, padding: 8) do
- button "Okay", width: 1.0 do
- pop_state
- end
- end
+ tagline "#{@options[:title]}", width: 0.9, text_align: :center
end
- flow(fill: true, height: 1.0)
+ stack(width: 1.0, fill: true, padding: 16) do
+ para @options[:message], width: 1.0
+ end
+
+ stack(width: 1.0, height: 40, padding: 8) do
+ button "Okay", width: 1.0 do
+ pop_state
+ end
+ end
end
end
diff --git a/lib/states/prompt_dialog.rb b/lib/states/prompt_dialog.rb
index f7d191e..b7d866f 100644
--- a/lib/states/prompt_dialog.rb
+++ b/lib/states/prompt_dialog.rb
@@ -8,41 +8,35 @@ class W3DHub
background 0xee_444444
- flow(width: 1.0, height: 1.0) do
- flow(fill: true, height: 1.0)
+ stack(width: 1.0, max_width: 720, height: 1.0, max_height: 256, v_align: :center, h_align: :center, background: 0xee_222222) do
+ flow(width: 1.0, height: 32, padding: 8) do
+ background 0x88_000000
- stack(width: 1.0, max_width: MAX_PAGE_WIDTH, height: 1.0, margin: 128, background: 0xee_222222) do
- flow(width: 1.0, height: 32, padding: 8) do
- background 0x88_000000
+ image "#{GAME_ROOT_PATH}/media/ui_icons/question.png", width: 32, align: :center, color: 0xff_ff8800
- image "#{GAME_ROOT_PATH}/media/ui_icons/question.png", width: 32, align: :center, color: 0xff_ff8800
+ tagline "#{@options[:title]}", fill: true, text_align: :center
+ end
- tagline "#{@options[:title]}", fill: true, text_align: :center
+ stack(width: 1.0, fill: true, padding: 16) do
+ para @options[:message], width: 1.0
+ @prompt_entry = edit_line @options[:prefill].to_s, margin_top: 24, width: 1.0, autofocus: true, focus: true, type: @options[:input_type] == :password ? :password : :text
+ end
+
+ flow(width: 1.0, height: 40, padding: 8) do
+ button "Cancel", width: 0.25 do
+ pop_state
+ @options[:cancel_callback]&.call(@prompt_entry.value)
end
- stack(width: 1.0, fill: true, padding: 16) do
- para @options[:message], width: 1.0
- @prompt_entry = edit_line @options[:prefill].to_s, margin_top: 24, width: 1.0, autofocus: true, focus: true, type: @options[:input_type] == :password ? :password : :text
- end
+ stack(fill: true)
- flow(width: 1.0, height: 40, padding: 8) do
- button "Cancel", width: 0.25 do
+ @accept_button = button "Accept", width: 0.25 do
+ if @options[:valid_callback]&.call(@prompt_entry.value)
pop_state
- @options[:cancel_callback]&.call(@prompt_entry.value)
- end
-
- stack(fill: true)
-
- @accept_button = button "Accept", width: 0.25 do
- if @options[:valid_callback]&.call(@prompt_entry.value)
- pop_state
- @options[:accept_callback]&.call(@prompt_entry.value)
- end
+ @options[:accept_callback]&.call(@prompt_entry.value)
end
end
end
-
- flow(fill: true, height: 1.0)
end
@prompt_entry.subscribe(:changed) do
diff --git a/lib/window.rb b/lib/window.rb
index e87471e..0c8ef32 100644
--- a/lib/window.rb
+++ b/lib/window.rb
@@ -21,6 +21,7 @@ class W3DHub
# push_state(W3DHub::States::Welcome)
push_state(W3DHub::States::Boot)
# push_state(W3DHub::States::DirectConnectDialog)
+ # push_state(W3DHub::Asterisk::States::IRCProfileForm)
end
def update