This class represents the collective information the client has about the players and games on the server. More...
#include <lobby_info.hpp>
Public Types | |
typedef std::map< int, game_info > | game_info_map |
using | game_filter_func = std::function< bool(const game_info &)> |
Public Member Functions | |
lobby_info () | |
void | process_gamelist (const config &data) |
Process a full game list. More... | |
bool | process_gamelist_diff (const config &data) |
Process a gamelist diff. More... | |
std::function< void()> | begin_state_sync () |
Updates the game pointer list and returns a second stage cleanup function to be called after any actions have been done using the pointer list. More... | |
const config & | gamelist () const |
Returns the raw game list config data. More... | |
void | add_game_filter (game_filter_func func) |
Adds a new filter function to be considered when apply_game_filter is called. More... | |
void | clear_game_filters () |
Clears all game filter functions. More... | |
void | set_game_filter_invert (std::function< bool(bool)> value) |
Sets whether the result of each game filter should be inverted. More... | |
bool | is_game_visible (const game_info &) |
Returns whether the game would be visible after the game filters are applied. More... | |
void | apply_game_filter () |
Generates a new list of games that match the current filter functions and inversion setting. More... | |
game_info * | get_game_by_id (int id) |
Returns info on a game with the given game ID. More... | |
const game_info * | get_game_by_id (int id) const |
Const overload of get_game_by_id. More... | |
user_info * | get_user (const std::string &name) |
Returns info on the user with the given name, or nullptr if they don't eixst. More... | |
const std::vector< game_info * > & | games () const |
const boost::dynamic_bitset & | games_visibility () const |
const std::vector< user_info > & | users () const |
std::vector< user_info > & | users () |
bool | gamelist_initialized () const |
void | refresh_installed_addons_cache () |
Private Member Functions | |
bool | process_gamelist_diff_impl (const config &data) |
void | process_userlist () |
void | make_games_vector () |
Generates a new vector of game pointers from the ID/game map. More... | |
Private Attributes | |
std::vector< std::string > | installed_addons_ |
config | gamelist_ |
bool | gamelist_initialized_ |
game_info_map | games_by_id_ |
std::vector< game_info * > | games_ |
std::vector< user_info > | users_ |
std::vector< game_filter_func > | game_filters_ |
std::function< bool(bool)> | game_filter_invert_ |
boost::dynamic_bitset | games_visibility_ |
This class represents the collective information the client has about the players and games on the server.
Definition at line 30 of file lobby_info.hpp.
using mp::lobby_info::game_filter_func = std::function<bool(const game_info&)> |
Definition at line 62 of file lobby_info.hpp.
typedef std::map<int, game_info> mp::lobby_info::game_info_map |
Definition at line 35 of file lobby_info.hpp.
mp::lobby_info::lobby_info | ( | ) |
Definition at line 34 of file lobby_info.cpp.
References refresh_installed_addons_cache().
Referenced by mp::get_lobby_info().
|
inline |
Adds a new filter function to be considered when apply_game_filter is called.
Definition at line 65 of file lobby_info.hpp.
References game_filters_.
Referenced by gui2::dialogs::mp_lobby::game_filter_init().
void mp::lobby_info::apply_game_filter | ( | ) |
Generates a new list of games that match the current filter functions and inversion setting.
Definition at line 336 of file lobby_info.cpp.
References games_, games_visibility_, i, and is_game_visible().
Referenced by begin_state_sync(), and gui2::dialogs::mp_lobby::update_gamelist_filter().
std::function< void()> mp::lobby_info::begin_state_sync | ( | ) |
Updates the game pointer list and returns a second stage cleanup function to be called after any actions have been done using the pointer list.
Definition at line 255 of file lobby_info.cpp.
References apply_game_filter(), mp::game_info::CLEAN, DBG_LB, mp::game_info::DELETED, games_by_id_, i, and make_games_vector().
Referenced by gui2::dialogs::mp_lobby::update_gamelist(), and gui2::dialogs::mp_lobby::update_gamelist_diff().
|
inline |
Clears all game filter functions.
Definition at line 71 of file lobby_info.hpp.
References game_filters_.
Referenced by gui2::dialogs::mp_lobby::game_filter_init().
|
inline |
Returns the raw game list config data.
Definition at line 57 of file lobby_info.hpp.
References gamelist_.
Referenced by gui2::dialogs::mp_lobby::pre_show().
|
inline |
Definition at line 117 of file lobby_info.hpp.
References gamelist_initialized_.
Referenced by gui2::dialogs::mp_lobby::network_handler().
|
inline |
Definition at line 97 of file lobby_info.hpp.
References games_.
Referenced by gui2::dialogs::mp_lobby::enter_game_by_index(), gui2::dialogs::mp_lobby::pre_show(), gui2::dialogs::mp_lobby::update_gamelist(), gui2::dialogs::mp_lobby::update_gamelist_diff(), gui2::dialogs::mp_lobby::update_gamelist_filter(), gui2::dialogs::mp_lobby::update_selected_game(), and gui2::dialogs::mp_lobby::update_visible_games().
|
inline |
Definition at line 102 of file lobby_info.hpp.
References games_visibility_.
Referenced by gui2::dialogs::mp_lobby::update_visible_games().
game_info * mp::lobby_info::get_game_by_id | ( | int | id | ) |
Returns info on a game with the given game ID.
Definition at line 287 of file lobby_info.cpp.
References games_by_id_, and i.
Referenced by gui2::dialogs::mp_lobby::enter_game_by_id(), gui2::dialogs::lobby_player_info::pre_show(), and process_userlist().
const game_info * mp::lobby_info::get_game_by_id | ( | int | id | ) | const |
Const overload of get_game_by_id.
Definition at line 293 of file lobby_info.cpp.
References games_by_id_, and i.
user_info * mp::lobby_info::get_user | ( | const std::string & | name | ) |
Returns info on the user with the given name, or nullptr if they don't eixst.
Definition at line 299 of file lobby_info.cpp.
References users_.
bool mp::lobby_info::is_game_visible | ( | const game_info & | game | ) |
Returns whether the game would be visible after the game filters are applied.
Definition at line 325 of file lobby_info.cpp.
References game_filter_invert_, and game_filters_.
Referenced by apply_game_filter(), and gui2::dialogs::mp_lobby::update_gamelist_diff().
|
private |
Generates a new vector of game pointers from the ID/game map.
The games will be referenced in ascending order by ID.
Definition at line 310 of file lobby_info.cpp.
References games_, games_by_id_, and games_visibility_.
Referenced by begin_state_sync().
void mp::lobby_info::process_gamelist | ( | const config & | data | ) |
Process a full game list.
Current info is discarded.
Definition at line 114 of file lobby_info.cpp.
References c, config::child_range(), data, DBG_LB, gamelist_, gamelist_initialized_, games_by_id_, installed_addons_, config::mandatory_child(), process_userlist(), and SCOPE_LB.
Referenced by gui2::dialogs::mp_lobby::process_gamelist().
bool mp::lobby_info::process_gamelist_diff | ( | const config & | data | ) |
Process a gamelist diff.
data | Raw game list data, usually received from the MP server. |
Definition at line 134 of file lobby_info.cpp.
References data, gamelist_initialized_, and process_gamelist_diff_impl().
Referenced by gui2::dialogs::mp_lobby::process_gamelist_diff().
|
private |
Definition at line 145 of file lobby_info.cpp.
References config::apply_diff(), c, config::child_range(), config::clear_diff_track(), data, DBG_LB, mp::game_info::DELETED, config::diff_track_attribute, e, ERR_LB, gamelist_, gamelist_initialized_, games_by_id_, installed_addons_, config::mandatory_child(), mp::game_info::NEW, process_userlist(), SCOPE_LB, mp::game_info::UPDATED, and WRN_LB.
Referenced by process_gamelist_diff().
|
private |
Definition at line 222 of file lobby_info.cpp.
References c, config::child_range(), mp::user_info::FRIEND, g, mp::user_info::game_id, gamelist_, get_game_by_id(), mp::user_info::get_relation(), mp::user_info::IGNORED, mp::user_info::name, SCOPE_LB, users_, and WRN_NG.
Referenced by process_gamelist(), and process_gamelist_diff_impl().
void mp::lobby_info::refresh_installed_addons_cache | ( | ) |
Definition at line 48 of file lobby_info.cpp.
References installed_addons(), and installed_addons_.
Referenced by lobby_info().
|
inline |
Sets whether the result of each game filter should be inverted.
Definition at line 77 of file lobby_info.hpp.
References game_filter_invert_.
|
inline |
Definition at line 112 of file lobby_info.hpp.
References users_.
|
inline |
Definition at line 107 of file lobby_info.hpp.
References users_.
Referenced by gui2::dialogs::mp_lobby::pre_show(), and gui2::dialogs::mp_lobby::update_playerlist().
|
private |
Definition at line 149 of file lobby_info.hpp.
Referenced by is_game_visible(), and set_game_filter_invert().
|
private |
Definition at line 147 of file lobby_info.hpp.
Referenced by add_game_filter(), clear_game_filters(), and is_game_visible().
|
private |
Definition at line 137 of file lobby_info.hpp.
Referenced by gamelist(), process_gamelist(), process_gamelist_diff_impl(), and process_userlist().
|
private |
Definition at line 139 of file lobby_info.hpp.
Referenced by gamelist_initialized(), process_gamelist(), process_gamelist_diff(), and process_gamelist_diff_impl().
|
private |
Definition at line 143 of file lobby_info.hpp.
Referenced by apply_game_filter(), games(), and make_games_vector().
|
private |
Definition at line 141 of file lobby_info.hpp.
Referenced by begin_state_sync(), get_game_by_id(), make_games_vector(), process_gamelist(), and process_gamelist_diff_impl().
|
private |
Definition at line 151 of file lobby_info.hpp.
Referenced by apply_game_filter(), games_visibility(), and make_games_vector().
|
private |
Definition at line 135 of file lobby_info.hpp.
Referenced by process_gamelist(), process_gamelist_diff_impl(), and refresh_installed_addons_cache().
|
private |
Definition at line 145 of file lobby_info.hpp.
Referenced by get_user(), process_userlist(), and users().