Ejemplo n.º 1
0
        /// <summary>
        /// Unzip DLC, only if tmp folder doesn't already exist
        /// </summary>
        /// <param name="dlcs"></param>
        private void UnzipDLC(string dlcDir, DLC dlc)
        {
            string dlcCode            = dlc.DLCFile.Replace(".dlc", "");
            string newDlcAbsolutePath = Path.Combine(dlcDir, dlcCode);

            if (!Directory.Exists(newDlcAbsolutePath))
            {
                logger.LogInformation(string.Format("Extracting {0} to {1}", dlc.Name, newDlcAbsolutePath));
                // Filter only portraits files, to gain speed/space
                using (var zip = ZipFile.OpenRead(dlc.AbsolutePath))
                {
                    var filteredEntries = zip.Entries
                                          .Where(e => e.Length > 0)
                                          .Where(e => DlcEntryFilters.Any(r => r.IsMatch(e.FullName)));
                    foreach (var entry in filteredEntries)
                    {
                        var fi = new FileInfo(Path.Combine(newDlcAbsolutePath, entry.FullName));
                        fi.Directory.CreateSubdirectory(".");

                        entry.ExtractToFile(fi.FullName);
                    }
                }
                //ZipFile.ExtractToDirectory(dlc.AbsolutePath, newDlcAbsolutePath, fileFilter);

                // In any case, create the directory, so that it is ignored for next load.
                Directory.CreateDirectory(newDlcAbsolutePath);
            }
            dlc.AbsolutePath = newDlcAbsolutePath;
        }
Ejemplo n.º 2
0
 public FormDLC(DLC dlc, List <Version> versions)
 {
     InitializeComponent();
     this.dlc      = dlc;
     this.versions = versions;
     RefreshData();
 }
 private void InitIsStart(int code, string message)
 {
     if (code == SUCCESS)
     {
         DLC.IsDlcReady(IsReadyHandler);
     }
 }
Ejemplo n.º 4
0
        public List <DLC> ParseFolder(string folder)
        {
            List <DLC> dlcs = new List <DLC>();

            DirectoryInfo dir = new DirectoryInfo(folder);

            if (dir.Exists)
            {
                FileInfo[] dlcFiles = dir.GetFiles("*.dlc");
                if (dlcFiles.Length == 0)
                {
                    logger.Error(string.Format("No DLC files found in folder: {0}", dir.FullName));
                }

                foreach (FileInfo dlcFile in dlcFiles)
                {
                    DLC dlc = Parse(dlcFile.FullName);
                    if (dlc != null && dlc.Archive != null)
                    {
                        // Note: path will be overriden when extracting the archive
                        dlc.AbsolutePath = Path.Combine(folder, dlc.Archive.Substring("dlc".Length + 1)); // Remove "dlc/" from path
                        dlcs.Add(dlc);
                    }
                }
            }
            else
            {
                logger.Error(string.Format("Folder not found: {0}", dir.FullName));
            }
            return(dlcs);
        }
Ejemplo n.º 5
0
        // 実行ボタンが押された
        private void ExecuteButton_Click(object sender, EventArgs e)
        {
            ReleaseGenerator ReleaseGen = new ReleaseGenerator(AutomationToolPath, TargetPlatform);

            if (!ReleaseGen.Execute())
            {
                MessageBox.Show("リリースの生成に失敗しました。");
                return;
            }

            Console.WriteLine("リリースを生成しました。\n\n");

            var DLCList = DLCListBox.CheckedItems;

            foreach (var DLC in DLCList)
            {
                string       DLCName = DLC.ToString();
                DLCGenerator DLCGen  = new DLCGenerator(AutomationToolPath, DLCName, TargetPlatform);
                if (!DLCGen.Execute())
                {
                    MessageBox.Show(DLCName + "のDLC生成に失敗しました。");
                    return;
                }
                Console.WriteLine(DLCName + "のDLCを生成しました。\n\n");
            }

            MessageBox.Show("完了しました。");
        }
