Exemplo n.º 1
0
 public void InsertAfter(PuzzleItem item, int slot)
 {
     if (DeleteAtEnd)
     {
         if (PuzzleItems.Count >= gridSize)
         {
             if (OverloadDumpSite != null)
             {
                 OverloadDumpSite.InsertBefore(PuzzleItems[gridSize - 1], 0);
             }
             PuzzleItems.Remove(PuzzleItems[gridSize - 1]);
         }
         if (PuzzleItems.Count >= gridSize)
         {
             try
             {
                 PuzzleItems.RemoveAt(gridSize);
                 foreach (PuzzleItem anItem in aListOfSelectedItems)
                 {
                     if (!PuzzleItems.Contains(anItem))
                     {
                         aListOfSelectedItems.Remove(anItem);
                     }
                 }
             }
             catch { /*happens when window is resized (sometimes)*/ }
         }
     }
     PuzzleItems.Insert(slot + 1, item);
     Invalidate();
 }
Exemplo n.º 2
0
        } // end of function ClearThumbnail

        #endregion

        #region filters

        public static void LoadFilters()
        {
            List<PuzzleItem> allPuzzleItems = new List<PuzzleItem>();

            string[] filePaths = Directory.GetFiles(itemDirectory, "*.bee");
            string[] temp;


            foreach (string path in filePaths)
            {
                string[] filecontents = File.ReadAllLines(path);

                string[][] individualItemDefinitions = Global.FindSubValues(filecontents, "Item");
                foreach (string[] definition in individualItemDefinitions)
                {
                    PuzzleItem aPuzzleItem = new PuzzleItem(definition);
                    foreach (string f in aPuzzleItem.Filters)
                    {
                        List<string> filter;
                        Filters.TryGetValue(f, out filter);
                        if (filter == null)
                        {
                            filter = new List<string>();
                            Filters.Add(f, filter);
                        }
                        if (!filter.Contains(aPuzzleItem.TypeName))
                            filter.Add(aPuzzleItem.TypeName);

                    }
                }
            } // next

        }
Exemplo n.º 3
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            PuzzleItem aPuzzleItem = getItemAt(new Point(e.X, e.Y));

            if (aPuzzleItem == null)
            {
                if (UnSelectItems())
                {
                    Invalidate();
                }
            }
            else
            {
                //if (!Control_Press)
                //    UnSelectItems();

                if (aListOfSelectedItems.Contains(aPuzzleItem))
                {
                    //aListOfSelectedItems.Remove(aPuzzleItem);
                    //Invalidate();
                }
                else
                {
                    UnSelectItems();
                    AddToSelected(aPuzzleItem);
                    Invalidate();
                }
            }

            base.OnMouseDown(e);
        }
Exemplo n.º 4
0
        private void panelItemHolderPalette_MouseMove(object sender, MouseEventArgs e)
        {
            PuzzleItem aPuzzleItem = panelItemHolderPalette.GetSelectedItem();

            if (aPuzzleItem != null)
            {
                if (e.Button == MouseButtons.Left)
                {
                    MarkAsSender(panelItemHolderPalette);
                    aPuzzleItem = aPuzzleItem.Clone();
                    DoDragDrop(aPuzzleItem, DragDropEffects.Move);
                }
            }
            int x = e.X, y = e.Y;

            aPuzzleItem = panelItemHolderPalette.getItemAt(new Point(x, y));
            if (aPuzzleItem != null)
            {
                if (aPuzzleItem != oldpitem)
                {
                    //toolTip1.Show(aPuzzleItem.Name_ToolTip, panelItemHolderPalette, new Point(paletteSelectedItemLabel.Left - panelItemHolderPalette.Left, paletteSelectedItemLabel.Top - panelItemHolderPalette.Top + 32), 2000);
                    toolTip1.Show(aPuzzleItem.Name_ToolTip, panelItemHolderPalette, new Point(paletteSelectedItemLabel.Left - panelItemHolderPalette.Left - 9, paletteSelectedItemLabel.Top - panelItemHolderPalette.Top + 32 + 40), 2000);
                    oldpitem = aPuzzleItem;
                }
            }
            else
            {
                toolTip1.RemoveAll();
                oldpitem = null;
            }

            panelItemHolderBucket_Focus();
        }
Exemplo n.º 5
0
        private void panelItemHolderBucket_MouseMove(object sender, MouseEventArgs e)
        {
            //PuzzleItem aPuzzleItem = sender as PuzzleItem;
            PuzzleItem aPuzzleItem = panelItemHolderBucket.GetSelectedItem();

            if (aPuzzleItem != null)
            {
                if (e.Button == MouseButtons.Left)
                {
                    MarkAsSender(panelItemHolderBucket);
                    aPuzzleItem = aPuzzleItem.Clone();
                    DoDragDrop(aPuzzleItem, DragDropEffects.Copy);
                }
            }
            int x = e.X, y = e.Y;

            aPuzzleItem = panelItemHolderBucket.getItemAt(new Point(x, y));
            if (aPuzzleItem != null)
            {
                if (aPuzzleItem != oldpitem)
                {
                    //toolTip1.Show(aPuzzleItem.Name_ToolTip, panelItemHolderBucket, new Point(0, panelItemHolderBucket.Height-4), 2000);
                    toolTip1.Show(aPuzzleItem.Name_ToolTip, panelItemHolderBucket, new Point(0, panelItemHolderBucket.GridLength * 65 + 10), 2000);
                    oldpitem = aPuzzleItem;
                }
            }
            else
            {
                toolTip1.RemoveAll();
                oldpitem = null;
            }
        }
