Skip to content

Commit fd5d405

Browse files
authored
Merge branch 'main' into main
2 parents 513204d + 8d85bb4 commit fd5d405

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1761
-1339
lines changed

Plain Craft Launcher 2/Application.xaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<local:MultiplicationConverter x:Key="MultiplicationConverter"/>
2020
<local:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter"/>
2121
<local:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
22+
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
2223

2324
<!-- 颜色表 -->
2425
<SolidColorBrush x:Key="ColorBrush1">#343d4a</SolidColorBrush>
@@ -287,21 +288,21 @@
287288
<Setter Property="BorderBrush" Value="{DynamicResource ColorBrushBg0}" />
288289
<Setter Property="Template">
289290
<Setter.Value>
290-
<ControlTemplate TargetType="TextBox">
291+
<ControlTemplate TargetType="local:MyTextBox">
291292
<Grid SnapsToDevicePixels="True" ToolTip="{TemplateBinding ToolTip}">
292293
<Grid.RowDefinitions>
293294
<RowDefinition MinHeight="28" />
294295
<RowDefinition Height="Auto" />
295296
</Grid.RowDefinitions>
296-
<Border x:Name="border" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" CornerRadius="3">
297+
<Border x:Name="border" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" CornerRadius="{TemplateBinding CornerRadius}">
297298
<ScrollViewer x:Name="PART_ContentHost" Style="{StaticResource ScrollViewerNoMargin}" RenderOptions.ClearTypeHint="Enabled" BorderThickness="0"
298299
Margin="5,0,0,0" Cursor="IBeam" />
299300
<!-- 由于未知原因,TextView 会有 2,0 的 Margin -->
300301
</Border>
301302
<Border Margin="{TemplateBinding Padding}" IsHitTestVisible="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" BorderThickness="0">
302-
<TextBlock x:Name="labHint" Foreground="{DynamicResource ColorBrush1}" Opacity="0.25" Margin="7,0,0,0" Padding="{TemplateBinding BorderThickness}" FontSize="{TemplateBinding FontSize}" FontFamily="Resources/#PCL English, Microsoft YaHei UI" />
303+
<TextBlock x:Name="labHint" Foreground="{StaticResource ColorBrushGray4}" Margin="7,0,0,0" Padding="{TemplateBinding BorderThickness}" FontSize="{TemplateBinding FontSize}" FontFamily="Resources/#PCL English, Microsoft YaHei UI" />
303304
</Border>
304-
<TextBlock Grid.Row="1" x:Name="labWrong" Height="0" Foreground="{TemplateBinding BorderBrush}" Padding="0,4,0,0" />
305+
<TextBlock Grid.Row="1" x:Name="labWrong" Height="0" Foreground="{TemplateBinding BorderBrush}" Padding="0,4,0,0" Margin="0,0,0,-3" />
305306
</Grid>
306307
</ControlTemplate>
307308
</Setter.Value>

Plain Craft Launcher 2/Application.xaml.vb

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Imports System.Net
2-
Imports System.Reflection
1+
Imports System.Reflection
32
Imports System.Windows.Threading
43

