Example #1
0
        private void RoomForm_Activated(object sender, EventArgs e)
        {
            MdiClient parent = Parent as MdiClient;

            if (parent != null)
            {
                foreach (Form child in parent.MdiChildren)
                {
                    if (child.GetType() == typeof(SpriteSheetForm))
                    {
                        SpriteSheetForm sheet = child as SpriteSheetForm;
                        Spritesheet     ss    = sheet.Spritesheet;
                        if (ss != null && !comboBox1.Items.Contains(ss))
                        {
                            comboBox1.Items.Add(ss);
                        }
                    }
                }
            }

            if (spritesheet != null)
            {
                comboBox1.SelectedItem = spritesheet;
            }
            else if (comboBox1.Items.Count > 0)
            {
                comboBox1.SelectedIndex = 0;
                spritesheet             = comboBox1.SelectedItem as Spritesheet;
            }
        }
Example #2
0
        //clicking picbox will grag coord and let you dump image at that point
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (spritesheet == null)
            {
                return;
            }

            if (e.GetType() == typeof(MouseEventArgs))
            {
                MouseEventArgs mouse = e as MouseEventArgs;
                CurrentTile = new Point(mouse.X / (spritesheet.GridWidth + spritesheet.Spacing), mouse.Y / (spritesheet.GridHeight + spritesheet.Spacing));

                //save tile coord here for draw use
                Tiles tmp = new Tiles();
                tmp.DestinationCoord = new Point(CurrentTile.X, CurrentTile.Y);

                SpriteSheetForm sheet = FindSheet();
                if (sheet != null)
                {
                    tmp.SourceCoord = new Point(sheet.CurrentTile.X, sheet.CurrentTile.Y);
                }
                else
                {
                    tmp.SourceCoord = new Point(0, 0);
                }
                drawSpriteAtPos.Add(tmp);
                addToListbox(tmp, sheet, tmp);
                DrawRoom();
            }
        }
Example #3
0
        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            Form childForm = new SpriteSheetForm();

            childForm.MdiParent = this;
            childForm.Text      = "Sprite Sheet " + childFormNumber++;
            childForm.Show();
        }
Example #4
0
 private void addToListbox(Tiles tileName, SpriteSheetForm sheet, Tiles tile)
 {
     if (sheet != null)
     {
         //listBox1.Items.Add(sheet.CurrentTile);
         listBox1.Items.Add(tile.DestinationCoord);
         DrawRoom();
     }
 }
Example #5
0
 //add button
 private void button1_Click(object sender, EventArgs e)
 {
     if (spritesheet != null)
     {
         SpriteSheetForm sheet = FindSheet();
         if (sheet != null)
         {
             listBox1.Items.Add(sheet.CurrentTile);
             DrawRoom();
         }
     }
 }
Example #6
0
        SpriteSheetForm FindSheet()
        {
            MdiClient parent = Parent as MdiClient;

            if (parent != null)
            {
                foreach (Form child in parent.MdiChildren)
                {
                    if (child.GetType() == typeof(SpriteSheetForm))
                    {
                        SpriteSheetForm sheet = child as SpriteSheetForm;
                        if (sheet.Spritesheet == spritesheet)
                        {
                            return(sheet);
                        }
                    }
                }
            }
            return(null);
        }