Example #1
0
        private IBindable <TValue> legacySettingLookup <TValue>(SkinConfiguration.LegacySetting legacySetting)
        {
            switch (legacySetting)
            {
            case SkinConfiguration.LegacySetting.Version:
                return(SkinUtils.As <TValue>(new Bindable <decimal>(Configuration.LegacyVersion ?? SkinConfiguration.LATEST_VERSION)));

            default:
                return(genericLookup <SkinConfiguration.LegacySetting, TValue>(legacySetting));
            }
        }
        public override IBindable <TValue>?GetConfig <TLookup, TValue>(TLookup lookup)
        {
            switch (lookup)
            {
            case GlobalSkinColours colour:
                switch (colour)
                {
                case GlobalSkinColours.ComboColours:
                    var comboColours = Configuration.ComboColours;
                    if (comboColours != null)
                    {
                        return(SkinUtils.As <TValue>(new Bindable <IReadOnlyList <Color4> >(comboColours)));
                    }

                    break;

                default:
                    return(SkinUtils.As <TValue>(getCustomColour(Configuration, colour.ToString())));
                }

                break;

            case SkinComboColourLookup comboColour:
                return(SkinUtils.As <TValue>(GetComboColour(Configuration, comboColour.ColourIndex, comboColour.Combo)));

            case SkinCustomColourLookup customColour:
                return(SkinUtils.As <TValue>(getCustomColour(Configuration, customColour.Lookup.ToString())));

            case LegacyManiaSkinConfigurationLookup maniaLookup:
                if (!AllowManiaSkin)
                {
                    break;
                }

                var result = lookupForMania <TValue>(maniaLookup);
                if (result != null)
                {
                    return(result);
                }

                break;

            case SkinConfiguration.LegacySetting legacy:
                return(legacySettingLookup <TValue>(legacy));

            default:
                return(genericLookup <TLookup, TValue>(lookup));
            }

            return(null);
        }
Example #3
0
        public override IBindable <TValue> GetConfig <TLookup, TValue>(TLookup lookup)
        {
            switch (lookup)
            {
            case LegacySkinConfiguration.LegacySetting s when s == LegacySkinConfiguration.LegacySetting.Version:
                if (Configuration.LegacyVersion is decimal version)
                {
                    return(SkinUtils.As <TValue>(new Bindable <decimal>(version)));
                }

                return(null);
            }

            return(base.GetConfig <TLookup, TValue>(lookup));
        }
        public override IBindable <TValue> GetConfig <TLookup, TValue>(TLookup lookup)
        {
            switch (lookup)
            {
            case GlobalSkinConfiguration global:
                switch (global)
                {
                case GlobalSkinConfiguration.ComboColours:
                    return(SkinUtils.As <TValue>(new Bindable <List <Color4> >(Configuration.ComboColours)));
                }

                break;

            case GlobalSkinColour colour:
                return(SkinUtils.As <TValue>(getCustomColour(colour.ToString())));

            case SkinCustomColourLookup customColour:
                return(SkinUtils.As <TValue>(getCustomColour(customColour.Lookup.ToString())));

            default:
                try
                {
                    if (Configuration.ConfigDictionary.TryGetValue(lookup.ToString(), out var val))
                    {
                        // special case for handling skins which use 1 or 0 to signify a boolean state.
                        if (typeof(TValue) == typeof(bool))
                        {
                            val = val == "1" ? "true" : "false";
                        }

                        var bindable = new Bindable <TValue>();
                        if (val != null)
                        {
                            bindable.Parse(val);
                        }
                        return(bindable);
                    }
                }
                catch
                {
                }

                break;
            }

            return(null);
        }