Ejemplo n.º 6
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        DLC dlc = (DLC)target;

        isValid = ValidateScene(dlc.sceneName);

        if (dlc.sceneName != null && dlc.sceneName != "")
        {
            if (!isValid)
            {
                EditorGUILayout.HelpBox("It seems that such a scene does not exist. \n" +
                                        "If it exists, make sure to add it to the scenes in the build settings!",
                                        MessageType.Error);
            }
        }
        else
        {
            EditorGUILayout.HelpBox("WARNING: No Scene name!", MessageType.Error);
        }

        if (GUILayout.Button("Validate Scene"))
        {
            ValidateScene(dlc.sceneName);
        }
    }
Ejemplo n.º 7
0
        public DLC AddDLC(int accountId, [FromBody] DLC dlc)
        {
            dlc.AccountId = accountId;

            var entity = DB.DLC.Add(dlc);

            return(entity);
        }
Ejemplo n.º 8
0
        private Book CheckNewBookEntry()
        {
            DLC  dlcSaveTo = null;
            Book NewBook   = null;

            try
            {
                string basePath = Path.Combine(LibraryLocation, baseval1, baseval2);
                if (DLCs.Any())
                {
                    Book[] emptyBooks = DLCs.SelectMany(o =>
                                                        o.Books.Where(b => !b.FileExists).Select(i => i)).ToArray();
                    if (emptyBooks.Any())
                    {
                        NewBook = emptyBooks.FirstOrDefault();
                    }
                    else
                    {
                        dlcSaveTo = DLCs.OrderByDescending(d => d.RootPath).FirstOrDefault();
                        int maxBookIndex = dlcSaveTo.Books.Any() ? dlcSaveTo.Books.Max(m => m.Index) : 0;
                        if (dlcSaveTo.Index == 7 && maxBookIndex == 7)
                        {
                            MessageBox.Show("Reader Book Limit has been reached!");
                            return(null);
                        }
                        if (maxBookIndex == 99)
                        {
                            int newDLCIndex = dlcSaveTo.Index + 1;
                            dlcSaveTo = new DLC {
                                Index    = newDLCIndex,
                                RootPath = Path.Combine(Path.GetDirectoryName(dlcSaveTo.RootPath), string.Concat(DLCBookTitleBase, newDLCIndex.ToString())),
                                Books    = new List <Book>()
                            };
                            NewBook = new Book {
                                Index = 1, DLCPath = dlcSaveTo.RootPath, DLCIndex = dlcSaveTo.Index
                            };
                        }
                        else
                        {
                            if (dlcSaveTo.Index == 1 && maxBookIndex == 0)
                            {
                                maxBookIndex = 1;
                            }
                            NewBook = new Book {
                                Index = maxBookIndex + 1, DLCPath = dlcSaveTo.RootPath, DLCIndex = dlcSaveTo.Index
                            };
                        }
                    }
                }
                return(NewBook);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(null);
            }
        }
Ejemplo n.º 9
0
        public DLC UpdateDLC(int dlcID, [FromBody] DLC dlc)
        {
            dlc.Id = dlcID;
            DB.DLC.Update(dlc);

            var updateDLC = DB.DLC.Find(dlcID);

            return(updateDLC);
        }
Ejemplo n.º 10
0
 private void buttonDelDLC_Click(object sender, EventArgs e)
 {
     if (listViewDLCs.SelectedIndices.Count == 1)
     {
         DLC dlc = (DLC)listViewDLCs.SelectedItems[0].Tag;
         dlcs.Remove(dlc);
         DrawDLCs();
         RefreshOthers();
     }
 }
        public DLC UpdateDLC(int dlcID, int accountId, [FromBody] DLC dlc)
        {
            dlc.Id        = dlcID;
            dlc.AccountId = accountId;
            DB.DLC.Update(dlc);

            var updateDLC = DB.DLC.Find(dlcID);

            return(updateDLC);
        }