Exemplo n.º 6
0
        public void ShowItem(Point aPoint, PuzzleItem aPuzzleItem)
        {
            Show();
            panelItemHolder_Visual1.PuzzleItems.Clear();
            panelItemHolder_Visual1.RemoveAllFromSelected();



            this.Location = aPoint;
            PuzzleItem aPuzzleItem2 = aPuzzleItem.Clone();

            aPuzzleItem2.SubcatagoryIndex = 0;
            for (int i = 0; i <= aPuzzleItem.SubcatagoryIndexMax; i++)
            {
                panelItemHolder_Visual1.PuzzleItems.Add(aPuzzleItem2.Clone());
                aPuzzleItem2.ToggleSubcatagory();
            }
            panelItemHolder_Visual1.AddToSelected(aPuzzleItem.SubcatagoryIndex);


            panelItemHolder_Visual1.Width = 337 - (4 - aPuzzleItem.SubcatagoryIndexMax) * 64;


            UpdateProperties(aPuzzleItem2);
        }
Exemplo n.º 7
0
        public void ShowItem(Point aPoint, PuzzleItem aPuzzleItem)
        {

            Show();
            panelItemHolder_Visual1.PuzzleItems.Clear();
            panelItemHolder_Visual1.RemoveAllFromSelected();



            this.Location = aPoint;
            PuzzleItem aPuzzleItem2 = aPuzzleItem.Clone();
            aPuzzleItem2.SubcatagoryIndex = 0;
            for (int i = 0; i <= aPuzzleItem.SubcatagoryIndexMax; i++)
            {
                panelItemHolder_Visual1.PuzzleItems.Add(aPuzzleItem2.Clone());
                aPuzzleItem2.ToggleSubcatagory();
            }
            panelItemHolder_Visual1.AddToSelected(aPuzzleItem.SubcatagoryIndex);


            panelItemHolder_Visual1.Width = 337 - (4 - aPuzzleItem.SubcatagoryIndexMax) * 64;


            UpdateProperties(aPuzzleItem2);
        }
Exemplo n.º 8
0
 private void panelItemHolderBucket_MouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right && panelItemHolderBucket.getItemAt(e.Location) == _itemForContextMenu)
     {
         PuzzleItem aPuzzleItem = panelItemHolderBucket.getItemAt(e.Location);
         aCustomContextMenu.ShowItem(MousePosition, aPuzzleItem, panelItemHolderBucket.getOffsetOnPoint(e.Location));
     }
 }
Exemplo n.º 9
0
 private void panelItemHolderRecentlyUsed_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         PuzzleItem aPuzzleItem = panelItemHolderRecentlyUsed.getItemAt(e.Location);
         aCustomContextMenu.ShowItem(MousePosition, aPuzzleItem, panelItemHolderRecentlyUsed.getOffsetOnPoint(e.Location));
     }
 }
Exemplo n.º 10
0
 private void panelItemHolderPalette_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         PuzzleItem aPuzzleItem = panelItemHolderPalette.getItemAt(e.Location);
         Point      aPoint      = panelItemHolderPalette.getOffsetOnPoint(e.Location);
         aCustomContextMenu.ShowItem(MousePosition, aPuzzleItem, new Point(aPoint.X + 6, aPoint.Y + 6), true);
     }
 }
Exemplo n.º 11
0
        //private string name;


        public override bool Equals(object obj)
        {
            if (obj.GetType() != typeof(PuzzleItem))
            {
                return(false);
            }
            PuzzleItem temp = (PuzzleItem)obj;

            return(temp.style == style && TypeName == temp.TypeName && temp.subcatagoryIndex == subcatagoryIndex);
        }
Exemplo n.º 12
0
        public void ShowItem(Point aPoint, PuzzleItem aPuzzleItem, Point Offset, bool ShouldChangeActualItem)
        {
            if (aPuzzleItem != null)
            {
                if (!ShouldChangeActualItem)
                {
                    aPuzzleItem   = aPuzzleItem.Clone();
                    ThePuzzleItem = null;
                }
                else
                {
                    ThePuzzleItem = aPuzzleItem;
                }

                ShowItem(aPoint, aPuzzleItem);
                aPoint   = MousePosition;
                aPoint.X = aPoint.X - Offset.X - (aPuzzleItem.SubcatagoryIndex * 65);
                aPoint.Y = aPoint.Y - Offset.Y;
                if (aPoint.X < 0)
                {
                    aPoint.X = 0;
                }
                if (aPoint.Y < 0)
                {
                    aPoint.Y = 0;
                }

                //check to make sure it will appear on screen
                int screenHeight = Screen.FromControl(this).Bounds.Height;
                int screenWidth  = Screen.FromControl(this).Bounds.Width;
                //MessageBox.Show(this.Location.X + " " + this.Location.Y);
                this.TopMost = false;
                Point aMousePoint = System.Windows.Forms.Cursor.Position;
                if (aPoint.X + Width > screenWidth || aPoint.X + Width < 0)
                {
                    aPoint.X     = screenWidth - Width;
                    this.TopMost = true;
                }
                if (aPoint.Y + Height > screenHeight || aPoint.Y + Height < 0)
                {
                    aPoint.Y     = screenHeight - Height;
                    this.TopMost = true;
                }

                aMousePoint = new Point(aPoint.X + Offset.X + aPuzzleItem.SubcatagoryIndex * 66, aPoint.Y + Offset.Y);
                System.Windows.Forms.Cursor.Position = aMousePoint;
                Location = aPoint;
            }
        }
