Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
Coloryr committed Jul 24, 2024
1 parent 7911b0e commit af68854
Show file tree
Hide file tree
Showing 51 changed files with 467 additions and 244 deletions.
3 changes: 3 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
⚫计划中
添加窗口状态保存

⚫2024.7.24
√ 修复返回错误

⚫2024.7.23(A27.1)
√ 添加账户重复使用不再提醒
√ 添加多个实例同时启动
Expand Down
8 changes: 4 additions & 4 deletions src/ColorMC.Core/LaunchPath/InstancesPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,26 +1050,26 @@ await Task.Run(() =>
/// <param name="obj">游戏实例</param>
/// <param name="path">自定义加载器路径</param>
/// <returns></returns>
public static async Task<(bool, string?)> SetGameLoader(this GameSettingObj obj, string path)
public static async Task<MessageRes> SetGameLoader(this GameSettingObj obj, string path)
{
if (!File.Exists(path))
{
return (false, LanguageHelper.Get("Core.Game.Error16"));
return new() { Message = LanguageHelper.Get("Core.Game.Error16") };
}

var list = await DownloadItemHelper.DecodeLoaderJarAsync(obj, path);

if (list == null)
{
return (false, LanguageHelper.Get("Core.Game.Error17"));
return new() { Message = LanguageHelper.Get("Core.Game.Error17") };
}

var local = obj.GetGameLoaderFile();
PathHelper.Delete(local);

PathHelper.CopyFile(path, local);

return (true, null);
return new() { State = true };
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/ColorMC.CustomGui/UIModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public async Task Launch()
Model.Progress("正在启动游戏");
var res = await GameBinding.Launch(Model, SelectGame.Obj, hide: true);
Model.ProgressClose();
if (!res.Item1)
if (!res.Res)
{
Model.Show("游戏启动失败\n" + res.Item2);
Model.Show("游戏启动失败\n" + res.Message);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/ColorMC.Gui/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using ColorMC.Core.Helpers;
using ColorMC.Core.Objs;
using ColorMC.Core.Utils;
using ColorMC.Gui.LaunchPath;
using ColorMC.Gui.Manager;
using ColorMC.Gui.Objs;
using ColorMC.Gui.Player;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using ColorMC.Gui.Objs;

namespace ColorMC.Gui.Utils.Hook;
namespace ColorMC.Gui.Hook;

public interface INative
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
using Avalonia.Input;
using Avalonia.Win32.Input;
using ColorMC.Gui.Objs;
using ColorMC.Gui.Utils;

namespace ColorMC.Gui.Utils.Hook;
namespace ColorMC.Gui.Hook;

public class Win32Native : INative
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Threading;
using X11;

namespace ColorMC.Gui.Utils.Hook;
namespace ColorMC.Gui.Hook;

internal partial class X11Hook
{
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/ColorMC.Gui/Net/Apis/OpenFrpApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using ColorMC.Core.Net;
using ColorMC.Core.Objs;
using ColorMC.Core.Utils;
using ColorMC.Gui.LaunchPath;
using ColorMC.Gui.Objs.Frp;
using ColorMC.Gui.Utils;
using ICSharpCode.SharpZipLib.GZip;
using ICSharpCode.SharpZipLib.Tar;
using ICSharpCode.SharpZipLib.Zip;
Expand Down
2 changes: 1 addition & 1 deletion src/ColorMC.Gui/Net/Apis/SakuraFrpApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using ColorMC.Core.Net;
using ColorMC.Core.Objs;
using ColorMC.Core.Utils;
using ColorMC.Gui.LaunchPath;
using ColorMC.Gui.Objs.Frp;
using ColorMC.Gui.Utils;
using Newtonsoft.Json;

namespace ColorMC.Gui.Net.Apis;
Expand Down
8 changes: 0 additions & 8 deletions src/ColorMC.Gui/Objs/JavaInfoObj.cs

This file was deleted.

33 changes: 33 additions & 0 deletions src/ColorMC.Gui/Objs/Result.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ColorMC.Core.Objs;
using ColorMC.Core.Objs.Login;

namespace ColorMC.Gui.Objs;

public record FrpLaunchRes
{
public bool Res;
public Process? Process;
public string? IP;
}

public record GameLaunchOneRes
{
public bool Res;
public string? Message;
public bool LoginFail;
public LoginObj? User;
}

public record GameLaunchListRes
{
public List<string>? Done;
public string? Message;
public Dictionary<string, LaunchState> Fail;
public LoginObj? User;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// 一个方块模型数据
/// </summary>
public record CubeModelItem
public record CubeModelItemObj
{
public float[] Model;
public ushort[] Point;
Expand All @@ -12,21 +12,21 @@ public record CubeModelItem
/// <summary>
/// 一个史蒂夫模型数据
/// </summary>
public record SteveModel
public record SteveModelObj
{
public CubeModelItem Head;
public CubeModelItem Body;
public CubeModelItem LeftArm;
public CubeModelItem RightArm;
public CubeModelItem LeftLeg;
public CubeModelItem RightLeg;
public CubeModelItem Cape;
public CubeModelItemObj Head;
public CubeModelItemObj Body;
public CubeModelItemObj LeftArm;
public CubeModelItemObj RightArm;
public CubeModelItemObj LeftLeg;
public CubeModelItemObj RightLeg;
public CubeModelItemObj Cape;
}

/// <summary>
/// 模型贴图数据
/// </summary>
public record SteveTexture
public record SteveTextureObj
{
public float[] Head;
public float[] Body;
Expand Down
6 changes: 3 additions & 3 deletions src/ColorMC.Gui/Skin/Steve3DModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Steve3DModel
/// </summary>
/// <param name="type">类型</param>
/// <returns></returns>
public SteveModel GetSteve(SkinType type)
public SteveModelObj GetSteve(SkinType type)
{
return new()
{
Expand Down Expand Up @@ -96,9 +96,9 @@ public SteveModel GetSteve(SkinType type)
/// </summary>
/// <param name="type">类型</param>
/// <returns></returns>
public SteveModel GetSteveTop(SkinType type)
public SteveModelObj GetSteveTop(SkinType type)
{
var model = new SteveModel
var model = new SteveModelObj
{
Head = new()
{
Expand Down
8 changes: 4 additions & 4 deletions src/ColorMC.Gui/Skin/Steve3DTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public class Steve3DTexture
/// </summary>
/// <param name="type">类型</param>
/// <returns></returns>
public SteveTexture GetSteveTextureTop(SkinType type)
public SteveTextureObj GetSteveTextureTop(SkinType type)
{
SteveTexture tex = new()
SteveTextureObj tex = new()
{
Head = GetTex(_headTex, type, 32f, 0f),
};
Expand All @@ -36,9 +36,9 @@ public SteveTexture GetSteveTextureTop(SkinType type)
/// </summary>
/// <param name="type">类型</param>
/// <returns></returns>
public SteveTexture GetSteveTexture(SkinType type)
public SteveTextureObj GetSteveTexture(SkinType type)
{
SteveTexture tex = new()
SteveTextureObj tex = new()
{
Head = GetTex(_headTex, type),
Body = GetTex(_bodyTex, type, 16f, 16f),
Expand Down
4 changes: 2 additions & 2 deletions src/ColorMC.Gui/UI/Controls/Add/AddJavaControl.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using Avalonia.Input;
using Avalonia.Media.Imaging;
using ColorMC.Gui.Manager;
using ColorMC.Gui.Objs;
using ColorMC.Gui.UI.Model;
using ColorMC.Gui.UI.Model.Add;
using ColorMC.Gui.UI.Model.Items;

namespace ColorMC.Gui.UI.Controls.Add;

Expand Down Expand Up @@ -58,7 +58,7 @@ public override Bitmap GetIcon()

private void JavaFiles_DoubleTapped(object? sender, TappedEventArgs e)
{
if (JavaFiles.SelectedItem is not JavaDownloadObj obj)
if (JavaFiles.SelectedItem is not JavaDownloadModel obj)
return;

(DataContext as AddJavaControlModel)!.Install(obj);
Expand Down
6 changes: 3 additions & 3 deletions src/ColorMC.Gui/UI/Controls/Setting/Tab2Control.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:model="clr-namespace:ColorMC.Gui.UI.Model.Setting"
xmlns:setting="clr-namespace:ColorMC.Gui.Utils"
xmlns:svg="clr-namespace:ColorMC.Gui.UI.Views.Svg"
xmlns:view="clr-namespace:ColorMC.Gui.Objs"
xmlns:view="clr-namespace:ColorMC.Gui.UI.Model.Items"
d:DesignWidth="800"
x:DataType="model:SettingModel"
mc:Ignorable="d">
Expand Down Expand Up @@ -110,7 +110,7 @@
ItemsSource="{Binding FontList}"
SelectedItem="{Binding FontItem}">
<ComboBox.ItemTemplate>
<DataTemplate DataType="view:FontDisplayObj">
<DataTemplate DataType="view:FontDisplayModel">
<StackPanel>
<TextBlock FontFamily="{Binding FontFamily}" Text="{Binding FontName}" />
</StackPanel>
Expand Down Expand Up @@ -140,7 +140,7 @@
ItemsSource="{Binding FontList}"
SelectedItem="{Binding FontItem}">
<ComboBox.ItemTemplate>
<DataTemplate DataType="view:FontDisplayObj">
<DataTemplate DataType="view:FontDisplayModel">
<StackPanel>
<TextBlock FontFamily="{Binding FontFamily}" Text="{Binding FontName}" />
</StackPanel>
Expand Down
2 changes: 1 addition & 1 deletion src/ColorMC.Gui/UI/Controls/Skin/SkinRender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ private void LoadSkin(GlInterface gl)
model.IsLoading = false;
}

private unsafe void PutVAO(GlInterface gl, VAOItem vao, CubeModelItem model, float[] uv)
private unsafe void PutVAO(GlInterface gl, VAOItem vao, CubeModelItemObj model, float[] uv)
{
float[] vertices =
[
Expand Down
4 changes: 2 additions & 2 deletions src/ColorMC.Gui/UI/Flyouts/SettingFlyout1.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections;
using System.Linq;
using Avalonia.Controls;
using ColorMC.Gui.Objs;
using ColorMC.Gui.UI.Model.Items;
using ColorMC.Gui.UI.Model.Setting;
using ColorMC.Gui.UIBinding;

Expand All @@ -11,7 +11,7 @@ public class SettingFlyout1
{
public SettingFlyout1(Control con, SettingModel model, IList list)
{
var java = list.Cast<JavaDisplayObj>();
var java = list.Cast<JavaDisplayModel>();

_ = new FlyoutsControl(
[
Expand Down
11 changes: 5 additions & 6 deletions src/ColorMC.Gui/UI/Model/Add/AddControlModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using ColorMC.Core.Objs.Modrinth;
using ColorMC.Core.Objs.OptiFine;
using ColorMC.Core.Utils;
using ColorMC.Gui.Objs;
using ColorMC.Gui.UI.Model.Items;
using ColorMC.Gui.UI.Windows;
using ColorMC.Gui.UIBinding;
Expand Down Expand Up @@ -42,7 +41,7 @@ public partial class AddControlModel : GameModel, IAddWindow
/// <summary>
/// 显示的文件列表
/// </summary>
public ObservableCollection<FileDisplayObj> FileList { get; init; } = [];
public ObservableCollection<FileDisplayModel> FileList { get; init; } = [];
/// <summary>
/// 显示的项目列表
/// </summary>
Expand Down Expand Up @@ -129,7 +128,7 @@ public partial class AddControlModel : GameModel, IAddWindow
/// 项目
/// </summary>
[ObservableProperty]
private FileDisplayObj? _file;
private FileDisplayModel? _file;
/// <summary>
/// 下载的模组
/// </summary>
Expand Down Expand Up @@ -940,7 +939,7 @@ public void Install()
/// 开始下载文件
/// </summary>
/// <param name="data"></param>
public async void Install1(FileDisplayObj data)
public async void Install1(FileDisplayModel data)
{
var type = SourceTypeList[DownloadSource];
if (Set)
Expand Down Expand Up @@ -1135,7 +1134,7 @@ private async void LoadFile(string? id = null)
{
FileList.Clear();

List<FileDisplayObj>? list = null;
List<FileDisplayModel>? list = null;
var type = SourceTypeList[DownloadSource];
if (type == SourceType.McMod)
{
Expand Down Expand Up @@ -1337,7 +1336,7 @@ private void ClearList()

public override void Close()
{
if (Display)
if (VersionDisplay || OptifineDisplay || ModDownloadDisplay)
{
Model.PopBack();
}
Expand Down
2 changes: 1 addition & 1 deletion src/ColorMC.Gui/UI/Model/Add/AddGameTab1Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public async Task AddGame()
if (game.Loader == Loaders.Custom && !string.IsNullOrWhiteSpace(LoaderLocal))
{
var res1 = await GameBinding.SetGameLoader(game, LoaderLocal);
if (!res1.Item1)
if (!res1.State)
{
Model.ShowOk(App.Lang("AddGameWindow.Tab1.Error18"), Done);
return;
Expand Down
Loading

0 comments on commit af68854

Please sign in to comment.