Ejemplo n.º 12
0
        private static DLC Parse(string filename)
        {
            var dlcFile = new FileInfo(filename);

            Debug.Assert(dlcFile.Exists);

            var dlc = new DLC(dlcFile.Name);

            foreach (var line in File.ReadLines(filename, WesternEncoding).Where(l => !l.StartsWith("#")))
            {
                if (line.StartsWith("name"))
                {
                    dlc.Name = line.Split('=')[1].Split('#')[0].Replace("\"", "").Trim();
                }
                if (line.StartsWith("archive"))
                {
                    dlc.Archive = line.Split('=')[1].Split('#')[0].Replace("\"", "").Trim();
                }
                if (line.StartsWith("checksum"))
                {
                    dlc.Checksum = line.Split('=')[1].Split('#')[0].Replace("\"", "").Trim();
                }

                if (line.StartsWith("steam_id"))
                {
                    if (int.TryParse(line.Split('=')[1].Split('#')[0].Replace("\"", "").Trim(), out int intOut))
                    {
                        dlc.SteamID = intOut;
                    }
                    else
                    {
                        logger.LogError(string.Format("Error parsing Steam ID in file: {0}", dlcFile.Name));
                    }
                }

                if (line.StartsWith("gamersgate_id"))
                {
                    if (int.TryParse(line.Split('=')[1].Split('#')[0].Replace("\"", "").Trim(), out int intOut))
                    {
                        dlc.GamersGateID = intOut;
                    }
                    else
                    {
                        logger.LogError(string.Format("Error parsing GamersGate ID in file: {0}", dlcFile.Name));
                    }
                }

                if (line.StartsWith("affects_checksum"))
                {
                    dlc.AffectsChecksum = line.Split('=')[1].Split('#')[0].Replace("\"", "").Trim() == "yes";
                }
            }
            return(dlc);
        }
Ejemplo n.º 13
0
        private void buttonAddDLC_Click(object sender, EventArgs e)
        {
            DLC     dlc  = new DLC();
            FormDLC form = new FormDLC(dlc, versions);

            if (form.ShowDialog() == DialogResult.OK)
            {
                dlcs.Add(dlc);
                DrawDLCs();
                RefreshOthers();
            }
        }
    public void UpdateDLCList()
    {
        var dlcCount = DLC.GetCount();

        dlcList = new Dictionary <string, bool>();
        for (int i = 0; i < dlcCount; i++)
        {
            var dlcAppId       = "";
            var isDLCAvailable = false;
            DLC.GetIsAvailable(i, out dlcAppId, out isDLCAvailable);
            dlcList.Add(dlcAppId, isDLCAvailable);
        }
    }
Ejemplo n.º 15
0
 private void buttonChangeDLC_Click(object sender, EventArgs e)
 {
     if (listViewDLCs.SelectedIndices.Count == 1)
     {
         DLC     dlc  = (DLC)listViewDLCs.SelectedItems[0].Tag;
         FormDLC form = new FormDLC(dlc, versions);
         if (form.ShowDialog() == DialogResult.OK)
         {
             DrawDLCs();
             RefreshOthers();
         }
     }
 }
Ejemplo n.º 16
0
        private void ShowBooks(DLC dLC)
        {
            List <Control> bookCovers = new List <Control>();

            flpCategories.Controls.Clear();
            dLC.Books.Where(b => b.FileExists).ToList().ForEach(b =>
            {
                Button btn = new Button();
                btn.Text   = b.Title + " - " + b.Authors[0].Author;
                if (b.Model == 0)
                {
                    btn.Size = new Size(177, 250);
                }
                else if (b.Model == 1)
                {
                    btn.Size = new Size(350, 250);
                }
                btn.ForeColor = Color.BlueViolet;
                try
                {
                    using (FileStream stream = new FileStream(Path.Combine(b.FilePath, "cover.jpg"), FileMode.Open, FileAccess.Read))
                    {
                        btn.Image = Image.FromStream(stream);
                        stream.Dispose();
                        btn.Image = ResizeImage(btn.Image, btn.Size);
                    }
                }
                catch { }
                btn.Tag = b.Index;

                CheckBox chb        = new CheckBox();
                chb.Parent          = btn;
                chb.Size            = new Size(15, 14);
                chb.Location        = new Point(5, (btn.Height - chb.Height) - 3);
                chb.TextAlign       = ContentAlignment.MiddleLeft;
                chb.TextAlign       = ContentAlignment.MiddleRight;
                chb.Tag             = b.Index;
                chb.CheckedChanged += chb_CheckedChanged;

                bookCovers.Add(btn);
                btn.Click     += btn_Click;
                btn.MouseDown += new MouseEventHandler(this.btn_Click);
            });
            flpCategories.Controls.AddRange(bookCovers.ToArray());
            this.Controls.Add(flpCategories);
        }
