mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-08-02 16:01:15 +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:
22
PCK-Studio-Updater/API/GithubParams.cs
Normal file
22
PCK-Studio-Updater/API/GithubParams.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace PCKStudio_Updater
|
||||
{
|
||||
public sealed class GithubParams
|
||||
{
|
||||
public readonly string RepositoryOwnerName;
|
||||
public readonly string RepositoryName;
|
||||
public readonly string TargetExecutableName;
|
||||
public readonly bool UsePreRelease;
|
||||
public readonly Regex VersionMatcher;
|
||||
|
||||
public GithubParams(string repositoryOwnerName, string repositoryName, string targetExecutableName, bool usePreRelease, Regex versionMatcher)
|
||||
{
|
||||
RepositoryOwnerName = repositoryOwnerName;
|
||||
RepositoryName = repositoryName;
|
||||
TargetExecutableName = targetExecutableName;
|
||||
UsePreRelease = usePreRelease;
|
||||
VersionMatcher = versionMatcher;
|
||||
}
|
||||
}
|
||||
}
|
||||
148
PCK-Studio-Updater/API/GithubUpdateDownloader.cs
Normal file
148
PCK-Studio-Updater/API/GithubUpdateDownloader.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO.Compression;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
|
||||
namespace PCKStudio_Updater
|
||||
{
|
||||
public sealed class GithubUpdateDownloader : IUpdateDownloader
|
||||
{
|
||||
private static readonly Assembly updaterAssembly = Assembly.GetAssembly(typeof(GithubUpdateDownloader));
|
||||
|
||||
private readonly GithubParams _updateParams;
|
||||
private readonly GitHubClient githubClient;
|
||||
private Release latestFetchedRelease;
|
||||
private Version latestReleaseVersion;
|
||||
private DirectoryInfo downloadDirectory;
|
||||
|
||||
|
||||
public GithubUpdateDownloader(GithubParams updateParams)
|
||||
{
|
||||
_updateParams = updateParams;
|
||||
var githubClientProductHeader = new ProductHeaderValue(updaterAssembly.GetName().Name);
|
||||
githubClient = new GitHubClient(githubClientProductHeader);
|
||||
}
|
||||
|
||||
public bool IsUpdateAvailable(FileVersionInfo fileVersionInfo)
|
||||
{
|
||||
return IsUpdateAvailable(fileVersionInfo.ProductVersion);
|
||||
}
|
||||
|
||||
public bool IsUpdateAvailable(Assembly currentAssembly)
|
||||
{
|
||||
if (!File.Exists(currentAssembly.Location))
|
||||
return false;
|
||||
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(currentAssembly.Location);
|
||||
return IsUpdateAvailable(fileVersionInfo.ProductVersion);
|
||||
}
|
||||
|
||||
public bool IsUpdateAvailable(Version productVersion)
|
||||
{
|
||||
Debug.WriteLine("Release Product ver.: " + latestReleaseVersion);
|
||||
Debug.WriteLine("Current Product ver.: " + productVersion);
|
||||
return latestReleaseVersion.CompareTo(productVersion) > 0;
|
||||
}
|
||||
|
||||
public bool IsUpdateAvailable(string productVersion)
|
||||
{
|
||||
GetLatestRelease(_updateParams.UsePreRelease);
|
||||
if (Version.TryParse(productVersion, out var currentVersion))
|
||||
{
|
||||
return IsUpdateAvailable(currentVersion);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void UnpackZip(string zipFilePath)
|
||||
{
|
||||
ZipFile.ExtractToDirectory(zipFilePath, Path.GetDirectoryName(zipFilePath));
|
||||
}
|
||||
|
||||
private static void DownloadAsset(ReleaseAsset asset, Stream destination)
|
||||
{
|
||||
string downloadUrl = asset.BrowserDownloadUrl;
|
||||
var client = new WebClient();
|
||||
using (var serverStream = client.OpenRead(downloadUrl))
|
||||
{
|
||||
serverStream.CopyTo(destination);
|
||||
}
|
||||
}
|
||||
|
||||
private void GetLatestRelease(bool prerelease)
|
||||
{
|
||||
Release release;
|
||||
if (prerelease)
|
||||
{
|
||||
var prereleaseTask = githubClient.Repository.Release.GetAll(_updateParams.RepositoryOwnerName, _updateParams.RepositoryName);
|
||||
prereleaseTask.Wait();
|
||||
var prereleases = prereleaseTask.Result.OrderByDescending(release => release.PublishedAt ?? release.CreatedAt).Where(release => release.Prerelease).ToArray();
|
||||
release = latestFetchedRelease = prereleases[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
var latestReleaseTask = githubClient.Repository.Release.GetLatest(_updateParams.RepositoryOwnerName, _updateParams.RepositoryName);
|
||||
latestReleaseTask.Wait();
|
||||
release = latestFetchedRelease = latestReleaseTask.Result;
|
||||
}
|
||||
var match = _updateParams.VersionMatcher.Match(release.Name);
|
||||
if (match.Success)
|
||||
{
|
||||
string versionString = match.Value;
|
||||
Version.TryParse(versionString, out latestReleaseVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void EmptyDirectory(DirectoryInfo directory)
|
||||
{
|
||||
string appname = Assembly.GetExecutingAssembly().GetName().Name;
|
||||
foreach (FileInfo file in directory.GetFiles())
|
||||
{
|
||||
if (Path.GetFileNameWithoutExtension(file.Name) != appname && file.Name != "update.zip")
|
||||
file.Delete();
|
||||
}
|
||||
foreach (DirectoryInfo subDirectory in directory.GetDirectories())
|
||||
subDirectory.Delete(true);
|
||||
}
|
||||
|
||||
public void DownloadTo(DirectoryInfo directory)
|
||||
{
|
||||
if (latestFetchedRelease is null)
|
||||
GetLatestRelease(_updateParams.UsePreRelease);
|
||||
if (latestFetchedRelease.Assets?.Count > 0)
|
||||
{
|
||||
var asset = latestFetchedRelease.Assets[0];
|
||||
string zipFilePath = Path.Combine(directory.FullName, "update.zip");
|
||||
using(var zipFileStream = File.OpenWrite(zipFilePath))
|
||||
{
|
||||
DownloadAsset(asset, zipFileStream);
|
||||
}
|
||||
Debug.WriteLine("Download Complete", category: nameof(GithubUpdateDownloader));
|
||||
EmptyDirectory(directory);
|
||||
UnpackZip(zipFilePath);
|
||||
File.Delete(zipFilePath);
|
||||
downloadDirectory = directory;
|
||||
}
|
||||
}
|
||||
|
||||
public void Launch()
|
||||
{
|
||||
if (downloadDirectory is null)
|
||||
{
|
||||
throw new ArgumentNullException("Download directory not set.");
|
||||
}
|
||||
|
||||
var files = downloadDirectory.GetFiles(_updateParams.TargetExecutableName + ".exe", SearchOption.TopDirectoryOnly);
|
||||
if (files is not null && files.Length > 0)
|
||||
{
|
||||
Process.Start(files[0].FullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
19
PCK-Studio-Updater/API/IUpdateDownloader.cs
Normal file
19
PCK-Studio-Updater/API/IUpdateDownloader.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PCKStudio_Updater
|
||||
{
|
||||
public interface IUpdateDownloader
|
||||
{
|
||||
public bool IsUpdateAvailable(Version currentVersion);
|
||||
public bool IsUpdateAvailable(string currentVersionString);
|
||||
|
||||
public void DownloadTo(DirectoryInfo directory);
|
||||
|
||||
public void Launch();
|
||||
}
|
||||
}
|
||||
105
PCK-Studio-Updater/PCK-Studio-Updater.csproj
Normal file
105
PCK-Studio-Updater/PCK-Studio-Updater.csproj
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{5B223556-15B9-41DA-AA0B-5E7F45E743BF}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>PCKStudio_Updater</RootNamespace>
|
||||
<AssemblyName>PCK-Studio-Updater</AssemblyName>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>PCKStudio_Updater.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>ProjectLogo.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="API\IUpdateDownloader.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="API\GithubParams.cs" />
|
||||
<Compile Include="API\GithubUpdateDownloader.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Costura.Fody">
|
||||
<Version>5.7.0</Version>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Octokit">
|
||||
<Version>7.1.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4.8 %28x86 and x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="ProjectLogo.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Properties\app.manifest" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
58
PCK-Studio-Updater/Program.cs
Normal file
58
PCK-Studio-Updater/Program.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace PCKStudio_Updater
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Uri projectUrl = new Uri("https://github.com/PhoenixARC/-PCK-Studio");
|
||||
if (args.Length > 0)
|
||||
{
|
||||
projectUrl = new Uri(args[0]);
|
||||
}
|
||||
|
||||
string executableName = "PCK-Studio";
|
||||
if (args.Length > 1)
|
||||
{
|
||||
executableName = args[1];
|
||||
}
|
||||
|
||||
bool prerelease = false;
|
||||
if (args.Length > 2)
|
||||
{
|
||||
prerelease = args[2].ToLower() == "true" || args[2].ToLower() == "1";
|
||||
}
|
||||
|
||||
var versionMatcher = new Regex("(\\*|\\d+(\\.\\d+){0,3}(\\.\\*)?)");
|
||||
if (args.Length > 3)
|
||||
{
|
||||
versionMatcher = new Regex(args[3]);
|
||||
}
|
||||
|
||||
GithubParams updateParams = new GithubParams(
|
||||
Path.GetDirectoryName(projectUrl.AbsolutePath).Replace("\\", ""),
|
||||
Path.GetFileName(projectUrl.AbsolutePath),
|
||||
executableName,
|
||||
prerelease,
|
||||
versionMatcher
|
||||
);
|
||||
|
||||
IUpdateDownloader updater = new GithubUpdateDownloader(updateParams);
|
||||
|
||||
if (!File.Exists(updateParams.TargetExecutableName + ".exe") || updater.IsUpdateAvailable(FileVersionInfo.GetVersionInfo(updateParams.TargetExecutableName + ".exe").ProductVersion))
|
||||
{
|
||||
updater.DownloadTo(new DirectoryInfo("."));
|
||||
updater.Launch();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
PCK-Studio-Updater/ProjectLogo.ico
Normal file
BIN
PCK-Studio-Updater/ProjectLogo.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 146 KiB |
36
PCK-Studio-Updater/Properties/AssemblyInfo.cs
Normal file
36
PCK-Studio-Updater/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("PckStudio-Updater")]
|
||||
[assembly: AssemblyDescription("Updater for PCK-Studio")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("PckStudio-Updater")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023 Miku-666")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("5b223556-15b9-41da-aa0b-5e7f45e743bf")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
70
PCK-Studio-Updater/Properties/app.manifest
Normal file
70
PCK-Studio-Updater/Properties/app.manifest
Normal file
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<!-- UAC Manifest Options
|
||||
If you want to change the Windows User Account Control level replace the
|
||||
requestedExecutionLevel node with one of the following.
|
||||
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
|
||||
|
||||
Specifying requestedExecutionLevel element will disable file and registry virtualization.
|
||||
Remove this element if your application requires this virtualization for backwards
|
||||
compatibility.
|
||||
-->
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
<applicationRequestMinimum>
|
||||
<defaultAssemblyRequest permissionSetReference="Custom" />
|
||||
<PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" />
|
||||
</applicationRequestMinimum>
|
||||
</security>
|
||||
</trustInfo>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- A list of the Windows versions that this application has been tested on
|
||||
and is designed to work with. Uncomment the appropriate elements
|
||||
and Windows will automatically select the most compatible environment. -->
|
||||
<!-- Windows Vista -->
|
||||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
|
||||
<!-- Windows 7 -->
|
||||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
|
||||
<!-- Windows 8 -->
|
||||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
|
||||
<!-- Windows 8.1 -->
|
||||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||
</application>
|
||||
</compatibility>
|
||||
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
|
||||
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
|
||||
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
|
||||
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
|
||||
<!--
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
-->
|
||||
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
|
||||
<!--
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
-->
|
||||
</assembly>
|
||||
@@ -71,6 +71,12 @@
|
||||
<setting name="ShowRichPresence" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="UsePrerelease" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="AutoUpdate" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="UseComboBoxForGRFParameter" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace PckStudio.Classes.Misc
|
||||
new Button()
|
||||
{
|
||||
Label = "Check it out!",
|
||||
Url = Program.ProjectUrl,
|
||||
Url = Program.ProjectUrl.AbsoluteUri,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PckStudio.Classes.Networking
|
||||
{
|
||||
[Obsolete]
|
||||
class Network
|
||||
{
|
||||
public static string Version = Application.ProductVersion;
|
||||
public static bool IsBeta = true;
|
||||
public static bool Portable = false;
|
||||
public static bool NeedsUpdate = false;
|
||||
public static Uri MainURL = new Uri(Program.BaseAPIUrl);
|
||||
public static Uri BackUpURL = new Uri(Program.BackUpAPIUrl);
|
||||
static readonly string UpdatePath = "/update/Version";
|
||||
static readonly string BetaUpdatePath = "/update/VersionBeta";
|
||||
|
||||
public static void CheckUpdate()
|
||||
{
|
||||
using WebClient wc = new WebClient();
|
||||
try
|
||||
{
|
||||
Update.CheckForUpdate(null); // TODO
|
||||
|
||||
Uri versionUri = new Uri(MainURL, IsBeta ? BetaUpdatePath : UpdatePath);
|
||||
Console.WriteLine(versionUri);
|
||||
string serverVersion = wc.DownloadString(versionUri);
|
||||
if (Version != serverVersion)
|
||||
{
|
||||
if (MessageBox.Show("An update is available! Do you want to update?" +
|
||||
$"\nYour Version: {Version}" +
|
||||
$"\nAvailable version: {serverVersion}", "Update Available", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
Update.UpdateProgram(new UpdateOptions(
|
||||
isBeta: IsBeta,
|
||||
isPortable: Portable,
|
||||
baseUri: new Uri(MainURL, "/Update/Download/setup/PCKStudio-Setup.msi"),
|
||||
betaUri: new Uri(MainURL, "/Update/Download/setup/beta/PCKStudioBeta-Setup.msi")
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
NeedsUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.Message);
|
||||
MessageBox.Show("Can't connect to the server!", "Server unavailabe");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PckStudio.Classes.Networking
|
||||
{
|
||||
[Obsolete]
|
||||
public enum UpdateResult
|
||||
{
|
||||
// Base Failure value
|
||||
Failure = -1,
|
||||
// Base Success value
|
||||
Success,
|
||||
|
||||
UpdateAvailable,
|
||||
|
||||
UpdateFailure,
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
class UpdateOptions
|
||||
{
|
||||
public bool IsBeta { get; set; }
|
||||
public bool IsPortable { get; set; }
|
||||
public string Domain
|
||||
{
|
||||
get => _baseDomain?.OriginalString ?? (_betaDomain?.OriginalString ?? throw new NullReferenceException(nameof(_betaDomain)));
|
||||
set
|
||||
{
|
||||
_ = value ?? throw new NullReferenceException(nameof(value));
|
||||
_baseDomain = new Uri(value);
|
||||
}
|
||||
}
|
||||
|
||||
private Uri _baseDomain;
|
||||
private Uri _betaDomain;
|
||||
|
||||
public UpdateOptions(bool isBeta, bool isPortable, Uri baseUri, Uri betaUri)
|
||||
{
|
||||
IsBeta = isBeta;
|
||||
IsPortable = isPortable;
|
||||
_baseDomain = baseUri;
|
||||
_betaDomain = betaUri;
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
static class Update
|
||||
{
|
||||
public static UpdateResult CheckForUpdate(UpdateOptions options)
|
||||
{
|
||||
// TODO: implement this
|
||||
return UpdateResult.Failure;
|
||||
}
|
||||
|
||||
public static void UpdateProgram(UpdateOptions options)
|
||||
{
|
||||
string updateURL = options.Domain;
|
||||
if (options.IsPortable)
|
||||
{
|
||||
updateURL = updateURL.Replace(".msi","Portable.msi");
|
||||
}
|
||||
|
||||
string downloadPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Temp\\";
|
||||
string destinationURL = options.Domain;
|
||||
if (TryDownloadFile(downloadPath + Path.GetFileName(destinationURL), destinationURL))
|
||||
{
|
||||
Process.Start(downloadPath + Path.GetFileName(destinationURL));
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
|
||||
static bool TryDownloadFile(string filePath, string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (WebClient client = new WebClient())
|
||||
client.DownloadFile(url, filePath);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) { Console.WriteLine(ex.Message); }
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
19
PCK-Studio/Forms/AppSettingsForm.Designer.cs
generated
19
PCK-Studio/Forms/AppSettingsForm.Designer.cs
generated
@@ -36,6 +36,7 @@
|
||||
this.autoLoadPckCheckBox = new MetroFramework.Controls.MetroCheckBox();
|
||||
this.showPresenceCheckBox = new MetroFramework.Controls.MetroCheckBox();
|
||||
this.grf_paramKeyComboBoxCheckBox = new MetroFramework.Controls.MetroCheckBox();
|
||||
this.usePrereleaseCheckBox = new MetroFramework.Controls.MetroCheckBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// autoSaveCheckBox
|
||||
@@ -76,7 +77,6 @@
|
||||
// autoUpdateCheckBox
|
||||
//
|
||||
this.autoUpdateCheckBox.AutoSize = true;
|
||||
this.autoUpdateCheckBox.Enabled = false;
|
||||
this.autoUpdateCheckBox.Location = new System.Drawing.Point(23, 105);
|
||||
this.autoUpdateCheckBox.Name = "autoUpdateCheckBox";
|
||||
this.autoUpdateCheckBox.Size = new System.Drawing.Size(90, 15);
|
||||
@@ -86,6 +86,7 @@
|
||||
this.autoUpdateCheckBox.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.SettingToolTip.SetToolTip(this.autoUpdateCheckBox, "Whether to automatically check for updates");
|
||||
this.autoUpdateCheckBox.UseSelectable = true;
|
||||
this.autoUpdateCheckBox.CheckedChanged += new System.EventHandler(this.autoUpdateCheckBox_CheckedChanged);
|
||||
//
|
||||
// autoLoadPckCheckBox
|
||||
//
|
||||
@@ -129,11 +130,26 @@
|
||||
this.grf_paramKeyComboBoxCheckBox.UseSelectable = true;
|
||||
this.grf_paramKeyComboBoxCheckBox.CheckedChanged += new System.EventHandler(this.grf_paramKeyComboBoxCheckBox_CheckedChanged);
|
||||
//
|
||||
// usePrereleaseCheckBox
|
||||
//
|
||||
this.usePrereleaseCheckBox.AutoSize = true;
|
||||
this.usePrereleaseCheckBox.Location = new System.Drawing.Point(119, 105);
|
||||
this.usePrereleaseCheckBox.Name = "usePrereleaseCheckBox";
|
||||
this.usePrereleaseCheckBox.Size = new System.Drawing.Size(98, 15);
|
||||
this.usePrereleaseCheckBox.Style = MetroFramework.MetroColorStyle.White;
|
||||
this.usePrereleaseCheckBox.TabIndex = 6;
|
||||
this.usePrereleaseCheckBox.Text = "Use Beta Build";
|
||||
this.usePrereleaseCheckBox.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.SettingToolTip.SetToolTip(this.usePrereleaseCheckBox, "Whether to automatically check for updates");
|
||||
this.usePrereleaseCheckBox.UseSelectable = true;
|
||||
this.usePrereleaseCheckBox.Visible = false;
|
||||
//
|
||||
// AppSettingsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(527, 270);
|
||||
this.Controls.Add(this.usePrereleaseCheckBox);
|
||||
this.Controls.Add(this.grf_paramKeyComboBoxCheckBox);
|
||||
this.Controls.Add(this.showPresenceCheckBox);
|
||||
this.Controls.Add(this.autoLoadPckCheckBox);
|
||||
@@ -164,5 +180,6 @@
|
||||
private MetroFramework.Controls.MetroCheckBox autoLoadPckCheckBox;
|
||||
private MetroFramework.Controls.MetroCheckBox showPresenceCheckBox;
|
||||
private MetroFramework.Controls.MetroCheckBox grf_paramKeyComboBoxCheckBox;
|
||||
private MetroFramework.Controls.MetroCheckBox usePrereleaseCheckBox;
|
||||
}
|
||||
}
|
||||
@@ -40,11 +40,21 @@ namespace PckStudio.Forms
|
||||
Settings.Default.ShowRichPresence = showPresenceCheckBox.Checked;
|
||||
}
|
||||
|
||||
private void autoUpdateCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
usePrereleaseCheckBox.Visible = Settings.Default.AutoUpdate = autoUpdateCheckBox.Checked;
|
||||
}
|
||||
|
||||
private void grf_paramKeyComboBoxCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Settings.Default.UseComboBoxForGRFParameter = grf_paramKeyComboBoxCheckBox.Checked;
|
||||
}
|
||||
|
||||
private void usePrereleaseCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Settings.Default.UsePrerelease = usePrereleaseCheckBox.Checked;
|
||||
}
|
||||
|
||||
private void LoadCheckboxState(CheckBox checkBox, EventHandler eventHandler, bool state)
|
||||
{
|
||||
checkBox.CheckedChanged -= eventHandler;
|
||||
@@ -58,6 +68,8 @@ namespace PckStudio.Forms
|
||||
LoadCheckboxState(endianCheckBox, endianCheckBox_CheckedChanged, Settings.Default.UseLittleEndianAsDefault);
|
||||
LoadCheckboxState(autoLoadPckCheckBox, autoLoadPckCheckBox_CheckedChanged, Settings.Default.LoadSubPcks);
|
||||
LoadCheckboxState(showPresenceCheckBox, showPresenceCheckBox_CheckedChanged, Settings.Default.ShowRichPresence);
|
||||
LoadCheckboxState(autoUpdateCheckBox, autoUpdateCheckBox_CheckedChanged, Settings.Default.AutoUpdate);
|
||||
LoadCheckboxState(usePrereleaseCheckBox, usePrereleaseCheckBox_CheckedChanged, Settings.Default.UsePrerelease);
|
||||
LoadCheckboxState(grf_paramKeyComboBoxCheckBox, grf_paramKeyComboBoxCheckBox_CheckedChanged, Settings.Default.UseComboBoxForGRFParameter);
|
||||
}
|
||||
|
||||
|
||||
31
PCK-Studio/MainForm.Designer.cs
generated
31
PCK-Studio/MainForm.Designer.cs
generated
@@ -33,6 +33,7 @@
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||
System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
|
||||
toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.contextMenuPCKEntries = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.createToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.folderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -99,6 +100,7 @@
|
||||
this.joinDevelopmentDiscordToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.trelloBoardToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.checkForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.videosToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.howToMakeABasicSkinPackToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -146,7 +148,6 @@
|
||||
this.LittleEndianCheckBox = new MetroFramework.Controls.MetroCheckBox();
|
||||
logoPictureBox = new System.Windows.Forms.PictureBox();
|
||||
toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
((System.ComponentModel.ISupportInitialize)(logoPictureBox)).BeginInit();
|
||||
this.contextMenuPCKEntries.SuspendLayout();
|
||||
this.menuStrip.SuspendLayout();
|
||||
@@ -166,6 +167,16 @@
|
||||
logoPictureBox.Name = "logoPictureBox";
|
||||
logoPictureBox.TabStop = false;
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
resources.ApplyResources(toolStripSeparator1, "toolStripSeparator1");
|
||||
//
|
||||
// toolStripSeparator3
|
||||
//
|
||||
toolStripSeparator3.Name = "toolStripSeparator3";
|
||||
resources.ApplyResources(toolStripSeparator3, "toolStripSeparator3");
|
||||
//
|
||||
// contextMenuPCKEntries
|
||||
//
|
||||
this.contextMenuPCKEntries.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
@@ -628,6 +639,7 @@
|
||||
// helpToolStripMenuItem
|
||||
//
|
||||
this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.checkForUpdatesToolStripMenuItem,
|
||||
this.aboutToolStripMenuItem,
|
||||
toolStripSeparator1,
|
||||
this.videosToolStripMenuItem,
|
||||
@@ -638,17 +650,18 @@
|
||||
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
|
||||
resources.ApplyResources(this.helpToolStripMenuItem, "helpToolStripMenuItem");
|
||||
//
|
||||
// checkForUpdatesToolStripMenuItem
|
||||
//
|
||||
this.checkForUpdatesToolStripMenuItem.Name = "checkForUpdatesToolStripMenuItem";
|
||||
resources.ApplyResources(this.checkForUpdatesToolStripMenuItem, "checkForUpdatesToolStripMenuItem");
|
||||
this.checkForUpdatesToolStripMenuItem.Click += new System.EventHandler(this.checkForUpdatesToolStripMenuItem_Click);
|
||||
//
|
||||
// aboutToolStripMenuItem
|
||||
//
|
||||
resources.ApplyResources(this.aboutToolStripMenuItem, "aboutToolStripMenuItem");
|
||||
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
|
||||
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
resources.ApplyResources(toolStripSeparator1, "toolStripSeparator1");
|
||||
//
|
||||
// videosToolStripMenuItem
|
||||
//
|
||||
this.videosToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
@@ -739,11 +752,6 @@
|
||||
resources.ApplyResources(this.forMattNLContributorToolStripMenuItem, "forMattNLContributorToolStripMenuItem");
|
||||
this.forMattNLContributorToolStripMenuItem.Click += new System.EventHandler(this.forMattNLContributorToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator3
|
||||
//
|
||||
toolStripSeparator3.Name = "toolStripSeparator3";
|
||||
resources.ApplyResources(toolStripSeparator3, "toolStripSeparator3");
|
||||
//
|
||||
// settingsToolStripMenuItem
|
||||
//
|
||||
this.settingsToolStripMenuItem.Image = global::PckStudio.Properties.Resources.ranch;
|
||||
@@ -1233,6 +1241,7 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem toPhoenixARCDeveloperToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem forMattNLContributorToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem checkForUpdatesToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ using PckStudio.Extensions;
|
||||
using PckStudio.Popups;
|
||||
using PckStudio.Classes.Utils;
|
||||
using PckStudio.Helper;
|
||||
using PCKStudio_Updater;
|
||||
|
||||
namespace PckStudio
|
||||
{
|
||||
@@ -2267,5 +2268,15 @@ namespace PckStudio
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.Updater.IsUpdateAvailable(Application.ProductVersion))
|
||||
{
|
||||
Program.UpdateToLatest("Would you like to download it?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, DialogResult.Yes);
|
||||
return;
|
||||
}
|
||||
MessageBox.Show("Already up to date.", "No update available");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@
|
||||
<PropertyGroup>
|
||||
<LangVersion>preview</LangVersion>
|
||||
<DisableFody Condition="'$(Configuration)' == 'Debug'">true</DisableFody>
|
||||
<DefineConstants Condition="'$(Configuration)' != 'Debug'">NDEBUG</DefineConstants>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
@@ -40,7 +41,7 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DefineConstants>$(DefineConstants);DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
@@ -50,7 +51,7 @@
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
@@ -60,7 +61,7 @@
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Beta\</OutputPath>
|
||||
<DefineConstants>BETA;TRACE</DefineConstants>
|
||||
<DefineConstants>$(DefineConstants);BETA;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
@@ -225,9 +226,7 @@
|
||||
<Compile Include="Classes\Models\Texel.cs" />
|
||||
<Compile Include="Classes\Models\TexelComparer.cs" />
|
||||
<Compile Include="Classes\Models\TexturePlane.cs" />
|
||||
<Compile Include="Classes\Networking\Network.cs" />
|
||||
<Compile Include="Classes\Misc\RichPresenceClient.cs" />
|
||||
<Compile Include="Classes\Networking\Update.cs" />
|
||||
<Compile Include="Features\CemuPanel.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
@@ -728,6 +727,10 @@
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PCK-Studio-Updater\PCK-Studio-Updater.csproj">
|
||||
<Project>{5B223556-15B9-41DA-AA0B-5E7F45E743BF}</Project>
|
||||
<Name>PCK-Studio-Updater</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Vendor\OMI-Lib\OMI Filetypes Library\OMI Filetype Library.csproj">
|
||||
<Project>{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}</Project>
|
||||
<Name>OMI Filetype Library</Name>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,6 @@ using System.Security.Permissions;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("7.0")]
|
||||
[assembly: AssemblyFileVersion("7.0")]
|
||||
[assembly: AssemblyVersion("7.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("7.0.0.0")]
|
||||
[assembly: NeutralResourcesLanguage("")]
|
||||
|
||||
24
PCK-Studio/Properties/Settings.Designer.cs
generated
24
PCK-Studio/Properties/Settings.Designer.cs
generated
@@ -80,6 +80,30 @@ namespace PckStudio.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool UsePrerelease {
|
||||
get {
|
||||
return ((bool)(this["UsePrerelease"]));
|
||||
}
|
||||
set {
|
||||
this["UsePrerelease"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool AutoUpdate {
|
||||
get {
|
||||
return ((bool)(this["AutoUpdate"]));
|
||||
}
|
||||
set {
|
||||
this["AutoUpdate"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
|
||||
@@ -17,6 +17,12 @@
|
||||
<Setting Name="ShowRichPresence" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="UsePrerelease" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="AutoUpdate" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="UseComboBoxForGRFParameter" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
|
||||
@@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OMI Filetype Library", "Ven
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpMss32", "Vendor\SharpMss32\SharpMss32\SharpMss32.csproj", "{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PCK-Studio-Updater", "PCK-Studio-Updater\PCK-Studio-Updater.csproj", "{5B223556-15B9-41DA-AA0B-5E7F45E743BF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Beta|Any CPU = Beta|Any CPU
|
||||
@@ -78,6 +80,24 @@ Global
|
||||
{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}.Release|x64.Build.0 = Release|Any CPU
|
||||
{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}.Release|x86.Build.0 = Release|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Beta|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Beta|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Beta|x64.ActiveCfg = Debug|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Beta|x64.Build.0 = Debug|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Beta|x86.ActiveCfg = Debug|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Beta|x86.Build.0 = Debug|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Release|x64.Build.0 = Release|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Reference in New Issue
Block a user