The Battle for Wesnoth  1.19.0-dev
display_chat_manager.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2024
3  by Chris Beck <render787@gmail.com>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include "chat_events.hpp"
19 
20 #include <cstdint>
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 std::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;
55  uint32_t created_at;
56  };
57 
58  void prune_chat_messages(bool remove_all=false);
59 
60  std::vector<chat_message> chat_messages_;
61 
63 };
std::set< std::string > whisperers_
std::set< std::string > observers_
display_chat_manager(display &disp)
void remove_whisperer(const std::string &nick)
void remove_observer(const std::string &name)
void add_observer(const std::string &name)
void add_whisperer(const std::string &nick)
const std::set< std::string > & observers() const
const std::set< std::string > & whisperers() const
void prune_chat_messages(bool remove_all=false)
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)
std::vector< chat_message > chat_messages_
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
Definition: display.hpp:81
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:109
#define h