Ejemplo n.º 17
0
 private void Cipher(bool decrypt, bool dlc)
 {
     if (!Open())
     {
         return;
     }
     //Decrypt then save
     if (dlc)
     {
         var file = new DLC((Region)RegionBox.SelectedIndex);
         Save((decrypt) ? file.Decrypt(Filepath) : file.Encrypt(Filepath));
     }
     else
     {
         var file = new SaveData((Region)RegionBox.SelectedIndex);
         Save((decrypt) ? file.Decrypt(Filepath) : file.Encrypt(Filepath));
     }
 }
Ejemplo n.º 18
0
 internal DLCItem(DLC DLC)
 {
     this.DLC = DLC;
     InitializeComponent();
     if (LocCulture == "el")
     {
         foreach (TextBlock TextBlock in StatusStack.Children)
         {
             TextBlock.FontSize = 16D;
         }
     }
     else if (LocCulture == "ar")
     {
         StatusStack.FlowDirection = FlowDirection.RightToLeft;
     }
     Image.Source   = new BitmapImage(new Uri($"pack://application:,,,/Resources/Images/{DLC.SpacelessName}.jpg"));
     NameBlock.Text = DLC.Name;
     SetStatus(DLC.Status);
 }
Ejemplo n.º 19
0
    // Token: 0x06000E3C RID: 3644 RVA: 0x0005BA2C File Offset: 0x00059C2C
    private void OnGUI()
    {
        GUIStyle style = new GUIStyle("button");

        if (!ViveportDemo_DLC.bInit)
        {
            GUI.contentColor = Color.white;
        }
        else
        {
            GUI.contentColor = Color.gray;
        }
        if (GUI.Button(new Rect((float)this.nXStart, (float)this.nYStart, (float)this.nWidth, (float)this.nHeight), "Init", style) && !ViveportDemo_DLC.bInit)
        {
            Api.Init(new StatusCallback(ViveportDemo_DLC.InitStatusHandler), ViveportDemo_DLC.APP_ID);
        }
        if (ViveportDemo_DLC.bInit)
        {
            GUI.contentColor = Color.white;
        }
        else
        {
            GUI.contentColor = Color.grey;
        }
        if (GUI.Button(new Rect((float)(this.nXStart + (this.nWidth + 10)), (float)this.nYStart, (float)this.nWidth, (float)this.nHeight), "Shutdown", style) && ViveportDemo_DLC.bInit)
        {
            Api.Shutdown(new StatusCallback(ViveportDemo_DLC.ShutdownHandler));
        }
        if (GUI.Button(new Rect((float)(this.nXStart + 2 * (this.nWidth + 10)), (float)this.nYStart, (float)this.nWidth, (float)this.nHeight), "IsDLCReady", style) && ViveportDemo_DLC.bInit)
        {
            DLC.IsDlcReady(new StatusCallback(ViveportDemo_DLC.IsDLCReadyHandler));
        }
        if (GUI.Button(new Rect((float)(this.nXStart + 3 * (this.nWidth + 10)), (float)this.nYStart, (float)this.nWidth, (float)this.nHeight), "GetDLCCount", style) && ViveportDemo_DLC.bInit && ViveportDemo_DLC.bIsReady)
        {
            ViveportDemo_DLC.dlcCount = DLC.GetCount();
            Viveport.Core.Logger.Log("DLC count: " + ViveportDemo_DLC.dlcCount);
        }
        if (GUI.Button(new Rect((float)(this.nXStart + 4 * (this.nWidth + 10)), (float)this.nYStart, (float)this.nWidth, (float)this.nHeight), "GetIsAvailable", style) && ViveportDemo_DLC.bInit && ViveportDemo_DLC.bIsReady && DLC.GetIsAvailable(this.dlcIndex, out ViveportDemo_DLC.dlcAppId, out ViveportDemo_DLC.bIsDLCAvailable))
        {
            Viveport.Core.Logger.Log("Is DLC available: " + ViveportDemo_DLC.bIsDLCAvailable.ToString());
            Viveport.Core.Logger.Log("DLC APP ID: " + ViveportDemo_DLC.dlcAppId);
        }
    }
