diff --git a/Client Launcher/Client Launcher.csproj b/Client Launcher/Client Launcher.csproj deleted file mode 100644 index 9c74c9de..00000000 --- a/Client Launcher/Client Launcher.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - Exe - net5.0 - Client_Launcher - - - diff --git a/Client Launcher/Program.cs b/Client Launcher/Program.cs deleted file mode 100644 index c7999c7c..00000000 --- a/Client Launcher/Program.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace Client_Launcher -{ - class Program - { - static void Main(string[] args) - { - Console.WriteLine("Hello World!"); - } - } -} diff --git a/ClientLauncher/ClientLauncher.csproj b/ClientLauncher/ClientLauncher.csproj index 20827042..41f1d5ad 100644 --- a/ClientLauncher/ClientLauncher.csproj +++ b/ClientLauncher/ClientLauncher.csproj @@ -2,7 +2,7 @@ Exe - net5.0 + net6.0 diff --git a/ClientLauncher/Program.cs b/ClientLauncher/Program.cs index 8e40d0ec..59ff33c8 100644 --- a/ClientLauncher/Program.cs +++ b/ClientLauncher/Program.cs @@ -83,6 +83,10 @@ static void Main(string[] args) processUtil.OutputReceived += (s, e) => Console.WriteLine(e); processUtil.StartWithEvents(); proc.WaitForExit(); + if (logs == "True") + { + Console.ReadLine(); + } } static string GetEnviromentVar(string variableName) { diff --git a/Package/Package.appxmanifest b/Package/Package.appxmanifest index a4c3ed5b..a3421224 100644 --- a/Package/Package.appxmanifest +++ b/Package/Package.appxmanifest @@ -11,7 +11,7 @@ + Version="0.3.7.0" /> SD Launcher diff --git a/Package/Package.wapproj b/Package/Package.wapproj index 0504036d..d32f41f9 100644 --- a/Package/Package.wapproj +++ b/Package/Package.wapproj @@ -59,7 +59,7 @@ True DB967EAAD2582A102C63D11D80EB102BA467810C SHA256 - True + False True x86|x64|arm|arm64 C:\ diff --git a/SDLauncher UWP/App.xaml b/SDLauncher UWP/App.xaml index 9491c7ef..f02eee77 100644 --- a/SDLauncher UWP/App.xaml +++ b/SDLauncher UWP/App.xaml @@ -10,12 +10,19 @@ - /Fonts/Pixeboy.ttf#Pixeboy - + + + + /Fonts/Pixeboy.ttf#Pixeboy + diff --git a/SDLauncher UWP/DataTemplates/ServerTemplate.cs b/SDLauncher UWP/DataTemplates/ServerTemplate.cs new file mode 100644 index 00000000..f211837e --- /dev/null +++ b/SDLauncher UWP/DataTemplates/ServerTemplate.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; +using Windows.UI.Xaml.Media.Imaging; +using SDLauncher_UWP.Helpers; + +namespace SDLauncher_UWP.DataTemplates +{ + public class ServerTemplate : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged = delegate { }; + //server + private string server; + public string Server { get => server; private set { server = value; OnPropertyChanged(); UpdateStatus(); } } + //Vers + private string ver; + public string Versions { get => ver; set { ver = value; OnPropertyChanged(); } } + //port + private int port; + public int Port { get => port; private set { port = value; OnPropertyChanged(); UpdateStatus(); } } + //max players + private int maxPlayers; + public int MaxPlayers { get => maxPlayers; private set { maxPlayers = value; OnPropertyChanged(); } } + //online players + private int minPlayers; + public int OnlinePlayers { get => minPlayers; private set { minPlayers = value; OnPropertyChanged(); } } + //favicon + private string favicon; + public string Favicon { get => favicon; private set { favicon = value; OnPropertyChanged(); } } + + public ServerTemplate(string server, int port) + { + Server = server; + Port = port; + UpdateStatus(); + } + + public async void UpdateStatus() + { + try + { + var status = ServerStatusJSONConverter.Convert(await Util.DownloadText("https://api.mcstatus.io/status/java/" + Server.Trim() + ":" + Port.ToString())); + if (status.online) + { + server = status.host; + port = status.port; + MaxPlayers = status.response.players.max; + Versions = status.response.version.name; + OnlinePlayers = status.response.players.online; + OnPropertyChanged(); + Favicon = status.response.favicon; + } + } + catch (Exception) + { + + } + } + private void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/SDLauncher UWP/Dialogs/Login.xaml b/SDLauncher UWP/Dialogs/Login.xaml index 0abffb11..f9dc090e 100644 --- a/SDLauncher UWP/Dialogs/Login.xaml +++ b/SDLauncher UWP/Dialogs/Login.xaml @@ -103,7 +103,7 @@ - + + + + + diff --git a/SDLauncher UWP/Dialogs/ServerChooserDialog.xaml.cs b/SDLauncher UWP/Dialogs/ServerChooserDialog.xaml.cs new file mode 100644 index 00000000..1fc1a091 --- /dev/null +++ b/SDLauncher UWP/Dialogs/ServerChooserDialog.xaml.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; +using SDLauncher_UWP.DataTemplates; +using System.Collections.ObjectModel; +// The Content Dialog item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 + +namespace SDLauncher_UWP.Dialogs +{ + public sealed partial class ServerChooserDialog : ContentDialog + { + public ObservableCollection servers = new ObservableCollection(); + public ServerChooserDialog() + { + this.InitializeComponent(); + servers.Add(new ServerTemplate("mc.hypixel.net", 25565)); + view.ItemsSource = servers; + } + + private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) + { + } + + private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) + { + } + } +} diff --git a/SDLauncher UWP/Helpers/Account.cs b/SDLauncher UWP/Helpers/Account.cs index 7bd6717e..63ed0051 100644 --- a/SDLauncher UWP/Helpers/Account.cs +++ b/SDLauncher UWP/Helpers/Account.cs @@ -37,9 +37,9 @@ public Account(string username, string type, string accesstoken, string uuid, in { IsCheckboxVsible = Visibility.Collapsed; IsChecked = false; - PicList.Add("https://raw.githubusercontent.com/Chaniru22/SDLauncher/main/Pictures/steve.png"); - PicList.Add("https://raw.githubusercontent.com/Chaniru22/SDLauncher/main/Pictures/NoobSteve.png"); - PicList.Add("https://raw.githubusercontent.com/Chaniru22/SDLauncher/main/Pictures/alex.png"); + PicList.Add("https://github.com/SeaDevTeam/SDLauncher/raw/main/Pictures/steve.png"); + PicList.Add("https://github.com/SeaDevTeam/SDLauncher/raw/main/Pictures/NoobSteve.png"); + PicList.Add("https://github.com/SeaDevTeam/SDLauncher/raw/main/Pictures/alex.png"); if (pic == null) { Random r = new Random(); diff --git a/SDLauncher UWP/Helpers/OptiFine.cs b/SDLauncher UWP/Helpers/OptiFine.cs index 087b38d3..9d56d7e7 100644 --- a/SDLauncher UWP/Helpers/OptiFine.cs +++ b/SDLauncher UWP/Helpers/OptiFine.cs @@ -68,22 +68,22 @@ public void DownloadOptiFineVer(string mcver, string modVer, string DisplayVer) case "1.18.2": returns = new OptFineVerReturns(modVer, mcver, DisplayVer, OptFineVerReturns.Results.DownloadOptiFineVer); optver = ": " + mcver; - OptFineDownload("https://raw.githubusercontent.com/Chaniru22/SDLauncher/main/OptiFine-1.18.2.zip", "OptiFine-" + mcver + ".zip", ModType.ver); + OptFineDownload("https://github.com/SeaDevTeam/SDLauncher/raw/main/OptiFine-1.18.2.zip", "OptiFine-" + mcver + ".zip", ModType.ver); break; case "1.18.1": returns = new OptFineVerReturns(modVer, mcver, DisplayVer, OptFineVerReturns.Results.DownloadOptiFineVer); optver = ": " + mcver; - OptFineDownload("https://raw.githubusercontent.com/Chaniru22/SDLauncher/main/OptiFine-1.18.1.zip", "OptiFine-" + mcver + ".zip", ModType.ver); + OptFineDownload("https://github.com/SeaDevTeam/SDLauncher/raw/main/OptiFine-1.18.1.zip", "OptiFine-" + mcver + ".zip", ModType.ver); break; case "1.17.1": returns = new OptFineVerReturns(modVer, mcver, DisplayVer, OptFineVerReturns.Results.DownloadOptiFineVer); optver = ": " + mcver; - OptFineDownload("https://raw.githubusercontent.com/Chaniru22/SDLauncher/main/OptiFine-1.17.1.zip", "OptiFine-" + mcver + ".zip", ModType.ver); + OptFineDownload("https://github.com/SeaDevTeam/SDLauncher/raw/main/OptiFine-1.17.1.zip", "OptiFine-" + mcver + ".zip", ModType.ver); break; case "1.16.5": returns = new OptFineVerReturns(modVer, mcver, DisplayVer, OptFineVerReturns.Results.DownloadOptiFineVer); optver = ": " + mcver; - OptFineDownload("https://raw.githubusercontent.com/Chaniru22/SDLauncher/main/OptiFine-1.16.5.zip", "OptiFine-" + mcver + ".zip", ModType.ver); + OptFineDownload("https://github.com/SeaDevTeam/SDLauncher/raw/main/OptiFine-1.16.5.zip", "OptiFine-" + mcver + ".zip", ModType.ver); break; } } @@ -129,7 +129,7 @@ public async Task CheckOptiFine(string mcver, string modVer, await MessageBox.Show("Information", "This will download main OptiFine library, Please click again " + DisplayVer + " (after download and extract the main OptiFine) to install optifine of that version !", MessageBoxButtons.Ok); optver = " Lib"; returns = new OptFineVerReturns(modVer, mcver, "Version", OptFineVerReturns.Results.DownloadOptiFineLib); - OptFineDownload("https://raw.githubusercontent.com/Chaniru22/SDLauncher/main/optifine.zip", "OptiFine.zip", ModType.lib); + OptFineDownload("https://github.com/SeaDevTeam/SDLauncher/raw/main/optifine.zip", "OptiFine.zip", ModType.lib); UIChangedReqested(true, new EventArgs()); return returns; } diff --git a/SDLauncher UWP/Helpers/ServerStatusInfo.cs b/SDLauncher UWP/Helpers/ServerStatusInfo.cs new file mode 100644 index 00000000..26d545a8 --- /dev/null +++ b/SDLauncher UWP/Helpers/ServerStatusInfo.cs @@ -0,0 +1,66 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SDLauncher_UWP.Helpers +{ + public static class ServerStatusJSONConverter + { + public static ServerStatusInfo.Root Convert(string json) + { + return JsonConvert.DeserializeObject(json); + } + } + public class ServerStatusInfo + { + + public class Root + { + public bool online { get; set; } + public string host { get; set; } + public int port { get; set; } + public Response response { get; set; } + } + + public class Response + { + public Version version { get; set; } + public Players players { get; set; } + public Motd motd { get; set; } + public string favicon { get; set; } + public Srv_Record srv_record { get; set; } + } + + public class Version + { + public string name { get; set; } + public int protocol { get; set; } + } + + public class Players + { + public int online { get; set; } + public int max { get; set; } + public object[] sample { get; set; } + } + + public class Motd + { + public string raw { get; set; } + public string clean { get; set; } + public string html { get; set; } + } + + public class Srv_Record + { + public string host { get; set; } + public int port { get; set; } + } + + } + + +} diff --git a/SDLauncher UWP/Helpers/SettingsDataManager.cs b/SDLauncher UWP/Helpers/SettingsDataManager.cs index 5dc20da9..7525c065 100644 --- a/SDLauncher UWP/Helpers/SettingsDataManager.cs +++ b/SDLauncher UWP/Helpers/SettingsDataManager.cs @@ -99,6 +99,7 @@ public async Task CreateSettingsFile(bool? Exit) writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteStartElement("App"); + writer.WriteAttributeString("AutoClose", vars.AutoClose.ToString()); writer.WriteComment("\n The theme and background of the app"); writer.WriteStartElement("Appearance"); writer.WriteAttributeString("CustomBackgroundImagePath", vars.BackgroundImagePath.ToString()); @@ -164,6 +165,7 @@ public async Task LoadSettingsFile() string jvmFullScreen; string isCustombg; string BGPath; + string autoClose; using (IRandomAccessStream stream = await storagefile.OpenAsync(FileAccessMode.Read)) { Stream s = stream.AsStreamForRead(); @@ -186,6 +188,7 @@ public async Task LoadSettingsFile() jvmFullScreen = reader.GetAttribute("FullScreen"); gamelogs = reader.GetAttribute("GameLogs"); reader.ReadToFollowing("App"); + autoClose = reader.GetAttribute("AutoClose"); reader.ReadToFollowing("Appearance"); theme = reader.GetAttribute("Theme"); isCustombg = reader.GetAttribute("UseCustomBackgroundImage"); @@ -305,90 +308,24 @@ public async Task LoadSettingsFile() { vars.Theme = ElementTheme.Light; } - else if (theme == "Dark") - { - vars.Theme = ElementTheme.Dark; - } else { - vars.Theme = ElementTheme.Default; + vars.Theme = theme == "Dark" ? (ElementTheme?)ElementTheme.Dark : (ElementTheme?)ElementTheme.Default; } if (Window.Current.Content is FrameworkElement fe) { fe.RequestedTheme = (ElementTheme)vars.Theme; } - if (tips == "True") - { - vars.ShowTips = true; - } - else - { - vars.ShowTips = false; - } - if (hashcheck == "True") - { - vars.HashCheck = true; - } - else - { - vars.HashCheck = false; - } - if (oldVer == "True") - { - vars.UseOldVerSeletor = true; - } - else - { - vars.UseOldVerSeletor = false; - } - if (isCustombg == "True") - { - vars.CustomBackground = true; - } - else - { - vars.CustomBackground = false; - } - if (gamelogs == "True") - { - vars.GameLogs = true; - } - else - { - vars.GameLogs = false; - } - if (assetscheck == "True") - { - vars.AssestsCheck = true; - } - else - { - vars.AssestsCheck = false; - } - if (autolog == "True") - { - vars.autoLog = true; - } - else - { - vars.autoLog = false; - } - if (fixDiscord == "True") - { - vars.IsFixedDiscord = true; - } - else - { - vars.IsFixedDiscord = false; - } - if (jvmFullScreen == "True") - { - vars.FullScreen = true; - } - else - { - vars.FullScreen = false; - } + vars.ShowTips = tips == "True"; + vars.HashCheck = hashcheck == "True"; + vars.UseOldVerSeletor = oldVer == "True"; + vars.AutoClose = autoClose == "True"; + vars.CustomBackground = isCustombg == "True"; + vars.GameLogs = gamelogs == "True"; + vars.AssestsCheck = assetscheck == "True"; + vars.autoLog = autolog == "True"; + vars.IsFixedDiscord = fixDiscord == "True"; + vars.FullScreen = jvmFullScreen == "True"; if (vars.autoLog) { foreach (var item in vars.Accounts) diff --git a/SDLauncher UWP/Helpers/Util.cs b/SDLauncher UWP/Helpers/Util.cs index a322e811..acc9bdd9 100644 --- a/SDLauncher UWP/Helpers/Util.cs +++ b/SDLauncher UWP/Helpers/Util.cs @@ -15,6 +15,28 @@ namespace SDLauncher_UWP.Helpers { public class Util { + public static BitmapImage Base64StringToBitmap(string base64String) + { + byte[] byteBuffer = Convert.FromBase64String(base64String); + MemoryStream memoryStream = new MemoryStream(byteBuffer); + memoryStream.Position = 0; + BitmapImage bitmapImage = new BitmapImage(); + bitmapImage.SetSource(memoryStream.AsRandomAccessStream()); + + memoryStream.Close(); + memoryStream = null; + byteBuffer = null; + + return bitmapImage; + } + + public static async Task DownloadText(string url) + { + var c = new System.Net.WebClient(); + var s = await c.DownloadStringTaskAsync(new Uri(url)); + return s; + } + public static async Task LoadImage(StorageFile file) { BitmapImage bitmapImage = new BitmapImage(); @@ -25,27 +47,22 @@ public static async Task LoadImage(StorageFile file) return bitmapImage; } - public long? GetMemoryMb() + public static int? GetMemoryMb() { try { var diagnosticInfo = SystemDiagnosticInfo.GetForCurrentSystem(); SystemMemoryUsageReport systemMemoryUsageReport = SystemDiagnosticInfo.GetForCurrentSystem().MemoryUsage.GetReport(); - //ulong totalMemory = diagnosticInfo.MemoryUsage.GetReport().TotalPhysicalSizeInBytes; - ulong totalMemory = systemMemoryUsageReport.TotalPhysicalSizeInBytes; - return (long?)(totalMemory / 1000000); + long memkb = Convert.ToInt64(systemMemoryUsageReport.TotalPhysicalSizeInBytes); + //Debug.WriteLine(Convert.ToInt32((memkb / Math.Pow(1024, 3) + 0.5)) + " GB of RAM installed."); + return Convert.ToInt32(memkb / Math.Pow(1024, 3) + 0.5); } catch { return null; } } - public bool CheckInternet() - { - bool result = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable(); - return result; - } } public class IniFile // revision 11 diff --git a/SDLauncher UWP/Package.appxmanifest b/SDLauncher UWP/Package.appxmanifest index dab5773c..d9fa8187 100644 --- a/SDLauncher UWP/Package.appxmanifest +++ b/SDLauncher UWP/Package.appxmanifest @@ -54,7 +54,6 @@ - diff --git a/SDLauncher UWP/Resources/AcrylicButton.xaml b/SDLauncher UWP/Resources/AcrylicButton.xaml new file mode 100644 index 00000000..b638cf82 --- /dev/null +++ b/SDLauncher UWP/Resources/AcrylicButton.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/SDLauncher UWP/SDLauncher UWP.csproj b/SDLauncher UWP/SDLauncher UWP.csproj index 89551200..aaee000c 100644 --- a/SDLauncher UWP/SDLauncher UWP.csproj +++ b/SDLauncher UWP/SDLauncher UWP.csproj @@ -130,15 +130,20 @@ + Login.xaml + + ServerChooserDialog.xaml + + @@ -243,6 +248,14 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/SDLauncher UWP/UserControls/ArgumentsListView.xaml.cs b/SDLauncher UWP/UserControls/ArgumentsListView.xaml.cs index 26249b24..dca23f1b 100644 --- a/SDLauncher UWP/UserControls/ArgumentsListView.xaml.cs +++ b/SDLauncher UWP/UserControls/ArgumentsListView.xaml.cs @@ -51,6 +51,7 @@ public void UpdateSource() private void RefreshView() { view.ItemsSource = null; + UpdateMainSource(); view.ItemsSource = source; } private void UpdateMainSource() diff --git a/SDLauncher UWP/Views/BaseLauncherPage.xaml b/SDLauncher UWP/Views/BaseLauncherPage.xaml index 2c0df56a..9069213d 100644 --- a/SDLauncher UWP/Views/BaseLauncherPage.xaml +++ b/SDLauncher UWP/Views/BaseLauncherPage.xaml @@ -9,7 +9,9 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:animatedvisuals="using:Microsoft.UI.Xaml.Controls.AnimatedVisuals" mc:Ignorable="d"> - + + + @@ -106,7 +108,7 @@ -