From 3b7684e449277b433af669a6c0604933dabe420e Mon Sep 17 00:00:00 2001
From: Coloryr <402067010@qq.com>
Date: Fri, 16 Aug 2024 19:36:43 +0800
Subject: [PATCH] up
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
更新UI布局
修复自定义窗口问题
---
.github/workflows/dotnet-build.yml | 6 +-
src/ColorMC.Core/CoreMain.cs | 12 +-
src/ColorMC.CustomGui/CustomUI.cs | 1 +
src/ColorMC.Gui/ColorMC.Gui.csproj | 5 +
src/ColorMC.Gui/Manager/WindowManager.cs | 2 +-
src/ColorMC.Gui/Objs/Results.cs | 2 +-
.../Resource/Language/gui_zh-cn.json | 4 +-
.../UI/Controls/Add/AddControl.axaml | 144 +++++-----
.../UI/Controls/Add/AddControl.axaml.cs | 15 -
.../UI/Controls/Add/AddModPackControl.axaml | 84 +++---
.../Controls/Add/AddModPackControl.axaml.cs | 7 -
.../UI/Controls/Custom/ICustomControl.cs | 1 +
.../Controls/Items/FileItemControl.axaml.cs | 4 +-
.../Items/FileModVersionControl.axaml | 36 +++
.../Items/FileModVersionControl.axaml.cs | 13 +
.../Items/FileVersionItemControl.axaml | 39 +++
.../Items/FileVersionItemControl.axaml.cs | 147 ++++++++++
.../UI/Model/Add/AddControlModel.cs | 88 ++++--
.../UI/Model/Add/AddModPackControlModel.cs | 67 ++++-
.../UI/Model/Items/DownloadModModel.cs | 2 +-
.../UI/Model/Items/FileDisplayModel.cs | 54 ----
.../UI/Model/Items/FileItemDisplayModel.cs | 61 -----
.../UI/Model/Items/FileItemModel.cs | 118 +++++---
.../UI/Model/Items/FileVersionItemModel.cs | 111 ++++++++
src/ColorMC.Gui/UI/Model/SelectItemModel.cs | 14 +-
src/ColorMC.Gui/UI/Windows/IAddWindow.cs | 4 +
src/ColorMC.Gui/UIBinding/BaseBinding.cs | 3 +-
src/ColorMC.Gui/UIBinding/GameBinding.cs | 2 +-
src/ColorMC.Gui/UIBinding/WebBinding.cs | 258 ++++++------------
src/ColorMC.Gui/Utils/DllAssembly.cs | 10 +-
src/ColorMC.Launcher/Program.cs | 2 +-
src/ColorMC.sln | 27 +-
32 files changed, 808 insertions(+), 535 deletions(-)
create mode 100644 src/ColorMC.Gui/UI/Controls/Items/FileModVersionControl.axaml
create mode 100644 src/ColorMC.Gui/UI/Controls/Items/FileModVersionControl.axaml.cs
create mode 100644 src/ColorMC.Gui/UI/Controls/Items/FileVersionItemControl.axaml
create mode 100644 src/ColorMC.Gui/UI/Controls/Items/FileVersionItemControl.axaml.cs
delete mode 100644 src/ColorMC.Gui/UI/Model/Items/FileDisplayModel.cs
delete mode 100644 src/ColorMC.Gui/UI/Model/Items/FileItemDisplayModel.cs
create mode 100644 src/ColorMC.Gui/UI/Model/Items/FileVersionItemModel.cs
diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml
index 7388676b8..c24f8ad0a 100644
--- a/.github/workflows/dotnet-build.yml
+++ b/.github/workflows/dotnet-build.yml
@@ -17,7 +17,7 @@ jobs:
- name: 设置.NET Core
uses: actions/setup-dotnet@v4
with:
- dotnet-version: 8.0.303
+ dotnet-version: 8.0.401
- name: Read version number
id: version
@@ -181,7 +181,7 @@ jobs:
- name: 设置.NET Core
uses: actions/setup-dotnet@v4
with:
- dotnet-version: 8.0.300
+ dotnet-version: 8.0.401
- name: Read version number
id: version
@@ -245,7 +245,7 @@ jobs:
- name: 设置.NET Core
uses: actions/setup-dotnet@v4
with:
- dotnet-version: 8.0.303
+ dotnet-version: 8.0.401
- name: 更新源码
shell: cmd
diff --git a/src/ColorMC.Core/CoreMain.cs b/src/ColorMC.Core/CoreMain.cs
index 4b6c44725..f34e7ecb8 100644
--- a/src/ColorMC.Core/CoreMain.cs
+++ b/src/ColorMC.Core/CoreMain.cs
@@ -258,12 +258,12 @@ public static void KillGame(string uuid)
}
///
- /// 启动器产生错误
+ /// 启动器产生错误,并打开窗口显示
///
///
///
///
- public static void OnError(string text, Exception? e, bool close)
+ internal static void OnError(string text, Exception? e, bool close)
{
Error?.Invoke(text, e, close);
Logs.Error(text, e);
@@ -274,7 +274,7 @@ public static void OnError(string text, Exception? e, bool close)
///
///
///
- public static void OnGameLog(GameSettingObj obj, string? text)
+ internal static void OnGameLog(GameSettingObj obj, string? text)
{
GameLog?.Invoke(obj, text);
}
@@ -283,18 +283,18 @@ public static void OnGameLog(GameSettingObj obj, string? text)
/// 语言重载
///
///
- public static void OnLanguageReload(LanguageType type)
+ internal static void OnLanguageReload(LanguageType type)
{
LanguageReload?.Invoke(type);
}
///
- /// 游戏推出
+ /// 游戏退出
///
///
///
///
- public static void OnGameExit(GameSettingObj obj, LoginObj obj1, int code)
+ internal static void OnGameExit(GameSettingObj obj, LoginObj obj1, int code)
{
Games.TryRemove(obj.UUID, out _);
GameExit?.Invoke(obj, obj1, code);
diff --git a/src/ColorMC.CustomGui/CustomUI.cs b/src/ColorMC.CustomGui/CustomUI.cs
index 7d70c4a57..a7abc4193 100644
--- a/src/ColorMC.CustomGui/CustomUI.cs
+++ b/src/ColorMC.CustomGui/CustomUI.cs
@@ -5,6 +5,7 @@ namespace ColorMC.CustomGui;
public class CustomUI : ICustomControl
{
+ public string LauncherApi => "A29";
///
/// 返回主界面 一般不用动
///
diff --git a/src/ColorMC.Gui/ColorMC.Gui.csproj b/src/ColorMC.Gui/ColorMC.Gui.csproj
index a22598e7c..0b7ef4f8e 100644
--- a/src/ColorMC.Gui/ColorMC.Gui.csproj
+++ b/src/ColorMC.Gui/ColorMC.Gui.csproj
@@ -345,4 +345,9 @@
+
+
+ FileVersionItemControl.axaml
+
+
diff --git a/src/ColorMC.Gui/Manager/WindowManager.cs b/src/ColorMC.Gui/Manager/WindowManager.cs
index deedabbcb..865d2c53b 100644
--- a/src/ColorMC.Gui/Manager/WindowManager.cs
+++ b/src/ColorMC.Gui/Manager/WindowManager.cs
@@ -279,7 +279,7 @@ public static bool ShowCustom(bool test = false)
{
var data = App.Lang("WindowManager.Error1");
Logs.Error(data, e);
- ShowError(data, e, true);
+ ShowError(data, e, !test);
}
return false;
diff --git a/src/ColorMC.Gui/Objs/Results.cs b/src/ColorMC.Gui/Objs/Results.cs
index adf1146d2..5449fc137 100644
--- a/src/ColorMC.Gui/Objs/Results.cs
+++ b/src/ColorMC.Gui/Objs/Results.cs
@@ -39,7 +39,7 @@ public record ModDownloadRes
{
public DownloadItemObj Item;
public ModInfoObj Info;
- public List List;
+ public List List;
}
public record GetJavaListRes
diff --git a/src/ColorMC.Gui/Resource/Language/gui_zh-cn.json b/src/ColorMC.Gui/Resource/Language/gui_zh-cn.json
index 71c04f7fa..15bcfecc9 100644
--- a/src/ColorMC.Gui/Resource/Language/gui_zh-cn.json
+++ b/src/ColorMC.Gui/Resource/Language/gui_zh-cn.json
@@ -683,8 +683,7 @@
"AddModPackWindow.Text12": "安装所选",
"AddModPackWindow.Text13": "没有资源",
"AddModPackWindow.Text14": "下一页",
- "AddModPackWindow.Text15": "下载次数",
- "AddModPackWindow.Text16": "发布时间",
+ "AddModPackWindow.Text16": "发布时间:",
"AddModPackWindow.Info1": "是否安装整合包 {0}",
"AddModPackWindow.Info2": "正在搜索整合包中",
"AddModPackWindow.Info3": "正在获取整合包版本中",
@@ -719,6 +718,7 @@
"AddWindow.Info11": "正在下载",
"AddWindow.Info13": "正在加载Optifine列表",
"AddWindow.Info14": "选择下载源",
+ "AddWindow.Info15": "是否切换模组版本",
"AddWindow.Error1": "你还没有选择资源",
"AddWindow.Error2": "资源数据加载失败",
"AddWindow.Error3": "资源版本数据加载失败",
diff --git a/src/ColorMC.Gui/UI/Controls/Add/AddControl.axaml b/src/ColorMC.Gui/UI/Controls/Add/AddControl.axaml
index c4c568ee4..bc7700279 100644
--- a/src/ColorMC.Gui/UI/Controls/Add/AddControl.axaml
+++ b/src/ColorMC.Gui/UI/Controls/Add/AddControl.axaml
@@ -13,7 +13,10 @@
x:DataType="model:AddControlModel"
mc:Ignorable="d">
-
+
-
-
-
+
+
+
@@ -196,38 +202,40 @@
ToolTip.VerticalOffset="-30" />
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -296,10 +304,16 @@
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ColorMC.Gui/UI/Controls/Add/AddControl.axaml.cs b/src/ColorMC.Gui/UI/Controls/Add/AddControl.axaml.cs
index 17d31063b..7a8d0e48f 100644
--- a/src/ColorMC.Gui/UI/Controls/Add/AddControl.axaml.cs
+++ b/src/ColorMC.Gui/UI/Controls/Add/AddControl.axaml.cs
@@ -27,9 +27,7 @@ public AddControl(GameSettingObj obj) : this()
Title = string.Format(App.Lang("AddWindow.Title"), obj.Name);
UseName = (ToString() ?? "GameSettingObj") + ":" + obj.UUID;
- VersionFiles.DoubleTapped += VersionFiles_DoubleTapped;
OptifineFiles.DoubleTapped += OptifineFiles_DoubleTapped;
- ModDownloadFiles.DoubleTapped += ModDownloadFiles_DoubleTapped;
VersionDisplay.PointerPressed += VersionDisplay_PointerPressed;
OptifineDisplay.PointerPressed += OptifineDisplay_PointerPressed;
@@ -171,22 +169,9 @@ private void ModDownloadDisplay_PointerPressed(object? sender, PointerPressedEve
e.Handled = true;
}
}
- private void ModDownloadFiles_DoubleTapped(object? sender, TappedEventArgs e)
- {
- var item = (DataContext as AddControlModel)!.Mod;
- if (item != null)
- {
- item.Download = !item.Download;
- }
- }
private async void OptifineFiles_DoubleTapped(object? sender, TappedEventArgs e)
{
await (DataContext as AddControlModel)!.DownloadOptifine();
}
-
- private async void VersionFiles_DoubleTapped(object? sender, RoutedEventArgs e)
- {
- await (DataContext as AddControlModel)!.GoFile();
- }
}
diff --git a/src/ColorMC.Gui/UI/Controls/Add/AddModPackControl.axaml b/src/ColorMC.Gui/UI/Controls/Add/AddModPackControl.axaml
index ba6a32a49..f733ec882 100644
--- a/src/ColorMC.Gui/UI/Controls/Add/AddModPackControl.axaml
+++ b/src/ColorMC.Gui/UI/Controls/Add/AddModPackControl.axaml
@@ -14,9 +14,9 @@
mc:Ignorable="d">
-
+
@@ -102,7 +102,6 @@
-
-
-
-
+
+
+
@@ -191,33 +193,39 @@
ToolTip.VerticalOffset="-30" />
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ColorMC.Gui/UI/Controls/Add/AddModPackControl.axaml.cs b/src/ColorMC.Gui/UI/Controls/Add/AddModPackControl.axaml.cs
index d6ccf9237..c5df15a33 100644
--- a/src/ColorMC.Gui/UI/Controls/Add/AddModPackControl.axaml.cs
+++ b/src/ColorMC.Gui/UI/Controls/Add/AddModPackControl.axaml.cs
@@ -20,8 +20,6 @@ public AddModPackControl()
Title = App.Lang("AddModPackWindow.Title");
UseName = ToString() ?? "AddModPackControl";
- PackFiles.DoubleTapped += PackFiles_DoubleTapped;
-
ModPackFiles.PointerPressed += ModPackFiles_PointerPressed;
}
@@ -94,9 +92,4 @@ private async void ModPackFiles_PointerPressed(object? sender, PointerPressedEve
e.Handled = true;
}
}
-
- private async void PackFiles_DoubleTapped(object? sender, RoutedEventArgs e)
- {
- await (DataContext as AddModPackControlModel)!.Download();
- }
}
diff --git a/src/ColorMC.Gui/UI/Controls/Custom/ICustomControl.cs b/src/ColorMC.Gui/UI/Controls/Custom/ICustomControl.cs
index 5983c5caa..85fedf69e 100644
--- a/src/ColorMC.Gui/UI/Controls/Custom/ICustomControl.cs
+++ b/src/ColorMC.Gui/UI/Controls/Custom/ICustomControl.cs
@@ -2,5 +2,6 @@
public interface ICustomControl
{
+ public string LauncherApi { get; }
public BaseUserControl GetControl();
}
diff --git a/src/ColorMC.Gui/UI/Controls/Items/FileItemControl.axaml.cs b/src/ColorMC.Gui/UI/Controls/Items/FileItemControl.axaml.cs
index c24722ad7..e136f962e 100644
--- a/src/ColorMC.Gui/UI/Controls/Items/FileItemControl.axaml.cs
+++ b/src/ColorMC.Gui/UI/Controls/Items/FileItemControl.axaml.cs
@@ -75,8 +75,8 @@ private void FileItemControl_PointerPressed(object? sender, PointerPressedEventA
void OpenFlyout()
{
- var url = model.Data?.GetUrl();
- var url1 = model.Data?.GetMcMod();
+ var url = model.Url;
+ var url1 = model.McMod?.GetUrl();
if (url == null && url1 == null)
{
return;
diff --git a/src/ColorMC.Gui/UI/Controls/Items/FileModVersionControl.axaml b/src/ColorMC.Gui/UI/Controls/Items/FileModVersionControl.axaml
new file mode 100644
index 000000000..fd29c1772
--- /dev/null
+++ b/src/ColorMC.Gui/UI/Controls/Items/FileModVersionControl.axaml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ColorMC.Gui/UI/Controls/Items/FileModVersionControl.axaml.cs b/src/ColorMC.Gui/UI/Controls/Items/FileModVersionControl.axaml.cs
new file mode 100644
index 000000000..27e72ebf1
--- /dev/null
+++ b/src/ColorMC.Gui/UI/Controls/Items/FileModVersionControl.axaml.cs
@@ -0,0 +1,13 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace ColorMC.Gui.UI.Controls.Items;
+
+public partial class FileModVersionControl : UserControl
+{
+ public FileModVersionControl()
+ {
+ InitializeComponent();
+ }
+}
\ No newline at end of file
diff --git a/src/ColorMC.Gui/UI/Controls/Items/FileVersionItemControl.axaml b/src/ColorMC.Gui/UI/Controls/Items/FileVersionItemControl.axaml
new file mode 100644
index 000000000..6a981f892
--- /dev/null
+++ b/src/ColorMC.Gui/UI/Controls/Items/FileVersionItemControl.axaml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ColorMC.Gui/UI/Controls/Items/FileVersionItemControl.axaml.cs b/src/ColorMC.Gui/UI/Controls/Items/FileVersionItemControl.axaml.cs
new file mode 100644
index 000000000..35f80828c
--- /dev/null
+++ b/src/ColorMC.Gui/UI/Controls/Items/FileVersionItemControl.axaml.cs
@@ -0,0 +1,147 @@
+using System;
+using Avalonia.Animation;
+using Avalonia.Animation.Easings;
+using Avalonia.Controls;
+using Avalonia.Controls.Primitives;
+using Avalonia.Input;
+using Avalonia.Interactivity;
+using Avalonia.Media;
+using Avalonia.Styling;
+using Avalonia.Threading;
+using ColorMC.Gui.UI.Model.Items;
+
+namespace ColorMC.Gui.UI.Controls.Items;
+
+public partial class FileVersionItemControl : UserControl
+{
+ public FileVersionItemControl()
+ {
+ InitializeComponent();
+
+ PointerPressed += FileItemControl_PointerPressed;
+ PointerReleased += FileItemControl_PointerReleased;
+ DoubleTapped += FileItemControl_DoubleTapped;
+ PointerEntered += FileItemControl_PointerEntered;
+ PointerExited += FileItemControl_PointerExited;
+ PointerMoved += FileItemControl_PointerMoved;
+ }
+
+ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
+ {
+ base.OnApplyTemplate(e);
+ Dispatcher.UIThread.Post(FadeIn);
+ }
+
+ private void FileItemControl_PointerMoved(object? sender, PointerEventArgs e)
+ {
+ LongPressed.Cancel();
+ }
+
+ private void FileItemControl_PointerReleased(object? sender, PointerReleasedEventArgs e)
+ {
+ LongPressed.Released();
+ }
+
+ private void FileItemControl_PointerExited(object? sender, PointerEventArgs e)
+ {
+ if (DataContext is FileVersionItemModel model)
+ {
+ model.Top = false;
+ }
+ }
+
+ private void FileItemControl_PointerEntered(object? sender, PointerEventArgs e)
+ {
+ if (DataContext is FileVersionItemModel model)
+ {
+ model.Top = true;
+ }
+ }
+
+ private void FileItemControl_DoubleTapped(object? sender, RoutedEventArgs e)
+ {
+ (DataContext as FileVersionItemModel)?.Install();
+ }
+
+ private void FileItemControl_PointerPressed(object? sender, PointerPressedEventArgs e)
+ {
+ if (DataContext is not FileVersionItemModel model)
+ {
+ return;
+ }
+ model.SetSelect();
+
+ var ev = e.GetCurrentPoint(this);
+ if (ev.Properties.IsXButton1Pressed)
+ {
+ model.Back();
+ e.Handled = true;
+ }
+ else if (ev.Properties.IsXButton2Pressed)
+ {
+ model.Next();
+ e.Handled = true;
+ }
+ }
+
+ private void FadeIn()
+ {
+ var animation = new Animation
+ {
+ FillMode = FillMode.Forward,
+ Easing = new CircularEaseInOut(),
+ Children =
+ {
+ new KeyFrame
+ {
+ Setters =
+ {
+ new Setter
+ {
+ Property = OpacityProperty,
+ Value = 0.0d
+ },
+ new Setter
+ {
+ Property = TranslateTransform.YProperty,
+ Value = 10d
+ }
+ },
+ Cue = new Cue(0d)
+ },
+ new KeyFrame
+ {
+ Setters =
+ {
+ new Setter
+ {
+ Property = OpacityProperty,
+ Value = 1.0d
+ },
+ new Setter
+ {
+ Property = TranslateTransform.YProperty,
+ Value = 10d
+ }
+ },
+ Cue = new Cue(0.5d)
+ },
+ new KeyFrame
+ {
+ Setters =
+ {
+ new Setter
+ {
+ Property = TranslateTransform.YProperty,
+ Value = 0d
+ }
+ },
+ Cue = new Cue(1d)
+ }
+ },
+ Duration = TimeSpan.FromMilliseconds(500)
+ };
+
+ animation.RunAsync(this);
+ }
+}
\ No newline at end of file
diff --git a/src/ColorMC.Gui/UI/Model/Add/AddControlModel.cs b/src/ColorMC.Gui/UI/Model/Add/AddControlModel.cs
index 71875662b..dd418fbaf 100644
--- a/src/ColorMC.Gui/UI/Model/Add/AddControlModel.cs
+++ b/src/ColorMC.Gui/UI/Model/Add/AddControlModel.cs
@@ -30,7 +30,7 @@ public partial class AddControlModel : GameModel, IAddWindow
///
/// 显示的下载模组项目列表
///
- public ObservableCollection DownloadModList { get; init; } = [];
+ public ObservableCollection DownloadModList { get; init; } = [];
///
/// 显示的下载类型列表
///
@@ -42,7 +42,7 @@ public partial class AddControlModel : GameModel, IAddWindow
///
/// 显示的文件列表
///
- public ObservableCollection FileList { get; init; } = [];
+ public ObservableCollection FileList { get; init; } = [];
///
/// 显示的项目列表
///
@@ -71,7 +71,7 @@ public partial class AddControlModel : GameModel, IAddWindow
///
/// Mod下载项目显示列表
///
- public readonly List ModList = [];
+ public readonly List ModList = [];
///
/// 高清修复列表
///
@@ -129,12 +129,12 @@ public partial class AddControlModel : GameModel, IAddWindow
/// 项目
///
[ObservableProperty]
- private FileDisplayModel? _file;
+ private FileVersionItemModel? _file;
///
/// 下载的模组
///
[ObservableProperty]
- private DownloadModModel? _mod;
+ private FileModVersionModel? _mod;
///
/// 是否在下载
@@ -147,6 +147,11 @@ public partial class AddControlModel : GameModel, IAddWindow
[ObservableProperty]
private bool _emptyDisplay = true;
///
+ /// 是否没有项目
+ ///
+ [ObservableProperty]
+ private bool _emptyVersionDisplay = true;
+ ///
/// 高清修复列表显示
///
[ObservableProperty]
@@ -458,7 +463,8 @@ public async Task GetList()
foreach (var item in data)
{
- DisplayList.Add(new(item, this));
+ item.Add = this;
+ DisplayList.Add(item);
}
_last = null;
@@ -492,14 +498,16 @@ public async Task GetList()
{
item.IsDownload = true;
}
- DisplayList.Add(new(item, this));
+ item.Add = this;
+ DisplayList.Add(item);
}
}
else
{
foreach (var item in data)
{
- DisplayList.Add(new(item, this));
+ item.Add = this;
+ DisplayList.Add(item);
}
}
@@ -547,7 +555,7 @@ public async Task GoFile()
item.Name));
if (res)
{
- Install1(item);
+ Install(item);
}
}
@@ -699,6 +707,17 @@ public void Next()
Page += 1;
}
+ [RelayCommand]
+ public void NextVersion()
+ {
+ if (_load)
+ {
+ return;
+ }
+
+ PageDownload++;
+ }
+
public async void LoadSourceData()
{
if (!Display || _load)
@@ -934,7 +953,7 @@ public void Install()
/// 开始下载文件
///
///
- public async void Install1(FileDisplayModel data)
+ public async void Install(FileVersionItemModel data)
{
var type = SourceTypeList[DownloadSource];
if (Set)
@@ -952,12 +971,22 @@ public async void Install1(FileDisplayModel data)
return;
}
+ if (_now == FileType.Mod && Obj.Mods.ContainsKey(data.ID))
+ {
+ var res1 = await Model.ShowWait(App.Lang("AddWindow.Info15"));
+ if (!res1)
+ {
+ return;
+ }
+ }
+
var last = _last!;
IsDownload = true;
if (last != null)
{
last.NowDownload = true;
}
+
VersionDisplay = false;
bool res = false;
@@ -1142,13 +1171,13 @@ private async void LoadFile(string? id = null)
{
FileList.Clear();
- List? list = null;
+ List? list = null;
var type = SourceTypeList[DownloadSource];
if (type == SourceType.McMod)
{
if (_lastType == SourceType.McMod)
{
- var obj1 = (_last!.Data.Data as McModSearchItemObj)!;
+ var obj1 = (_last!.Data as McModSearchItemObj)!;
if (obj1.curseforge_id != null && obj1.modrinth_id != null)
{
var res = await Model.ShowCombo(App.Lang("AddWindow.Info14"), SourceTypeNameList);
@@ -1188,15 +1217,15 @@ private async void LoadFile(string? id = null)
if (type == SourceType.CurseForge)
{
EnablePage = true;
- list = await WebBinding.GetPackFileList(type, id ??
- (_last!.Data.Data as CurseForgeObjList.Data)!.id.ToString(), PageDownload,
+ list = await WebBinding.GetFileList(type, id ??
+ (_last!.Data as CurseForgeObjList.Data)!.id.ToString(), PageDownload,
GameVersionDownload, Obj.Loader, _now);
}
else if (type == SourceType.Modrinth)
{
EnablePage = false;
- list = await WebBinding.GetPackFileList(type, id ??
- (_last!.Data.Data as ModrinthSearchObj.Hit)!.project_id, PageDownload,
+ list = await WebBinding.GetFileList(type, id ??
+ (_last!.Data as ModrinthSearchObj.Hit)!.project_id, PageDownload,
GameVersionDownload, _now == FileType.Mod ? Obj.Loader : Loaders.Normal, _now);
}
@@ -1211,6 +1240,7 @@ private async void LoadFile(string? id = null)
{
foreach (var item in list)
{
+ item.Add = this;
if (Obj.Mods.TryGetValue(item.ID, out var value)
&& value.FileId == item.ID1)
{
@@ -1223,10 +1253,13 @@ private async void LoadFile(string? id = null)
{
foreach (var item in list)
{
+ item.Add = this;
FileList.Add(item);
}
}
+ EmptyVersionDisplay = FileList.Count == 0;
+
Model.ProgressClose();
}
@@ -1273,6 +1306,19 @@ public void Back()
Page -= 1;
}
+ ///
+ /// 上一页
+ ///
+ public void BackVersion()
+ {
+ if (_load || PageDownload <= 0)
+ {
+ return;
+ }
+
+ Page -= 1;
+ }
+
///
/// 重载
///
@@ -1314,6 +1360,16 @@ public void Install(FileItemModel item)
Install();
}
+ public void SetSelect(FileVersionItemModel item)
+ {
+ if (File != null)
+ {
+ File.IsSelect = false;
+ }
+ File = item;
+ item.IsSelect = true;
+ }
+
///
/// 加载高清修复列表
///
diff --git a/src/ColorMC.Gui/UI/Model/Add/AddModPackControlModel.cs b/src/ColorMC.Gui/UI/Model/Add/AddModPackControlModel.cs
index db1607c56..8a6399d02 100644
--- a/src/ColorMC.Gui/UI/Model/Add/AddModPackControlModel.cs
+++ b/src/ColorMC.Gui/UI/Model/Add/AddModPackControlModel.cs
@@ -18,7 +18,7 @@ namespace ColorMC.Gui.UI.Model.Add;
public partial class AddModPackControlModel : TopModel, IAddWindow
{
public string[] SourceList { get; init; } = LanguageBinding.GetSourceList();
- public ObservableCollection FileList { get; init; } = [];
+ public ObservableCollection FileList { get; init; } = [];
public ObservableCollection GameVersionList { get; init; } = [];
public ObservableCollection CategorieList { get; init; } = [];
public ObservableCollection SortTypeList { get; init; } = [];
@@ -29,7 +29,7 @@ public partial class AddModPackControlModel : TopModel, IAddWindow
private bool _load = false;
[ObservableProperty]
- private FileDisplayModel _item;
+ private FileVersionItemModel _item;
[ObservableProperty]
private int _source = -1;
@@ -57,9 +57,10 @@ public partial class AddModPackControlModel : TopModel, IAddWindow
private bool _display = false;
[ObservableProperty]
private bool _emptyDisplay = true;
-
[ObservableProperty]
private bool _sourceLoad;
+ [ObservableProperty]
+ private bool _emptyVersionDisplay;
private readonly string _useName;
@@ -173,7 +174,7 @@ public async Task Download()
string.Format(App.Lang("AddModPackWindow.Info1"), Item.Name));
if (res)
{
- Install1(Item);
+ Install(Item);
}
}
@@ -266,7 +267,7 @@ public void Install()
Load1();
}
- public void Install1(FileDisplayModel data)
+ public void Install(FileVersionItemModel data)
{
var select = _last;
WindowClose();
@@ -275,13 +276,13 @@ public void Install1(FileDisplayModel data)
{
WindowManager.AddGameWindow?.Install(
(data.Data as CurseForgeModObj.Data)!,
- (select!.Data?.Data as CurseForgeObjList.Data)!);
+ (select!.Data as CurseForgeObjList.Data)!);
}
else if (data.SourceType == SourceType.Modrinth)
{
WindowManager.AddGameWindow?.Install(
(data.Data as ModrinthVersionObj)!,
- (select!.Data?.Data as ModrinthSearchObj.Hit)!);
+ (select!.Data as ModrinthSearchObj.Hit)!);
}
}
@@ -328,7 +329,8 @@ private async void Load()
DisplayList.Clear();
foreach (var item in data)
{
- DisplayList.Add(new(item, this));
+ item.Add = this;
+ DisplayList.Add(item);
}
OnPropertyChanged(nameof(DisplayList));
@@ -346,19 +348,19 @@ private async void Load1()
FileList.Clear();
Model.Progress(App.Lang("AddModPackWindow.Info3"));
- List? list = null;
+ List? list = null;
if (Source == 0)
{
PageEnable1 = true;
- list = await WebBinding.GetPackFileList((SourceType)Source,
- (_last!.Data?.Data as CurseForgeObjList.Data)!.id.ToString(), Page1 ?? 0,
+ list = await WebBinding.GetFileList((SourceType)Source,
+ (_last!.Data as CurseForgeObjList.Data)!.id.ToString(), Page1 ?? 0,
GameVersion1, Loaders.Normal);
}
else if (Source == 1)
{
PageEnable1 = false;
- list = await WebBinding.GetPackFileList((SourceType)Source,
- (_last!.Data?.Data as ModrinthSearchObj.Hit)!.project_id, Page1 ?? 0,
+ list = await WebBinding.GetFileList((SourceType)Source,
+ (_last!.Data as ModrinthSearchObj.Hit)!.project_id, Page1 ?? 0,
GameVersion1, Loaders.Normal);
}
if (list == null)
@@ -367,7 +369,14 @@ private async void Load1()
Model.ProgressClose();
return;
}
- FileList.AddRange(list);
+
+ foreach (var item in list)
+ {
+ item.Add = this;
+ FileList.Add(item);
+ }
+
+ EmptyVersionDisplay = FileList.Count == 0;
Model.ProgressClose();
}
@@ -436,4 +445,34 @@ public override void Close()
DisplayList.Clear();
_last = null;
}
+
+ public void SetSelect(FileVersionItemModel item)
+ {
+ if (Item != null)
+ {
+ Item.IsSelect = false;
+ }
+ Item = item;
+ item.IsSelect = true;
+ }
+
+ public void BackVersion()
+ {
+ if (_load || Page1 <= 0)
+ {
+ return;
+ }
+
+ Page1 -= 1;
+ }
+
+ public void NextVersion()
+ {
+ if (_load)
+ {
+ return;
+ }
+
+ Page1 += 1;
+ }
}
diff --git a/src/ColorMC.Gui/UI/Model/Items/DownloadModModel.cs b/src/ColorMC.Gui/UI/Model/Items/DownloadModModel.cs
index 533e53fca..6d7d320b1 100644
--- a/src/ColorMC.Gui/UI/Model/Items/DownloadModModel.cs
+++ b/src/ColorMC.Gui/UI/Model/Items/DownloadModModel.cs
@@ -7,7 +7,7 @@ namespace ColorMC.Gui.UI.Model.Items;
///
/// Mod下载项目显示
///
-public partial class DownloadModModel : ObservableObject
+public partial class FileModVersionModel : SelectItemModel
{
[ObservableProperty]
private bool _download;
diff --git a/src/ColorMC.Gui/UI/Model/Items/FileDisplayModel.cs b/src/ColorMC.Gui/UI/Model/Items/FileDisplayModel.cs
deleted file mode 100644
index 59bab30f9..000000000
--- a/src/ColorMC.Gui/UI/Model/Items/FileDisplayModel.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using ColorMC.Core.Objs;
-
-namespace ColorMC.Gui.UI.Model.Items;
-
-///
-/// 项目显示
-///
-public record FileDisplayModel
-{
- ///
- /// 名字
- ///
- public string Name { get; set; }
- ///
- /// 下载次数
- ///
- public long Download { get; set; }
- ///
- /// 大小
- ///
- public string Size { get; set; }
- ///
- /// 更新时间
- ///
- public string Time { get; set; }
- ///
- /// 是否已经下载
- ///
- public bool IsDownload { get; set; }
-
- ///
- /// 文件类型
- ///
- public FileType FileType;
- ///
- /// 下载源
- ///
- public SourceType SourceType;
-
- ///
- /// Mod用
- ///
- public string ID;
- ///
- /// Mod用
- ///
- public string ID1;
-
- ///
- /// 数据
- ///
- public object Data;
-}
-
diff --git a/src/ColorMC.Gui/UI/Model/Items/FileItemDisplayModel.cs b/src/ColorMC.Gui/UI/Model/Items/FileItemDisplayModel.cs
deleted file mode 100644
index 9a7b8d683..000000000
--- a/src/ColorMC.Gui/UI/Model/Items/FileItemDisplayModel.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using ColorMC.Core.Objs;
-
-namespace ColorMC.Gui.UI.Model.Items;
-
-///
-/// 文件显示
-///
-public record FileItemDisplayModel
-{
- ///
- /// 名字
- ///
- public string Name { get; set; }
- ///
- /// 介绍
- ///
- public string Summary { get; set; }
- ///
- /// 作者
- ///
- public string Author { get; set; }
- ///
- /// 下载次数
- ///
- public long DownloadCount { get; set; }
- ///
- /// 更新日期
- ///
- public string ModifiedDate { get; set; }
- ///
- /// 图标网址
- ///
- public string? Logo { get; set; }
- ///
- /// 是否已经下载
- ///
- public bool IsDownload { get; set; }
-
- ///
- /// 文件类型
- ///
- public FileType FileType;
- ///
- /// 下载源
- ///
- public SourceType SourceType;
-
- ///
- /// Mod用
- ///
- public string ID;
- ///
- /// 数据
- ///
- public object Data;
- ///
- /// 数据
- ///
- public object? Data1;
-}
-
diff --git a/src/ColorMC.Gui/UI/Model/Items/FileItemModel.cs b/src/ColorMC.Gui/UI/Model/Items/FileItemModel.cs
index 0cefa4c78..e989850c2 100644
--- a/src/ColorMC.Gui/UI/Model/Items/FileItemModel.cs
+++ b/src/ColorMC.Gui/UI/Model/Items/FileItemModel.cs
@@ -1,8 +1,11 @@
using System;
using System.Threading.Tasks;
using Avalonia.Media.Imaging;
+using ColorMC.Core.Helpers;
using ColorMC.Core.Objs;
+using ColorMC.Core.Objs.CurseForge;
using ColorMC.Core.Objs.McMod;
+using ColorMC.Core.Objs.Modrinth;
using ColorMC.Core.Utils;
using ColorMC.Gui.Manager;
using ColorMC.Gui.UI.Windows;
@@ -16,49 +19,95 @@ namespace ColorMC.Gui.UI.Model.Items;
public partial class FileItemModel : SelectItemModel
{
- private readonly IAddWindow _add;
+ public IAddWindow Add { get; set; }
public Task Image => GetImage();
private Bitmap? _img;
- public FileItemDisplayModel Data { get; init; }
- public string? Name => Data.Name;
- public string? Summary => Data.Summary;
- public string? Author => Data.Author;
- public long? DownloadCount => Data.DownloadCount;
- public DateTime? ModifiedDate => DateTime.Parse(Data.ModifiedDate);
+ public string? Name { get; init; }
+ public string? Summary { get; init; }
+ public string? Author { get; init; }
+ public long? DownloadCount { get; init; }
+ public DateTime? ModifiedDate { get; init; }
+ public bool IsModPack { get; init; }
+ public bool HaveDownload { get; init; }
[ObservableProperty]
- private bool isDownload = false;
+ private bool _isDownload = false;
[ObservableProperty]
private bool _nowDownload = false;
[ObservableProperty]
private bool _top;
[ObservableProperty]
private bool _enableButton;
- [ObservableProperty]
- private bool _haveDownload;
- public FileItemModel(FileItemDisplayModel data, IAddWindow add)
+ public FileType FileType;
+ public SourceType SourceType;
+ public string Url;
+ public McModSearchItemObj? McMod;
+ public string? Logo;
+ public string ID;
+
+ ///
+ ///
+ ///
+ public object Data;
+
+ public FileItemModel(CurseForgeObjList.Data data, FileType type)
{
Data = data;
- _add = add;
- if (data == null)
- {
- return;
- }
- isDownload = data.IsDownload;
- if (data.SourceType == SourceType.McMod)
- {
- var obj1 = (data.Data as McModSearchItemObj)!;
- _haveDownload = obj1.curseforge_id != null || obj1.modrinth_id != null;
- }
- else
- {
- _haveDownload = true;
- }
+ ID = data.id.ToString();
+ Name = data.name;
+ Summary = data.summary;
+ Author = data.authors.GetString();
+ DownloadCount = data.downloadCount;
+ ModifiedDate = DateTime.Parse(data.dateModified);
+ Logo = data.logo?.url;
+ FileType = type;
+ SourceType = SourceType.CurseForge;
+ Url = data.GetUrl();
+
+ HaveDownload = true;
+ IsModPack = type == FileType.ModPack;
+ }
+
+ public FileItemModel(ModrinthSearchObj.Hit data, FileType type)
+ {
+ Data = data;
+
+ ID = data.project_id;
+ Name = data.title;
+ Summary = data.description;
+ Author = data.author;
+ DownloadCount = data.downloads;
+ ModifiedDate = DateTime.Parse(data.date_modified);
+ Logo = data.icon_url;
+ FileType = type;
+ SourceType = SourceType.Modrinth;
+ Url = data.GetUrl(type);
+
+ HaveDownload = true;
+ IsModPack = type == FileType.ModPack;
+ }
+
+ public FileItemModel(McModSearchItemObj data, FileType type)
+ {
+ Data = data;
+ McMod = data;
+
+ Logo = data.mcmod_icon.StartsWith("//")
+ ? "https:" + data.mcmod_icon : data.mcmod_icon;
+ Name = data.mcmod_name;
+ Summary = data.mcmod_text;
+ Author = data.mcmod_author;
+ FileType = FileType.Mod;
+ SourceType = SourceType.McMod;
+ ModifiedDate = data.mcmod_update_time;
+
+ HaveDownload = data.curseforge_id != null || data.modrinth_id != null;
+ IsModPack = type == FileType.ModPack;
}
protected override void IsSelectChanged(bool value)
@@ -74,10 +123,9 @@ partial void OnTopChanged(bool value)
[RelayCommand]
public void OpenWeb()
{
- var url = Data.SourceType == SourceType.McMod ? Data.GetMcMod() : Data.GetUrl();
- if (url != null)
+ if (Url != null)
{
- BaseBinding.OpUrl(url);
+ BaseBinding.OpUrl(Url);
}
}
@@ -87,7 +135,7 @@ public void OpenWeb()
{
return _img;
}
- if (Data?.Logo == null)
+ if (Logo == null)
{
return null;
}
@@ -95,7 +143,7 @@ public void OpenWeb()
{
await Task.Run(() =>
{
- _img = ImageUtils.Load(Data.Logo, true).Result;
+ _img = ImageUtils.Load(Logo, true).Result;
});
return _img;
}
@@ -113,22 +161,22 @@ public void Install()
{
return;
}
- _add.Install(this);
+ Add?.Install(this);
}
public void SetSelect()
{
- _add.SetSelect(this);
+ Add?.SetSelect(this);
}
public void Back()
{
- _add.Back();
+ Add?.Back();
}
public void Next()
{
- _add.Next();
+ Add?.Next();
}
public async void Close()
diff --git a/src/ColorMC.Gui/UI/Model/Items/FileVersionItemModel.cs b/src/ColorMC.Gui/UI/Model/Items/FileVersionItemModel.cs
new file mode 100644
index 000000000..a472d78d4
--- /dev/null
+++ b/src/ColorMC.Gui/UI/Model/Items/FileVersionItemModel.cs
@@ -0,0 +1,111 @@
+using System;
+using System.Linq;
+using ColorMC.Core.Objs;
+using ColorMC.Core.Objs.CurseForge;
+using ColorMC.Core.Objs.Modrinth;
+using ColorMC.Gui.UI.Windows;
+using ColorMC.Gui.Utils;
+
+namespace ColorMC.Gui.UI.Model.Items;
+
+///
+/// 项目显示
+///
+public partial class FileVersionItemModel : SelectItemModel
+{
+ public IAddWindow? Add { get; set; }
+
+ ///
+ /// 名字
+ ///
+ public string Name { get; set; }
+ ///
+ /// 下载次数
+ ///
+ public long Download { get; set; }
+ ///
+ /// 大小
+ ///
+ public string Size { get; set; }
+ ///
+ /// 更新时间
+ ///
+ public DateTime Time { get; set; }
+ ///
+ /// 是否已经下载
+ ///
+ public bool IsDownload { get; set; }
+
+ ///
+ /// 文件类型
+ ///
+ public FileType FileType;
+ ///
+ /// 下载源
+ ///
+ public SourceType SourceType;
+
+ ///
+ /// Mod用
+ ///
+ public string ID;
+ ///
+ /// Mod用
+ ///
+ public string ID1;
+
+ ///
+ /// 数据
+ ///
+ public object Data;
+
+ public FileVersionItemModel(CurseForgeModObj.Data data, FileType type)
+ {
+ Data = data;
+
+ ID = data.modId.ToString();
+ ID1 = data.id.ToString();
+ Name = data.displayName;
+ Size = UIUtils.MakeFileSize1(data.fileLength);
+ Download = data.downloadCount;
+ Time = DateTime.Parse(data.fileDate);
+ FileType = type;
+ SourceType = SourceType.CurseForge;
+ }
+
+ public FileVersionItemModel(ModrinthVersionObj data, FileType type1)
+ {
+ Data = data;
+
+ ID = data.project_id;
+ ID1 = data.id;
+ Name = data.name;
+ var file = data.files.FirstOrDefault(a => a.primary) ?? data.files[0];
+ Size = UIUtils.MakeFileSize1(file.size);
+ Download = data.downloads;
+ Time = DateTime.Parse(data.date_published);
+ FileType = type1;
+ SourceType = SourceType.Modrinth;
+ }
+
+ public void SetSelect()
+ {
+ Add?.SetSelect(this);
+ }
+
+ public void Back()
+ {
+ Add?.BackVersion();
+ }
+
+ public void Next()
+ {
+ Add?.NextVersion();
+ }
+
+ internal void Install()
+ {
+ Add?.Install(this);
+ }
+}
+
diff --git a/src/ColorMC.Gui/UI/Model/SelectItemModel.cs b/src/ColorMC.Gui/UI/Model/SelectItemModel.cs
index 08ae6c10d..b19d9b27b 100644
--- a/src/ColorMC.Gui/UI/Model/SelectItemModel.cs
+++ b/src/ColorMC.Gui/UI/Model/SelectItemModel.cs
@@ -11,6 +11,10 @@ public partial class SelectItemModel : ObservableObject
[ObservableProperty]
private bool _isSelect;
+ [ObservableProperty]
+ private bool _top;
+ [ObservableProperty]
+ private bool _enableButton;
partial void OnIsSelectChanged(bool value)
{
@@ -26,5 +30,13 @@ partial void OnIsSelectChanged(bool value)
IsSelectChanged(value);
}
- protected virtual void IsSelectChanged(bool value) { }
+ protected virtual void IsSelectChanged(bool value)
+ {
+ EnableButton = Top || IsSelect;
+ }
+
+ partial void OnTopChanged(bool value)
+ {
+ EnableButton = Top || IsSelect;
+ }
}
diff --git a/src/ColorMC.Gui/UI/Windows/IAddWindow.cs b/src/ColorMC.Gui/UI/Windows/IAddWindow.cs
index bfc5c6ab1..d031fe63a 100644
--- a/src/ColorMC.Gui/UI/Windows/IAddWindow.cs
+++ b/src/ColorMC.Gui/UI/Windows/IAddWindow.cs
@@ -6,6 +6,10 @@ public interface IAddWindow
{
public void SetSelect(FileItemModel item);
public void Install(FileItemModel item);
+ public void SetSelect(FileVersionItemModel item);
+ public void Install(FileVersionItemModel item);
void Back();
void Next();
+ void BackVersion();
+ void NextVersion();
}
diff --git a/src/ColorMC.Gui/UIBinding/BaseBinding.cs b/src/ColorMC.Gui/UIBinding/BaseBinding.cs
index aa291f96b..f601b7c56 100644
--- a/src/ColorMC.Gui/UIBinding/BaseBinding.cs
+++ b/src/ColorMC.Gui/UIBinding/BaseBinding.cs
@@ -394,8 +394,7 @@ public static bool TestCustomWindow()
{
try
{
- WindowManager.ShowCustom(true);
- return true;
+ return WindowManager.ShowCustom(true);
}
catch (Exception ex)
{
diff --git a/src/ColorMC.Gui/UIBinding/GameBinding.cs b/src/ColorMC.Gui/UIBinding/GameBinding.cs
index 3d3b14a8e..9ce35201b 100644
--- a/src/ColorMC.Gui/UIBinding/GameBinding.cs
+++ b/src/ColorMC.Gui/UIBinding/GameBinding.cs
@@ -2458,7 +2458,7 @@ await Task.Run(() =>
}
}
});
- WindowManager.ShowError(App.Lang("GameBinding.Info13"), info.ToString(), false);
+ WindowManager.ShowError(App.Lang("GameBinding.Info13"), info.ToString());
}
///
diff --git a/src/ColorMC.Gui/UIBinding/WebBinding.cs b/src/ColorMC.Gui/UIBinding/WebBinding.cs
index 2b4375f0d..8e1539071 100644
--- a/src/ColorMC.Gui/UIBinding/WebBinding.cs
+++ b/src/ColorMC.Gui/UIBinding/WebBinding.cs
@@ -37,7 +37,7 @@ public static class WebBinding
private const string Arm64 = "Arm64";
///
- /// ȡϰб
+ /// 获取整合包列表
///
///
///
@@ -46,7 +46,7 @@ public static class WebBinding
///
///
///
- public static async Task?> GetModPackList(SourceType type, string? version,
+ public static async Task?> GetModPackList(SourceType type, string? version,
string? filter, int page, int sort, string categoryId)
{
version ??= "";
@@ -72,22 +72,13 @@ public static class WebBinding
_ => 1
}, categoryId: categoryId);
if (list == null)
+ {
return null;
- var list1 = new List();
+ }
+ var list1 = new List();
list.data.ForEach(item =>
{
- list1.Add(new()
- {
- Name = item.name,
- Summary = item.summary,
- Author = item.authors.GetString(),
- DownloadCount = item.downloadCount,
- ModifiedDate = item.dateModified,
- Logo = item.logo?.url,
- FileType = FileType.ModPack,
- SourceType = SourceType.CurseForge,
- Data = item
- });
+ list1.Add(new(item, FileType.ModPack));
});
return list1;
@@ -96,22 +87,13 @@ public static class WebBinding
{
var list = await ModrinthAPI.GetModPackList(version, page, filter: filter, sortOrder: sort, categoryId: categoryId);
if (list == null)
+ {
return null;
- var list1 = new List();
+ }
+ var list1 = new List();
list.hits.ForEach(item =>
{
- list1.Add(new()
- {
- Name = item.title,
- Summary = item.description,
- Author = item.author,
- DownloadCount = item.downloads,
- ModifiedDate = item.date_modified,
- Logo = item.icon_url,
- FileType = FileType.ModPack,
- SourceType = SourceType.Modrinth,
- Data = item
- });
+ list1.Add(new(item, FileType.ModPack));
});
return list1;
@@ -121,7 +103,7 @@ public static class WebBinding
}
///
- /// ȡϰļб
+ /// 获取文件列表
///
///
///
@@ -130,7 +112,7 @@ public static class WebBinding
///
///
///
- public static async Task?> GetPackFileList(SourceType type, string id,
+ public static async Task?> GetFileList(SourceType type, string id,
int page, string? mc, Loaders loader, FileType type1 = FileType.ModPack)
{
if (type == SourceType.CurseForge)
@@ -139,21 +121,10 @@ public static class WebBinding
if (list == null)
return null;
- var list1 = new List();
+ var list1 = new List();
list.data.ForEach(item =>
{
- list1.Add(new()
- {
- ID = item.modId.ToString(),
- ID1 = item.id.ToString(),
- Name = item.displayName,
- Size = UIUtils.MakeFileSize1(item.fileLength),
- Download = item.downloadCount,
- Time = DateTime.Parse(item.fileDate).ToString(),
- FileType = type1,
- SourceType = SourceType.CurseForge,
- Data = item
- });
+ list1.Add(new(item, type1));
});
return list1;
@@ -164,22 +135,10 @@ public static class WebBinding
if (list == null)
return null;
- var list1 = new List();
+ var list1 = new List();
list.ForEach(item =>
{
- var file = item.files.FirstOrDefault(a => a.primary) ?? item.files[0];
- list1.Add(new()
- {
- ID = item.project_id,
- ID1 = item.id,
- Name = item.name,
- Size = UIUtils.MakeFileSize1(file.size),
- Download = item.downloads,
- Time = DateTime.Parse(item.date_published).ToString(),
- FileType = type1,
- SourceType = SourceType.Modrinth,
- Data = item
- });
+ list1.Add(new(item, type1));
});
return list1;
@@ -189,7 +148,7 @@ public static class WebBinding
}
///
- /// ȡԴб
+ /// 获取下载源列表
///
///
///
@@ -219,7 +178,7 @@ or FileType.Resourcepack
}
///
- /// ȡļб
+ /// 获取文件列表
///
///
///
@@ -230,7 +189,7 @@ or FileType.Resourcepack
///
///
///
- public static async Task?> GetList(FileType now, SourceType type, string? version, string? filter, int page, int sort, string categoryId, Loaders loader)
+ public static async Task?> GetList(FileType now, SourceType type, string? version, string? filter, int page, int sort, string categoryId, Loaders loader)
{
version ??= "";
filter ??= "";
@@ -332,7 +291,7 @@ or FileType.Resourcepack
};
if (list == null)
return null;
- var list1 = new List();
+ var list1 = new List();
var modlist = new List();
list.data.ForEach(item =>
{
@@ -342,19 +301,9 @@ or FileType.Resourcepack
list.data.ForEach(item =>
{
var id = item.id.ToString();
- list1.Add(new()
+ list1.Add(new(item, now)
{
- ID = id,
- Name = item.name,
- Summary = item.summary,
- Author = item.authors.GetString(),
- DownloadCount = item.downloadCount,
- ModifiedDate = item.dateModified,
- Logo = item.logo?.url,
- FileType = now,
- SourceType = SourceType.CurseForge,
- Data = item,
- Data1 = list2?.TryGetValue(id, out var data1) == true ? data1 : null
+ McMod = list2?.TryGetValue(id, out var data1) == true ? data1 : null
});
});
@@ -372,8 +321,7 @@ or FileType.Resourcepack
};
if (list == null)
return null;
- var list1 = new List();
-
+ var list1 = new List();
var modlist = new List();
list.hits.ForEach(item =>
{
@@ -382,19 +330,9 @@ or FileType.Resourcepack
var list2 = await ColorMCAPI.GetMcModFromMO(modlist);
list.hits.ForEach(item =>
{
- list1.Add(new()
+ list1.Add(new(item, now)
{
- ID = item.project_id,
- Name = item.title,
- Summary = item.description,
- Author = item.author,
- DownloadCount = item.downloads,
- ModifiedDate = item.date_modified,
- Logo = item.icon_url,
- FileType = FileType.ModPack,
- SourceType = SourceType.Modrinth,
- Data = item,
- Data1 = list2?.TryGetValue(item.project_id, out var data1) == true
+ McMod = list2?.TryGetValue(item.project_id, out var data1) == true
? data1 : null
});
});
@@ -406,7 +344,7 @@ or FileType.Resourcepack
}
///
- /// ȡģб
+ /// 获取模组下载列表
///
///
///
@@ -420,7 +358,7 @@ public static async Task GetDownloadModList(GameSettingObj obj,
string path = obj.GetModsPath();
- var res = new Dictionary();
+ var res = new Dictionary();
if (data.dependencies != null && data.dependencies.Count > 0)
{
var res1 = await CurseForgeHelper.GetModDependencies(data, obj.Version, obj.Loader, true);
@@ -465,7 +403,7 @@ public static async Task GetDownloadModList(GameSettingObj obj,
}
///
- /// ȡģб
+ /// 获取模组下载列表
///
///
///
@@ -477,7 +415,7 @@ public static async Task GetDownloadModList(GameSettingObj obj,
return new();
}
- var res = new Dictionary();
+ var res = new Dictionary();
if (data.dependencies != null && data.dependencies.Count > 0)
{
var list2 = await ModrinthHelper.GetModDependencies(data, obj.Version, obj.Loader);
@@ -519,7 +457,7 @@ public static async Task GetDownloadModList(GameSettingObj obj,
}
///
- /// ģ
+ /// 下载模组
///
///
///
@@ -544,7 +482,7 @@ public static async Task DownloadMod(GameSettingObj obj, ICollection
- /// ģ
+ /// 下载模组
///
///
///
@@ -564,7 +502,7 @@ public static async Task DownloadMod(GameSettingObj obj, ICollection
- /// Դ
+ /// 下载资源
///
///
///
@@ -624,7 +562,7 @@ public static async Task Download(FileType type, GameSettingObj obj, Curse
}
///
- /// Դ
+ /// 下载资源
///
///
///
@@ -662,7 +600,7 @@ public static async Task Download(FileType type, GameSettingObj obj, Modri
}
///
- /// صͼԴ
+ /// 下载地图资源
///
///
///
@@ -688,7 +626,7 @@ public static async Task Download(WorldObj obj1, CurseForgeModObj.Data? da
}
///
- /// صͼԴ
+ /// 下载地图资源
///
///
///
@@ -713,56 +651,39 @@ public static async Task Download(WorldObj obj1, ModrinthVersionObj? data)
}
///
- /// ȡԭվַ
+ /// 获取原站地址
///
///
///
- public static string? GetUrl(this FileItemDisplayModel obj)
+ public static string GetUrl(this CurseForgeObjList.Data obj)
{
- if (obj.SourceType == SourceType.CurseForge)
- {
- return (obj.Data as CurseForgeObjList.Data)!.links.websiteUrl;
- }
- else if (obj.SourceType == SourceType.Modrinth)
- {
- var obj1 = (obj.Data as ModrinthSearchObj.Hit)!;
- return obj.FileType switch
- {
- FileType.ModPack => "https://modrinth.com/modpack/",
- FileType.Shaderpack => "https://modrinth.com/shaders/",
- FileType.Resourcepack => "https://modrinth.com/resourcepacks/",
- FileType.DataPacks => "https://modrinth.com/datapacks/",
- _ => "https://modrinth.com/mod/"
- } + obj1.project_id;
- }
+ return obj.links.websiteUrl;
+ }
- return null;
+ public static string GetUrl(this ModrinthSearchObj.Hit obj, FileType fileType)
+ {
+ return fileType switch
+ {
+ FileType.ModPack => "https://modrinth.com/modpack/",
+ FileType.Shaderpack => "https://modrinth.com/shaders/",
+ FileType.Resourcepack => "https://modrinth.com/resourcepacks/",
+ FileType.DataPacks => "https://modrinth.com/datapacks/",
+ _ => "https://modrinth.com/mod/"
+ } + obj.project_id;
}
///
- /// ȡMcModַ
+ /// 获取McMod地址
///
///
///
- public static string? GetMcMod(this FileItemDisplayModel obj)
+ public static string? GetUrl(this McModSearchItemObj obj)
{
- if ((obj.SourceType == SourceType.CurseForge
- || obj.SourceType == SourceType.Modrinth)
- && obj.Data1 is McModSearchItemObj obj1)
- {
- return $"https://www.mcmod.cn/class/{obj1.mcmod_id}.html";
- }
- else if (obj.SourceType == SourceType.McMod)
- {
- var obj2 = (obj.Data as McModSearchItemObj)!;
- return $"https://www.mcmod.cn/class/{obj2.mcmod_id}.html";
- }
-
- return null;
+ return $"https://www.mcmod.cn/class/{obj.mcmod_id}.html";
}
///
- /// ȡб
+ /// 获取高清修复列表
///
///
public static async Task?> GetOptifine()
@@ -771,7 +692,7 @@ public static async Task Download(WorldObj obj1, ModrinthVersionObj? data)
}
///
- /// ظ
+ /// 下载高清修复
///
///
///
@@ -782,7 +703,7 @@ public static Task DownloadOptifine(GameSettingObj obj, OptifineObj
}
///
- /// ģ
+ /// 检查模组更新
///
///
///
@@ -802,7 +723,7 @@ await Parallel.ForEachAsync(mods, async (item, cancel) =>
var type1 = DownloadItemHelper.TestSourceType(item.PID, item.FID);
- var list1 = await GetPackFileList(type1, item.PID, 0,
+ var list1 = await GetFileList(type1, item.PID, 0,
game.Version, game.Loader, FileType.Mod);
if (list1 == null || list1.Count == 0)
{
@@ -846,7 +767,7 @@ await Parallel.ForEachAsync(mods, async (item, cancel) =>
}
///
- /// McModҳ
+ /// 打开McMod网页
///
///
public static void OpenMcmod(ModDisplayModel obj)
@@ -855,7 +776,7 @@ public static void OpenMcmod(ModDisplayModel obj)
}
///
- /// ģ
+ /// 搜索模组
///
///
///
@@ -864,34 +785,23 @@ public static void OpenMcmod(ModDisplayModel obj)
///
///
///
- public static async Task?> SearchMcmod(string name, int page, Loaders loader, string version, string modtype, int sort)
+ public static async Task?> SearchMcmod(string name, int page, Loaders loader, string version, string modtype, int sort)
{
var list = await ColorMCAPI.GetMcMod(name, page, loader, version, modtype, sort);
if (list == null)
return null;
- var list1 = new List();
+ var list1 = new List();
foreach (var item in list.Values)
{
- list1.Add(new()
- {
- Logo = item.mcmod_icon.StartsWith("//")
- ? "https:" + item.mcmod_icon : item.mcmod_icon,
- Name = item.mcmod_name,
- Summary = item.mcmod_text,
- Author = item.mcmod_author,
- FileType = FileType.Mod,
- SourceType = SourceType.McMod,
- Data = item,
- ModifiedDate = item.mcmod_update_time.ToString()
- });
+ list1.Add(new(item, FileType.Mod));
}
return list1;
}
///
- /// ҳ
+ /// 打开网页
///
///
public static void OpenWeb(WebType type)
@@ -922,7 +832,7 @@ public static void OpenWeb(WebType type)
}
///
- /// ȡForgeֵ֧Ϸ汾
+ /// 获取Forge支持的游戏版本
///
///
public static Task?> GetForgeSupportVersion()
@@ -930,7 +840,7 @@ public static void OpenWeb(WebType type)
return ForgeAPI.GetSupportVersion(false, WebClient.Source);
}
///
- /// ȡFabricֵ֧Ϸ汾
+ /// 获取Fabric支持的游戏版本
///
///
public static Task?> GetFabricSupportVersion()
@@ -938,7 +848,7 @@ public static void OpenWeb(WebType type)
return FabricAPI.GetSupportVersion(WebClient.Source);
}
///
- /// ȡQuiltֵ֧Ϸ汾
+ /// 获取Quilt支持的游戏版本
///
///
public static Task?> GetQuiltSupportVersion()
@@ -946,7 +856,7 @@ public static void OpenWeb(WebType type)
return QuiltAPI.GetSupportVersion(WebClient.Source);
}
///
- /// ȡNeoForgeֵ֧Ϸ汾
+ /// 获取NeoForge支持的游戏版本
///
///
public static Task?> GetNeoForgeSupportVersion()
@@ -954,7 +864,7 @@ public static void OpenWeb(WebType type)
return ForgeAPI.GetSupportVersion(true, WebClient.Source);
}
///
- /// ȡOptifineֵ֧Ϸ汾
+ /// 获取Optifine支持的游戏版本
///
///
public static async Task?> GetOptifineSupportVersion()
@@ -963,45 +873,45 @@ public static void OpenWeb(WebType type)
}
///
- /// ȡForge汾
+ /// 获取Forge版本
///
- /// Ϸ汾
+ /// 游戏版本
///
public static Task?> GetForgeVersion(string version)
{
return ForgeAPI.GetVersionList(false, version, WebClient.Source);
}
///
- /// ȡFabric汾
+ /// 获取Fabric版本
///
- /// Ϸ汾
+ /// 游戏版本
///
public static Task?> GetFabricVersion(string version)
{
return FabricAPI.GetLoaders(version, WebClient.Source);
}
///
- /// ȡQuilt汾
+ /// 获取Quilt版本
///
- /// Ϸ汾
+ /// 游戏版本
///
public static Task?> GetQuiltVersion(string version)
{
return QuiltAPI.GetLoaders(version, WebClient.Source);
}
///
- /// ȡNeoForge汾
+ /// 获取NeoForge版本
///
- /// Ϸ汾
+ /// 游戏版本
///
public static Task?> GetNeoForgeVersion(string version)
{
return ForgeAPI.GetVersionList(true, version, WebClient.Source);
}
///
- /// ȡOptifine汾
+ /// 获取Optifine版本
///
- /// Ϸ汾
+ /// 游戏版本
///
public static async Task?> GetOptifineVersion(string version)
{
@@ -1023,7 +933,7 @@ public static void OpenWeb(WebType type)
}
///
- /// Mcloϴ־
+ /// 向Mclo上传日志
///
///
///
@@ -1033,7 +943,7 @@ public static void OpenWeb(WebType type)
}
///
- /// ȡColorMC־
+ /// 获取ColorMC更新日志
///
///
public static Task GetNewLog()
@@ -1042,7 +952,7 @@ public static void OpenWeb(WebType type)
}
///
- /// ȡӳб
+ /// 获取映射列表
///
///
public static async Task?> GetFrpServer()
@@ -1061,7 +971,7 @@ public static void OpenWeb(WebType type)
}
///
- /// ӳ
+ /// 共享映射
///
///
///
@@ -1725,7 +1635,7 @@ private static async Task GetOpenJ9List()
}
///
- /// ȡJava
+ /// 获取Java类型
///
///
public static List GetJavaType()
@@ -1734,7 +1644,7 @@ public static List GetJavaType()
}
///
- /// עҳ
+ /// 打开注册网页
///
///
///
@@ -1755,7 +1665,7 @@ public static void OpenRegister(AuthType type, string? name)
}
///
- /// ȡMinecraft News
+ /// 获取Minecraft News
///
///
public static async Task LoadNews()
diff --git a/src/ColorMC.Gui/Utils/DllAssembly.cs b/src/ColorMC.Gui/Utils/DllAssembly.cs
index a9fe3325d..e9ddcbc71 100644
--- a/src/ColorMC.Gui/Utils/DllAssembly.cs
+++ b/src/ColorMC.Gui/Utils/DllAssembly.cs
@@ -2,6 +2,8 @@
using System.IO;
using System.Reflection;
using System.Runtime.Loader;
+using ColorMC.Core;
+using ColorMC.Core.Utils;
using ColorMC.Gui.UI.Controls;
using ColorMC.Gui.UI.Controls.Custom;
using ColorMC.Gui.UIBinding;
@@ -44,7 +46,13 @@ public DllAssembly() : base("ColorMC.Custom", true)
{
if (item2 == typeof(ICustomControl))
{
- Plugin = (Activator.CreateInstance(item1) as ICustomControl)!;
+ var plugin = (Activator.CreateInstance(item1) as ICustomControl)!;
+ if (plugin.LauncherApi != ColorMCCore.TopVersion)
+ {
+ Logs.Error("CustomControl API Version error");
+ return;
+ }
+ Plugin = plugin;
Window = Plugin.GetControl();
IsLoad = true;
return;
diff --git a/src/ColorMC.Launcher/Program.cs b/src/ColorMC.Launcher/Program.cs
index f1a5ae4ec..c0137e5e3 100644
--- a/src/ColorMC.Launcher/Program.cs
+++ b/src/ColorMC.Launcher/Program.cs
@@ -52,7 +52,7 @@ public static class Program
///
/// 加载路径
///
- public const string TopVersion = "A28";
+ public const string TopVersion = "A29";
public static readonly string[] BaseSha1 =
[
diff --git a/src/ColorMC.sln b/src/ColorMC.sln
index a87154edc..b49ff3150 100644
--- a/src/ColorMC.sln
+++ b/src/ColorMC.sln
@@ -21,14 +21,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Live2DCSharpSDK.App", "..\L
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Live2DCSharpSDK.Framework", "..\Live2DCSharpSDK\Live2DCSharpSDK.Framework\Live2DCSharpSDK.Framework.csproj", "{39EC99EF-DD4C-4F09-88F7-103F25E1C80B}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorMC.Setup.Wix", "ColorMC.Setup.Wix\ColorMC.Setup.Wix.csproj", "{7169B43D-C8CD-431E-965A-274F154BA9AE}"
- ProjectSection(ProjectDependencies) = postProject
- {60B8E35E-7277-4DCB-8175-49E71FBB8E2E} = {60B8E35E-7277-4DCB-8175-49E71FBB8E2E}
- EndProjectSection
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "X11", "..\X11.Net\X11\X11.csproj", "{5CE171A3-EC3A-41A7-9163-10623926DC54}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorMC.CustomGui", "ColorMC.CustomGui\ColorMC.CustomGui.csproj", "{8543640C-A015-475F-90A1-CCA2B768C402}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorMC.CustomGui", "ColorMC.CustomGui\ColorMC.CustomGui.csproj", "{8543640C-A015-475F-90A1-CCA2B768C402}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -164,26 +159,6 @@ Global
{39EC99EF-DD4C-4F09-88F7-103F25E1C80B}.Release|x64.Build.0 = Release|Any CPU
{39EC99EF-DD4C-4F09-88F7-103F25E1C80B}.Release|x86.ActiveCfg = Release|Any CPU
{39EC99EF-DD4C-4F09-88F7-103F25E1C80B}.Release|x86.Build.0 = Release|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Debug|ARM.ActiveCfg = Debug|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Debug|ARM.Build.0 = Debug|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Debug|ARM64.ActiveCfg = Debug|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Debug|ARM64.Build.0 = Debug|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Debug|x64.ActiveCfg = Debug|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Debug|x64.Build.0 = Debug|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Debug|x86.ActiveCfg = Debug|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Debug|x86.Build.0 = Debug|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Release|Any CPU.Build.0 = Release|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Release|ARM.ActiveCfg = Release|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Release|ARM.Build.0 = Release|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Release|ARM64.ActiveCfg = Release|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Release|ARM64.Build.0 = Release|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Release|x64.ActiveCfg = Release|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Release|x64.Build.0 = Release|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Release|x86.ActiveCfg = Release|Any CPU
- {7169B43D-C8CD-431E-965A-274F154BA9AE}.Release|x86.Build.0 = Release|Any CPU
{5CE171A3-EC3A-41A7-9163-10623926DC54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5CE171A3-EC3A-41A7-9163-10623926DC54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5CE171A3-EC3A-41A7-9163-10623926DC54}.Debug|ARM.ActiveCfg = Debug|Any CPU