Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
更新UI布局
修复自定义窗口问题
  • Loading branch information
Coloryr committed Aug 16, 2024
1 parent 4a8a37f commit 3b7684e
Show file tree
Hide file tree
Showing 32 changed files with 808 additions and 535 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/dotnet-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/ColorMC.Core/CoreMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,12 @@ public static void KillGame(string uuid)
}

/// <summary>
/// 启动器产生错误
/// 启动器产生错误,并打开窗口显示
/// </summary>
/// <param name="text"></param>
/// <param name="e"></param>
/// <param name="close"></param>
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);
Expand All @@ -274,7 +274,7 @@ public static void OnError(string text, Exception? e, bool close)
/// </summary>
/// <param name="obj"></param>
/// <param name="text"></param>
public static void OnGameLog(GameSettingObj obj, string? text)
internal static void OnGameLog(GameSettingObj obj, string? text)
{
GameLog?.Invoke(obj, text);
}
Expand All @@ -283,18 +283,18 @@ public static void OnGameLog(GameSettingObj obj, string? text)
/// 语言重载
/// </summary>
/// <param name="type"></param>
public static void OnLanguageReload(LanguageType type)
internal static void OnLanguageReload(LanguageType type)
{
LanguageReload?.Invoke(type);
}

/// <summary>
/// 游戏推出
/// 游戏退出
/// </summary>
/// <param name="obj"></param>
/// <param name="obj1"></param>
/// <param name="code"></param>
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);
Expand Down
1 change: 1 addition & 0 deletions src/ColorMC.CustomGui/CustomUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace ColorMC.CustomGui;

