gui/dialogs/lobby/lobby_info.hpp

Go to the documentation of this file.
00001 /* $Id: lobby_info.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2009 - 2012 by Tomasz Sniatowski <kailoran@gmail.com>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #ifndef INC_LOBBY_INFO
00017 #define INC_LOBBY_INFO
00018 
00019 #include "config.hpp"
00020 #include "gui/dialogs/lobby/lobby_data.hpp"
00021 
00022 /**
00023  * This class represents the collective information the client has
00024  * about the players and games on the server
00025  */
00026 class lobby_info
00027 {
00028 public:
00029     explicit lobby_info(const config& game_config);
00030 
00031     ~lobby_info();
00032 
00033     void delete_games();
00034 
00035     typedef std::map<int, game_info*> game_info_map;
00036 
00037     /**
00038      * Process a full gamelist. Current info is discarded.
00039      */
00040     void process_gamelist(const config &data);
00041 
00042     /**
00043      * Process a gamelist diff.
00044      * @return true on success, false on failure (e.g. when the
00045      * diff did not apply correctly)
00046      */
00047     bool process_gamelist_diff(const config &data);
00048 
00049     void sync_games_display_status();
00050 
00051     void make_games_vector();
00052 
00053     const config& gamelist() const { return gamelist_; }
00054 
00055     void clear_game_filter();
00056     void add_game_filter(game_filter_base* f);
00057     void set_game_filter_invert(bool value);
00058     void apply_game_filter();
00059 
00060     game_info* get_game_by_id(int id);
00061     const game_info* get_game_by_id(int id) const;
00062 
00063     void sort_users(bool by_name, bool by_relation);
00064 
00065     void open_room(const std::string& name);
00066     void close_room(const std::string& name);
00067     bool has_room(const std::string& name) const;
00068     room_info* get_room(const std::string& name);
00069     const room_info* get_room(const std::string& name) const;
00070 
00071     user_info& get_user(const std::string& name);
00072 
00073     chat_log& get_whisper_log(const std::string& name);
00074 
00075     void update_user_statuses(int game_id, const room_info* room);
00076 
00077     const std::vector<room_info>& rooms() const { return rooms_; }
00078     const std::vector<game_info*>& games() const { return games_; }
00079     const std::vector<bool>& games_visibility() const { return games_visibility_; }
00080     const std::vector<game_info*>& games_filtered() const;
00081     const std::vector<user_info>& users() const { return users_; }
00082     const std::vector<user_info*>& users_sorted() const;
00083 private:
00084     void process_userlist();
00085 
00086     const config& game_config_;
00087     config gamelist_;
00088     bool gamelist_initialized_;
00089     std::vector<room_info> rooms_;
00090 
00091     game_info_map games_by_id_;
00092 
00093     std::vector<game_info*> games_;
00094     std::vector<game_info*> games_filtered_;
00095     std::vector<user_info> users_;
00096     std::vector<user_info*> users_sorted_;
00097     std::map<std::string, chat_log> whispers_;
00098     game_filter_and_stack game_filter_;
00099     bool game_filter_invert_;
00100     std::vector<bool> games_visibility_;
00101 };
00102 
00103 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:58 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs