Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Pd233 committed Dec 28, 2023
1 parent fca65d9 commit ab396a3
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 85 deletions.
2 changes: 1 addition & 1 deletion src/LipUI/LipUI.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>

<WindowsPackageType>None</WindowsPackageType>
Expand Down
3 changes: 1 addition & 2 deletions src/LipUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using LipUI.Language;
using LipUI.Models;
using LipUI.Models;
using LipUI.Pages;
using Microsoft.UI.Composition;
using Microsoft.UI.Composition.SystemBackdrops;
Expand Down
39 changes: 17 additions & 22 deletions src/LipUI/Models/Main.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using LipUI.Language;
using LipUI.Models.Lip;
using LipUI.Models.Lip;
using LipUI.VIews;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
Expand All @@ -16,7 +15,6 @@ internal static class Main
{
static Main() => Initialize();

private static readonly object _lock = new();


public static Config Config { get; private set; }
Expand Down Expand Up @@ -63,36 +61,33 @@ private static void InitializeConfig()
}
}

public static async ValueTask<Lip.LipConsole?> CreateLipConsole(XamlRoot xamlRoot)
public static async ValueTask<LipConsole?> CreateLipConsole(XamlRoot xamlRoot)
{
var server = Config.SelectedServer;
if (server is null)
return null;

var (success, path) = await TryGetLipConsolePathAsync(xamlRoot);
if (success is false)
return null;

return new Lip.LipConsole(path!, server.WorkingDirectory);
var server = Config.SelectedServer;
if (server is null)
return null;

return new LipConsole(path!, server.WorkingDirectory);
}

public static async ValueTask SaveConfigAsync()
{
lock (_lock)
{
var path = Path.Combine(WorkingDirectory, DefaultSettings.ConfigFileName);
if (File.Exists(path)) File.Delete(path);
var path = Path.Combine(WorkingDirectory, DefaultSettings.ConfigFileName);
if (File.Exists(path)) File.Delete(path);

using var file = File.Create(path);
using var writer = new StreamWriter(file);
using var file = File.Create(path);
using var writer = new StreamWriter(file);

writer.Write(JsonSerializer.Serialize(Config, new JsonSerializerOptions()
{
WriteIndented = true,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
}));
}
await Task.Yield();

await writer.WriteAsync(JsonSerializer.Serialize(Config, new JsonSerializerOptions()
{
WriteIndented = true,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
}));
}

public static async ValueTask<(bool, string)> TryGetLipConsolePathAsync(XamlRoot xamlRoot)
Expand Down
4 changes: 2 additions & 2 deletions src/LipUI/Pages/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ private void StartServerButton_Click(object sender, RoutedEventArgs e)
var dir = Main.Config.SelectedServer.WorkingDirectory;
var path = Path.Combine(dir, "bedrock_server_mod.exe");

if (File.Exists(path))
if (File.Exists(path))
{
Process.Start(path);
return;
}

