protected override void Close()
        {
            if (CurrentWaitableSpriteKey?.IsCompleted() == false)
            {
                CurrentWaitableSpriteKey.SetError(new Exception("Canceled"));
            }

            base.Close();
        }
        protected virtual void ApplyEncounterImage()
        {
            if (CurrentKey != null && SpriteCollection.ContainsKey(CurrentKey))
            {
                SpriteCollection.Remove(CurrentKey);
            }

            CurrentWaitableSpriteKey.SetResult(EncounterImageKey);
        }
        protected override void Remove()
        {
            if (CurrentKey != null && SpriteCollection.ContainsKey(CurrentKey))
            {
                SpriteCollection.Remove(CurrentKey);
            }

            CurrentWaitableSpriteKey.SetResult(null);

            base.Remove();
        }
        public virtual WaitableTask <string> SelectSprite(Encounter encounter, string spriteKey)
        {
            if (CurrentWaitableSpriteKey?.IsCompleted() == false)
            {
                CurrentWaitableSpriteKey.SetError(new Exception("New popup opened"));
            }

            gameObject.SetActive(true);
            Encounter = encounter;
            var isEncounterImage = KeyIsEncounterImage(spriteKey);

            CurrentKey = !isEncounterImage ? spriteKey : null;
            CurrentWaitableSpriteKey = new WaitableTask <string>();
            useEncounterImageToggle.SetIsOnWithoutNotify(isEncounterImage);

            SetImage();

            return(CurrentWaitableSpriteKey);
        }
        protected virtual void ApplyContentImage()
        {
            if (CurrentImage != null)
            {
                if (CurrentKey != null && SpriteCollection.ContainsKey(CurrentKey))
                {
                    SpriteCollection[CurrentKey] = CurrentImage;
                }
                else if (CurrentKey != null)
                {
                    SpriteCollection.Add(CurrentKey, CurrentImage);
                }
                else
                {
                    CurrentKey = SpriteCollection.Add(CurrentImage);
                }
            }

            CurrentWaitableSpriteKey.SetResult(CurrentKey);
        }
        protected override void ApplyClicked()
        {
            if (CurrentImage != null)
            {
                if (CurrentKey != null && SpriteCollection.ContainsKey(CurrentKey))
                {
                    SpriteCollection[CurrentKey] = CurrentImage;
                }
                else if (CurrentKey != null)
                {
                    SpriteCollection.Add(CurrentKey, CurrentImage);
                }
                else
                {
                    CurrentKey = SpriteCollection.Add(CurrentImage);
                }
            }

            CurrentWaitableSpriteKey.SetResult(CurrentKey);

            base.ApplyClicked();
        }
        public virtual WaitableTask <string> SelectSprite(KeyedCollection <Sprite> sprites, string spriteKey)
        {
            if (CurrentWaitableSpriteKey?.IsCompleted() == false)
            {
                CurrentWaitableSpriteKey.SetError(new Exception("New popup opened"));
            }

            gameObject.SetActive(true);
            SpriteCollection         = sprites;
            CurrentKey               = spriteKey;
            CurrentWaitableSpriteKey = new WaitableTask <string>();

            if (spriteKey != null && SpriteCollection.ContainsKey(spriteKey))
            {
                SetImage(SpriteCollection[spriteKey]);
            }
            else
            {
                SetImage(null);
            }

            return(CurrentWaitableSpriteKey);
        }