Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在 Mod 下载页面的卡片标题栏显示 Mod 加载器图标 #5399

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion Plain Craft Launcher 2/Controls/MyCard.vb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
Private ReadOnly MainGrid As Grid
Private ReadOnly MainChrome As SystemDropShadowChrome
Private ReadOnly MainBorder As Border
'图标
Private _icon As ImageSource
Public Property Icon As ImageSource
Get
Return _icon
End Get
Set(value As ImageSource)
_icon = value
If _iconImage IsNot Nothing Then
_iconImage.Source = value
End If
End Set
End Property
Private _iconImage As Image
Public Property BorderChild As UIElement
Get
Return MainBorder.Child
Expand Down Expand Up @@ -61,9 +75,21 @@
Private Sub Init() Handles Me.Loaded
If IsLoad Then Exit Sub
IsLoad = True
'图标
If Icon IsNot Nothing Then
_iconImage = New Image() With {
.Source = Icon,
.HorizontalAlignment = HorizontalAlignment.Left,
.VerticalAlignment = VerticalAlignment.Top,
.Margin = New Thickness(15, 12, 5, 0),
.Width = 16,
.Height = 16
}
MainGrid.Children.Add(_iconImage)
End If
'初次加载限定
If Title <> "" AndAlso MainTextBlock Is Nothing Then
MainTextBlock = New TextBlock With {.HorizontalAlignment = HorizontalAlignment.Left, .VerticalAlignment = VerticalAlignment.Top, .Margin = New Thickness(15, 12, 0, 0), .FontWeight = FontWeights.Bold, .FontSize = 13, .IsHitTestVisible = False}
MainTextBlock = New TextBlock With {.HorizontalAlignment = HorizontalAlignment.Left, .VerticalAlignment = VerticalAlignment.Top, .Margin = New Thickness(35, 12, 0, 0), .FontWeight = FontWeights.Bold, .FontSize = 13, .IsHitTestVisible = False}
MainTextBlock.SetResourceReference(TextBlock.ForegroundProperty, "ColorBrush1")
MainTextBlock.SetBinding(TextBlock.TextProperty, New Binding("Title") With {.Source = Me, .Mode = BindingMode.OneWay})
MainGrid.Children.Add(MainTextBlock)
Expand Down
Binary file added Plain Craft Launcher 2/Images/Blocks/Forge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Plain Craft Launcher 2/Images/Blocks/Quilt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,27 @@
End If
Next
End If
'加载器图标
Dim LoaderIcons As New Dictionary(Of String, ImageSource) From {
{"Forge", New BitmapImage(New Uri("pack://application:,,,/images/Blocks/Forge.png", UriKind.Absolute))},
{"Fabric", New BitmapImage(New Uri("pack://application:,,,/images/Blocks/Fabric.png", UriKind.Absolute))},
{"Quilt", New BitmapImage(New Uri("pack://application:,,,/images/Blocks/Quilt.png", UriKind.Absolute))},
{"NeoForge", New BitmapImage(New Uri("pack://application:,,,/images/Blocks/NeoForge.png", UriKind.Absolute))}
}
'转化为 UI
Try
PanResults.Children.Clear()
For Each Pair As KeyValuePair(Of String, List(Of CompFile)) In Dict
If Not Pair.Value.Any() Then Continue For
Dim LoaderName As String = Pair.Key.Split(" "c)(0).Trim()
Dim NewCardIcon As ImageSource = Nothing
If LoaderIcons.ContainsKey(LoaderName) Then
NewCardIcon = LoaderIcons(LoaderName)
Else
NewCardIcon = New BitmapImage(New Uri("pack://application:,,,/images/Blocks/Egg.png", UriKind.Absolute))'暂时用蛋代替
End If
'增加卡片
Dim NewCard As New MyCard With {.Title = Pair.Key, .Margin = New Thickness(0, 0, 0, 15), .SwapType = If(Project.Type = CompType.ModPack, 9, 8)} 'FUTURE: Res
Dim NewCard As New MyCard With {.Title = Pair.Key, .Margin = New Thickness(0, 0, 0, 15), .SwapType = If(Project.Type = CompType.ModPack, 9, 8), .Icon = NewCardIcon} 'FUTURE: Res
Dim NewStack As New StackPanel With {.Margin = New Thickness(20, MyCard.SwapedHeight, 18, 0), .VerticalAlignment = VerticalAlignment.Top, .RenderTransform = New TranslateTransform(0, 0), .Tag = Pair.Value}
NewCard.Children.Add(NewStack)
NewCard.SwapControl = NewStack
Expand Down
3 changes: 2 additions & 1 deletion Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,8 @@
<Resource Include="Images\Heads\MCBBS.png" />
</ItemGroup>
<ItemGroup>

<Resource Include="Images\Blocks\Forge.png" />
<Resource Include="Images\Blocks\Quilt.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Blocks\NeoForge.png" />
Expand Down