Exemple #1
0
        public void SetMap(MapClass _Map)
        {
            Map = _Map;

            Map.cellIter.Reset();

            int X1 = Int32.MaxValue, Y1 = Int32.MaxValue, X2 = Int32.MinValue, Y2 = Int32.MinValue;

            foreach(var cell in Map.cellIter.Range()) {
                var p = cell.Position2DCells;
                X1 = Math.Min(X1, p.X);
                X2 = Math.Max(X2, p.X + 60);
                Y1 = Math.Min(Y1, p.Y);
                Y2 = Math.Max(Y2, p.Y + 30);
            }

            EntireMap = new Rectangle(X1, Y1, X2 - X1, Y2 - Y1);

            Debug.Assert(EntireMap.Width / 60 == Map.MapSize.Width, "Map size misconfigured?");
            Debug.Assert(EntireMap.Height / 30 == Map.MapSize.Height, "Map size misconfigured?");

            var visibleX = Map.LocalSize.X - Map.MapSize.X;
            var visibleY = Map.LocalSize.Y - Map.MapSize.Y;

            VisibleMap = new Rectangle(EntireMap.X + visibleX * 60 - 30, EntireMap.Y + visibleY * 30 - 15, Map.LocalSize.Width * 60 + 60, Map.LocalSize.Height * 30 + 30);

            ScreenArea = new Rectangle(VisibleMap.X, VisibleMap.Y, Width, Height);
        }
Exemple #2
0
 public MapClass(String filename)
 {
     MapFile = new MAP(FileSystem.LoadFile(filename));
     Instance = this;
 }
Exemple #3
0
 public MapClass(String filename)
 {
     MapFile  = new MAP(FileSystem.LoadFile(filename));
     Instance = this;
 }
Exemple #4
0
 internal CellIterator(MapClass _Map)
 {
     Map = _Map;
     NextX = 1;
     NextY = Map.MapRect.Width;
     CurrentY = NextY - 1;
     CurrentCellIndex = 512 * NextY + 1;
 }
Exemple #5
0
        void form_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            if (e.Data.GetDataPresent(System.Windows.Forms.DataFormats.FileDrop)) {
                string[] files = (string[])e.Data.GetData(System.Windows.Forms.DataFormats.FileDrop);

                if (files != null) {
                    lock (plock) {
                        var file = files[0];
                        var ext = Path.GetExtension(file).ToUpper();

                        switch (ext) {
                            //case ".PAL":
                            //    MousePalette = new PAL(file);

                            //    break;

                            //case ".SHP":
                            //case ".SHA":
                            //    MouseFrame = -1;

                            //    MouseTextures = new SHP(file);
                            //    if (MousePalette == null) {
                            //        MousePalette = PAL.GrayscalePalette;
                            //    }
                            //    MouseTextures.ApplyPalette(MousePalette);
                            //    break;

                            //case ".INI":
                            //    INIFile = new INI(file);

                            //    break;

                            //case ".HVA":
                            //    var H = new HVA(file);

                            //    Console.WriteLine("Loaded HVA with {0} sections", H.Sections.Count);
                            //    break;

                            //case ".VXL":
                            //    LoadedVoxels.Clear();
                            //    VoxelFrame = 0;

                            //    var body = VoxLib.Create(file);
                            //    if (body != null) {
                            //        var turname = file.Replace(Path.GetExtension(file), "tur.vxl");
                            //        var turret = VoxLib.Create(turname);

                            //        var barlname = file.Replace(Path.GetExtension(file), "barl.vxl");
                            //        var barrel = VoxLib.Create(barlname);

                            //        VoxelChanged = true;

                            //        LoadedVoxels.Add(body);
                            //        if (turret != null) {
                            //            LoadedVoxels.Add(turret);
                            //        }
                            //        if (barrel != null) {
                            //            LoadedVoxels.Add(barrel);
                            //        }

                            //        Console.WriteLine("Loaded VXL with {0} sections", LoadedVoxels.Sum(v => v.Voxel.Sections.Count));
                            //    }
                            //    break;

                            case ".YRM":
                            case ".MAP":
                                Map = new MapClass(file);

                                LoadMap();

                                if (MapTexture != null) {
                                    MapTexture.Dispose();
                                    MapTexture = null;
                                }

                                break;

                            //case ".CSF":
                            //    var lbl = new CSF(file);

                            //    Console.WriteLine("Loaded string table with {0} entries", lbl.Labels.Count);

                            //    break;

                            //case ".IDX":
                            //    var idx = new IDX(file);

                            //    Console.WriteLine("Loaded IDX with {0} samples", idx.Samples.Count);

                            //    var bagFile = file.Replace(Path.GetExtension(file), ".BAG");
                            //    if (File.Exists(bagFile)) {
                            //        var Bag = new BAG(bagFile);
                            //        idx.ReadBAG(Bag);

                            //        var soundPlayer = new libZPlay.ZPlay();

                            //        var samplesToExtract = new List<String>() { /*"ichratc", */"ichratta" };

                            //        foreach (var s in samplesToExtract) {
                            //            var sample = idx.Samples[s];
                            //            if (sample != null) {
                            //                var output = sample.GetWaveHeader().Compile();

                            //                var outFile = Path.GetDirectoryName(file) + Path.DirectorySeparatorChar + sample.Name + ".WAV";

                            //                using (var outWav = File.OpenWrite(outFile)) {
                            //                    using (var writer = new BinaryWriter(outWav)) {
                            //                        writer.Write(output);
                            //                        writer.Flush();
                            //                    }
                            //                }

                            //                if (!soundPlayer.OpenStream(false, false, ref output, (uint)output.Length, libZPlay.TStreamFormat.sfWav)) {
                            //                    Console.WriteLine("Sound failed: {0}.", soundPlayer.GetError());
                            //                    break;
                            //                }

                            //                if (!soundPlayer.StartPlayback()) {
                            //                    Console.WriteLine("Sound failed: {0}.", soundPlayer.GetError());
                            //                    break;
                            //                }

                            //            }
                            //        }
                            //    }

                            //    break;
                        }

                    }
                }
            }
        }