Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
8 changes: 4 additions & 4 deletions Plain Craft Launcher 2/FormMain.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ Public Class FormMain
Try
If PageCurrent = PageType.VersionSetup AndAlso PageCurrentSub = PageSubType.VersionMod Then
'Mod 管理自动刷新
FrmVersionMod.ReloadModList()
FrmVersionMod.ReloadCompFileList()
ElseIf PageCurrent = PageType.VersionSelect Then
'版本选择自动刷新
LoaderFolderRun(McVersionListLoader, PathMcFolder, LoaderFolderRunType.RunOnUpdated, MaxDepth:=1, ExtraPath:="versions\")
Expand Down Expand Up @@ -775,7 +775,7 @@ Public Class FormMain
Exit Sub
End If
'安装 Mod
If PageVersionMod.InstallMods(FilePathList) Then Exit Sub
If PageVersionCompResource.InstallMods(FilePathList) Then Exit Sub
'处理资源安装
If PageCurrent = PageType.VersionSetup AndAlso {"zip"}.Any(Function(i) i = Extension) Then
Select Case PageCurrentSub
Expand All @@ -797,7 +797,7 @@ Public Class FormMain
End If
CopyFile(FilePath, DestFile)
Hint($"已导入 {GetFileNameFromPath(FilePath)}", HintType.Finish)
If FrmVersionResourcePack IsNot Nothing Then RunInUi(Sub() FrmVersionResourcePack.Reload())
If FrmVersionResourcePack IsNot Nothing Then RunInUi(Sub() FrmVersionResourcePack.ReloadCompFileList())
Exit Sub
Case PageSubType.VersionShader
Dim DestFile = PageVersionLeft.Version.PathIndie + "shaderpacks\" + GetFileNameFromPath(FilePath)
Expand All @@ -807,7 +807,7 @@ Public Class FormMain
End If
CopyFile(FilePath, DestFile)
Hint($"已导入 {GetFileNameFromPath(FilePath)}", HintType.Finish)
If FrmVersionShader IsNot Nothing Then RunInUi(Sub() FrmVersionShader.Reload())
If FrmVersionShader IsNot Nothing Then RunInUi(Sub() FrmVersionShader.ReloadCompFileList())
Exit Sub
End Select
End If
Expand Down
286 changes: 162 additions & 124 deletions Plain Craft Launcher 2/Modules/Minecraft/ModComp.vb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Plain Craft Launcher 2/Modules/Minecraft/MyCompItem.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@
End If
'打开详情页
Dim TargetVersion As String
Dim TargetLoader As CompModLoaderType
Dim TargetLoader As CompLoaderType
If FrmMain.PageCurrent.Page = FormMain.PageType.CompDetail Then
TargetVersion = FrmMain.PageCurrent.Additional(2)
TargetLoader = FrmMain.PageCurrent.Additional(3)
ElseIf FrmMain.PageCurrent.Page = FormMain.PageType.Download AndAlso FrmMain.PageCurrentSub = FormMain.PageSubType.DownloadCompFavorites Then
TargetVersion = ""
TargetLoader = CompModLoaderType.Any
TargetLoader = CompLoaderType.Any
Else
Select Case CType(sender.Tag, CompProject).Type
Case CompType.Mod
Expand All @@ -125,7 +125,7 @@
TargetVersion = "" 'If(PageDownloadResource.Loader.Input.GameVersion, "")
End Select
End If
If CType(sender.Tag, CompProject).Type <> CompType.Mod Then TargetLoader = CompModLoaderType.Any
If CType(sender.Tag, CompProject).Type <> CompType.Mod Then TargetLoader = CompLoaderType.Any
FrmMain.PageChange(New FormMain.PageStackData With {.Page = FormMain.PageType.CompDetail,
.Additional = {sender.Tag, New List(Of String), TargetVersion, TargetLoader}})
End Sub
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Grid x:Class="MyLocalModItem"
<Grid x:Class="MyLocalCompItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:PCL;assembly="
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Imports System.Windows.Forms

Public Class MyLocalModItem
Public Class MyLocalCompItem

#Region "基础属性"
Public Uuid As Integer = GetUuid()
Expand All @@ -24,11 +24,11 @@ Public Class MyLocalModItem
Set(value As String)
Dim RawValue = value
Select Case Entry.State
Case McMod.McModState.Fine
Case LocalCompFile.LocalFileStatus.Fine
LabTitle.TextDecorations = Nothing
Case McMod.McModState.Disabled
Case LocalCompFile.LocalFileStatus.Disabled
LabTitle.TextDecorations = TextDecorations.Strikethrough
Case McMod.McModState.Unavailable
Case LocalCompFile.LocalFileStatus.Unavailable
LabTitle.TextDecorations = TextDecorations.Strikethrough
value &= " [错误]"
End Select
Expand Down Expand Up @@ -79,11 +79,11 @@ Public Class MyLocalModItem
End Property

'相关联的 Mod
Public Property Entry As McMod
Public Property Entry As LocalCompFile
Get
Return Tag
End Get
Set(value As McMod)
Set(value As LocalCompFile)
Tag = value
End Set
End Property
Expand Down Expand Up @@ -114,39 +114,46 @@ Public Class MyLocalModItem
If ButtonStack IsNot Nothing Then ButtonStack.IsHitTestVisible = True
End Sub

Public Class SwipeSelect
Public Property Start As Integer
Public Property [End] As Integer
Public Property Swiping As Boolean
Public Property SwipeToState As Boolean
Public Property TargetFrm As PageVersionCompResource
End Class

Public Property CurrentSwipe As SwipeSelect

'滑动选中
Private Shared SwipeStart As Integer, SwipeEnd As Integer
Private Shared Swiping As Boolean = False
Private Shared SwipToState As Boolean '被滑动到的目标应将 Checked 改为此值
Private Sub Button_MouseSwipeStart(sender As Object, e As Object) Handles Me.MouseLeftButtonDown
If Parent Is Nothing Then Exit Sub 'Mod 可能已被删除(#3824)
If Parent Is Nothing OrElse CurrentSwipe Is Nothing Then Exit Sub 'Mod 可能已被删除(#3824)
'开始滑动
Dim Index = CType(Parent, StackPanel).Children.IndexOf(Me)
SwipeStart = Index
SwipeEnd = Index
Swiping = True
SwipToState = Not Checked
FrmVersionMod.CardSelect.IsHitTestVisible = False '暂时禁用下边栏
CurrentSwipe.Start = Index
CurrentSwipe.End = Index
CurrentSwipe.Swiping = True
CurrentSwipe.SwipeToState = Not Checked
CurrentSwipe.TargetFrm.CardSelect.IsHitTestVisible = False '暂时禁用下边栏
End Sub
Private Sub Button_MouseSwipe(sender As Object, e As Object) Handles Me.MouseEnter, Me.MouseLeave, Me.MouseLeftButtonUp
If Parent Is Nothing Then Exit Sub 'Mod 可能已被删除(#3824)
If Parent Is Nothing OrElse CurrentSwipe Is Nothing Then Exit Sub 'Mod 可能已被删除(#3824)
'结束滑动
If Mouse.LeftButton <> MouseButtonState.Pressed OrElse Not Swiping Then
Swiping = False
FrmVersionMod.CardSelect.IsHitTestVisible = True
If Mouse.LeftButton <> MouseButtonState.Pressed OrElse Not CurrentSwipe.Swiping Then
CurrentSwipe.Swiping = False
CurrentSwipe.TargetFrm.CardSelect.IsHitTestVisible = True
Exit Sub
End If
'计算滑动范围
Dim Elements = CType(Parent, StackPanel).Children
Dim Index As Integer = Elements.IndexOf(Me)
SwipeStart = MathClamp(Math.Min(SwipeStart, Index), 0, Elements.Count - 1)
SwipeEnd = MathClamp(Math.Max(SwipeEnd, Index), 0, Elements.Count - 1)
CurrentSwipe.Start = MathClamp(Math.Min(CurrentSwipe.Start, Index), 0, Elements.Count - 1)
CurrentSwipe.End = MathClamp(Math.Max(CurrentSwipe.End, Index), 0, Elements.Count - 1)
'勾选所有范围中的项
If SwipeStart = SwipeEnd Then Exit Sub
For i = SwipeStart To SwipeEnd
Dim Item As MyLocalModItem = Elements(i)
If CurrentSwipe.Start = CurrentSwipe.End Then Exit Sub
For i = CurrentSwipe.Start To CurrentSwipe.End
Dim Item As MyLocalCompItem = Elements(i)
Item.InitLate(Item, e)
Item.Checked = SwipToState
Item.Checked = CurrentSwipe.SwipeToState
Next
End Sub

Expand Down Expand Up @@ -188,29 +195,29 @@ Public Class MyLocalModItem
Anim.Add(AaOpacity(RectCheck, 1 - RectCheck.Opacity, 30))
RectCheck.VerticalAlignment = VerticalAlignment.Center
RectCheck.Margin = New Thickness(-3, 0, 0, 0)
Anim.Add(AaColor(LabTitle, TextBlock.ForegroundProperty, If(Entry.State = McMod.McModState.Fine, "ColorBrush2", "ColorBrush5"), 200))
Anim.Add(AaColor(LabTitle, TextBlock.ForegroundProperty, If(Entry.State = LocalCompFile.LocalFileStatus.Fine, "ColorBrush2", "ColorBrush5"), 200))
Else
'由有变无
Anim.Add(AaHeight(RectCheck, -RectCheck.ActualHeight, 120,, New AniEaseInFluent(AniEasePower.Weak)))
Anim.Add(AaOpacity(RectCheck, -RectCheck.Opacity, 70, 40))
RectCheck.VerticalAlignment = VerticalAlignment.Center
Anim.Add(AaColor(LabTitle, TextBlock.ForegroundProperty, If(LabTitle.TextDecorations Is Nothing, "ColorBrush1", "ColorBrushGray4"), 120))
End If
AniStart(Anim, "MyLocalModItem Checked " & Uuid)
AniStart(Anim, "MyLocalCompItem Checked " & Uuid)
Else
'不在窗口上时直接设置
RectCheck.VerticalAlignment = VerticalAlignment.Center
RectCheck.Margin = New Thickness(-3, 0, 0, 0)
If Checked Then
RectCheck.Height = 32
RectCheck.Opacity = 1
LabTitle.SetResourceReference(TextBlock.ForegroundProperty, If(Entry.State = McMod.McModState.Fine, "ColorBrush2", "ColorBrush5"))
LabTitle.SetResourceReference(TextBlock.ForegroundProperty, If(Entry.State = LocalCompFile.LocalFileStatus.Fine, "ColorBrush2", "ColorBrush5"))
Else
RectCheck.Height = 0
RectCheck.Opacity = 0
LabTitle.SetResourceReference(TextBlock.ForegroundProperty, If(Entry.State = McMod.McModState.Fine, "ColorBrush1", "ColorBrushGray4"))
LabTitle.SetResourceReference(TextBlock.ForegroundProperty, If(Entry.State = LocalCompFile.LocalFileStatus.Fine, "ColorBrush1", "ColorBrushGray4"))
End If
AniStop("MyLocalModItem Checked " & Uuid)
AniStop("MyLocalCompItem Checked " & Uuid)
End If
Catch ex As Exception
Log(ex, "设置 Checked 失败")
Expand Down Expand Up @@ -256,7 +263,7 @@ Public Class MyLocalModItem
End Property

'按钮
Public ButtonHandler As Action(Of MyLocalModItem, EventArgs)
Public ButtonHandler As Action(Of MyLocalCompItem, EventArgs)
Public ButtonStack As FrameworkElement
Private _Buttons As IEnumerable(Of MyIconButton)
Public Property Buttons As IEnumerable(Of MyIconButton)
Expand Down Expand Up @@ -337,9 +344,9 @@ Public Class MyLocalModItem
'标题与描述
Dim DescFileName As String
Select Case Entry.State
Case McMod.McModState.Fine
Case LocalCompFile.LocalFileStatus.Fine
DescFileName = GetFileNameWithoutExtentionFromPath(Entry.Path)
Case McMod.McModState.Disabled
Case LocalCompFile.LocalFileStatus.Disabled
DescFileName = GetFileNameWithoutExtentionFromPath(Entry.Path.Replace(".disabled", "").Replace(".old", ""))
Case Else 'McMod.McModState.Unavailable
DescFileName = GetFileNameFromPath(Entry.Path)
Expand Down Expand Up @@ -382,14 +389,14 @@ Public Class MyLocalModItem
End If
Description = NewDescription
If Checked Then
LabTitle.SetResourceReference(TextBlock.ForegroundProperty, If(Entry.State = McMod.McModState.Fine, "ColorBrush2", "ColorBrush5"))
LabTitle.SetResourceReference(TextBlock.ForegroundProperty, If(Entry.State = LocalCompFile.LocalFileStatus.Fine, "ColorBrush2", "ColorBrush5"))
Else
LabTitle.SetResourceReference(TextBlock.ForegroundProperty, If(Entry.State = McMod.McModState.Fine, "ColorBrush1", "ColorBrushGray4"))
LabTitle.SetResourceReference(TextBlock.ForegroundProperty, If(Entry.State = LocalCompFile.LocalFileStatus.Fine, "ColorBrush1", "ColorBrushGray4"))
End If
'主 Logo
Logo = If(Entry.Comp Is Nothing, PathImage & "Icons/NoIcon.png", Entry.Comp.GetControlLogo())
'图标右下角的 Logo
If Entry.State = McMod.McModState.Fine Then
If Entry.State = LocalCompFile.LocalFileStatus.Fine Then
If ImgState IsNot Nothing Then
Children.Remove(ImgState)
ImgState = Nothing
Expand Down Expand Up @@ -483,9 +490,13 @@ Public Class MyLocalModItem

'触发更新
Private Sub BtnUpdate_Click(sender As Object, e As EventArgs) Handles BtnUpdate.Click
Select Case MyMsgBox($"是否要更新 {Entry.Name}?{vbCrLf}{vbCrLf}{GetUpdateCompareDescription()}", "Mod 更新确认", "更新", "查看更新日志", "取消")
Select Case MyMsgBox($"是否要更新 {Entry.Name}?{vbCrLf}{vbCrLf}{GetUpdateCompareDescription()}", "更新确认", "更新", "查看更新日志", "取消")
Case 1 '更新
FrmVersionMod.UpdateMods({Entry})
Select Case Entry.Comp.Type
Case CompType.Mod : FrmVersionMod.UpdateResource({Entry})
Case CompType.ResourcePack : FrmVersionResourcePack.UpdateResource({Entry})
Case CompType.Shader : FrmVersionShader.UpdateResource({Entry})
End Select
Case 2 '查看更新日志
ShowUpdateLog()
Case 3 '取消
Expand Down
6 changes: 3 additions & 3 deletions Plain Craft Launcher 2/Modules/ModMain.vb
Original file line number Diff line number Diff line change
Expand Up @@ -441,12 +441,12 @@ EndHint:
'版本设置页面声明
Public FrmVersionLeft As PageVersionLeft
Public FrmVersionOverall As PageVersionOverall
Public FrmVersionMod As PageVersionMod
Public FrmVersionMod As PageVersionCompResource
Public FrmVersionModDisabled As PageVersionModDisabled
Public FrmVersionScreenshot As PageVersionScreenshot
Public FrmVersionWorld As PageVersionWorld
Public FrmVersionShader As PageVersionShader
Public FrmVersionResourcePack As PageVersionResourcePack
Public FrmVersionShader As PageVersionCompResource
Public FrmVersionResourcePack As PageVersionCompResource
Public FrmVersionSetup As PageVersionSetup
Public FrmVersionInstall As PageVersionInstall

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
TargetLoader = FrmMain.PageCurrent.Additional(3)
End Sub
Private Project As CompProject
Private TargetVersion As String, TargetLoader As CompModLoaderType
Private TargetVersion As String, TargetLoader As CompLoaderType
'自动重试
Private Sub Load_State(sender As Object, state As MyLoading.MyLoadingState, oldState As MyLoading.MyLoadingState) Handles Load.StateChanged
Select Case CompFileLoader.State
Expand Down Expand Up @@ -119,12 +119,12 @@
UpdateFilterResult()
End Sub
Private Sub UpdateFilterResult()
Dim TargetCardName As String = If(TargetVersion <> "" OrElse TargetLoader <> CompModLoaderType.Any,
$"所选版本:{If(TargetLoader <> CompModLoaderType.Any, TargetLoader.ToString & " ", "")}{TargetVersion}", "")
Dim TargetCardName As String = If(TargetVersion <> "" OrElse TargetLoader <> CompLoaderType.Any,
$"所选版本:{If(TargetLoader <> CompLoaderType.Any, TargetLoader.ToString & " ", "")}{TargetVersion}", "")
'归类到卡片下
Dim Dict As New SortedDictionary(Of String, List(Of CompFile))(New CardSorter(TargetCardName))
Dict.Add("其他版本", New List(Of CompFile))
Dim SupportedLoaders As New List(Of Integer)([Enum].GetValues(GetType(CompModLoaderType)))
Dim SupportedLoaders As New List(Of Integer)([Enum].GetValues(GetType(CompLoaderType)))
For Each Version As CompFile In CompFileLoader.Output
For Each GameVersion In Version.GameVersions
'检查是否符合版本筛选器
Expand All @@ -138,7 +138,7 @@
Project.Type = CompType.Mod AndAlso '是 Mod
Ver.StartsWith("1.") Then '不是 “快照版本” 之类的
For Each Loader In Version.ModLoaders
If Loader = CompModLoaderType.Quilt AndAlso Setup.Get("ToolDownloadIgnoreQuilt") Then Continue For
If Loader = CompLoaderType.Quilt AndAlso Setup.Get("ToolDownloadIgnoreQuilt") Then Continue For
If SupportedLoaders.Contains(Loader) Then Loaders.Add(Loader.ToString & " ")
Next
End If
Expand All @@ -156,7 +156,7 @@
Dict.Add(TargetCardName, New List(Of CompFile))
For Each Version As CompFile In CompFileLoader.Output
If Version.GameVersions.Contains(TargetVersion) AndAlso
(TargetLoader = CompModLoaderType.Any OrElse Version.ModLoaders.Contains(TargetLoader)) Then
(TargetLoader = CompLoaderType.Any OrElse Version.ModLoaders.Contains(TargetLoader)) Then
'检查是否符合版本筛选器
If VersionFilter IsNot Nothing AndAlso
Not Version.GameVersions.Any(Function(v) GetGroupedVersionName(v, IsMajorVersionFilter, True) = VersionFilter) Then Continue For
Expand Down Expand Up @@ -322,11 +322,11 @@
'获取 Mod 所需的加载器种类
Dim AllowForge As Boolean? = Nothing, AllowFabric As Boolean? = Nothing
If File.ModLoaders.Any Then '从文件中获取
AllowForge = File.ModLoaders.Contains(CompModLoaderType.Forge) OrElse File.ModLoaders.Contains(CompModLoaderType.NeoForge)
AllowFabric = File.ModLoaders.Contains(CompModLoaderType.Fabric)
AllowForge = File.ModLoaders.Contains(CompLoaderType.Forge) OrElse File.ModLoaders.Contains(CompLoaderType.NeoForge)
AllowFabric = File.ModLoaders.Contains(CompLoaderType.Fabric)
ElseIf Project.ModLoaders.Any Then '从工程中获取
AllowForge = Project.ModLoaders.Contains(CompModLoaderType.Forge) OrElse File.ModLoaders.Contains(CompModLoaderType.NeoForge)
AllowFabric = Project.ModLoaders.Contains(CompModLoaderType.Fabric)
AllowForge = Project.ModLoaders.Contains(CompLoaderType.Forge) OrElse File.ModLoaders.Contains(CompLoaderType.NeoForge)
AllowFabric = Project.ModLoaders.Contains(CompLoaderType.Fabric)
End If
If AllowForge IsNot Nothing AndAlso Not AllowForge AndAlso
AllowFabric IsNot Nothing AndAlso Not AllowFabric Then
Expand Down
Loading