diff --git a/Telegram/Resources/art/bball_idle.tgs b/Telegram/Resources/art/bball_idle.tgs
new file mode 100644
index 000000000..e82b62639
Binary files /dev/null and b/Telegram/Resources/art/bball_idle.tgs differ
diff --git a/Telegram/Resources/art/fball_idle.tgs b/Telegram/Resources/art/fball_idle.tgs
new file mode 100644
index 000000000..b1d71e43a
Binary files /dev/null and b/Telegram/Resources/art/fball_idle.tgs differ
diff --git a/Telegram/Resources/art/slot_0_idle.tgs b/Telegram/Resources/art/slot_0_idle.tgs
new file mode 100644
index 000000000..1d8a0955f
Binary files /dev/null and b/Telegram/Resources/art/slot_0_idle.tgs differ
diff --git a/Telegram/Resources/art/slot_1_idle.tgs b/Telegram/Resources/art/slot_1_idle.tgs
new file mode 100644
index 000000000..b6549225f
Binary files /dev/null and b/Telegram/Resources/art/slot_1_idle.tgs differ
diff --git a/Telegram/Resources/art/slot_2_idle.tgs b/Telegram/Resources/art/slot_2_idle.tgs
new file mode 100644
index 000000000..c13193e81
Binary files /dev/null and b/Telegram/Resources/art/slot_2_idle.tgs differ
diff --git a/Telegram/Resources/art/slot_back.tgs b/Telegram/Resources/art/slot_back.tgs
new file mode 100644
index 000000000..5eaa214a3
Binary files /dev/null and b/Telegram/Resources/art/slot_back.tgs differ
diff --git a/Telegram/Resources/art/slot_pull.tgs b/Telegram/Resources/art/slot_pull.tgs
new file mode 100644
index 000000000..478b69067
Binary files /dev/null and b/Telegram/Resources/art/slot_pull.tgs differ
diff --git a/Telegram/Resources/qrc/telegram/telegram.qrc b/Telegram/Resources/qrc/telegram/telegram.qrc
index 86befe36e..291058f37 100644
--- a/Telegram/Resources/qrc/telegram/telegram.qrc
+++ b/Telegram/Resources/qrc/telegram/telegram.qrc
@@ -49,6 +49,13 @@
../../art/sunrise.jpg
../../art/dice_idle.tgs
../../art/dart_idle.tgs
+ ../../art/bball_idle.tgs
+ ../../art/fball_idle.tgs
+ ../../art/slot_0_idle.tgs
+ ../../art/slot_1_idle.tgs
+ ../../art/slot_2_idle.tgs
+ ../../art/slot_back.tgs
+ ../../art/slot_pull.tgs
../../day-blue.tdesktop-theme
../../night.tdesktop-theme
../../night-green.tdesktop-theme
diff --git a/Telegram/SourceFiles/api/api_sending.cpp b/Telegram/SourceFiles/api/api_sending.cpp
index becdfceb8..3ee6026f6 100644
--- a/Telegram/SourceFiles/api/api_sending.cpp
+++ b/Telegram/SourceFiles/api/api_sending.cpp
@@ -225,6 +225,9 @@ bool SendDice(Api::MessageToSend &message) {
Stickers::DicePacks::kDiceString,
Stickers::DicePacks::kDartString,
Stickers::DicePacks::kSlotString,
+ Stickers::DicePacks::kFballString,
+ Stickers::DicePacks::kFballString + QChar(0xFE0F),
+ Stickers::DicePacks::kBballString,
};
const auto list = config.get>(
"emojies_send_dice",
diff --git a/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.cpp b/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.cpp
index 59a5c8ba4..631cc8df0 100644
--- a/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.cpp
+++ b/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.cpp
@@ -23,6 +23,8 @@ namespace Stickers {
const QString DicePacks::kDiceString = QString::fromUtf8("\xF0\x9F\x8E\xB2");
const QString DicePacks::kDartString = QString::fromUtf8("\xF0\x9F\x8E\xAF");
const QString DicePacks::kSlotString = QString::fromUtf8("\xF0\x9F\x8E\xB0");
+const QString DicePacks::kFballString = QString::fromUtf8("\xE2\x9A\xBD");
+const QString DicePacks::kBballString = QString::fromUtf8("\xF0\x9F\x8F\x80");
DicePack::DicePack(not_null session, const QString &emoji)
: _session(session)
@@ -56,15 +58,15 @@ void DicePack::load() {
}
void DicePack::applySet(const MTPDmessages_stickerSet &data) {
- _map.clear();
- auto documents = base::flat_map>();
const auto isSlotMachine = DicePacks::IsSlot(_emoji);
+ auto index = 0;
+ auto documents = base::flat_map>();
for (const auto &sticker : data.vdocuments().v) {
const auto document = _session->data().processDocument(
sticker);
if (document->sticker()) {
if (isSlotMachine) {
- _map.emplace(_map.size(), document);
+ _map.emplace(index++, document);
} else {
documents.emplace(document->id, document);
}
@@ -98,14 +100,25 @@ void DicePack::tryGenerateLocalZero() {
return;
}
- const auto path = (_emoji == DicePacks::kDiceString)
- ? qsl(":/gui/art/dice_idle.tgs")
- : (_emoji == DicePacks::kDartString)
- ? qsl(":/gui/art/dart_idle.tgs")
- : QString();
- if (path.isEmpty()) {
- return;
+ if (_emoji == DicePacks::kDiceString) {
+ generateLocal(0, u"dice_idle"_q);
+ } else if (_emoji == DicePacks::kDartString) {
+ generateLocal(0, u"dart_idle"_q);
+ } else if (_emoji == DicePacks::kBballString) {
+ generateLocal(0, u"bball_idle"_q);
+ } else if (_emoji == DicePacks::kFballString) {
+ generateLocal(0, u"fball_idle"_q);
+ } else if (_emoji == DicePacks::kSlotString) {
+ generateLocal(0, u"slot_back"_q);
+ generateLocal(2, u"slot_pull"_q);
+ generateLocal(8, u"slot_0_idle"_q);
+ generateLocal(14, u"slot_1_idle"_q);
+ generateLocal(20, u"slot_2_idle"_q);
}
+}
+
+void DicePack::generateLocal(int index, const QString &name) {
+ const auto path = u":/gui/art/"_q + name + u".tgs"_q;
auto task = FileLoadTask(
_session,
path,
@@ -114,15 +127,15 @@ void DicePack::tryGenerateLocalZero() {
SendMediaType::File,
FileLoadTo(0, {}, 0),
{});
- task.process();
+ task.process({ .generateGoodThumbnail = false });
const auto result = task.peekResult();
Assert(result != nullptr);
const auto document = _session->data().processDocument(
result->document,
- Images::FromImageInMemory(result->thumb, "PNG"));
+ Images::FromImageInMemory(result->thumb, "WEBP", result->thumbbytes));
document->setLocation(Core::FileLocation(path));
- _map.emplace(0, document);
+ _map.emplace(index, document);
Ensures(document->sticker());
Ensures(document->sticker()->animated);
@@ -132,13 +145,16 @@ DicePacks::DicePacks(not_null session) : _session(session) {
}
DocumentData *DicePacks::lookup(const QString &emoji, int value) {
- const auto i = _packs.find(emoji);
+ const auto key = emoji.endsWith(QChar(0xFE0F))
+ ? emoji.mid(0, emoji.size() - 1)
+ : emoji;
+ const auto i = _packs.find(key);
if (i != end(_packs)) {
return i->second->lookup(value);
}
return _packs.emplace(
- emoji,
- std::make_unique(_session, emoji)
+ key,
+ std::make_unique(_session, key)
).first->second->lookup(value);
}
diff --git a/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.h b/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.h
index a1556ee25..e8752b84f 100644
--- a/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.h
+++ b/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.h
@@ -27,6 +27,7 @@ private:
void load();
void applySet(const MTPDmessages_stickerSet &data);
void tryGenerateLocalZero();
+ void generateLocal(int index, const QString &name);
const not_null _session;
QString _emoji;
@@ -42,6 +43,8 @@ public:
static const QString kDiceString;
static const QString kDartString;
static const QString kSlotString;
+ static const QString kFballString;
+ static const QString kBballString;
[[nodiscard]] static bool IsSlot(const QString &emoji) {
return (emoji == kSlotString);
diff --git a/Telegram/SourceFiles/history/view/media/history_view_dice.cpp b/Telegram/SourceFiles/history/view/media/history_view_dice.cpp
index 9c823b0b9..4afa66425 100644
--- a/Telegram/SourceFiles/history/view/media/history_view_dice.cpp
+++ b/Telegram/SourceFiles/history/view/media/history_view_dice.cpp
@@ -32,9 +32,7 @@ namespace {
Dice::Dice(not_null parent, not_null dice)
: _parent(parent)
, _dice(dice)
-, _link(_parent->data()->Has()
- ? nullptr
- : dice->makeHandler()) {
+, _link(dice->makeHandler()) {
if (const auto document = Lookup(parent, dice->emoji(), 0)) {
_start.emplace(parent, document);
_start->setDiceIndex(_dice->emoji(), 0);
diff --git a/Telegram/SourceFiles/history/view/media/history_view_slot_machine.cpp b/Telegram/SourceFiles/history/view/media/history_view_slot_machine.cpp
index 67a2f2743..ddd1ef733 100644
--- a/Telegram/SourceFiles/history/view/media/history_view_slot_machine.cpp
+++ b/Telegram/SourceFiles/history/view/media/history_view_slot_machine.cpp
@@ -72,9 +72,7 @@ SlotMachine::SlotMachine(
not_null dice)
: _parent(parent)
, _dice(dice)
-, _link(_parent->data()->Has()
- ? nullptr
- : dice->makeHandler()) {
+, _link(dice->makeHandler()) {
resolveStarts();
_showLastFrame = _parent->data()->Has();
if (_showLastFrame) {
diff --git a/Telegram/SourceFiles/storage/localimageloader.cpp b/Telegram/SourceFiles/storage/localimageloader.cpp
index d9c8a52a7..e1e67bf84 100644
--- a/Telegram/SourceFiles/storage/localimageloader.cpp
+++ b/Telegram/SourceFiles/storage/localimageloader.cpp
@@ -680,7 +680,7 @@ bool FileLoadTask::FillImageInformation(
return true;
}
-void FileLoadTask::process() {
+void FileLoadTask::process(Args &&args) {
_result = std::make_shared(
id(),
_id,
@@ -829,12 +829,13 @@ void FileLoadTask::process() {
}
attributes.push_back(MTP_documentAttributeVideo(MTP_flags(flags), MTP_int(video->duration), MTP_int(coverWidth), MTP_int(coverHeight)));
- goodThumbnail = video->thumbnail;
- {
- QBuffer buffer(&goodThumbnailBytes);
- goodThumbnail.save(&buffer, "JPG", kThumbnailQuality);
+ if (args.generateGoodThumbnail) {
+ goodThumbnail = video->thumbnail;
+ {
+ QBuffer buffer(&goodThumbnailBytes);
+ goodThumbnail.save(&buffer, "JPG", kThumbnailQuality);
+ }
}
-
thumbnail = PrepareFileThumbnail(std::move(video->thumbnail));
} else if (filemime == qstr("application/x-tdesktop-theme")
|| filemime == qstr("application/x-tgtheme-tdesktop")) {
@@ -863,7 +864,7 @@ void FileLoadTask::process() {
MTP_string(),
MTP_inputStickerSetEmpty(),
MTPMaskCoords()));
- if (isAnimation) {
+ if (isAnimation && args.generateGoodThumbnail) {
goodThumbnail = fullimage;
{
QBuffer buffer(&goodThumbnailBytes);
diff --git a/Telegram/SourceFiles/storage/localimageloader.h b/Telegram/SourceFiles/storage/localimageloader.h
index e80058430..d744b5b4c 100644
--- a/Telegram/SourceFiles/storage/localimageloader.h
+++ b/Telegram/SourceFiles/storage/localimageloader.h
@@ -274,8 +274,15 @@ public:
return _id;
}
- void process();
- void finish();
+ struct Args {
+ bool generateGoodThumbnail = true;
+ };
+ void process(Args &&args);
+
+ void process() override {
+ process({});
+ }
+ void finish() override;
FileLoadResult *peekResult() const;