Exemplo n.º 1
0
        private void InitializeMetadataSettings()
        {
            IFileInfo fileInfo = FileProvider.GetFileInfo(METADATA_CATALOG_NAME);

            if (!fileInfo.Exists)
            {
                Directory.CreateDirectory(fileInfo.PhysicalPath);
            }

            string json = "{}";

            fileInfo = FileProvider.GetFileInfo($"{METADATA_CATALOG_NAME}/{METADATA_SETTINGS_FILE_NAME}");
            if (fileInfo.Exists)
            {
                using (StreamReader reader = new StreamReader(fileInfo.PhysicalPath, Encoding.UTF8))
                {
                    json = reader.ReadToEnd();
                }
                MetadataSettings = JsonSerializer.Deserialize <MetadataSettings>(json);
            }
            else
            {
                SaveMetadataSettings();
            }
        }
Exemplo n.º 2
0
        private string MetadataSettingsFilePath(IFileProvider fileProvider)
        {
            string filePath = $"{METADATA_SETTINGS_CATALOG_NAME}/{METADATA_SETTINGS_FILE_NAME}";

            IFileInfo fileInfo = fileProvider.GetFileInfo(METADATA_SETTINGS_CATALOG_NAME);

            if (!fileInfo.Exists)
            {
                Directory.CreateDirectory(fileInfo.PhysicalPath);
            }

            fileInfo = fileProvider.GetFileInfo(filePath);
            if (!fileInfo.Exists)
            {
                MetadataSettings      settings = new MetadataSettings();
                JsonSerializerOptions options  = new JsonSerializerOptions()
                {
                    WriteIndented = true
                };
                string json = JsonSerializer.Serialize(settings, options);
                using (StreamWriter writer = new StreamWriter(fileInfo.PhysicalPath, false, Encoding.UTF8))
                {
                    writer.Write(json);
                }
            }

            return(filePath);
        }
Exemplo n.º 3
0
        /// <summary> Applies a predicate to all artist and title metadata fields. Yields an issue wherever the predicate is true. </summary>
        private IEnumerable <Issue> GetFormattingIssues(MetadataSettings aSettings, Func <string, bool> aFunc)
        {
            if (aFunc(aSettings.artist))
            {
                yield return(new Issue(GetTemplate("Wrong Format"), null,
                                       "Romanized", "artist", aSettings.artist));
            }

            // Unicode fields do not exist in file version 9.
            if (aSettings.artistUnicode != null && aFunc(aSettings.artistUnicode))
            {
                yield return(new Issue(GetTemplate("Wrong Format"), null,
                                       "Unicode", "artist", aSettings.artistUnicode));
            }

            if (aFunc(aSettings.title))
            {
                yield return(new Issue(GetTemplate("Wrong Format"), null,
                                       "Romanized", "title", aSettings.title));
            }

            if (aSettings.titleUnicode != null && aFunc(aSettings.titleUnicode))
            {
                yield return(new Issue(GetTemplate("Wrong Format"), null,
                                       "Unicode", "title", aSettings.titleUnicode));
            }
        }
Exemplo n.º 4
0
        private void SetupServices(IConfiguration configuration, IServiceCollection services)
        {
            services.AddOptions();
            services.Configure <AppSettings>(configuration.GetSection(nameof(AppSettings)));

            IFileProvider    fileProvider     = ConfigureFileProvider(services);
            WebSettings      settings         = ConfigureWebSettings(fileProvider, services);
            MetadataSettings metadataSettings = ConfigureMetadataSettings(fileProvider, services);

            services.AddTransient <TabViewModel>();
            services.AddSingleton <MainWindowViewModel>();
            services.AddSingleton <MetadataController>();
            services.AddSingleton <ScriptingController>();
            services.AddTransient <ScriptEditorViewModel>();
            services.AddSingleton <HttpServicesController>();
            services.AddSingleton <MessagingController>();

            services.AddSingleton <IMetadataService, MetadataService>();
            services.AddSingleton <IQueryExecutor, QueryExecutor>();
            services.AddSingleton <IScriptingService, ScriptingService>();
            services.AddSingleton <IMessagingService, MessagingService>();

            services.AddHttpClient();
            foreach (WebServer server in settings.WebServers)
            {
                services.AddHttpClient(server.Name, client =>
                {
                    client.BaseAddress = new Uri(server.Address);
                });
            }
        }