Ejemplo n.º 20
0
 internal ValidatorWindow(DLC DLC, bool DoValidate)
 {
     this.DoValidate = DoValidate;
     this.DLC        = DLC;
     InitializeComponent();
     if (LocCulture == "pt" || LocCulture == "el")
     {
         Button.FontSize = 12D;
     }
     if (LocCulture == "ar")
     {
         foreach (Panel Stack in ValidationBlock.Children)
         {
             Stack.FlowDirection = FlowDirection.RightToLeft;
         }
     }
     TitleBlock.Text              = Title = string.Format(LocString(LocCode.DLCValidator), DLC.Name);
     ProgressBar.ProgressUpdated += ProgressUpdatedHandler;
     LastStatus = DLC.Status;
     DLC.SetStatus(ARK.Status.Updating);
     Downloader = new ContentDownloader(DLC.DepotID, FinishHandler, SetStatus, ProgressBar);
 }
Ejemplo n.º 21
0
        public async Task Should_sync_dlc()
        {
            var dlc = new DLC()
            {
                Name      = "test",
                Path      = "dlc/dlc01.dlc",
                IsEnabled = true
            };
            var dlc2 = new DLC()
            {
                Name      = "test",
                Path      = "dlc/dlc02.dlc",
                IsEnabled = true
            };
            var dlcExport = new Mock <IDLCExporter>();

            dlcExport.Setup(p => p.GetDisabledDLCAsync(It.IsAny <DLCParameters>())).ReturnsAsync(() => new List <IDLCObject>()
            {
                new DLCObject()
                {
                    Path = "dlc/dlc01.dlc"
                }
            });
            var service = new DLCService(dlcExport.Object, null, null, null, null, null);
            var result  = await service.SyncStateAsync(new Game()
            {
                ExecutableLocation = string.Empty,
                Type = "Should_sync_dlc"
            }, new List <IDLC>()
            {
                dlc, dlc2
            });

            result.Should().BeTrue();
            dlc.IsEnabled.Should().BeFalse();
            dlc2.IsEnabled.Should().BeTrue();
        }
Ejemplo n.º 22
0
        private async void CheckForGameAndDLCsUpdates()
        {
            string Executable = ExecutablePath;

            if (Settings.DisableUpdChecks)
            {
                foreach (DLC DLC in DLCs)
                {
                    DLC.SetStatus(DLC.IsInstalled ? Status.Installed : Status.NotInstalled);
                }
                SetCurrentVersion(FileExists(Executable) ? Game.Version ?? LocString(LocCode.NA) : LocString(LocCode.None), (SolidColorBrush)FindResource("BrightestBrightBrush"));
            }
            bool   QuerySucceeded = false;
            Hashes InitialQuery   = new Hashes();

            if (IsConnectionAvailable())
            {
                for (int AttemptsCounter = 0; !QuerySucceeded && AttemptsCounter < 5; AttemptsCounter++)
                {
                    if (await InitialQuery.RequestAsync())
                    {
                        QuerySucceeded = true;
                    }
                }
            }
            else
            {
                Message.Show("Warning", LocString(LocCode.NoInternet));
            }
            if (Settings.DisableUpdChecks)
            {
                return;
            }
            if (QuerySucceeded && InitialQuery.Checksums.ContainsKey(MapCode.TheIsland))
            {
                if (FileExists(Executable))
                {
                    using (SHA1 SHA = Create())
                        using (FileStream ChecksumStream = OpenRead(Executable))
                        {
                            if (SHA.ComputeHash(ChecksumStream).SequenceEqual(InitialQuery.Checksums[MapCode.TheIsland]))
                            {
                                SetCurrentVersion(Game.Version ?? LocString(LocCode.Latest), DarkGreen);
                            }
                            else
                            {
                                UpdateAvailable = true;
                                SetCurrentVersion(Game.Version ?? LocString(LocCode.Outdated), YellowBrush);
                                Add(LocString(LocCode.ARKUpdateAvailable), LocString(LocCode.Update), RunGameUpdate);
                            }
                        }
                }
                else
                {
                    SetCurrentVersion(LocString(LocCode.None), DarkRed);
                }
                if (DLCs.Any(DLC => DLC.IsInstalled))
                {
                    Notification DLCNotification = AddLoading($"{LocString(LocCode.CheckingForDLCUpds)} ", LocString(LocCode.Update), RunDLCUpdater);
                    await CheckForUpdatesAsync(InitialQuery.Checksums);

                    bool DLCUpdatesAvailable = false;
                    foreach (DLC DLC in DLCs)
                    {
                        DLCUpdatesAvailable |= DLC.Status == Status.UpdateAvailable;
                    }
                    if (DLCUpdatesAvailable)
                    {
                        DLCNotification.FinishLoading(LocString(LocCode.DLCUpdsAvailable), true);
                    }
                    else
                    {
                        DLCNotification.FinishLoading(LocString(LocCode.DLCUpToDate), false);
                        await Delay(1500);

                        DLCNotification.Hide();
                    }
                }
            }
            else
            {
                foreach (DLC DLC in DLCs)
                {
                    DLC.SetStatus(DLC.IsInstalled ? Status.Installed : Status.NotInstalled);
                }
                SetCurrentVersion(FileExists(Executable) ? Game.Version ?? LocString(LocCode.NA) : LocString(LocCode.None), (SolidColorBrush)FindResource("GrayBrush"));
            }
        }
