The Battle for Wesnoth  1.17.0-dev
lobby_player_list_helper.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2021
3  by Tomasz Sniatowski <kailoran@gmail.com>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include <array>
19 #include <functional>
20 #include <string>
21 
22 namespace mp
23 {
24 struct user_info;
25 }
26 
27 namespace gui2
28 {
29 class label;
30 class tree_view;
31 class tree_view_node;
32 class window;
33 
35 {
36 public:
37  void init(window& w);
38 
39  /** Updates the tree contents based on the given user data. */
40  void update(std::vector<mp::user_info>& user_info);
41 
42 private:
43  struct sub_list
44  {
45  sub_list() = default;
46  sub_list(tree_view* parent_tree, const std::string& label, const bool unfolded);
47 
48  void update_player_count_label();
49 
51 
53  };
54 
55  /** Main subsections of the player tree. This should never change at runtime so the number is hardcoded. */
56  std::array<sub_list, 3> player_lists;
57 
58  /** The parent tree. */
60 
61  /** The double click callback bound to each player's tree node. */
62  std::function<void(mp::user_info*)> user_callback;
63 
64 public:
65  lobby_player_list_helper(decltype(user_callback) ucb)
66  : player_lists()
67  , tree(nullptr)
68  , user_callback(ucb)
69  {
70  }
71 };
72 } // namespace gui2
tree_view * tree
The parent tree.
lobby_player_list_helper(decltype(user_callback) ucb)
A label displays a text, the text can be wrapped but no scrollbars are provided.
Definition: label.hpp:57
Generic file dialog.
Definition: field-fwd.hpp:23
std::function< void(mp::user_info *)> user_callback
The double click callback bound to each player&#39;s tree node.
Main entry points of multiplayer mode.
Definition: lobby_data.cpp:52
struct utils::detail::formula_initer init
std::string label
What to show in the filter&#39;s drop-down list.
Definition: manager.cpp:217
A tree view is a control that holds several items of the same or different types. ...
Definition: tree_view.hpp:60
std::array< sub_list, 3 > player_lists
Main subsections of the player tree.
int w
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:65