mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-17 22:57:11 +02:00
Fix collision of dice_sticker last frames.
This commit is contained in:
parent
f03351d112
commit
13ea045055
4 changed files with 28 additions and 12 deletions
|
@ -441,7 +441,7 @@ void StickerInBubblePart::ensureCreated(Element *replacing) const {
|
|||
_skipTop = data.skipTop;
|
||||
_sticker.emplace(_parent, sticker, skipPremiumEffect, replacing);
|
||||
if (data.singleTimePlayback) {
|
||||
_sticker->setDiceIndex(info->alt, 1);
|
||||
_sticker->setPlayingOnce(true);
|
||||
}
|
||||
_sticker->initSize(data.size);
|
||||
_sticker->setCustomCachingTag(data.cacheTag);
|
||||
|
|
|
@ -295,7 +295,7 @@ void PremiumGift::ensureStickerCreated() const {
|
|||
if (const auto sticker = document->sticker()) {
|
||||
const auto skipPremiumEffect = false;
|
||||
_sticker.emplace(_parent, document, skipPremiumEffect, _parent);
|
||||
_sticker->setDiceIndex(sticker->alt, 1);
|
||||
_sticker->setPlayingOnce(true);
|
||||
_sticker->initSize(st::msgServiceGiftBoxStickerSize);
|
||||
return;
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ void PremiumGift::ensureStickerCreated() const {
|
|||
if (const auto sticker = document->sticker()) {
|
||||
const auto skipPremiumEffect = false;
|
||||
_sticker.emplace(_parent, document, skipPremiumEffect, _parent);
|
||||
_sticker->setDiceIndex(sticker->alt, 1);
|
||||
_sticker->setPlayingOnce(true);
|
||||
_sticker->initSize(st::msgServiceGiftBoxStickerSize);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -249,7 +249,9 @@ DocumentData *Sticker::document() {
|
|||
}
|
||||
|
||||
void Sticker::stickerClearLoopPlayed() {
|
||||
_oncePlayed = false;
|
||||
if (!_playingOnce) {
|
||||
_oncePlayed = false;
|
||||
}
|
||||
_premiumEffectSkipped = false;
|
||||
}
|
||||
|
||||
|
@ -304,7 +306,7 @@ void Sticker::paintAnimationFrame(
|
|||
_nextLastDiceFrame = !paused
|
||||
&& (_diceIndex > 0)
|
||||
&& (_frameIndex + 2 == count);
|
||||
const auto playOnce = (_diceIndex > 0)
|
||||
const auto playOnce = (_playingOnce || _diceIndex > 0)
|
||||
? true
|
||||
: (_diceIndex == 0)
|
||||
? false
|
||||
|
@ -332,10 +334,10 @@ bool Sticker::paintPixmap(
|
|||
if (pixmap.isNull()) {
|
||||
return false;
|
||||
}
|
||||
const auto position = QPoint(
|
||||
r.x() + (r.width() - _size.width()) / 2,
|
||||
r.y() + (r.height() - _size.height()) / 2);
|
||||
const auto size = pixmap.size() / pixmap.devicePixelRatio();
|
||||
const auto position = QPoint(
|
||||
r.x() + (r.width() - size.width()) / 2,
|
||||
r.y() + (r.height() - size.height()) / 2);
|
||||
const auto mirror = mirrorHorizontal();
|
||||
if (mirror) {
|
||||
p.save();
|
||||
|
@ -386,6 +388,14 @@ void Sticker::paintPath(
|
|||
|
||||
QPixmap Sticker::paintedPixmap(const PaintContext &context) const {
|
||||
auto helper = std::optional<style::owned_color>();
|
||||
const auto sticker = _data->sticker();
|
||||
const auto ratio = style::DevicePixelRatio();
|
||||
const auto adjust = [&](int side) {
|
||||
return (((side * ratio) / 8) * 8) / ratio;
|
||||
};
|
||||
const auto useSize = (sticker && sticker->type == StickerType::Tgs)
|
||||
? QSize(adjust(_size.width()), adjust(_size.height()))
|
||||
: _size;
|
||||
const auto colored = (customEmojiPart() && _data->emojiUsesTextColor())
|
||||
? &helper.emplace(ComputeEmojiTextColor(context)).color()
|
||||
: context.selected()
|
||||
|
@ -393,19 +403,19 @@ QPixmap Sticker::paintedPixmap(const PaintContext &context) const {
|
|||
: nullptr;
|
||||
const auto good = _dataMedia->goodThumbnail();
|
||||
if (const auto image = _dataMedia->getStickerLarge()) {
|
||||
return image->pix(_size, { .colored = colored });
|
||||
return image->pix(useSize, { .colored = colored });
|
||||
//
|
||||
// Inline thumbnails can't have alpha channel.
|
||||
//
|
||||
//} else if (const auto blurred = _data->thumbnailInline()) {
|
||||
// return blurred->pix(
|
||||
// _size,
|
||||
// useSize,
|
||||
// { .colored = colored, .options = Images::Option::Blur });
|
||||
} else if (good) {
|
||||
return good->pix(_size, { .colored = colored });
|
||||
return good->pix(useSize, { .colored = colored });
|
||||
} else if (const auto thumbnail = _dataMedia->thumbnail()) {
|
||||
return thumbnail->pix(
|
||||
_size,
|
||||
useSize,
|
||||
{ .colored = colored, .options = Images::Option::Blur });
|
||||
}
|
||||
return QPixmap();
|
||||
|
@ -511,6 +521,10 @@ void Sticker::setDiceIndex(const QString &emoji, int index) {
|
|||
_diceIndex = index;
|
||||
}
|
||||
|
||||
void Sticker::setPlayingOnce(bool once) {
|
||||
_playingOnce = once;
|
||||
}
|
||||
|
||||
void Sticker::setCustomCachingTag(ChatHelpers::StickerLottieSize tag) {
|
||||
_cachingTag = tag;
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ public:
|
|||
}
|
||||
|
||||
void setDiceIndex(const QString &emoji, int index);
|
||||
void setPlayingOnce(bool once);
|
||||
void setCustomCachingTag(ChatHelpers::StickerLottieSize tag);
|
||||
void setCustomEmojiPart();
|
||||
void setEmojiSticker();
|
||||
|
@ -141,6 +142,7 @@ private:
|
|||
bool _customEmojiPart : 1 = false;
|
||||
bool _emojiSticker : 1 = false;
|
||||
bool _webpagePart : 1 = false;
|
||||
bool _playingOnce : 1 = false;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue