コード例 #1
0
        /// <summary>
        /// the corruption generator copies files without checking the names, so only the extensions are the same, the outcome is truly random so a cursor might look like a combo number or whatever
        /// </summary>
        public override void Generate()
        {
            List <SkinnableFile> newSkin = new List <SkinnableFile>();

            foreach (SkinnableFile installedFile in base.relevantFiles)                   // go over every installed file
            {
                if (!newSkin.Exists(x => x.skinnableName == installedFile.skinnableName)) // check if the skinnable element is already there
                {
                    // if not found
                    List <SkinnableFile> skinnableGroup = base.relevantFiles.Where(x => x.extension == installedFile.extension).ToList(); // look for matches in extension ==> dont care for anything else
                    SkinnableFile        corruptedFile  = new SkinnableFile();
                    corruptedFile = skinnableGroup[rnd.Next(0, skinnableGroup.Count)];
                    corruptedFile.overrideSkinnable = installedFile.skinnableName;
                    newSkin.Add(corruptedFile); // add file to result skin
                }
            }

            string resultSkinDirectory = base.pathToOsuSkinFolder + @"\" + base.skinResultName + @"\";

            foreach (SkinnableFile file in newSkin) // go over the result skin and copy over the files
            {
                string sourcePath = base.pathToOsuSkinFolder + @"\" + file.skinName + @"\" + file.skinnableName + file.extension;
                string targetPath = resultSkinDirectory + file.overrideSkinnable + file.extension;
                if (!System.IO.File.Exists(targetPath))
                {
                    System.IO.File.Copy(sourcePath, targetPath);
                }
            }
        }
コード例 #2
0
        public void GatherFiles()
        {
            myLogger.AddLoggerLine("reading files...", Severity.Information);
            List <string> installedSkins = System.IO.Directory.GetDirectories(pathToOsuSkinFolder).ToList(); // skin paths => all installed skin folders
            // get skinnables file
            string skinnableBase = @"Assets\SkinnableData\baseDataSkinnables.base";
            // read it
            List <string> EverySkinnable = System.IO.File.ReadAllLines(skinnableBase).ToList();

            // go over list
            foreach (string skinnableBaseName in EverySkinnable)
            {
                myLogger.AddLoggerLine("File: " + skinnableBaseName + " gathered (from installed)", Severity.Information);
                List <string> matchingFiles = new List <string>();
                foreach (string installedSkin in installedSkins)                                                                                                  // go over installed skins
                {
                    string foundMatch = System.IO.Directory.GetFiles(installedSkin, skinnableBaseName, System.IO.SearchOption.TopDirectoryOnly).FirstOrDefault(); // check for file
                    if (foundMatch != null)
                    {
                        matchingFiles.Add(foundMatch);
                    }
                }
                if (matchingFiles.Count() > 0)
                {
                    string   filePath           = matchingFiles[rnd.Next(0, matchingFiles.Count())];
                    string[] skinFolderSegments = filePath.Split('\\');
                    if (skinFolderSegments[skinFolderSegments.Count() - 3] == "Skins") // the file is actually in the skin folder and not in a folder below it
                    {
                        string        skinName = skinFolderSegments[skinFolderSegments.Count() - 2];
                        SkinnableFile newFile  = new SkinnableFile();
                        newFile.extension     = System.IO.Path.GetExtension(filePath);
                        newFile.skinnableName = System.IO.Path.GetFileNameWithoutExtension(filePath);
                        newFile.skinName      = skinName;
                        relevantFiles.Add(newFile); // add the file to the installed skinnable file list
                    }
                }
            }
        }