Merge main into '3dSkinRenderer'

This commit is contained in:
miku-666
2024-06-27 20:19:34 +02:00
21 changed files with 138 additions and 712 deletions

View File

@@ -45,7 +45,7 @@ jobs:
run: "msbuild PCK_Studio.sln -p:Configuration=Release"
- name: Package binary
run: Compress-Archive -Path ${{ github.workspace }}\PCK-Studio\bin\Release\ -Destination ${{ env.RELEASE_NAME }}.zip
run: Compress-Archive -Path "${{ github.workspace }}\PCK-Studio\bin\Release\*" -Destination ${{ env.RELEASE_NAME }}.zip
- name: Release
uses: softprops/action-gh-release@v2

3
.gitignore vendored
View File

@@ -250,3 +250,6 @@ paket-files/
# JetBrains Rider
.idea/
*.sln.iml
# Deploy util
makeUpdate.py

View File

@@ -1,22 +0,0 @@
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;
}
}
}

View File

@@ -1,148 +0,0 @@
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);
}
}
}
}

View File

@@ -1,19 +0,0 @@
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();
}
}

View File

@@ -1,105 +0,0 @@
<?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>

View File

@@ -1,58 +0,0 @@
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;
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 KiB

View File

@@ -1,36 +0,0 @@
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")]

View File

@@ -1,70 +0,0 @@
<?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>

View File

