Skip to content

Commit 94d1304

Browse files
committed
up 修改主界面
1 parent def475d commit 94d1304

13 files changed

Lines changed: 135 additions & 17 deletions

File tree

src/ColorMC.Core/CoreMain.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public static class ColorMCCore
4848
/// </summary>
4949
public static event Action<InstanceChangeEventArgs>? InstanceChange;
5050
/// <summary>
51+
/// Java修改
52+
/// </summary>
53+
public static event Action<JavaChangeArg>? JavaChange;
54+
/// <summary>
5155
/// 是否为新运行
5256
/// </summary>
5357
public static bool NewStart { get; internal set; }
@@ -246,6 +250,19 @@ internal static void OnInstanceIconChange(GameSettingObj obj)
246250
InstanceChange?.Invoke(new InstanceChangeEventArgs(InstanceChangeType.IconChange, obj));
247251
}
248252

253+
/// <summary>
254+
/// Java修改
255+
/// </summary>
256+
internal static void OnJavaChange(JavaInfoObj? java, bool add, bool mut)
257+
{
258+
JavaChange?.Invoke(new JavaChangeArg
259+
{
260+
IsAdd = add,
261+
IsMut = mut,
262+
Java = java
263+
});
264+
}
265+
249266
/// <summary>
250267
/// 获取下载窗口句柄
251268
/// </summary>

src/ColorMC.Core/LaunchPath/JvmPath.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ public static StringRes AddItem(string name, string local)
205205
if (info != null)
206206
{
207207
Jvms.Add(name, info);
208+
ColorMCCore.OnJavaChange(info, true, false);
208209
ConfigLoad.Config.JavaList?.Add(new JvmConfigObj
209210
{
210211
Name = name,
@@ -223,7 +224,10 @@ public static StringRes AddItem(string name, string local)
223224
/// <param name="name">名字</param>
224225
public static void Remove(string name)
225226
{
226-
Jvms.Remove(name);
227+
if (Jvms.Remove(name, out var info))
228+
{
229+
ColorMCCore.OnJavaChange(info, false, false);
230+
}
227231
var item = ConfigLoad.Config.JavaList?.FirstOrDefault(a => a.Name == name);
228232
if (item != null && ConfigLoad.Config.JavaList?.Remove(item) == true)
229233
{
@@ -272,6 +276,8 @@ private static void AddList(List<JvmConfigObj> list)
272276
});
273277
}
274278
});
279+
280+
ColorMCCore.OnJavaChange(null, true, true);
275281
});
276282
}
277283

@@ -301,6 +307,7 @@ private static void AddList(List<JvmConfigObj> list)
301307
public static void RemoveAll()
302308
{
303309
Jvms.Clear();
310+
ColorMCCore.OnJavaChange(null, false, true);
304311
ConfigLoad.Config.JavaList.Clear();
305312
ConfigLoad.Save();
306313
}

src/ColorMC.Core/Objs/Events.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ public class InstanceChangeEventArgs(InstanceChangeType type, GameSettingObj? ga
673673
}
674674

675675
/// <summary>
676-
/// 开始下载回调
676+
/// 开始下载事件
677677
/// </summary>
678678
public class DownloadEventArgs : EventArgs
679679
{
@@ -685,4 +685,23 @@ public class DownloadEventArgs : EventArgs
685685
/// 界面操作回调
686686
/// </summary>
687687
public IDownloadGui? GuiHandle { get; set; }
688+
}
689+
690+
/// <summary>
691+
/// Java修改事件
692+
/// </summary>
693+
public class JavaChangeArg : EventArgs
694+
{
695+
/// <summary>
696+
/// 是否为添加操作
697+
/// </summary>
698+
public bool IsAdd { get; set; }
699+
/// <summary>
700+
/// 是否为批量操作
701+
/// </summary>
702+
public bool IsMut { get; set; }
703+
/// <summary>
704+
/// 修改的Java
705+
/// </summary>
706+
public JavaInfoObj? Java { get; set; }
688707
}

src/ColorMC.Gui/ColorMC.Gui.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@
358358
<ProjectReference Include="..\ColorMC.Core\ColorMC.Core.csproj" />
359359
</ItemGroup>
360360
<ItemGroup>
361+
<Compile Update="UI\Controls\Main\MainSimpleControl.axaml.cs">
362+
<DependentUpon>MainSimpleControl.axaml</DependentUpon>
363+
</Compile>
361364
<Compile Update="UI\Controls\TitleControl.axaml.cs">
362365
<DependentUpon>TitleControl.axaml</DependentUpon>
363366
</Compile>