Exemplo n.º 13
0
        private void panelItemHolderRecentlyUsed_DragDrop(object sender, DragEventArgs e)
        {
            if (!e.Data.GetDataPresent(typeof(PuzzleItem)))
            {
                return;
            }
            if (lastClickedPanel.Equals(panelItemHolderRecentlyUsed))
            {
                panelItemHolderRecentlyUsed.RemoveItem(panelItemHolderRecentlyUsed.GetSelectedItem());
            }
            PuzzleItem aPuzzleItem = (PuzzleItem)e.Data.GetData(typeof(PuzzleItem));

            panelItemHolderRecentlyUsed.InsertBefore(aPuzzleItem, 0);
            panelItemHolderRecentlyUsed.RemoveAllFromSelected();
            panelItemHolderRecentlyUsed.AddToSelected(aPuzzleItem);
        }
Exemplo n.º 14
0
        private void panelItemHolderRecentlyUsed_MouseMove(object sender, MouseEventArgs e)
        {
            PuzzleItem aPuzzleItem = panelItemHolderRecentlyUsed.GetSelectedItem();

            if (aPuzzleItem != null)
            {
                if (e.Button == MouseButtons.Left)
                {
                    MarkAsSender(panelItemHolderRecentlyUsed);
                    aPuzzleItem = aPuzzleItem.Clone();
                    DoDragDrop(aPuzzleItem, DragDropEffects.Copy);
                }
            }

            panelItemHolderBucket_Focus();
        }
Exemplo n.º 15
0
        private void panelItemHolderPalette_DragDrop(object sender, DragEventArgs e)
        {
            //todoFIXED: stop panel crash when something other than a PuzzleItem is dropped here
            if (!e.Data.GetDataPresent(typeof(PuzzleItem)))
            {
                return;
            }

            //todoFIXED: get them to drop into the right spot.... problem is that when something is dropped on the origin for the panel, it isn't the origin in the e variable
            //looks like the origin is 8,30...no idea why, maybe its different for other operating systems, or settings.

            //panelItemHolderPalette.getItemAt(new Point(e.X, e.Y));
            Point aPoint = new Point(e.X - this.Location.X - panelItemHolderPalette.Location.X - 8, e.Y - this.Location.Y - panelItemHolderPalette.Location.Y - 30);
            //if (lastClickedPanel!=null&&lastClickedPanel.Equals(panelItemHolderPalette))

            PuzzleItem aPuzzleItem = (PuzzleItem)e.Data.GetData(typeof(PuzzleItem));
            int        numcheck    = panelItemHolderPalette.GetNumberOfItems();

            if (lastClickedPanel.Equals(panelItemHolderPalette))
            {
                panelItemHolderPalette.RemoveItem(panelItemHolderPalette.GetSelectedItem());

                //special case if the palette is full, this caused the last item to bump off
                //if the panel was full
                //if (numcheck >= 32)
                //{
                //    //but now has less
                //    if (panelItemHolderPalette.GetNumberOfItems() == 31)
                //    {
                //        //then grab the first item from the recently used bucket and toss it back in here
                //        panelItemHolderPalette.InsertAfter(panelItemHolderRecentlyUsed.getItemNumber(0), 30);
                //        panelItemHolderRecentlyUsed.RemoveItemNumber(0);
                //    }
                //}
            }
            panelItemHolderPalette.DropItemOnPoint(aPuzzleItem, aPoint);

            panelItemHolderPalette.RemoveAllFromSelected();
            panelItemHolderPalette.AddToSelected(aPuzzleItem);
            paletteSelectedItemLabel.Text = panelItemHolderPalette.GetSelectedItemName();


            //Graphics gr = panelItemHolderPalette.CreateGraphics();
            //Pen aPen = new Pen(Color.Blue);
            //gr.DrawLine(aPen, new Point(e.X, e.Y), new Point(e.X, e.Y-20));
        }