Exemplo n.º 5
0
        /// <summary> Applies a predicate to all artist and title metadata fields. Yields an issue wherever the predicate is true. </summary>
        private IEnumerable <Issue> GetFormattingIssues(MetadataSettings settings, Marker marker)
        {
            if (marker.IsSimilarButNotExact(settings.artist))
            {
                yield return(new Issue(GetTemplate("Wrong Format"), null,
                                       marker.name, "Romanized", "artist", settings.artist));
            }

            // Unicode fields do not exist in file version 9.
            if (settings.artistUnicode != null && marker.IsSimilarButNotExact(settings.artistUnicode))
            {
                yield return(new Issue(GetTemplate("Wrong Format"), null,
                                       marker.name, "Unicode", "artist", settings.artistUnicode));
            }

            if (marker.IsSimilarButNotExact(settings.title))
            {
                yield return(new Issue(GetTemplate("Wrong Format"), null,
                                       marker.name, "Romanized", "title", settings.title));
            }

            if (settings.titleUnicode != null && marker.IsSimilarButNotExact(settings.titleUnicode))
            {
                yield return(new Issue(GetTemplate("Wrong Format"), null,
                                       marker.name, "Unicode", "title", settings.titleUnicode));
            }
        }
 public void Copy(MetadataSettings metadataToCopy)
 {
     mapName   = metadataToCopy.mapName;
     indoorMap = metadataToCopy.indoorMap;
     bgmSource = metadataToCopy.bgmSource;
     volume    = metadataToCopy.volume;
     pitch     = metadataToCopy.pitch;
 }
Exemplo n.º 7
0
        public void LoadSongMetadata()
        {
            var metadata = MetadataSettings.Load(StoryDirectory);

            TextContainer.Clear();
            TextContainer.AddParagraph($"Title: {metadata.SongTitle}");
            TextContainer.AddParagraph($"Artist: {metadata.SongArtist}");
            TextContainer.AddParagraph($"Author: {metadata.StoryAuthor}");
            TextContainer.AddParagraph($"Description: {metadata.MiscDescription}");
        }
Exemplo n.º 8
0
        private void CreatePrefab(XElement xmlPrefab, string objPath)
        {
            var customImporters = GetCustomImporterInstances();

            // Part 1: Create the prefab
            string     prefabName  = xmlPrefab.Attribute("name").Value;
            float      prefabScale = ImportUtils.GetAttributeAsFloat(xmlPrefab, "scale", 1.0f);
            GameObject tempPrefab  = new GameObject(prefabName);

            // Part 2: Build out the prefab
            // We may have an 'isTrigger' attribute that we want our children to obey
            bool isTrigger = ImportUtils.GetAttributeAsBoolean(xmlPrefab, "isTrigger", false);

            AddGameObjectsTo(tempPrefab, xmlPrefab, isTrigger, objPath, customImporters);

            // Part 3: Allow for customization from other editor scripts to be made on the prefab
            // (These are generally for game-specific needs)
            CustomizePrefab(tempPrefab, customImporters);

            // Part 3.5: Apply the scale only after all children have been added
            tempPrefab.transform.localScale = new Vector3(prefabScale, prefabScale, prefabScale);

            // Part 4: Save the prefab, keeping references intact.
            string resourcePath = ImportUtils.GetAttributeAsString(xmlPrefab, "resourcePath", "");
            bool   isResource   = !String.IsNullOrEmpty(resourcePath) || ImportUtils.GetAttributeAsBoolean(xmlPrefab, "resource", false);
            string prefabPath   = GetPrefabAssetPath(prefabName, isResource, resourcePath);

            UnityEngine.Object finalPrefab = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject));

            //Part 5:  Handle properities (uses info regarding whether or not the prefab was already defined)
            int previousMapId = 0;
            MetadataSettings previousMetadata = null;

            if (finalPrefab != null)
            {
                TiledMap map = ((GameObject)AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject))).GetComponent <TiledMap>();
                previousMapId    = map.MapID;
                previousMetadata = ((GameObject)AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject))).GetComponent <MetadataSettings>();
            }
            HandleTiledAttributes(tempPrefab, xmlPrefab, previousMapId, previousMetadata);
            HandleCustomProperties(tempPrefab, xmlPrefab, customImporters);

            if (finalPrefab == null)
            {
                // The prefab needs to be created
                ImportUtils.ReadyToWrite(prefabPath);
                finalPrefab = PrefabUtility.CreateEmptyPrefab(prefabPath);
            }

            // Replace the prefab, keeping connections based on name.
            PrefabUtility.ReplacePrefab(tempPrefab, finalPrefab, ReplacePrefabOptions.ReplaceNameBased);

            // Destroy the instance from the current scene hiearchy.
            UnityEngine.Object.DestroyImmediate(tempPrefab);
        }
