Exemplo n.º 1
0
        protected LegacySkin(SkinInfo skin, IResourceStore <byte[]> storage, AudioManager audioManager, string filename)
            : base(skin)
        {
            Stream stream = storage.GetStream(filename);

            if (stream != null)
            {
                using (StreamReader reader = new StreamReader(stream))
                    Configuration = new LegacySkinDecoder().Decode(reader);
            }
            else
            {
                Configuration = new SkinConfiguration();
            }

            Samples  = audioManager.GetSampleStore(storage);
            Textures = new TextureStore(new TextureLoaderStore(storage));

            using (var testStream = storage.GetStream("hitcircle@2x") ?? storage.GetStream("hitcircle"))
                hasHitCircle |= testStream != null;

            if (hasHitCircle)
            {
                Configuration.SliderPathRadius = legacy_circle_radius;
            }
        }
Exemplo n.º 2
0
Arquivo: Skin.cs Projeto: bdach/osu
        protected Skin(SkinInfo skin, IStorageResourceProvider resources, [CanBeNull] Stream configurationStream = null)
        {
            SkinInfo       = skin.ToLive();
            this.resources = resources;

            configurationStream ??= getConfigurationStream();

            if (configurationStream != null)
            {
                // stream will be closed after use by LineBufferedReader.
                ParseConfigurationStream(configurationStream);
            }
            else
            {
                Configuration = new SkinConfiguration();
            }

            // skininfo files may be null for default skin.
            SkinInfo.PerformRead(s =>
            {
                // we may want to move this to some kind of async operation in the future.
                foreach (SkinnableTarget skinnableTarget in Enum.GetValues(typeof(SkinnableTarget)))
                {
                    string filename = $"{skinnableTarget}.json";

                    // skininfo files may be null for default skin.
                    var fileInfo = s.Files.FirstOrDefault(f => f.Filename == filename);

                    if (fileInfo == null)
                    {
                        continue;
                    }

                    byte[] bytes = resources?.Files.Get(fileInfo.File.GetStoragePath());

                    if (bytes == null)
                    {
                        continue;
                    }

                    try
                    {
                        string jsonContent      = Encoding.UTF8.GetString(bytes);
                        var deserializedContent = JsonConvert.DeserializeObject <IEnumerable <SkinnableInfo> >(jsonContent);

                        if (deserializedContent == null)
                        {
                            continue;
                        }

                        DrawableComponentInfo[skinnableTarget] = deserializedContent.ToArray();
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(ex, "Failed to load skin configuration.");
                    }
                }
            });
        }
Exemplo n.º 3
0
 public DefaultSkin()
     : base(SkinInfo.Default)
 {
     Configuration = new SkinConfiguration
     {
         ComboColours =
         {
             new Color4(17,  136, 170, 255),
             new Color4(102, 136,   0, 255),
             new Color4(204, 102,   0, 255),
             new Color4(121,   9,  13, 255)
         }
     };
 }
Exemplo n.º 4
0
        protected LegacySkin(SkinInfo skin, IResourceStore <byte[]> storage, AudioManager audioManager, string filename) : base(skin)
        {
            Stream stream = storage.GetStream(filename);

            if (stream != null)
            {
                using (StreamReader reader = new StreamReader(stream))
                    Configuration = new LegacySkinDecoder().Decode(reader);
            }
            else
            {
                Configuration = new SkinConfiguration();
            }

            Samples  = audioManager.GetSampleManager(storage);
            Textures = new TextureStore(new TextureLoaderStore(storage));
        }
Exemplo n.º 5
0
        protected Skin(SkinInfo skin, IStorageResourceProvider?resources, IResourceStore <byte[]>?storage = null, string configurationFilename = @"skin.ini")
        {
            if (resources != null)
            {
                SkinInfo = skin.ToLive(resources.RealmAccess);

                storage ??= realmBackedStorage = new RealmBackedResourceStore <SkinInfo>(SkinInfo, resources.Files, resources.RealmAccess);

                (storage as ResourceStore <byte[]>)?.AddExtension("ogg");

                var samples = resources.AudioManager?.GetSampleStore(storage);
                if (samples != null)
                {
                    samples.PlaybackConcurrency = OsuGameBase.SAMPLE_CONCURRENCY;
                }

                Samples  = samples;
                Textures = new TextureStore(resources.CreateTextureLoaderStore(storage));
            }
            else
            {
                // Generally only used for tests.
                SkinInfo = skin.ToLiveUnmanaged();
            }

            var configurationStream = storage?.GetStream(configurationFilename);

            if (configurationStream != null)
            {
                // stream will be closed after use by LineBufferedReader.
                ParseConfigurationStream(configurationStream);
                Debug.Assert(Configuration != null);
            }
            else
            {
                Configuration = new SkinConfiguration();
            }

            // skininfo files may be null for default skin.
            foreach (SkinnableTarget skinnableTarget in Enum.GetValues(typeof(SkinnableTarget)))
            {
                string filename = $"{skinnableTarget}.json";

                byte[]? bytes = storage?.Get(filename);

                if (bytes == null)
                {
                    continue;
                }

                try
                {
                    string jsonContent         = Encoding.UTF8.GetString(bytes);
                    var    deserializedContent = JsonConvert.DeserializeObject <IEnumerable <SkinnableInfo> >(jsonContent);

                    if (deserializedContent == null)
                    {
                        continue;
                    }

                    DrawableComponentInfo[skinnableTarget] = deserializedContent.ToArray();
                }
                catch (Exception ex)
                {
                    Logger.Error(ex, "Failed to load skin configuration.");
                }
            }
        }
Exemplo n.º 6
0
 protected virtual void ParseConfigurationStream(Stream stream)
 {
     using (LineBufferedReader reader = new LineBufferedReader(stream, true))
         Configuration = new LegacySkinDecoder().Decode(reader);
 }
Exemplo n.º 7
0
 public DefaultSkin()
     : base(SkinInfo.Default)
 {
     Configuration = new SkinConfiguration();
 }