RigsofRods
Soft-body Physics Simulation
GUI_MultiplayerSelector.h
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3 
4  Copyright 2005-2012 Pierre-Michel Ricordel
5  Copyright 2007-2012 Thomas Fischer
6  Copyright 2013-2020 Petr Ohlidal
7 
8  For more information, see http://www.rigsofrods.org/
9 
10  Rigs of Rods is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License version 3, as
12  published by the Free Software Foundation.
13 
14  Rigs of Rods is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #pragma once
24 
25 #include "Application.h"
26 #include "OgreImGui.h" // ImVec4
27 
28 #include <future>
29 #include <memory>
30 #include <thread>
31 #include <vector>
32 
33 namespace RoR{
34 namespace GUI {
35 
37 {
39  std::string display_passwd;
40  std::string display_name;
41  std::string display_terrn;
42  int num_users;
43  int max_users;
44  std::string display_users;
45  std::string net_host;
46  std::string net_version;
47  std::string display_version;
48  int net_port;
49  std::string display_host;
50 };
51 
52 typedef std::vector<MpServerInfo> MpServerInfoVec;
53 
55 {
56 public:
57  const float BUTTONS_EXTRA_SPACE = 6.f;
58  const float TABLE_PADDING_LEFT = 4.f;
59 
61 
62  void SetVisible(bool v);
63  inline bool IsVisible() const { return m_is_visible; }
64  void StartAsyncRefresh();
65  void Draw();
66  void DisplayRefreshFailed(CurlFailInfo* failinfo);
68 
69 private:
70  void DrawSetupTab();
71  void DrawDirectTab();
72  void DrawServerlistTab();
73 
75  int m_selected_item = -1;
76  char m_window_title[100];
77  bool m_is_visible = false;
78  bool m_draw_table = false;
83  Ogre::TexturePtr m_lock_icon;
84  bool m_show_spinner = false;
85 
86  // status or error messages
87  std::string m_serverlist_msg;
89  std::string m_serverlist_curlmsg;
90  std::string m_serverlist_httpmsg;
91 };
92 
93 } // namespace GUI
94 } // namespace RoR
RoR::GUI::MultiplayerSelector::SetVisible
void SetVisible(bool v)
Definition: GUI_MultiplayerSelector.cpp:392
RoR::GUI::MultiplayerSelector::StartAsyncRefresh
void StartAsyncRefresh()
Launch refresh from main thread.
Definition: GUI_MultiplayerSelector.cpp:379
RoR::GUI::MpServerInfo::display_users
std::string display_users
Definition: GUI_MultiplayerSelector.h:44
RoR::GUI::MpServerInfo::num_users
int num_users
Definition: GUI_MultiplayerSelector.h:42
RoR::GUI::MultiplayerSelector::DisplayRefreshFailed
void DisplayRefreshFailed(CurlFailInfo *failinfo)
Definition: GUI_MultiplayerSelector.cpp:406
RoR::GUI::MultiplayerSelector::UpdateServerlist
void UpdateServerlist(MpServerInfoVec *data)
Definition: GUI_MultiplayerSelector.cpp:418
RoR::GUI::MpServerInfo::display_terrn
std::string display_terrn
Definition: GUI_MultiplayerSelector.h:41
RoR::GUI::MpServerInfo::net_host
std::string net_host
Definition: GUI_MultiplayerSelector.h:45
RoR::GUI::MpServerInfo
Definition: GUI_MultiplayerSelector.h:36
RoR::GUI::MpServerInfo::display_version
std::string display_version
Definition: GUI_MultiplayerSelector.h:47
RoR::GUI::MultiplayerSelector::MultiplayerSelector
MultiplayerSelector()
Definition: GUI_MultiplayerSelector.cpp:143
RoR::GUI::MultiplayerSelector::m_serverlist_curlmsg
std::string m_serverlist_curlmsg
Displayed as dimmed text.
Definition: GUI_MultiplayerSelector.h:89
RoR::GUI::MultiplayerSelector::m_player_name_buf
Str< 1000 > m_player_name_buf
Definition: GUI_MultiplayerSelector.h:80
RoR::GUI::MultiplayerSelector::m_server_host_buf
Str< 1000 > m_server_host_buf
Definition: GUI_MultiplayerSelector.h:82
RoR::CurlFailInfo
Definition: Network.h:47
RoR::GUI::MultiplayerSelector::m_serverlist_data
MpServerInfoVec m_serverlist_data
Definition: GUI_MultiplayerSelector.h:74
RoR::GUI::MultiplayerSelector::DrawServerlistTab
void DrawServerlistTab()
Definition: GUI_MultiplayerSelector.cpp:236
RoR::GUI::MultiplayerSelector::m_draw_table
bool m_draw_table
Definition: GUI_MultiplayerSelector.h:78
OgreImGui.h
RoR::GUI::MultiplayerSelector::TABLE_PADDING_LEFT
const float TABLE_PADDING_LEFT
Definition: GUI_MultiplayerSelector.h:58
RoR::GUI::MpServerInfo::max_users
int max_users
Definition: GUI_MultiplayerSelector.h:43
RoR::GUI::MultiplayerSelector::IsVisible
bool IsVisible() const
Definition: GUI_MultiplayerSelector.h:63
RoR::GUI::MultiplayerSelector::m_selected_item
int m_selected_item
Definition: GUI_MultiplayerSelector.h:75
RoR::Str< 1000 >
RoR::GUI::MultiplayerSelector::DrawSetupTab
void DrawSetupTab()
Definition: GUI_MultiplayerSelector.cpp:187
RoR::GUI::MpServerInfo::net_port
int net_port
Definition: GUI_MultiplayerSelector.h:48
Application.h
Central state/object manager and communications hub.
RoR::GUI::MultiplayerSelector::m_serverlist_msg
std::string m_serverlist_msg
Definition: GUI_MultiplayerSelector.h:87
RoR::GUI::MpServerInfo::display_name
std::string display_name
Definition: GUI_MultiplayerSelector.h:40
RoR::GUI::MultiplayerSelector::DrawDirectTab
void DrawDirectTab()
Definition: GUI_MultiplayerSelector.cpp:215
RoR::GUI::MpServerInfo::display_passwd
std::string display_passwd
Definition: GUI_MultiplayerSelector.h:39
RoR::GUI::MpServerInfo::display_host
std::string display_host
Definition: GUI_MultiplayerSelector.h:49
RoR::GUI::MpServerInfoVec
std::vector< MpServerInfo > MpServerInfoVec
Definition: GUI_MultiplayerSelector.h:52
RoR::GUI::MultiplayerSelector::m_is_visible
bool m_is_visible
Definition: GUI_MultiplayerSelector.h:77
RoR::GUI::MpServerInfo::net_version
std::string net_version
Definition: GUI_MultiplayerSelector.h:46
RoR::GUI::MultiplayerSelector::m_show_spinner
bool m_show_spinner
Definition: GUI_MultiplayerSelector.h:84
RoR::GUI::MultiplayerSelector
Definition: GUI_MultiplayerSelector.h:54
RoR::GUI::MultiplayerSelector::m_lock_icon
Ogre::TexturePtr m_lock_icon
Definition: GUI_MultiplayerSelector.h:83
RoR::GUI::MultiplayerSelector::Draw
void Draw()
Definition: GUI_MultiplayerSelector.cpp:148
RoR::GUI::MultiplayerSelector::m_serverlist_msg_color
ImVec4 m_serverlist_msg_color
Definition: GUI_MultiplayerSelector.h:88
RoR
Definition: AppContext.h:36
RoR::GUI::MultiplayerSelector::m_window_title
char m_window_title[100]
Definition: GUI_MultiplayerSelector.h:76
RoR::GUI::MultiplayerSelector::m_password_buf
Str< 1000 > m_password_buf
Definition: GUI_MultiplayerSelector.h:81
RoR::GUI::MpServerInfo::has_password
bool has_password
Definition: GUI_MultiplayerSelector.h:38
RoR::GUI::MultiplayerSelector::m_serverlist_httpmsg
std::string m_serverlist_httpmsg
Displayed as dimmed text.
Definition: GUI_MultiplayerSelector.h:90
RoR::GUI::MultiplayerSelector::BUTTONS_EXTRA_SPACE
const float BUTTONS_EXTRA_SPACE
Definition: GUI_MultiplayerSelector.h:57
RoR::GUI::MultiplayerSelector::m_user_token_buf
Str< 1000 > m_user_token_buf
Definition: GUI_MultiplayerSelector.h:79