mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-07-05 03:54:20 +00:00
Added new PCK-Studio Updater (#20)
* Added PCK-Studio-Updater project * Updated PCK-Studio-Updater to be a standanlone executable and added checkbox for using beta builds in the settings panel * Rename constant define '_NOT_DEBUG' to 'NDEBUG' and moved it to .csproj file
This commit is contained in:
@@ -1,21 +1,36 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using PckStudio.Classes.Misc;
|
||||
using PckStudio.Internal;
|
||||
using PckStudio.Properties;
|
||||
using PCKStudio_Updater;
|
||||
|
||||
|
||||
namespace PckStudio
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
public static readonly string ProjectUrl = "https://github.com/PhoenixARC/-PCK-Studio";
|
||||
public static readonly string BaseAPIUrl = "http://api.pckstudio.xyz/api/pck";
|
||||
public static readonly string BackUpAPIUrl = "https://raw.githubusercontent.com/PhoenixARC/pckstudio.tk/main/studio/PCK/api/";
|
||||
public static readonly string AppData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Application.ProductName);
|
||||
public static readonly string AppDataCache = Path.Combine(AppData, "cache");
|
||||
internal static readonly Uri ProjectUrl = new Uri("https://github.com/PhoenixARC/-PCK-Studio");
|
||||
internal static readonly string BaseAPIUrl = "http://api.pckstudio.xyz/api/pck";
|
||||
internal static readonly string BackUpAPIUrl = "https://raw.githubusercontent.com/PhoenixARC/pckstudio.tk/main/studio/PCK/api/";
|
||||
|
||||
public static MainForm MainInstance { get; private set; }
|
||||
internal static readonly string AppData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Application.ProductName);
|
||||
internal static readonly string AppDataCache = Path.Combine(AppData, "cache");
|
||||
|
||||
private static readonly GithubParams UpdateParams = new GithubParams(
|
||||
Path.GetDirectoryName(ProjectUrl.AbsolutePath).Replace("\\", ""),
|
||||
Path.GetFileName(ProjectUrl.AbsolutePath),
|
||||
Application.ProductName,
|
||||
Settings.Default.UsePrerelease,
|
||||
new Regex("(\\*|\\d+(\\.\\d+){0,3}(\\.\\*)?)")
|
||||
);
|
||||
internal static readonly IUpdateDownloader Updater = new GithubUpdateDownloader(UpdateParams);
|
||||
|
||||
|
||||
internal static MainForm MainInstance { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
@@ -23,6 +38,11 @@ namespace PckStudio
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (Settings.Default.AutoUpdate)
|
||||
{
|
||||
UpdateToLatest("Click Ok to continue.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, DialogResult.OK);
|
||||
}
|
||||
|
||||
ApplicationScope.Initialize();
|
||||
Trace.TraceInformation("Startup");
|
||||
RPC.Initialize();
|
||||
@@ -32,5 +52,21 @@ namespace PckStudio
|
||||
Application.ApplicationExit += (sender, e) => { RPC.Deinitialize(); };
|
||||
Application.Run(MainInstance);
|
||||
}
|
||||
|
||||
[Conditional("NDEBUG")]
|
||||
internal static void UpdateToLatest(string message, MessageBoxButtons buttons, MessageBoxIcon icon, DialogResult dialogResult)
|
||||
{
|
||||
bool updateAvailable = Updater.IsUpdateAvailable(Application.ProductVersion);
|
||||
if (updateAvailable && MessageBox.Show(
|
||||
"New update available.\n" +
|
||||
message,
|
||||
"Update Available",
|
||||
buttons, icon, MessageBoxDefaultButton.Button1) == dialogResult)
|
||||
{
|
||||
Updater.DownloadTo(new DirectoryInfo(Application.StartupPath));
|
||||
Updater.Launch();
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user