Exemplo n.º 1
0
        /// <summary>
        /// Opens file from given path.
        /// </summary>
        /// <param name="filePath"></param>
        private void OpenFile(string filePath)
        {
            try
            {
                _openFile     = DataDogFile.Read(filePath);
                _openFilePath = filePath;

                this.Text = filePath + " - " + this.Title;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Failed to open file. Error: " + ex.Message, this.Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.CboList.Items.Clear();
            this.CboList.Items.Add("All lists");
            foreach (var listName in _openFile.Lists.Keys)
            {
                this.CboList.Items.Add(listName);
            }

            this.CboList.SelectedIndex = 0;
            this.CboList.Enabled       = true;
            this.BtnExportXml.Enabled  = true;

            if (_openFile.Lists.Count == 1)
            {
                this.CboList.SelectedIndex = 1;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads tiles from given stream of a data dog file.
        /// </summary>
        /// <param name="stream"></param>
        public static void Load(Stream stream)
        {
            var dataDogFile = DataDogFile.Read(stream);

            if (!dataDogFile.Lists.TryGetValue("TileList", out var objList))
            {
                throw new ArgumentException($"DataDog object list 'TileList' not found in file.");
            }

            foreach (var obj in objList.Objects)
            {
                var entry = new TileIndexEntry();

                entry.TileID        = (int)obj.Fields["TileID"].Value;
                entry.TileName      = (string)obj.Fields["TileName"].Value;
                entry.BillBoardName = (string)obj.Fields["BillBoardName"].Value;

                // Conditional reading of Property, as it doesn't exist in
                // KR281.
                if (obj.Fields.TryGetValue("Property", out var property))
                {
                    entry.Property = (byte)property.Value;
                }

                _entries[entry.TileID] = entry;
            }
        }