// level tileset
 public Tileset(LevelMap levelMap, PaletteSet paletteSet)
 {
     this.levelMap   = levelMap;   // grab the current LevelMap
     this.paletteSet = paletteSet; // grab the current Palette Set
     this.Width      = 16;
     this.Height     = 32;
     this.HeightL3   = 16;
     this.tilesize   = 2;
     this.Type       = TilesetType.Level;
     // set tileset byte arrays
     tilesets_bytes[0] = Model.Tilesets[levelMap.TilesetL1 + 0x20];
     tilesets_bytes[1] = Model.Tilesets[levelMap.TilesetL2 + 0x20];
     tilesets_bytes[2] = Model.Tilesets[levelMap.TilesetL3];
     // combine graphic sets into one array
     graphics = new byte[0x6000];
     Buffer.BlockCopy(Model.GraphicSets[levelMap.GraphicSetA + 0x48], 0, graphics, 0, 0x2000);
     Buffer.BlockCopy(Model.GraphicSets[levelMap.GraphicSetB + 0x48], 0, graphics, 0x2000, 0x1000);
     Buffer.BlockCopy(Model.GraphicSets[levelMap.GraphicSetC + 0x48], 0, graphics, 0x3000, 0x1000);
     Buffer.BlockCopy(Model.GraphicSets[levelMap.GraphicSetD + 0x48], 0, graphics, 0x4000, 0x1000);
     Buffer.BlockCopy(Model.GraphicSets[levelMap.GraphicSetE + 0x48], 0, graphics, 0x5000, 0x1000);
     if (levelMap.GraphicSetL3 != 0xFF)
     {
         graphicsL3 = Model.GraphicSets[levelMap.GraphicSetL3];
     }
     // initialize 16x16 tile arrays
     tilesets_tiles[0] = new Tile[Width * Height];
     tilesets_tiles[1] = new Tile[Width * Height];
     if (levelMap.GraphicSetL3 != 0xFF)
     {
         tilesets_tiles[2] = new Tile[Width * HeightL3];
     }
     for (int l = 0; l < 3; l++)
     {
         if (tilesets_tiles[l] == null)
         {
             continue;
         }
         for (int i = 0; i < tilesets_tiles[l].Length; i++)
         {
             tilesets_tiles[l][i] = new Tile(i);
         }
     }
     // draw all 16x16 tiles
     DrawTileset(tilesets_bytes[0], tilesets_tiles[0], graphics, 0x20);
     DrawTileset(tilesets_bytes[1], tilesets_tiles[1], graphics, 0x20);
     if (levelMap.GraphicSetL3 != 0xFF)
     {
         DrawTileset(tilesets_bytes[2], tilesets_tiles[2], graphicsL3, 0x10);
     }
 }