@@ -14,6 +14,12 @@ namespace PckStudio.Extensions
{
if (string.IsNullOrWhiteSpace(path))
return Array.Empty<TreeNode>();
if (!path.Contains(treeView.PathSeparator))
{
return treeView.Nodes.Find(path, false);
}
string segment = path.Substring(0, path.IndexOf(treeView.PathSeparator));
if (treeView.Nodes.ContainsKey(segment))
{

View File

@@ -29,149 +29,33 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AppSettingsForm));
this.autoSaveCheckBox = new MetroFramework.Controls.MetroCheckBox();
this.SettingToolTip = new MetroFramework.Components.MetroToolTip();
this.endianCheckBox = new MetroFramework.Controls.MetroCheckBox();
this.autoUpdateCheckBox = new MetroFramework.Controls.MetroCheckBox();
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.validateSkinDimenssionCheckBox = new MetroFramework.Controls.MetroCheckBox();
this.flowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
this.SuspendLayout();
//
// autoSaveCheckBox
//
this.autoSaveCheckBox.AutoSize = true;
this.autoSaveCheckBox.Location = new System.Drawing.Point(23, 63);
this.autoSaveCheckBox.Name = "autoSaveCheckBox";
this.autoSaveCheckBox.Size = new System.Drawing.Size(76, 15);
this.autoSaveCheckBox.Style = MetroFramework.MetroColorStyle.White;
this.autoSaveCheckBox.TabIndex = 0;
this.autoSaveCheckBox.Text = "Auto Save";
this.autoSaveCheckBox.Theme = MetroFramework.MetroThemeStyle.Dark;
this.SettingToolTip.SetToolTip(this.autoSaveCheckBox, "Whether to automatically save changes inside of file editor such as the loc edito" +
"r");
this.autoSaveCheckBox.UseSelectable = true;
this.autoSaveCheckBox.CheckedChanged += new System.EventHandler(this.autoSaveCheckBox_CheckedChanged);
//
// SettingToolTip
//
this.SettingToolTip.Style = MetroFramework.MetroColorStyle.White;
this.SettingToolTip.StyleManager = null;
this.SettingToolTip.Theme = MetroFramework.MetroThemeStyle.Dark;
//
// endianCheckBox
// flowLayoutPanel
//
this.endianCheckBox.AutoSize = true;
this.endianCheckBox.Location = new System.Drawing.Point(23, 84);
this.endianCheckBox.Name = "endianCheckBox";
this.endianCheckBox.Size = new System.Drawing.Size(75, 15);
this.endianCheckBox.Style = MetroFramework.MetroColorStyle.White;
this.endianCheckBox.TabIndex = 1;
this.endianCheckBox.Text = "Open Vita";
this.endianCheckBox.Theme = MetroFramework.MetroThemeStyle.Dark;
this.SettingToolTip.SetToolTip(this.endianCheckBox, "Whether to automatically set the \'Open as Switch/Vita pck\' checkbox");
this.endianCheckBox.UseSelectable = true;
this.endianCheckBox.CheckedChanged += new System.EventHandler(this.endianCheckBox_CheckedChanged);
//
// autoUpdateCheckBox
//
this.autoUpdateCheckBox.AutoSize = true;
this.autoUpdateCheckBox.Location = new System.Drawing.Point(23, 105);
this.autoUpdateCheckBox.Name = "autoUpdateCheckBox";
this.autoUpdateCheckBox.Size = new System.Drawing.Size(90, 15);
this.autoUpdateCheckBox.Style = MetroFramework.MetroColorStyle.White;
this.autoUpdateCheckBox.TabIndex = 2;
this.autoUpdateCheckBox.Text = "Auto Update";
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
//
this.autoLoadPckCheckBox.AutoSize = true;
this.autoLoadPckCheckBox.Location = new System.Drawing.Point(23, 126);
this.autoLoadPckCheckBox.Name = "autoLoadPckCheckBox";
this.autoLoadPckCheckBox.Size = new System.Drawing.Size(331, 15);
this.autoLoadPckCheckBox.Style = MetroFramework.MetroColorStyle.White;
this.autoLoadPckCheckBox.TabIndex = 3;
this.autoLoadPckCheckBox.Text = "Auto load additional pck files (also known as SubPCK files)";
this.autoLoadPckCheckBox.Theme = MetroFramework.MetroThemeStyle.Dark;
this.SettingToolTip.SetToolTip(this.autoLoadPckCheckBox, "Whether to automatically load files inside that end in .pck");
this.autoLoadPckCheckBox.UseSelectable = true;
this.autoLoadPckCheckBox.CheckedChanged += new System.EventHandler(this.autoLoadPckCheckBox_CheckedChanged);
//
// showPresenceCheckBox
//
this.showPresenceCheckBox.AutoSize = true;
this.showPresenceCheckBox.Location = new System.Drawing.Point(23, 147);
this.showPresenceCheckBox.Name = "showPresenceCheckBox";
this.showPresenceCheckBox.Size = new System.Drawing.Size(171, 15);
this.showPresenceCheckBox.Style = MetroFramework.MetroColorStyle.White;
this.showPresenceCheckBox.TabIndex = 4;
this.showPresenceCheckBox.Text = "Show Discord Rich Presence";
this.showPresenceCheckBox.Theme = MetroFramework.MetroThemeStyle.Dark;
this.SettingToolTip.SetToolTip(this.showPresenceCheckBox, "Whether to show a rich presence on discord");
this.showPresenceCheckBox.UseSelectable = true;
this.showPresenceCheckBox.CheckedChanged += new System.EventHandler(this.showPresenceCheckBox_CheckedChanged);
//
// grf_paramKeyComboBoxCheckBox
//
this.grf_paramKeyComboBoxCheckBox.AutoSize = true;
this.grf_paramKeyComboBoxCheckBox.Location = new System.Drawing.Point(23, 169);
this.grf_paramKeyComboBoxCheckBox.Name = "grf_paramKeyComboBoxCheckBox";
this.grf_paramKeyComboBoxCheckBox.Size = new System.Drawing.Size(100, 15);
this.grf_paramKeyComboBoxCheckBox.Style = MetroFramework.MetroColorStyle.White;
this.grf_paramKeyComboBoxCheckBox.TabIndex = 5;
this.grf_paramKeyComboBoxCheckBox.Text = "Select GRF Key";
this.grf_paramKeyComboBoxCheckBox.Theme = MetroFramework.MetroThemeStyle.Dark;
this.SettingToolTip.SetToolTip(this.grf_paramKeyComboBoxCheckBox, "Use a combobox instead of typing the parameter key name");
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;
//
// validateSkinDimenssionCheckBox
//
this.validateSkinDimenssionCheckBox.AutoSize = true;
this.validateSkinDimenssionCheckBox.Location = new System.Drawing.Point(23, 190);
this.validateSkinDimenssionCheckBox.Name = "validateSkinDimenssionCheckBox";
this.validateSkinDimenssionCheckBox.Size = new System.Drawing.Size(149, 15);
this.validateSkinDimenssionCheckBox.Style = MetroFramework.MetroColorStyle.White;
this.validateSkinDimenssionCheckBox.TabIndex = 7;
this.validateSkinDimenssionCheckBox.Text = "Validate Skin Dimension";
this.validateSkinDimenssionCheckBox.Theme = MetroFramework.MetroThemeStyle.Dark;
this.SettingToolTip.SetToolTip(this.validateSkinDimenssionCheckBox, "Use a combobox instead of typing the parameter key name");
this.validateSkinDimenssionCheckBox.UseSelectable = true;
this.validateSkinDimenssionCheckBox.CheckedChanged += new System.EventHandler(this.validateSkinDimenssionCheckBox_CheckedChanged);
this.flowLayoutPanel.AutoScroll = true;
this.flowLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanel.Location = new System.Drawing.Point(20, 60);
this.flowLayoutPanel.Name = "flowLayoutPanel";
this.flowLayoutPanel.Padding = new System.Windows.Forms.Padding(3);
this.flowLayoutPanel.Size = new System.Drawing.Size(487, 190);
this.flowLayoutPanel.TabIndex = 0;
//
// 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.validateSkinDimenssionCheckBox);
this.Controls.Add(this.usePrereleaseCheckBox);
this.Controls.Add(this.grf_paramKeyComboBoxCheckBox);
this.Controls.Add(this.showPresenceCheckBox);
this.Controls.Add(this.autoLoadPckCheckBox);
this.Controls.Add(this.autoUpdateCheckBox);
this.Controls.Add(this.endianCheckBox);
this.Controls.Add(this.autoSaveCheckBox);
this.Controls.Add(this.flowLayoutPanel);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
@@ -183,20 +67,11 @@
this.Theme = MetroFramework.MetroThemeStyle.Dark;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.AppBehaviorSettingsForm_FormClosing);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private MetroFramework.Controls.MetroCheckBox autoSaveCheckBox;
private MetroFramework.Components.MetroToolTip SettingToolTip;
private MetroFramework.Controls.MetroCheckBox endianCheckBox;
private MetroFramework.Controls.MetroCheckBox autoUpdateCheckBox;
private MetroFramework.Controls.MetroCheckBox autoLoadPckCheckBox;
private MetroFramework.Controls.MetroCheckBox showPresenceCheckBox;
private MetroFramework.Controls.MetroCheckBox grf_paramKeyComboBoxCheckBox;
private MetroFramework.Controls.MetroCheckBox usePrereleaseCheckBox;
private MetroFramework.Controls.MetroCheckBox validateSkinDimenssionCheckBox;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel;
}
}

