Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                PrintUsage();
                return;
            }

            var data = File.ReadAllBytes(args[0]);

            var b = AssetInfoList.TryParse(data, MltdConstants.Utf8WithoutBom, out var assetInfoList);

            if (!b || assetInfoList == null)
            {
                Console.WriteLine("Manifest parsing failed.");
                return;
            }

            string outputFilePath;

            if (args.Length > 1)
            {
                outputFilePath = args[1];
            }
            else
            {
                var fileInfo = new FileInfo(args[0]);
                outputFilePath = fileInfo.FullName + ".txt";
            }

            using (var writer = new StreamWriter(outputFilePath, false, MltdConstants.Utf8WithoutBom)) {
                writer.WriteLine("Asset count: {0}", assetInfoList.Assets.Count);

                foreach (var asset in assetInfoList.Assets)
                {
                    writer.WriteLine();
                    writer.WriteLine("Resource name: {0}", asset.ResourceName);
                    writer.WriteLine("Resource hash: {0}", asset.ContentHash);
                    writer.WriteLine("Remote name: {0}", asset.RemoteName);
                    writer.WriteLine("File size: {0} ({1})", asset.Size, MathUtilities.GetHumanReadableFileSize(asset.Size));
                }
            }
        }
Exemplo n.º 2
0
        private void MnuFileOpenLocal_Click(object sender, EventArgs e)
        {
            ofd.CheckFileExists              = true;
            ofd.DereferenceLinks             = true;
            ofd.Filter                       = "Asset Database (*.data)|*.data";
            ofd.Multiselect                  = false;
            ofd.ReadOnlyChecked              = false;
            ofd.ShowReadOnly                 = false;
            ofd.SupportMultiDottedExtensions = true;
            ofd.ValidateNames                = true;

            var r = ofd.ShowDialog(this);

            if (r == DialogResult.Cancel)
            {
                return;
            }

            var filePath = ofd.FileName;
            var data     = File.ReadAllBytes(filePath);

            var b = AssetInfoList.TryParse(data, out var assetInfoList);

            if (!b)
            {
                var message = $"'{filePath}' is not a valid asset database file.";
                MessageBox.Show(message, ApplicationHelper.GetApplicationTitle(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            Debug.Assert(assetInfoList != null);

            var opening = ManifestOpening.Local(filePath);

            var form = new FManifest(assetInfoList, opening, null);

            form.MdiParent = this;

            form.Show();
        }
Exemplo n.º 3
0
        private async void MnuFileOpenRemote_Click(object sender, EventArgs e)
        {
            var(r, config) = FManifestDownload.ShowModal(this);

            if (r == DialogResult.Cancel)
            {
                return;
            }

            Debug.Assert(config != null);

            byte[] assetInfoListData;

            try {
                assetInfoListData = await TDDownloader.DownloadData(config.ResourceVersion, config.ManifestAssetName);
            } catch (Exception ex) {
                MessageBox.Show(ex.ToString(), ApplicationHelper.GetApplicationTitle(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var b = AssetInfoList.TryParse(assetInfoListData, out var assetInfoList);

            if (!b)
            {
                const string message = "Received data is not a valid asset database file.";
                MessageBox.Show(message, ApplicationHelper.GetApplicationTitle(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            Debug.Assert(assetInfoList != null);

            var opening = ManifestOpening.Remote(config.ResourceVersion, config.IsLatest);

            var form = new FManifest(assetInfoList, opening, config);

            form.MdiParent = this;

            form.Show();
        }