Пример #1
0
        /// <summary>
        /// Outputs a list of Mod Files that can be built
        /// </summary>
        /// <param name="qmt"></param>
        /// <param name="Family"></param>
        /// <param name="ci"></param>
        /// <param name="Slot"></param>
        /// <param name="ModLoader"></param>
        /// <param name="li"></param>
        /// <param name="game"></param>
        /// <returns></returns>
        public static ObservableCollection <ModFile> GetModFiles(QuasarModType qmt, GameElementFamily Family, ContentItem ci, int Slot, int ModLoader, LibraryItem li, Game game)
        {
            string DefaultDir = Properties.Settings.Default.DefaultDir;
            ObservableCollection <ModFile> PreparedModFiles = new ObservableCollection <ModFile>();

            foreach (ScanFile sf in ci.ScanFiles)
            {
                QuasarModTypeFileDefinition FileDefinition = qmt.QuasarModTypeFileDefinitions.Single(def => def.ID == sf.QuasarModTypeFileDefinitionID);
                GameElement ge        = Family.GameElements.Single(e => e.ID == sf.GameElementID);
                string      ModFolder = Properties.Settings.Default.DefaultDir + @"\Library\Mods\" + li.Guid + @"\";

                ModFile mf = new ModFile()
                {
                    SourceFilePath      = ModFolder + sf.SourcePath,
                    DestinationFilePath = ProcessOutput(ModFolder + sf.SourcePath, FileDefinition, ge, Slot, ModLoader, li, ModFolder),
                    LibraryItemGuid     = ci.LibraryItemGuid
                };

                PreparedModFiles.Add(mf);
            }
            return(PreparedModFiles);
        }
Пример #2
0
        /// <summary>
        /// Matches all scan files to a game entry
        /// </summary>
        /// <param name="FilesToMatch"></param>
        /// <param name="FileDefinition"></param>
        /// <param name="qmt"></param>
        /// <param name="game"></param>
        /// <param name="ModFolder"></param>
        /// <returns></returns>
        public static ObservableCollection <ScanFile> MatchFiles(ObservableCollection <ScanFile> FilesToMatch, QuasarModTypeFileDefinition FileDefinition, QuasarModType qmt, Game game, string ModFolder)
        {
            Regex FileRegex   = new Regex(PrepareRegex(FileDefinition.SearchFileName));
            Regex FolderRegex = new Regex(PrepareRegex(FileDefinition.SearchPath));

            foreach (ScanFile FileToMatch in FilesToMatch)
            {
                Match fileMatch   = FileRegex.Match(FileToMatch.SourcePath.Replace('\\', '/'));
                Match folderMatch = FolderRegex.Match(FileToMatch.SourcePath.Replace('\\', '/'));

                if (folderMatch.Success || fileMatch.Success)
                {
                    //Match Data
                    string            FolderSlot = "";
                    string            FileSlot   = "";
                    GameElement       RecognisedFolderGameData = null;
                    GameElement       RecognisedFileGameData   = null;
                    GameElementFamily Family = game.GameElementFamilies.Single(f => f.ID == qmt.GameElementFamilyID);

                    //Match Data Processing
                    if (folderMatch.Success)
                    {
                        Group  GameData       = folderMatch.Groups["GameData"];
                        string FolderGameData = GameData.Value;
                        RecognisedFolderGameData = Family.GameElements.SingleOrDefault(ge => (ge.GameFolderName == FolderGameData.ToLower()) || (ge.GameFolderName.Contains(";") ? ge.GameFolderName.Split(';').Contains(FolderGameData.ToLower()) : false));

                        Group Slot = folderMatch.Groups["Slot"];
                        FolderSlot = Slot.Value;
                    }
                    if (fileMatch.Success)
                    {
                        Group  GameData     = fileMatch.Groups["GameData"];
                        string FileGameData = GameData.Value;
                        RecognisedFileGameData = Family.GameElements.SingleOrDefault(ge => (ge.GameFolderName == FileGameData.ToLower()) || (ge.GameFolderName.Contains(";") ? ge.GameFolderName.Split(';').Contains(FileGameData.ToLower()) : false));

                        Group Slot = fileMatch.Groups["Slot"];
                        FileSlot = Slot.Value;
                    }

                    //Match Validation
                    if ((RecognisedFileGameData != null || RecognisedFolderGameData != null) && (FileDefinition.SearchPath == "" || folderMatch.Success) && fileMatch.Success)
                    {
                        FileToMatch.QuasarModTypeID = qmt.ID;
                        FileToMatch.QuasarModTypeFileDefinitionID = FileDefinition.ID;
                        FileToMatch.GameElementID = RecognisedFolderGameData != null ? RecognisedFolderGameData.ID : RecognisedFileGameData.ID;
                        FileToMatch.Slot          = FolderSlot != "" ? FolderSlot : FileSlot != "" ? FileSlot : "00";

                        //Processing paths
                        FileToMatch.SourcePath = FileToMatch.SourcePath.Replace('/', '\\').Replace(ModFolder, "");
                        if (folderMatch.Value == "")
                        {
                            FileToMatch.OriginPath = FileToMatch.SourcePath;
                        }
                        else
                        {
                            FileToMatch.OriginPath = FileToMatch.SourcePath.Replace("\\" + folderMatch.Value.Replace('/', '\\'), "");
                        }
                        FileToMatch.OriginPath = FileToMatch.OriginPath.Replace(fileMatch.Value, "|");
                        FileToMatch.OriginPath = FileToMatch.OriginPath.Split('|')[0];
                        FileToMatch.Scanned    = true;
                    }
                }
            }

            return(FilesToMatch);
        }
