1 #ifndef _ServerConnectWnd_h_
2 #define _ServerConnectWnd_h_
3 
4 #include <string>
5 #include <GG/GGFwd.h>
6 #include <GG/ListBox.h>
7 
8 #include "CUIWnd.h"
9 #include "../network/Networking.h"
10 
11 /** server connections window */
12 class ServerConnectWnd : public CUIWnd
13 {
14 public:
15     /** Connection parameters */
16     struct Result {
17         std::string player_name;
18         std::string server_dest;
19         Networking::ClientType type;
20     };
21 
22     /** \name Structors */ //@{
23     ServerConnectWnd();
24     void CompleteConstruction() override;
25     //@}
26 
27     //! \name Mutators
28     //!@{
29     void ModalInit() override;
30 
31     void KeyPress(GG::Key key, std::uint32_t key_code_point, GG::Flags<GG::ModKey> mod_keys) override;
32     //!@}
33 
34     /** \name Accessors */ //@{
35     /** returns a the player's name (.player_name); the location of the server (.server_dest -- IP address or name), or "" if none was selected and client type (.type) */
36     const Result& GetResult() const;
37     //@}
38 
39 protected:
40     GG::Rect CalculatePosition() const override;
41 
42 private:
43     void PopulateServerList();
44     void ServerSelected(const GG::ListBox::SelectionSet& selections);
45     void IPAddressEdited(const std::string& str);
46     void OkClicked();
CancelClicked()47     void CancelClicked() {CUIWnd::CloseClicked();}
48     void EnableDisableControls();
49 
50     Result m_result;
51 
52     std::shared_ptr<GG::RadioButtonGroup>               m_host_or_join_radio_group;
53     std::shared_ptr<GG::DropDownList>                   m_client_type_list;
54     std::shared_ptr<GG::Label>                          m_LAN_game_label;
55     std::shared_ptr<GG::ListBox>                        m_servers_lb;
56     std::shared_ptr<GG::Button>                         m_find_LAN_servers_bn;
57     std::shared_ptr<GG::Label>                          m_internet_game_label;
58     std::shared_ptr<GG::Edit>                           m_IP_address_edit;
59     std::shared_ptr<GG::Edit>                           m_player_name_edit;
60     std::shared_ptr<GG::Button>                         m_ok_bn;
61     std::shared_ptr<GG::Button>                         m_cancel_bn;
62 };
63 
64 #endif // _ServerConnectWnd_h_
65