28 #define ERR_LB LOG_STREAM(err, log_lobby)
35 tree_group_item[
"tree_view_node_label"][
"label"] = lbl;
37 root = &parent_tree->
add_node(
"player_group", tree_group_item);
49 label_player_count->set_label(std::to_string(root->count_children()));
67 std::array<update_pod, std::tuple_size<decltype(
player_lists)>::value> inputs{};
69 for(
const auto& user : user_info) {
70 std::string name = user.name;
72 std::stringstream icon_ss;
73 icon_ss <<
"lobby/status";
75 switch(user.get_state(focused_game)) {
81 icon_ss << (user.observing ?
"-obs" :
"-playing");
85 icon_ss << (user.observing ?
"-obs" :
"-playing");
89 switch(user.get_relation()) {
110 tree_group_field[
"label"] = icon_ss.str();
111 tree_group_item[
"icon"] = tree_group_field;
113 tree_group_field[
"label"] = name;
114 tree_group_field[
"use_markup"] =
"true";
115 tree_group_item[
"name"] = tree_group_field;
118 switch(user.get_state(focused_game)) {
120 inputs[0].node_data.push_back(std::move(tree_group_item));
121 inputs[0].user_data.push_back(&user);
125 inputs[1].node_data.push_back(std::move(tree_group_item));
126 inputs[1].user_data.push_back(&user);
130 inputs[2].node_data.push_back(std::move(tree_group_item));
131 inputs[2].user_data.push_back(&user);
140 assert(inputs[
i].
node_data.size() == inputs[
i].user_data.size());
145 for(std::size_t k = 0; k < new_nodes.size(); ++k) {
146 auto* node = new_nodes[k].get();
147 auto*
info = inputs[
i].user_data[k];
153 find_widget<toggle_panel>(node,
"tree_view_node_label",
false),
169 tree = find_widget<tree_view>(&
w,
"player_tree",
false,
true);
std::map< const tree_view_node *, const mp::user_info * > info_map
Node-to-info mappings for easy access.
const mp::user_info * get_selected_info() const
std::array< sub_list, 3 > player_lists
Main subsections of the player tree.
void update(const std::vector< mp::user_info > &user_info, int focused_game)
Updates the tree contents based on the given user data.
tree_view * tree
The parent tree.
std::function< void(const mp::user_info *)> user_callback
The double click callback bound to each player's tree node.
void unfold(const bool recursive=false)
tree_view_node & add_node(const std::string &id, const widget_data &data, const int index=-1)
tree_view_node * selected_item()
base class of top level items, the only item which needs to store the final canvases to draw on.
static std::string _(const char *str)
static lg::log_domain log_lobby("lobby")
std::vector< widget_data > node_data
The raw data used to mass-construct player tree nodes.
std::vector< const mp::user_info * > user_data
The associated user data for each node, index-to-index.
std::string span_color(const color_t &color)
Returns a Pango formatting string using the provided color_t object.
void connect_signal_mouse_left_double_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button double click.
std::map< std::string, widget_item > widget_data
std::map< std::string, t_string > widget_item
label * label_player_count
void update_player_count_label()
This class represents the information a client has about another player.