Exemplo n.º 9
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddOptions();
            IFileProvider    fileProvider     = ConfigureFileProvider(services);
            MetadataSettings metadataSettings = ConfigureMetadataSettings(fileProvider, services);

            services.AddControllers();
            services.AddSingleton <IQueryExecutor, QueryExecutor>();
            services.AddSingleton <IMetadataService, MetadataService>();
            services.AddSingleton <IScriptingService, ScriptingService>();
        }
Exemplo n.º 10
0
 private void InitializeMetadata(IMetadataService metadata, MetadataSettings settings)
 {
     foreach (DatabaseServer server in settings.Servers)
     {
         //_ = Parallel.ForEach(server.Databases, InitializeMetadata);
         foreach (DatabaseInfo database in server.Databases)
         {
             metadata.Initialize(server, database);
         }
     }
 }
        public override void Seed(IDbContext context)
        {
            var entityDescriptor = Seeder._cache[Seeder.EntityDescriptor] as EntityDescriptorSettings;
            var signing          = Seeder._cache[Seeder.Signing] as SigningCredential;
            var metadataSettings = new MetadataSettings
            {
                SigningCredential    = signing,
                SPDescriptorSettings = entityDescriptor
            };

            context.Add <MetadataSettings>(metadataSettings);
            Seeder._cache[Seeder.Metadata] = metadataSettings;
        }
Exemplo n.º 12
0
        public Beatmap(string aCode, float?aStarRating = null, string aSongPath = null, string aMapPath = null)
        {
            code     = aCode;
            songPath = aSongPath;
            mapPath  = aMapPath;

            string[] lines = aCode.Split(new string[] { "\n" }, StringSplitOptions.None);

            generalSettings    = ParserStatic.GetSettings(lines, "General", aSectionLines => new GeneralSettings(aSectionLines));
            metadataSettings   = ParserStatic.GetSettings(lines, "Metadata", aSectionLines => new MetadataSettings(aSectionLines));
            difficultySettings = ParserStatic.GetSettings(lines, "Difficulty", aSectionLines => new DifficultySettings(aSectionLines));
            colourSettings     = ParserStatic.GetSettings(lines, "Colours", aSectionLines => new ColourSettings(aSectionLines));

            // event type 3 seems to be "background colour transformation" https://i.imgur.com/Tqlz3s5.png

            backgrounds = GetEvents(lines, new List <string>()
            {
                "Background", "0"
            }, anArgs => new Background(anArgs));
            videos = GetEvents(lines, new List <string>()
            {
                "Video", "1"
            }, anArgs => new Video(anArgs));
            breaks = GetEvents(lines, new List <string>()
            {
                "Break", "2"
            }, anArgs => new Break(anArgs));
            sprites = GetEvents(lines, new List <string>()
            {
                "Sprite", "4"
            }, anArgs => new Sprite(anArgs));
            storyHitSounds = GetEvents(lines, new List <string>()
            {
                "Sample", "5"
            }, anArgs => new StoryHitSound(anArgs));
            animations = GetEvents(lines, new List <string>()
            {
                "Animation", "6"
            }, anArgs => new Animation(anArgs));

            timingLines = GetTimingLines(lines);
            hitObjects  = GetHitobjects(lines);

            if (generalSettings.mode == Mode.Standard)
            {
                // Stacking is standard-only.
                ApplyStacking();

                starRating = aStarRating ?? (float)StandardDifficultyCalculator.Calculate(this).Item3;
            }
        }
Exemplo n.º 13
0
        public SettingsManager(ApplicationSettings applicationSettings,
                               MetadataSettings metadataSettings,
                               IThemeManager themeManager)
        {
            _applicationSettings = applicationSettings;
            _metadataSettings    = metadataSettings;
            _themeManager        = themeManager;

            _opacity = _applicationSettings.Opacity;
            _accent  = _applicationSettings.Accent;

            _isUpdateMetadataEnabled     = _metadataSettings.IsUpdateMetadataEnabled;
            _isSaveMetadataToFileEnabled = _metadataSettings.IsSaveMetadataToFileEnabled;
        }