Ejemplo n.º 23
0
 public DLC()
 {
     instance = this;
 }
Ejemplo n.º 24
0
        public static DLCInfoAttribute GetDLCInfo(this DLC dlc)
        {
            var member = typeof(DLC).GetMember(dlc.ToString())[0];

            return(member.GetCustomAttribute <DLCInfoAttribute>());
        }
Ejemplo n.º 25
0
    public void AddDLC(string name, float price)
    {
        DLC newDLC = new DLC(name, price, this);

        dlcs.Add(newDLC);
    }
Ejemplo n.º 26
0
        private DLC Parse(string filename)
        {
            if (!File.Exists(filename))
            {
                logger.Error(string.Format("File not found: {0}", filename));
                return(null);
            }

            string   line;
            int      intOut;
            FileInfo dlcFile = new FileInfo(filename);

            DLC dlc = new DLC();

            dlc.DLCFile = dlcFile.Name;

            StreamReader reader = new StreamReader(filename, Encoding.GetEncoding(1252));

            while ((line = reader.ReadLine()) != null)
            {
                if (line.StartsWith("#"))
                {
                    continue;
                }

                if (line.StartsWith("name"))
                {
                    dlc.Name = line.Split('=')[1].Split('#')[0].Replace("\"", "").Trim();
                }
                if (line.StartsWith("archive"))
                {
                    dlc.Archive = line.Split('=')[1].Split('#')[0].Replace("\"", "").Trim();
                }
                if (line.StartsWith("checksum"))
                {
                    dlc.Checksum = line.Split('=')[1].Split('#')[0].Replace("\"", "").Trim();
                }

                if (line.StartsWith("steam_id"))
                {
                    if (Int32.TryParse(line.Split('=')[1].Split('#')[0].Replace("\"", "").Trim(), out intOut))
                    {
                        dlc.SteamID = intOut;
                    }
                    else
                    {
                        logger.Error(string.Format("Error parsing Steam ID in file: {0}", dlcFile.Name));
                    }
                }

                if (line.StartsWith("gamersgate_id"))
                {
                    if (Int32.TryParse(line.Split('=')[1].Split('#')[0].Replace("\"", "").Trim(), out intOut))
                    {
                        dlc.GamersGateID = intOut;
                    }
                    else
                    {
                        logger.Error(string.Format("Error parsing GamersGate ID in file: {0}", dlcFile.Name));
                    }
                }

                if (line.StartsWith("affects_checksum"))
                {
                    dlc.AffectsChecksum = line.Split('=')[1].Split('#')[0].Replace("\"", "").Trim() == "yes";
                }
            }
            return(dlc);
        }
