The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
info.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2016 by Tomasz Sniatowski <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #ifndef INC_LOBBY_INFO
16 #define INC_LOBBY_INFO
17 
18 #include "config.hpp"
21 /**
22  * This class represents the collective information the client has
23  * about the players and games on the server
24  */
26 {
27 public:
29 
30  ~lobby_info();
31 
32  void delete_games();
33 
34  typedef std::map<int, game_info*> game_info_map;
35 
36  /**
37  * Process a full gamelist. Current info is discarded.
38  */
39  void process_gamelist(const config& data);
40 
41  /**
42  * Process a gamelist diff.
43  * @return true on success, false on failure (e.g. when the
44  * diff did not apply correctly)
45  */
46  bool process_gamelist_diff(const config& data);
47 
49 
50  void make_games_vector();
51 
52  const config& gamelist() const
53  {
54  return gamelist_;
55  }
56 
57  void clear_game_filter();
59  void set_game_filter_invert(bool value);
60  void apply_game_filter();
61 
62  game_info* get_game_by_id(int id);
63  const game_info* get_game_by_id(int id) const;
64 
65  void sort_users(bool by_name, bool by_relation);
66 
67  void open_room(const std::string& name);
68  void close_room(const std::string& name);
69  bool has_room(const std::string& name) const;
71  const room_info* get_room(const std::string& name) const;
72 
74 
76 
77  void update_user_statuses(int game_id, const room_info* room);
78 
79  const std::vector<room_info>& rooms() const
80  {
81  return rooms_;
82  }
83  const std::vector<game_info*>& games() const
84  {
85  return games_;
86  }
87  const std::vector<bool>& games_visibility() const
88  {
89  return games_visibility_;
90  }
91  const std::vector<game_info*>& games_filtered() const;
92  const std::vector<user_info>& users() const
93  {
94  return users_;
95  }
96  const std::vector<user_info*>& users_sorted() const;
97 
98 private:
99  void process_userlist();
100 
104  std::vector<room_info> rooms_;
105 
106  game_info_map games_by_id_;
107 
108  std::vector<game_info*> games_;
109  std::vector<game_info*> games_filtered_;
110  std::vector<user_info> users_;
111  std::vector<user_info*> users_sorted_;
112  std::map<std::string, chat_log> whispers_;
115  std::vector<bool> games_visibility_;
117 };
118 
119 #endif
void close_room(const std::string &name)
Definition: info.cpp:291
bool game_filter_invert_
Definition: info.hpp:114
bool has_room(const std::string &name) const
Definition: info.cpp:274
This class represents the information a client has about a room.
Definition: data.hpp:65
std::map< std::string, chat_log > whispers_
Definition: info.hpp:112
this class memorizes a chat session.
Definition: data.hpp:40
lobby_info(const config &game_config, twesnothd_connection &)
Definition: info.cpp:41
game_info * get_game_by_id(int id)
Definition: info.cpp:242
std::vector< bool > games_visibility_
Definition: info.hpp:115
const std::vector< bool > & games_visibility() const
Definition: info.hpp:87
game_info_map games_by_id_
Definition: info.hpp:106
std::vector< game_info * > games_filtered_
Definition: info.hpp:109
~lobby_info()
Definition: info.cpp:59
This class represents the collective information the client has about the players and games on the se...
Definition: info.hpp:25
void open_room(const std::string &name)
Definition: info.cpp:284
const std::vector< room_info > & rooms() const
Definition: info.hpp:79
game_filter_and_stack game_filter_
Definition: info.hpp:113
const std::vector< game_info * > & games_filtered() const
Definition: info.cpp:301
void process_userlist()
Definition: info.cpp:194
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
Definition: glew.h:1347
config gamelist_
Definition: info.hpp:102
Definitions for the interface to Wesnoth Markup Language (WML).
This class represents the information a client has about another player.
Definition: data.hpp:102
void set_game_filter_invert(bool value)
Definition: info.cpp:316
std::map< int, game_info * > game_info_map
Definition: info.hpp:34
const config & gamelist() const
Definition: info.hpp:52
A class that represents a TCP/IP connection to the wesnothd server.
bool gamelist_initialized_
Definition: info.hpp:103
std::vector< game_info * > games_
Definition: info.hpp:108
GLsizei const GLfloat * value
Definition: glew.h:1817
void update_user_statuses(int game_id, const room_info *room)
Definition: info.cpp:350
const config & game_config_
Definition: info.hpp:101
void apply_game_filter()
Definition: info.cpp:332
void sync_games_display_status()
Definition: info.cpp:225
void make_games_vector()
Definition: info.cpp:321
chat_log & get_whisper_log(const std::string &name)
Definition: info.cpp:279
Game configuration data as global variables.
Definition: build_info.cpp:38
twesnothd_connection & wesnothd_connection_
Definition: info.hpp:116
const std::vector< user_info > & users() const
Definition: info.hpp:92
GLuint const GLchar * name
Definition: glew.h:1782
void clear_game_filter()
Definition: info.cpp:311
void add_game_filter(game_filter_base *f)
Definition: info.cpp:306
void sort_users(bool by_name, bool by_relation)
Definition: info.cpp:396
This class represents the info a client has about a game on the server.
Definition: data.hpp:136
void process_gamelist(const config &data)
Process a full gamelist.
Definition: info.cpp:102
std::vector< user_info * > users_sorted_
Definition: info.hpp:111
std::vector< room_info > rooms_
Definition: info.hpp:104
void delete_games()
Definition: info.cpp:64
std::vector< user_info > users_
Definition: info.hpp:110
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
const std::vector< game_info * > & games() const
Definition: info.hpp:83
GLsizei const GLcharARB ** string
Definition: glew.h:4503
room_info * get_room(const std::string &name)
Definition: info.cpp:254
const std::vector< user_info * > & users_sorted() const
Definition: info.cpp:420
bool process_gamelist_diff(const config &data)
Process a gamelist diff.
Definition: info.cpp:120
user_info & get_user(const std::string &name)
GLclampf f
Definition: glew.h:3024