Exemplo n.º 16
0
        private void UpdateProperties(PuzzleItem aPuzzleItem)
        {
            string NA = "N/A";

            if (aPuzzleItem != null && panelItemHolder_Visual1.GetSelectedItem() != null)
            {
                label5.Text = aPuzzleItem.TypeName;
                label6.Text = aPuzzleItem.Name_ToolTip;
                label7.Text = aPuzzleItem.Author;
                itemDescriptionTextBox.Text = aPuzzleItem.Description;
                if (CurrentStyle != null)
                {
                    label11.Text = CurrentStyle.Name;
                    label12.Text = CurrentStyle.Author;
                    styleDescriptionTextBox.Text = CurrentStyle.Comment;
                }
                else
                {
                    label11.Text = NA;
                    label12.Text = NA;
                    styleDescriptionTextBox.Text = NA;
                }
                //label11.Text =
            }
            else
            {
                label5.Text = NA;
                label6.Text = NA;
                label7.Text = NA;
                itemDescriptionTextBox.Text = NA;
                if (CurrentStyle != null)
                {
                    label11.Text = CurrentStyle.Name;
                    label12.Text = CurrentStyle.Author;
                    styleDescriptionTextBox.Text = CurrentStyle.Comment;
                }
                else
                {
                    label11.Text = NA;
                    label12.Text = NA;
                    styleDescriptionTextBox.Text = NA;
                }
            }
            itemDescriptionTextBox.Select(0, 0);
            styleDescriptionTextBox.Select(0, 0);
        }
Exemplo n.º 17
0
        public void DropItemOnPoint(PuzzleItem aPuzzleItem, Point aPoint)
        {
            //todoFIXED: make this precise

            int i = getItemSlotBetween(aPoint);

            //if (i >= GetSelectedItemIndex())
            //    i--;
            if (i >= 0)
            {
                InsertBefore(aPuzzleItem, i);
            }
            else
            {
                InsertAfter(aPuzzleItem, PuzzleItems.Count - 1);
            }
            dragging_insert_slot = -2;
        }
Exemplo n.º 18
0
        /// <summary>
        /// Creates a new PuzzleItem based off of a given item definition, and a specified subcatagory
        /// but using the existing image
        /// </summary>
        /// <param name="itemDefinition">Item definitions can be taken directly from the /scripts/editoritems.txt</param>
        /// <param name="subcatagory"></param>
        /// <param name="image"></param>
        public PuzzleItem(PuzzleItem p)
        {
            this.fileName    = p.fileName;
            this.TypeName    = p.TypeName;
            this.Author      = p.Author;
            this.Description = p.Description;

            // This object is shared with the original item
            this.ItemDefinition = p.ItemDefinition; // shallow clone

            // The subitems need to be different objects so we can change the image in a copy.
            // But the objects inside the subitem are the same objects until we change them.
            this.SubItems = new ArrayList();
            foreach (SubItem s in p.SubItems)
            {
                this.SubItems.Add(s.Clone());
            }

            this.subcatagoryIndex = p.subcatagoryIndex;
        }
Exemplo n.º 19
0
        public static void PopulateWithAllItems(PanelItemHolder holder)
        {
            string[] filePaths = Directory.GetFiles(itemDirectory, "*.bee");
            string[] temp;
            foreach (string path in filePaths)
            {
                if (path.EndsWith(individualItemExtension))
                {
                    temp = path.Split('\\');

                    PuzzleItem aPuzzleItem = new PuzzleItem(temp[temp.Length - 1].Replace(individualItemExtension, ""));
                    //get each subcatagory
                    for (int i = 0; i <= aPuzzleItem.SubcatagoryIndexMax; i++)
                    {
                        holder.InsertBefore(aPuzzleItem.Clone(), 0);
                        aPuzzleItem.ToggleSubcatagory();
                    }
                }
            }
        }
Exemplo n.º 20
0
        public void ShowItem(Point aPoint, PuzzleItem aPuzzleItem, Point Offset, bool ShouldChangeActualItem)
        {
            if (aPuzzleItem != null)
            {
                if (!ShouldChangeActualItem)
                {
                    aPuzzleItem = aPuzzleItem.Clone();
                    ThePuzzleItem = null;
                }
                else
                    ThePuzzleItem = aPuzzleItem;

                ShowItem(aPoint, aPuzzleItem);
                aPoint = MousePosition;
                aPoint.X = aPoint.X - Offset.X - (aPuzzleItem.SubcatagoryIndex * 65);
                aPoint.Y = aPoint.Y - Offset.Y;
                if (aPoint.X < 0) aPoint.X = 0;
                if (aPoint.Y < 0) aPoint.Y = 0;

                //check to make sure it will appear on screen
                int screenHeight = Screen.FromControl(this).Bounds.Height;
                int screenWidth = Screen.FromControl(this).Bounds.Width;
                //MessageBox.Show(this.Location.X + " " + this.Location.Y);
                this.TopMost = false;
                Point aMousePoint = System.Windows.Forms.Cursor.Position;
                if (aPoint.X + Width > screenWidth || aPoint.X + Width<0)
                {
                    aPoint.X = screenWidth - Width;
                    this.TopMost = true;
                }
                if (aPoint.Y + Height > screenHeight || aPoint.Y + Height<0)
                {
                    aPoint.Y = screenHeight - Height;
                    this.TopMost = true;
                }

                aMousePoint = new Point(aPoint.X + Offset.X + aPuzzleItem.SubcatagoryIndex * 66, aPoint.Y + Offset.Y);
                System.Windows.Forms.Cursor.Position = aMousePoint;
                Location = aPoint;
            }
        }
