예제 #1
0
파일: Skin.cs 프로젝트: shadiwolf/e
        protected Skin(SkinInfo skin, IStorageResourceProvider resources)
        {
            SkinInfo = skin;

            // 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 = SkinInfo.Files?.FirstOrDefault(f => f.Filename == filename);

                if (fileInfo == null)
                {
                    continue;
                }

                var bytes = resources?.Files.Get(fileInfo.FileInfo.StoragePath);

                if (bytes == null)
                {
                    continue;
                }

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

                if (deserializedContent == null)
                {
                    continue;
                }

                DrawableComponentInfo[skinnableTarget] = deserializedContent.ToArray();
            }
        }
예제 #2
0
 public LegacySkin(SkinInfo skin, IResourceStore <byte[]> storage, AudioManager audioManager)
     : base(skin)
 {
     storage  = new LegacySkinResourceStore(skin, storage);
     samples  = audioManager.GetSampleManager(storage);
     textures = new TextureStore(new RawTextureLoaderStore(storage));
 }
예제 #3
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;
            }
        }
예제 #4
0
파일: Skin.cs 프로젝트: 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.");
                    }
                }
            });
        }
예제 #5
0
 protected LegacySkin(SkinInfo skin, IStorageResourceProvider?resources, IResourceStore <byte[]>?storage, string configurationFilename = @"skin.ini")
     : base(skin, resources, storage, configurationFilename)
 {
     // todo: this shouldn't really be duplicated here (from ManiaLegacySkinTransformer). we need to come up with a better solution.
     hasKeyTexture = new Lazy <bool>(() => this.GetAnimation(
                                         lookupForMania <string>(new LegacyManiaSkinConfigurationLookup(4, LegacyManiaSkinConfigurationLookups.KeyImage, 0))?.Value ?? "mania-key1", true,
                                         true) != null);
 }
 private void initialiseFileCache(SkinInfo source)
 {
     fileToStoragePathMapping.Clear();
     foreach (var f in source.Files)
     {
         fileToStoragePathMapping[f.Filename.ToLowerInvariant()] = f.File.GetStoragePath();
     }
 }
예제 #7
0
 public LegacySkin(SkinInfo skin, IResourceStore <byte[]> storage, AudioManager audioManager)
     : this(skin, new LegacySkinResourceStore <SkinFileInfo>(skin, storage), audioManager, "skin.ini")
 {
     // defaults should only be applied for non-beatmap skins (which are parsed via this constructor).
     if (!Configuration.CustomColours.ContainsKey("SliderBall"))
     {
         Configuration.CustomColours["SliderBall"] = new Color4(2, 170, 255, 255);
     }
 }
예제 #8
0
        public DefaultLegacySkin(SkinInfo skin, IResourceStore <byte[]> storage, IStorageResourceProvider resources)
            : base(skin, storage, resources, string.Empty)
        {
            Configuration.CustomColours["SliderBall"] = new Color4(2, 170, 255, 255);
            Configuration.AddComboColours(
                new Color4(255, 192, 0, 255),
                new Color4(0, 202, 0, 255),
                new Color4(18, 124, 255, 255),
                new Color4(242, 24, 57, 255)
                );

            Configuration.LegacyVersion = 2.7m;
        }
예제 #9
0
        public DefaultLegacySkin(SkinInfo skin, IStorageResourceProvider resources)
            : base(skin, new NamespacedResourceStore <byte[]>(resources.Resources, "Skins/Legacy"), resources, string.Empty)
        {
            Configuration.CustomColours["SliderBall"] = new Color4(2, 170, 255, 255);
            Configuration.CustomComboColours          = new List <Color4>
            {
                new Color4(255, 192, 0, 255),
                new Color4(0, 202, 0, 255),
                new Color4(18, 124, 255, 255),
                new Color4(242, 24, 57, 255)
            };

            Configuration.LegacyVersion = 2.7m;
        }
예제 #10
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));
        }
예제 #11
0
        public DefaultLegacySkin(SkinInfo skin, IStorageResourceProvider resources)
            : base(
                skin,
                resources,
                // In the case of the actual default legacy skin (ie. the fallback one, which a user hasn't applied any modifications to) we want to use the game provided resources.
                skin.Protected ? new NamespacedResourceStore <byte[]>(resources.Resources, "Skins/Legacy") : null
                )
        {
            Configuration.CustomColours["SliderBall"] = new Color4(2, 170, 255, 255);
            Configuration.CustomComboColours          = new List <Color4>
            {
                new Color4(255, 192, 0, 255),
                new Color4(0, 202, 0, 255),
                new Color4(18, 124, 255, 255),
                new Color4(242, 24, 57, 255)
            };

            Configuration.LegacyVersion = 2.7m;
        }
