1 #ifndef _MultiPlayerLobbyWnd_h_
2 #define _MultiPlayerLobbyWnd_h_
3 
4 #include <vector>
5 #include <GG/GGFwd.h>
6 
7 #include "ChatWnd.h"
8 #include "CUIWnd.h"
9 #include "CUIControls.h"
10 #include "GalaxySetupWnd.h"
11 #include "../util/MultiplayerCommon.h"
12 
13 class Message;
14 struct PlayerLabelRow;
15 
16 
17 /** multiplayer lobby window */
18 class MultiPlayerLobbyWnd : public CUIWnd {
19 public:
20     /** \name Structors */ //@{
21     MultiPlayerLobbyWnd();
22     void CompleteConstruction() override;
23     //@}
24 
25     /** \name Accessors */ //@{
26     GG::Pt MinUsableSize() const override;
27 
28     bool            LoadGameSelected() const;
29 
30     std::string     GetChatText() const;
31     //@}
32 
33     /** \name Mutators */ //@{
34     void SizeMove(const GG::Pt& ul, const GG::Pt& lr) override;
35 
36     void Render() override;
37 
38     void KeyPress(GG::Key key, std::uint32_t key_code_point, GG::Flags<GG::ModKey> mod_keys) override;
39 
40     void            ChatMessage(int player_id, const boost::posix_time::ptime& timestamp, const std::string& msg);
41     void            ChatMessage(const std::string& message_text,
42                                 const std::string& player_name,
43                                 GG::Clr text_color,
44                                 const boost::posix_time::ptime& timestamp);
45     void            TurnPhaseUpdate(Message::TurnProgressPhase phase_id);
46     void            LobbyUpdate(const MultiplayerLobbyData& lobby_data);
47     void            Refresh();
48     void            CleanupChat();
49     //@}
50 
51 protected:
52     struct PlayerLabelRow : GG::ListBox::Row {
53         PlayerLabelRow(GG::X width = GG::X(600));
54 
55         void CompleteConstruction() override;
56 
57         /** Set text of control at @p column to @p str */
58         void SetText(size_t column, const std::string& str);
59 
60         void Render() override;
61     };
62 
63     GG::Rect CalculatePosition() const override;
64 
65 private:
66     void            DoLayout();
67     void            NewLoadClicked(std::size_t idx);
68     void            GalaxySetupPanelChanged();
69     void            SaveGameBrowse();
70     void PreviewImageChanged(std::shared_ptr<GG::Texture> new_image);
71     void            PlayerDataChangedLocally();
72     bool            PopulatePlayerList();   ///< repopulate list with rows built from current m_lobby_data.  returns true iff something in the lobby data was changed during population and an update should be sent back to the server
73     void            SendUpdate();
74     bool            PlayerDataAcceptable() const;
75     bool            CanStart() const;
76     bool            HasAuthRole(Networking::RoleType role) const;
77     void            ReadyClicked();
78     void            CancelClicked();
79     void            AnyCanEdit(bool checked);
80 
81     MultiplayerLobbyData    m_lobby_data;   ///< a copy of the most recently received lobby update
82 
83     std::shared_ptr<MessageWnd>             m_chat_wnd;
84     std::shared_ptr<CUIStateButton>         m_any_can_edit;
85     std::shared_ptr<GG::RadioButtonGroup>   m_new_load_game_buttons;
86     std::shared_ptr<GalaxySetupPanel>       m_galaxy_setup_panel;
87     std::shared_ptr<GG::Label>              m_save_file_text;
88     std::shared_ptr<GG::Button>             m_browse_saves_btn;
89     std::shared_ptr<GG::StaticGraphic>      m_preview_image;
90     std::shared_ptr<GG::ListBox>            m_players_lb;
91     std::shared_ptr<PlayerLabelRow>         m_players_lb_headers;
92     std::shared_ptr<GG::Button>             m_ready_bn;
93     std::shared_ptr<GG::Button>             m_cancel_bn;
94     std::shared_ptr<GG::Label>              m_start_conditions_text;
95 };
96 
97 #endif // _MultiPlayerLobbyWnd_h_
98