src/ColorMC.Gui/Resource/Language/zh-cn.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"MainWindow.Text94": "服务器信息获取失败",
8787
"MainWindow.Text95": "实例列表",
8888
"MainWindow.Text96": "高级设定",
89+
"MainWindow.Text97": "更多配置",
8990
"UserWindow.Title": "账户管理",
9091
"UserWindow.Text2": "密码",
9192
"UserWindow.Text3": "账户类型",

src/ColorMC.Gui/UI/Controls/Main/MainControl.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
<DockPanel
172172
Margin="30,20,0,0"
173173
DockPanel.Dock="Top"
174-
IsVisible="{Binding HaveGame}">
174+
IsVisible="{Binding !IsNotGame}">
175175
<Border
176176
Padding="3"
177177
Background="{setting:Theme RadioGroupBG}"

src/ColorMC.Gui/UI/Controls/Main/MainControl.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public partial class MainControl : BaseUserControl
4343
/// <summary>
4444
/// 简易主界面
4545
/// </summary>
46-
private SimpleControl? _simple;
46+
private MainSimpleControl? _simple;
4747

4848
public MainControl() : base(WindowManager.GetUseName<MainControl>())
4949
{

src/ColorMC.Gui/UI/Controls/Main/SimpleControl.axaml renamed to src/ColorMC.Gui/UI/Controls/Main/MainSimpleControl.axaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<UserControl
2-
x:Class="ColorMC.Gui.UI.Controls.Main.SimpleControl"
2+
x:Class="ColorMC.Gui.UI.Controls.Main.MainSimpleControl"
33
xmlns="https://github.com/avaloniaui"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -103,6 +103,7 @@
103103
OnContent="{setting:Localize SettingWindow.Tab4.Text12}" />
104104
</Grid>
105105
<Grid
106+
Margin="0,0,0,10"
106107
ColumnDefinitions="auto,*,auto,*"
107108
IsEnabled="{Binding HaveGame}"
108109
IsVisible="{Binding EnableArg}">
@@ -125,6 +126,28 @@
125126
Minimum="1"
126127
Value="{Binding MaxMem}" />
127128
</Grid>
129+
<StackPanel
130+
Margin="0,0,0,5"
131+
HorizontalAlignment="Center"
132+
IsVisible="{Binding EnableArg}"
133+
Orientation="Horizontal">
134+
<TextBlock Margin="0,0,5,0" Text="{setting:Localize GameEditWindow.Tab2.Text22}" />
135+
<ComboBox
136+
Width="230"
137+
IsEditable="True"
138+
ItemsSource="{Binding JavaList}"
139+
Text="{Binding Java}" />
140+
</StackPanel>
141+
<Button
142+
Width="200"
143+
Height="35"
144+
Margin="-3,0,-3,0"
145+
HorizontalAlignment="Stretch"
146+
Classes="top"
147+
Command="{Binding OpenGameSetting}"
148+
Content="{setting:Localize MainWindow.Text97}"
149+
IsEnabled="{Binding HaveGame}"
150+
IsVisible="{Binding EnableArg}" />
128151
</StackPanel>
129152
</Border>
130153
</UserControl>

src/ColorMC.Gui/UI/Controls/Main/SimpleControl.axaml.cs renamed to src/ColorMC.Gui/UI/Controls/Main/MainSimpleControl.axaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace ColorMC.Gui.UI.Controls.Main;
44

5-
public partial class SimpleControl : UserControl
5+
public partial class MainSimpleControl : UserControl
66
{
7-
public SimpleControl()
7+
public MainSimpleControl()
88
{
99
InitializeComponent();
1010
}

src/ColorMC.Gui/UI/Model/Main/GameListModel.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ public partial class MainModel
4141
/// </summary>
4242
private readonly Dictionary<Guid, GameItemModel> Launchs = [];
4343

44-
/// <summary>
45-
/// 用于
46-
/// </summary>
47-
private readonly Semaphore _semaphore = new(0, 2);
48-
4944
/// <summary>
5045
/// 游戏实例
5146
/// </summary>
@@ -107,8 +102,6 @@ public partial class MainModel
107102
/// </summary>
108103
public bool IsMut { get; private set; }
109104

110-
private GameItemModel? _dragItem;
111-
112105
partial void OnGridTypeChanged(ItemsGridType value)
113106
{
114107
OnPropertyChanged(SwitchView);

0 commit comments

Comments
 (0)