Exemplo n.º 1
0
        private void selectTile(NSMBTileset.ObjectDefTile tile)
        {
            selTile           = tile;
            DataUpdateFlag    = true;
            map16Tile.Value   = selTile.tileID;
            controlByte.Value = selTile.controlByte;
//            map16Picker1.selectTile(selTile.tileID);
            grpTileSettings.Visible = selTile != null;

            DataUpdateFlag = false;
        }
Exemplo n.º 2
0
 private void deleteButton_Click(object sender, EventArgs e)
 {
     if (selRow == null)
     {
         return;
     }
     if (selTile == null)
     {
         if (obj.tiles.Count - 1 == obj.tiles.IndexOf(selRow))
         {
             if (obj.tiles.IndexOf(selRow) == 0)
             {
                 return;
             }
             else
             {
                 selRow = obj.tiles[obj.tiles.IndexOf(selRow) - 1];
                 obj.tiles.RemoveAt(obj.tiles.IndexOf(selRow) + 1);
             }
         }
         else
         {
             selRow = obj.tiles[obj.tiles.IndexOf(selRow) + 1];
             obj.tiles.RemoveAt(obj.tiles.IndexOf(selRow) - 1);
         }
     }
     else
     {
         if (selRow.Count - 1 == selRow.IndexOf(selTile))
         {
             if (selRow.IndexOf(selTile) == 0)
             {
                 selRow.Remove(selTile);
                 selTile = null;
             }
             else
             {
                 selTile = selRow[selRow.IndexOf(selTile) - 1];
                 selRow.RemoveAt(selRow.IndexOf(selTile) + 1);
             }
         }
         else
         {
             selTile = selRow[selRow.IndexOf(selTile) + 1];
             selRow.RemoveAt(selRow.IndexOf(selTile) - 1);
         }
     }
     repaint();
 }
Exemplo n.º 3
0
 private void tilePicker1_TileSelected(int selTileNum, int selTilePal, int selTileWidth, int selTileHeight)
 {
     for (int y = 0; y < selTileHeight; y++)
     {
         if (y != 0)
         {
             newLine();
         }
         for (int x = 0; x < selTileWidth; x++)
         {
             NSMBTileset.ObjectDefTile tile = new NSMBTileset.ObjectDefTile(tls);
             tile.tileID = selTileNum + x + y * tilePicker1.bufferWidth;
             insertTile(tile);
         }
     }
 }
Exemplo n.º 4
0
        private void insertTile(NSMBTileset.ObjectDefTile tile)
        {
            if (selRow == null)
            {
                return;
            }
            if (selTile == null)
            {
                selRow.Insert(0, tile);
            }
            else
            {
                selRow.Insert(selRow.IndexOf(selTile) + 1, tile);
            }

            selectTile(tile);
            repaint();
        }
Exemplo n.º 5
0
 public void setObject(int num)
 {
     if (tls.Objects[num] == null)
     {
         return;
     }
     previewObject.ObjNum    = num;
     grpTileSettings.Visible = false;
     obj = tls.Objects[num];
     if (obj.tiles.Count == 0)
     {
         obj.tiles.Add(new List <NSMBTileset.ObjectDefTile>());
     }
     selTile                 = null;
     selRow                  = obj.tiles[0];
     DataUpdateFlag          = true;
     objWidth.Value          = obj.width;
     objHeight.Value         = obj.height;
     DataUpdateFlag          = false;
     grpTileSettings.Visible = selTile != null;
     repaint();
 }
Exemplo n.º 6
0
        private void map16Picker1_TileSelected(int tile)
        {
            if (DataUpdateFlag)
            {
                return;
            }

            if (Control.ModifierKeys == Keys.Control)
            {
                NSMBTileset.ObjectDefTile nt = new NSMBTileset.ObjectDefTile(tls);
                nt.tileID = tile;
                insertTile(nt);
            }
            else if (selTile != null)
            {
                DataUpdateFlag  = true;
                selTile.tileID  = tile;
                map16Tile.Value = tile;
                DataUpdateFlag  = false;
            }

            repaint();
        }