Exemplo n.º 14
0
        /// <summary> Returns the beatmapset as a string in the format "Artist - Title (Creator)". </summary>
        public override string ToString()
        {
            if (beatmaps.Count > 0)
            {
                MetadataSettings settings = beatmaps.First().metadataSettings;

                string songArtist  = settings.GetFileNameFiltered(settings.artist);
                string songTitle   = settings.GetFileNameFiltered(settings.title);
                string songCreator = settings.GetFileNameFiltered(settings.creator);

                return(songArtist + " - " + songTitle + " (" + songCreator + ")");
            }
            return("No beatmaps in set.");
        }
Exemplo n.º 15
0
        /// <summary> Returns the expected .osb file name based on the metadata of the first beatmap if any exists, otherwise null. </summary>
        public string GetOsbFileName()
        {
            MetadataSettings settings = beatmaps.FirstOrDefault()?.metadataSettings;

            if (settings == null)
            {
                return(null);
            }

            string songArtist  = settings.GetFileNameFiltered(settings.artist);
            string songTitle   = settings.GetFileNameFiltered(settings.title);
            string songCreator = settings.GetFileNameFiltered(settings.creator);

            return(songArtist + " - " + songTitle + " (" + songCreator + ").osb");
        }
Exemplo n.º 16
0
        private MetadataSettings ConfigureMetadataSettings(IFileProvider fileProvider, IServiceCollection services)
        {
            string filePath = MetadataSettingsFilePath(fileProvider);

            MetadataSettings settings = new MetadataSettings();
            var config = new ConfigurationBuilder()
                         .AddJsonFile(filePath, optional: false)
                         .Build();

            config.Bind(settings);

            services.Configure <MetadataSettings>(config);

            return(settings);
        }
        public override IEnumerable <Issue> GetIssues(BeatmapSet beatmapSet)
        {
            Beatmap          refBeatmap  = beatmapSet.beatmaps[0];
            string           refVersion  = refBeatmap.metadataSettings.version;
            MetadataSettings refSettings = refBeatmap.metadataSettings;

            foreach (Beatmap beatmap in beatmapSet.beatmaps)
            {
                string curVersion = beatmap.metadataSettings.version;

                List <Issue> issues = new List <Issue>();
                issues.AddRange(GetInconsistency("artist", beatmap, refBeatmap, otherBeatmap => otherBeatmap.metadataSettings.artist));
                issues.AddRange(GetInconsistency("unicode artist", beatmap, refBeatmap, otherBeatmap => otherBeatmap.metadataSettings.artistUnicode));
                issues.AddRange(GetInconsistency("title", beatmap, refBeatmap, otherBeatmap => otherBeatmap.metadataSettings.title));
                issues.AddRange(GetInconsistency("unicode title", beatmap, refBeatmap, otherBeatmap => otherBeatmap.metadataSettings.titleUnicode));
                issues.AddRange(GetInconsistency("source", beatmap, refBeatmap, otherBeatmap => otherBeatmap.metadataSettings.source));
                issues.AddRange(GetInconsistency("creator", beatmap, refBeatmap, otherBeatmap => otherBeatmap.metadataSettings.creator));
                foreach (Issue issue in issues)
                {
                    yield return(issue);
                }

                if (beatmap.metadataSettings.tags == refSettings.tags)
                {
                    continue;
                }

                IEnumerable <string> refTags        = refSettings.tags.Split(' ');
                IEnumerable <string> curTags        = beatmap.metadataSettings.tags.Split(' ');
                IEnumerable <string> differenceTags = refTags.Except(curTags).Union(curTags.Except(refTags)).Distinct();

                string difference = String.Join(" ", differenceTags);
                if (difference != "")
                {
                    yield return
                        (new Issue(GetTemplate("Tags"), null,
                                   curVersion, refVersion,
                                   difference));
                }
            }
        }
Exemplo n.º 18
0
        public PackageJsonConfigurationsInitializer(MetadataApi metadataApi, MetadataSettings metadataSettings, ILog log) : base(0)
        {
            _metadataApi = metadataApi;
            _log         = log;

            _contentDirectory = metadataSettings.ContentDirectory;
            _configurations   = new Lazy <IEnumerable <DynamicWrapper> >(LoadConfigsMetadata);

            if (metadataSettings.EnableFileSystemWatcher)
            {
                var watcher = new FileSystemWatcher(_contentDirectory, "*.json")
                {
                    IncludeSubdirectories = true
                };

                watcher.Changed += (sender, args) => { UpdateConfigsMetadata(args); };
                watcher.Created += (sender, args) => { UpdateConfigsMetadata(args); };
                watcher.Deleted += (sender, args) => { UpdateConfigsMetadata(args); };

                watcher.EnableRaisingEvents = true;
            }
        }
