MP/Lobby: reorganized sidebar, added player info section
This commit is contained in:
parent
984838c99d
commit
551cb75693
5 changed files with 166 additions and 45 deletions
|
@ -94,6 +94,16 @@
|
|||
|
||||
[/panel_definition]
|
||||
|
||||
[panel_definition]
|
||||
|
||||
id = "box_display_no_blur_medium_border"
|
||||
description = "Definition of the panel for the title screen"
|
||||
|
||||
{_GUI_RESOLUTION (window_width,window_height = 800, 600) 10 5 10 5 () }
|
||||
{_GUI_RESOLUTION (window_width,window_height = 850, 650) 15 5 9 14 () }
|
||||
|
||||
[/panel_definition]
|
||||
|
||||
[panel_definition]
|
||||
|
||||
id = "box_display_no_blur_no_border"
|
||||
|
|
|
@ -388,51 +388,33 @@
|
|||
|
||||
#define _GUI_CONTROL_AREA
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = true
|
||||
|
||||
[button]
|
||||
id = "quit"
|
||||
definition = "large"
|
||||
label = _ "Log Out"
|
||||
id = "create"
|
||||
definition = "really_large"
|
||||
label = _ "Create Game"
|
||||
[/button]
|
||||
[/column]
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
[column]
|
||||
horizontal_grow = true
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
[button]
|
||||
id = "create"
|
||||
definition = "large"
|
||||
label = _ "Create Game"
|
||||
[/button]
|
||||
[/column]
|
||||
horizontal_grow = true
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
[button]
|
||||
id = "show_preferences"
|
||||
definition = "large"
|
||||
label = _ "Preferences"
|
||||
[/button]
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
[button]
|
||||
id = "join_global"
|
||||
definition = "large"
|
||||
|
@ -443,6 +425,8 @@
|
|||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = true
|
||||
|
||||
[button]
|
||||
id = "observe_global"
|
||||
definition = "large"
|
||||
|
@ -450,6 +434,35 @@
|
|||
[/button]
|
||||
[/column]
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = true
|
||||
|
||||
[button]
|
||||
id = "server_info"
|
||||
definition = "large"
|
||||
label = _ "Information"
|
||||
[/button]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = true
|
||||
|
||||
[button]
|
||||
id = "show_preferences"
|
||||
definition = "large"
|
||||
label = _ "Preferences"
|
||||
[/button]
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
|
@ -459,11 +472,72 @@
|
|||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = true
|
||||
[button]
|
||||
id = "server_info"
|
||||
definition = "large"
|
||||
label = _ "Information"
|
||||
[/button]
|
||||
|
||||
[panel]
|
||||
id = "profile"
|
||||
definition = "box_display_no_blur_medium_border"
|
||||
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
border = "bottom"
|
||||
border_size = 5
|
||||
horizontal_grow = true
|
||||
|
||||
[label]
|
||||
id = "username"
|
||||
definition = "title"
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
|
||||
{GUI_FILLER_ROW HEIGHT=10}
|
||||
|
||||
[row]
|
||||
[column]
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
border = "right,top,bottom"
|
||||
border_size = 5
|
||||
|
||||
[button]
|
||||
id = "view_profile"
|
||||
definition = "default"
|
||||
label = "Profile"
|
||||
[/button]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "left,top,bottom"
|
||||
border_size = 5
|
||||
|
||||
[button]
|
||||
id = "view_match_history"
|
||||
definition = "default"
|
||||
label = "Match History"
|
||||
[/button]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
[column]
|
||||
border = "top"
|
||||
border_size = 5
|
||||
horizontal_grow = true
|
||||
|
||||
[button]
|
||||
id = "quit"
|
||||
definition = "large"
|
||||
label = _ "Log Out"
|
||||
[/button]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/panel]
|
||||
[/column]
|
||||
[/row]
|
||||
|
||||
|
@ -495,8 +569,6 @@
|
|||
|
||||
[/row]
|
||||
|
||||
#{GUI_HORIZONTAL_SPACER_LINE}
|
||||
|
||||
{_GUI_PLAYER_TREE_AREA}
|
||||
|
||||
[/grid]
|
||||
|
@ -608,16 +680,16 @@
|
|||
[/button]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = true
|
||||
[button]
|
||||
id = "server_info"
|
||||
definition = "default"
|
||||
label = _ "Information"
|
||||
[/button]
|
||||
[/column]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = true
|
||||
[button]
|
||||
id = "server_info"
|
||||
definition = "default"
|
||||
label = _ "Information"
|
||||
[/button]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
|
|
|
@ -56,6 +56,8 @@ static lg::log_domain log_mp("mp/main");
|
|||
|
||||
namespace
|
||||
{
|
||||
std::string profile_url_prefix;
|
||||
|
||||
/** Opens a new server connection and prompts the client for login credentials, if necessary. */
|
||||
std::unique_ptr<wesnothd_connection> open_connection(std::string host)
|
||||
{
|
||||
|
@ -356,6 +358,9 @@ std::unique_ptr<wesnothd_connection> open_connection(std::string host)
|
|||
// Flag us as authenticated, if applicable...
|
||||
preferences::set_admin_authentication(join_lobby["is_moderator"].to_bool(false));
|
||||
|
||||
// Note the forum profile prefix (will be empty if this server doesn't have an attached database)
|
||||
profile_url_prefix = join_lobby["profile_url_prefix"];
|
||||
|
||||
// All done!
|
||||
break;
|
||||
}
|
||||
|
@ -586,8 +591,8 @@ void mp_manager::enter_wait_mode(int game_id, bool observe)
|
|||
mp_game_metadata metadata(*connection);
|
||||
metadata.is_host = false;
|
||||
|
||||
if(lobby_info.get_game_by_id(game_id)) {
|
||||
metadata.current_turn = lobby_info.get_game_by_id(game_id)->current_turn;
|
||||
if(mp::game_info* gi = lobby_info.get_game_by_id(game_id)) {
|
||||
metadata.current_turn = gi->current_turn;
|
||||
}
|
||||
|
||||
if(preferences::skip_mp_replay() || preferences::blindfold_replay()) {
|
||||
|
@ -764,4 +769,13 @@ void start_local_game_commandline(saved_game& state, const commandline_options&
|
|||
}
|
||||
}
|
||||
|
||||
std::string get_profile_link(int user_id)
|
||||
{
|
||||
if(!profile_url_prefix.empty()) {
|
||||
return profile_url_prefix + std::to_string(user_id);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace mp
|
||||
|
|
|
@ -60,4 +60,7 @@ bool goto_mp_connect(ng::connect_engine& engine, wesnothd_connection* connection
|
|||
*/
|
||||
bool goto_mp_wait(saved_game& state, wesnothd_connection* connection, bool observe);
|
||||
|
||||
/** Gets the forum profile link for the given user. */
|
||||
std::string get_profile_link(int user_id);
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "addon/client.hpp"
|
||||
#include "addon/manager_ui.hpp"
|
||||
#include "chat_log.hpp"
|
||||
#include "desktop/open.hpp"
|
||||
#include "font/text_formatting.hpp"
|
||||
#include "formatter.hpp"
|
||||
#include "formula/string_utils.hpp"
|
||||
|
@ -824,6 +825,27 @@ void mp_lobby::pre_show(window& window)
|
|||
lobby_update_timer_ = add_timer(
|
||||
game_config::lobby_network_timer, std::bind(&mp_lobby::network_handler, this), true);
|
||||
|
||||
//
|
||||
// Profile box
|
||||
//
|
||||
if(auto* profile_panel = find_widget<panel>(&window, "profile", false, false)) {
|
||||
const mp::user_info& your_info = *std::find_if(lobby_info_.users().begin(), lobby_info_.users().end(),
|
||||
[](const auto& u) { return u.relation == mp::user_info::user_relation::ME; });
|
||||
|
||||
find_widget<label>(profile_panel, "username", false).set_label(your_info.name);
|
||||
|
||||
auto& profile_button = find_widget<button>(profile_panel, "view_profile", false);
|
||||
if(your_info.forum_id != 0) {
|
||||
connect_signal_mouse_left_click(profile_button,
|
||||
std::bind(&desktop::open_object, mp::get_profile_link(your_info.forum_id)));
|
||||
} else {
|
||||
profile_button.set_active(false);
|
||||
}
|
||||
|
||||
// TODO: implement
|
||||
find_widget<button>(profile_panel, "view_match_history", false).set_active(false);
|
||||
}
|
||||
|
||||
// Set up Lua plugin context
|
||||
plugins_context_.reset(new plugins_context("Multiplayer Lobby"));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue