示例#1
0
        private static int QueryCheatsDir(ModCache mods, DirectoryInfo cheatsDir)
        {
            if (!cheatsDir.Exists)
            {
                return(0);
            }

            int numMods = 0;

            foreach (FileInfo file in cheatsDir.EnumerateFiles())
            {
                if (!StrEquals(CheatExtension, file.Extension))
                {
                    continue;
                }

                string cheatId = Path.GetFileNameWithoutExtension(file.Name);

                if (cheatId.Length != Cheat.CheatIdSize)
                {
                    continue;
                }

                if (!ulong.TryParse(cheatId, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out _))
                {
                    continue;
                }

                // A cheat file can contain several cheats for the same executable, so the file must be parsed in
                // order to properly enumerate them.
                mods.Cheats.AddRange(GetCheatsInFile(file));
            }

            return(numMods);
        }
示例#2
0
        public static void QueryTitleDir(ModCache mods, DirectoryInfo titleDir)
        {
            if (!titleDir.Exists)
            {
                return;
            }

            var fsFile = new FileInfo(Path.Combine(titleDir.FullName, RomfsContainer));

            if (fsFile.Exists)
            {
                mods.RomfsContainers.Add(new Mod <FileInfo>($"<{titleDir.Name} RomFs>", fsFile));
            }

            fsFile = new FileInfo(Path.Combine(titleDir.FullName, ExefsContainer));
            if (fsFile.Exists)
            {
                mods.ExefsContainers.Add(new Mod <FileInfo>($"<{titleDir.Name} ExeFs>", fsFile));
            }

            System.Text.StringBuilder types = new System.Text.StringBuilder(5);

            foreach (var modDir in titleDir.EnumerateDirectories())
            {
                types.Clear();
                Mod <DirectoryInfo> mod = new Mod <DirectoryInfo>("", null);

                if (StrEquals(RomfsDir, modDir.Name))
                {
                    mods.RomfsDirs.Add(mod = new Mod <DirectoryInfo>($"<{titleDir.Name} RomFs>", modDir));
                    types.Append('R');
                }
                else if (StrEquals(ExefsDir, modDir.Name))
                {
                    mods.ExefsDirs.Add(mod = new Mod <DirectoryInfo>($"<{titleDir.Name} ExeFs>", modDir));
                    types.Append('E');
                }
                else
                {
                    var romfs = new DirectoryInfo(Path.Combine(modDir.FullName, RomfsDir));
                    var exefs = new DirectoryInfo(Path.Combine(modDir.FullName, ExefsDir));
                    if (romfs.Exists)
                    {
                        mods.RomfsDirs.Add(mod = new Mod <DirectoryInfo>(modDir.Name, romfs));
                        types.Append('R');
                    }
                    if (exefs.Exists)
                    {
                        mods.ExefsDirs.Add(mod = new Mod <DirectoryInfo>(modDir.Name, exefs));
                        types.Append('E');
                    }
                }

                if (types.Length > 0)
                {
                    Logger.Info?.Print(LogClass.ModLoader, $"Found mod '{mod.Name}' [{types}]");
                }
            }
        }
示例#3
0
    private void buttonRescanCache_Click(object sender, EventArgs e)
    {
        ModCache.RescanModCacheFolder();

        olvModList.Refresh();
        RefreshTreeView();
        RefreshListView();
    }
示例#4
0
    private void Form1_Shown(object sender, EventArgs e)
    {
        ModCache.RescanModCacheFolder();
        RefreshListView();

        GetSelectedMod();
        olvModList.Focus();
    }
示例#5
0
    private void Form1_Shown(object sender, EventArgs e)
    {
        ModCache.RescanModCacheFolder();
        RefreshListView();

        GetSelectedMod();
        olvModList.Focus();
        Language Language = new Language();

        if (!this.DesignMode)
        {
            Language.InitLanguage(this);
        }
    }
示例#6
0
    private void reloadArchiveToolStripMenuItem_Click(object sender, EventArgs e)
    {
        ModInfo selMod = GetSelectedMod();

        if (!selMod)
        {
            return;
        }

        ModCache.ReCheckMods(new ModInfo[] { selMod });

        RefreshListView();
        RefreshTreeView();
    }
示例#7
0
        public static void QueryContentsDir(ModCache mods, DirectoryInfo contentsDir, ulong titleId)
        {
            if (!contentsDir.Exists)
            {
                return;
            }

            Logger.Info?.Print(LogClass.ModLoader, $"Searching mods for {((titleId & 0x1000) != 0 ? "DLC" : "Title")} {titleId:X16}");

            var titleDir = FindTitleDir(contentsDir, $"{titleId:x16}");

            if (titleDir != null)
            {
                QueryTitleDir(mods, titleDir);
            }
        }
示例#8
0
    private void olvModList_DragDrop(object sender, DragEventArgs e)
    {
        string modCacheFolder = Serializer.GetModsCacheFolder();

        Directory.CreateDirectory(modCacheFolder);

        var files = e.Data.GetData(DataFormats.FileDrop) as string[];

        if (files.Length == 0)
        {
            return;
        }

        string[] modFiles  = Directory.GetFiles(modCacheFolder, "*", SearchOption.AllDirectories);
        string   lastAdded = null;


        foreach (string file in files)
        {
            bool   isDir    = Directory.Exists(file);
            string fileName = Path.GetFileName(file);

            if (isDir)
            {
                FileSystem.MoveDirectory(file, modCacheFolder + fileName, UIOption.OnlyErrorDialogs, UICancelOption.DoNothing);
            }
            else
            {
                if (!modFiles.Contains(file) && !File.Exists(modCacheFolder + fileName) && File.Exists(file))
                {
                    File.Move(file, modCacheFolder + fileName);
                }
                lastAdded = modCacheFolder + fileName;
            }
        }

        ModCache.RescanModCacheFolder();

        if (lastAdded != null)
        {
            olvModList.SelectedObject = modsData.modInfos.FindLast(x => x.modPath.ToLower() == lastAdded.ToLower());
            olvModList.EnsureModelVisible(olvModList.SelectedObject);
        }
    }
示例#9
0
    private void buttonRescanInstall_Click(object sender, EventArgs e)
    {
        buttonRescanInstall.Text = Language.GetLanguageText("Scanning...");
        buttonRescanInstall.Refresh();

        ModCache.ReCheckMods(modsData.modInfos);

        foreach (var mod in modsData.modInfos)
        {
            mod.CheckIfInstalled();
        }

        buttonRescanInstall.Text = Language.GetLanguageText("Re-Scan Installations");

        SaveData();

        olvModList.Refresh();
        RefreshTreeView();
    }
示例#10
0
            static bool TryQuery(ModCache mods, PatchCache patches, ulong?titleId, DirectoryInfo dir, DirectoryInfo searchDir)
            {
                if (StrEquals(AmsContentsDir, dir.Name))
                {
                    if (titleId.HasValue)
                    {
                        QueryContentsDir(mods, dir, (ulong)titleId);

                        return(true);
                    }
                }
                else if (IsPatchesDir(dir.Name))
                {
                    QueryPatchDirs(patches, dir, searchDir);

                    return(true);
                }

                return(false);
            }
示例#11
0
 public static void CollectMods(ModCache mods, PatchCache patches, ulong?titleId, params string[] searchDirPaths)
 {