Exemplo n.º 19
0
        internal MetadataContext BuildFromDbSettings(MetadataSettings metadataSettings)
        {
            if (metadataSettings == null)
            {
                throw new ArgumentNullException("metadataSettings");
            }

            var entityDescriptor = metadataSettings.SPDescriptorSettings;
            var entityDescriptorConfiguration = MetadataHelper.BuildEntityDesriptorConfiguration(entityDescriptor);
            var signing = metadataSettings.SigningCredential;

            var signingContext = new MetadataSigningContext(signing.SignatureAlgorithm, signing.DigestAlgorithm);

            signingContext.KeyDescriptors.Add(MetadataHelper.BuildKeyDescriptorConfiguration(signing.Certificates.First(x => x.Use == KeyUsage.Signing && x.IsDefault)));
            var metadataContext = new MetadataContext
            {
                EntityDesriptorConfiguration = entityDescriptorConfiguration,
                MetadataSigningContext       = signingContext
            };

            return(metadataContext);
        }
Exemplo n.º 20
0
        public override IEnumerable <Issue> GetIssues(BeatmapSet aBeatmapSet)
        {
            Beatmap beatmap = aBeatmapSet.beatmaps[0];

            List <Func <string, string> > problemTests = new List <Func <string, string> >()
            {
                aField => FormalSpaceRegex(aField, "CV:"),
                aField => FormalSpaceRegex(aField, "vs\\."),
                aField => FormalSpaceRegex(aField, "feat\\."),
                aField => FormalSpaceRegex(aField, "&"),

                aField => new Regex("[a-zA-Z0-9]\\(CV:").IsMatch(aField) ? "whitespace before \"(CV:\" or full-width bracket \"(\"" : null,
                // also check before any parenthesis CV: might have before it

                aField => new Regex("(?<!(\\(|())CV:").IsMatch(aField) ? "\"(\" before \"CV:\"" : null,
                // implied from the "Character (CV: Voice Actor)" format requirement

                aField => new Regex(",[a-zA-Z0-9]").IsMatch(aField) ? "whitespace after \",\"" : null,
                // comma only checks trailing whitespaces
            };
            List <Func <string, string> > warningTests = new List <Func <string, string> >()
            {
                // Markers only need spaces around them if both of the following are true
                // - They are not full width (i.e. "、" for comma and ":" for colon)
                // - The character after/before is not full width (i.e. most chinese/japanese characters)
                // Source: Lanturn (metadata helper at the time of writing this)

                // The regex "[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー]" matches all japanese characters.

                aField => new Regex("(?<! |\\(|()feat\\.").IsMatch(aField) ? "whitespace before \"feat.\""    : null,
                aField => new Regex("(?<! )(\\(|()feat\\.").IsMatch(aField) ? "whitespace before \"(feat.\""   : null,
                aField => new Regex("(?<! |[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー])vs\\.").IsMatch(aField) ? "whitespace before \"vs.\""      : null,
                aField => new Regex("(?<! |[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー])&").IsMatch(aField) ? "whitespace before \"&\""        : null,

                aField => new Regex("CV(?!:[ 一-龠]+|[ぁ-ゔ]+|[ァ-ヴー]|:)").IsMatch(aField) ? "whitespace after \"CV:\" or full-width colon \":\"" : null,
                aField => new Regex(",(?![ 一-龠]+|[ぁ-ゔ]+|[ァ-ヴー])").IsMatch(aField) ? "whitespace after \",\" or full-width comma \"、\""   : null,

                aField => new Regex("feat\\.(?! |[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー])").IsMatch(aField) ? "whitespace after \"feat.\"" : null,
                aField => new Regex("vs\\.(?! |[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー])").IsMatch(aField) ? "whitespace after \"vs.\""   : null,
                aField => new Regex("&(?! |[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー])").IsMatch(aField) ? "whitespace after \"&\""     : null,
            };

            MetadataSettings metadata             = beatmap.metadataSettings;
            List <Tuple <string, string> > fields = new List <Tuple <string, string> >()
            {
                new Tuple <string, string>(metadata.artist, "artist"),
                new Tuple <string, string>(metadata.artistUnicode, "artist unicode")
            };

            List <Tuple <Tuple <string, string>, string, bool> > issueMessages = new List <Tuple <Tuple <string, string>, string, bool> >();

            foreach (Tuple <string, string> field in fields)
            {
                // old osu versions didn't have unicode fields
                if (field.Item1 != null)
                {
                    foreach (Func <string, string> problemTest in problemTests)
                    {
                        string message = problemTest(field.Item1);
                        if (message != null && !issueMessages.Any(aTuple => aTuple.Item2 == message && aTuple.Item1 == field))
                        {
                            issueMessages.Add(new Tuple <Tuple <string, string>, string, bool>(field, message, true));
                        }
                    }

                    foreach (Func <string, string> warningTest in warningTests)
                    {
                        string message = warningTest(field.Item1);
                        if (message != null && !issueMessages.Any(aTuple => aTuple.Item2 == message && aTuple.Item1 == field))
                        {
                            issueMessages.Add(new Tuple <Tuple <string, string>, string, bool>(field, message, false));
                        }
                    }
                }
            }

            foreach (Tuple <Tuple <string, string>, string, bool> messageTuple in issueMessages)
            {
                yield return(new Issue(GetTemplate(messageTuple.Item3 ? "Problem" : "Warning"), null,
                                       messageTuple.Item2, messageTuple.Item1.Item2,
                                       messageTuple.Item1.Item1));
            }
        }
