Пример #1
0
        static Cartographer() {
            var relativeFilePath = DatDigger.Utilities.DataFileIdToRelativePath(mapSheetFileId);
            var filePath = System.IO.Path.Combine(Properties.Settings.Default.GameDirectory, relativeFilePath);
            var cd = Directory.GetCurrentDirectory();
            Directory.SetCurrentDirectory(Properties.Settings.Default.GameDirectory);
            using (var fs = File.OpenRead(filePath))
            {
                var fileLoader = new DatDigger.FileLoaders.SheetLoader();
                fileLoader.ReadFile(fs);

                var dataLoader = new DatDigger.FileLoaders.SheetDataLoader();
                dataLoader.ReadSheet(fileLoader.Sheets[0]);

                mapDataTable = dataLoader.Data;
                mapData = new List<MapData>();
                for (var i = 0; i < mapDataTable.Rows.Count; i++)
                {
                    DataRow row = mapDataTable.Rows[i];
                    var md = new MapData();
                    md.ID = (int)row[0];
                    md.Folder = (int)row[1];
                    md.ParentId = (int)row[2];
                    md.Unknown1 = (int)row[3];
                    md.Unknown2 = (int)row[4];
                    md.Width = (int)row[5];
                    md.Height = (int)row[6];
                    mapData.Add(md);
                }
            }
            Directory.SetCurrentDirectory(cd);
        }
Пример #2
0
        static Cartographer()
        {
            var relativeFilePath = DatDigger.Utilities.DataFileIdToRelativePath(mapSheetFileId);
            var filePath = System.IO.Path.Combine(Properties.Settings.Default.GameDirectory, relativeFilePath);
            var cd = Directory.GetCurrentDirectory();
            Directory.SetCurrentDirectory(Properties.Settings.Default.GameDirectory);
            using (var fs = File.OpenRead(filePath))
            {
                var fileLoader = new DatDigger.FileLoaders.SheetLoader();
                fileLoader.ReadFile(fs);

                var dataLoader = new DatDigger.FileLoaders.SheetDataLoader();
                dataLoader.ReadSheet(fileLoader.Sheets[0]);

                mapDataTable = dataLoader.Data;
                mapData = new List<MapData>();
                for (var i = 0; i < mapDataTable.Rows.Count; i++)
                {
                    DataRow row = mapDataTable.Rows[i];
                    var md = new MapData();
                    md.ID = (int)row[0];
                    md.Folder = (int)row[1];
                    md.ParentId = (int)row[2];
                    md.Unknown1 = (int)row[3];
                    md.Unknown2 = (int)row[4];
                    md.Width = (int)row[5];
                    md.Height = (int)row[6];
                    mapData.Add(md);
                }
            }
            Directory.SetCurrentDirectory(cd);
        }
Пример #3
0
        public static DataTable LoadSingleSheet(int fileId)
        {
            string xmlPath = DatDigger.Utilities.DataFileIdToPath(fileId);

            List<DatDigger.Xml.Sheet> sheets;
            using (FileStream stream = File.Open(xmlPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                var loader = new DatDigger.FileLoaders.SheetLoader();
                if (!loader.ReadFile(stream))
                {
                    throw new InvalidOperationException("Unable to load XML from " + xmlPath);
                }

                sheets = loader.Sheets;
            }

            if (sheets.Count != 1)
            {
                throw new InvalidOperationException("Unexpected number of sheets - expected 1, found " + sheets.Count.ToString());
            }

            var r = new DatDigger.FileLoaders.SheetDataLoader();
            if (!r.ReadSheet(sheets[0]))
            {
                throw new InvalidOperationException("Unable to load data from sheet");
            }

            return r.Data;
        }
Пример #4
0
        public static DataTable LoadSingleSheet(int fileId)
        {
            string xmlPath = DatDigger.Utilities.DataFileIdToPath(fileId);

            List <DatDigger.Xml.Sheet> sheets;

            using (FileStream stream = File.Open(xmlPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                var loader = new DatDigger.FileLoaders.SheetLoader();
                if (!loader.ReadFile(stream))
                {
                    throw new InvalidOperationException("Unable to load XML from " + xmlPath);
                }

                sheets = loader.Sheets;
            }

            if (sheets.Count != 1)
            {
                throw new InvalidOperationException("Unexpected number of sheets - expected 1, found " + sheets.Count.ToString());
            }

            var r = new DatDigger.FileLoaders.SheetDataLoader();

            if (!r.ReadSheet(sheets[0]))
            {
                throw new InvalidOperationException("Unable to load data from sheet");
            }

            return(r.Data);
        }
Пример #5
0
        public static DataTable LoadLanguageSheet(int fileId, Language lang)
        {
            string xmlPath = DatDigger.Utilities.DataFileIdToPath(fileId);

            List <DatDigger.Xml.Sheet> sheets;

            using (FileStream stream = File.Open(xmlPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                var loader = new DatDigger.FileLoaders.SheetLoader();
                if (!loader.ReadFile(stream))
                {
                    throw new InvalidOperationException("Unable to load XML from " + xmlPath);
                }

                sheets = loader.Sheets;
            }

            Xml.Sheet sheet = null;
            foreach (var s in sheets)
            {
                if (s.Language == lang)
                {
                    sheet = s;
                    break;
                }
            }

            if (sheet == null)
            {
                throw new InvalidOperationException("Could not find sheet with language " + lang + " in XML " + xmlPath);
            }

            var r = new DatDigger.FileLoaders.SheetDataLoader();

            if (!r.ReadSheet(sheet))
            {
                throw new InvalidOperationException("Unable to load data from sheet");
            }

            return(r.Data);
        }
Пример #6
0
        public static DataTable LoadLanguageSheet(int fileId, Language lang)
        {
            string xmlPath = DatDigger.Utilities.DataFileIdToPath(fileId);

            List<DatDigger.Xml.Sheet> sheets;
            using (FileStream stream = File.Open(xmlPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                var loader = new DatDigger.FileLoaders.SheetLoader();
                if (!loader.ReadFile(stream))
                {
                    throw new InvalidOperationException("Unable to load XML from " + xmlPath);
                }

                sheets = loader.Sheets;
            }

            Xml.Sheet sheet = null;
            foreach (var s in sheets)
            {
                if (s.Language == lang)
                {
                    sheet = s;
                    break;
                }
            }

            if (sheet == null)
            {
                throw new InvalidOperationException("Could not find sheet with language " + lang + " in XML " + xmlPath);
            }

            var r = new DatDigger.FileLoaders.SheetDataLoader();
            if (!r.ReadSheet(sheet))
            {
                throw new InvalidOperationException("Unable to load data from sheet");
            }

            return r.Data;
        }