private void OnClickClear(object sender, EventArgs e) { int blockx1 = (int)numericUpDownX1.Value; int blockx2 = (int)numericUpDownX2.Value; int blocky1 = (int)numericUpDownY1.Value; int blocky2 = (int)numericUpDownY2.Value; int temp; if (blockx1 > blockx2) { temp = blockx1; blockx1 = blockx2; blockx2 = temp; } if (blocky1 > blocky2) { temp = blocky1; blocky1 = blocky2; blocky2 = temp; } blockx1 >>= 3; blockx2 >>= 3; blocky1 >>= 3; blocky2 >>= 3; for (int x = blockx1; x <= blockx2; ++x) { for (int y = blocky1; y <= blocky2; ++y) { HuedTile[][][] tiles = _map.Tiles.GetStaticBlock(x, y, false); // TODO: unused variable? do we need to call GetStaticBlock() here? _map.Tiles.RemoveStaticBlock(x, y); } } _map.ResetCache(); MessageBox.Show("Done", "Clear Static", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); _mapParent.RefreshMap(); }
private void OnClickMelt(object sender, EventArgs e) { SaveFileDialog dialog = new SaveFileDialog { CheckPathExists = true, Title = "Choose the file to save to" }; if (dialog.ShowDialog() != DialogResult.OK) { return; } int blockx1 = (int)numericUpDownX1.Value; int blockx2 = (int)numericUpDownX2.Value; int blocky1 = (int)numericUpDownY1.Value; int blocky2 = (int)numericUpDownY2.Value; int temp; if (blockx1 > blockx2) { temp = blockx1; blockx1 = blockx2; blockx2 = temp; } if (blocky1 > blocky2) { temp = blocky1; blocky1 = blocky2; blocky2 = temp; } blockx1 >>= 3; blockx2 >>= 3; blocky1 >>= 3; blocky2 >>= 3; int count = 1; using (StreamWriter tex = new StreamWriter(new FileStream(dialog.FileName, FileMode.Create, FileAccess.Write), System.Text.Encoding.GetEncoding(1252))) { for (int x = blockx1; x <= blockx2; ++x) { for (int y = blocky1; y <= blocky2; ++y) { HuedTile[][][] tiles = _map.Tiles.GetStaticBlock(x, y, false); for (int ix = 0; ix < 8; ++ix) { for (int iy = 0; iy < 8; ++iy) { foreach (HuedTile tile in tiles[ix][iy]) { tex.WriteLine("SECTION WORLDITEM {0}", count); tex.WriteLine("{"); tex.WriteLine(" NAME #"); tex.WriteLine(" ID {0}", tile.ID); tex.WriteLine(" X {0}", (x << 3) + ix); tex.WriteLine(" Y {0}", (y << 3) + iy); tex.WriteLine(" Z {0}", tile.Z); tex.WriteLine(" COLOR {0}", tile.Hue); tex.WriteLine(" CONT -1"); tex.WriteLine(" TYPE 255"); tex.WriteLine("}"); ++count; } } } _map.Tiles.RemoveStaticBlock(x, y); } } } dialog.Dispose(); _map.ResetCache(); MessageBox.Show("Done", "Melt Static", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); _mapParent.RefreshMap(); }