Exemple #2
0
 // constructor
 public IOArchitecture(string action, int index, LevelMap levelMap, PaletteSet paletteSet, Tileset tileSet, Tilemap tileMap, PrioritySet prioritySet)
 {
     this.action      = action;
     this.index       = index;
     this.levelMap    = levelMap;
     this.paletteSet  = paletteSet;
     this.tileset     = tileSet;
     this.tilemap     = tileMap;
     this.prioritySet = prioritySet;
     InitializeComponent();
     if (action == "import")
     {
         groupBox1.Text = "Import the following elements from architecture file";
     }
     else
     {
         groupBox1.Text = "Export the following elements to architecture file";
     }
 }
 private void Export_Worker_DoWork(object sender, DoWorkEventArgs e, string fullPath,
                                   bool crop, bool contact, bool gif, int maxwidth, int start, int end, bool current)
 {
     for (int a = start; a < end; a++)
     {
         if (Export_Worker.CancellationPending)
         {
             break;
         }
         Sprite s = null;
         if (element == "levels")
         {
             Export_Worker.ReportProgress(a);
         }
         else
         {
             s = sprites[a];
             Export_Worker.ReportProgress(s.Index);
         }
         // if NOT sprite sheet or animated gif (ie. if NOT single image for each element)
         if (!contact && element == "sprites")
         {
             DirectoryInfo di = new DirectoryInfo(fullPath + "Sprite #" + s.Index.ToString("d4"));
             if (!di.Exists)
             {
                 di.Create();
             }
         }
         int index = 0;
         int x = 0, y = 0;
         if (this.element == "levels")
         {
             LevelMap     lmap = levelMaps[levels[a].LevelMap];
             LevelLayer   layr = levels[a].Layer;
             PaletteSet   pset = paletteSets[levelMaps[levels[a].LevelMap].PaletteSet];
             Tileset      tset = new Tileset(lmap, pset);
             LevelTilemap tmap = new LevelTilemap(levels[a], tset);
             int[]        pixels;
             Rectangle    region;
             if (crop)
             {
                 region = new Rectangle(
                     layr.MaskLowX * 16, layr.MaskLowY * 16,
                     (layr.MaskHighX - layr.MaskLowX) * 16 + 16,
                     (layr.MaskHighY - layr.MaskLowY) * 16 + 16);
                 pixels = Do.GetPixelRegion(tmap.Pixels, region, 1024, 1024);
             }
             else
             {
                 region = new Rectangle(0, 0, 1024, 1024);
                 pixels = tmap.Pixels;
             }
             Bitmap image = Do.PixelsToImage(pixels, region.Width, region.Height);
             if (!current)
             {
                 image.Save(fullPath + "Level #" + a.ToString("d3") + ".png", ImageFormat.Png);
             }
             else
             {
                 image.Save(fullPath, ImageFormat.Png);
             }
             continue;
         }
         // sprites
         if (gif)
         {
             Animation animation = animations[s.AnimationPacket];
             foreach (Mold m in animation.Molds)
             {
                 foreach (Mold.Tile t in m.Tiles)
                 {
                     t.DrawSubtiles(s.Graphics, s.Palette, m.Gridplane);
                 }
             }
             foreach (Sequence sequence in animation.Sequences)
             {
                 List <int> durations     = new List <int>();
                 Bitmap[]   croppedFrames = sequence.GetSequenceImages(animation, ref durations);
                 //
                 string path = fullPath + "Sprite #" + s.Index.ToString("d4") + "\\sequence." + index.ToString("d2") + ".gif";
                 if (croppedFrames.Length > 0)
                 {
                     Do.ImagesToAnimatedGIF(croppedFrames, durations.ToArray(), path);
                 }
                 index++;
             }
             continue;
         }
         int[][]          molds = new int[animations[s.AnimationPacket].Molds.Count][];
         int[]            sheet;
         int              biggestHeight = 0;
         int              biggestWidth = 0;
         List <Rectangle> sheetRegions = new List <Rectangle>();
         foreach (Mold m in animations[s.AnimationPacket].Molds)
         {
             foreach (Mold.Tile t in m.Tiles)
             {
                 t.DrawSubtiles(
                     images[s.Image].Graphics(spriteGraphics),
                     palettes[images[s.Image].PaletteNum + s.PaletteIndex].Palette,
                     m.Gridplane);
             }
             Rectangle region;
             if (crop)
             {
                 if (m.Gridplane)
                 {
                     region = Do.Crop(m.GridplanePixels(), out molds[index], 32, 32);
                 }
                 else
                 {
                     region = Do.Crop(m.MoldPixels(), out molds[index], 256, 256);
                 }
                 m.MoldTilesPerPixel = null;
                 if (x + region.Width < maxwidth && biggestWidth < x + region.Width)
                 {
                     biggestWidth = x + region.Width;
                 }
                 // if reached far right boundary of a row, add current row's height
                 if (x + region.Width >= maxwidth)
                 {
                     x  = region.Width; // reset width counter
                     y += biggestHeight;
                     sheetRegions.Add(new Rectangle(x - region.Width, y, region.Width, region.Height));
                     biggestHeight = 0; // start next row
                 }
                 else
                 {
                     sheetRegions.Add(new Rectangle(x, y, region.Width, region.Height));
                     x += region.Width;
                 }
                 if (biggestHeight < region.Height)
                 {
                     biggestHeight = region.Height;
                 }
             }
             else
             {
                 region       = new Rectangle(new Point(0, 0), m.Gridplane ? new Size(32, 32) : new Size(256, 256));
                 molds[index] = m.Gridplane ? m.GridplanePixels() : m.MoldPixels();
             }
             if (!contact)
             {
                 Do.PixelsToImage(molds[index], region.Width, region.Height).Save(
                     fullPath + "Sprite #" + s.Index.ToString("d4") + "\\mold." + index.ToString("d2") + ".png", ImageFormat.Png);
             }
             index++;
         }
         if (contact)
         {
             sheet = new int[biggestWidth * (y + biggestHeight)];
             for (int i = 0; i < molds.Length; i++)
             {
                 Do.PixelsToPixels(molds[i], sheet, biggestWidth, sheetRegions[i]);
             }
             string path = fullPath + (current ? "" : "Sprite #" + s.Index.ToString("d4") + ".png");
             Do.PixelsToImage(sheet, biggestWidth, y + biggestHeight).Save(path, ImageFormat.Png);
         }
     }
 }