public class CustomUI : ICustomControl
{
public string LauncherApi => "A29";
/// <summary>
/// 返回主界面 一般不用动
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/ColorMC.Gui/ColorMC.Gui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,9 @@
<ProjectReference Include="..\..\X11.Net\X11\X11.csproj" />
<ProjectReference Include="..\ColorMC.Core\ColorMC.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="UI\Controls\Items\FileVersionItemControl.axaml.cs">
<DependentUpon>FileVersionItemControl.axaml</DependentUpon>
</Compile>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/ColorMC.Gui/Manager/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ColorMC.Gui/Objs/Results.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public record ModDownloadRes
{
public DownloadItemObj Item;
public ModInfoObj Info;
public List<DownloadModModel> List;
public List<FileModVersionModel> List;
}

public record GetJavaListRes
Expand Down
4 changes: 2 additions & 2 deletions src/ColorMC.Gui/Resource/Language/gui_zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,7 @@
"AddModPackWindow.Text12": "安装所选",
"AddModPackWindow.Text13": "没有资源",
"AddModPackWindow.Text14": "下一页",
"AddModPackWindow.Text15": "下载次数",
"AddModPackWindow.Text16": "发布时间",
"AddModPackWindow.Text16": "发布时间:",
"AddModPackWindow.Info1": "是否安装整合包 {0}",
"AddModPackWindow.Info2": "正在搜索整合包中",
"AddModPackWindow.Info3": "正在获取整合包版本中",
Expand Down Expand Up @@ -719,6 +718,7 @@
"AddWindow.Info11": "正在下载",
"AddWindow.Info13": "正在加载Optifine列表",
"AddWindow.Info14": "选择下载源",
"AddWindow.Info15": "是否切换模组版本",
"AddWindow.Error1": "你还没有选择资源",
"AddWindow.Error2": "资源数据加载失败",
"AddWindow.Error3": "资源版本数据加载失败",
Expand Down
144 changes: 71 additions & 73 deletions src/ColorMC.Gui/UI/Controls/Add/AddControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
x:DataType="model:AddControlModel"
mc:Ignorable="d">
<Panel>
<ScrollViewer Name="ScrollViewer1" VerticalScrollBarVisibility="Visible">
<ScrollViewer
Name="ScrollViewer1"
IsVisible="True"
VerticalScrollBarVisibility="Visible">
<DockPanel Margin="10">
<Border
Margin="10,0,10,5"
Expand Down Expand Up @@ -142,14 +145,17 @@
</Panel>
</DockPanel>
</ScrollViewer>
<Decorator Name="VersionDisplay" IsVisible="False">
<Border
Margin="20,10,20,20"
Classes="t2"
DockPanel.Dock="Top">
<DockPanel>
<ScrollViewer
Name="VersionDisplay"
IsVisible="False"
VerticalScrollBarVisibility="Visible">
<DockPanel Margin="10">
<Border
Margin="10,0,10,5"
Classes="t2"
DockPanel.Dock="Top">
<panel:WrapPanelWithStretch
Margin="15,15,5,-5"
Margin="15,15,5,5"
AutoMax="{Binding MinMode}"
DockPanel.Dock="Top">
<DockPanel MinWidth="190" Margin="0,0,10,10">
Expand Down Expand Up @@ -196,38 +202,40 @@
ToolTip.VerticalOffset="-30" />
</StackPanel>
</panel:WrapPanelWithStretch>
<DataGrid
Name="VersionFiles"
Margin="5,0,5,5"
CanUserResizeColumns="True"
ItemsSource="{Binding FileList}"
SelectedItem="{Binding File}">
<DataGrid.Columns>
<DataGridCheckBoxColumn
Binding="{Binding IsDownload}"
Header="{setting:Localize Text.Downloaded}"
IsReadOnly="True" />
<DataGridTextColumn
Binding="{Binding Name}"
Header="{setting:Localize Text.Name}"
IsReadOnly="True" />
<DataGridTextColumn
Binding="{Binding Size}"
Header="{setting:Localize Text.Size}"
IsReadOnly="True" />
<DataGridTextColumn
Binding="{Binding Download}"
Header="{setting:Localize AddModPackWindow.Text15}"
IsReadOnly="True" />
<DataGridTextColumn
Binding="{Binding Time}"
Header="{setting:Localize AddModPackWindow.Text16}"
IsReadOnly="True" />
</DataGrid.Columns>
</DataGrid>
</DockPanel>
</Border>
</Decorator>
</Border>
<Panel>
<StackPanel>
<ItemsControl
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ItemsSource="{Binding FileList}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<item:FileVersionItemControl DataContext="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Button
Height="35"
Margin="6,0,6,5"
HorizontalAlignment="Stretch"
Classes="top"
Command="{Binding NextVersion}"
Content="{setting:Localize AddModPackWindow.Text14}"
IsVisible="{Binding !EmptyVersionDisplay}" />
</StackPanel>
<Border
Margin="10,5,10,10"
Classes="t1"
IsVisible="{Binding EmptyVersionDisplay}">
<TextBlock
HorizontalAlignment="Center"
FontSize="30"
Text="{setting:Localize AddModPackWindow.Text13}" />
</Border>
</Panel>
</DockPanel>
</ScrollViewer>
<Decorator Name="OptifineDisplay" IsVisible="False">
<Border Margin="20,10,20,20" Classes="t2">
<DockPanel>
Expand Down Expand Up @@ -296,10 +304,16 @@
</DockPanel>
</Border>
</Decorator>
<Decorator Name="ModDownloadDisplay" IsVisible="False">
<Border Margin="20,10,20,20" Classes="t2">
<DockPanel>
<WrapPanel Margin="15,15,5,-5" DockPanel.Dock="Top">
<ScrollViewer
Name="ModDownloadDisplay"
IsVisible="False"
VerticalScrollBarVisibility="Visible">
<DockPanel Margin="10">
<Border
Margin="10,0,10,5"
Classes="t2"
DockPanel.Dock="Top">
<WrapPanel Margin="15,15,5,15" DockPanel.Dock="Top">
<TextBlock Margin="0,0,20,0" Text="{setting:Localize AddWindow.Text7}" />
<ToggleSwitch
Margin="0,0,10,0"
Expand Down Expand Up @@ -327,34 +341,18 @@
ToolTip.VerticalOffset="-30" />
</StackPanel>
</WrapPanel>
<DataGrid
Name="ModDownloadFiles"
Margin="5"
CanUserResizeColumns="True"
ItemsSource="{Binding DownloadModList}"
SelectedItem="{Binding Mod}">
<DataGrid.Columns>
<DataGridCheckBoxColumn Binding="{Binding Download}" Header="{setting:Localize AddWindow.Text11}" />
<DataGridTextColumn
Binding="{Binding Name}"
Header="{setting:Localize AddWindow.Text12}"
IsReadOnly="True" />
<DataGridTemplateColumn Header="{setting:Localize Text.Version}">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox
Margin="0,5,0,5"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ItemsSource="{Binding Version}"
SelectedIndex="{Binding SelectVersion}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</DockPanel>
</Border>
</Decorator>
</Border>
<ItemsControl
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ItemsSource="{Binding DownloadModList}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<item:FileModVersionControl DataContext="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DockPanel>
</ScrollViewer>
</Panel>
</UserControl>
15 changes: 0 additions & 15 deletions src/ColorMC.Gui/UI/Controls/Add/AddControl.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
Loading

0 comments on commit 3b7684e

Please sign in to comment.