private void load(GameHost host, KaraokeRulesetConfigManager manager)
        {
            var storage = host.Storage;

            if (!storage.ExistsDirectory(base_path))
            {
                return;
            }

            // get all font usage which wants to import.
            var targetImportFonts = new[]
            {
                manager.Get <FontUsage>(KaraokeRulesetSetting.MainFont),
                manager.Get <FontUsage>(KaraokeRulesetSetting.RubyFont),
                manager.Get <FontUsage>(KaraokeRulesetSetting.RomajiFont),
                manager.Get <FontUsage>(KaraokeRulesetSetting.TranslateFont),
                manager.Get <FontUsage>(KaraokeRulesetSetting.NoteFont),
            };

            // convert to file path then import
            var targetImportFontPaths = targetImportFonts.Select(x =>
            {
                var path = Path.Combine(base_path, x.FontName);
                var pathWithExtension = Path.ChangeExtension(path, "cached");
                return(pathWithExtension);
            }).Where(p => storage.Exists(p)).Distinct().ToArray();

            if (!targetImportFontPaths.Any())
            {
                return;
            }

            // create font store if wants to import.
            localFontStore = new FontStore(scaleAdjust: 200, minFilterMode: All.Linear);
            fontStore.AddStore(localFontStore);

            foreach (var path in targetImportFontPaths)
            {
                var fontName  = Path.GetFileNameWithoutExtension(path);
                var resources = new CachedFontArchiveReader(storage.GetStream(path), fontName);
                var store     = new GlyphStore(new ResourceStore <byte[]>(resources), $"{fontName}", host.CreateTextureLoaderStore(resources));
                localFontStore.AddStore(store);
            }
        }
Exemplo n.º 2
0
        private void load()
        {
            Scale        = new Vector2((float)(config?.Get <double>(KaraokeRulesetSetting.LyricScale) ?? 2));
            AutoSizeAxes = Axes.Both;

            AddInternal(lyricPieces = new Container <DefaultLyricPiece>
            {
                AutoSizeAxes = Axes.Both,
            });
            AddInternal(translateText = new OsuSpriteText
            {
                Anchor = Anchor.BottomLeft,
                Origin = Anchor.TopLeft,
            });

            SingersBindable.BindValueChanged(index => { ApplySkin(CurrentSkin, false); });
            LayoutIndexBindable.BindValueChanged(index => { ApplySkin(CurrentSkin, false); });
            TranslateTextBindable.BindCollectionChanged((_, args) => { ApplyTranslate(); });
        }
Exemplo n.º 3
0
        private void load(KaraokeRulesetConfigManager config, IBindable <IReadOnlyList <Mod> > mods, IBindable <WorkingBeatmap> beatmap, KaraokeSessionStatics session, EditorBeatmap editorBeatmap)
        {
            if (editorBeatmap != null)
            {
                session.SetValue(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.Edit);
                return;
            }

            this.beatmap = beatmap.Value.Beatmap;

            var disableMicrophoneDeviceByMod = mods.Value.OfType <IApplicableToMicrophone>().Any(x => !x.MicrophoneEnabled);

            if (disableMicrophoneDeviceByMod)
            {
                session.SetValue(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.AutoPlay);
                return;
            }

            var beatmapSaitenable = beatmap.Value.Beatmap.IsScorable();

            if (!beatmapSaitenable)
            {
                session.SetValue(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.NotSaitening);
                return;
            }

            try
            {
                var selectedDevice = config.Get <string>(KaraokeRulesetSetting.MicrophoneDevice);
                var microphoneList = new MicrophoneManager().MicrophoneDeviceNames.ToList();

                // Find index by selection id
                var deviceIndex = microphoneList.IndexOf(selectedDevice);
                AddHandler(new OsuTKMicrophoneHandler(deviceIndex));

                session.SetValue(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.Saitening);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "Microphone initialize error.");
                // todo : set real error by exception
                session.SetValue(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.WindowsMicrophonePermissionDeclined);
            }
        }