Exemplo n.º 21
0
        public override IEnumerable <Issue> GetIssues(BeatmapSet beatmapSet)
        {
            Beatmap beatmap = beatmapSet.beatmaps[0];

            List <Func <string, string> > problemTests = new List <Func <string, string> >()
            {
                field => FormalSpaceRegex(field, @"CV:"),
                field => FormalSpaceRegex(field, @"vs\."),
                field => FormalSpaceRegex(field, @"feat\."),

                field => new Regex(@"[a-zA-Z0-9]\(CV:").IsMatch(field) ? "whitespace before \"(CV:\" or full-width bracket \"(\"" : null,
                // also check before any parenthesis CV: might have before it

                field => new Regex(@"(?<!(\(|())CV:").IsMatch(field) ? "\"(\" before \"CV:\"" : null,
                // implied from the "Character (CV: Voice Actor)" format requirement

                field => new Regex(@",[a-zA-Z0-9]").IsMatch(field) ? "whitespace after \",\"" : null,
                // comma only checks trailing whitespaces
            };
            List <Func <string, string> > warningTests = new List <Func <string, string> >()
            {
                // Some artists include ampersand as part of their name.
                field => FormalSpaceRegex(field, "&"),

                // Markers only need spaces around them if both of the following are true
                // - They are not full width (i.e. "、" for comma and ":" for colon)
                // - The character after/before is not full width (i.e. most chinese/japanese characters)
                // Source: Lanturn (metadata helper at the time of writing this)

                // The regex "[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー]" matches all japanese characters.

                field => new Regex(@"(?<! |\(|()feat\.").IsMatch(field) ? "whitespace before \"feat.\""    : null,
                field => new Regex(@"(?<! )(\(|()feat\.").IsMatch(field) ? "whitespace before \"(feat.\""   : null,
                field => new Regex(@"(?<! |[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー])vs\.").IsMatch(field) ? "whitespace before \"vs.\""      : null,
                field => new Regex(@"(?<! |[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー])&").IsMatch(field) ? "whitespace before \"&\""        : null,

                field => new Regex(@"CV(?!:[ 一-龠]+|[ぁ-ゔ]+|[ァ-ヴー]|:)").IsMatch(field) ? "whitespace after \"CV:\" or full-width colon \":\"" : null,
                field => new Regex(@",(?![ 一-龠]+|[ぁ-ゔ]+|[ァ-ヴー])").IsMatch(field) ? "whitespace after \",\" or full-width comma \"、\""   : null,

                field => new Regex(@"feat\.(?! |[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー])").IsMatch(field) ? "whitespace after \"feat.\"" : null,
                field => new Regex(@"vs\.(?! |[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー])").IsMatch(field) ? "whitespace after \"vs.\""   : null,
                field => new Regex(@"&(?! |[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー])").IsMatch(field) ? "whitespace after \"&\""     : null,
            };

            MetadataSettings metadata = beatmap.metadataSettings;
            List <Field>     fields   = new List <Field>()
            {
                new Field("artist", metadata.artist),
                new Field("artist unicode", metadata.artistUnicode)
            };

            List <FieldIssue> fieldIssues = new List <FieldIssue>();

            foreach (Field field in fields)
            {
                // old osu versions didn't have unicode fields
                if (field.content == null)
                {
                    continue;
                }

                foreach (Func <string, string> problemTest in problemTests)
                {
                    string message = problemTest(field.content);
                    if (message != null && !fieldIssues.Any(fieldIssue => fieldIssue.message == message && fieldIssue.field == field))
                    {
                        fieldIssues.Add(new FieldIssue(field, message, isProblem: true));
                    }
                }

                foreach (Func <string, string> warningTest in warningTests)
                {
                    string message = warningTest(field.content);
                    if (message != null && !fieldIssues.Any(fieldIssue => fieldIssue.message == message && fieldIssue.field == field))
                    {
                        fieldIssues.Add(new FieldIssue(field, message, isProblem: false));
                    }
                }
            }

            foreach (FieldIssue fieldIssue in fieldIssues)
            {
                yield return(new Issue(GetTemplate(fieldIssue.isProblem ? "Problem" : "Warning"), null,
                                       fieldIssue.message, fieldIssue.field.name, fieldIssue.field.content));
            }
        }