54
Public Class Application
@@ -26,7 +25,15 @@ Public Class Application
2625
If e.Args(0) = "--update" Then
2726
'自动更新
2827
UpdateReplace(e.Args(1), e.Args(2).Trim(""""), e.Args(3).Trim(""""), e.Args(4))
29-
Environment.Exit(Result.Cancel)
28+
Environment.Exit(ProcessReturnValues.TaskDone)
29+
ElseIf e.Args(0) = "--gpu" Then
30+
'调整显卡设置
31+
Try
32+
SetGPUPreference(e.Args(1).Trim(""""))
33+
Environment.Exit(ProcessReturnValues.TaskDone)
34+
Catch ex As Exception
35+
Environment.Exit(ProcessReturnValues.Fail)
36+
End Try
3037
ElseIf e.Args(0).StartsWithF("--memory") Then
3138
'内存优化
3239
Dim Ram = My.Computer.Info.AvailablePhysicalMemory
@@ -45,10 +52,10 @@ Public Class Application
4552
'制作更新包
4653
ElseIf e.Args(0) = "--edit1" Then
4754
ExeEdit(e.Args(1), True)
48-
Environment.Exit(Result.Cancel)
55+
Environment.Exit(ProcessReturnValues.TaskDone)
4956
ElseIf e.Args(0) = "--edit2" Then
5057
ExeEdit(e.Args(1), False)
51-
Environment.Exit(Result.Cancel)
58+
Environment.Exit(ProcessReturnValues.TaskDone)
5259
#End If
5360
End If
5461
End If
@@ -87,7 +94,7 @@ WaitRetry:
8794
ShowWindowToTop(WindowHwnd)
8895
'播放提示音并退出
8996
Beep()
90-
Environment.[Exit](Result.Cancel)
97+
Environment.[Exit](ProcessReturnValues.Cancel)
9198
End If
9299
#End If
93100
'设置 ToolTipService 默认值
@@ -143,7 +150,7 @@ WaitRetry:
143150
Catch
144151
End Try
145152
MsgBox(GetExceptionDetail(ex, True) & vbCrLf & "PCL 所在路径:" & If(String.IsNullOrEmpty(FilePath), "获取失败", FilePath), MsgBoxStyle.Critical, "PCL 初始化错误")
146-
FormMain.EndProgramForce(Result.Exception)
153+
FormMain.EndProgramForce(ProcessReturnValues.Exception)
147154
End Try
148155
End Sub
149156

@@ -160,7 +167,7 @@ WaitRetry:
160167
If IsProgramEnded Then Exit Sub
161168
If IsCritErrored Then
162169
'在汇报错误后继续引发错误,知道这次压不住了
163-
FormMain.EndProgramForce(Result.Exception)
170+
FormMain.EndProgramForce(ProcessReturnValues.Exception)
164171
Exit Sub
165172
End If
166173
IsCritErrored = True
@@ -171,7 +178,7 @@ WaitRetry:
171178
ExceptionString.Contains("未能加载文件或程序集") Then
172179
OpenWebsite("https://dotnet.microsoft.com/zh-cn/download/dotnet-framework/thank-you/net462-offline-installer")
173180
MsgBox("你的 .NET Framework 版本过低或损坏,请下载并重新安装 .NET Framework 4.6.2!", MsgBoxStyle.Information, "运行环境错误")
174-
FormMain.EndProgramForce(Result.Cancel)
181+
FormMain.EndProgramForce(ProcessReturnValues.Cancel)
175182
Else
176183
FeedbackInfo()
177184
Log(e.Exception, "程序出现未知错误", LogLevel.Assert, "锟斤拷烫烫烫")

Plain Craft Launcher 2/Controls/MyCard.vb

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'控件
44
Inherits Grid
55
Private ReadOnly MainGrid As Grid
6-
Private ReadOnly MainChrome As SystemDropShadowChrome
6+
Public ReadOnly Property MainChrome As SystemDropShadowChrome
77
Private ReadOnly MainBorder As Border
88
Public Property BorderChild As UIElement
99
Get
@@ -41,6 +41,15 @@
4141
Return MainTextBlock.Inlines
4242
End Get
4343
End Property
44+
Public Property CornerRadius As CornerRadius
45+
Get
46+
Return MainChrome.CornerRadius
47+
End Get
48+
Set(value As CornerRadius)
49+
MainChrome.CornerRadius = value
50+
MainBorder.CornerRadius = value
51+
End Set
52+
End Property
4453
Public Property Title As String
4554
Get
4655
Return GetValue(TitleProperty)
@@ -103,13 +112,13 @@
103112
'排序
104113
Select Case Type
105114
Case 3
106-
Stack.Tag = Sort(CType(Stack.Tag, List(Of DlOptiFineListEntry)), Function(a, b) VersionSortBoolean(a.NameDisplay, b.NameDisplay))
115+
Stack.Tag = CType(Stack.Tag, List(Of DlOptiFineListEntry)).Sort(Function(a, b) VersionSortBoolean(a.NameDisplay, b.NameDisplay))
107116
Case 4, 10
108-
Stack.Tag = Sort(CType(Stack.Tag, List(Of DlLiteLoaderListEntry)), Function(a, b) VersionSortBoolean(a.Inherit, b.Inherit))
117+
Stack.Tag = CType(Stack.Tag, List(Of DlLiteLoaderListEntry)).Sort(Function(a, b) VersionSortBoolean(a.Inherit, b.Inherit))
109118
Case 6
110-
Stack.Tag = Sort(CType(Stack.Tag, List(Of DlForgeVersionEntry)), Function(a, b) a.Version > b.Version)
119+
Stack.Tag = CType(Stack.Tag, List(Of DlForgeVersionEntry)).Sort(Function(a, b) a.Version > b.Version)
111120
Case 8, 9
112-
Stack.Tag = Sort(CType(Stack.Tag, List(Of CompFile)), Function(a, b) a.ReleaseDate > b.ReleaseDate)
121+
Stack.Tag = CType(Stack.Tag, List(Of CompFile)).Sort(Function(a, b) a.ReleaseDate > b.ReleaseDate)
113122
End Select
114123
'控件转换
115124
Select Case Type
@@ -185,10 +194,10 @@
185194
If Not IsNothing(MainTextBlock) Then AniList.Add(AaColor(MainTextBlock, TextBlock.ForegroundProperty, "ColorBrush2", 150))
186195
If Not IsNothing(MainSwap) Then AniList.Add(AaColor(MainSwap, Shapes.Path.FillProperty, "ColorBrush2", 150))
187196
AniList.AddRange({
188-
AaColor(MainChrome, SystemDropShadowChrome.ColorProperty, "ColorObject2", 180),
189-
AaColor(MainBorder, Border.BackgroundProperty, New MyColor(230, 255, 255, 255) - MainBorder.Background, 180),
190-
AaOpacity(MainChrome, 0.3 - MainChrome.Opacity, 180)
191-
})
197+
AaColor(MainChrome, SystemDropShadowChrome.ColorProperty, "ColorObject2", 180),
198+
AaColor(MainBorder, Border.BackgroundProperty, New MyColor(230, 255, 255, 255) - MainBorder.Background, 180),
199+
AaOpacity(MainChrome, 0.3 - MainChrome.Opacity, 180)
200+
})
192201
AniStart(AniList, "MyCard Mouse " & Uuid)
193202
End Sub
194203
Private Sub MyCard_MouseLeave(sender As Object, e As MouseEventArgs) Handles Me.MouseLeave
@@ -197,10 +206,10 @@
197206
If Not IsNothing(MainTextBlock) Then AniList.Add(AaColor(MainTextBlock, TextBlock.ForegroundProperty, "ColorBrush1", 250))
198207
If Not IsNothing(MainSwap) Then AniList.Add(AaColor(MainSwap, Shapes.Path.FillProperty, "ColorBrush1", 250))
199208
AniList.AddRange({
200-
AaColor(MainChrome, SystemDropShadowChrome.ColorProperty, "ColorObject1", 300),
201-
AaColor(MainBorder, Border.BackgroundProperty, New MyColor(205, 255, 255, 255) - MainBorder.Background, 300),
202-
AaOpacity(MainChrome, 0.1 - MainChrome.Opacity, 300)
203-
})
209+
AaColor(MainChrome, SystemDropShadowChrome.ColorProperty, "ColorObject1", 300),
210+
AaColor(MainBorder, Border.BackgroundProperty, New MyColor(205, 255, 255, 255) - MainBorder.Background, 300),
211+
AaOpacity(MainChrome, 0.1 - MainChrome.Opacity, 300)
212+
})
204213
AniStart(AniList, "MyCard Mouse " & Uuid)
205214
End Sub
206215

@@ -335,18 +344,19 @@ Partial Public Module ModAnimation
335344
If Control.IsHitTestVisible Then
336345
Control.IsHitTestVisible = False
337346
AniStart({
338-
AaScaleTransform(Control, -0.08, 200,, New AniEaseInFluent),
339-
AaOpacity(Control, -1, 200,, New AniEaseOutFluent),
340-
AaHeight(Control, -Control.ActualHeight, 150, 100, New AniEaseOutFluent),
341-
AaCode(Sub()
342-
If RemoveFromChildren Then
343-
If Control.Parent Is Nothing Then Exit Sub
344-
CType(Control.Parent, Object).Children.Remove(Control)
345-
Else
346-
Control.Visibility = Visibility.Collapsed
347-
End If
348-
If CallBack IsNot Nothing Then CallBack(Control)
349-
End Sub,, True)
347+
AaScaleTransform(Control, -0.08, 200,, New AniEaseInFluent),
348+
AaOpacity(Control, -1, 200,, New AniEaseOutFluent),
349+
AaHeight(Control, -Control.ActualHeight, 150, 100, New AniEaseOutFluent),
350+
AaCode(
351+
Sub()
352+
If RemoveFromChildren Then
353+
If Control.Parent Is Nothing Then Exit Sub
354+
CType(Control.Parent, Object).Children.Remove(Control)
355+
Else
356+
Control.Visibility = Visibility.Collapsed
357+
End If
358+
If CallBack IsNot Nothing Then CallBack(Control)
359+
End Sub,, True)
350360
}, "MyCard Dispose " & Control.Uuid)
351361
Else
352362
If RemoveFromChildren Then

Plain Craft Launcher 2/Controls/MyExtraButton.xaml.vb

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@
113113
Private Sub Button_LeftMouseDown(sender As Object, e As MouseButtonEventArgs) Handles PanClick.MouseLeftButtonDown
114114
If Not IsLeftMouseHeld AndAlso Not IsRightMouseHeld Then
115115
AniStart({
116-
AaScaleTransform(PanScale, 0.85 - CType(PanScale.RenderTransform, ScaleTransform).ScaleX, 800,, New AniEaseOutFluent(AniEasePower.Strong)),
117-
AaScaleTransform(PanScale, -0.05, 60,, New AniEaseOutFluent)
118-
}, "MyExtraButton Scale " & Uuid)
116+
AaScaleTransform(PanScale, 0.85 - CType(PanScale.RenderTransform, ScaleTransform).ScaleX, 800,, New AniEaseOutFluent(AniEasePower.Strong)),
117+
AaScaleTransform(PanScale, -0.05, 60,, New AniEaseOutFluent)
118+
}, "MyExtraButton Scale " & Uuid)
119119
End If
120120
IsLeftMouseHeld = True
121121
Focus()
@@ -124,18 +124,18 @@
124124
If Not CanRightClick Then Exit Sub
125125
If Not IsLeftMouseHeld AndAlso Not IsRightMouseHeld Then
126126
AniStart({
127-
AaScaleTransform(PanScale, 0.85 - CType(PanScale.RenderTransform, ScaleTransform).ScaleX, 800,, New AniEaseOutFluent(AniEasePower.Strong)),
128-
AaScaleTransform(PanScale, -0.05, 60,, New AniEaseOutFluent)
129-
}, "MyExtraButton Scale " & Uuid)
127+
AaScaleTransform(PanScale, 0.85 - CType(PanScale.RenderTransform, ScaleTransform).ScaleX, 800,, New AniEaseOutFluent(AniEasePower.Strong)),
128+
AaScaleTransform(PanScale, -0.05, 60,, New AniEaseOutFluent)
129+
}, "MyExtraButton Scale " & Uuid)
130130
End If
131131
IsRightMouseHeld = True
132132
Focus()
133133
End Sub
134134
Private Sub Button_LeftMouseUp() Handles PanClick.MouseLeftButtonUp
135135
If Not IsRightMouseHeld Then
136136
AniStart({
137-
AaScaleTransform(PanScale, 1 - CType(PanScale.RenderTransform, ScaleTransform).ScaleX, 300,, New AniEaseOutBack)
138-
}, "MyExtraButton Scale " & Uuid)
137+
AaScaleTransform(PanScale, 1 - CType(PanScale.RenderTransform, ScaleTransform).ScaleX, 300,, New AniEaseOutBack)
138+
}, "MyExtraButton Scale " & Uuid)
139139
End If
140140
IsLeftMouseHeld = False
141141
RefreshColor() '直接刷新颜色以判断是否已触发 MouseLeave
@@ -144,8 +144,8 @@
144144
If Not CanRightClick Then Exit Sub
145145
If Not IsLeftMouseHeld Then
146146
AniStart({
147-
AaScaleTransform(PanScale, 1 - CType(PanScale.RenderTransform, ScaleTransform).ScaleX, 300,, New AniEaseOutBack)
148-
}, "MyExtraButton Scale " & Uuid)
147+
AaScaleTransform(PanScale, 1 - CType(PanScale.RenderTransform, ScaleTransform).ScaleX, 300,, New AniEaseOutBack)
148+
}, "MyExtraButton Scale " & Uuid)
149149
End If
150150
IsRightMouseHeld = False
151151
RefreshColor() '直接刷新颜色以判断是否已触发 MouseLeave
@@ -154,20 +154,23 @@
154154
IsLeftMouseHeld = False
155155
IsRightMouseHeld = False
156156
AniStart({
157-
AaScaleTransform(PanScale, 1 - CType(PanScale.RenderTransform, ScaleTransform).ScaleX, 500,, New AniEaseOutFluent)
158-
}, "MyExtraButton Scale " & Uuid)
157+
AaScaleTransform(PanScale, 1 - CType(PanScale.RenderTransform, ScaleTransform).ScaleX, 500,, New AniEaseOutFluent)
158+
}, "MyExtraButton Scale " & Uuid)
159159
RefreshColor() '直接刷新颜色以判断是否已触发 MouseLeave
160160
End Sub
161161

162162
'自定义事件
163163
'务必放在 IsMouseDown 更新之后
164164
Private Const AnimationColorIn As Integer = 120
165165
Private Const AnimationColorOut As Integer = 150
166-
Public Sub RefreshColor() Handles PanClick.MouseEnter, PanClick.MouseLeave, Me.Loaded
166+
Public Sub RefreshColor() Handles PanClick.MouseEnter, PanClick.MouseLeave, Me.Loaded, Me.IsEnabledChanged
167167
Try
168168
If IsLoaded AndAlso AniControlEnabled = 0 Then '防止默认属性变更触发动画
169169

170-
If IsMouseOver Then
170+
If Not IsEnabled Then
171+
'禁用
172+
AniStart(AaColor(PanColor, BackgroundProperty, "ColorBrushGray4", AnimationColorIn), "MyExtraButton Color " & Uuid)
173+
ElseIf IsMouseOver Then
171174
'指向
172175
AniStart(AaColor(PanColor, BackgroundProperty, "ColorBrush4", AnimationColorIn), "MyExtraButton Color " & Uuid)
173176
Else
@@ -178,7 +181,9 @@
178181
Else
179182

180183
AniStop("MyExtraButton Color " & Uuid)
181-
If IsMouseOver Then
184+
If Not IsEnabled Then
185+
PanColor.SetResourceReference(BackgroundProperty, "ColorBrushGray4")
186+
ElseIf IsMouseOver Then
182187
PanColor.SetResourceReference(BackgroundProperty, "ColorBrush4")
183188
Else
184189
PanColor.SetResourceReference(BackgroundProperty, "ColorBrush3")

Plain Craft Launcher 2/Controls/MyExtraTextButton.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:local="clr-namespace:PCL"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
x:Name="PanBack" mc:Ignorable="d" x:Class="MyExtraTextButton"
7-
RenderTransformOrigin="0.5,0.5" ToolTipService.Placement="Left" ToolTipService.VerticalOffset="16" ToolTipService.HorizontalOffset="-8" Height="52">
7+
RenderTransformOrigin="0.5,0.5" ToolTipService.Placement="Left" Height="52" Margin="20">
88
<Grid.RenderTransform>
99
<ScaleTransform ScaleX="0" ScaleY="0" />
1010
</Grid.RenderTransform>
@@ -20,14 +20,14 @@
2020
<DropShadowEffect ShadowDepth="0" BlurRadius="10" Opacity="0.2" />
2121
</Border.Effect>
2222
</Border>
23-
<StackPanel Orientation="Horizontal" Margin="24,0" SnapsToDevicePixels="False" UseLayoutRounding="False">
24-
<Path x:Name="Path" Stretch="Uniform" Margin="0,12" Fill="{DynamicResource ColorBrush8}" RenderTransformOrigin="0.5,0.5">
23+
<StackPanel Orientation="Horizontal" Margin="20,0" SnapsToDevicePixels="False" UseLayoutRounding="False">
24+
<Path x:Name="Path" Stretch="Uniform" Margin="2,12,0,12" Fill="{DynamicResource ColorBrush8}" RenderTransformOrigin="0.5,0.5">
2525
<Path.RenderTransform>
2626
<ScaleTransform />
2727
</Path.RenderTransform>
2828
</Path>
2929
<TextBlock x:Name="LabText" VerticalAlignment="Center" Foreground="{DynamicResource ColorBrush8}" FontSize="16"
30-
Margin="11,0,-2,1.2" />
30+
Margin="12,0,0,0.8" />
3131
</StackPanel>
3232
</Grid>
3333
</Grid>

0 commit comments

Comments
 (0)