WIP: Adding IRC support to Direct Connect system, using new v/h_align option for centering dialogs

This commit is contained in:
2022-06-13 21:43:13 -05:00
parent 7e59c984ff
commit 3ca8ab656f
11 changed files with 172 additions and 139 deletions

View File

@@ -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

View File

@@ -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 "<b>#{I18n.t(:"server_browser.direct_connect")}</b>", 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

View File

@@ -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