Skip to content

Commit 206569f

Browse files
committed
not done
1 parent 05c75be commit 206569f

89 files changed

Lines changed: 2124 additions & 1755 deletions

File tree

Some content is hidden

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

docs/Core.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ var game = await InstancesPath.CreateGame(new()
164164
//上一步登录的账户
165165
var auth = AuthDatabase.Auths.First().Value;
166166
//启动游戏
167-
var handel = await game.StartGameAsync(new()
167+
var handle = await game.StartGameAsync(new()
168168
{
169169
Auth = auth
170170
}, CancellationToken.None);
133 KB
Binary file not shown.

src/ColorMC.Core/CoreMain.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using ColorMC.Core.Config;
33
using ColorMC.Core.Downloader;
44
using ColorMC.Core.Game;
5-
using ColorMC.Core.GuiHandel;
5+
using ColorMC.Core.GuiHandle;
66
using ColorMC.Core.LaunchPath;
77
using ColorMC.Core.Net;
88
using ColorMC.Core.Objs;
@@ -64,7 +64,7 @@ public static class ColorMCCore
6464
/// <summary>
6565
/// 游戏窗口句柄
6666
/// </summary>
67-
private static readonly ConcurrentDictionary<string, GameHandel> s_games = [];
67+
private static readonly ConcurrentDictionary<string, GameHandle> s_games = [];
6868
/// <summary>
6969
/// 游戏日志
7070
/// </summary>
@@ -221,7 +221,7 @@ public static void OnGameExit(GameSettingObj obj, LoginObj obj1, int code)
221221
/// </summary>
222222
/// <param name="uuid"></param>
223223
/// <param name="handel"></param>
224-
internal static void AddGameHandel(string uuid, GameHandel handel)
224+
internal static void AddGameHandel(string uuid, GameHandle handel)
225225
{
226226
if (!s_games.TryAdd(uuid, handel))
227227
{
@@ -250,13 +250,13 @@ internal static void OnInstanceIconChange(GameSettingObj obj)
250250
/// 获取下载窗口句柄
251251
/// </summary>
252252
/// <returns></returns>
253-
internal static IDownloadGuiHandel? OnDownloadGui()
253+
internal static IDownloadGui? OnDownloadGui()
254254
{
255255
var arg = new DownloadEventArgs
256256
{
257257
Thread = ConfigLoad.Config.Http.DownloadThread
258258
};
259259
Download?.Invoke(arg);
260-
return arg.GuiHandel;
260+
return arg.GuiHandle;
261261
}
262262
}

src/ColorMC.Core/Downloader/DownloadManager.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Collections.Concurrent;
22
using ColorMC.Core.Config;
3-
using ColorMC.Core.GuiHandel;
3+
using ColorMC.Core.GuiHandle;
44
using ColorMC.Core.Objs;
55

66
namespace ColorMC.Core.Downloader;
@@ -108,22 +108,22 @@ public static void Resume()
108108
/// </summary>
109109
/// <param name="list">下载列表</param>
110110
/// <returns>是否成功</returns>
111-
public static async Task<bool> StartAsync(ICollection<FileItemObj> list)
111+
public static async Task<bool> StartAsync(ICollection<FileItemObj> list, IProgressGui? gui = null)
112112
{
113113
if (s_stop)
114114
{
115115
return false;
116116
}
117117
var arg = ColorMCCore.OnDownloadGui();
118118

119-
return await StartAsync(list, arg);
119+
return await StartAsync(list, arg, gui);
120120
}
121121

122122
/// <summary>
123123
/// 进行下一个任务
124124
/// </summary>
125125
/// <param name="arg">下载参数</param>
126-
internal static void TaskDone(IDownloadGuiHandel? arg, DownloadTask task)
126+
internal static void TaskDone(IDownloadGui? arg, DownloadTask task)
127127
{
128128
s_tasks.Remove(task);
129129

@@ -145,11 +145,11 @@ internal static void TaskDone(IDownloadGuiHandel? arg, DownloadTask task)
145145
/// 开始下载
146146
/// </summary>
147147
/// <param name="list">下载列表</param>
148-
/// <param name="arg">下载参数</param>
148+
/// <param name="gui">下载参数</param>
149149
/// <returns>是否完成</returns>
150-
private static Task<bool> StartAsync(ICollection<FileItemObj> list, IDownloadGuiHandel? arg)
150+
private static Task<bool> StartAsync(ICollection<FileItemObj> list, IDownloadGui? gui, IProgressGui? pgui)
151151
{
152-
var task = new DownloadTask(arg);
152+
var task = new DownloadTask(gui, pgui);
153153
s_tasks.Add(task);
154154

155155
var names = new List<string>();
@@ -172,7 +172,7 @@ private static Task<bool> StartAsync(ICollection<FileItemObj> list, IDownloadGui
172172

173173
Start();
174174

175-
arg?.Update(s_threads.Count, true, s_tasks.Count);
175+
gui?.Update(s_threads.Count, true, s_tasks.Count);
176176

177177
return task.WaitDone();
178178
}

src/ColorMC.Core/Downloader/DownloadTask.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
using ColorMC.Core.GuiHandel;
1+
using ColorMC.Core.GuiHandle;
22
using ColorMC.Core.Objs;
33

44
namespace ColorMC.Core.Downloader;
55

66
/// <remarks>
77
/// 下载任务
88
/// </remarks>
9-
/// <param name="arg">GUI下载参数</param>
10-
internal class DownloadTask(IDownloadGuiHandel? arg)
9+
/// <param name="gui">GUI下载参数</param>
10+
internal class DownloadTask(IDownloadGui? gui, IProgressGui? pgui)
1111
{
1212
/// <summary>
1313
/// 任务是否已经取消
@@ -44,7 +44,7 @@ internal class DownloadTask(IDownloadGuiHandel? arg)
4444
public void SetSize(int size)
4545
{
4646
_allSize = size;
47-
arg?.UpdateTask(UpdateType.AddItems, _allSize);
47+
gui?.UpdateTask(UpdateType.AddItems, _allSize);
4848
}
4949

5050
/// <summary>
@@ -74,7 +74,7 @@ public void Cancel()
7474
_cancel.Cancel();
7575
_semaphore.Release();
7676

77-
DownloadManager.TaskDone(arg, this);
77+
DownloadManager.TaskDone(gui, this);
7878
}
7979

8080
/// <summary>
@@ -83,7 +83,8 @@ public void Cancel()
8383
public void Done()
8484
{
8585
_doneSize++;
86-
arg?.UpdateTask(UpdateType.ItemDone, 1);
86+
gui?.UpdateTask(UpdateType.ItemDone, 1);
87+
pgui?.SetNowProcess(_doneSize + _errorSize, _allSize);
8788

8889
ItemDone();
8990
}
@@ -94,7 +95,8 @@ public void Done()
9495
public void Error()
9596
{
9697
_errorSize++;
97-
arg?.UpdateTask(UpdateType.ItemDone, 1);
98+
gui?.UpdateTask(UpdateType.ItemDone, 1);
99+
pgui?.SetNowProcess(_doneSize + _errorSize, _allSize);
98100

99101
ItemDone();
100102
}
@@ -108,7 +110,7 @@ private void ItemDone()
108110
{
109111
//任务结束
110112
_semaphore.Release();
111-
DownloadManager.TaskDone(arg, this);
113+
DownloadManager.TaskDone(gui, this);
112114
}
113115
}
114116

@@ -119,6 +121,6 @@ private void ItemDone()
119121
/// <param name="obj">下载文件</param>
120122
public void UpdateItem(int index, FileItemObj obj)
121123
{
122-
arg?.UpdateItem(index, obj);
124+
gui?.UpdateItem(index, obj);
123125
}
124126
}

src/ColorMC.Core/Game/GameAuth.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using ColorMC.Core.GuiHandel;
1+
using ColorMC.Core.GuiHandle;
22
using ColorMC.Core.Net.Apis;
33
using ColorMC.Core.Net.Login;
44
using ColorMC.Core.Objs;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace ColorMC.Core.Game;
99
/// <summary>
1010
/// 游戏句柄
1111
/// </summary>
12-
public class GameHandel
12+
public class GameHandle
1313
{
1414
/// <summary>
1515
/// 游戏进程
@@ -26,7 +26,7 @@ public class GameHandel
2626
/// <summary>
2727
/// 游戏实例主窗口句柄
2828
/// </summary>
29-
public IntPtr Handel => Process.MainWindowHandle;
29+
public IntPtr Handle => Process.MainWindowHandle;
3030
/// <summary>
3131
/// 是否为管理员启动,且无法获取句柄
3232
/// </summary>
@@ -38,7 +38,7 @@ public class GameHandel
3838
/// 游戏句柄
3939
/// </summary>
4040
/// <param name="run">游戏运行参数</param>
41-
public GameHandel(GameRunObj run)
41+
public GameHandle(GameRunObj run)
4242
{
4343
_game = run.Obj;
4444

src/ColorMC.Core/Game/GameLaunch.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private static async Task<string> FindJavaAsync(GameSettingObj obj, GameLaunchAr
220220
list1?.ForEach(item => JvmPath.AddItem(item.Type + "_" + item.Version, item.Path));
221221
}
222222

223-
JavaInfo? jvm = null;
223+
JavaInfoObj? jvm = null;
224224
if (!string.IsNullOrWhiteSpace(obj.JvmName))
225225
{
226226
jvm = JvmPath.GetInfo(obj.JvmName);
@@ -466,12 +466,12 @@ public static async Task<Dictionary<GameSettingObj, GameLaunchRes>>
466466
//启动进程
467467
var stopwatch = new Stopwatch();
468468
stopwatch.Start();
469-
var handel = new GameHandel(item1);
469+
var handel = new GameHandle(item1);
470470
stopwatch.Stop();
471471
ColorMCCore.OnGameLog(item1.Obj, GameSystemLog.LaunchTime, stopwatch.Elapsed.ToString(), "");
472472

473473
ColorMCCore.AddGameHandel(item1.Obj.UUID, handel);
474-
list.Add(item1.Obj, new GameLaunchRes { Handel = handel });
474+
list.Add(item1.Obj, new GameLaunchRes { Handle = handel });
475475
}
476476

477477
return list;
@@ -574,7 +574,7 @@ public static async Task<CreateCmdRes> CreateGameCmdAsync(this GameSettingObj ob
574574
/// <param name="token">取消Token</param>
575575
/// <exception cref="LaunchException">启动错误</exception>
576576
/// <returns>游戏句柄</returns>
577-
public static async Task<GameHandel?> StartGameAsync(this GameSettingObj obj, GameLaunchArg larg,
577+
public static async Task<GameHandle?> StartGameAsync(this GameSettingObj obj, GameLaunchArg larg,
578578
CancellationToken token)
579579
{
580580
ColorMCCore.GameLogClear(obj);
@@ -709,7 +709,7 @@ public static async Task<CreateCmdRes> CreateGameCmdAsync(this GameSettingObj ob
709709
//启动进程
710710
stopwatch.Reset();
711711
stopwatch.Start();
712-
var handel = new GameHandel(new GameRunObj
712+
var handel = new GameHandle(new GameRunObj
713713
{
714714
Obj = obj,
715715
Arg = arg,

src/ColorMC.Core/Game/GameSaves.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System.Collections.Concurrent;
2-
using ColorMC.Core.GuiHandel;
2+
using ColorMC.Core.GuiHandle;
33
using ColorMC.Core.Helpers;
44
using ColorMC.Core.LaunchPath;
55
using ColorMC.Core.Nbt;

src/ColorMC.Core/Game/ServerPack.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Collections.Concurrent;
22
using ColorMC.Core.Config;
33
using ColorMC.Core.Downloader;
4-
using ColorMC.Core.GuiHandel;
4+
using ColorMC.Core.GuiHandle;
55
using ColorMC.Core.Helpers;
66
using ColorMC.Core.LaunchPath;
77
using ColorMC.Core.Net;

0 commit comments

Comments
 (0)