From 1c51b642604c4fc8d15e93a4353ff0a76730ea71 Mon Sep 17 00:00:00 2001 From: walon Date: Fri, 20 Dec 2024 11:31:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[change]=20=E6=94=AF=E6=8C=81=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=BB=98=E8=AE=A4variant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Luban.Core/Defs/DefAssembly.cs | 14 ++++++++++++++ src/Luban.Core/Defs/DefField.cs | 2 +- src/Luban/Luban.csproj | 10 ++++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/Luban.Core/Defs/DefAssembly.cs b/src/Luban.Core/Defs/DefAssembly.cs index baf395d1..7e033be8 100644 --- a/src/Luban.Core/Defs/DefAssembly.cs +++ b/src/Luban.Core/Defs/DefAssembly.cs @@ -45,6 +45,20 @@ public bool TryGetVariantName(string variantKey, out string variantName) return _variants.TryGetValue(variantKey, out variantName); } + public bool TryGetVariantNameOrDefault(string variantKey, out string variantName) + { + if (_variants == null) + { + variantName = ""; + return false; + } + if (_variants.TryGetValue(variantKey, out variantName)) + { + return true; + } + return _variants.TryGetValue("default", out variantName); + } + public DefAssembly(RawAssembly assembly, string target, List outputTables, List groupDefs, Dictionary variants) { _targets = assembly.Targets; diff --git a/src/Luban.Core/Defs/DefField.cs b/src/Luban.Core/Defs/DefField.cs index 37f0f5c0..1962a08e 100644 --- a/src/Luban.Core/Defs/DefField.cs +++ b/src/Luban.Core/Defs/DefField.cs @@ -80,7 +80,7 @@ public void Compile() if (Variants != null && Variants.Count > 0) { string variantKey = $"{HostType.FullName}.{Name}"; - if (HostType.Assembly.TryGetVariantName(variantKey, out var variantName)) + if (HostType.Assembly.TryGetVariantNameOrDefault(variantKey, out var variantName)) { if (!Variants.Contains(variantName)) { diff --git a/src/Luban/Luban.csproj b/src/Luban/Luban.csproj index dae116f7..061ba134 100644 --- a/src/Luban/Luban.csproj +++ b/src/Luban/Luban.csproj @@ -36,6 +36,12 @@ 3.10.0 + + + + + + @@ -64,10 +70,6 @@ - - - - True From f8a5fd65cd0cfefc4b6d05429157c397295304e5 Mon Sep 17 00:00:00 2001 From: walon Date: Fri, 20 Dec 2024 11:31:41 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[version]=20=E6=8F=90=E5=8D=87=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=E4=B8=BAv3.11.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Luban/Luban.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Luban/Luban.csproj b/src/Luban/Luban.csproj index 061ba134..cec7380c 100644 --- a/src/Luban/Luban.csproj +++ b/src/Luban/Luban.csproj @@ -33,7 +33,7 @@ README.md True $(AssemblyVersion) - 3.10.0 + 3.11.0