Exemplo n.º 1
0
    IEnumerator UpdateList(string sourceUrl, bool clearList = false)
    {
        if (clearList)
        {
            currentAssetInfoList.items = new AssetInfo[0];
            totalPages = 0;
            SetPage(0);
            MasterController.Instance.StageManager.ClearStage();
        }
        lastUpdate = DateTime.Now;
        WWW www = new WWW(sourceUrl.Replace(" ", "%20"));

        yield return(www);

        if (www.error == null)
        {
            currentAssetInfoList = AssetInfoList.CreateFromJSON(www.text);

            totalPages = currentAssetInfoList.items.Length / itemsPerPage + 1;

            SetPage(currentPage);

            if (ListUpdated != null)
            {
                ListUpdated();
            }
        }
        else
        {
            Debug.LogError("WWW error: " + www.error);
        }
    }
Exemplo n.º 2
0
        private void BtnSelectManifestDatabase_Click(object sender, EventArgs e)
        {
            ofd.FileName        = string.Empty;
            ofd.CheckFileExists = true;
            ofd.ValidateNames   = true;
            ofd.ShowReadOnly    = false;
            ofd.ReadOnlyChecked = false;
            ofd.Filter          = "Manifest Database (*.data)|*.data";

            var r = ofd.ShowDialog(this);

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

            var           filePath = ofd.FileName;
            var           bytes    = File.ReadAllBytes(filePath);
            AssetInfoList assetInfoList;

            try {
                assetInfoList = AssetInfoList.Parse(bytes, MltdConstants.Utf8WithoutBom);
            } catch (Exception ex) {
                MessageBox.Show(ex.ToString(), ApplicationHelper.GetApplicationTitle(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            txtManifestDatabasePath.Text = filePath;

            _assetInfoList = assetInfoList;

            BtnManifestReset_Click(sender, e);
        }
Exemplo n.º 3
0
        public FManifest([NotNull] AssetInfoList manifest, [NotNull] ManifestOpening opening, [CanBeNull] DownloadConfig downloadConfig)
        {
            Manifest            = manifest;
            _opening            = opening;
            _downloadConfig     = downloadConfig;
            _downloadPendingSet = new HashSet <TreeListItem>();

            InitializeComponent();
            RegisterEventHandlers();
            InitializeControls();
        }
Exemplo n.º 4
0
        public static void UpdateCatalog(string baseDataPath)
        {
            if (updatingAssetInfos)
            {
                return;
            }
            updatingAssetInfos = true;
            try
            {
                if (!Directory.Exists(baseDataPath + "\\"))
                {
                    Directory.CreateDirectory(baseDataPath + "\\");
                }

                foreach (var subFolderPath in Directory.GetDirectories(baseDataPath))
                {
                    var bundlesPath = subFolderPath + "\\Bundles";
                    if (!Directory.Exists(bundlesPath + "\\"))
                    {
                        Directory.CreateDirectory(bundlesPath + "\\");
                    }

                    var assetInfos = new AssetInfoList()
                    {
                        UpdatedDateTime = DateTime.Now.ToString(),
                        items           = new List <AssetInfo>()
                    };
                    foreach (var bundlePath in Directory.GetDirectories(bundlesPath))
                    {
                        if (File.Exists(bundlePath + "\\bundleInfo.json"))
                        {
                            using (FileStream stream = new FileStream(bundlePath + "\\bundleInfo.json", FileMode.Open, FileAccess.Read))
                            {
                                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(AssetInfo));
                                assetInfos.items.Add((AssetInfo)ser.ReadObject(stream));
                            }
                        }
                    }
                    using (FileStream stream = new FileStream(bundlesPath + "\\" + "bundles.json", FileMode.OpenOrCreate, FileAccess.Write))
                    {
                        stream.SetLength(0);
                        DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(AssetInfoList));
                        ser.WriteObject(stream, assetInfos);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("*** Exception updating infos {0}", ex.Message);
                Console.ResetColor();
            }
            finally { updatingAssetInfos = false; }
        }
Exemplo n.º 5
0
        public void AddItems([NotNull] AssetInfoList assetInfoList)
        {
            lv.BeginUpdate();
            tv.BeginUpdate();

            foreach (var assetInfo in assetInfoList.Assets)
            {
                AddItem(assetInfo);
            }

            tv.EndUpdate();
            lv.EndUpdate();
        }
Exemplo n.º 6
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.º 7
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.º 8
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();
        }
Exemplo n.º 9
0
        private void BtnSelectCardsDatabase_Click(object sender, EventArgs e)
        {
            ofd.FileName        = string.Empty;
            ofd.CheckFileExists = true;
            ofd.ValidateNames   = true;
            ofd.ShowReadOnly    = false;
            ofd.ReadOnlyChecked = false;
            ofd.Filter          = "Manifest Database (*.data)|*.data";

            var r = ofd.ShowDialog(this);

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

            var           filePath = ofd.FileName;
            var           bytes    = File.ReadAllBytes(filePath);
            AssetInfoList assetInfoList;

            try {
                assetInfoList = AssetInfoList.Parse(bytes, MltdConstants.Utf8WithoutBom);
            } catch (Exception ex) {
                MessageBox.Show(ex.ToString(), ApplicationHelper.GetApplicationTitle(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            txtCardsDatabasePath.Text = filePath;

            lvwCards.Items.Clear();

            var cardNameRegex = new Regex(@"^card_list_(?<idolIndex>\d{3})(?<idolAbbr>[a-z]{3})(?<ser>\d{4})\.acb\.unity3d$", RegexOptions.CultureInvariant);
            var cardList      = _cardList;
            var idols         = MltdConstants.Idols;

            cardList.Clear();

            foreach (var assetInfo in assetInfoList.Assets)
            {
                var match = cardNameRegex.Match(assetInfo.ResourceName);

                if (!match.Success)
                {
                    continue;
                }

                var idolID           = Convert.ToInt32(match.Groups["idolIndex"].Value);
                var detectedIdolAbbr = match.Groups["idolAbbr"].Value;

                if (idolID < 1 || idolID > idols.Count)
                {
                    Debug.Print("Warning: idol index out of range: {0} with abbr {1}", idolID, detectedIdolAbbr);
                    continue;
                }

                var idol = idols[idolID - 1];

                if (idol.Abbreviation != detectedIdolAbbr)
                {
                    Debug.Print("Warning: detected abbr {0} does not match standard abbr {1}.", detectedIdolAbbr, idol.Abbreviation);
                    continue;
                }

                var serial    = match.Groups["ser"].Value;
                var serialInt = Convert.ToInt32(serial);
                var rarity    = (Rarity)(serialInt % 10);
                serial = TheaterHelper.GetIdolSerialAbbreviation(idolID) + serial;
                var entry = (idol.Name, idol.Color, rarity, serial);

                cardList.Add(entry);
            }

            foreach (var entry in cardList)
            {
                var lvi = lvwCards.Items.Add(entry.Idol);
                lvi.SubItems.Add(entry.Color.ToString());
                lvi.SubItems.Add(entry.Rarity.ToString());
                lvi.SubItems.Add(entry.Serial);
            }

            lvwCards.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
        }