Chatterino
FfzBadges.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "common/Aliases.hpp"
5 #include "util/QStringHash.hpp"
6 
7 #include <QColor>
8 #include <boost/optional.hpp>
9 #include <common/Singleton.hpp>
10 
11 #include <map>
12 #include <memory>
13 #include <set>
14 #include <shared_mutex>
15 #include <unordered_map>
16 #include <vector>
17 
18 namespace chatterino {
19 
20 struct Emote;
21 using EmotePtr = std::shared_ptr<const Emote>;
22 
23 class FfzBadges : public Singleton
24 {
25 public:
26  virtual void initialize(Settings &settings, Paths &paths) override;
27  FfzBadges() = default;
28 
29  struct Badge {
31  QColor color;
32  };
33 
34  std::vector<Badge> getUserBadges(const UserId &id);
35 
36 private:
37  boost::optional<Badge> getBadge(int badgeID);
38 
39  void load();
40 
41  std::shared_mutex mutex_;
42 
43  // userBadges points a user ID to the list of badges they have
44  std::unordered_map<QString, std::set<int>> userBadges;
45 
46  // badges points a badge ID to the information about the badge
47  std::unordered_map<int, Badge> badges;
48 };
49 
50 } // namespace chatterino
Definition: Singleton.hpp:10
EmotePtr emote
Definition: FfzBadges.hpp:30
Definition: Application.cpp:48
Definition: FfzBadges.hpp:23
Definition: FfzBadges.hpp:29
std::shared_ptr< const Emote > EmotePtr
Definition: Emote.hpp:38
QColor color
Definition: FfzBadges.hpp:31
Settings which are availlable for reading and writing on the gui thread.
Definition: Settings.hpp:78
Definition: Paths.hpp:8
std::vector< Badge > getUserBadges(const UserId &id)
Definition: FfzBadges.cpp:21
virtual void initialize(Settings &settings, Paths &paths) override
Definition: FfzBadges.cpp:16
void load(const std::shared_ptr< NetworkData > &data)
Definition: NetworkPrivate.cpp:391