Exemplo n.º 21
0
 public void InsertBefore(PuzzleItem item, int slot)
 {
     if (slot >= 32)
     {
         if (OverloadDumpSite != null)
         {
             OverloadDumpSite.InsertBefore(item, 0);
         }
     }
     else
     {
         if (DeleteAtEnd)
         {
             if (PuzzleItems.Count >= gridSize)
             {
                 if (OverloadDumpSite != null)
                 {
                     OverloadDumpSite.InsertBefore(PuzzleItems[gridSize - 1], 0);
                 }
                 PuzzleItems.Remove(PuzzleItems[gridSize - 1]);
             }
             if (PuzzleItems.Count >= gridSize)
             {
                 try
                 {
                     PuzzleItems.RemoveAt(gridSize);
                     foreach (PuzzleItem anItem in aListOfSelectedItems)
                     {
                         if (!PuzzleItems.Contains(anItem))
                         {
                             aListOfSelectedItems.Remove(anItem);
                         }
                     }
                 }
                 catch { /*happens when window is resized (sometimes... and things break) */ }
             }
         }
         PuzzleItems.Insert(slot, item);//todo: fix crash when Item dragged too deep onto the palette
     }
     Invalidate();
 }
Exemplo n.º 22
0
        /// <summary>
        /// Creates a new PuzzleItem based off of a given item definition, and a specified subcatagory
        /// but using the existing image
        /// </summary>
        /// <param name="itemDefinition">Item definitions can be taken directly from the /scripts/editoritems.txt</param>
        /// <param name="subcatagory"></param>
        /// <param name="image"></param>
        public PuzzleItem(PuzzleItem p)
        {
            this.fileName = p.fileName;
            this.TypeName = p.TypeName;
            this.Author = p.Author;
            this.Description = p.Description;

            // This object is shared with the original item
            this.ItemDefinition = p.ItemDefinition; // shallow clone

            // The subitems need to be different objects so we can change the image in a copy.
            // But the objects inside the subitem are the same objects until we change them.
            this.SubItems = new ArrayList();
            foreach (SubItem s in p.SubItems)
            {
                this.SubItems.Add(s.Clone());
            }

            this.subcatagoryIndex = p.subcatagoryIndex;

        }
Exemplo n.º 23
0
 private void panelItemHolderBucket_MouseDown(object sender, MouseEventArgs e)
 {
     _itemForContextMenu = panelItemHolderBucket.getItemAt(e.Location);
 }
Exemplo n.º 24
0
 /// <summary>
 /// Removes the given PuzzleItem from the holders list of selected items
 /// </summary>
 /// <param name="value"></param>
 public virtual void RemoveFromSelected(PuzzleItem value)
 {
     aListOfSelectedItems.Remove(value);
 }/// <summary>
Exemplo n.º 25
0
 /// <summary>
 /// Adds the given PuzzleItem to the holders list of selected items
 /// </summary>
 /// <param name="value"></param>
 public virtual void AddToSelected(PuzzleItem value)
 {
     aListOfSelectedItems.Insert(0, value);
 }
Exemplo n.º 26
0
 private void UpdateProperties(PuzzleItem aPuzzleItem)
 {
     string NA = "N/A";
     if (aPuzzleItem != null && panelItemHolder_Visual1.GetSelectedItem() != null)
     {
         label5.Text = aPuzzleItem.TypeName;
         label6.Text = aPuzzleItem.Name_ToolTip;
         label7.Text = aPuzzleItem.Author;
         itemDescriptionTextBox.Text = aPuzzleItem.Description;
         if (CurrentStyle != null)
         {
             label11.Text = CurrentStyle.Name;
             label12.Text = CurrentStyle.Author;
             styleDescriptionTextBox.Text = CurrentStyle.Comment;
         }
         else
         {
             label11.Text = NA;
             label12.Text = NA;
             styleDescriptionTextBox.Text = NA;
         }
         //label11.Text = 
     }
     else
     {
         label5.Text = NA;
         label6.Text = NA;
         label7.Text = NA;
         itemDescriptionTextBox.Text = NA;
         if (CurrentStyle != null)
         {
             label11.Text = CurrentStyle.Name;
             label12.Text = CurrentStyle.Author;
             styleDescriptionTextBox.Text = CurrentStyle.Comment;
         }
         else
         {
             label11.Text = NA;
             label12.Text = NA;
             styleDescriptionTextBox.Text = NA;
         }
     }
     itemDescriptionTextBox.Select(0,0);
     styleDescriptionTextBox.Select(0,0);
 }
Exemplo n.º 27
0
 /// <summary>
 /// Removes the given PuzzleItem from the holders list of selected items
 /// </summary>
 /// <param name="value"></param>
 public virtual void RemoveFromSelected(PuzzleItem value)
 {
     aListOfSelectedItems.Remove(value);
 }/// <summary>
