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