예제 #1
0
        public override IBindable <TValue> GetConfig <TLookup, TValue>(TLookup lookup)
        {
            switch (lookup)
            {
            case OsuSkinColour colour:
                return(base.GetConfig <SkinCustomColourLookup, TValue>(new SkinCustomColourLookup(colour)));

            case OsuSkinConfiguration osuLookup:
                switch (osuLookup)
                {
                case OsuSkinConfiguration.SliderPathRadius:
                    if (hasHitCircle.Value)
                    {
                        return(SkinUtils.As <TValue>(new BindableFloat(LEGACY_CIRCLE_RADIUS)));
                    }

                    break;

                case OsuSkinConfiguration.HitCircleOverlayAboveNumber:
                    // See https://osu.ppy.sh/help/wiki/Skinning/skin.ini#%5Bgeneral%5D
                    // HitCircleOverlayAboveNumer (with typo) should still be supported for now.
                    return(base.GetConfig <OsuSkinConfiguration, TValue>(OsuSkinConfiguration.HitCircleOverlayAboveNumber) ??
                           base.GetConfig <OsuSkinConfiguration, TValue>(OsuSkinConfiguration.HitCircleOverlayAboveNumer));
                }

                break;
            }

            return(base.GetConfig <TLookup, TValue>(lookup));
        }
예제 #2
0
 /// <summary>
 ///     Applies the skin on all controls inside the form.
 /// </summary>
 private void ApplyAllControlsSkin()
 {
     foreach (Control c in Controls)
     {
         SkinUtils.ApplySkinToControl(FormSkin, c);
     }
 }
예제 #3
0
        protected override void OnControlAdded(ControlEventArgs e)
        {
            base.OnControlAdded(e);

            //Apply the skin to any control newly added to the form.
            if (FormSkin != null && !DesignMode)
            {
                SkinUtils.ApplySkinToControl(FormSkin, e.Control);
            }
        }
예제 #4
0
        public void ApplySkin(BaseSkin skin)
        {
            FlatStyle = skin.TabControlFlatStyle;
            FlatTabSelectedBackColor = skin.TabControlSelectedTabBackColor;
            FlatTabSelectedForeColor = skin.TabControlSelectedTabForeColor;
            FlatTabBorderColor       = skin.TabControlTabBorderColor;

            foreach (Control c in Controls)
            {
                SkinUtils.ApplySkinToControl(skin, c);
            }
        }
예제 #5
0
            public override IBindable <TValue> GetConfig <TLookup, TValue>(TLookup lookup)
            {
                if (lookup is CatchSkinConfiguration config)
                {
                    if (config == CatchSkinConfiguration.FlipCatcherPlate)
                    {
                        return(SkinUtils.As <TValue>(new Bindable <bool>(FlipCatcherPlate)));
                    }
                }

                return(base.GetConfig <TLookup, TValue>(lookup));
            }
        public override IBindable <TValue> GetConfig <TLookup, TValue>(TLookup lookup)
        {
            switch (lookup)
            {
            // Lookup skin by type and index
            case KaraokeSkinLookup skinLookup:
            {
                var config       = skinLookup.Config;
                var lookupNumber = skinLookup.Lookup;

                switch (config)
                {
                case KaraokeSkinConfiguration.LyricStyle:
                    return(SkinUtils.As <TValue>(bindableFonts[lookupNumber]));

                case KaraokeSkinConfiguration.LyricLayout:
                    return(SkinUtils.As <TValue>(bindableLayouts[lookupNumber]));

                case KaraokeSkinConfiguration.NoteStyle:
                    return(SkinUtils.As <TValue>(bindableNotes[lookupNumber]));

                case KaraokeSkinConfiguration.Singer:
                    return(SkinUtils.As <TValue>(bindableSingers[lookupNumber]));
                }

                break;
            }

            // Lookup list of name by type
            case KaraokeIndexLookup indexLookup:
                switch (indexLookup)
                {
                case KaraokeIndexLookup.Layout:
                    return(SkinUtils.As <TValue>(bindableLayoutsLookup));

                case KaraokeIndexLookup.Style:
                    return(SkinUtils.As <TValue>(bindableFontsLookup));

                case KaraokeIndexLookup.Note:
                    return(SkinUtils.As <TValue>(bindableNotesLookup));

                case KaraokeIndexLookup.Singer:
                    return(SkinUtils.As <TValue>(bindableSingersLookup));
                }

                break;
            }

            return(source.GetConfig <TLookup, TValue>(lookup));
        }
