Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
14 changes: 14 additions & 0 deletions Plain Craft Launcher 2/Modules/Minecraft/ModLoaderType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace PCL;

/// <summary>
/// 实例安装流程中可互斥选择的主 Mod 加载器。
/// </summary>
internal enum ModLoaderType
{
Forge,
NeoForge,
Cleanroom,
Fabric,
LegacyFabric,
LabyMod
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ public void MinecraftSelected(MyListItem sender, MouseButtonEventArgs e)
private ModDownload.DlOptiFineListEntry? selectedOptiFine;

/// <summary>
/// 选定的 Mod Loader 名称,内容应为 Forge / NeoForge / Fabric / Cleanroom / LabyMod / LegacyFabric
/// 选定的主 Mod 加载器。
/// </summary>
private string? selectedLoaderName;
private ModLoaderType? selectedLoaderName;

/// <summary>
/// 选定的 Mod Loader API 名称,内容应为 Fabric API
Expand Down Expand Up @@ -1083,14 +1083,14 @@ private static void _StackInstall(StackPanel stack)
/// </summary>
private string LoadOptiFineGetError()
{
if (selectedLoaderName == "NeoForge" || selectedLoaderName == "LabyMod" || selectedLoaderName == "Cleanroom")
if (selectedLoaderName is ModLoaderType.NeoForge or ModLoaderType.LabyMod or ModLoaderType.Cleanroom)
return Lang.Text("Download.Install.Compat.IncompatibleWithLoader", selectedLoaderName);
if (LoadOptiFine is null || LoadOptiFine.State.LoadingState == MyLoading.MyLoadingState.Run)
return Lang.Text("Download.Install.State.Loading");
if (LoadOptiFine.State.LoadingState == MyLoading.MyLoadingState.Error)
return $"{Lang.Text("Download.Install.State.GetVersionListFailed")}{((ModLoader.LoaderBase)LoadOptiFine.State).Error.Message}";
// 检查 Forge 1.13 - 1.14.3:全部不兼容
if (selectedLoaderName == "Forge" && McVersionComparer.CompareVersion(_vanillaName, "1.13") >= 0 &&
if (selectedLoaderName == ModLoaderType.Forge && McVersionComparer.CompareVersion(_vanillaName, "1.13") >= 0 &&
McVersionComparer.CompareVersion("1.14.3", _vanillaName) >= 0) return Lang.Text("Download.Install.Compat.IncompatibleWithLoader", selectedLoaderName);
// 检查 Fabric 1.20.5+: 全部不兼容
if (selectedFabric is not null && McVersionComparer.CompareVersion(_vanillaName, "1.20.4") > 0)
Expand Down Expand Up @@ -1232,7 +1232,7 @@ private string LoadLiteLoaderGetError()
// 检查 Loader
if (GetLoaderError(LoadLiteLoader) is not null)
return GetLoaderError(LoadLiteLoader);
if (selectedLoaderName == "NeoForge" || selectedLoaderName == "LegacyFabric" || selectedLoaderName == "LabyMod" || selectedLoaderName == "Cleanroom")
if (selectedLoaderName is ModLoaderType.NeoForge or ModLoaderType.LegacyFabric or ModLoaderType.LabyMod or ModLoaderType.Cleanroom)
return Lang.Text("Download.Install.Compat.IncompatibleWithLoader", selectedLoaderName);
// 检查版本
return ModDownload.dlLiteLoaderListLoader.output.Value.Any(v => (v.Inherit ?? "") == (_vanillaName ?? ""))
Expand Down Expand Up @@ -1307,7 +1307,7 @@ private string LoadForgeGetError()
if (McVersionComparer.CompareVersionGe("1.5.1", _vanillaName) && McVersionComparer.CompareVersionGe(_vanillaName, "1.1"))
return Lang.Text("Download.Install.State.NoVersion");

if (selectedLoaderName is not null && !ReferenceEquals(selectedLoaderName, "Forge"))
if (selectedLoaderName is not null && selectedLoaderName != ModLoaderType.Forge)
return Lang.Text("Download.Install.Compat.IncompatibleWithLoader", selectedLoaderName);

// 检查 Loader
Expand Down Expand Up @@ -1389,7 +1389,7 @@ private void Forge_Loaded()
private void Forge_Selected(MyListItem sender, EventArgs e)
{
selectedForge = (ModDownload.DlForgeVersionEntry)(dynamic)sender.Tag;
selectedLoaderName = "Forge";
selectedLoaderName = ModLoaderType.Forge;
CardForge.IsSwapped = true;
if (selectedOptiFine is not null &&
!(bool)IsOptiFineSuitForForge(selectedOptiFine, selectedForge))
Expand Down Expand Up @@ -1419,7 +1419,7 @@ private string LoadNeoForgeGetError()
{
if (selectedOptiFine is not null)
return Lang.Text("Download.Install.Compat.IncompatibleWithOptiFine");
if (selectedLoaderName is not null && !ReferenceEquals(selectedLoaderName, "NeoForge"))
if (selectedLoaderName is not null && selectedLoaderName != ModLoaderType.NeoForge)
return Lang.Text("Download.Install.Compat.IncompatibleWithLoader", selectedLoaderName);
// 检查 Loader
if (GetLoaderError(LoadNeoForge) is not null)
Expand Down Expand Up @@ -1475,7 +1475,7 @@ private void NeoForge_Loaded()
private void NeoForge_Selected(MyListItem sender, EventArgs e)
{
selectedNeoForge = (ModDownload.DlNeoForgeListEntry)(dynamic)sender.Tag;
selectedLoaderName = "NeoForge";
selectedLoaderName = ModLoaderType.NeoForge;
CardNeoForge.IsSwapped = true;
OptiFine_Loaded();
ReloadSelected();
Expand Down Expand Up @@ -1504,7 +1504,7 @@ private void NeoForge_Clear(object sender, MouseButtonEventArgs e)
return Lang.Text("Download.Install.State.NoAvailableVersion");
if (selectedOptiFine is not null)
return Lang.Text("Download.Install.Compat.IncompatibleWithOptiFine");
if (selectedLoaderName is not null && selectedLoaderName != "Cleanroom")
if (selectedLoaderName is not null && selectedLoaderName != ModLoaderType.Cleanroom)
return Lang.Text("Download.Install.Compat.IncompatibleWithLoader", selectedLoaderName);
if (selectedLiteLoader is not null)
return Lang.Text("Download.Install.Compat.IncompatibleWithLiteLoader");
Expand Down Expand Up @@ -1561,7 +1561,7 @@ private void Cleanroom_Loaded()
private void Cleanroom_Selected(MyListItem sender, EventArgs e)
{
selectedCleanroom = (ModDownload.DlCleanroomListEntry)(dynamic)sender.Tag;
selectedLoaderName = "Cleanroom";
selectedLoaderName = ModLoaderType.Cleanroom;
CardCleanroom.IsSwapped = true;
OptiFine_Loaded();
ReloadSelected();
Expand Down Expand Up @@ -1597,7 +1597,7 @@ private string LoadFabricGetError()
if ((version["version"].ToString() ?? "") ==
(_vanillaName.Replace("∞", "infinite").Replace("Combat Test 7c", "1.16_combat-3") ?? ""))
{
if (selectedLoaderName is not null && !ReferenceEquals(selectedLoaderName, "Fabric"))
if (selectedLoaderName is not null && selectedLoaderName != ModLoaderType.Fabric)
return Lang.Text("Download.Install.Compat.IncompatibleWithLoader", selectedLoaderName);
return null;
}
Expand Down Expand Up @@ -1652,7 +1652,7 @@ public void Fabric_Selected(MyListItem sender, EventArgs e)
{
ModBase.Log(((dynamic)sender.Tag).ToString());
selectedFabric = ((dynamic)sender.Tag)["version"].ToString();
selectedLoaderName = "Fabric";
selectedLoaderName = ModLoaderType.Fabric;
FabricApi_Loaded();
OptiFabric_Loaded();
CardFabric.IsSwapped = true;
Expand Down Expand Up @@ -1815,7 +1815,7 @@ private string LoadLegacyFabricGetError()
{
if (selectedLiteLoader is not null)
return Lang.Text("Download.Install.Compat.IncompatibleWithLiteLoader");
if (selectedLoaderName is not null && !ReferenceEquals(selectedLoaderName, "LegacyFabric"))
if (selectedLoaderName is not null && selectedLoaderName != ModLoaderType.LegacyFabric)
return Lang.Text("Download.Install.Compat.IncompatibleWithLoader", selectedLoaderName);
return null;
}
Expand Down Expand Up @@ -1868,7 +1868,7 @@ private void LegacyFabric_Loaded()
public void LegacyFabric_Selected(MyListItem sender, EventArgs e)
{
selectedLegacyFabric = ((dynamic)sender.Tag)["version"].ToString();
selectedLoaderName = "LegacyFabric";
selectedLoaderName = ModLoaderType.LegacyFabric;
LegacyFabricApi_Loaded();
CardLegacyFabric.IsSwapped = true;
ReloadSelected();
Expand Down Expand Up @@ -2165,7 +2165,7 @@ private string LoadLabyModGetError()
return GetLoaderError(LoadLabyMod);
if (selectedOptiFine is not null)
return Lang.Text("Download.Install.Compat.IncompatibleWithOptiFine");
if (selectedLoaderName is not null && selectedLoaderName != "LabyMod")
if (selectedLoaderName is not null && selectedLoaderName != ModLoaderType.LabyMod)
return Lang.Text("Download.Install.Compat.IncompatibleWithLoader", selectedLoaderName);
if (selectedLiteLoader is not null)
return Lang.Text("Download.Install.Compat.IncompatibleWithLiteLoader");
Expand Down Expand Up @@ -2249,7 +2249,7 @@ public void LabyMod_Selected(MyListItem sender, EventArgs e)
selectedLabyModBaseVersion = ((dynamic)sender.Tag)["version"].ToString();
selectedLabyModVersion =
selectedLabyModBaseVersion + " " + (selectedLabyModChannel == "snapshot" ? Lang.Text("Download.Version.Type.Snapshot") : Lang.Text("Download.Version.Type.Stable"));
selectedLoaderName = "LabyMod";
selectedLoaderName = ModLoaderType.LabyMod;
CardLabyMod.IsSwapped = true;
ReloadSelected();
}
Expand All @@ -2261,7 +2261,7 @@ private void LabyMod_Clear(object sender, MouseButtonEventArgs e)
selectedLabyModBaseVersion = null;
selectedLabyModChannel = null;

if (selectedLoaderName == "LabyMod")
if (selectedLoaderName == ModLoaderType.LabyMod)
{
selectedLoaderName = null;
}
Expand Down
Loading
Loading