path = Path.Combine(dir, "bedrock_server.exe");
if(File.Exists(path))
if (File.Exists(path))
{
Process.Start(path);
}
Expand Down
2 changes: 1 addition & 1 deletion src/LipUI/Pages/IndexPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using LipUI.Language;
using LipUI.Models;
using LipUI.Protocol;
using LipUI.VIews;
Expand Down Expand Up @@ -29,6 +28,7 @@ public IndexPage()
private void ReloadLipIndex()
{
TeethScrollViewer.Content = new ProgressRing();
ToothListView.Items.Clear();

DispatcherQueue.TryEnqueue(async () =>
{
Expand Down
6 changes: 5 additions & 1 deletion src/LipUI/Pages/LipExecutionPanelPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
Grid.Column="0"
x:Name="ToothInfoPanel"
CornerRadius="5"
Background="{ThemeResource CardBackgroundFillColorSecondary}"/>
Spacing="4"
Padding="12,8,12,8"
Background="{ThemeResource CardBackgroundFillColorSecondary}">

</StackPanel>

<Grid
Grid.Row="1"
Expand Down
64 changes: 44 additions & 20 deletions src/LipUI/Pages/LipExecutionPanelPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
using LipUI.Models;
using LipUI.Models.Lip;
using LipUI.Protocol;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using System.Collections.Specialized;

using static LipUI.Models.Lip.LipCommand;
using static LipUI.Models.Lip.LipCommandOption;
using LipUI.Models;
using LipUI.Models.Lip;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using Microsoft.UI.Dispatching;
using Windows.UI;
using static LipUI.Models.Lip.LipCommand;
using static LipUI.Models.Lip.LipCommandOption;
using static LipUI.Protocol.LipIndex.LipIndexData;

// To learn more about WinUI, the WinUI project structure,
Expand Down Expand Up @@ -94,15 +86,18 @@ public void Run()
{
dispatcherQueue.TryEnqueue(async () =>
{
var server = Main.Config.SelectedServer;
if (server is null)
return;
lip = await Main.CreateLipConsole(page.XamlRoot);
if (lip is null)
{
var bar = page.TaskProgressBar;
bar.IsIndeterminate = false;
bar.Value = 0;

var (success, path) = await Main.TryGetLipConsolePathAsync(page.XamlRoot);
if (success is false)
page.LipWorkingInfoText.Text = string.Empty;
page.ProgressRateText.Text = string.Empty;
return;
}

lip = new LipConsole(path!, server.WorkingDirectory);

lip.Output += OutputHandler;

Expand Down Expand Up @@ -294,6 +289,9 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
var args = (InitArguments)e.Parameter;
Mode = args.Mode;

var style = (Style)Application.Current.Resources["CaptionTextBlockStyle"];
var brush = new SolidColorBrush((Color)Application.Current.Resources["TextFillColorSecondary"]);

switch (args.Mode)
{
case ExecutionMode.Install:
Expand All @@ -302,12 +300,38 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
Tooth = tooth;
ToothItem = toothItem;
SelectedVersion = selectedVersion;

ToothInfoPanel.Children.Add(new TextBlock()
{
Text = ToothItem.RepoName,
Style = style,
Foreground = brush
});
ToothInfoPanel.Children.Add(new TextBlock()
{
Text = SelectedVersion,
Style = style,
Foreground = brush
});
}
break;
case ExecutionMode.Delete:
case ExecutionMode.Update:
{
Package = (ToothPackage)args.Parameter;

ToothInfoPanel.Children.Add(new TextBlock()
{
Text = Package.Tooth,
Style = style,
Foreground = brush
});
ToothInfoPanel.Children.Add(new TextBlock()
{
Text = Package.Version,
Style = style,
Foreground = brush
});
}
break;
}
Expand Down
5 changes: 5 additions & 0 deletions src/LipUI/Pages/LocalPackagePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ public LocalPackagePage()
private void ReloadPackage()
{
TeethScrollViewer.Content = new ProgressRing();
ToothListView.Items.Clear();

DispatcherQueue.TryEnqueue(async () =>
{
var lip = await Main.CreateLipConsole(XamlRoot);

if (lip is null)
{
((ProgressRing)TeethScrollViewer.Content).IsActive = false;
return;
}

var cmd = LipCommand.CreateCommand();

Expand Down
4 changes: 0 additions & 4 deletions src/LipUI/Pages/ToothInfoPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

using CommunityToolkit.WinUI.UI.Controls;
using LipUI.Models;
using LipUI.Models.Lip;
using LipUI.Protocol;
using LipUI.VIews;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Windows.ApplicationModel.DataTransfer;
using Windows.Security.Authentication.Identity.Core;
using Windows.UI;

// To learn more about WinUI, the WinUI project structure,
Expand Down
7 changes: 1 addition & 6 deletions src/LipUI/Protocol/LocalToothItem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace LipUI.Protocol;

Expand Down
13 changes: 0 additions & 13 deletions src/LipUI/VIews/EulaAcceptView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
Expand Down
3 changes: 2 additions & 1 deletion src/LipUI/VIews/LipInstallerView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ private async void InstallButton_Click(object sender, RoutedEventArgs e)
progressRing.Visibility = Visibility.Visible;

CancelButton.IsEnabled = false;
ViewGrid.Children.Remove(ButtonGrid);
InstallButton.IsEnabled = false;
//ViewGrid.Children.Remove(ButtonGrid);

var info = await RequestLipInstallerInfo();

Expand Down
12 changes: 0 additions & 12 deletions src/LipUI/VIews/LocalToothView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@
using LipUI.Protocol;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
Expand Down

0 comments on commit ab396a3

Please sign in to comment.