-
-
Notifications
You must be signed in to change notification settings - Fork 548
Expand file tree
/
Copy pathEmoteController.cpp
More file actions
95 lines (80 loc) · 2.06 KB
/
EmoteController.cpp
File metadata and controls
95 lines (80 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "controllers/emotes/EmoteController.hpp"
#include "controllers/emotes/EmoteProvider.hpp"
#include "providers/emoji/Emojis.hpp"
#include "providers/twitch/TwitchEmotes.hpp"
#include "singletons/helper/GifTimer.hpp"
namespace chatterino {
EmoteController::EmoteController()
: twitchEmotes_(std::make_unique<TwitchEmotes>())
, emojis_(std::make_unique<Emojis>())
, gifTimer_(std::make_unique<GIFTimer>())
{
}
EmoteController::~EmoteController() = default;
void EmoteController::initialize()
{
this->emojis_->load();
this->gifTimer_->initialize();
this->sort();
for (const auto &provider : this->providers_)
{
provider->initialize();
}
}
EmoteProviderPtr EmoteController::findProviderByName(QStringView name) const
{
auto it = std::ranges::find_if(this->providers_, [&](const auto &provider) {
return provider->name() == name;
});
if (it == this->providers_.end())
{
return nullptr;
}
return *it;
}
EmoteProviderPtr EmoteController::findProviderByID(QStringView id) const
{
auto it = std::ranges::find_if(this->providers_, [&](const auto &provider) {
return provider->id() == id;
});
if (it == this->providers_.end())
{
return nullptr;
}
return *it;
}
EmotePtr EmoteController::resolveGlobal(const EmoteName &query) const
{
for (const auto &provider : this->providers_)
{
auto emote = provider->globalEmote(query);
if (emote)
{
return emote;
}
}
return nullptr;
}
std::span<const EmoteProviderPtr> EmoteController::getProviders() const
{
return this->providers_;
}
TwitchEmotes *EmoteController::getTwitchEmotes() const
{
return this->twitchEmotes_.get();
}
Emojis *EmoteController::getEmojis() const
{
return this->emojis_.get();
}
GIFTimer *EmoteController::getGIFTimer() const
{
return this->gifTimer_.get();
}
void EmoteController::sort()
{
std::ranges::sort(this->providers_, {}, [](const auto &provider) {
return provider->priority();
});
}
} // namespace chatterino