Пример #3
0
        public static void ProcessGameFile(ObservableCollection <V1.Game> V1Games, ObservableCollection <V1.GameData> V1GameDatas)
        {
            //New format instancing
            ObservableCollection <V2.Game> Games = new ObservableCollection <V2.Game>();

            V2.Game game = new V2.Game();

            //Foreach source game
            foreach (V1.Game v1game in V1Games)
            {
                if (v1game.ID == 1)
                {
                    game.ID                  = 1;
                    game.APIGameName         = v1game.GameName;
                    game.Name                = v1game.Name;
                    game.GameAPICategories   = new ObservableCollection <V2.GameAPICategory>();
                    game.GameElementFamilies = new ObservableCollection <GameElementFamily>();

                    //Parsing game's GameAPICategories
                    foreach (V1.GameModType gmt in v1game.GameModTypes)
                    {
                        if (gmt.ID != -1)
                        {
                            V2.GameAPICategory GameAPICategory = new V2.GameAPICategory()
                            {
                                APICategoryName = gmt.APIName,
                                ID = gmt.ID,
                                LibraryFolderName = gmt.LibraryFolder,
                                Name = gmt.Name,
                                GameAPISubCategories = new ObservableCollection <GameAPISubCategory>()
                            };

                            //Parsing Categories' SubCategories
                            foreach (Category cat in gmt.Categories)
                            {
                                if (cat.ID != -1 && cat.ID != 0)
                                {
                                    V2.GameAPISubCategory gameAPISubCategory = new V2.GameAPISubCategory()
                                    {
                                        ID = cat.ID,
                                        APISubCategoryID   = cat.APICategory,
                                        APISubCategoryName = cat.Name
                                    };
                                    GameAPICategory.GameAPISubCategories.Add(gameAPISubCategory);
                                }
                            }

                            game.GameAPICategories.Add(GameAPICategory);
                        }
                    }

                    //Parsing game's GameData
                    foreach (V1.GameData gd in V1GameDatas)
                    {
                        if (gd.GameID == 1)
                        {
                            //Parsing Game Element Families
                            foreach (GameDataCategory gdc in gd.Categories)
                            {
                                GameElementFamily Family = new GameElementFamily()
                                {
                                    ID           = gdc.ID,
                                    Name         = gdc.Name,
                                    GameElements = new ObservableCollection <GameElement>()
                                };

                                //Parsing Game Elements
                                foreach (GameDataItem gdi in gdc.Items)
                                {
                                    GameElement Element = new GameElement()
                                    {
                                        ID             = gdi.ID,
                                        Name           = gdi.Name,
                                        GameFolderName = gdi.Attributes[0].Value,
                                        isDLC          = gdi.Attributes[1].Value.Contains("True")
                                    };
                                    Family.GameElements.Add(Element);
                                }

                                game.GameElementFamilies.Add(Family);
                            }
                        }
                    }
                }
            }

            Games.Add(game);
            JSonHelper.SaveGamesFile(Games);
        }