diff --git a/Bloxstrap/App.xaml b/Bloxstrap/App.xaml index ff72fe3..ae4bfac 100644 --- a/Bloxstrap/App.xaml +++ b/Bloxstrap/App.xaml @@ -34,9 +34,9 @@ - + diff --git a/Bloxstrap/Enums/BootstrapperIcon.cs b/Bloxstrap/Enums/BootstrapperIcon.cs index a67185d..8706e82 100644 --- a/Bloxstrap/Enums/BootstrapperIcon.cs +++ b/Bloxstrap/Enums/BootstrapperIcon.cs @@ -2,14 +2,21 @@ { public enum BootstrapperIcon { + [EnumName(StaticName = "Bloxstrap")] IconBloxstrap, + [EnumName(StaticName = "2008")] Icon2008, + [EnumName(StaticName = "2011")] Icon2011, IconEarly2015, IconLate2015, + [EnumName(StaticName = "2017")] Icon2017, + [EnumName(StaticName = "2019")] Icon2019, + [EnumName(StaticName = "2022")] Icon2022, + [EnumName(FromTranslation = "Common.Custom")] IconCustom } } diff --git a/Bloxstrap/Enums/BootstrapperStyle.cs b/Bloxstrap/Enums/BootstrapperStyle.cs index 2dff225..5c5f6fd 100644 --- a/Bloxstrap/Enums/BootstrapperStyle.cs +++ b/Bloxstrap/Enums/BootstrapperStyle.cs @@ -8,6 +8,7 @@ ProgressDialog, ClassicFluentDialog, ByfronDialog, + [EnumName(StaticName = "Bloxstrap")] FluentDialog, FluentAeroDialog } diff --git a/Bloxstrap/Enums/CursorType.cs b/Bloxstrap/Enums/CursorType.cs index 98e8ec4..76e5038 100644 --- a/Bloxstrap/Enums/CursorType.cs +++ b/Bloxstrap/Enums/CursorType.cs @@ -2,6 +2,7 @@ { public enum CursorType { + [EnumName(FromTranslation = "Common.Default")] Default, From2006, From2013 diff --git a/Bloxstrap/Enums/FlagPresets/InGameMenuVersion.cs b/Bloxstrap/Enums/FlagPresets/InGameMenuVersion.cs index 0e63264..30bbc70 100644 --- a/Bloxstrap/Enums/FlagPresets/InGameMenuVersion.cs +++ b/Bloxstrap/Enums/FlagPresets/InGameMenuVersion.cs @@ -2,6 +2,7 @@ { public enum InGameMenuVersion { + [EnumName(FromTranslation = "Common.Default")] Default, V1, V2, diff --git a/Bloxstrap/Enums/FlagPresets/MSAAMode.cs b/Bloxstrap/Enums/FlagPresets/MSAAMode.cs index eea0c8b..e5ae281 100644 --- a/Bloxstrap/Enums/FlagPresets/MSAAMode.cs +++ b/Bloxstrap/Enums/FlagPresets/MSAAMode.cs @@ -2,9 +2,13 @@ { public enum MSAAMode { + [EnumName(FromTranslation = "Common.Automatic")] Default, + [EnumName(StaticName = "1x")] x1, + [EnumName(StaticName = "2x")] x2, + [EnumName(StaticName = "4x")] x4 } } diff --git a/Bloxstrap/Enums/FlagPresets/MaterialVersion.cs b/Bloxstrap/Enums/FlagPresets/MaterialVersion.cs deleted file mode 100644 index 9e17d61..0000000 --- a/Bloxstrap/Enums/FlagPresets/MaterialVersion.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Bloxstrap.Enums.FlagPresets -{ - public enum MaterialVersion - { - Default, - Old, - New - } -} diff --git a/Bloxstrap/Enums/FlagPresets/RenderingMode.cs b/Bloxstrap/Enums/FlagPresets/RenderingMode.cs index 2e94952..769a430 100644 --- a/Bloxstrap/Enums/FlagPresets/RenderingMode.cs +++ b/Bloxstrap/Enums/FlagPresets/RenderingMode.cs @@ -2,10 +2,11 @@ { public enum RenderingMode { + [EnumName(FromTranslation = "Common.Automatic")] Default, - Vulkan, + // Vulkan, D3D11, D3D10, - OpenGL + // OpenGL } } diff --git a/Bloxstrap/Enums/FlagPresets/TextureQuality.cs b/Bloxstrap/Enums/FlagPresets/TextureQuality.cs index cb99e98..9610135 100644 --- a/Bloxstrap/Enums/FlagPresets/TextureQuality.cs +++ b/Bloxstrap/Enums/FlagPresets/TextureQuality.cs @@ -2,6 +2,7 @@ { public enum TextureQuality { + [EnumName(FromTranslation = "Common.Automatic")] Default, Level0, Level1, diff --git a/Bloxstrap/Enums/Theme.cs b/Bloxstrap/Enums/Theme.cs index 2f76cb4..f3cd71c 100644 --- a/Bloxstrap/Enums/Theme.cs +++ b/Bloxstrap/Enums/Theme.cs @@ -2,6 +2,7 @@ { public enum Theme { + [EnumName(FromTranslation = "Common.SystemDefault")] Default, Light, Dark diff --git a/Bloxstrap/Locale.cs b/Bloxstrap/Locale.cs index 3b62873..ed6e444 100644 --- a/Bloxstrap/Locale.cs +++ b/Bloxstrap/Locale.cs @@ -12,7 +12,7 @@ namespace Bloxstrap public static readonly Dictionary SupportedLocales = new() { - { "nil", Strings.Enums_Theme_Default }, // /shrug + { "nil", Strings.Common_SystemDefault }, { "en", "English" }, { "en-US", "English (United States)" }, { "ar", "العربية" }, @@ -55,13 +55,9 @@ namespace Bloxstrap public static List GetLanguages() { - var languages = new List() - { - Strings.Enums_Theme_Default, - "English", - "English (United States)" - }; - + var languages = new List(); + + languages.AddRange(SupportedLocales.Values.Take(3)); languages.AddRange(SupportedLocales.Values.Where(x => !languages.Contains(x)).OrderBy(x => x)); return languages; diff --git a/Bloxstrap/Models/Attributes/EnumNameAttribute.cs b/Bloxstrap/Models/Attributes/EnumNameAttribute.cs new file mode 100644 index 0000000..47c3eec --- /dev/null +++ b/Bloxstrap/Models/Attributes/EnumNameAttribute.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Bloxstrap.Models.Attributes +{ + class EnumNameAttribute : Attribute + { + public string? StaticName { get; set; } + public string? FromTranslation { get; set; } + } +} diff --git a/Bloxstrap/Models/BootstrapperIconEntry.cs b/Bloxstrap/Models/BootstrapperIconEntry.cs index 009cba3..9f4a22e 100644 --- a/Bloxstrap/Models/BootstrapperIconEntry.cs +++ b/Bloxstrap/Models/BootstrapperIconEntry.cs @@ -5,7 +5,6 @@ namespace Bloxstrap.Models public class BootstrapperIconEntry { public BootstrapperIcon IconType { get; set; } - public string Name => IconType.ToString(); public ImageSource ImageSource => IconType.GetIcon().GetImageSource(); } } diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs index ed949f4..bce2f21 100644 --- a/Bloxstrap/Resources/Strings.Designer.cs +++ b/Bloxstrap/Resources/Strings.Designer.cs @@ -314,6 +314,15 @@ namespace Bloxstrap.Resources { } } + /// + /// Looks up a localized string similar to Automatic. + /// + public static string Common_Automatic { + get { + return ResourceManager.GetString("Common.Automatic", resourceCulture); + } + } + /// /// Looks up a localized string similar to Browse. /// @@ -341,6 +350,24 @@ namespace Bloxstrap.Resources { } } + /// + /// Looks up a localized string similar to Custom. + /// + public static string Common_Custom { + get { + return ResourceManager.GetString("Common.Custom", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Default. + /// + public static string Common_Default { + get { + return ResourceManager.GetString("Common.Default", resourceCulture); + } + } + /// /// Looks up a localized string similar to Delete. /// @@ -458,6 +485,15 @@ namespace Bloxstrap.Resources { } } + /// + /// Looks up a localized string similar to System default. + /// + public static string Common_SystemDefault { + get { + return ResourceManager.GetString("Common.SystemDefault", resourceCulture); + } + } + /// /// Looks up a localized string similar to Value. /// @@ -738,69 +774,6 @@ namespace Bloxstrap.Resources { } } - /// - /// Looks up a localized string similar to 2008. - /// - public static string Enums_BootstrapperIcon_Icon2008 { - get { - return ResourceManager.GetString("Enums.BootstrapperIcon.Icon2008", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 2011. - /// - public static string Enums_BootstrapperIcon_Icon2011 { - get { - return ResourceManager.GetString("Enums.BootstrapperIcon.Icon2011", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 2017. - /// - public static string Enums_BootstrapperIcon_Icon2017 { - get { - return ResourceManager.GetString("Enums.BootstrapperIcon.Icon2017", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 2019. - /// - public static string Enums_BootstrapperIcon_Icon2019 { - get { - return ResourceManager.GetString("Enums.BootstrapperIcon.Icon2019", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 2022. - /// - public static string Enums_BootstrapperIcon_Icon2022 { - get { - return ResourceManager.GetString("Enums.BootstrapperIcon.Icon2022", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Bloxstrap. - /// - public static string Enums_BootstrapperIcon_IconBloxstrap { - get { - return ResourceManager.GetString("Enums.BootstrapperIcon.IconBloxstrap", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Custom. - /// - public static string Enums_BootstrapperIcon_IconCustom { - get { - return ResourceManager.GetString("Enums.BootstrapperIcon.IconCustom", resourceCulture); - } - } - /// /// Looks up a localized string similar to Early 2015. /// @@ -846,15 +819,6 @@ namespace Bloxstrap.Resources { } } - /// - /// Looks up a localized string similar to Bloxstrap. - /// - public static string Enums_BootstrapperStyle_FluentDialog { - get { - return ResourceManager.GetString("Enums.BootstrapperStyle.FluentDialog", resourceCulture); - } - } - /// /// Looks up a localized string similar to Legacy (2008 - 2011). /// @@ -891,15 +855,6 @@ namespace Bloxstrap.Resources { } } - /// - /// Looks up a localized string similar to Default. - /// - public static string Enums_CursorType_Default { - get { - return ResourceManager.GetString("Enums.CursorType.Default", resourceCulture); - } - } - /// /// Looks up a localized string similar to 2006 (Cartoony). /// @@ -963,15 +918,6 @@ namespace Bloxstrap.Resources { } } - /// - /// Looks up a localized string similar to Default. - /// - public static string Enums_FlagPresets_InGameMenuVersion_Default { - get { - return ResourceManager.GetString("Enums.FlagPresets.InGameMenuVersion.Default", resourceCulture); - } - } - /// /// Looks up a localized string similar to 2015 (V1). /// @@ -1044,69 +990,6 @@ namespace Bloxstrap.Resources { } } - /// - /// Looks up a localized string similar to Chosen by game. - /// - public static string Enums_FlagPresets_MaterialVersion_Default { - get { - return ResourceManager.GetString("Enums.FlagPresets.MaterialVersion.Default", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to New (2022). - /// - public static string Enums_FlagPresets_MaterialVersion_New { - get { - return ResourceManager.GetString("Enums.FlagPresets.MaterialVersion.New", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Old (Pre-2022). - /// - public static string Enums_FlagPresets_MaterialVersion_Old { - get { - return ResourceManager.GetString("Enums.FlagPresets.MaterialVersion.Old", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Automatic. - /// - public static string Enums_FlagPresets_MSAAMode_Default { - get { - return ResourceManager.GetString("Enums.FlagPresets.MSAAMode.Default", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 1x. - /// - public static string Enums_FlagPresets_MSAAMode_x1 { - get { - return ResourceManager.GetString("Enums.FlagPresets.MSAAMode.x1", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 2x. - /// - public static string Enums_FlagPresets_MSAAMode_x2 { - get { - return ResourceManager.GetString("Enums.FlagPresets.MSAAMode.x2", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 4x. - /// - public static string Enums_FlagPresets_MSAAMode_x4 { - get { - return ResourceManager.GetString("Enums.FlagPresets.MSAAMode.x4", resourceCulture); - } - } - /// /// Looks up a localized string similar to Direct3D 10. /// @@ -1125,42 +1008,6 @@ namespace Bloxstrap.Resources { } } - /// - /// Looks up a localized string similar to Automatic. - /// - public static string Enums_FlagPresets_RenderingMode_Default { - get { - return ResourceManager.GetString("Enums.FlagPresets.RenderingMode.Default", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to OpenGL. - /// - public static string Enums_FlagPresets_RenderingMode_OpenGL { - get { - return ResourceManager.GetString("Enums.FlagPresets.RenderingMode.OpenGL", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Vulkan. - /// - public static string Enums_FlagPresets_RenderingMode_Vulkan { - get { - return ResourceManager.GetString("Enums.FlagPresets.RenderingMode.Vulkan", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Default. - /// - public static string Enums_FlagPresets_TextureQuality_Default { - get { - return ResourceManager.GetString("Enums.FlagPresets.TextureQuality.Default", resourceCulture); - } - } - /// /// Looks up a localized string similar to Level 0 (Lowest). /// @@ -1233,15 +1080,6 @@ namespace Bloxstrap.Resources { } } - /// - /// Looks up a localized string similar to System default. - /// - public static string Enums_Theme_Default { - get { - return ResourceManager.GetString("Enums.Theme.Default", resourceCulture); - } - } - /// /// Looks up a localized string similar to Light. /// diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx index f7c0682..6627e96 100644 --- a/Bloxstrap/Resources/Strings.resx +++ b/Bloxstrap/Resources/Strings.resx @@ -333,25 +333,7 @@ Click for more information Bloxstrap Exception - - 2008 - - - 2011 - - - 2017 - - - 2019 - - - 2022 - - - Bloxstrap - - + Custom @@ -369,9 +351,6 @@ Click for more information Bloxstrap (Glass) - - Bloxstrap - Legacy (2008 - 2011) @@ -384,9 +363,6 @@ Click for more information Vista (2008 - 2011) - - Default - 2006 (Cartoony) @@ -408,9 +384,6 @@ Click for more information Windows 8 - - Default - 2015 (V1) @@ -432,42 +405,12 @@ Click for more information Voxel (Phase 1) - - Chosen by game - - - New (2022) - - - Old (Pre-2022) - - - Automatic - - - 1x - - - 2x - - - 4x - Direct3D 10 Direct3D 11 - - Automatic - - - OpenGL - - - Vulkan - Private @@ -480,9 +423,6 @@ Click for more information Dark - - System default - Light @@ -1033,9 +973,6 @@ Selecting 'No' will ignore this warning and continue installation. Texture quality - - Default - Level 0 (Lowest) @@ -1082,4 +1019,13 @@ Selecting 'No' will ignore this warning and continue installation. No log file will be written for this launch because Bloxstrap is unable to write to the folder at '{0}' + + Default + + + Automatic + + + System default + \ No newline at end of file diff --git a/Bloxstrap/UI/Converters/EnumNameConverter.cs b/Bloxstrap/UI/Converters/EnumNameConverter.cs new file mode 100644 index 0000000..52e1cf0 --- /dev/null +++ b/Bloxstrap/UI/Converters/EnumNameConverter.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Xml.Linq; + +namespace Bloxstrap.UI.Converters +{ + class EnumNameConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + // https://stackoverflow.com/a/28672015/11852173 + + var enumVal = (Enum)value; + var stringVal = enumVal.ToString(); + + var type = enumVal.GetType(); + var typeName = type.FullName!; + var attributes = type.GetMember(stringVal)[0].GetCustomAttributes(typeof(EnumNameAttribute), false); + + if (attributes.Length > 0) + { + var attribute = (EnumNameAttribute)attributes[0]; + + if (attribute is not null) + { + if (attribute.StaticName is not null) + return attribute.StaticName; + + if (attribute.FromTranslation is not null) + return Resources.Strings.ResourceManager.GetStringSafe(attribute.FromTranslation); + } + } + + return Resources.Strings.ResourceManager.GetStringSafe(String.Format( + "{0}.{1}", + typeName.Substring(typeName.IndexOf('.', StringComparison.Ordinal) + 1), + stringVal + )); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotSupportedException(); + } + } +} diff --git a/Bloxstrap/UI/Converters/ResourceConverter.cs b/Bloxstrap/UI/Converters/ResourceConverter.cs deleted file mode 100644 index ee1d696..0000000 --- a/Bloxstrap/UI/Converters/ResourceConverter.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Windows.Data; - -namespace Bloxstrap.UI.Converters -{ - internal class ResourceConverter : IValueConverter - { - // parameter is the resource namespace prefix - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) - { - if (value is null) - return ""; - - if (parameter is null) - return value.ToString()!; - - string valueStr = value.ToString()!; - string parameterStr = parameter.ToString()!; - string resourceName = parameterStr + valueStr; - - return Resources.Strings.ResourceManager.GetStringSafe(resourceName); - } - - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotImplementedException(nameof(ConvertBack)); - } - } -} diff --git a/Bloxstrap/UI/Elements/Menu/Pages/AppearancePage.xaml b/Bloxstrap/UI/Elements/Menu/Pages/AppearancePage.xaml index bd7610a..7fe3ec4 100644 --- a/Bloxstrap/UI/Elements/Menu/Pages/AppearancePage.xaml +++ b/Bloxstrap/UI/Elements/Menu/Pages/AppearancePage.xaml @@ -19,7 +19,7 @@ - + @@ -59,7 +59,7 @@ - + @@ -78,7 +78,7 @@ - + diff --git a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml index d4364da..0887421 100644 --- a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml +++ b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml @@ -60,7 +60,7 @@ - + @@ -96,7 +96,7 @@ - + @@ -114,7 +114,7 @@ - + @@ -125,7 +125,7 @@ - + @@ -159,7 +159,7 @@ - + diff --git a/Bloxstrap/UI/Elements/Menu/Pages/ModsPage.xaml b/Bloxstrap/UI/Elements/Menu/Pages/ModsPage.xaml index b6dab01..420a714 100644 --- a/Bloxstrap/UI/Elements/Menu/Pages/ModsPage.xaml +++ b/Bloxstrap/UI/Elements/Menu/Pages/ModsPage.xaml @@ -75,7 +75,7 @@ - + @@ -99,7 +99,7 @@ - +