mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-17 22:57:11 +02:00
Keep first game sticker frames inside the binary.
This commit is contained in:
parent
7f956d32a6
commit
c2f0bcf933
15 changed files with 64 additions and 31 deletions
BIN
Telegram/Resources/art/bball_idle.tgs
Normal file
BIN
Telegram/Resources/art/bball_idle.tgs
Normal file
Binary file not shown.
BIN
Telegram/Resources/art/fball_idle.tgs
Normal file
BIN
Telegram/Resources/art/fball_idle.tgs
Normal file
Binary file not shown.
BIN
Telegram/Resources/art/slot_0_idle.tgs
Normal file
BIN
Telegram/Resources/art/slot_0_idle.tgs
Normal file
Binary file not shown.
BIN
Telegram/Resources/art/slot_1_idle.tgs
Normal file
BIN
Telegram/Resources/art/slot_1_idle.tgs
Normal file
Binary file not shown.
BIN
Telegram/Resources/art/slot_2_idle.tgs
Normal file
BIN
Telegram/Resources/art/slot_2_idle.tgs
Normal file
Binary file not shown.
BIN
Telegram/Resources/art/slot_back.tgs
Normal file
BIN
Telegram/Resources/art/slot_back.tgs
Normal file
Binary file not shown.
BIN
Telegram/Resources/art/slot_pull.tgs
Normal file
BIN
Telegram/Resources/art/slot_pull.tgs
Normal file
Binary file not shown.
|
@ -49,6 +49,13 @@
|
|||
<file alias="art/sunrise.jpg">../../art/sunrise.jpg</file>
|
||||
<file alias="art/dice_idle.tgs">../../art/dice_idle.tgs</file>
|
||||
<file alias="art/dart_idle.tgs">../../art/dart_idle.tgs</file>
|
||||
<file alias="art/bball_idle.tgs">../../art/bball_idle.tgs</file>
|
||||
<file alias="art/fball_idle.tgs">../../art/fball_idle.tgs</file>
|
||||
<file alias="art/slot_0_idle.tgs">../../art/slot_0_idle.tgs</file>
|
||||
<file alias="art/slot_1_idle.tgs">../../art/slot_1_idle.tgs</file>
|
||||
<file alias="art/slot_2_idle.tgs">../../art/slot_2_idle.tgs</file>
|
||||
<file alias="art/slot_back.tgs">../../art/slot_back.tgs</file>
|
||||
<file alias="art/slot_pull.tgs">../../art/slot_pull.tgs</file>
|
||||
<file alias="day-blue.tdesktop-theme">../../day-blue.tdesktop-theme</file>
|
||||
<file alias="night.tdesktop-theme">../../night.tdesktop-theme</file>
|
||||
<file alias="night-green.tdesktop-theme">../../night-green.tdesktop-theme</file>
|
||||
|
|
|
@ -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<std::vector<QString>>(
|
||||
"emojies_send_dice",
|
||||
|
|
|
@ -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<Main::Session*> 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<DocumentId, not_null<DocumentData*>>();
|
||||
const auto isSlotMachine = DicePacks::IsSlot(_emoji);
|
||||
auto index = 0;
|
||||
auto documents = base::flat_map<DocumentId, not_null<DocumentData*>>();
|
||||
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<Main::Session*> 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<DicePack>(_session, emoji)
|
||||
key,
|
||||
std::make_unique<DicePack>(_session, key)
|
||||
).first->second->lookup(value);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Main::Session*> _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);
|
||||
|
|
|
@ -32,9 +32,7 @@ namespace {
|
|||
Dice::Dice(not_null<Element*> parent, not_null<Data::MediaDice*> dice)
|
||||
: _parent(parent)
|
||||
, _dice(dice)
|
||||
, _link(_parent->data()->Has<HistoryMessageForwarded>()
|
||||
? nullptr
|
||||
: dice->makeHandler()) {
|
||||
, _link(dice->makeHandler()) {
|
||||
if (const auto document = Lookup(parent, dice->emoji(), 0)) {
|
||||
_start.emplace(parent, document);
|
||||
_start->setDiceIndex(_dice->emoji(), 0);
|
||||
|
|
|
@ -72,9 +72,7 @@ SlotMachine::SlotMachine(
|
|||
not_null<Data::MediaDice*> dice)
|
||||
: _parent(parent)
|
||||
, _dice(dice)
|
||||
, _link(_parent->data()->Has<HistoryMessageForwarded>()
|
||||
? nullptr
|
||||
: dice->makeHandler()) {
|
||||
, _link(dice->makeHandler()) {
|
||||
resolveStarts();
|
||||
_showLastFrame = _parent->data()->Has<HistoryMessageForwarded>();
|
||||
if (_showLastFrame) {
|
||||
|
|
|
@ -680,7 +680,7 @@ bool FileLoadTask::FillImageInformation(
|
|||
return true;
|
||||
}
|
||||
|
||||
void FileLoadTask::process() {
|
||||
void FileLoadTask::process(Args &&args) {
|
||||
_result = std::make_shared<FileLoadResult>(
|
||||
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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue