gui2/addon_manager: Add TLS status and server address indicator
This is displayed on the bottom left in "big GUI" mode and on the bottom middle in "small GUI" mode. The hostname label's colour depends on whether the connection is actually layered in TLS or not. The tooltips are kind of a hack because we currently can't set a tooltip on a grid so it triggers whenever the player mouses over any of its children or the border/margin space between cells. Instead we set the same tooltips for both widget pairs via preprocessor trickery and call it a day.
This commit is contained in:
parent
71c17a3b65
commit
1e26269729
2 changed files with 108 additions and 0 deletions
|
@ -3,6 +3,77 @@
|
|||
### Definition of the window to select an addon for installation.
|
||||
###
|
||||
|
||||
# HACK: we can't assign a tooltip to a grid
|
||||
|
||||
#define _GUI_SERVER_CONN_INFO:TOOLTIP_PLAIN
|
||||
tooltip = _ "Traffic between the game and server is not secure"
|
||||
#enddef
|
||||
|
||||
#define _GUI_SERVER_CONN_INFO:TOOLTIP_TLS
|
||||
tooltip = _ "Traffic between the game and server is encrypted"
|
||||
#enddef
|
||||
|
||||
#define _GUI_SERVER_CONN_INFO
|
||||
[stacked_widget]
|
||||
id = "server_conn_info"
|
||||
# This needs to have at least two pages. Page 0 is used for plain text
|
||||
# connections, while page 1 is used for TLS. Do NOT change this.
|
||||
[layer]
|
||||
[row]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
grow_factor = 0
|
||||
horizontal_grow = false
|
||||
[image]
|
||||
label = "icons/action/lock_broken_ornate_30.png"
|
||||
{_GUI_SERVER_CONN_INFO:TOOLTIP_PLAIN}
|
||||
[/image]
|
||||
[/column]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
grow_factor = 1
|
||||
horizontal_grow = true
|
||||
[label]
|
||||
id = "server_addr"
|
||||
definition = "bad_small"
|
||||
#label = "Connection info label"
|
||||
{_GUI_SERVER_CONN_INFO:TOOLTIP_PLAIN}
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
[/layer]
|
||||
[layer]
|
||||
[row]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
grow_factor = 0
|
||||
horizontal_grow = false
|
||||
[image]
|
||||
id = "secure_conn_icon"
|
||||
label = "icons/action/lock_ornate_30.png"
|
||||
{_GUI_SERVER_CONN_INFO:TOOLTIP_TLS}
|
||||
[/image]
|
||||
[/column]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
grow_factor = 1
|
||||
horizontal_grow = true
|
||||
[label]
|
||||
id = "server_addr"
|
||||
definition = "gold_small"
|
||||
#label = "Connection info label"
|
||||
{_GUI_SERVER_CONN_INFO:TOOLTIP_TLS}
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
[/layer]
|
||||
[/stacked_widget]
|
||||
#enddef
|
||||
|
||||
#define _GUI_ADDON_DETAILS_SECTION
|
||||
[grid]
|
||||
|
||||
|
@ -933,6 +1004,13 @@
|
|||
[/button]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_alignment = "right"
|
||||
|
||||
{_GUI_SERVER_CONN_INFO}
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "all"
|
||||
|
@ -1097,6 +1175,13 @@
|
|||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
horizontal_alignment = "left"
|
||||
|
||||
{_GUI_SERVER_CONN_INFO}
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "all"
|
||||
|
@ -1142,3 +1227,6 @@
|
|||
|
||||
#undef _GUI_ADDON_FILTER_OPTIONS
|
||||
#undef _GUI_ADDON_DETAILS_SECTION
|
||||
#undef _GUI_SERVER_CONN_INFO:TOOLTIP_TLS
|
||||
#undef _GUI_SERVER_CONN_INFO:TOOLTIP_PLAIN
|
||||
#undef _GUI_SERVER_CONN_INFO
|
||||
|
|
|
@ -309,6 +309,26 @@ void addon_manager::pre_show(window& window)
|
|||
{
|
||||
window.set_escape_disabled(true);
|
||||
|
||||
stacked_widget& addr_info = find_widget<stacked_widget>(&window, "server_conn_info", false);
|
||||
grid* addr_visible;
|
||||
|
||||
if(client_.using_tls()) {
|
||||
addr_info.select_layer(1);
|
||||
addr_visible = addr_info.get_layer_grid(1);
|
||||
addr_info.set_tooltip("Traffic between the game and the server is encrypted");
|
||||
} else {
|
||||
addr_info.select_layer(0);
|
||||
addr_visible = addr_info.get_layer_grid(0);
|
||||
addr_info.set_tooltip("Traffic between the game and the server is not secure");
|
||||
}
|
||||
|
||||
if(addr_visible) {
|
||||
auto addr_box = dynamic_cast<styled_widget*>(addr_visible->find("server_addr", false));
|
||||
if(addr_box) {
|
||||
addr_box->set_label(client_.addr());
|
||||
}
|
||||
}
|
||||
|
||||
addon_list& list = find_widget<addon_list>(&window, "addons", false);
|
||||
|
||||
text_box& filter = find_widget<text_box>(&window, "filter", false);
|
||||
|
|
Loading…
Add table
Reference in a new issue