Ejemplo n.º 27
0
        public List <DLC> GetInstalledDLCFiles()
        {
            List <DLC> dlcList = new List <DLC>();

            if (AppManifestPath != null && File.Exists(AppManifestPath))
            {
                KeyValue appManifest = KeyValue.LoadAsText(AppManifestPath);
                Dictionary <string, string> depotManifests = new Dictionary <string, string>();

                foreach (KeyValue mountedDepot in appManifest["MountedDepots"].Children)
                {
                    depotManifests[mountedDepot.Name] = mountedDepot.Value;
                }

                foreach (KeyValue mountedDepot in appManifest["InstalledDepots"].Children)
                {
                    depotManifests[mountedDepot.Name] = mountedDepot["manifest"].Value;
                }

                foreach (KeyValuePair <string, string> depotManifest in depotManifests)
                {
                    uint   dlcappid     = Convert.ToUInt32(depotManifest.Key);
                    string manifestPath = Path.Combine(SteamPath, "depotcache", $"{dlcappid}_{depotManifest.Value}.manifest");

                    if (File.Exists(manifestPath))
                    {
                        DLC           dlc      = new DLC(dlcappid);
                        DepotManifest manifest = DepotManifest.Deserialize(File.ReadAllBytes(manifestPath));

                        foreach (DepotManifest.FileData file in manifest.Files)
                        {
                            if (file.Flags.HasFlag(EDepotFileFlag.Directory))
                            {
                                continue;
                            }

                            string fileName  = file.FileName.ToLower();
                            string extension = Path.GetExtension(fileName).ToLower();

                            if (fileName.Contains("assets"))
                            {
                                if (extension.Contains("xml") || extension.Contains("bin"))
                                {
                                    dlc.IncludedFiles.Add(NormalizePath(GetRelativePath(Path.Combine(RWPath, "Assets"), Path.Combine(RWPath, fileName))));
                                }

                                if (extension == ".ap")
                                {
                                    string absoluteFileName = Path.Combine(RWPath, fileName);
                                    try
                                    {
                                        ZipArchive zipFile = ZipFile.OpenRead(absoluteFileName);
                                        dlc.IncludedFiles.AddRange(from x in zipFile.Entries where (x.FullName.Contains(".xml") || x.FullName.Contains(".bin")) select NormalizePath(GetRelativePath(Path.Combine(RWPath, "Assets"), Path.Combine(Path.GetDirectoryName(absoluteFileName), x.FullName))));
                                    }
                                    catch { }
                                }
                            }
                        }

                        dlcList.Add(dlc);
                    }
                }
            }

            return(dlcList);
        }
Ejemplo n.º 28
0
    void OnGUI()
    {
        GUIStyle CustButton = new GUIStyle("button");

#if UNITY_ANDROID
        CustButton.fontSize = 23;
#endif
        if (bInit == false)
        {
            GUI.contentColor = Color.white;
        }
        else
        {
            GUI.contentColor = Color.gray;
        }

        // Init function
        if (GUI.Button(new Rect(nXStart, nYStart, nWidth, nHeight), "Init", CustButton))
        {
            if (bInit == false)
            {
                Api.Init(InitStatusHandler, APP_ID);
            }
        }

        if (bInit == true)
        {
            GUI.contentColor = Color.white;
        }
        else
        {
            GUI.contentColor = Color.grey;
        }

        // Shutdown function
        if (GUI.Button(new Rect((nXStart + 1 * (nWidth + 10)), nYStart, nWidth, nHeight), "Shutdown", CustButton))
        {
            if (bInit == true)
            {
                Api.Shutdown(ShutdownHandler);
            }
        }

#if !UNITY_ANDROID
        // IsDLCReady function
        if (GUI.Button(new Rect((nXStart + 2 * (nWidth + 10)), nYStart, nWidth, nHeight), "IsDLCReady", CustButton))
        {
            if (bInit == true)
            {
                DLC.IsDlcReady(IsDLCReadyHandler);
            }
        }

        // GetDLCCount function
        if (GUI.Button(new Rect((nXStart + 3 * (nWidth + 10)), nYStart, nWidth, nHeight), "GetDLCCount", CustButton))
        {
            if (bInit == true && bIsReady == true)
            {
                dlcCount = DLC.GetCount();
                Viveport.Core.Logger.Log("DLC count: " + dlcCount);
            }
        }

        // GetIsAvailable function
        if (GUI.Button(new Rect((nXStart + 4 * (nWidth + 10)), nYStart, nWidth, nHeight), "GetIsAvailable", CustButton))
        {
            if (bInit == true && bIsReady == true)
            {
                bool isInRange = DLC.GetIsAvailable(dlcIndex, out dlcAppId, out bIsDLCAvailable);
                if (isInRange)
                {
                    Viveport.Core.Logger.Log("Is DLC available: " + bIsDLCAvailable);
                    Viveport.Core.Logger.Log("DLC APP ID: " + dlcAppId);
                }
            }
        }
#endif
    }