Add color replacements to messageAnimatedEmoji.

This commit is contained in:
levlam 2021-10-05 18:42:05 +03:00
parent aae781295c
commit 9fb1f1438e
3 changed files with 38 additions and 4 deletions

View File

@ -234,6 +234,10 @@ maskPointChin = MaskPoint;
maskPosition point:MaskPoint x_shift:double y_shift:double scale:double = MaskPosition;
//@description Describes a color replacement for animated emoji @old_color Original animated emoji color in the RGB24 format @new_color Replacement animated emoji color in the RGB24 format
colorReplacement old_color:int32 new_color:int32 = ColorReplacement;
//@description Represents a closed vector path. The path begins at the end point of the last command @commands List of vector path commands
closedVectorPath commands:vector<VectorPathCommand> = ClosedVectorPath;
@ -1707,8 +1711,8 @@ messageVenue venue:venue = MessageContent;
//@description A message with a user contact @contact The contact description
messageContact contact:contact = MessageContent;
//@description A message with an animated emoji @sticker The animated sticker with the emoji animation @emoji The corresponding emoji
messageAnimatedEmoji sticker:sticker emoji:string = MessageContent;
//@description A message with an animated emoji @sticker The animated sticker with the emoji animation @color_replacements The list of colors to be replaced while the sticker is rendered @emoji The corresponding emoji
messageAnimatedEmoji sticker:sticker color_replacements:vector<colorReplacement> emoji:string = MessageContent;
//@description A dice message. The dice value is randomly generated by the server
//@initial_state The animated stickers with the initial dice animation; may be null if unknown. updateMessageContent will be sent when the sticker became known

View File

@ -1963,13 +1963,41 @@ std::pair<FileId, int> StickersManager::get_animated_emoji_sticker(const string
return get_animated_emoji_sticker(get_animated_emoji_sticker_set(), emoji);
}
vector<td_api::object_ptr<td_api::colorReplacement>> StickersManager::get_color_replacements_object(
int fitzpatrick_modifier) {
vector<td_api::object_ptr<td_api::colorReplacement>> result;
switch (fitzpatrick_modifier) {
case 0:
break;
case 2:
case 3:
case 4:
case 5:
case 6: {
static int32 old_colors[] = {0xf77e41, 0xffb139, 0xffd140, 0xffdf79};
static int32 new_colors[] = {0xcb7b55, 0xf6b689, 0xffcda7, 0xffdfc5, 0xa45a38, 0xdf986b, 0xedb183,
0xf4c3a0, 0x703a17, 0xab673d, 0xc37f4e, 0xd89667, 0x4a2409, 0x7d3e0e,
0x965529, 0xa96337, 0x200f0a, 0x412924, 0x593d37, 0x63453f};
for (size_t i = 0; i < 4; i++) {
result.push_back(td_api::make_object<td_api::colorReplacement>(old_colors[i],
new_colors[(fitzpatrick_modifier - 2) * 4 + i]));
}
break;
}
default:
UNREACHABLE();
}
return result;
}
td_api::object_ptr<td_api::MessageContent> StickersManager::get_message_content_animated_emoji_object(
const string &emoji) {
auto it = emoji_messages_.find(emoji);
auto animated_sticker =
it != emoji_messages_.end() ? it->second.animated_emoji_sticker : get_animated_emoji_sticker(emoji);
if (animated_sticker.first.is_valid()) {
return td_api::make_object<td_api::messageAnimatedEmoji>(get_sticker_object(animated_sticker.first), emoji);
return td_api::make_object<td_api::messageAnimatedEmoji>(
get_sticker_object(animated_sticker.first), get_color_replacements_object(animated_sticker.second), emoji);
}
return td_api::make_object<td_api::messageText>(
td_api::make_object<td_api::formattedText>(emoji, std::vector<td_api::object_ptr<td_api::textEntity>>()),

View File

@ -603,7 +603,7 @@ class StickersManager final : public Actor {
bool update_sticker_set_cache(const StickerSet *sticker_set, Promise<Unit> &promise);
static int get_emoji_number(Slice emoji);
static vector<td_api::object_ptr<td_api::colorReplacement>> get_color_replacements_object(int fitzpatrick_modifier);
const StickerSet *get_animated_emoji_sticker_set();
@ -613,6 +613,8 @@ class StickersManager final : public Actor {
void try_update_animated_emoji_messages();
static int get_emoji_number(Slice emoji);
vector<FileId> get_animated_emoji_click_stickers(const StickerSet *sticker_set, Slice emoji) const;
void choose_animated_emoji_click_sticker(const StickerSet *sticker_set, Slice message_text,