The Battle for Wesnoth  1.15.1+dev
display_chat_manager.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2018 by Chris Beck <render787@gmail.com>
3  Part of the Battle for Wesnoth Project https://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 #pragma once
16 
17 #include "chat_events.hpp"
18 
19 #include <cstdint>
20 #include <ctime>
21 #include <set>
22 #include <string>
23 #include <vector>
24 
25 class display;
26 
28 public:
30 
31  void add_observer(const std::string& name) { observers_.insert(name); }
32  void remove_observer(const std::string& name) { observers_.erase(name); }
33  const std::set<std::string>& observers() const { return observers_; }
34 
35  void add_whisperer(const std::string& nick) { whisperers_.insert(nick); }
36  void remove_whisperer(const std::string& nick) { whisperers_.erase(nick); }
37  const std::set<std::string>& whisperers() const { return whisperers_; }
38 
39  void add_chat_message(const std::time_t& time, const std::string& speaker,
40  int side, const std::string& msg, events::chat_handler::MESSAGE_TYPE type, bool bell);
42 
43  friend class game_display; //needed because it calls prune_chat_message
44 private:
45  std::set<std::string> observers_;
46  std::set<std::string> whisperers_; //nicks who whisper you for tab-completition purpose
47 
48  struct chat_message
49  {
50  chat_message(int speaker, int h);
51 
53  int handle;
54  uint32_t created_at;
55  };
56 
57  void prune_chat_messages(bool remove_all=false);
58 
59  std::vector<chat_message> chat_messages_;
60 
62 };
display_chat_manager(display &disp)
const std::set< std::string > & whisperers() const
std::set< std::string > observers_
const std::set< std::string > & observers() const
#define h
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:109
std::set< std::string > whisperers_
std::vector< chat_message > chat_messages_
void add_chat_message(const std::time_t &time, const std::string &speaker, int side, const std::string &msg, events::chat_handler::MESSAGE_TYPE type, bool bell)
static const char * name(const std::vector< SDL_Joystick *> &joysticks, const std::size_t index)
Definition: joystick.cpp:48
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)
void add_observer(const std::string &name)