private static SlotChangeManager GetSenderInfo(ref object sender, out SlotChange loc, int slot)
        {
            loc = new SlotChange();
            var ctrl = WinFormsUtil.GetUnderlyingControl(sender);
            var obj  = ctrl.Parent.Parent;

            if (obj is BoxEditor b)
            {
                loc.Box    = b.CurrentBox;
                loc.Slot   = slot;
                loc.Offset = b.GetOffset(loc.Slot, loc.Box);
                loc.Parent = b.FindForm();
                sender     = ctrl;
                return(b.M);
            }
            obj = obj.Parent.Parent;
            if (obj is SAVEditor z)
            {
                loc.Box    = z.Box.CurrentBox;
                loc.Slot   = slot;
                loc.Offset = z.GetPKMOffset(loc.Slot, loc.Box);
                loc.Parent = z.FindForm();
                sender     = ctrl;
                return(z.M);
            }
            return(null);
        }
                    public void Accept(IVisitor4 visitor)
                    {
                        SlotChange slotChange = new SlotChange(id);

                        slotChange.NotifySlotCreated(new Slot(address, length));
                        visitor.Visit(slotChange);
                    }
                public void Visit(object idSlotMapping)
                {
                    SlotChange slotChange = new SlotChange(((TreeInt)idSlotMapping)._key);

                    slotChange.NotifySlotCreated(((IdSlotTree)idSlotMapping).Slot());
                    outSideVisitor.Visit(slotChange);
                }
Beispiel #4
0
                public void Visit(object idSlotMapping)
                {
                    var slotChange = new SlotChange(((IdSlotMapping)idSlotMapping)._id);

                    slotChange.NotifySlotCreated(((IdSlotMapping)idSlotMapping).Slot());
                    outSideVisitor.Visit(slotChange);
                }
Beispiel #5
0
 public SlotChange(SlotChange info, SaveFile sav)
 {
     Box    = info.Box;
     Slot   = info.Slot;
     Offset = info.Offset;
     PKM    = sav.GetStoredSlot(info.Offset);
 }
Beispiel #6
0
 public void Accept(IVisitor4 visitor)
 {
     for (int slotChangeIndex = 0; slotChangeIndex < slotChanges.Length; ++slotChangeIndex)
     {
         SlotChange slotChange = slotChanges[slotChangeIndex];
         visitor.Visit(slotChange);
     }
 }
Beispiel #7
0
 public void Reset()
 {
     LeftMouseIsDown = RightMouseIsDown = DragDropInProgress = false;
     Source          = new SlotChange {
         OriginalData = BlankData
     };
     Destination = new SlotChange();
     Cursor      = CurrentPath = null;
 }
Beispiel #8
0
            private Slot AllocateNewSlot(int newId)
            {
                SlotChange slotChange    = SlotChangeFactory.UserObjects.NewInstance(newId);
                Slot       allocatedSlot = LocalContainer().AllocateSlot(SlotLength);

                slotChange.NotifySlotCreated(allocatedSlot);
                Commit(new SlotChange[] { slotChange });
                return(allocatedSlot);
            }
        private static SlotChangeManager GetSenderInfo(ref object sender, out SlotChange loc)
        {
            sender = WinFormsUtil.GetUnderlyingControl(sender);
            var pb   = (PictureBox)sender;
            var view = WinFormsUtil.FindFirstControlOfType <ISlotViewer <PictureBox> >(pb);

            loc = view.GetSlotData(pb);
            return(view.M);
        }
        public virtual bool IsDeleted(int id)
        {
            SlotChange slot = FindSlotChange(id);

            if (slot == null)
            {
                return(false);
            }
            return(slot.IsDeleted());
        }
Beispiel #11
0
            public virtual void TestSingleSlotDelete()
            {
                int id = IdSystem().NewId();

                AllocateNewSlot(id);
                SlotChange slotChange = SlotChangeFactory.UserObjects.NewInstance(id);

                slotChange.NotifyDeleted(FreespaceManager());
                Commit(new SlotChange[] { slotChange });
                Assert.IsFalse(IsValid(IdSystem().CommittedSlot(id)));
            }
Beispiel #12
0
            public virtual void TestSingleSlotUpdate()
            {
                int id = IdSystem().NewId();

                AllocateNewSlot(id);
                SlotChange slotChange  = SlotChangeFactory.UserObjects.NewInstance(id);
                Slot       updatedSlot = LocalContainer().AllocateSlot(SlotLength);

                slotChange.NotifySlotUpdated(FreespaceManager(), updatedSlot);
                Commit(new SlotChange[] { slotChange });
                Assert.AreEqual(updatedSlot, IdSystem().CommittedSlot(id));
            }
        public virtual SlotChange ProduceSlotChange(int id, SlotChangeFactory slotChangeFactory
                                                    )
        {
            if (DTrace.enabled)
            {
                DTrace.ProduceSlotChange.Log(id);
            }
            SlotChange slot = slotChangeFactory.NewInstance(id);

            _slotChanges.Add(slot);
            return((SlotChange)slot.AddedOrExisting());
        }
Beispiel #14
0
 public override void Write()
 {
     WriteH(3877);
     WriteC((byte)type);
     WriteC((byte)leaderSlot);
     WriteC((byte)slots.Count);
     for (int i = 0; i < slots.Count; i++)
     {
         SlotChange slot = slots[i];
         WriteC((byte)slot.oldSlot.Id);
         WriteC((byte)slot.newSlot.Id);
         WriteC((byte)slot.oldSlot.state);
         WriteC((byte)slot.newSlot.state);
     }
 }
Beispiel #15
0
        public virtual Slot ModifiedSlot(int id)
        {
            if (id == 0)
            {
                return(null);
            }
            SlotChange change = _slotChanges.FindSlotChange(id);

            if (change != null)
            {
                if (change.SlotModified())
                {
                    return(change.NewSlot());
                }
            }
            return(ModifiedSlotInParentIdSystem(id));
        }
Beispiel #16
0
        protected static bool UpdateRosterPosition(Trooper edit, ref Trooper primary, ref Trooper submitter,
                                                   [NotNullWhen(true)] out SlotChange?update)
        {
            if (primary.Slot != edit.Slot ||
                primary.Role != edit.Role ||
                primary.Team != edit.Team ||
                primary.Flight != edit.Flight)
            {
                update = new SlotChange()
                {
                    NewSlot   = edit.Slot,
                    NewRole   = edit.Role,
                    NewTeam   = edit.Team,
                    NewFlight = edit.Flight,

                    OldSlot   = primary.Slot,
                    OldRole   = primary.Role,
                    OldTeam   = primary.Team,
                    OldFlight = primary.Flight,

                    ChangedOn = DateTime.UtcNow,
                    SubmittedByRosterClerk = true
                };

                primary.Slot   = edit.Slot;
                primary.Role   = edit.Role;
                primary.Team   = edit.Team;
                primary.Flight = edit.Flight;

                primary.SlotChanges.Add(update);
                submitter.ApprovedSlotChanges.Add(update);

                return(true);
            }

            update = null;
            return(false);
        }
Beispiel #17
0
 private void SetSlotSprite(SlotChange loc, PKM pk, BoxEditor x = null) => (x ?? SE.Box).SetSlotFiller(pk, loc.Box, loc.Slot);