Example #1
0
 /// <summary>
 /// Notifies all <see cref="Subscribers"/> with the latest slot change details.
 /// </summary>
 /// <param name="slot">Last interacted slot</param>
 /// <param name="type">Last interacted slot interaction type</param>
 public void NotifySlotChanged(SlotChange slot, SlotTouchType type)
 {
     foreach (var sub in Subscribers)
     {
         ResetView(sub, slot, type);
     }
     Previous     = slot;
     PreviousType = type;
 }
Example #2
0
        private void WriteSlot(ISlotInfo slot, PKM pkm, SlotTouchType type = SlotTouchType.Set)
        {
            Changelog.AddNewChange(slot);
            var result = slot.WriteTo(SAV, pkm);

            if (result)
            {
                NotifySlotChanged(slot, type, pkm);
            }
        }
Example #3
0
 /// <summary>
 /// Notifies all <see cref="Subscribers"/> with the latest slot change details.
 /// </summary>
 /// <param name="slot">Last interacted slot</param>
 /// <param name="type">Last interacted slot interaction type</param>
 /// <param name="pkm">Last interacted slot interaction data</param>
 public void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pkm)
 {
     foreach (var sub in Subscribers)
     {
         ResetView(sub, slot, type, pkm);
     }
     Previous     = slot;
     PreviousType = type;
     PreviousPKM  = pkm;
 }
Example #4
0
        private void WriteSlot(ISlotInfo slot, PKM pkm, SlotTouchType type = SlotTouchType.Set)
        {
            Changelog.AddNewChange(slot);
            var setDetail = type is SlotTouchType.Swap ? PKMImportSetting.Skip : PKMImportSetting.UseDefault;
            var result    = slot.WriteTo(SAV, pkm, setDetail);

            if (result)
            {
                NotifySlotChanged(slot, type, pkm);
            }
        }
Example #5
0
 /// <summary>
 /// Gets the background image for a slot based on the provided <see cref="type"/>.
 /// </summary>
 public static Image GetTouchTypeBackground(SlotTouchType type)
 {
     return(type switch
     {
         SlotTouchType.None => SpriteUtil.Spriter.Transparent,
         SlotTouchType.Get => SpriteUtil.Spriter.View,
         SlotTouchType.Set => SpriteUtil.Spriter.Set,
         SlotTouchType.Delete => SpriteUtil.Spriter.Delete,
         SlotTouchType.Swap => SpriteUtil.Spriter.Set,
         _ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
     });
Example #6
0
 /// <summary>
 /// Gets the background image for a slot based on the provided <see cref="type"/>.
 /// </summary>
 public static Image GetTouchTypeBackground(SlotTouchType type)
 {
     return(type switch
     {
         SlotTouchType.None => Resources.slotTrans,
         SlotTouchType.Get => Resources.slotView,
         SlotTouchType.Set => Resources.slotSet,
         SlotTouchType.Delete => Resources.slotDel,
         SlotTouchType.Swap => Resources.slotSet,
         _ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
     });
Example #7
0
        /// <summary>
        /// Sets data to a slot.
        /// </summary>
        /// <param name="slot">Slot to be set to.</param>
        /// <param name="pkm">Data to set.</param>
        /// <param name="type">Type of slot action</param>
        /// <returns>Operation succeeded or not via enum value.</returns>
        public SlotTouchResult Set(ISlotInfo slot, PKM pkm, SlotTouchType type = SlotTouchType.Set)
        {
            if (!slot.CanWriteTo(SAV))
            {
                return(SlotTouchResult.FailWrite);
            }

            WriteSlot(slot, pkm, type);
            NotifySlotChanged(slot, type, pkm);

            return(SlotTouchResult.Success);
        }
Example #8
0
        private void ResetView(ISlotViewer <T> sub, ISlotInfo slot, SlotTouchType type, PKM pkm)
        {
            if (PreviousPKM != null)
            {
                sub.NotifySlotOld(Previous);
            }

            if (!(slot is SlotInfoBox b) || sub.ViewIndex == b.Box)
            {
                sub.NotifySlotChanged(slot, type, pkm);
            }
        }
Example #9
0
    public void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pk)
    {
        int index = GetViewIndex(slot);

        if (index < 0)
        {
            return;
        }

        var pb = SlotPictureBoxes[index];

        SlotUtil.UpdateSlot(pb, slot, pk, SAV, FlagIllegal, type);
    }
Example #10
0
        private void ResetView(ISlotViewer sub, SlotChange slot, SlotTouchType type)
        {
            if (Previous != null)
            {
                sub.NotifySlotOld(Previous);
            }

            int index = sub.ViewIndex;

            if (index == slot.Box)
            {
                sub.NotifySlotChanged(slot, type);
            }
        }
Example #11
0
        public void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pkm)
        {
            if (!(slot is SlotInfoMisc m))
            {
                return;
            }
            var index = GetViewIndex(m);

            if (index < 0)
            {
                return;
            }
            var pb = slots[index];

            SlotUtil.UpdateSlot(pb, slot, pkm, SAV, FlagIllegal, type);
        }
Example #12
0
        public void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pkm)
        {
            if (!checkBox2.Checked || !Remote.Bot.Connected)
            {
                return;
            }
            if (slot is not SlotInfoBox b)
            {
                return;
            }
            if (!type.IsContentChange())
            {
                return;
            }
            int box     = b.Box;
            int slotpkm = b.Slot;

            Remote.Bot.SendSlot(RamOffsets.WriteBoxData(Remote.Bot.Version) ? pkm.EncryptedBoxData : pkm.EncryptedPartyData, box, slotpkm);
        }
Example #13
0
        public void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pkm)
        {
            if (!checkBox2.Checked || !Remote.Bot.Connected)
            {
                return;
            }
            if (!(slot is SlotInfoBox b))
            {
                return;
            }
            if (!type.IsContentChange())
            {
                return;
            }
            int box     = b.Box;
            int slotpkm = b.Slot;

            Remote.Bot.SendSlot(pkm.EncryptedPartyData, box, slotpkm);
        }
Example #14
0
 private void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pkm) => Publisher.NotifySlotChanged(slot, type, pkm);
Example #15
0
 public static bool IsContentChange(this SlotTouchType t) => t > SlotTouchType.Get;
Example #16
0
 /// <summary>
 /// Gets the background image for a slot based on the provided <see cref="type"/>.
 /// </summary>
 public static Image GetTouchTypeBackground(SlotTouchType type) => type switch
 {