View File

@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Diagnostics;
using System.Windows.Forms;
using MetroFramework.Controls;
using MetroFramework.Forms;
using PckStudio.Properties;
@@ -14,74 +11,65 @@ namespace PckStudio.Forms
{
public partial class AppSettingsForm : MetroForm
{
private ApplicationSettingsBase _applicationSettings;
public AppSettingsForm()
: this(Settings.Default)
{
}
public AppSettingsForm(ApplicationSettingsBase applicationSettings)
{
InitializeComponent();
_applicationSettings = applicationSettings;
LoadSettings();
}
private void autoSaveCheckBox_CheckedChanged(object sender, EventArgs e)
private static Dictionary<string, string> CheckBoxText = new Dictionary<string, string>()
{
Settings.Default.AutoSaveChanges = autoSaveCheckBox.Checked;
}
["ShowRichPresence"] = "Show Rich Presence",
["AutoSaveChanges"] = "Auto Save",
["UseLittleEndianAsDefault"] = "Open as Little Endian",
["AutoUpdate"] = "Auto Update",
["LoadSubPcks"] = "Load Sub Pcks",
["UsePrerelease"] = "Use Prerelease",
["UseComboBoxForGRFParameter"] = "Easy Grf Param",
};
private void endianCheckBox_CheckedChanged(object sender, EventArgs e)
private void CheckBox_CheckedChanged(object sender, EventArgs e)
{
Settings.Default.UseLittleEndianAsDefault = endianCheckBox.Checked;
}
private void autoLoadPckCheckBox_CheckedChanged(object sender, EventArgs e)
{
Settings.Default.LoadSubPcks = autoLoadPckCheckBox.Checked;
}
private void showPresenceCheckBox_CheckedChanged(object sender, EventArgs e)
{
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 validateSkinDimenssionCheckBox_CheckedChanged(object sender, EventArgs e)
{
Settings.Default.ValidateImageDimension = validateSkinDimenssionCheckBox.Checked;
}
private void LoadCheckboxState(CheckBox checkBox, EventHandler eventHandler, bool state)
{
checkBox.CheckedChanged -= eventHandler;
checkBox.Checked = state;
checkBox.CheckedChanged += eventHandler;
if (sender is CheckBox checkBox && checkBox.Tag is string settingsKey && _applicationSettings[settingsKey] is bool)
{
_applicationSettings[settingsKey] = checkBox.Checked;
}
}
private void LoadSettings()
{
LoadCheckboxState(autoSaveCheckBox, autoSaveCheckBox_CheckedChanged, Settings.Default.AutoSaveChanges);
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);
LoadCheckboxState(validateSkinDimenssionCheckBox, validateSkinDimenssionCheckBox_CheckedChanged, Settings.Default.ValidateImageDimension);
foreach (SettingsPropertyValue item in _applicationSettings.PropertyValues)
{
Debug.WriteLine($"{item.Property.Name}: {item.Property.PropertyType}");
if (!item.Property.Attributes.ContainsKey(typeof(UserScopedSettingAttribute)) || item.Property.PropertyType != typeof(bool))
continue;
var checkBox = new MetroCheckBox
{
Name = item.Name,
Tag = item.Name,
Text = CheckBoxText.ContainsKey(item.Name) ? CheckBoxText[item.Name] : item.Name,
Checked = (bool)item.PropertyValue,
AutoSize = true,
Theme = MetroFramework.MetroThemeStyle.Dark,
Style = MetroFramework.MetroColorStyle.White,
};
checkBox.CheckedChanged += CheckBox_CheckedChanged;
flowLayoutPanel.Controls.Add(checkBox);
}
}
private void AppBehaviorSettingsForm_FormClosing(object sender, FormClosingEventArgs e)
{
Settings.Default.Save();
_applicationSettings.Save();
}
}
}

