Start with the end Dice animation in forwarded.

This commit is contained in:
John Preston 2020-03-06 13:48:29 +04:00
parent e7ca405e8c
commit 2cefccc6eb
2 changed files with 15 additions and 12 deletions

View File

@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "chat_helpers/stickers_dice_pack.h"
#include "history/history.h"
#include "history/history_item.h"
#include "history/history_item_components.h"
#include "history/view/history_view_element.h"
#include "main/main_session.h"
@ -28,7 +29,12 @@ Dice::Dice(not_null<Element*> parent, int value)
: _parent(parent)
, _start(parent, Lookup(parent, 0))
, _value(value) {
_start.setDiceIndex(0);
_showLastFrame = _parent->data()->Has<HistoryMessageForwarded>();
if (_showLastFrame) {
_drawingEnd = true;
} else {
_start.setDiceIndex(0);
}
}
Dice::~Dice() = default;
@ -38,19 +44,17 @@ QSize Dice::size() {
}
void Dice::draw(Painter &p, const QRect &r, bool selected) {
Expects(_end.has_value() || !_drawingEnd);
if (!_end && _value) {
if (const auto document = Lookup(_parent, _value)) {
_end.emplace(_parent, document);
_end->setDiceIndex(_value);
_end->initSize();
}
}
if (_drawingEnd) {
_end->draw(p, r, selected);
} else {
_start.draw(p, r, selected);
if (!_end && _value) {
if (const auto document = Lookup(_parent, _value)) {
_end.emplace(_parent, document);
_end->setDiceIndex(_value);
_end->initSize();
}
}
if (_end && _end->readyToDrawLottie() && _start.atTheEnd()) {
_drawingEnd = true;
}

View File

@ -21,7 +21,6 @@ public:
void draw(Painter &p, const QRect &r, bool selected) override;
void clearStickerLoopPlayed() override {
_lottieOncePlayed = false;
}
void unloadHeavyPart() override {
_start.unloadHeavyPart();
@ -38,7 +37,7 @@ private:
std::optional<Sticker> _end;
Sticker _start;
int _value = 0;
mutable bool _lottieOncePlayed = false;
mutable bool _showLastFrame = false;
mutable bool _drawingEnd = false;
};