fixed emote preview not using 3x images
This commit is contained in:
+33
-23
@@ -58,31 +58,36 @@ const ImagePtr &ImageSet::getImage3() const
|
||||
return this->imageX3_;
|
||||
}
|
||||
|
||||
const ImagePtr &ImageSet::getImage(float scale) const
|
||||
const std::shared_ptr<Image> &getImagePriv(const ImageSet &set, float scale)
|
||||
{
|
||||
scale *= getSettings()->emoteScale;
|
||||
|
||||
int quality = 1;
|
||||
|
||||
if (scale > 2.001f)
|
||||
quality = 3;
|
||||
else if (scale > 1.001f)
|
||||
quality = 2;
|
||||
|
||||
if (!set.getImage3()->isEmpty() && quality == 3)
|
||||
{
|
||||
return set.getImage3();
|
||||
}
|
||||
|
||||
if (!set.getImage2()->isEmpty() && quality >= 2)
|
||||
{
|
||||
return set.getImage2();
|
||||
}
|
||||
|
||||
return set.getImage1();
|
||||
}
|
||||
|
||||
const ImagePtr &ImageSet::getImageOrLoaded(float scale) const
|
||||
{
|
||||
auto &&result = getImagePriv(*this, scale);
|
||||
|
||||
// get best image based on scale
|
||||
auto &&result = [&]() -> const std::shared_ptr<Image> & {
|
||||
scale *= getSettings()->emoteScale;
|
||||
|
||||
int quality = 1;
|
||||
|
||||
if (scale > 2.001f)
|
||||
quality = 3;
|
||||
else if (scale > 1.001f)
|
||||
quality = 2;
|
||||
|
||||
if (!this->imageX3_->isEmpty() && quality == 3)
|
||||
{
|
||||
return this->imageX3_;
|
||||
}
|
||||
|
||||
if (!this->imageX2_->isEmpty() && quality == 2)
|
||||
{
|
||||
return this->imageX2_;
|
||||
}
|
||||
|
||||
return this->imageX1_;
|
||||
}();
|
||||
result->load();
|
||||
|
||||
// prefer other image if selected image is not loaded yet
|
||||
if (result->loaded())
|
||||
@@ -99,6 +104,11 @@ const ImagePtr &ImageSet::getImage(float scale) const
|
||||
return result;
|
||||
}
|
||||
|
||||
const ImagePtr &ImageSet::getImage(float scale) const
|
||||
{
|
||||
return getImagePriv(*this, scale);
|
||||
}
|
||||
|
||||
bool ImageSet::operator==(const ImageSet &other) const
|
||||
{
|
||||
return std::tie(this->imageX1_, this->imageX2_, this->imageX3_) ==
|
||||
|
||||
Reference in New Issue
Block a user