예제 #7
0
            public IBindable <TValue> GetConfig <TLookup, TValue>(TLookup lookup)
            {
                switch (lookup)
                {
                case OsuSkinConfiguration osuLookup:
                    if (osuLookup == OsuSkinConfiguration.CursorCentre)
                    {
                        return(SkinUtils.As <TValue>(new BindableBool()));
                    }

                    break;
                }

                return(null);
            }
예제 #8
0
파일: XRichEditor.cs 프로젝트: JWPLAY/AUBE
 private void InitFont()
 {
     if (SkinUtils.GetFont("맑은 고딕") != null)
     {
         editor.Document.DefaultCharacterProperties.FontName = SkinUtils.GetFont("맑은 고딕").FontFamily.Name;
     }
     else
     {
         if (SkinUtils.GetFont("굴림") != null)
         {
             editor.Document.DefaultCharacterProperties.FontName = SkinUtils.GetFont("굴림").FontFamily.Name;
         }
         else
         {
             editor.Document.DefaultCharacterProperties.FontName = AppearanceObject.DefaultFont.FontFamily.Name;
         }
     }
 }
예제 #9
0
        public IBindable <TValue> GetConfig <TLookup, TValue>(TLookup lookup)
        {
            if (!(lookup is KaraokeSkinLookup skinLookup))
            {
                throw new NotSupportedException();
            }

            var config = skinLookup.Config;

            switch (config)
            {
            case KaraokeSkinConfiguration.LyricStyle:
                return(SkinUtils.As <TValue>(BindableFont));

            case KaraokeSkinConfiguration.LyricLayout:
                return(SkinUtils.As <TValue>(BindableLayout));

            default:
                throw new NotSupportedException();
            }
        }
예제 #10
0
        public IBindable <TValue> GetConfig <TLookup, TValue>(TLookup lookup)
        {
            switch (lookup)
            {
            case OsuSkinColour colour:
                return(source.GetConfig <SkinCustomColourLookup, TValue>(new SkinCustomColourLookup(colour)));

            case OsuSkinConfiguration osuLookup:
                switch (osuLookup)
                {
                case OsuSkinConfiguration.SliderPathRadius:
                    if (hasHitCircle.Value)
                    {
                        return(SkinUtils.As <TValue>(new BindableFloat(LEGACY_CIRCLE_RADIUS)));
                    }

                    break;
                }

                break;
            }

            return(source.GetConfig <TLookup, TValue>(lookup));
        }
예제 #11
0
        private static void ApplySkinFromConfig()
        {
            var skin = Config.Instance.LastSkin;

            SkinHandler.SetCurrentSkin(SkinUtils.SkinFromString(skin));
        }
