diff --git a/MetaforceInstaller.Core/Intefaces/IStorageService.cs b/MetaforceInstaller.Core/Intefaces/IStorageService.cs deleted file mode 100644 index 5967309..0000000 --- a/MetaforceInstaller.Core/Intefaces/IStorageService.cs +++ /dev/null @@ -1,9 +0,0 @@ -using MetaforceInstaller.Core.Models; - -namespace MetaforceInstaller.Core.Intefaces; - -public interface IStorageService -{ - AppData Load(); - void Save(AppData data); -} \ No newline at end of file diff --git a/MetaforceInstaller.Core/Models/AppData.cs b/MetaforceInstaller.Core/Models/AppData.cs deleted file mode 100644 index 5c37871..0000000 --- a/MetaforceInstaller.Core/Models/AppData.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace MetaforceInstaller.Core.Models; - -public class AppData -{ - public List Installations { get; set; } = new(); -} \ No newline at end of file diff --git a/MetaforceInstaller.Core/Models/InstallationData.cs b/MetaforceInstaller.Core/Models/InstallationData.cs deleted file mode 100644 index 855fae7..0000000 --- a/MetaforceInstaller.Core/Models/InstallationData.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MetaforceInstaller.Core.Models; - -public class InstallationData -{ - public Guid Id { get; set; } = Guid.NewGuid(); - public string Title { get; set; } - public string AndroidPackagePath { get; set; } - public string WindowsServerPackagePath { get; set; } - public string WindowsAdminPackagePath { get; set; } -} \ No newline at end of file diff --git a/MetaforceInstaller.Core/Models/InstallationParts.cs b/MetaforceInstaller.Core/Models/InstallationParts.cs deleted file mode 100644 index cb531ab..0000000 --- a/MetaforceInstaller.Core/Models/InstallationParts.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace MetaforceInstaller.Core.Models; - -public record InstallationParts -{ - public bool OculusClientExists { get; init; } - public bool PicoClientExists { get; init; } - public bool AndroidAdminExists { get; init; } - public bool AndroidContentExists { get; init; } - public bool WindowsContentExists { get; init; } - public bool WindowsAdminExists { get; init; } - public bool WindowsServerExists { get; init; } -} \ No newline at end of file diff --git a/MetaforceInstaller.Core/Services/StorageService.cs b/MetaforceInstaller.Core/Services/StorageService.cs deleted file mode 100644 index 7fa1601..0000000 --- a/MetaforceInstaller.Core/Services/StorageService.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Text.Json; -using MetaforceInstaller.Core.Intefaces; -using MetaforceInstaller.Core.Models; - -namespace MetaforceInstaller.Core.Services; - -public class StorageService : IStorageService -{ - private readonly string _storagePath; - - public StorageService() - { - var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); - var appDirectory = Path.Combine(appData, "MetaforceInstaller"); - Directory.CreateDirectory(appDirectory); - _storagePath = Path.Combine(appDirectory, "installations.json"); - } - - public AppData Load() - { - if (!File.Exists(_storagePath)) - return new AppData(); - - var json = File.ReadAllText(_storagePath); - return JsonSerializer.Deserialize(json) ?? new AppData(); - } - - public void Save(AppData data) - { - var json = JsonSerializer.Serialize(data, new JsonSerializerOptions - { - WriteIndented = true - }); - File.WriteAllText(_storagePath, json); - } -} \ No newline at end of file diff --git a/MetaforceInstaller.Core/Services/ZipScrapper.cs b/MetaforceInstaller.Core/Services/ZipScrapper.cs deleted file mode 100644 index b5d1a32..0000000 --- a/MetaforceInstaller.Core/Services/ZipScrapper.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System.IO.Compression; -using MetaforceInstaller.Core.Models; - -namespace MetaforceInstaller.Core.Services; - -public class ZipScrapper -{ - public static InstallationParts PeekFiles(ZipArchive archive) - { - return new InstallationParts - { - AndroidContentExists = DoesAndroidContentExists(archive), - OculusClientExists = DoesOculusClientExists(archive), - PicoClientExists = DoesPicoClientExists(archive), - AndroidAdminExists = DoesAndroidAdminExists(archive), - WindowsAdminExists = DoesPcAdminExists(archive), - WindowsContentExists = DoesWindowsContentExists(archive), - WindowsServerExists = DoesServerExists(archive), - }; - // Console.WriteLine($"Contents of {archive}:"); - // Console.WriteLine("----------------------------------"); - // - // foreach (ZipArchiveEntry entry in archive.Entries) - // { - // // You can access properties like entry.Name, entry.FullName, entry.Length (uncompressed size), entry.CompressedLength - // Console.WriteLine($"Entry: {entry.FullName}"); - // Console.WriteLine($" Uncompressed Size: {entry.Length} bytes"); - // Console.WriteLine($" Compressed Size: {entry.CompressedLength} bytes"); - // Console.WriteLine("----------------------------------"); - // } - } - - public static string ExtractZip(ZipArchive archive, string outputPath) - { - archive.ExtractToDirectory(outputPath); - return outputPath; - } - - private static bool DoesPicoClientExists(ZipArchive archive) - { - return archive.Entries - .Any(entry => entry.Name.Contains("MetaforcePico") - && entry.Name.EndsWith(".apk")); - } - - private static bool DoesOculusClientExists(ZipArchive archive) - { - return archive.Entries - .Any(entry => entry.Name.Contains("MetaforceOculus") - && entry.Name.EndsWith(".apk")); - } - - private static bool DoesAndroidAdminExists(ZipArchive archive) - { - return archive.Entries - .Any(entry => entry.Name.Contains("MetaforceAdmin") - && entry.Name.EndsWith(".apk")); - } - - private static bool DoesAndroidContentExists(ZipArchive archive) - { - return archive.Entries - .Any(entry => entry.Name.Contains("Content_Android") - && entry.Name.EndsWith(".zip")); - } - - private static bool DoesWindowsContentExists(ZipArchive archive) - { - return archive.Entries - .Any(entry => entry.Name.Contains("Content_StandaloneWindows") - && entry.Name.EndsWith(".zip")); - } - - private static bool DoesPcAdminExists(ZipArchive archive) - { - return archive.Entries - .Any(entry => entry.FullName.Contains("MetaforceAdminPC") - && entry.Name.EndsWith(".exe") && !entry.Name.Contains("UnityCrashHandler") && - !entry.Name.Contains("crashpad_handler")); - } - - private static bool DoesServerExists(ZipArchive archive) - { - return archive.Entries - .Any(entry => entry.FullName.Contains("MetaforceServer") - && entry.Name.EndsWith(".exe") && !entry.Name.Contains("UnityCrashHandler") && - !entry.Name.Contains("crashpad_handler")); - } -} \ No newline at end of file diff --git a/MetaforceInstaller.UI/MainWindow.axaml b/MetaforceInstaller.UI/MainWindow.axaml index 7b8c85a..61a426d 100644 --- a/MetaforceInstaller.UI/MainWindow.axaml +++ b/MetaforceInstaller.UI/MainWindow.axaml @@ -10,11 +10,11 @@ - + - + - + @@ -22,44 +22,49 @@ - + - - + + + + + + - + + + - Install server - Install admin - Save android admin - Save VR client - - - - - - - - \ No newline at end of file diff --git a/MetaforceInstaller.UI/NewInstallationDialog.axaml.cs b/MetaforceInstaller.UI/NewInstallationDialog.axaml.cs deleted file mode 100644 index 85d5f28..0000000 --- a/MetaforceInstaller.UI/NewInstallationDialog.axaml.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System.IO.Compression; -using Avalonia.Controls; -using Avalonia.Interactivity; -using Avalonia.Platform.Storage; -using MetaforceInstaller.Core.Models; -using MetaforceInstaller.Core.Services; - -namespace MetaforceInstaller.UI; - -public partial class NewInstallationDialog : Window -{ - private string? _zipPath; - private InstallationParts? _installationParts; - - public NewInstallationDialog() - { - InitializeComponent(); - RefreshCheckboxes(); - CancelButton.Click += OnCancelClick; - ChooseZip.Click += OnChooseZipClick; - InstallButton.IsEnabled = false; - InstallButton.Click += OnInstallClick; - } - - private async void RefreshCheckboxes() - { - var serverCheckbox = ServerCheckBox; - var pcAdminCheckbox = PcAdminCheckBox; - var androidAdminCheckbox = AndroidAdminCheckbox; - var vrClientCheckbox = VrClientCheckbox; - serverCheckbox.Content = TextDefaults.InstallServer; - serverCheckbox.IsEnabled = true; - pcAdminCheckbox.Content = TextDefaults.InstallAdmin; - pcAdminCheckbox.IsEnabled = true; - androidAdminCheckbox.Content = TextDefaults.SaveAndroidAdmin; - androidAdminCheckbox.IsEnabled = true; - vrClientCheckbox.Content = TextDefaults.SaveVRClient; - vrClientCheckbox.IsEnabled = true; - } - - private async void OnChooseZipClick(object? sender, RoutedEventArgs e) - { - var topLevel = GetTopLevel(this); - var files = await topLevel!.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions - { - Title = "Выберите архив с контентом", - AllowMultiple = false, - FileTypeFilter = - [ - new FilePickerFileType("ZIP Files") - { - Patterns = ["*.zip"] - } - ] - }); - - if (files.Count >= 1) - { - _zipPath = files[0].Path.LocalPath; - using var archive = ZipFile.OpenRead(_zipPath); - _installationParts = ZipScrapper.PeekFiles(archive); - UpdateCheckboxes(); - archive.Dispose(); - } - } - - private async void OnInstallClick(object? sender, RoutedEventArgs e) - { - using var archive = ZipFile.OpenRead(_zipPath); - - } - - private void UpdateCheckboxes() - { - RefreshCheckboxes(); - var serverCheckbox = ServerCheckBox; - var pcAdminCheckbox = PcAdminCheckBox; - var androidAdminCheckbox = AndroidAdminCheckbox; - var vrClientCheckbox = VrClientCheckbox; - - if (!_installationParts.WindowsServerExists) - { - serverCheckbox.IsEnabled = false; - serverCheckbox.Content += "\nCouldn't find directory with server"; - } - - if (!_installationParts.WindowsAdminExists) - { - pcAdminCheckbox.IsEnabled = false; - pcAdminCheckbox.Content += "\nCouldn't find directory with PC admin"; - } - - if (!_installationParts.WindowsContentExists) - { - pcAdminCheckbox.IsEnabled = false; - pcAdminCheckbox.Content += "\nCouldn't find windows content"; - } - - if (!_installationParts.AndroidContentExists) - { - vrClientCheckbox.IsEnabled = false; - vrClientCheckbox.Content += "\nCouldn't find android content"; - androidAdminCheckbox.IsEnabled = false; - androidAdminCheckbox.Content += "\nCouldn't find android content"; - } - - if (!_installationParts.PicoClientExists && !_installationParts.OculusClientExists) - { - vrClientCheckbox.IsEnabled = false; - vrClientCheckbox.Content += "\nCouldn't find any VR clients"; - } - } - - private void OnCancelClick(object? sender, RoutedEventArgs e) - { - Close(); - } -} \ No newline at end of file diff --git a/MetaforceInstaller.UI/TextDefaults.cs b/MetaforceInstaller.UI/TextDefaults.cs deleted file mode 100644 index 176e1f6..0000000 --- a/MetaforceInstaller.UI/TextDefaults.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace MetaforceInstaller.UI; - -public static class TextDefaults -{ - public static readonly string InstallServer = "Install Server"; - public static readonly string InstallAdmin = "Install Admin"; - public static readonly string SaveAndroidAdmin = "Save Android admin"; - public static readonly string SaveVRClient = "Save VR client"; -} \ No newline at end of file