Exemplo n.º 28
0
 /// <summary>
 /// removes the designated item from the palette if it exists
 /// </summary>
 /// <param name="aPuzzleItem"></param>
 public void RemoveItem(PuzzleItem aPuzzleItem)
 {
     PuzzleItems.Remove(aPuzzleItem);
     aListOfSelectedItems.Remove(aPuzzleItem);//dont think this is nessesary
     Invalidate();
 }
Exemplo n.º 29
0
        public void InsertBefore(PuzzleItem item, int slot)
        {
            if (slot >= 32)
            {
                if (OverloadDumpSite != null)
                {
                    OverloadDumpSite.InsertBefore(item, 0);
                }
            }
            else
            {
                if (DeleteAtEnd)
                {

                    if (PuzzleItems.Count >= gridSize)
                    {
                        if (OverloadDumpSite != null)
                        {
                            OverloadDumpSite.InsertBefore(PuzzleItems[gridSize - 1], 0);
                        }
                        PuzzleItems.Remove(PuzzleItems[gridSize - 1]);
                    }
                    if (PuzzleItems.Count >= gridSize)
                    {
                        try
                        {
                            PuzzleItems.RemoveAt(gridSize);
                            foreach (PuzzleItem anItem in aListOfSelectedItems)
                            {
                                if (!PuzzleItems.Contains(anItem))
                                    aListOfSelectedItems.Remove(anItem);
                            }
                        }
                        catch { /*happens when window is resized (sometimes... and things break) */}
                    }
                }
                PuzzleItems.Insert(slot, item);//todo: fix crash when Item dragged too deep onto the palette
            }
            Invalidate();
        }
Exemplo n.º 30
0
 private void panelItemHolderBucket_MouseDown(object sender, MouseEventArgs e)
 {
     _itemForContextMenu = panelItemHolderBucket.getItemAt(e.Location);
 }
Exemplo n.º 31
0
        private void panelItemHolderPalette_MouseMove(object sender, MouseEventArgs e)
        {
            PuzzleItem aPuzzleItem = panelItemHolderPalette.GetSelectedItem();
            if (aPuzzleItem != null)
            {
                if (e.Button == MouseButtons.Left)
                {
                    MarkAsSender(panelItemHolderPalette);
                    aPuzzleItem = aPuzzleItem.Clone();
                    DoDragDrop(aPuzzleItem, DragDropEffects.Move);
                }
            }
            int x = e.X, y = e.Y;
            aPuzzleItem = panelItemHolderPalette.getItemAt(new Point(x, y));
            if (aPuzzleItem != null)
            {
                if (aPuzzleItem != oldpitem)
                {
                    //toolTip1.Show(aPuzzleItem.Name_ToolTip, panelItemHolderPalette, new Point(paletteSelectedItemLabel.Left - panelItemHolderPalette.Left, paletteSelectedItemLabel.Top - panelItemHolderPalette.Top + 32), 2000);
                    toolTip1.Show(aPuzzleItem.Name_ToolTip, panelItemHolderPalette, new Point(paletteSelectedItemLabel.Left - panelItemHolderPalette.Left - 9, paletteSelectedItemLabel.Top - panelItemHolderPalette.Top + 32 + 40), 2000);
                    oldpitem = aPuzzleItem;
                }
            }
            else
            {
                toolTip1.RemoveAll();
                oldpitem = null;
            }

            panelItemHolderBucket_Focus();
        }
Exemplo n.º 32
0
 public override void RemoveFromSelected(PuzzleItem value)
 {
     HoldOffOnPainting = true;
     base.RemoveFromSelected(value);
     HoldOffOnPainting = false;
 }
Exemplo n.º 33
0
 public override void AddToSelected(PuzzleItem value)
 {
     HoldOffOnPainting = true;
     base.AddToSelected(value);
     HoldOffOnPainting = false;
 }
Exemplo n.º 34
0
 public void ShowItem(Point aPoint, PuzzleItem aPuzzleItem, Point Offset)
 {
     ShowItem(aPoint, aPuzzleItem, Offset, false);
 }
Exemplo n.º 35
0
 public override void AddToSelected(PuzzleItem value)
 {
     HoldOffOnPainting = true;
     base.AddToSelected(value);
     HoldOffOnPainting = false;
 }
Exemplo n.º 36
0
 public void ShowItem(Point aPoint, PuzzleItem aPuzzleItem, Point Offset)
 {
     ShowItem(aPoint, aPuzzleItem, Offset, false);
 }