Example #5
0
        public override IBindable <TValue> GetConfig <TLookup, TValue>(TLookup lookup)
        {
            switch (lookup)
            {
            // todo: this code is pulled from LegacySkin and should not exist.
            // will likely change based on how databased storage of skin configuration goes.
            case GlobalSkinColours global:
                switch (global)
                {
                case GlobalSkinColours.ComboColours:
                    return(SkinUtils.As <TValue>(new Bindable <IReadOnlyList <Color4> >(Configuration.ComboColours)));
                }

                break;
            }

            return(null);
        }
        private IBindable <TValue>?lookupForMania <TValue>(LegacyManiaSkinConfigurationLookup maniaLookup)
        {
            if (!maniaConfigurations.TryGetValue(maniaLookup.Keys, out var existing))
            {
                maniaConfigurations[maniaLookup.Keys] = existing = new LegacyManiaSkinConfiguration(maniaLookup.Keys);
            }

            switch (maniaLookup.Lookup)
            {
            case LegacyManiaSkinConfigurationLookups.ColumnWidth:
                Debug.Assert(maniaLookup.TargetColumn != null);
                return(SkinUtils.As <TValue>(new Bindable <float>(existing.ColumnWidth[maniaLookup.TargetColumn.Value])));

            case LegacyManiaSkinConfigurationLookups.ColumnSpacing:
                Debug.Assert(maniaLookup.TargetColumn != null);
                return(SkinUtils.As <TValue>(new Bindable <float>(existing.ColumnSpacing[maniaLookup.TargetColumn.Value])));

            case LegacyManiaSkinConfigurationLookups.HitPosition:
                return(SkinUtils.As <TValue>(new Bindable <float>(existing.HitPosition)));

            case LegacyManiaSkinConfigurationLookups.ScorePosition:
                return(SkinUtils.As <TValue>(new Bindable <float>(existing.ScorePosition)));

            case LegacyManiaSkinConfigurationLookups.LightPosition:
                return(SkinUtils.As <TValue>(new Bindable <float>(existing.LightPosition)));

            case LegacyManiaSkinConfigurationLookups.ShowJudgementLine:
                return(SkinUtils.As <TValue>(new Bindable <bool>(existing.ShowJudgementLine)));

            case LegacyManiaSkinConfigurationLookups.ExplosionImage:
                return(SkinUtils.As <TValue>(getManiaImage(existing, "LightingN")));

            case LegacyManiaSkinConfigurationLookups.ExplosionScale:
                Debug.Assert(maniaLookup.TargetColumn != null);

                if (GetConfig <SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value < 2.5m)
                {
                    return(SkinUtils.As <TValue>(new Bindable <float>(1)));
                }

                if (existing.ExplosionWidth[maniaLookup.TargetColumn.Value] != 0)
                {
                    return(SkinUtils.As <TValue>(new Bindable <float>(existing.ExplosionWidth[maniaLookup.TargetColumn.Value] / LegacyManiaSkinConfiguration.DEFAULT_COLUMN_SIZE)));
                }

                return(SkinUtils.As <TValue>(new Bindable <float>(existing.ColumnWidth[maniaLookup.TargetColumn.Value] / LegacyManiaSkinConfiguration.DEFAULT_COLUMN_SIZE)));

            case LegacyManiaSkinConfigurationLookups.ColumnLineColour:
                return(SkinUtils.As <TValue>(getCustomColour(existing, "ColourColumnLine")));

            case LegacyManiaSkinConfigurationLookups.JudgementLineColour:
                return(SkinUtils.As <TValue>(getCustomColour(existing, "ColourJudgementLine")));

            case LegacyManiaSkinConfigurationLookups.ColumnBackgroundColour:
                Debug.Assert(maniaLookup.TargetColumn != null);
                return(SkinUtils.As <TValue>(getCustomColour(existing, $"Colour{maniaLookup.TargetColumn + 1}")));

            case LegacyManiaSkinConfigurationLookups.ColumnLightColour:
                Debug.Assert(maniaLookup.TargetColumn != null);
                return(SkinUtils.As <TValue>(getCustomColour(existing, $"ColourLight{maniaLookup.TargetColumn + 1}")));

            case LegacyManiaSkinConfigurationLookups.MinimumColumnWidth:
                return(SkinUtils.As <TValue>(new Bindable <float>(existing.MinimumColumnWidth)));

            case LegacyManiaSkinConfigurationLookups.NoteImage:
                Debug.Assert(maniaLookup.TargetColumn != null);
                return(SkinUtils.As <TValue>(getManiaImage(existing, $"NoteImage{maniaLookup.TargetColumn}")));

            case LegacyManiaSkinConfigurationLookups.HoldNoteHeadImage:
                Debug.Assert(maniaLookup.TargetColumn != null);
                return(SkinUtils.As <TValue>(getManiaImage(existing, $"NoteImage{maniaLookup.TargetColumn}H")));

            case LegacyManiaSkinConfigurationLookups.HoldNoteTailImage:
                Debug.Assert(maniaLookup.TargetColumn != null);
                return(SkinUtils.As <TValue>(getManiaImage(existing, $"NoteImage{maniaLookup.TargetColumn}T")));

            case LegacyManiaSkinConfigurationLookups.HoldNoteBodyImage:
                Debug.Assert(maniaLookup.TargetColumn != null);
                return(SkinUtils.As <TValue>(getManiaImage(existing, $"NoteImage{maniaLookup.TargetColumn}L")));

            case LegacyManiaSkinConfigurationLookups.HoldNoteLightImage:
                return(SkinUtils.As <TValue>(getManiaImage(existing, "LightingL")));

            case LegacyManiaSkinConfigurationLookups.HoldNoteLightScale:
                Debug.Assert(maniaLookup.TargetColumn != null);

                if (GetConfig <SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value < 2.5m)
                {
                    return(SkinUtils.As <TValue>(new Bindable <float>(1)));
                }

                if (existing.HoldNoteLightWidth[maniaLookup.TargetColumn.Value] != 0)
                {
                    return(SkinUtils.As <TValue>(new Bindable <float>(existing.HoldNoteLightWidth[maniaLookup.TargetColumn.Value] / LegacyManiaSkinConfiguration.DEFAULT_COLUMN_SIZE)));
                }

                return(SkinUtils.As <TValue>(new Bindable <float>(existing.ColumnWidth[maniaLookup.TargetColumn.Value] / LegacyManiaSkinConfiguration.DEFAULT_COLUMN_SIZE)));

            case LegacyManiaSkinConfigurationLookups.KeyImage:
                Debug.Assert(maniaLookup.TargetColumn != null);
                return(SkinUtils.As <TValue>(getManiaImage(existing, $"KeyImage{maniaLookup.TargetColumn}")));

            case LegacyManiaSkinConfigurationLookups.KeyImageDown:
                Debug.Assert(maniaLookup.TargetColumn != null);
                return(SkinUtils.As <TValue>(getManiaImage(existing, $"KeyImage{maniaLookup.TargetColumn}D")));

            case LegacyManiaSkinConfigurationLookups.LeftStageImage:
                return(SkinUtils.As <TValue>(getManiaImage(existing, "StageLeft")));

            case LegacyManiaSkinConfigurationLookups.RightStageImage:
                return(SkinUtils.As <TValue>(getManiaImage(existing, "StageRight")));

            case LegacyManiaSkinConfigurationLookups.BottomStageImage:
                return(SkinUtils.As <TValue>(getManiaImage(existing, "StageBottom")));

            case LegacyManiaSkinConfigurationLookups.LightImage:
                return(SkinUtils.As <TValue>(getManiaImage(existing, "StageLight")));

            case LegacyManiaSkinConfigurationLookups.HitTargetImage:
                return(SkinUtils.As <TValue>(getManiaImage(existing, "StageHint")));

            case LegacyManiaSkinConfigurationLookups.LeftLineWidth:
                Debug.Assert(maniaLookup.TargetColumn != null);
                return(SkinUtils.As <TValue>(new Bindable <float>(existing.ColumnLineWidth[maniaLookup.TargetColumn.Value])));

            case LegacyManiaSkinConfigurationLookups.RightLineWidth:
                Debug.Assert(maniaLookup.TargetColumn != null);
                return(SkinUtils.As <TValue>(new Bindable <float>(existing.ColumnLineWidth[maniaLookup.TargetColumn.Value + 1])));

            case LegacyManiaSkinConfigurationLookups.Hit0:
            case LegacyManiaSkinConfigurationLookups.Hit50:
            case LegacyManiaSkinConfigurationLookups.Hit100:
            case LegacyManiaSkinConfigurationLookups.Hit200:
            case LegacyManiaSkinConfigurationLookups.Hit300:
            case LegacyManiaSkinConfigurationLookups.Hit300g:
                return(SkinUtils.As <TValue>(getManiaImage(existing, maniaLookup.Lookup.ToString())));

            case LegacyManiaSkinConfigurationLookups.KeysUnderNotes:
                return(SkinUtils.As <TValue>(new Bindable <bool>(existing.KeysUnderNotes)));
            }

            return(null);
        }