예제 #12
0
        public DefaultLegacySkin(SkinInfo skin, IStorageResourceProvider resources)
            : base(
                skin,
                new NamespacedResourceStore <byte[]>(resources.Resources, "Skins/Legacy"),
                resources,
                // A default legacy skin may still have a skin.ini if it is modified by the user.
                // We must specify the stream directly as we are redirecting storage to the osu-resources location for other files.
                new LegacyDatabasedSkinResourceStore(skin, resources.Files).GetStream("skin.ini")
                )
        {
            Configuration.CustomColours["SliderBall"] = new Color4(2, 170, 255, 255);
            Configuration.CustomComboColours          = new List <Color4>
            {
                new Color4(255, 192, 0, 255),
                new Color4(0, 202, 0, 255),
                new Color4(18, 124, 255, 255),
                new Color4(242, 24, 57, 255)
            };

            Configuration.LegacyVersion = 2.7m;
        }
예제 #13
0
        /// <summary>
        /// Construct a new legacy skin instance.
        /// </summary>
        /// <param name="skin">The model for this skin.</param>
        /// <param name="storage">A storage for looking up files within this skin using user-facing filenames.</param>
        /// <param name="resources">Access to raw game resources.</param>
        /// <param name="configurationStream">An optional stream containing the contents of a skin.ini file.</param>
        protected LegacySkin(SkinInfo skin, [CanBeNull] IResourceStore <byte[]> storage, [CanBeNull] IStorageResourceProvider resources, [CanBeNull] Stream configurationStream)
            : base(skin, resources, configurationStream)
        {
            if (storage != null)
            {
                var samples = resources?.AudioManager?.GetSampleStore(storage);
                if (samples != null)
                {
                    samples.PlaybackConcurrency = OsuGameBase.SAMPLE_CONCURRENCY;
                }

                Samples  = samples;
                Textures = new TextureStore(resources?.CreateTextureLoaderStore(storage));

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

            // todo: this shouldn't really be duplicated here (from ManiaLegacySkinTransformer). we need to come up with a better solution.
            hasKeyTexture = new Lazy <bool>(() => this.GetAnimation(
                                                lookupForMania <string>(new LegacyManiaSkinConfigurationLookup(4, LegacyManiaSkinConfigurationLookups.KeyImage, 0))?.Value ?? "mania-key1", true,
                                                true) != null);
        }
예제 #14
0
 public LegacySkinResourceStore(SkinInfo skin, IResourceStore <byte[]> underlyingStore)
 {
     this.skin            = skin;
     this.underlyingStore = underlyingStore;
 }
예제 #15
0
 public LegacySkin(SkinInfo skin, IStorageResourceProvider resources)
     : this(skin, new LegacySkinResourceStore <SkinFileInfo>(skin, resources.Files), resources, "skin.ini")
 {
 }
예제 #16
0
 public DefaultSkin(SkinInfo skin, IStorageResourceProvider resources)
     : base(skin, resources)
 {
     this.resources = resources;
     Configuration  = new DefaultSkinConfiguration();
 }
예제 #17
0
 /// <summary>
 /// Construct a new legacy skin instance.
 /// </summary>
 /// <param name="skin">The model for this skin.</param>
 /// <param name="storage">A storage for looking up files within this skin using user-facing filenames.</param>
 /// <param name="resources">Access to raw game resources.</param>
 /// <param name="configurationFilename">The user-facing filename of the configuration file to be parsed. Can accept an .osu or skin.ini file.</param>
 protected LegacySkin(SkinInfo skin, [CanBeNull] IResourceStore <byte[]> storage, [CanBeNull] IStorageResourceProvider resources, string configurationFilename)
     : this(skin, storage, resources, storage?.GetStream(configurationFilename))
 {
 }
예제 #18
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.");
                }
            }
        }
 public bool Equals(SkinInfo other) => other != null && ID == other.ID;
예제 #20
0
 public DefaultSkin(SkinInfo skin, IStorageResourceProvider resources)
     : base(skin, resources)
 {
     this.resources = resources;
 }
예제 #21
0
 public LegacySkin(SkinInfo skin, IResourceStore <byte[]> storage, AudioManager audioManager)
     : this(skin, new LegacySkinResourceStore <SkinFileInfo>(skin, storage), audioManager, "skin.ini")
 {
 }
예제 #22
0
 protected Skin(SkinInfo skin)
 {
     SkinInfo = skin;
 }
 public LegacyDatabasedSkinResourceStore(SkinInfo source, IResourceStore <byte[]> underlyingStore)
     : base(underlyingStore)
 {
     initialiseFileCache(source);
 }
예제 #24
0
 public LegacySkin(SkinInfo skin, IStorageResourceProvider resources)
     : this(skin, resources, null)
 {
 }