Ejemplo n.º 1
0
        /// <summary>
        /// Loads a database arz file.
        /// </summary>
        private void LoadARZFile()
        {
            if (TQDebug.DatabaseDebugLevel > 0)
            {
                Log.LogDebug("Database.LoadARZFile()");
            }

            // from the original TQ folder
            string file = Path.Combine(Path.Combine(GamePathResolver.TQPath, "Database"), "database.arz");

            if (TQDebug.DatabaseDebugLevel > 1)
            {
                Log.LogDebug("Load Titan Quest database arz file");
                Log.LogDebug("file = {0}", file);
            }

            this.ArzFile = new ArzFile(file);
            arzProv.Read(this.ArzFile);

            // now Immortal Throne expansion pack
            this.ArzFileIT = this.ArzFile;

            // Added to load a custom map database file.
            if (GamePathResolver.IsCustom)
            {
                file = Path.Combine(GamePathResolver.MapName, "database", $"{Path.GetFileName(GamePathResolver.MapName)}.arz");

                if (TQDebug.DatabaseDebugLevel > 1)
                {
                    Log.LogDebug("Load Custom Map database arz file");
                    Log.LogDebug("file = {0}", file);
                }

                if (File.Exists(file))
                {
                    this.ArzFileMod = new ArzFile(file);
                    arzProv.Read(this.ArzFileMod);
                }
                else
                {
                    this.ArzFileMod = null;
                }
            }

            if (TQDebug.DatabaseDebugLevel > 0)
            {
                Log.LogDebug("Exiting Database.LoadARZFile()");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Opens a file and updates the tree view.
        /// </summary>
        /// <param name="filename">Name of the file we want to open.</param>
        private void OpenFile(string filename)
        {
            if (string.IsNullOrEmpty(filename))
            {
                return;
            }

            this.sourceFile = filename;
            string fullSrcPath = null;


            if (string.IsNullOrEmpty(this.sourceFile))
            {
                MessageBox.Show("You must enter a valid source file path.");
                return;
            }

            // See if path exists and create it if necessary
            if (!string.IsNullOrEmpty(this.sourceFile))
            {
                fullSrcPath = Path.GetFullPath(this.sourceFile);
            }

            if (!File.Exists(fullSrcPath))
            {
                // they did not give us a file
                MessageBox.Show("You must specify a file!");
                return;
            }

            // Try to read it as an ARC file since those have a header.
            arcFile = new ArcFile(this.sourceFile);
            if (arcProv.Read(arcFile))
            {
                fileType = CompressedFileType.ArcFile;
            }
            else
            {
                arcFile  = null;
                fileType = CompressedFileType.Unknown;
            }

            // Try reading the file as an ARZ file.
            if (fileType == CompressedFileType.Unknown)
            {
                // Read our ARZ file into memory.
                arzFile = new ArzFile(this.sourceFile);
                if (arzProv.Read(arzFile))
                {
                    fileType = CompressedFileType.ArzFile;
                }
                else
                {
                    arzFile  = null;
                    fileType = CompressedFileType.Unknown;
                }
            }

            // We failed reading the file
            // so we just clear everything out.
            if (fileType == CompressedFileType.Unknown)
            {
                this.Text = this.titleText;
                this.treeViewTOC.Nodes.Clear();
                this.selectedFileToolStripMenuItem.Enabled = false;
                this.allFilesToolStripMenuItem.Enabled     = false;
                this.textBoxDetails.Lines = null;
                MessageBox.Show(string.Format("Error Reading {0}", this.sourceFile));
                return;
            }

            this.selectedFileToolStripMenuItem.Enabled   = true;
            this.allFilesToolStripMenuItem.Enabled       = true;
            this.hideZeroValuesToolStripMenuItem.Enabled = fileType == CompressedFileType.ArzFile;

            this.Text = string.Format("{0} - {1}", this.titleText, this.sourceFile);

            this.textBoxDetails.Lines   = null;
            this.pictureBoxItem.Visible = false;

            this.BuildTreeView();
        }