Implement preferred emote quality setting.

This doesn't work super well for Twitch emotes because they don't
conform to a proper emote scaling standard

Fixes #150
This commit is contained in:
Rasmus Karlsson
2018-01-07 02:56:45 +01:00
parent 5baba39cdc
commit 9fa9d7f0e3
8 changed files with 194 additions and 72 deletions
+44 -4
View File
@@ -3,6 +3,8 @@
#include "messages/lazyloadedimage.hpp"
#include "util/concurrentmap.hpp"
#include <cassert>
namespace chatterino {
namespace util {
@@ -12,13 +14,51 @@ struct EmoteData {
}
EmoteData(messages::LazyLoadedImage *_image)
: image(_image)
: image1x(_image)
{
}
messages::LazyLoadedImage *image = nullptr;
messages::LazyLoadedImage *getImageForSize(unsigned emoteSize) const
{
messages::LazyLoadedImage *ret = nullptr;
switch (emoteSize) {
case 0:
ret = this->image1x;
break;
case 1:
ret = this->image2x;
break;
case 2:
ret = this->image3x;
break;
default:
ret = this->image1x;
break;
}
if (ret == nullptr) {
ret = this->image1x;
}
assert(ret != nullptr);
return ret;
}
// Emotes must have a 1x image to be valid
bool isValid() const
{
return this->image1x != nullptr;
}
messages::LazyLoadedImage *image1x = nullptr;
messages::LazyLoadedImage *image2x = nullptr;
messages::LazyLoadedImage *image3x = nullptr;
};
typedef ConcurrentMap<QString, EmoteData> EmoteMap;
}
}
} // namespace util
} // namespace chatterino