Exemplo n.º 22
0
        private void BuildMetadataContext(FederationPartyConfiguration federationPartyContext, MetadataSettings metadataSettings)
        {
            var metadataContextBuilder = new MetadataContextBuilder(this._dbContext, this._cacheProvider);
            var metadata = metadataContextBuilder.BuildFromDbSettings(metadataSettings);

            federationPartyContext.MetadataContext = metadata;
        }
        private void BuildMetadataContext(TenantContext relyingPartyContext, MetadataSettings metadataSettings)
        {
            var metadataContextBuilder = new MetadataContextBuilder(this._dbContext, this._cacheProvider);

            relyingPartyContext.MetadataContext = metadataContextBuilder.BuildFromDbSettings(metadataSettings);
        }
Exemplo n.º 24
0
        public void OnExecute()
        {
            if (MapsetPath == null)
            {
                Console.WriteLine("Missing argument: MapsetPath. Use -h to show help.");
                return;
            }

            BeatmapSet beatmapSet = new BeatmapSet(MapsetPath);

            if (Verbose)
            {
                if (OutputAsJSON)
                {
                    Checker.OnLoadStart    = LoadStartJS;
                    Checker.OnLoadComplete = LoadFinishJS;
                }
                else
                {
                    Checker.OnLoadStart    = LoadStart;
                    Checker.OnLoadComplete = LoadFinish;
                }
            }

            Checker.LoadCheckDLLs();
            IEnumerable <Issue> issues =
                Checker.GetBeatmapSetIssues(beatmapSet)
                .Where(anIssue => anIssue.level >= IssueLevel);

            List <JSONIssue> mapIssues = new List <JSONIssue>();

            foreach (var beatmapIssues in issues.GroupBy(anIssue => anIssue.beatmap))
            {
                JSONIssue diffIssue = new JSONIssue();

                Beatmap beatmap = beatmapIssues.Key;
                diffIssue.difficulty = beatmap?.ToString() ?? "[General]";
                diffIssue.problems   = new List <CategoryIssue>();

                foreach (var category in beatmapIssues.GroupBy(anIssue => anIssue.CheckOrigin))
                {
                    if (beatmap == null || category.Any(anIssue => anIssue.AppliesToDifficulty(beatmap.GetDifficulty())))
                    {
                        CategoryIssue categoryIssue = new CategoryIssue();
                        categoryIssue.problems = new List <Problem>();
                        categoryIssue.message  = category.Key.GetMetadata().Message;

                        foreach (Issue issue in category)
                        {
                            if (beatmap == null || issue.AppliesToDifficulty(beatmap.GetDifficulty()))
                            {
                                Problem problemIssue = new Problem();
                                problemIssue.level   = issue.level;
                                problemIssue.message = issue.message;
                                categoryIssue.problems.Add(problemIssue);
                            }
                        }
                        diffIssue.problems.Add(categoryIssue);
                    }
                }
                mapIssues.Add(diffIssue);
            }

            Result           mapResult   = new Result();
            Metadata         mapMetadata = new Metadata();
            MetadataSettings settings    = beatmapSet.beatmaps.First().metadataSettings;

            mapMetadata.artist = settings.GetFileNameFiltered(settings.artist);
            mapMetadata.title  = settings.GetFileNameFiltered(settings.title);
            mapMetadata.mapper = settings.GetFileNameFiltered(settings.creator);
            mapResult.metadata = mapMetadata;
            mapResult.results  = mapIssues;
            if (OutputAsJSON)
            {
                Console.Write(JsonConvert.SerializeObject(mapResult));
            }
            else
            {
                foreach (JSONIssue diff in mapIssues)
                {
                    Console.WriteLine(diff.difficulty);
                    foreach (CategoryIssue category in diff.problems)
                    {
                        Console.WriteLine(category.message);
                        foreach (Problem timestamp in category.problems)
                        {
                            Console.WriteLine($"\t {timestamp.level} - {timestamp.message}");
                        }
                    }
                    Console.WriteLine();
                }
            }
        }