Exemplo n.º 37
0
        public string[] BuildEditorItems(List <PuzzleItem> ListOfAllItems, string StyleName)
        {
            ArrayList editorItems = new ArrayList();

            string[] results;

            // All the items that aren't in the palette have to be done FIRST
            // unless we are going to remove the palette entry
            for (int i = 0; i < ListOfAllItems.Count; i++)
            {
                PuzzleItem aPuzzleItem = ListOfAllItems[i];


                if (aPuzzleItem != null)
                {
                    //check for duplicates with all previously printed items
                    bool itemHasBeenSeen = false;
                    for (int j = 0; j < i; j++)
                    {
                        if ((ListOfAllItems[j]).TypeName == aPuzzleItem.TypeName)
                        {
                            itemHasBeenSeen = true;
                            break;
                        }
                    }
                    //check to make sure it also wasn't on the palette
                    if (!itemHasBeenSeen)
                    {
                        for (int j = 0; j < PuzzleItems.Count; j++)
                        {
                            if ((PuzzleItems[j]).TypeName == aPuzzleItem.TypeName)
                            {
                                itemHasBeenSeen = true;
                                break;
                            }
                        }
                    }
                    //only do this if the item hasn't been used before
                    if (!itemHasBeenSeen)
                    {
                        results = aPuzzleItem.GetDefinition();
                        editorItems.Add(results);
                    }
                }
            }

            // Now do the items in the Palette
            for (int i = 0; i < PuzzleItems.Count; i++)
            {
                //for each item, add it
                PuzzleItem aPuzzleItem = PuzzleItems[i];


                if (aPuzzleItem != null)
                {
                    //check for duplicates with all previously printed items
                    bool itemHasBeenSeen = false;
                    for (int j = 0; j < i; j++)
                    {
                        if ((PuzzleItems[j]).TypeName == aPuzzleItem.TypeName)
                        {
                            itemHasBeenSeen = true;
                            break;
                        }
                    }
                    //only do this if the item hasn't been used before
                    if (!itemHasBeenSeen)
                    {
                        //get all later instances of this object and combine them into one item entry
                        ArrayList activeSubItems   = new ArrayList();
                        ArrayList subItemLocations = new ArrayList();
                        for (int j = 0; j < PuzzleItems.Count; j++)//this should probably be int j = i  but I'm not going to try that just yet
                        {
                            if ((PuzzleItems[j]).TypeName == aPuzzleItem.TypeName)
                            {
                                activeSubItems.Add((PuzzleItems[j]).SubcatagoryIndex);
                                subItemLocations.Add(j);
                            }
                        }

                        results = aPuzzleItem.GetDefinition((int[])activeSubItems.ToArray(typeof(int)), (int[])subItemLocations.ToArray(typeof(int)));
                        editorItems.Add(results);
                    }
                }
            }

            //insert the vbsp style definition
            //find the style then grab its definition and insert into the editorItems at the beginning
            foreach (object style in Global.ListOfStyles)
            {
                if (((VBSPStyle)style).Name == StyleName)
                {
                    editorItems.Insert(0, ((VBSPStyle)style).WholeDefinition);
                    break;
                }
            }



            //collapse all entries into one string[]
            ArrayList returnValue = new ArrayList();

            string[] temp;
            int      tabsDeep = 0;

            for (int i = 0; i < editorItems.Count; i++)
            {
                temp = (string[])editorItems[i];
                for (int j = 0; j < temp.Length; j++)
                {
                    if (temp[j].Trim() == "}")
                    {
                        tabsDeep--;
                    }

                    string tttemp = "";
                    for (int k = 0; k < tabsDeep; k++)
                    {
                        tttemp += "\t";
                    }
                    tttemp += temp[j];
                    returnValue.Add(tttemp);
                    if (temp[j].Trim() == "{")
                    {
                        tabsDeep++;
                    }
                }
            }
            returnValue.Add("}");

            //iterate through and find subdefinitions with palette positions not on the palette
            int indexOfPaletteOpening = -1;
            int indexOfPaletteEnding  = -1;

            for (int i = 0; i < returnValue.Count; i++)
            {
                string line = (string)returnValue[i];
                if (line.Trim() == "\"Palette\"")
                {
                    indexOfPaletteOpening = i;
                }
                else if (line.Contains(Global.NotOnPaletteEntry))
                {
                    //found an entry to take out
                    indexOfPaletteEnding = -1;
                    for (int j = 0; indexOfPaletteEnding == -1; j++)
                    {
                        if (((string)returnValue[i + j]).Trim().StartsWith("}"))
                        {
                            indexOfPaletteEnding = i + j;
                        }
                    }
                    //now we have the beginning and ending points... either clear this data out or comment it out... I'll comment for now
                    for (int j = indexOfPaletteOpening; j <= indexOfPaletteEnding; j++)
                    {
                        returnValue[j] = ((string)returnValue[j]).Insert(0, "//"); //inserting comments
                    }
                    i = indexOfPaletteEnding;                                      //new place to continue searching (saves a little time)
                }
            }
            return((string[])returnValue.ToArray(typeof(string)));
        }