Exemple #4
0
 private void buttonOK_Click(object sender, EventArgs e)
 {
     #region Levels
     if (this.Text == "EXPORT LEVEL DATA...")
     {
         this.Enabled = false;
         if (radioButtonCurrent.Checked)
         {
             // create the serialized level
             SerializedLevel sLevel = new SerializedLevel();
             sLevel.LevelLayer  = Model.Levels[currentIndex].Layer;
             sLevel.LevelMapNum = Model.Levels[currentIndex].LevelMap;
             LevelMap lMap = Model.LevelMaps[Model.Levels[currentIndex].LevelMap];
             sLevel.LevelMap      = lMap;// Add it to serialized level data object
             sLevel.TilesetL1     = Model.Tilesets[lMap.TilesetL1 + 0x20];
             sLevel.TilesetL2     = Model.Tilesets[lMap.TilesetL2 + 0x20];
             sLevel.TilesetL3     = Model.Tilesets[lMap.TilesetL3];
             sLevel.TilemapL1     = Model.Tilemaps[lMap.TilemapL1 + 0x40];
             sLevel.TilemapL2     = Model.Tilemaps[lMap.TilemapL2 + 0x40];
             sLevel.TilemapL3     = Model.Tilemaps[lMap.TilemapL3];
             sLevel.SolidityMap   = Model.SolidityMaps[lMap.SolidityMap];
             sLevel.LevelNPCs     = Model.Levels[currentIndex].LevelNPCs;
             sLevel.LevelExits    = Model.Levels[currentIndex].LevelExits;
             sLevel.LevelEvents   = Model.Levels[currentIndex].LevelEvents;
             sLevel.LevelOverlaps = Model.Levels[currentIndex].LevelOverlaps;
             // finally export the serialized levels
             Do.Export(sLevel, null, fullPath);
         }
         else
         {
             // create the serialized level
             SerializedLevel[] sLevels = new SerializedLevel[510];
             for (int i = 0; i < sLevels.Length; i++)
             {
                 sLevels[i]             = new SerializedLevel();
                 sLevels[i].LevelLayer  = Model.Levels[i].Layer;
                 sLevels[i].LevelMapNum = Model.Levels[i].LevelMap;
                 LevelMap lMap = Model.LevelMaps[Model.Levels[i].LevelMap];
                 sLevels[i].LevelMap      = lMap;// Add it to serialized level data object
                 sLevels[i].TilesetL1     = Model.Tilesets[lMap.TilesetL1 + 0x20];
                 sLevels[i].TilesetL2     = Model.Tilesets[lMap.TilesetL2 + 0x20];
                 sLevels[i].TilesetL3     = Model.Tilesets[lMap.TilesetL3];
                 sLevels[i].TilemapL1     = Model.Tilemaps[lMap.TilemapL1 + 0x40];
                 sLevels[i].TilemapL2     = Model.Tilemaps[lMap.TilemapL2 + 0x40];
                 sLevels[i].TilemapL3     = Model.Tilemaps[lMap.TilemapL3];
                 sLevels[i].SolidityMap   = Model.SolidityMaps[lMap.SolidityMap];
                 sLevels[i].LevelNPCs     = Model.Levels[i].LevelNPCs;
                 sLevels[i].LevelExits    = Model.Levels[i].LevelExits;
                 sLevels[i].LevelEvents   = Model.Levels[i].LevelEvents;
                 sLevels[i].LevelOverlaps = Model.Levels[i].LevelOverlaps;
             }
             // finally export the serialized levels
             Do.Export(sLevels,
                       fullPath + "\\" + Model.GetFileNameWithoutPath() + " - Levels\\" + "level", "LEVEL", true);
         }
     }
     if (this.Text == "IMPORT LEVEL DATA...")
     {
         this.Enabled = false;
         if (radioButtonCurrent.Checked)
         {
             SerializedLevel sLevel = new SerializedLevel();
             try
             {
                 sLevel = (SerializedLevel)Do.Import(sLevel, fullPath);
             }
             catch
             {
                 MessageBox.Show("File not a level data file.", "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                 return;
             }
             Model.Levels[currentIndex].Layer       = sLevel.LevelLayer;
             Model.Levels[currentIndex].Layer.Index = currentIndex;
             Model.Levels[currentIndex].LevelMap    = sLevel.LevelMapNum;
             LevelMap lMap = sLevel.LevelMap;
             Model.LevelMaps[Model.Levels[currentIndex].LevelMap] = lMap;
             Model.Tilesets[lMap.TilesetL1 + 0x20]          = sLevel.TilesetL1;
             Model.Tilesets[lMap.TilesetL2 + 0x20]          = sLevel.TilesetL2;
             Model.Tilesets[lMap.TilesetL3]                 = sLevel.TilesetL3;
             Model.EditTilesets[lMap.TilesetL1 + 0x20]      = true;
             Model.EditTilesets[lMap.TilesetL2 + 0x20]      = true;
             Model.EditTilesets[lMap.TilesetL3]             = true;
             Model.Tilemaps[lMap.TilemapL1 + 0x40]          = sLevel.TilemapL1;
             Model.Tilemaps[lMap.TilemapL2 + 0x40]          = sLevel.TilemapL2;
             Model.Tilemaps[lMap.TilemapL3]                 = sLevel.TilemapL3;
             Model.EditTilemaps[lMap.TilemapL1 + 0x40]      = true;
             Model.EditTilemaps[lMap.TilemapL2 + 0x40]      = true;
             Model.EditTilemaps[lMap.TilemapL3]             = true;
             Model.SolidityMaps[lMap.SolidityMap]           = sLevel.SolidityMap;
             Model.EditSolidityMaps[lMap.SolidityMap]       = true;
             Model.Levels[currentIndex].LevelNPCs           = sLevel.LevelNPCs;
             Model.Levels[currentIndex].LevelExits          = sLevel.LevelExits;
             Model.Levels[currentIndex].LevelEvents         = sLevel.LevelEvents;
             Model.Levels[currentIndex].LevelOverlaps       = sLevel.LevelOverlaps;
             Model.Levels[currentIndex].LevelNPCs.Index     = currentIndex;
             Model.Levels[currentIndex].LevelExits.Index    = currentIndex;
             Model.Levels[currentIndex].LevelEvents.Index   = currentIndex;
             Model.Levels[currentIndex].LevelOverlaps.Index = currentIndex;
         }
         else
         {
             SerializedLevel[] sLevels = new SerializedLevel[510];
             for (int i = 0; i < sLevels.Length; i++)
             {
                 sLevels[i] = new SerializedLevel();
             }
             try
             {
                 Do.Import(sLevels, fullPath + "\\" + "level", "LEVEL", true);
             }
             catch
             {
                 MessageBox.Show("One or more files not a level data file.", "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                 return;
             }
             for (int i = 0; i < sLevels.Length; i++)
             {
                 Model.Levels[i].Layer       = sLevels[i].LevelLayer;
                 Model.Levels[i].Layer.Index = currentIndex;
                 Model.Levels[i].LevelMap    = sLevels[i].LevelMapNum;
                 LevelMap lMap = sLevels[i].LevelMap;
                 Model.LevelMaps[Model.Levels[i].LevelMap] = lMap;
                 Model.Tilesets[lMap.TilesetL1 + 0x20]     = sLevels[i].TilesetL1;
                 Model.Tilesets[lMap.TilesetL2 + 0x20]     = sLevels[i].TilesetL2;
                 Model.Tilesets[lMap.TilesetL3]            = sLevels[i].TilesetL3;
                 Model.EditTilesets[lMap.TilesetL1 + 0x20] = true;
                 Model.EditTilesets[lMap.TilesetL2 + 0x20] = true;
                 Model.EditTilesets[lMap.TilesetL3]        = true;
                 Model.Tilemaps[lMap.TilemapL1 + 0x40]     = sLevels[i].TilemapL1;
                 Model.Tilemaps[lMap.TilemapL2 + 0x40]     = sLevels[i].TilemapL2;
                 Model.Tilemaps[lMap.TilemapL3]            = sLevels[i].TilemapL3;
                 Model.EditTilemaps[lMap.TilemapL1 + 0x40] = true;
                 Model.EditTilemaps[lMap.TilemapL2 + 0x40] = true;
                 Model.EditTilemaps[lMap.TilemapL3]        = true;
                 Model.SolidityMaps[lMap.SolidityMap]      = sLevels[i].SolidityMap;
                 Model.EditSolidityMaps[lMap.SolidityMap]  = true;
                 Model.Levels[i].LevelNPCs           = sLevels[i].LevelNPCs;
                 Model.Levels[i].LevelExits          = sLevels[i].LevelExits;
                 Model.Levels[i].LevelEvents         = sLevels[i].LevelEvents;
                 Model.Levels[i].LevelOverlaps       = sLevels[i].LevelOverlaps;
                 Model.Levels[i].LevelNPCs.Index     = currentIndex;
                 Model.Levels[i].LevelExits.Index    = currentIndex;
                 Model.Levels[i].LevelEvents.Index   = currentIndex;
                 Model.Levels[i].LevelOverlaps.Index = currentIndex;
             }
         }
     }
     #endregion
     #region Battlefields
     if (this.Text == "EXPORT BATTLEFIELDS...")
     {
         Battlefield[]           battlefields = Model.Battlefields;
         SerializedBattlefield[] serialized   = new SerializedBattlefield[battlefields.Length];
         PaletteSet[]            paletteSets  = Model.PaletteSetsBF;
         int i = 0;
         foreach (Battlefield battlefield in battlefields)
         {
             serialized[i] = new SerializedBattlefield(Model.TilesetsBF[battlefields[i].TileSet],
                                                       paletteSets[battlefields[i++].PaletteSet], battlefield);
         }
         if (radioButtonCurrent.Checked)
         {
             Do.Export(serialized[currentIndex], null, fullPath);
         }
         else
         {
             Do.Export(serialized,
                       fullPath + "\\" + Model.GetFileNameWithoutPath() + " - Battlefields\\" + "battlefield",
                       "BATTLEFIELD", true);
         }
     }
     if (this.Text == "IMPORT BATTLEFIELDS...")
     {
         Battlefield[] battlefields = Model.Battlefields;
         if (radioButtonCurrent.Checked)
         {
             SerializedBattlefield battlefield = new SerializedBattlefield();
             try
             {
                 battlefield = (SerializedBattlefield)Do.Import(battlefield, fullPath);
             }
             catch
             {
                 MessageBox.Show("File not a battlefield data file.", "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                 return;
             }
             Model.TilesetsBF[battlefields[currentIndex].TileSet] = battlefield.tileset;
             battlefields[currentIndex].GraphicSetA = battlefield.graphicSetA;
             battlefields[currentIndex].GraphicSetB = battlefield.graphicSetB;
             battlefields[currentIndex].GraphicSetC = battlefield.graphicSetC;
             battlefields[currentIndex].GraphicSetD = battlefield.graphicSetD;
             battlefields[currentIndex].GraphicSetE = battlefield.graphicSetE;
             Model.PaletteSetsBF[battlefields[currentIndex].PaletteSet] = battlefield.paletteSet;
             battlefields[currentIndex].Index = currentIndex;
         }
         else
         {
             SerializedBattlefield[] battlefield = new SerializedBattlefield[battlefields.Length];
             for (int i = 0; i < battlefield.Length; i++)
             {
                 battlefield[i] = new SerializedBattlefield();
             }
             try
             {
                 Do.Import(battlefield, fullPath + "\\" + "battlefield", "BATTLEFIELD", true);
             }
             catch
             {
                 MessageBox.Show("One or more files not a battlefield data file.", "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                 return;
             }
             for (int i = 0; i < battlefield.Length; i++)
             {
                 Model.TilesetsBF[battlefields[i].TileSet] = battlefield[i].tileset;
                 battlefields[i].GraphicSetA = battlefield[i].graphicSetA;
                 battlefields[i].GraphicSetB = battlefield[i].graphicSetB;
                 battlefields[i].GraphicSetC = battlefield[i].graphicSetC;
                 battlefields[i].GraphicSetD = battlefield[i].graphicSetD;
                 battlefields[i].GraphicSetE = battlefield[i].graphicSetE;
                 Model.PaletteSetsBF[battlefields[i].PaletteSet] = battlefield[i].paletteSet;
                 battlefields[i].Index = i;
             }
         }
     }
     #endregion
     #region Audio
     if (this.Text == "EXPORT SAMPLE BRRs...")
     {
         if (radioButtonCurrent.Checked)
         {
             Do.Export(Model.AudioSamples[currentIndex].Sample,
                       "sampleBRR." + currentIndex.ToString("d3") + ".brr", fullPath);
         }
         else
         {
             byte[][] samples = new byte[Model.AudioSamples.Length][];
             int      i       = 0;
             foreach (BRRSample s in Model.AudioSamples)
             {
                 samples[i++] = s.Sample;
             }
             Do.Export(samples,
                       fullPath + "\\" + Model.GetFileNameWithoutPath() + " - BRR Samples\\" + "sampleBRR",
                       "BRR SAMPLE", true);
         }
         this.DialogResult = DialogResult.OK;
         this.Close();
         return;
     }
     if (this.Text == "IMPORT SAMPLE BRRs...")
     {
         if (radioButtonCurrent.Checked)
         {
             try
             {
                 byte[] sample = (byte[])Do.Import(new byte[1], fullPath);
                 Model.AudioSamples[currentIndex].Sample = sample;
             }
             catch
             {
                 MessageBox.Show("Error importing .brr file.", "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                 return;
             }
         }
         else
         {
             byte[][] samples = new byte[Model.AudioSamples.Length][];
             try
             {
                 Do.Import(samples, fullPath + "\\" + "sampleBRR", "BRR SAMPLE", true);
             }
             catch
             {
                 MessageBox.Show("Error importing .brr file(s).", "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                 return;
             }
             int i = 0;
             foreach (BRRSample sample in Model.AudioSamples)
             {
                 sample.Sample = samples[i++];
             }
         }
         this.DialogResult = DialogResult.OK;
         this.Close();
         return;
     }
     if (this.Text == "EXPORT SAMPLE WAVs...")
     {
         if (radioButtonCurrent.Checked)
         {
             Do.Export(BRR.BRRToWAV(Model.AudioSamples[currentIndex].Sample, (int)args[0]),
                       "sampleWAV." + currentIndex.ToString("d3") + ".wav", fullPath);
         }
         else
         {
             byte[][] samples = new byte[Model.AudioSamples.Length][];
             int      i       = 0;
             foreach (BRRSample s in Model.AudioSamples)
             {
                 samples[i++] = BRR.BRRToWAV(s.Sample, (int)args[0]);
             }
             Do.Export(samples,
                       fullPath + "\\" + Model.GetFileNameWithoutPath() + " - WAV Samples\\" + "sampleWAV",
                       "SAMPLE", true);
         }
         this.DialogResult = DialogResult.OK;
         this.Close();
         return;
     }
     if (this.Text == "IMPORT SAMPLE WAVs...")
     {
         if (radioButtonCurrent.Checked)
         {
             try
             {
                 byte[] sample = (byte[])Do.Import(new byte[1], fullPath);
                 Model.AudioSamples[currentIndex].Sample = BRR.Encode(sample);
             }
             catch
             {
                 MessageBox.Show("Error encoding .wav file.", "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                 return;
             }
         }
         else
         {
             byte[][] samples = new byte[Model.AudioSamples.Length][];
             try
             {
                 Do.Import(samples, fullPath + "\\" + "sampleWAV", "WAV SAMPLE", true);
             }
             catch
             {
                 MessageBox.Show("Error encoding .wav file(s).", "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                 return;
             }
             int i = 0;
             foreach (BRRSample sample in Model.AudioSamples)
             {
                 sample.Sample = BRR.Encode(samples[i++]);
             }
         }
         this.DialogResult = DialogResult.OK;
         this.Close();
         return;
     }
     if (this.Text == "EXPORT SPCs...")
     {
         if (radioButtonCurrent.Checked)
         {
             Do.Export(Model.SPCs[currentIndex], null, textBoxCurrent.Text);
         }
         else
         {
             Do.Export(Model.SPCs, fullPath + "\\" + Model.GetFileNameWithoutPath() + " - SPCs\\" + "spc", "SPC", true);
         }
         this.DialogResult = DialogResult.OK;
         this.Close();
         return;
     }
     if (this.Text == "IMPORT SPCs...")
     {
         if (radioButtonCurrent.Checked)
         {
             SPCTrack spc = new SPCTrack();
             try
             {
                 spc = (SPCTrack)Do.Import(spc, fullPath);
             }
             catch
             {
                 MessageBox.Show("File not an SPC data file.", "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                 return;
             }
             spc.CreateCommands();
             Model.SPCs[currentIndex] = spc;
         }
         else
         {
             SPCTrack[] spcs = new SPCTrack[Model.SPCs.Length];
             for (int i = 0; i < spcs.Length; i++)
             {
                 spcs[i] = new SPCTrack();
             }
             try
             {
                 Do.Import(spcs, fullPath + "\\" + "spc", "SPC", true);
             }
             catch
             {
                 MessageBox.Show("One or more files not an SPC data file.", "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                 return;
             }
             for (int i = 0; i < spcs.Length; i++)
             {
                 if (spcs[i].SPCData == null)
                 {
                     continue;
                 }
                 Model.SPCs[i] = spcs[i];
                 Model.SPCs[i].CreateCommands();
             }
         }
         this.DialogResult = DialogResult.OK;
         this.Close();
         return;
     }
     #endregion
     #region Other
     try
     {
         Element[] array = (Element[])element;
         string    name  = this.Text.ToLower().Substring(7, this.Text.Length - 7 - 4);
         if (this.Text.Substring(0, 6) == "EXPORT")
         {
             if (radioButtonCurrent.Checked)
             {
                 Do.Export(array[currentIndex], null, textBoxCurrent.Text);
             }
             else
             {
                 Do.Export(array,
                           fullPath + "\\" + Model.GetFileNameWithoutPath() + " - " +
                           Lists.ToTitleCase(name) + "s" + "\\" + name,
                           name.ToUpper(), true);
             }
         }
         if (this.Text.Substring(0, 6) == "IMPORT")
         {
             if (radioButtonCurrent.Checked)
             {
                 try
                 {
                     array[currentIndex] = (Element)Do.Import(array[currentIndex], fullPath);
                 }
                 catch
                 {
                     MessageBox.Show("Incorrect data file type.", "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                     return;
                 }
                 array[currentIndex].Index = currentIndex;
             }
             else
             {
                 try
                 {
                     Do.Import(array, fullPath + "\\" + name, name.ToUpper(), true);
                 }
                 catch
                 {
                     MessageBox.Show("One or more files incorrect data file type.", "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                     return;
                 }
                 int i = 0;
                 foreach (Element item in array)
                 {
                     item.Index = i++;
                 }
             }
         }
     }
     catch { }
     #endregion
     this.Tag          = radioButtonAll.Checked;
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
Exemple #5
0
 // constructor
 public LevelSolidMap(LevelMap levelMap)
 {
     this.levelMap = levelMap;
     tilemap_Bytes = Model.SolidityMaps[levelMap.SolidityMap];
 }