예제 #1
0
        public override void Undo()
        {
            PasswordDatum data = GetData();

            data.MapX = oldX;
            data.MapY = oldY;
            data.Item = oldValue;
        }
예제 #2
0
        public override void Do()
        {
            PasswordDatum data = GetData();

            data.MapX = newX;
            data.MapY = newY;
            data.Item = newValue;
        }
예제 #3
0
 private void lstEntries_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!updatingItem)
     {
         PasswordDatum d = (PasswordDatum)lstEntries.SelectedItem;
         lblCurrentItem.SetBounds(d.MapX * 8, d.MapY * 8, 8, 8);
         lstSubtypes.SelectedIndex = d.Item;
     }
 }
예제 #4
0
        private void lstSubtypes_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!updatingItem)
            {
                PasswordDatum d = ((PasswordDatum)lstEntries.SelectedItem);
                d.Item = lstSubtypes.SelectedIndex;

                UpdateSelectedItem();
            }
        }
예제 #5
0
        public PasswordDataAction(EditroidUndoRedoQueue q, int dataIndex)
            : base(q)
        {
            this.dataIndex = dataIndex;
            PasswordDatum data = GetData();

            oldX     = newX = data.MapX;
            oldY     = newY = data.MapY;
            oldValue = newValue = data.Item;
        }
예제 #6
0
        private void WriteNodes(TreeNode node, ref int index, byte[] data)
        {
            foreach (TreeNode n in node.Nodes)
            {
                PasswordDatum writer = new PasswordDatum(data, index * 2);
                index++;

                datTag tag = (datTag)n.Tag;
                writer.MapX = tag.p.X;
                writer.MapY = tag.p.Y;
                writer.Item = tag.type;
            }
        }
예제 #7
0
        private void lblCurrentItem_MouseMove(object sender, MouseEventArgs e)
        {
            if (isDraggingItem)
            {
                int destX = lblCurrentItem.Left / 8 +
                            (e.X / 8 - dragStartX);
                int destY = lblCurrentItem.Top / 8 +
                            (e.Y / 8 - dragStartY);

                // Account for rounding up instead of down with negatives
                if (e.X < 0)
                {
                    destX--;
                }
                if (e.Y < 0)
                {
                    destY--;
                }

                // Constrain to game map
                if (destX < 0)
                {
                    destX = 0;
                }
                if (destX > 31)
                {
                    destX = 31;
                }
                if (destY < 0)
                {
                    destY = 0;
                }
                if (destY > 31)
                {
                    destY = 31;
                }

                PasswordDatum d = currentDat;
                if (destX != d.MapX || destY != d.MapY)
                {
                    UndrawDat(d);
                    d.MapX = destX;
                    d.MapY = destY;
                    DrawDat(d);

                    lblCurrentItem.SetBounds(d.MapX * 8, d.MapY * 8, 8, 8);
                    pnlMap.Invalidate();
                    UpdateSelectedItem();
                }
            }
        }
예제 #8
0
        private void pnlMap_MouseDown(object sender, MouseEventArgs e)
        {
            int           i     = 0;
            bool          found = false;
            PasswordDatum d     = rom.PasswordData.GetDatum(0);

            while (i < PasswordData.DataCount & !found)
            {
                d = rom.PasswordData.GetDatum(i);
                if (d.MapX == e.X / 8 && d.MapY == e.Y / 8)
                {
                    lstEntries.SelectedIndex = i;
                }

                i++;
            }
        }
예제 #9
0
        private void DrawMap()
        {
            if (map == null || rom == null)
            {
                return;
            }

            gMapImage.DrawImage(bgImage, new Rectangle(0, 0, 256, 256), new Rectangle(0, 0, 256, 256), GraphicsUnit.Pixel);

            for (int i = 0; i < PasswordData.DataCount; i++)
            {
                PasswordDatum d = rom.PasswordData.GetDatum(i);
                gMapImage.DrawRectangle(Pens.Yellow, d.MapX * 8, d.MapY * 8, 7, 7);

                lstEntries.Items.Add(d);
            }

            lstEntries.SelectedIndex = 0;
        }
예제 #10
0
        private void UndrawDat(PasswordDatum d)
        {
            Rectangle rect = new Rectangle(d.MapX * 8, d.MapY * 8, 8, 8);

            bool erase = true; // We may not want to erase the rectangle...

            for (int i = 0; i < PasswordData.DataCount; i++)
            {
                PasswordDatum pd = rom.PasswordData.GetDatum(i);
                // ... if there is a different entry with the same map coords
                if (pd.offset != d.offset && pd.MapX == d.MapX && pd.MapY == d.MapY)
                {
                    erase = false;
                }
            }

            if (erase)
            {
                gMapImage.DrawImage(bgImage, rect, rect, GraphicsUnit.Pixel);
            }
        }
예제 #11
0
        /// <summary>
        /// Finds the password data entry that corresponds to the selected gameItem, if there is one.
        /// </summary>
        private void GetPasswordEntry()
        {
            if (currentRoom.ItemType != ItemType.PowerUp)
            {
                return;                                       // Only applies to power-ups
            }
            for (int i = 0; i < PasswordData.DataCount; i++)  // Loop through password entries
            {
                PasswordDatum d = rom.PasswordData.GetDatum(i);
                if (d.MapX == GetMapPosition().X&&      // If coordinates are the same
                    d.MapY == GetMapPosition().Y&&
                    d.Item == (int)currentRoom.PowerUp) // And it is the same item

                {
                    passwordDataEntry = d; // we have our entry.
                    return;
                }
            }

            passwordDataEntry = new PasswordDatum(); // No entry has been found
        }
예제 #12
0
 // Todo: a better solution would be to UndrawDat/DrawDat every
 // time a different object is selected instead of every time
 // the selection is moved.
 private void DrawDat(PasswordDatum d)
 {
     gMapImage.DrawRectangle(Pens.Yellow, d.MapX * 8, d.MapY * 8, 7, 7);
 }