mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-06 17:00:13 +00:00
Slot animation fixes
This commit is contained in:
parent
7ea3a76fa2
commit
4bedb23cca
@ -154,9 +154,12 @@ public final class SlotMachineAnimationNode: ASDisplayNode {
|
||||
private var diceState: ManagedSlotMachineAnimationState? = nil
|
||||
private let disposables = DisposableSet()
|
||||
|
||||
private let animationSize = CGSize(width: 184.0, height: 184.0)
|
||||
private let animationSize: CGSize
|
||||
|
||||
public override init() {
|
||||
public var success: ((Bool) -> Void)?
|
||||
|
||||
public init(size: CGSize = CGSize(width: 184.0, height: 184.0)) {
|
||||
self.animationSize = size
|
||||
self.backNode = ManagedAnimationNode(size: self.animationSize)
|
||||
self.leftReelNode = ManagedAnimationNode(size: self.animationSize)
|
||||
self.centerReelNode = ManagedAnimationNode(size: self.animationSize)
|
||||
@ -197,8 +200,9 @@ public final class SlotMachineAnimationNode: ASDisplayNode {
|
||||
case let .value(value, _):
|
||||
let slotValue = SlotMachineValue(rawValue: value)
|
||||
if slotValue.isThreeOfSame {
|
||||
Queue.mainQueue().after(1.5) {
|
||||
Queue.mainQueue().after(1.2) {
|
||||
self.backNode.trackTo(item: ManagedAnimationItem(source: .local("Slot_Back_Win"), loop: false))
|
||||
self.success?(!slotValue.is777)
|
||||
}
|
||||
} else {
|
||||
self.backNode.trackTo(item: ManagedAnimationItem(source: .local("Slot_Back_Win"), frames: .still(.start), loop: false))
|
||||
|
||||
@ -2159,7 +2159,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
self?.displayPsa(type: type, sourceNode: sourceNode, isAutomatic: false)
|
||||
}, displayDiceTooltip: { [weak self] dice in
|
||||
self?.displayDiceTooltip(dice: dice)
|
||||
}, animateDiceSuccess: { [weak self] in
|
||||
}, animateDiceSuccess: { [weak self] onlyHaptic in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
@ -2167,7 +2167,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
strongSelf.selectPollOptionFeedback = HapticFeedback()
|
||||
}
|
||||
strongSelf.selectPollOptionFeedback?.success()
|
||||
strongSelf.chatDisplayNode.animateQuizCorrectOptionSelected()
|
||||
if !onlyHaptic {
|
||||
strongSelf.chatDisplayNode.animateQuizCorrectOptionSelected()
|
||||
}
|
||||
}, greetingStickerNode: { [weak self] in
|
||||
return self?.chatDisplayNode.greetingStickerNode
|
||||
}, openPeerContextMenu: { [weak self] peer, node, rect, gesture in
|
||||
|
||||
@ -110,7 +110,7 @@ public final class ChatControllerInteraction {
|
||||
let displayPollSolution: (TelegramMediaPollResults.Solution, ASDisplayNode) -> Void
|
||||
let displayPsa: (String, ASDisplayNode) -> Void
|
||||
let displayDiceTooltip: (TelegramMediaDice) -> Void
|
||||
let animateDiceSuccess: () -> Void
|
||||
let animateDiceSuccess: (Bool) -> Void
|
||||
let greetingStickerNode: () -> (ASDisplayNode, ASDisplayNode, ASDisplayNode, () -> Void)?
|
||||
let openPeerContextMenu: (Peer, ASDisplayNode, CGRect, ContextGesture?) -> Void
|
||||
let openMessageReplies: (MessageId, Bool, Bool) -> Void
|
||||
@ -197,7 +197,7 @@ public final class ChatControllerInteraction {
|
||||
displayPollSolution: @escaping (TelegramMediaPollResults.Solution, ASDisplayNode) -> Void,
|
||||
displayPsa: @escaping (String, ASDisplayNode) -> Void,
|
||||
displayDiceTooltip: @escaping (TelegramMediaDice) -> Void,
|
||||
animateDiceSuccess: @escaping () -> Void,
|
||||
animateDiceSuccess: @escaping (Bool) -> Void,
|
||||
greetingStickerNode: @escaping () -> (ASDisplayNode, ASDisplayNode, ASDisplayNode, () -> Void)?,
|
||||
openPeerContextMenu: @escaping (Peer, ASDisplayNode, CGRect, ContextGesture?) -> Void,
|
||||
openMessageReplies: @escaping (MessageId, Bool, Bool) -> Void,
|
||||
@ -321,7 +321,7 @@ public final class ChatControllerInteraction {
|
||||
}, displayPollSolution: { _, _ in
|
||||
}, displayPsa: { _, _ in
|
||||
}, displayDiceTooltip: { _ in
|
||||
}, animateDiceSuccess: {
|
||||
}, animateDiceSuccess: { _ in
|
||||
}, greetingStickerNode: {
|
||||
return nil
|
||||
}, openPeerContextMenu: { _, _, _, _ in
|
||||
|
||||
@ -584,15 +584,14 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
|
||||
self.addSubnode(self.backgroundNode)
|
||||
self.addSubnode(self.historyNodeContainer)
|
||||
self.addSubnode(self.navigateButtons)
|
||||
self.addSubnode(self.titleAccessoryPanelContainer)
|
||||
|
||||
self.addSubnode(self.inputPanelBackgroundNode)
|
||||
self.addSubnode(self.inputPanelBackgroundSeparatorNode)
|
||||
|
||||
self.addSubnode(self.inputContextPanelContainer)
|
||||
|
||||
self.addSubnode(self.navigateButtons)
|
||||
|
||||
|
||||
self.addSubnode(self.navigationBarBackroundNode)
|
||||
self.addSubnode(self.navigationBarSeparatorNode)
|
||||
if !self.context.sharedContext.immediateExperimentalUISettings.playerEmbedding {
|
||||
|
||||
@ -334,13 +334,20 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
||||
if let telegramDice = self.telegramDice {
|
||||
if telegramDice.emoji == "🎰" {
|
||||
let animationNode = SlotMachineAnimationNode()
|
||||
if !item.message.effectivelyIncoming(item.context.account.peerId) {
|
||||
animationNode.success = { [weak self] onlyHaptic in
|
||||
if let strongSelf = self, let item = strongSelf.item {
|
||||
item.controllerInteraction.animateDiceSuccess(onlyHaptic)
|
||||
}
|
||||
}
|
||||
}
|
||||
self.animationNode = animationNode
|
||||
} else {
|
||||
let animationNode = ManagedDiceAnimationNode(context: item.context, emoji: telegramDice.emoji.strippedEmoji)
|
||||
if !item.message.effectivelyIncoming(item.context.account.peerId) {
|
||||
animationNode.success = { [weak self] in
|
||||
if let strongSelf = self, let item = strongSelf.item {
|
||||
item.controllerInteraction.animateDiceSuccess()
|
||||
item.controllerInteraction.animateDiceSuccess(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -448,7 +448,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
||||
}, displayPollSolution: { _, _ in
|
||||
}, displayPsa: { _, _ in
|
||||
}, displayDiceTooltip: { _ in
|
||||
}, animateDiceSuccess: {
|
||||
}, animateDiceSuccess: { _ in
|
||||
}, greetingStickerNode: {
|
||||
return nil
|
||||
}, openPeerContextMenu: { _, _, _, _ in
|
||||
|
||||
@ -141,7 +141,7 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
|
||||
}, displayPollSolution: { _, _ in
|
||||
}, displayPsa: { _, _ in
|
||||
}, displayDiceTooltip: { _ in
|
||||
}, animateDiceSuccess: {
|
||||
}, animateDiceSuccess: { _ in
|
||||
}, greetingStickerNode: {
|
||||
return nil
|
||||
}, openPeerContextMenu: { _, _, _, _ in
|
||||
|
||||
@ -131,7 +131,7 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, UIGestu
|
||||
}, displayPollSolution: { _, _ in
|
||||
}, displayPsa: { _, _ in
|
||||
}, displayDiceTooltip: { _ in
|
||||
}, animateDiceSuccess: {
|
||||
}, animateDiceSuccess: { _ in
|
||||
}, greetingStickerNode: {
|
||||
return nil
|
||||
}, openPeerContextMenu: { _, _, _, _ in
|
||||
|
||||
@ -1959,7 +1959,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
}, displayPollSolution: { _, _ in
|
||||
}, displayPsa: { _, _ in
|
||||
}, displayDiceTooltip: { _ in
|
||||
}, animateDiceSuccess: {
|
||||
}, animateDiceSuccess: { _ in
|
||||
}, greetingStickerNode: {
|
||||
return nil
|
||||
}, openPeerContextMenu: { _, _, _, _ in
|
||||
|
||||
@ -1231,7 +1231,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
||||
}, displayPollSolution: { _, _ in
|
||||
}, displayPsa: { _, _ in
|
||||
}, displayDiceTooltip: { _ in
|
||||
}, animateDiceSuccess: {
|
||||
}, animateDiceSuccess: { _ in
|
||||
}, greetingStickerNode: {
|
||||
return nil
|
||||
}, openPeerContextMenu: { _, _, _, _ in
|
||||
|
||||
@ -359,11 +359,13 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
}
|
||||
|
||||
if dice.emoji == "🎰" {
|
||||
let slotMachineNode = SlotMachineAnimationNode()
|
||||
let slotMachineNode = SlotMachineAnimationNode(size: CGSize(width: 42.0, height: 42.0))
|
||||
self.slotMachineNode = slotMachineNode
|
||||
|
||||
// slotMachineNode.setState(.rolling)
|
||||
// slotMachineNode.setState(.value(value, true))
|
||||
slotMachineNode.setState(.rolling)
|
||||
if let value = dice.value {
|
||||
slotMachineNode.setState(.value(value, true))
|
||||
}
|
||||
} else {
|
||||
let animatedStickerNode = AnimatedStickerNode()
|
||||
self.animatedStickerNode = animatedStickerNode
|
||||
@ -615,6 +617,8 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
if let animatedStickerNode = self.animatedStickerNode {
|
||||
animatedStickerNode.updateLayout(size: iconFrame.size)
|
||||
transition.updateFrame(node: animatedStickerNode, frame: iconFrame)
|
||||
} else if let slotMachineNode = self.slotMachineNode {
|
||||
transition.updateFrame(node: slotMachineNode, frame: iconFrame)
|
||||
}
|
||||
} else if let animatedStickerNode = self.animatedStickerNode {
|
||||
let iconSize = CGSize(width: 32.0, height: 32.0)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user