diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index dfe0770..0000000
--- a/.gitattributes
+++ /dev/null
@@ -1,2 +0,0 @@
-# Auto detect text files and perform LF normalization
-* text=auto
diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml
new file mode 100644
index 0000000..58bd8cb
--- /dev/null
+++ b/.github/workflows/build-linux.yml
@@ -0,0 +1,33 @@
+name: Build Linux
+
+on:
+ push:
+ branches: [ "main" ]
+ pull_request:
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: 6.0.x
+ - name: Restore dependencies
+ run: dotnet restore
+ - name: Build
+ run: dotnet build --no-restore
+ - name: Test
+ run: dotnet test --no-build --verbosity normal
+
+ - name: Publish
+ run: dotnet publish
+
+ - name: Upload WebApp1 Build Artifact
+ uses: actions/upload-artifact@v2
+ with:
+ name: CanaryLauncher
+ path: /home/runner/work/CanaryLauncherUpdate/CanaryLauncherUpdate/bin/Debug/net6.0-windows/publish/
diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml
new file mode 100644
index 0000000..f031ee4
--- /dev/null
+++ b/.github/workflows/build-windows.yml
@@ -0,0 +1,50 @@
+---
+name: Build Windows
+
+on:
+ push:
+ branches: [ "main" ]
+ pull_request:
+
+jobs:
+
+ build:
+
+ strategy:
+ matrix:
+ configuration: [Release]
+
+ runs-on: windows-latest
+
+ env:
+ Solution_Name: CanaryLauncherUpdate.csproj
+ Test_Project_Path: CanaryLauncherUpdate.csproj
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+
+ # Install the .NET Core workload
+ - name: Install .NET Core
+ uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: 6.0.x
+
+ # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
+ - name: Setup MSBuild.exe
+ uses: microsoft/setup-msbuild@v1.0.2
+
+ # Execute all unit tests in the solution
+ - name: Execute unit tests
+ run: dotnet test
+
+ - name: Publish
+ run: dotnet publish
+
+ - name: Upload Build Artifact
+ uses: actions/upload-artifact@v2
+ with:
+ name: CanaryLauncher
+ path: D:\a\CanaryLauncherUpdate\CanaryLauncherUpdate\bin\Debug\net6.0-windows\publish\
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..79313f4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+bin
+obj
+.vs
+*.user
+
+# Build results
+Properties/
+.vs/
+.obj/
diff --git a/Assets/background.jpg b/Assets/background.jpg
new file mode 100644
index 0000000..4aa34b6
Binary files /dev/null and b/Assets/background.jpg differ
diff --git a/Assets/bg_button_update.png b/Assets/bg_button_update.png
new file mode 100644
index 0000000..d2eb071
Binary files /dev/null and b/Assets/bg_button_update.png differ
diff --git a/Assets/bg_hints.png b/Assets/bg_hints.png
new file mode 100644
index 0000000..47c77ad
Binary files /dev/null and b/Assets/bg_hints.png differ
diff --git a/Assets/button_hover_play.png b/Assets/button_hover_play.png
new file mode 100644
index 0000000..a813d2d
Binary files /dev/null and b/Assets/button_hover_play.png differ
diff --git a/Assets/button_hover_update.png b/Assets/button_hover_update.png
new file mode 100644
index 0000000..1235c21
Binary files /dev/null and b/Assets/button_hover_update.png differ
diff --git a/Assets/button_play.png b/Assets/button_play.png
new file mode 100644
index 0000000..eebc273
Binary files /dev/null and b/Assets/button_play.png differ
diff --git a/Assets/button_update.png b/Assets/button_update.png
new file mode 100644
index 0000000..9d6a8fb
Binary files /dev/null and b/Assets/button_update.png differ
diff --git a/Assets/icon_play.png b/Assets/icon_play.png
new file mode 100644
index 0000000..2886648
Binary files /dev/null and b/Assets/icon_play.png differ
diff --git a/Assets/icon_update.png b/Assets/icon_update.png
new file mode 100644
index 0000000..064361a
Binary files /dev/null and b/Assets/icon_update.png differ
diff --git a/Assets/icons.xaml b/Assets/icons.xaml
new file mode 100644
index 0000000..eeb8d35
--- /dev/null
+++ b/Assets/icons.xaml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Assets/launcher_ico.png b/Assets/launcher_ico.png
new file mode 100644
index 0000000..5ea515d
Binary files /dev/null and b/Assets/launcher_ico.png differ
diff --git a/Assets/logo.png b/Assets/logo.png
new file mode 100644
index 0000000..b673e47
Binary files /dev/null and b/Assets/logo.png differ
diff --git a/Assets/logo_company.png b/Assets/logo_company.png
new file mode 100644
index 0000000..1d3d4cc
Binary files /dev/null and b/Assets/logo_company.png differ
diff --git a/Assets/rh_lore.png b/Assets/rh_lore.png
new file mode 100644
index 0000000..5e534f5
Binary files /dev/null and b/Assets/rh_lore.png differ
diff --git a/CanaryLauncher.csproj b/CanaryLauncher.csproj
new file mode 100644
index 0000000..e1d5a5f
--- /dev/null
+++ b/CanaryLauncher.csproj
@@ -0,0 +1,97 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {E21D451C-4724-4738-A716-DD441AD38747}
+ WinExe
+ CanaryLauncher
+ icon.ico
+ CanaryLauncher
+ v4.8
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ 8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CanaryLauncher.sln b/CanaryLauncher.sln
new file mode 100644
index 0000000..74d1c05
--- /dev/null
+++ b/CanaryLauncher.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.4.33205.214
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CanaryLauncher", "CanaryLauncher.csproj", "{E21D451C-4724-4738-A716-DD441AD38747}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {E21D451C-4724-4738-A716-DD441AD38747}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E21D451C-4724-4738-A716-DD441AD38747}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E21D451C-4724-4738-A716-DD441AD38747}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E21D451C-4724-4738-A716-DD441AD38747}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {F0CE66E6-7311-4CFA-8866-0B11975F833A}
+ EndGlobalSection
+EndGlobal
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b947d59
--- /dev/null
+++ b/README.md
@@ -0,0 +1,22 @@
+# ZyroniaOT - Launcher Update
+
+Laucher Update usado no projeto zyroniaot 13x.
+
+## Repositório Base:
+- Launcher Update: [Launcher](https://github.com/eightbites/client-launcher)
+
+## Requesitos:
+* C# WPF
+* .NET 6.0
+
+## Informação:
+
+* ✅ Lançador como Tibia Global
+* ✅ Baixar cliente
+* ✅ Atualização de verificação automática
+* ✅ Atualizar cliente
+* ✅ Execute o cliente
+
+## Observação:
+- Você deve configurar a url "launcher_config.json" em MainWindow.cs e SplashScreen.cs
+- Em launcher_config.json você precisa fazer as configurações necessárias para usar o launcher. (Leia a explicação de como usar cada configuração)
diff --git a/icon.ico b/icon.ico
new file mode 100644
index 0000000..5264277
Binary files /dev/null and b/icon.ico differ
diff --git a/launcher_config.json b/launcher_config.json
new file mode 100644
index 0000000..17aaca9
--- /dev/null
+++ b/launcher_config.json
@@ -0,0 +1,29 @@
+/**
+• JSON configuration file for the Client Updater
+• version The version of the client, represented as "major.minor.patch".
+• replaceFolders Whether the updater should replace the client's current folders
+• folders An array of objects representing the client's folders, each object has the key "name"
+• clientFolder The name of the main client folder, represented as "Tibia"
+NOTE: Set it to "false" or only "" to not use the client folder, so everything will be added to the main folder
+• newClientUrl The URL where the new client version can be downloaded from
+• executable The path to the client's executable file, represented as "bin/client.exe"
+*/
+{
+ "clientVersion": "13.40.54ea79",
+ "launcherVersion": "1.2",
+ "replaceFolders": true,
+ "replaceFolderName": [
+ {
+ "name": "assets"
+ },
+ {
+ "name": "storeimages"
+ },
+ {
+ "name": "bin"
+ }
+ ],
+ "clientFolder": "AzuraOT",
+ "newClientUrl" : "https://github.com/eightbites/azura-launcher/releases/download/client/client-to-update.zip",
+ "clientExecutable": "client.exe"
+}
\ No newline at end of file
diff --git a/src/App.xaml b/src/App.xaml
new file mode 100644
index 0000000..da27899
--- /dev/null
+++ b/src/App.xaml
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/App.xaml.cs b/src/App.xaml.cs
new file mode 100644
index 0000000..642ac69
--- /dev/null
+++ b/src/App.xaml.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace CanaryLauncherUpdate
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public class Program
+ {
+ [STAThread]
+ public static void Main(string[] args)
+ {
+ App app = new App();
+ app.InitializeComponent();
+ app.Run();
+ }
+ }
+}
diff --git a/src/AssemblyInfo.cs b/src/AssemblyInfo.cs
new file mode 100644
index 0000000..8b5504e
--- /dev/null
+++ b/src/AssemblyInfo.cs
@@ -0,0 +1,10 @@
+using System.Windows;
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
diff --git a/src/ClientConfig.cs b/src/ClientConfig.cs
new file mode 100644
index 0000000..0500688
--- /dev/null
+++ b/src/ClientConfig.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Windows;
+using System.Net;
+using System.IO;
+using System.Collections.Generic;
+using System.Net.Http;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+
+namespace LauncherConfig
+{
+ public class ClientConfig
+ {
+ public string clientVersion { get; set; }
+ public string launcherVersion { get; set; }
+ public bool replaceFolders { get; set; }
+ public ReplaceFolderName[] replaceFolderName { get; set; }
+ public string clientFolder { get; set; }
+ public string newClientUrl { get; set; }
+ public string newConfigUrl { get; set; }
+ public string clientExecutable { get; set; }
+
+ public static ClientConfig loadFromFile(string url)
+ {
+ using (HttpClient client = new HttpClient())
+ {
+ Task jsonTask = client.GetStringAsync(url);
+ string jsonString = jsonTask.Result;
+ return JsonConvert.DeserializeObject(jsonString);
+ }
+ }
+ }
+
+ public class ReplaceFolderName
+ {
+ public string name { get; set; }
+ }
+}
diff --git a/src/MainWindow.xaml b/src/MainWindow.xaml
new file mode 100644
index 0000000..6c6ca5c
--- /dev/null
+++ b/src/MainWindow.xaml
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Morgana Servers
+
+
+
+
+
+
+
+
+ Nos confins digitais de um vasto universo, surge uma nova estrela no firmamento dos servidores de jogos online. Morgana, um novo servidor global custom, desponta com promessas de aventuras sem igual, desafiando os limites da imaginação dos jogadores mais ávidos.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Version
+
+
+
+
+
diff --git a/src/MainWindow.xaml.cs b/src/MainWindow.xaml.cs
new file mode 100644
index 0000000..5459592
--- /dev/null
+++ b/src/MainWindow.xaml.cs
@@ -0,0 +1,341 @@
+using System;
+using System.IO;
+using System.Reflection;
+using System.Windows;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Net;
+using System.Collections.Generic;
+using System.Linq;
+using System.Diagnostics;
+using Newtonsoft.Json;
+using System.Net.Http;
+using System.Threading.Tasks;
+using Ionic.Zip;
+using LauncherConfig;
+
+namespace CanaryLauncherUpdate
+{
+ public partial class MainWindow : Window
+ {
+ static string launcerConfigUrl = "https://raw.githubusercontent.com/eightbites/azura-launcher/main/launcher_config.json";
+ // Load informations of launcher_config.json file
+ static ClientConfig clientConfig = ClientConfig.loadFromFile(launcerConfigUrl);
+
+ static string clientExecutableName = clientConfig.clientExecutable;
+ static string urlClient = clientConfig.newClientUrl;
+ static string programVersion = clientConfig.launcherVersion;
+
+ string newVersion = "";
+ bool clientDownloaded = false;
+ bool needUpdate = false;
+
+ static readonly HttpClient httpClient = new HttpClient();
+ WebClient webClient = new WebClient();
+
+ private string GetLauncherPath(bool onlyBaseDirectory = false)
+ {
+ string launcherPath = "";
+ if (string.IsNullOrEmpty(clientConfig.clientFolder) || onlyBaseDirectory) {
+ launcherPath = AppDomain.CurrentDomain.BaseDirectory.ToString();
+ } else {
+ launcherPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "/" + clientConfig.clientFolder;
+ }
+
+ return launcherPath;
+ }
+
+ public MainWindow()
+ {
+ InitializeComponent();
+ }
+
+ static void CreateShortcut()
+ {
+ string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
+ string shortcutPath = Path.Combine(desktopPath, clientConfig.clientFolder + ".lnk");
+ Type t = Type.GetTypeFromProgID("WScript.Shell");
+ dynamic shell = Activator.CreateInstance(t);
+ var lnk = shell.CreateShortcut(shortcutPath);
+ try
+ {
+ lnk.TargetPath = Assembly.GetExecutingAssembly().Location.Replace(".dll", ".exe");
+ lnk.Description = clientConfig.clientFolder;
+ lnk.Save();
+ }
+ finally
+ {
+ System.Runtime.InteropServices.Marshal.FinalReleaseComObject(lnk);
+ }
+ }
+
+ private void TibiaLauncher_Load(object sender, RoutedEventArgs e)
+ {
+ ImageLogoServer.Source = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "pack://application:,,,/Assets/logo.png"));
+ ImageLogoCompany.Source = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "pack://application:,,,/Assets/logo_company.png"));
+
+ newVersion = clientConfig.clientVersion;
+ progressbarDownload.Visibility = Visibility.Collapsed;
+ labelClientVersion.Visibility = Visibility.Collapsed;
+ labelDownloadPercent.Visibility = Visibility.Collapsed;
+
+ if (File.Exists(GetLauncherPath(true) + "/launcher_config.json"))
+ {
+ // Read actual client version
+ string actualVersion = GetClientVersion(GetLauncherPath(true));
+ labelVersion.Text = "v" + programVersion;
+
+ if (newVersion != actualVersion)
+ {
+ buttonPlay.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "pack://application:,,,/Assets/button_update.png")));
+ buttonPlayIcon.Source = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "pack://application:,,,/Assets/icon_update.png"));
+ labelClientVersion.Content = newVersion;
+ labelClientVersion.Visibility = Visibility.Visible;
+ buttonPlay.Visibility = Visibility.Visible;
+ buttonPlay_tooltip.Text = "Update";
+ needUpdate = true;
+ }
+ }
+ if (!File.Exists(GetLauncherPath(true) + "/launcher_config.json") || Directory.Exists(GetLauncherPath()) && Directory.GetFiles(GetLauncherPath()).Length == 0 && Directory.GetDirectories(GetLauncherPath()).Length == 0)
+ {
+ labelVersion.Text = "v" + programVersion;
+ buttonPlay.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "pack://application:,,,/Assets/button_update.png")));
+ buttonPlayIcon.Source = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "pack://application:,,,/Assets/icon_update.png"));
+ labelClientVersion.Content = "Download";
+ labelClientVersion.Visibility = Visibility.Visible;
+ buttonPlay.Visibility = Visibility.Visible;
+ buttonPlay_tooltip.Text = "Download";
+ needUpdate = true;
+ }
+ }
+
+ static string GetClientVersion(string path)
+ {
+ string json = path + "/launcher_config.json";
+ StreamReader stream = new StreamReader(json);
+ dynamic jsonString = stream.ReadToEnd();
+ dynamic versionclient = JsonConvert.DeserializeObject(jsonString);
+ foreach (string version in versionclient)
+ {
+ return version;
+ }
+
+ return "";
+ }
+
+ private void AddReadOnly()
+ {
+ // If the files "eventschedule/boostedcreature/onlinenumbers" exist, set them as read-only
+ string eventSchedulePath = GetLauncherPath() + "/cache/eventschedule.json";
+ if (File.Exists(eventSchedulePath)) {
+ File.SetAttributes(eventSchedulePath, FileAttributes.ReadOnly);
+ }
+ string boostedCreaturePath = GetLauncherPath() + "/cache/boostedcreature.json";
+ if (File.Exists(boostedCreaturePath)) {
+ File.SetAttributes(boostedCreaturePath, FileAttributes.ReadOnly);
+ }
+ string onlineNumbersPath = GetLauncherPath() + "/cache/onlinenumbers.json";
+ if (File.Exists(onlineNumbersPath)) {
+ File.SetAttributes(onlineNumbersPath, FileAttributes.ReadOnly);
+ }
+ }
+
+ private void UpdateClient()
+ {
+ if (!Directory.Exists(GetLauncherPath(true)))
+ {
+ Directory.CreateDirectory(GetLauncherPath());
+ }
+ labelDownloadPercent.Visibility = Visibility.Visible;
+ progressbarDownload.Visibility = Visibility.Visible;
+ labelClientVersion.Visibility = Visibility.Collapsed;
+ buttonPlay.Visibility = Visibility.Collapsed;
+ webClient.DownloadProgressChanged += Client_DownloadProgressChanged;
+ webClient.DownloadFileCompleted += Client_DownloadFileCompleted;
+ webClient.DownloadFileAsync(new Uri(urlClient), GetLauncherPath() + "/tibia.zip");
+ }
+
+ private void buttonPlay_Click(object sender, RoutedEventArgs e)
+ {
+ if (needUpdate == true || !Directory.Exists(GetLauncherPath()))
+ {
+ try
+ {
+ UpdateClient();
+ }
+ catch (Exception ex)
+ {
+ labelVersion.Text = ex.ToString();
+ }
+ }
+ else
+ {
+ if (clientDownloaded == true || !Directory.Exists(GetLauncherPath(true)))
+ {
+ Process.Start(GetLauncherPath() + "/bin/" + clientExecutableName);
+ this.Close();
+ }
+ else
+ {
+ try
+ {
+ UpdateClient();
+ }
+ catch (Exception ex)
+ {
+ labelVersion.Text = ex.ToString();
+ }
+ }
+ }
+ }
+
+ private void ExtractZip(string path, ExtractExistingFileAction existingFileAction)
+ {
+ using (ZipFile modZip = ZipFile.Read(path))
+ {
+ foreach (ZipEntry zipEntry in modZip)
+ {
+ zipEntry.Extract(GetLauncherPath(), existingFileAction);
+ }
+ }
+ }
+
+ private async void Client_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
+ {
+ buttonPlay.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "pack://application:,,,/Assets/button_play.png")));
+ buttonPlayIcon.Source = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "pack://application:,,,/Assets/icon_play.png"));
+
+ if (clientConfig.replaceFolders)
+ {
+ foreach (ReplaceFolderName folderName in clientConfig.replaceFolderName)
+ {
+ string folderPath = Path.Combine(GetLauncherPath(), folderName.name);
+ if (Directory.Exists(folderPath))
+ {
+ Directory.Delete(folderPath, true);
+ }
+ }
+ }
+
+ // Adds the task to a secondary task to prevent the program from crashing while this is running
+ await Task.Run(() =>
+ {
+ Directory.CreateDirectory(GetLauncherPath());
+ ExtractZip(GetLauncherPath() + "/tibia.zip", ExtractExistingFileAction.OverwriteSilently);
+ File.Delete(GetLauncherPath() + "/tibia.zip");
+ });
+ progressbarDownload.Value = 100;
+
+ // Download launcher_config.json from url to the launcher path
+ WebClient webClient = new WebClient();
+ string localPath = Path.Combine(GetLauncherPath(true), "launcher_config.json");
+ webClient.DownloadFile(launcerConfigUrl, localPath);
+
+ AddReadOnly();
+ CreateShortcut();
+
+ needUpdate = false;
+ clientDownloaded = true;
+ labelClientVersion.Content = GetClientVersion(GetLauncherPath(true));
+ buttonPlay_tooltip.Text = GetClientVersion(GetLauncherPath(true));
+ labelClientVersion.Visibility = Visibility.Visible;
+ buttonPlay.Visibility = Visibility.Visible;
+ progressbarDownload.Visibility = Visibility.Collapsed;
+ labelDownloadPercent.Visibility = Visibility.Collapsed;
+ }
+
+ private void Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
+ {
+ progressbarDownload.Value = e.ProgressPercentage;
+ if (progressbarDownload.Value == 100) {
+ labelDownloadPercent.Content = "Finishing, wait...";
+ } else {
+ labelDownloadPercent.Content = SizeSuffix(e.BytesReceived) + " / " + SizeSuffix(e.TotalBytesToReceive);
+ }
+ }
+
+ static readonly string[] SizeSuffixes = { "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
+ static string SizeSuffix(Int64 value, int decimalPlaces = 1)
+ {
+ if (decimalPlaces < 0) { throw new ArgumentOutOfRangeException("decimalPlaces"); }
+ if (value < 0) { return "-" + SizeSuffix(-value, decimalPlaces); }
+ if (value == 0) { return string.Format("{0:n" + decimalPlaces + "} bytes", 0); }
+
+ int mag = (int)Math.Log(value, 1024);
+ decimal adjustedSize = (decimal)value / (1L << (mag * 10));
+
+ if (Math.Round(adjustedSize, decimalPlaces) >= 1000)
+ {
+ mag += 1;
+ adjustedSize /= 1024;
+ }
+ return string.Format("{0:n" + decimalPlaces + "} {1}",
+ adjustedSize,
+ SizeSuffixes[mag]);
+ }
+
+ private void buttonPlay_MouseEnter(object sender, MouseEventArgs e)
+ {
+ if (File.Exists(GetLauncherPath() + "/launcher_config.json"))
+ {
+ string actualVersion = GetClientVersion(GetLauncherPath(true));
+ if (newVersion != actualVersion)
+ {
+ buttonPlay.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "pack://application:,,,/Assets/button_hover_update.png")));
+ }
+ if (newVersion == actualVersion)
+ {
+ buttonPlay.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "pack://application:,,,/Assets/button_hover_play.png")));
+ }
+ }
+ else
+ {
+ buttonPlay.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "pack://application:,,,/Assets/button_hover_update.png")));
+ }
+ }
+
+ private void buttonPlay_MouseLeave(object sender, MouseEventArgs e)
+ {
+ if (File.Exists(GetLauncherPath(true) + "/launcher_config.json"))
+ {
+ string actualVersion = GetClientVersion(GetLauncherPath(true));
+ if (newVersion != actualVersion)
+ {
+ buttonPlay.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "pack://application:,,,/Assets/button_update.png")));
+ }
+ if (newVersion == actualVersion)
+ {
+ buttonPlay.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "pack://application:,,,/Assets/button_play.png")));
+ }
+ }
+ else
+ {
+ buttonPlay.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "pack://application:,,,/Assets/button_update.png")));
+ }
+ }
+
+ private void CloseButton_Click(object sender, RoutedEventArgs e)
+ {
+ Close();
+ }
+
+ private void RestoreButton_Click(object sender, RoutedEventArgs e)
+ {
+ if (ResizeMode != ResizeMode.NoResize)
+ {
+ if (WindowState == WindowState.Normal)
+ WindowState = WindowState.Maximized;
+ else
+ WindowState = WindowState.Normal;
+ }
+ }
+
+ private void MinimizeButton_Click(object sender, RoutedEventArgs e)
+ {
+ WindowState = WindowState.Minimized;
+ }
+
+ }
+}
diff --git a/src/SplashScreen.xaml b/src/SplashScreen.xaml
new file mode 100644
index 0000000..e0ef0c5
--- /dev/null
+++ b/src/SplashScreen.xaml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
diff --git a/src/SplashScreen.xaml.cs b/src/SplashScreen.xaml.cs
new file mode 100644
index 0000000..5944532
--- /dev/null
+++ b/src/SplashScreen.xaml.cs
@@ -0,0 +1,106 @@
+using System;
+using System.Windows;
+using System.IO;
+using System.Net;
+using System.Windows.Threading;
+using System.Net.Http;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.IO.Compression;
+using System.Diagnostics;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+using LauncherConfig;
+
+namespace CanaryLauncherUpdate
+{
+ public partial class SplashScreen : Window
+ {
+ static string launcerConfigUrl = "https://raw.githubusercontent.com/eightbites/azura-launcher/main/launcher_config.json";
+ // Load informations of launcher_config.json file
+ static ClientConfig clientConfig = ClientConfig.loadFromFile(launcerConfigUrl);
+
+ static string clientExecutableName = clientConfig.clientExecutable;
+ static string urlClient = clientConfig.newClientUrl;
+
+ static readonly HttpClient httpClient = new HttpClient();
+ DispatcherTimer timer = new DispatcherTimer();
+
+ private string GetLauncherPath(bool onlyBaseDirectory = false)
+ {
+ string launcherPath = "";
+ if (string.IsNullOrEmpty(clientConfig.clientFolder) || onlyBaseDirectory) {
+ launcherPath = AppDomain.CurrentDomain.BaseDirectory.ToString();
+ } else {
+ launcherPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "/" + clientConfig.clientFolder;
+ }
+
+ return launcherPath;
+ }
+
+ static string GetClientVersion(string path)
+ {
+ string json = path + "/launcher_config.json";
+ StreamReader stream = new StreamReader(json);
+ dynamic jsonString = stream.ReadToEnd();
+ dynamic versionclient = JsonConvert.DeserializeObject(jsonString);
+ foreach (string version in versionclient)
+ {
+ return version;
+ }
+
+ return "";
+ }
+
+ private void StartClient()
+ {
+ if (File.Exists(GetLauncherPath() + "/bin/" + clientExecutableName)) {
+ Process.Start(GetLauncherPath() + "/bin/" + clientExecutableName);
+ this.Close();
+ }
+ }
+
+ public SplashScreen()
+ {
+ string newVersion = clientConfig.clientVersion;
+ if (newVersion == null)
+ {
+ this.Close();
+ }
+
+ // Start the client if the versions are the same
+ if (File.Exists(GetLauncherPath(true) + "/launcher_config.json")) {
+ string actualVersion = GetClientVersion(GetLauncherPath(true));
+ if (newVersion == actualVersion && Directory.Exists(GetLauncherPath()) ) {
+ StartClient();
+ }
+ }
+
+ InitializeComponent();
+ timer.Tick += new EventHandler(timer_SplashScreen);
+ timer.Interval = new TimeSpan(0, 0, 5);
+ timer.Start();
+ }
+
+ public async void timer_SplashScreen(object sender, EventArgs e)
+ {
+ var requestClient = new HttpRequestMessage(HttpMethod.Post, urlClient);
+ var response = await httpClient.SendAsync(requestClient);
+ if (response.StatusCode == HttpStatusCode.NotFound)
+ {
+ this.Close();
+ }
+
+ if (!Directory.Exists(GetLauncherPath()))
+ {
+ Directory.CreateDirectory(GetLauncherPath());
+ }
+ MainWindow mainWindow = new MainWindow();
+ this.Close();
+ mainWindow.Show();
+ timer.Stop();
+ }
+ }
+}