Update dice

This commit is contained in:
Ilya Laktyushin
2020-04-17 14:23:40 +04:00
parent f684f8637f
commit 05712b4bc6
5 changed files with 1852 additions and 1835 deletions

View File

@@ -5475,6 +5475,7 @@ Any member of this group will be able to see messages in the channel.";
"MuteFor.Forever" = "Mute Forever";
"Conversation.Dice" = "Send a 🎲 emoji to any chat to get a random number from Telegram.";
"Conversation.Darts" = "Send a single dart 🎯 emoji to try your luck.";
"ForwardedDices_1" = "Forwarded dice";
"ForwardedDices_2" = "2 forwarded dices";

View File

@@ -1008,9 +1008,20 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
return .optionalAction({
let _ = item.controllerInteraction.openMessage(item.message, .default)
})
} else if let _ = self.telegramDice {
} else if let dice = self.telegramDice {
return .optionalAction({
item.controllerInteraction.displayMessageTooltip(item.content.firstMessage.id, item.presentationData.strings.Conversation_Dice, self, self.imageNode.frame.offsetBy(dx: 0.0, dy: self.imageNode.frame.height / 3.0))
var text: String?
switch dice.emoji {
case "🎲":
text = item.presentationData.strings.Conversation_Dice
case "🎯":
text = item.presentationData.strings.Conversation_Darts
default:
break
}
if let text = text {
item.controllerInteraction.displayMessageTooltip(item.content.firstMessage.id, text, self, self.imageNode.frame.offsetBy(dx: 0.0, dy: self.imageNode.frame.height / 3.0))
}
})
} else if let _ = self.emojiFile {
if let animationNode = self.animationNode as? AnimatedStickerNode {

View File

@@ -146,8 +146,6 @@ final class ManagedDiceAnimationNode: ManagedAnimationNode, GenericAnimatedStick
return .single(ManagedAnimationItem(source: .resource(context.account.postbox.mediaBox, file.resource), frames: ManagedAnimationFrameRange(startFrame: 0, endFrame: frameCount), duration: duration))
}
} else {
self.setState(.rolling)
let dimensions = file.dimensions ?? PixelDimensions(width: 512, height: 512)
let fittedSize = dimensions.cgSize.aspectFilled(CGSize(width: 384.0, height: 384.0))
@@ -159,6 +157,7 @@ final class ManagedDiceAnimationNode: ManagedAnimationNode, GenericAnimatedStick
return data.complete
}).start(next: { next in
subscriber.putNext(ManagedAnimationItem(source: .resource(context.account.postbox.mediaBox, file.resource), frames: ManagedAnimationFrameRange(startFrame: 0, endFrame: frameCount), duration: duration))
subscriber.putCompletion()
})
return ActionDisposable {
@@ -166,7 +165,12 @@ final class ManagedDiceAnimationNode: ManagedAnimationNode, GenericAnimatedStick
resourceDisposable.dispose()
}
}
return animationItem
if let item = rollingAnimationItem(emoji: self.dice.emoji) {
return .single(item) |> then(animationItem)
} else {
return animationItem
}
}
}