The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
display_chat_manager.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2016 by Chris Beck <[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 INCL_DISPLAY_CHAT_MGR_HPP_
16 #define INCL_DISPLAY_CHAT_MGR_HPP_
17 
18 #include "chat_events.hpp"
19 
20 #include <boost/cstdint.hpp>
21 #include <ctime>
22 #include <set>
23 #include <string>
24 #include <vector>
25 
26 class display;
27 
29 public:
31 
32  void add_observer(const std::string& name) { observers_.insert(name); }
33  void remove_observer(const std::string& name) { observers_.erase(name); }
34  const std::set<std::string>& observers() const { return observers_; }
35 
36  void add_whisperer(const std::string& nick) { whisperers_.insert(nick); }
37  void remove_whisperer(const std::string& nick) { whisperers_.erase(nick); }
38  const std::set<std::string>& whisperers() const { return whisperers_; }
39 
40  void add_chat_message(const time_t& time, const std::string& speaker,
41  int side, const std::string& msg, events::chat_handler::MESSAGE_TYPE type, bool bell);
43 
44  friend class game_display; //needed because it calls prune_chat_message
45 private:
46  std::set<std::string> observers_;
47  std::set<std::string> whisperers_; //nicks who whisper you for tab-completition purpose
48 
49  struct chat_message
50  {
51  chat_message(int speaker, int h);
52 
54  int handle;
56  };
57 
58  void prune_chat_messages(bool remove_all=false);
59 
60  std::vector<chat_message> chat_messages_;
61 
63 };
64 
65 #endif
display_chat_manager(display &disp)
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1221
boost::uint32_t uint32_t
Definition: xbrz.hpp:45
std::set< std::string > observers_
std::set< std::string > whisperers_
std::vector< chat_message > chat_messages_
void add_whisperer(const std::string &nick)
void prune_chat_messages(bool remove_all=false)
void remove_whisperer(const std::string &nick)
void remove_observer(const std::string &name)
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:5910
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:112
GLuint const GLchar * name
Definition: glew.h:1782
void add_observer(const std::string &name)
void add_chat_message(const time_t &time, const std::string &speaker, int side, const std::string &msg, events::chat_handler::MESSAGE_TYPE type, bool bell)
const std::set< std::string > & whisperers() const
GLsizei const GLcharARB ** string
Definition: glew.h:4503
const std::set< std::string > & observers() const