Exemplo n.º 25
0
        private void HandleTiledAttributes(GameObject gameObject, XElement goXml, int previousMapID, MetadataSettings previousMetadata)
        {
            // Add the TiledMap component
            TiledMap map = gameObject.AddComponent <TiledMap>();

            try
            {
                map.NumTilesWide      = ImportUtils.GetAttributeAsInt(goXml, "numTilesWide");
                map.NumTilesHigh      = ImportUtils.GetAttributeAsInt(goXml, "numTilesHigh");
                map.TileWidth         = ImportUtils.GetAttributeAsInt(goXml, "tileWidth");
                map.TileHeight        = ImportUtils.GetAttributeAsInt(goXml, "tileHeight");
                map.ExportScale       = ImportUtils.GetAttributeAsFloat(goXml, "exportScale");
                map.MapWidthInPixels  = ImportUtils.GetAttributeAsInt(goXml, "mapWidthInPixels");
                map.MapHeightInPixels = ImportUtils.GetAttributeAsInt(goXml, "mapHeightInPixels");
                if (previousMapID == 0)
                {
                    map.MapID = IDHandler.getNextMapID(EditorApplication.currentScene);
                }
                else
                {
                    map.MapID = previousMapID;
                }
                map.gameObject.AddComponent <MetadataSettings>();
                if (previousMetadata != null)
                {
                    map.gameObject.GetComponent <MetadataSettings>().Copy(previousMetadata);
                }
            }
            catch
            {
                Debug.LogWarning(String.Format("Error adding TiledMap component. Are you using an old version of Tiled2Unity in your Unity project?"));
                GameObject.DestroyImmediate(map);
            }
        }
Exemplo n.º 26
0
        public Beatmap(string code, double?starRating = null, string songPath = null, string mapPath = null)
        {
            this.code     = code;
            this.songPath = songPath;
            this.mapPath  = mapPath;

            string[] lines = code.Split(new string[] { "\n" }, StringSplitOptions.None);

            generalSettings    = ParserStatic.GetSettings(lines, "General", sectionLines => new GeneralSettings(sectionLines));
            metadataSettings   = ParserStatic.GetSettings(lines, "Metadata", sectionLines => new MetadataSettings(sectionLines));
            difficultySettings = ParserStatic.GetSettings(lines, "Difficulty", sectionLines => new DifficultySettings(sectionLines));
            colourSettings     = ParserStatic.GetSettings(lines, "Colours", sectionLines => new ColourSettings(sectionLines));

            // event type 3 seems to be "background colour transformation" https://i.imgur.com/Tqlz3s5.png

            backgrounds = GetEvents(lines, new List <string>()
            {
                "Background", "0"
            }, args => new Background(args));
            videos = GetEvents(lines, new List <string>()
            {
                "Video", "1"
            }, args => new Video(args));
            breaks = GetEvents(lines, new List <string>()
            {
                "Break", "2"
            }, args => new Break(args));
            sprites = GetEvents(lines, new List <string>()
            {
                "Sprite", "4"
            }, args => new Sprite(args));
            samples = GetEvents(lines, new List <string>()
            {
                "Sample", "5"
            }, args => new Sample(args));
            animations = GetEvents(lines, new List <string>()
            {
                "Animation", "6"
            }, args => new Animation(args));

            timingLines = GetTimingLines(lines);
            hitObjects  = GetHitobjects(lines);

            if (generalSettings.mode != Mode.Standard)
            {
                return;
            }

            // Stacking is standard-only.
            ApplyStacking();

            if (starRating != null)
            {
                this.starRating = starRating.Value;
            }
            else
            {
                DifficultyAttributes attributes = new OsuDifficultyCalculator(this).Calculate();
                difficultyAttributes = attributes;
                this.starRating      = attributes.StarRating;
            }
        }
Exemplo n.º 27
0
 public static MetadataSettings ReadMetadata() => MetadataSettings.Load(TestDirectory);