Exemplo n.º 38
0
        public static void LoadItemStyles()
        {
            // Item collections can define new styles based on base styles from the .style files
            // So go through each item collection and create the new styles
            string[] filePaths = Directory.GetFiles(Global.ItemDirectory, "*.beec");
            foreach (string path in filePaths)
            {
                string[] filecontents = File.ReadAllLines(path);
                //Parse the definition for style info
                ArrayList styleDefinition = new ArrayList();
                bool stylish = false;
                foreach (string line in filecontents)
                {
                    if (line.Contains("@EndStyle"))
                    {
                        stylish = false;
                        break;//take out the break if you want the whole file to be parsed for styleinfo
                    }
                    if (stylish)
                        styleDefinition.Add(line);
                    if (line.Contains("@Style"))
                        stylish = true;
                }
                string[] StyleDefinition = (string[])styleDefinition.ToArray(typeof(string));
                //take out the comments
                for (int i = 0; i < StyleDefinition.Length; i++)
                {
                    if (StyleDefinition[i].Trim().StartsWith("//"))
                        StyleDefinition[i] = StyleDefinition[i].Trim().Substring(2, StyleDefinition[i].Trim().Length - 2);
                }
                //find specific details from the style
                string styleName = Global.FindValue(StyleDefinition, "Style");
                string baseStyleName = Global.FindValue(StyleDefinition, "Base");
                string author = Global.FindValue(StyleDefinition, "Author");
                string comment = Global.FindValue(StyleDefinition, "Comment");
                if (styleName == null)
                {
                    if (baseStyleName != null)
                        styleName = baseStyleName;
                    else styleName = "Clean";
                }

                // if it's a new style...
                VBSPStyle thisStyle = GetStyle(styleName);
                if (thisStyle == null && baseStyleName != styleName)
                {
                    // ...based on an existing style...
                    VBSPStyle baseStyle = GetStyle(baseStyleName);
                    if (baseStyle != null)
                    {
                        // ...then add it.
                        thisStyle = new VBSPStyle(baseStyle.WholeDefinition);
                        thisStyle.Name = styleName;
                        thisStyle.Author = author;
                        thisStyle.Comment = comment;
                        thisStyle.Base = baseStyleName;
                        ListOfStyles.Add(thisStyle);
                    }
                }
                if (thisStyle == null)
                    continue;

                /*
                // make a list of the styles available for each item type
                ItemTypeStyles = new Dictionary<string, List<string>>();
                foreach (string s in filecontents)
                {
                    string line = s.Trim();
                    //make sure this whole line is long enough to even have a property this long
                    if (line.Length >= 10)
                    {
                        if (line.Substring(1, 5).Equals("Type\""))
                        {
                            string typeName = line.Substring(4 + 2).Trim();
                            if (!ItemTypeStyles.ContainsKey(typeName))
                                ItemTypeStyles.Add(typeName, new List<string>());
                            ItemTypeStyles[typeName].Add(typeName);
                        }
                    }
                }
                */

                string[][] individualItemDefinitions = Global.FindSubValues(filecontents, "Item");
                foreach (string[] definition in individualItemDefinitions)
                {
                    PuzzleItem aPuzzleItem = new PuzzleItem(definition);
                    aPuzzleItem.style = thisStyle;
                    thisStyle.BaseItems.Add(aPuzzleItem);
                    //don't need subcategories yet

                }


            } // next

        }
Exemplo n.º 39
0
 public void InsertAfter(PuzzleItem item, int slot)
 {
     if (DeleteAtEnd)
     {
         if (PuzzleItems.Count >= gridSize)
         {
             if (OverloadDumpSite != null)
             {
                 OverloadDumpSite.InsertBefore(PuzzleItems[gridSize - 1], 0);
             }
             PuzzleItems.Remove(PuzzleItems[gridSize - 1]);
         }
         if (PuzzleItems.Count >= gridSize)
         {
             try
             {
                 PuzzleItems.RemoveAt(gridSize);
                 foreach (PuzzleItem anItem in aListOfSelectedItems)
                 {
                     if (!PuzzleItems.Contains(anItem))
                         aListOfSelectedItems.Remove(anItem);
                 }
             }
             catch { /*happens when window is resized (sometimes)*/}
         }
     }
     PuzzleItems.Insert(slot + 1, item);
     Invalidate();
 }
Exemplo n.º 40
0
 /// <summary>
 /// removes the designated item from the palette if it exists
 /// </summary>
 /// <param name="aPuzzleItem"></param>
 public void RemoveItem(PuzzleItem aPuzzleItem)
 {
     PuzzleItems.Remove(aPuzzleItem);
     aListOfSelectedItems.Remove(aPuzzleItem);//dont think this is nessesary
     Invalidate();
 }
Exemplo n.º 41
0
 /// <summary>
 /// Adds the given PuzzleItem to the holders list of selected items
 /// </summary>
 /// <param name="value"></param>
 public virtual void AddToSelected(PuzzleItem value)
 {
     aListOfSelectedItems.Insert(0, value);
 }
Exemplo n.º 42
0
        public PuzzleItem getItemNumber(int value)
        {
            PuzzleItem aPuzzleItem = PuzzleItems[value];

            return(aPuzzleItem.Clone());
        }
Exemplo n.º 43
0
        public void DropItemOnPoint(PuzzleItem aPuzzleItem, Point aPoint)
        {
            //todoFIXED: make this precise

            int i = getItemSlotBetween(aPoint);
            //if (i >= GetSelectedItemIndex())
            //    i--;
            if (i >= 0)
                InsertBefore(aPuzzleItem, i);
            else
                InsertAfter(aPuzzleItem, PuzzleItems.Count - 1);
            dragging_insert_slot = -2;
        }
Exemplo n.º 44
0
 public override void RemoveFromSelected(PuzzleItem value)
 {
     HoldOffOnPainting = true;
     base.RemoveFromSelected(value);
     HoldOffOnPainting = false;
 }