예제 #12
0
        private void LoadSkin(Skin skin)
        {
            try
            {
                if (skin == null)
                {
                    return;
                }

                EntityModel model = null;

                if (!skin.IsPersonaSkin)
                {
                    if (!string.IsNullOrWhiteSpace(skin.GeometryData) && !skin.GeometryData.Equals(
                            "null", StringComparison.InvariantCultureIgnoreCase))
                    {
                        try
                        {
                            if (string.IsNullOrWhiteSpace(skin.ResourcePatch) || skin.ResourcePatch == "null")
                            {
                                Log.Debug($"Resourcepatch null for player {Name}");
                            }
                            else
                            {
                                var resourcePatch = JsonConvert.DeserializeObject <SkinResourcePatch>(
                                    skin.ResourcePatch, GeometrySerializationSettings);

                                Dictionary <string, EntityModel> models = new Dictionary <string, EntityModel>();
                                BedrockResourcePack.LoadEntityModel(skin.GeometryData, models);

                                var processedModels = BedrockResourcePack.ProcessEntityModels(models);

                                if (processedModels == null || processedModels.Count == 0)
                                {
                                    Log.Warn($"!! Model count was 0 for player {NameTag} !!");

                                    if (!Directory.Exists("failed"))
                                    {
                                        Directory.CreateDirectory("failed");
                                    }

                                    File.WriteAllText(
                                        Path.Combine(
                                            "failed",
                                            $"{Environment.TickCount64}-{resourcePatch.Geometry.Default}.json"),
                                        skin.GeometryData);
                                }
                                else
                                {
                                    if (resourcePatch?.Geometry != null)
                                    {
                                        if (!processedModels.TryGetValue(resourcePatch.Geometry.Default, out model))
                                        {
                                            Log.Debug(
                                                $"Invalid geometry: {resourcePatch.Geometry.Default} for player {Name}");
                                        }
                                        else
                                        {
                                        }
                                    }
                                    else
                                    {
                                        Log.Debug($"Resourcepatch geometry was null for player {Name}");
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            string name = "N/A";
                            Log.Debug(ex, $"Could not create geometry ({name}): {ex.ToString()} for player {Name}");
                        }
                    }
                    else
                    {
                        //Log.Debug($"Geometry data null for player {Name}");
                    }
                }

                if (model == null)
                {
                    ModelFactory.TryGetModel(
                        skin.Slim ? "geometry.humanoid.custom" : "geometry.humanoid.customSlim", out model);

                    /*model = skin.Slim ? (EntityModel) new Models.HumanoidCustomslimModel() :
                     *      (EntityModel) new HumanoidModel();*/// new Models.HumanoidCustomGeometryHumanoidModel();
                }

                if (model != null && ValidateModel(model, Name))
                {
                    Image <Rgba32> skinBitmap = null;

                    if (!skin.TryGetBitmap(model, out skinBitmap))
                    {
                        Log.Warn($"No custom skin data for player {Name}");

                        if (Alex.Instance.Resources.TryGetBitmap("entity/alex", out var rawTexture))
                        {
                            skinBitmap = rawTexture;
                        }
                    }

                    //if (!Directory.Exists("skins"))
                    //	Directory.CreateDirectory("skins");

                    //var path = Path.Combine("skins", $"{model.Description.Identifier}-{Environment.TickCount64}");
                    //File.WriteAllText($"{path}.json", skin.GeometryData);
                    //skinBitmap.SaveAsPng($"{path}.png");

                    var modelTextureSize = new Point(
                        (int)model.Description.TextureWidth, (int)model.Description.TextureHeight);

                    var textureSize = new Point(skinBitmap.Width, skinBitmap.Height);

                    if (modelTextureSize != textureSize)
                    {
                        if (modelTextureSize.Y > textureSize.Y)
                        {
                            skinBitmap = SkinUtils.ConvertSkin(skinBitmap, modelTextureSize.X, modelTextureSize.Y);
                        }

                        /*var bitmap = skinBitmap;
                         * bitmap.Mutate<Rgba32>(xx =>
                         * {
                         *      xx.Resize(modelTextureSize.X, modelTextureSize.Y);
                         * //	xx.Flip(FlipMode.Horizontal);
                         * });
                         *
                         * skinBitmap = bitmap;*/
                    }

                    GeometryName = model.Description.Identifier;

                    var modelRenderer = new EntityModelRenderer(
                        model, TextureUtils.BitmapToTexture2D(Alex.Instance.GraphicsDevice, skinBitmap));

                    if (modelRenderer.Valid)
                    {
                        ModelRenderer = modelRenderer;
                    }
                    else
                    {
                        modelRenderer.Dispose();
                        Log.Debug($"Invalid model: for player {Name} (Disposing)");
                    }
                }
                else
                {
                    Log.Debug($"Invalid model for player {Name}");
                }
            }
            catch (Exception ex)
            {
                Log.Warn(ex, $"Error while handling player skin.");
            }
        }