Exemplo n.º 7
0
 private void slopeControlButton_Click(object sender, EventArgs e)
 {
     NSMBTileset.ObjectDefTile tile = new NSMBTileset.ObjectDefTile(tls);
     tile.controlByte = 0x80;
     insertTile(tile);
 }
Exemplo n.º 8
0
 private void emptyTileButton_Click(object sender, EventArgs e)
 {
     NSMBTileset.ObjectDefTile t = new NSMBTileset.ObjectDefTile(tls);
     t.tileID = -1;
     insertTile(t);
 }
Exemplo n.º 9
0
        private void editZone_MouseDown(object sender, MouseEventArgs e)
        {
            if (obj == null)
            {
                return;
            }

            int tx = e.X / 16 - 1;
            int ty = e.Y / 16;

            if (tx < -1)
            {
                return;
            }
            if (ty < 0)
            {
                return;
            }

            if (obj.tiles.Count > ty)
            {
                if (obj.tiles[ty].Count > tx)
                {
                    selRow = obj.tiles[ty];
                    if (tx == -1)
                    {
                        selTile = null;
                        if (Control.ModifierKeys == Keys.Control)
                        {
                            obj.tiles.Remove(selRow);
                        }
                    }
                    else
                    {
                        selectTile(selRow[tx]);
                        if (Control.ModifierKeys == Keys.Control)
                        {
                            selRow.Remove(selTile);
                            selTile = null;
                        }
                        else if (Control.ModifierKeys == Keys.Shift)
                        {
                            selTile.controlByte ^= 2;
                        }
                        else if (Control.ModifierKeys == Keys.Alt)
                        {
                            selTile.controlByte ^= 1;
                        }
                    }
                    grpTileSettings.Visible = selTile != null;
                    if (selTile != null)
                    {
                        tilePicker1.selTileHeight = 1;
                        tilePicker1.selTileWidth  = 1;
                        tilePicker1.selTileNum    = selTile.tileID;
                        tilePicker1.Invalidate(true);
                    }
                    repaint();
                }
            }
        }
Exemplo n.º 10
0
        private void copyPalettes_Click(object sender, EventArgs e)
        {
            int repeat = 12;

            //Copy map16

            for (int p = 1; p < t.palettes.Length; p++)
            {
                for (int x = 0; x < 32; x++)
                {
                    for (int y = 0; y < repeat * 2; y++)
                    {
                        t.map16.tiles[x, y + p * repeat * 2]        = t.map16.tiles[x, y];
                        t.map16.tiles[x, y + p * repeat * 2].palNum = (t.map16.tiles[x, y + p * repeat * 2].palNum + p) % t.palettes.Length;
                    }
                }
            }

            //Copy Tile behaviors
            for (int p = 1; p < t.palettes.Length; p++)
            {
                for (int x = 0; x < 16 * repeat; x++)
                {
                    t.TileBehaviors[x + p * 16 * repeat] = t.TileBehaviors[x];
                }
            }

            //And now copy objects. Meh
            int objCount = 0;

            while (objCount < t.Objects.Length && t.Objects[objCount] != null)
            {
                objCount++;
            }

            for (int p = 1; p < t.palettes.Length; p++)
            {
                for (int i = 0; i < objCount; i++)
                {
                    if (i + p * objCount >= t.Objects.Length)
                    {
                        continue;
                    }

                    NSMBTileset.ObjectDef o = new NSMBTileset.ObjectDef(t);
                    o.tiles.Clear();
                    foreach (List <NSMBTileset.ObjectDefTile> row in t.Objects[i].tiles)
                    {
                        List <NSMBTileset.ObjectDefTile> row2 = new List <NSMBTileset.ObjectDefTile>();
                        foreach (NSMBTileset.ObjectDefTile tile in row)
                        {
                            NSMBTileset.ObjectDefTile tile2 = new NSMBTileset.ObjectDefTile(t);
                            tile2.tileID      = (tile.tileID + repeat * 16 * p) % 768;
                            tile2.controlByte = tile.controlByte;
                            row2.Add(tile2);
                        }
                        o.tiles.Add(row2);
                    }
                    t.Objects[i + p * objCount] = o;
                }
            }
            //TODO merp

            mustRepaintObjects();
        }