/// <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; }
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); } }
/// <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; }
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); } }
/// <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) });
/// <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) });
/// <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); }
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); } }
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); }
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); } }
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); }
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); }
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); }
private void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pkm) => Publisher.NotifySlotChanged(slot, type, pkm);
public static bool IsContentChange(this SlotTouchType t) => t > SlotTouchType.Get;
/// <summary> /// Gets the background image for a slot based on the provided <see cref="type"/>. /// </summary> public static Image GetTouchTypeBackground(SlotTouchType type) => type switch {