gui/addon_manager: Show server identification after the address

This enables the client to show the [server_id] info (for 1.16+
campaignd instances that provide the relevant fields) in the UI so
the user can more easily know which instance they are connected to
in case they do not handle that information directly themselves (e.g.
when entering a port number of their own).

The server info shown in the bottom left is changed from "<encryption
status> <server address>" to add "— <server id> (<server version>)"
right after it, with the server version in parentheses being included
only if debug mode is enabled to avoid redundancy or confusing values
(such as "wesnoth.org — 1.18 (1.17.19+dev)").
This commit is contained in:
Iris Morelle 2024-02-29 20:20:26 -03:00 committed by Charles Dang
parent 597a64701c
commit 17bd58dd79
2 changed files with 15 additions and 1 deletions

View file

@ -0,0 +1,3 @@
### Add-ons client
* The add-ons server identifier (e.g. 1.18) is now displayed on the bottom left after the
server address. If debug mode is enabled the server software version is also shown.

View file

@ -325,7 +325,18 @@ void addon_manager::pre_show(window& window)
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());
if(!client_.server_id().empty()) {
auto full_id = formatter()
<< client_.addr() << ' '
<< font::unicode_em_dash << ' '
<< client_.server_id();
if(game_config::debug && !client_.server_version().empty()) {
full_id << " (" << client_.server_version() << ')';
}
addr_box->set_label(full_id.str());
} else {
addr_box->set_label(client_.addr());
}
}
}