View File

@@ -27,7 +27,7 @@ namespace PckStudio.Forms
#else
buildConfig = "unknown";
#endif
buildLabel.Text = $"Verion: {Application.ProductVersion}\nBuild Config: {buildConfig}\nBranch: {CommitInfo.BranchName}@{CommitInfo.CommitHash}";
buildLabel.Text = $"Verion: {ApplicationScope.CurrentVersion}\nBuild Config: {buildConfig}\nBranch: {CommitInfo.BranchName}@{CommitInfo.CommitHash}";
}
protected override void OnLoad(EventArgs e)

View File

@@ -21,6 +21,8 @@ namespace PckStudio.Internal.App
private static Image[] _entityImages;
public static Image[] EntityImages => _entityImages;
public static Version CurrentVersion { get; } = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
internal static void Initialize()
{
Profiler.Start();

View File

@@ -92,7 +92,7 @@ namespace PckStudio
Text = Application.ProductName;
labelVersion.Text = $"{Application.ProductName}: {Application.ProductVersion}";
labelVersion.Text = $"{Application.ProductName}: {ApplicationScope.CurrentVersion}";
ChangelogRichTextBox.Text = Resources.CHANGELOG;
pckFileTypeHandler = new Dictionary<PckAssetType, Action<PckAsset>>(15)
@@ -2494,12 +2494,7 @@ namespace PckStudio
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(this, "Already up to date.", "No update available");
Program.UpdateToLatest();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)

View File

@@ -712,6 +712,9 @@
<PackageReference Include="AnimatedGif">
<Version>1.0.5</Version>
</PackageReference>
<PackageReference Include="Autoupdater.NET.Official">
<Version>1.9.1</Version>
</PackageReference>
<PackageReference Include="Costura.Fody">
<Version>5.8.0-alpha0098</Version>
<IncludeAssets>compile; runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -755,10 +758,6 @@
</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>

View File

