selects correct image when scaling emotes
This commit is contained in:
+2
-1
@@ -210,7 +210,8 @@ SOURCES += \
|
|||||||
src/widgets/notificationpopup.cpp \
|
src/widgets/notificationpopup.cpp \
|
||||||
src/controllers/taggedusers/taggeduserscontroller.cpp \
|
src/controllers/taggedusers/taggeduserscontroller.cpp \
|
||||||
src/controllers/taggedusers/taggeduser.cpp \
|
src/controllers/taggedusers/taggeduser.cpp \
|
||||||
src/controllers/taggedusers/taggedusersmodel.cpp
|
src/controllers/taggedusers/taggedusersmodel.cpp \
|
||||||
|
src/util/emotemap.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/precompiled_header.hpp \
|
src/precompiled_header.hpp \
|
||||||
|
|||||||
@@ -97,19 +97,10 @@ void EmoteElement::addToContainer(MessageLayoutContainer &container, MessageElem
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int quality = getApp()->settings->preferredEmoteQuality;
|
Image *_image = this->data.getImage(container.getScale());
|
||||||
|
|
||||||
Image *_image;
|
QSize size(int(container.getScale() * _image->getScaledWidth()),
|
||||||
if (quality == 3 && this->data.image3x != nullptr) {
|
int(container.getScale() * _image->getScaledHeight()));
|
||||||
_image = this->data.image3x;
|
|
||||||
} else if (quality >= 2 && this->data.image2x != nullptr) {
|
|
||||||
_image = this->data.image2x;
|
|
||||||
} else {
|
|
||||||
_image = this->data.image1x;
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize size((int)(container.getScale() * _image->getScaledWidth()),
|
|
||||||
(int)(container.getScale() * _image->getScaledHeight()));
|
|
||||||
|
|
||||||
container.addElement(
|
container.addElement(
|
||||||
(new ImageLayoutElement(*this, _image, size))->setLink(this->getLink()));
|
(new ImageLayoutElement(*this, _image, size))->setLink(this->getLink()));
|
||||||
|
|||||||
@@ -42,7 +42,10 @@ void SettingManager::initialize()
|
|||||||
app->windows->layoutVisibleChatWidgets();
|
app->windows->layoutVisibleChatWidgets();
|
||||||
});
|
});
|
||||||
|
|
||||||
this->emoteScale.connect([](auto, auto) { getApp()->windows->layoutVisibleChatWidgets(); });
|
this->emoteScale.connect([](auto, auto) {
|
||||||
|
getApp()->fonts->incGeneration();
|
||||||
|
getApp()->windows->layoutVisibleChatWidgets();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageElement::Flags SettingManager::getWordFlags()
|
MessageElement::Flags SettingManager::getWordFlags()
|
||||||
|
|||||||
@@ -78,10 +78,10 @@ public:
|
|||||||
BoolSetting enableGifAnimations = {"/emotes/enableGifAnimations", true};
|
BoolSetting enableGifAnimations = {"/emotes/enableGifAnimations", true};
|
||||||
FloatSetting emoteScale = {"/emotes/scale", 1.f};
|
FloatSetting emoteScale = {"/emotes/scale", 1.f};
|
||||||
|
|
||||||
// 0 = Smallest size
|
// 0 = No preference
|
||||||
// 1 = One size above 0 (usually size of 0 * 2)
|
// 1 = 1x
|
||||||
// 2 = One size above 1 (usually size of 1 * 2)
|
// 2 = 2x
|
||||||
// etc...
|
// 3 = 3x
|
||||||
IntSetting preferredEmoteQuality = {"/emotes/preferredEmoteQuality", 0};
|
IntSetting preferredEmoteQuality = {"/emotes/preferredEmoteQuality", 0};
|
||||||
|
|
||||||
/// Links
|
/// Links
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#include "emotemap.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
namespace util {
|
||||||
|
|
||||||
|
EmoteData::EmoteData(messages::Image *_image)
|
||||||
|
: image1x(_image)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Emotes must have a 1x image to be valid
|
||||||
|
bool EmoteData::isValid() const
|
||||||
|
{
|
||||||
|
return this->image1x != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
messages::Image *EmoteData::getImage(float scale) const
|
||||||
|
{
|
||||||
|
int quality = getApp()->settings->preferredEmoteQuality;
|
||||||
|
|
||||||
|
if (quality == 0) {
|
||||||
|
scale *= getApp()->settings->emoteScale.getValue();
|
||||||
|
quality = [&] {
|
||||||
|
if (scale <= 1)
|
||||||
|
return 1;
|
||||||
|
if (scale <= 2)
|
||||||
|
return 2;
|
||||||
|
return 3;
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
|
||||||
|
messages::Image *_image;
|
||||||
|
if (quality == 3 && this->image3x != nullptr) {
|
||||||
|
_image = this->image3x;
|
||||||
|
} else if (quality >= 2 && this->image2x != nullptr) {
|
||||||
|
_image = this->image2x;
|
||||||
|
} else {
|
||||||
|
_image = this->image1x;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _image;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace util
|
||||||
|
} // namespace chatterino
|
||||||
@@ -9,16 +9,11 @@ namespace util {
|
|||||||
struct EmoteData {
|
struct EmoteData {
|
||||||
EmoteData() = default;
|
EmoteData() = default;
|
||||||
|
|
||||||
EmoteData(messages::Image *_image)
|
EmoteData(messages::Image *_image);
|
||||||
: image1x(_image)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Emotes must have a 1x image to be valid
|
// Emotes must have a 1x image to be valid
|
||||||
bool isValid() const
|
bool isValid() const;
|
||||||
{
|
messages::Image *getImage(float scale) const;
|
||||||
return this->image1x != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
messages::Image *image1x = nullptr;
|
messages::Image *image1x = nullptr;
|
||||||
messages::Image *image2x = nullptr;
|
messages::Image *image2x = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user