Skip to content

Commit

Permalink
重大升级
Browse files Browse the repository at this point in the history
  • Loading branch information
VeryJokerJal committed Jan 25, 2025
1 parent 30b8525 commit 15d3f91
Show file tree
Hide file tree
Showing 27 changed files with 6,288 additions and 323 deletions.
1 change: 1 addition & 0 deletions Alpha/Alpha.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AvalonEdit" Version="6.3.0.90" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="ReactiveUI" Version="20.1.63" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
Expand Down
1 change: 1 addition & 0 deletions Alpha/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<converters:IgnoreStatusVisibilityMultiConverter x:Key="IgnoreStatusVisibilityMultiConverter" />
<ResourceDictionary.MergedDictionaries>
<XamlUIResources />
<ResourceDictionary Source="Resources/IconDictionary.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Expand Down
4 changes: 2 additions & 2 deletions Alpha/Converters/ExpiryToDateTimeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ public class ExpiryToDateTimeConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
if (value is DateTime)
if (value is DateTime time)
{
writer.WriteValue(((DateTime)value - new DateTime(1970, 1, 1)).TotalSeconds);
writer.WriteValue((time - new DateTime(1970, 1, 1)).TotalSeconds);
}
else
{
Expand Down
60 changes: 52 additions & 8 deletions Alpha/Converters/LevelColorConverter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;

Expand All @@ -9,14 +10,57 @@ public class LevelColorConverter : IValueConverter
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is string level
? level.ToUpper() switch
{
"GOLD" => new SolidColorBrush(Color.FromRgb(212, 175, 55)), // 金色 #FFD4AF37
"SILVER" => new SolidColorBrush(Color.FromRgb(192, 192, 192)), // 银色 #FFC0C0C0
"BRONZE" => new SolidColorBrush(Color.FromRgb(205, 127, 50)), // 铜色 #FFCD7F32
_ => new SolidColorBrush(Color.FromRgb(192, 192, 192)) // 默认银色
}
: (object)new SolidColorBrush(Color.FromRgb(192, 192, 192));
? level.ToUpper() switch
{
"GRANDMASTER" => new LinearGradientBrush
{
StartPoint = new Point(0, 0),
EndPoint = new Point(1, 1),
GradientStops = new GradientStopCollection
{
new GradientStop(Color.FromRgb(255, 192, 203), 0.0), // 粉红
new GradientStop(Color.FromRgb(255, 182, 193), 0.5), // 浅粉红
new GradientStop(Color.FromRgb(255, 160, 200), 1.0) // 中粉红
}
},
"MASTER" => new LinearGradientBrush
{
StartPoint = new Point(0, 0),
EndPoint = new Point(1, 1),
GradientStops = new GradientStopCollection
{
new GradientStop(Color.FromRgb(230, 190, 255), 0.0), // 浅紫
new GradientStop(Color.FromRgb(221, 160, 255), 0.5), // 淡紫
new GradientStop(Color.FromRgb(200, 150, 255), 1.0) // 中紫
}
},
"EXPERT" => new LinearGradientBrush
{
StartPoint = new Point(0, 0),
EndPoint = new Point(1, 1),
GradientStops = new GradientStopCollection
{
new GradientStop(Color.FromRgb(135, 206, 250), 0.0), // 浅天蓝
new GradientStop(Color.FromRgb(176, 224, 230), 0.5), // 粉蓝
new GradientStop(Color.FromRgb(173, 216, 230), 1.0) // 淡蓝
}
},
"GOLD" => new LinearGradientBrush
{
StartPoint = new Point(0, 0),
EndPoint = new Point(1, 1),
GradientStops = new GradientStopCollection
{
new GradientStop(Color.FromRgb(255, 223, 0), 0.0), // 明亮金
new GradientStop(Color.FromRgb(255, 215, 0), 0.5), // 金色
new GradientStop(Color.FromRgb(255, 200, 0), 1.0) // 浅金
}
},
"SILVER" => new SolidColorBrush(Color.FromRgb(192, 192, 192)), // 银色
"BRONZE" => new SolidColorBrush(Color.FromRgb(205, 127, 50)), // 铜色
_ => new SolidColorBrush(Color.FromRgb(192, 192, 192)) // 默认银色
}
: new SolidColorBrush(Color.FromRgb(192, 192, 192));
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
Expand Down
12 changes: 6 additions & 6 deletions Alpha/Helpers/DirectiveReplacerExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Alpha.Helpers
{
public static class DirectiveReplacerExtension
{
public static IEnumerable<string> ExpandPlaceholders(string input, Dictionary<int, List<string>> replacements)
public static IEnumerable<string> ExpandPlaceholders(string input, Dictionary<int, List<string?>> replacements)
{
MatchCollection matches = Regex.Matches(input, @"\$(\d+)");
List<int> placeholderKeys = [];
Expand All @@ -18,8 +18,8 @@ public static IEnumerable<string> ExpandPlaceholders(string input, Dictionary<in
}

// Start with an empty combination
IEnumerable<IEnumerable<(int Key, string Value)>> combos =
new List<IEnumerable<(int, string)>> { Enumerable.Empty<(int, string)>() };
IEnumerable<IEnumerable<(int Key, string? Value)>> combos =
new List<IEnumerable<(int, string?)>> { Enumerable.Empty<(int, string?)>() };

// Build combinations
foreach (int key in placeholderKeys)
Expand All @@ -29,12 +29,12 @@ public static IEnumerable<string> ExpandPlaceholders(string input, Dictionary<in
}

// Replace placeholders in each combination
foreach (IEnumerable<(int Key, string Value)> combo in combos)
foreach (IEnumerable<(int Key, string? Value)> combo in combos)
{
string result = input;
foreach ((int k, string v) in combo)
foreach ((int k, string? v) in combo)
{
result = Regex.Replace(result, @"\$" + k + @"\b", v);
result = Regex.Replace(result, @"\$" + k + @"\b", v ?? "", RegexOptions.IgnoreCase);
}
yield return result;
}
Expand Down
Loading

0 comments on commit 15d3f91

Please sign in to comment.