@@ -6,8 +6,9 @@ using System.Windows.Forms;
using PckStudio.Internal.Misc;
using PckStudio.Internal;
using PckStudio.Properties;
using PCKStudio_Updater;
using PckStudio.Internal.App;
using AutoUpdaterDotNET;
using Newtonsoft.Json;
namespace PckStudio
@@ -15,22 +16,13 @@ namespace PckStudio
static class Program
{
internal static readonly Uri ProjectUrl = new Uri("https://github.com/PhoenixARC/-PCK-Studio");
internal static readonly Uri RawProjectUrl = new Uri("https://raw.githubusercontent.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/";
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>
@@ -39,9 +31,23 @@ namespace PckStudio
[STAThread]
static void Main(string[] args)
{
AutoUpdater.SetOwner(MainInstance);
//AutoUpdater.ClearAppDirectory = true;
#if DEBUG
AutoUpdater.ReportErrors = true;
#endif
AutoUpdater.DownloadPath = Application.StartupPath;
AutoUpdater.ExecutablePath = "./PCK-Studio.exe";
AutoUpdater.TopMost = true;
string jsonPath = Path.Combine(Environment.CurrentDirectory, "updates.json");
AutoUpdater.PersistenceProvider = new JsonFilePersistenceProvider(jsonPath);
AutoUpdater.ParseUpdateInfoEvent += AutoUpdaterOnParseUpdateInfoEvent;
AutoUpdater.Icon = Resources.ProjectLogo.ToBitmap();
if (Settings.Default.AutoUpdate)
{
UpdateToLatest("Click Ok to continue.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, DialogResult.OK);
UpdateToLatest();
}
ApplicationScope.Initialize();
@@ -51,24 +57,48 @@ namespace PckStudio
if (args.Length > 0 && File.Exists(args[0]) && args[0].EndsWith(".pck"))
MainInstance.InitPckFromFile(args[0]);
Application.ApplicationExit += (sender, e) => { RPC.Deinitialize(); };
MainInstance.FocusMe();
Application.Run(MainInstance);
}
[Conditional("NDEBUG")]
internal static void UpdateToLatest(string message, MessageBoxButtons buttons, MessageBoxIcon icon, DialogResult dialogResult)
internal static void UpdateToLatest()
{
bool updateAvailable = Updater.IsUpdateAvailable(Application.ProductVersion);
if (updateAvailable && MessageBox.Show(
MainInstance ?? null,
"New update available.\n" +
message,
"Update Available",
buttons, icon, MessageBoxDefaultButton.Button1) == dialogResult)
{
Updater.DownloadTo(new DirectoryInfo(Application.StartupPath));
Updater.Launch();
Application.Exit();
}
#if NDEBUG
string url = $"{RawProjectUrl}/main/Version.json";
AutoUpdater.Start(url);
#endif
}
class UpdateInfo
{
[JsonProperty("version")]
public string Version { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
[JsonProperty("changelog")]
public string Changelog { get; set; }
[JsonProperty("mandatory")]
public bool Mandatory { get; set; }
}
private static void AutoUpdaterOnParseUpdateInfoEvent(ParseUpdateInfoEventArgs args)
{
UpdateInfo json = JsonConvert.DeserializeObject<UpdateInfo>(args.RemoteData);
args.UpdateInfo = new UpdateInfoEventArgs
{
CurrentVersion = json.Version,
DownloadURL = json.Url,
ChangelogURL = json.Changelog,
Mandatory = new Mandatory()
{
Value = json.Mandatory,
}
};
}
}
}

View File

@@ -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.0.0")]
[assembly: AssemblyVersion("7.0.0.1")]
[assembly: AssemblyFileVersion("7.0.0.0")]
[assembly: NeutralResourcesLanguage("")]

View File

@@ -11,8 +11,6 @@ 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
@@ -80,24 +78,6 @@ 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

6
Version.json Normal file
View File

@@ -0,0 +1,6 @@
{
"version": "7.0.0.1",
"url": "https://github.com/PhoenixARC/-PCK-Studio/releases/download/v7.0.0.1/PCK-Studio.zip",
"changelog": "https://raw.githubusercontent.com/PhoenixARC/-PCK-Studio/main/CHANGELOG.md",
"mandatory": false
}