Merge branch 'main' into 3dSkinRenderer

This commit is contained in:
miku-666
2023-10-08 15:29:28 +02:00
24 changed files with 828 additions and 357 deletions

View 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;
}
}
}

View 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);
}
}
}
}

View 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();
}
}

View 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>

View 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;
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

View 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")]

View 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>

View File

@@ -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>

View File

@@ -27,7 +27,7 @@ namespace PckStudio.Classes.Misc
new Button()
{
Label = "Check it out!",
Url = Program.ProjectUrl,
Url = Program.ProjectUrl.AbsoluteUri,
}
};

View File

@@ -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");
}
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}

View File

@@ -1442,7 +1442,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAElPcGVuVEssIFZlcnNpb249My4zLjMuMCwgQ3VsdHVyZT1uZXV0
cmFsLCBQdWJsaWNLZXlUb2tlbj1iYWQxOTlmZTg0ZWIzZGY0BQEAAAAOT3BlblRLLlZlY3RvcjICAAAA
AVgBWQAACwsCAAAAAAAAAAAAAAAL
</value>
</value>
</data>
<data name="renderer3D1.Rotation" mimetype="application/x-microsoft.net.object.binary.base64">
<value>

View File

@@ -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();
@@ -147,7 +149,6 @@
this.skinRenderer3DToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
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();
@@ -640,6 +641,7 @@
// helpToolStripMenuItem
//
this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.checkForUpdatesToolStripMenuItem,
this.aboutToolStripMenuItem,
toolStripSeparator1,
this.videosToolStripMenuItem,
@@ -650,6 +652,12 @@
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");
@@ -1241,6 +1249,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;
private System.Windows.Forms.ToolStripMenuItem skinRenderer3DToolStripMenuItem;
}
}

View File

@@ -32,10 +32,11 @@ using PckStudio.Extensions;
using PckStudio.Popups;
using PckStudio.Classes.Utils;
using PckStudio.Helper;
using PCKStudio_Updater;
namespace PckStudio
{
public partial class MainForm : MetroFramework.Forms.MetroForm
public partial class MainForm : MetroFramework.Forms.MetroForm
{
private PckManager PckManager = null;
string saveLocation = string.Empty;
@@ -51,45 +52,45 @@ namespace PckStudio
{
InitializeComponent();
skinToolStripMenuItem1.Click += (sender, e) => SetFileType(PckFileType.SkinFile);
capeToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.CapeFile);
textureToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.TextureFile);
languagesFileLOCToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.LocalisationFile);
gameRulesFileGRFToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.GameRulesFile);
audioPCKFileToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.AudioFile);
coloursCOLFileToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.ColourTableFile);
gameRulesHeaderGRHToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.GameRulesHeader);
skinsPCKToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.SkinDataFile);
modelsFileBINToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.ModelsFile);
behavioursFileBINToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.BehavioursFile);
entityMaterialsFileBINToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.MaterialFile);
skinToolStripMenuItem1.Click += (sender, e) => SetFileType(PckFileType.SkinFile);
capeToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.CapeFile);
textureToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.TextureFile);
languagesFileLOCToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.LocalisationFile);
gameRulesFileGRFToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.GameRulesFile);
audioPCKFileToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.AudioFile);
coloursCOLFileToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.ColourTableFile);
gameRulesHeaderGRHToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.GameRulesHeader);
skinsPCKToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.SkinDataFile);
modelsFileBINToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.ModelsFile);
behavioursFileBINToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.BehavioursFile);
entityMaterialsFileBINToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.MaterialFile);
treeViewMain.TreeViewNodeSorter = new PckNodeSorter();
treeViewMain.TreeViewNodeSorter = new PckNodeSorter();
pckOpen.AllowDrop = true;
Text = Application.ProductName;
labelVersion.Text = $"{Application.ProductName}: {Application.ProductVersion}";
labelVersion.Text = $"{Application.ProductName}: {Application.ProductVersion}";
ChangelogRichTextBox.Text = Resources.CHANGELOG;
pckFileTypeHandler = new Dictionary<PckFileType, Action<PckFileData>>(15)
pckFileTypeHandler = new Dictionary<PckFileType, Action<PckFileData>>(15)
{
[PckFileType.SkinFile] = HandleSkinFile,
[PckFileType.CapeFile] = null,
[PckFileType.TextureFile] = HandleTextureFile,
[PckFileType.UIDataFile] = _ => throw new NotSupportedException("unused in-game"),
[PckFileType.InfoFile] = null,
[PckFileType.SkinFile] = HandleSkinFile,
[PckFileType.CapeFile] = null,
[PckFileType.TextureFile] = HandleTextureFile,
[PckFileType.UIDataFile] = _ => throw new NotSupportedException("unused in-game"),
[PckFileType.InfoFile] = null,
[PckFileType.TexturePackInfoFile] = null,
[PckFileType.LocalisationFile] = HandleLocalisationFile,
[PckFileType.GameRulesFile] = HandleGameRuleFile,
[PckFileType.AudioFile] = HandleAudioFile,
[PckFileType.ColourTableFile] = HandleColourFile,
[PckFileType.GameRulesHeader] = HandleGameRuleFile,
[PckFileType.SkinDataFile] = null,
[PckFileType.ModelsFile] = HandleModelsFile,
[PckFileType.BehavioursFile] = HandleBehavioursFile,
[PckFileType.MaterialFile] = HandleMaterialFile,
[PckFileType.LocalisationFile] = HandleLocalisationFile,
[PckFileType.GameRulesFile] = HandleGameRuleFile,
[PckFileType.AudioFile] = HandleAudioFile,
[PckFileType.ColourTableFile] = HandleColourFile,
[PckFileType.GameRulesHeader] = HandleGameRuleFile,
[PckFileType.SkinDataFile] = null,
[PckFileType.ModelsFile] = HandleModelsFile,
[PckFileType.BehavioursFile] = HandleBehavioursFile,
[PckFileType.MaterialFile] = HandleMaterialFile,
};
}
@@ -98,7 +99,7 @@ namespace PckStudio
checkSaveState();
treeViewMain.Nodes.Clear();
currentPCK = openPck(filepath);
if (currentPCK == null)
if (currentPCK == null)
{
MessageBox.Show(string.Format("Failed to load {0}", Path.GetFileName(filepath)), "Error");
return;
@@ -112,8 +113,8 @@ namespace PckStudio
{
SettingsManager.RegisterPropertyChangedCallback<bool>(nameof(Settings.Default.UseLittleEndianAsDefault), state =>
{
LittleEndianCheckBox.Checked = state;
});
LittleEndianCheckBox.Checked = state;
});
SettingsManager.RegisterPropertyChangedCallback(nameof(Settings.Default.LoadSubPcks), () =>
{
if (currentPCK is not null)
@@ -122,32 +123,32 @@ namespace PckStudio
}
});
imageList.Images.Add(Resources.ZZFolder); // Icon for folders
imageList.Images.Add(Resources.BINKA_ICON); // Icon for music cue file (audio.pck)
imageList.Images.Add(Resources.IMAGE_ICON); // Icon for images (unused for now)
imageList.Images.Add(Resources.LOC_ICON); // Icon for string localization files (languages.loc;localisation.loc)
imageList.Images.Add(Resources.PCK_ICON); // Icon for generic PCK files (*.pck)
imageList.Images.Add(Resources.ZUnknown); // Icon for Unknown formats
imageList.Images.Add(Resources.COL_ICON); // Icon for color palette files (colours.col)
imageList.Images.Add(Resources.SKINS_ICON); // Icon for Skin.pck archives (skins.pck)
imageList.Images.Add(Resources.MODELS_ICON); // Icon for Model files (models.bin)
imageList.Images.Add(Resources.GRF_ICON); // Icon for Game Rule files (*.grf)
imageList.Images.Add(Resources.GRH_ICON); // Icon for Game Rule Header files (*.grh)
imageList.Images.Add(Resources.INFO_ICON); // Icon for Info files (0)
imageList.Images.Add(Resources.SKIN_ICON); // Icon for Skin files (*.png)
imageList.Images.Add(Resources.CAPE_ICON); // Icon for Cape files (*.png)
imageList.Images.Add(Resources.TEXTURE_ICON); // Icon for Texture files (*.png;*.tga)
imageList.Images.Add(Resources.BEHAVIOURS_ICON); // Icon for Behaviour files (behaviours.bin)
imageList.Images.Add(Resources.ENTITY_MATERIALS_ICON); // Icon for Entity Material files (entityMaterials.bin)
imageList.Images.Add(Resources.ZZFolder); // Icon for folders
imageList.Images.Add(Resources.BINKA_ICON); // Icon for music cue file (audio.pck)
imageList.Images.Add(Resources.IMAGE_ICON); // Icon for images (unused for now)
imageList.Images.Add(Resources.LOC_ICON); // Icon for string localization files (languages.loc;localisation.loc)
imageList.Images.Add(Resources.PCK_ICON); // Icon for generic PCK files (*.pck)
imageList.Images.Add(Resources.ZUnknown); // Icon for Unknown formats
imageList.Images.Add(Resources.COL_ICON); // Icon for color palette files (colours.col)
imageList.Images.Add(Resources.SKINS_ICON); // Icon for Skin.pck archives (skins.pck)
imageList.Images.Add(Resources.MODELS_ICON); // Icon for Model files (models.bin)
imageList.Images.Add(Resources.GRF_ICON); // Icon for Game Rule files (*.grf)
imageList.Images.Add(Resources.GRH_ICON); // Icon for Game Rule Header files (*.grh)
imageList.Images.Add(Resources.INFO_ICON); // Icon for Info files (0)
imageList.Images.Add(Resources.SKIN_ICON); // Icon for Skin files (*.png)
imageList.Images.Add(Resources.CAPE_ICON); // Icon for Cape files (*.png)
imageList.Images.Add(Resources.TEXTURE_ICON); // Icon for Texture files (*.png;*.tga)
imageList.Images.Add(Resources.BEHAVIOURS_ICON); // Icon for Behaviour files (behaviours.bin)
imageList.Images.Add(Resources.ENTITY_MATERIALS_ICON); // Icon for Entity Material files (entityMaterials.bin)
isSelectingTab = true;
tabControl.SelectTab(0);
isSelectingTab = false;
isSelectingTab = true;
tabControl.SelectTab(0);
isSelectingTab = false;
UpdateRichPresence();
UpdateRichPresence();
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
PckManager?.Close();
checkSaveState();
@@ -222,7 +223,7 @@ namespace PckStudio
isSelectingTab = true;
tabControl.SelectTab(1);
isSelectingTab = false;
UpdateRichPresence();
UpdateRichPresence();
}
private void CloseEditorTab()
@@ -243,35 +244,35 @@ namespace PckStudio
saveToolStripMenuItem1.Enabled = false;
quickChangeToolStripMenuItem.Enabled = false;
closeToolStripMenuItem.Visible = false;
packSettingsToolStripMenuItem.Visible = false;
convertToBedrockToolStripMenuItem.Enabled = false;
packSettingsToolStripMenuItem.Visible = false;
convertToBedrockToolStripMenuItem.Enabled = false;
addCustomPackImageToolStripMenuItem.Enabled = false;
fileEntryCountLabel.Text = string.Empty;
pckFileLabel.Text = string.Empty;
UpdateRichPresence();
}
private void UpdateRichPresence()
{
if (currentPCK is not null &&
TryGetLocFile(out LOCFile locfile) &&
locfile.HasLocEntry("IDS_DISPLAY_NAME") &&
locfile.Languages.Contains("en-EN"))
{
RPC.SetPresence($"Editing a Pack: {locfile.GetLocEntry("IDS_DISPLAY_NAME", "en-EN")}");
return;
}
// default
RPC.SetPresence("An Open Source .PCK File Editor");
}
private void UpdateRichPresence()
{
if (currentPCK is not null &&
TryGetLocFile(out LOCFile locfile) &&
locfile.HasLocEntry("IDS_DISPLAY_NAME") &&
locfile.Languages.Contains("en-EN"))
{
RPC.SetPresence($"Editing a Pack: {locfile.GetLocEntry("IDS_DISPLAY_NAME", "en-EN")}");
return;
}
// default
RPC.SetPresence("An Open Source .PCK File Editor");
}
/// <summary>
/// wrapper that allows the use of <paramref name="name"/> in <code>TreeNode.Nodes.Find(<paramref name="name"/>, ...)</code> and <code>TreeNode.Nodes.ContainsKey(<paramref name="name"/>)</code>
/// </summary>
/// <param name="name"></param>
/// <param name="tag"></param>
/// <returns>new Created TreeNode</returns>
public static TreeNode CreateNode(string name, object tag = null)
/// <summary>
/// wrapper that allows the use of <paramref name="name"/> in <code>TreeNode.Nodes.Find(<paramref name="name"/>, ...)</code> and <code>TreeNode.Nodes.ContainsKey(<paramref name="name"/>)</code>
/// </summary>
/// <param name="name"></param>
/// <param name="tag"></param>
/// <returns>new Created TreeNode</returns>
public static TreeNode CreateNode(string name, object tag = null)
{
TreeNode node = new TreeNode(name);
node.Name = name;
@@ -307,25 +308,25 @@ namespace PckStudio
node.Tag = file;
if (Settings.Default.LoadSubPcks &&
(file.Filetype == PckFileType.SkinDataFile || file.Filetype == PckFileType.TexturePackInfoFile) &&
file.Size > 0)
file.Size > 0)
{
using (var stream = new MemoryStream(file.Data))
using (var stream = new MemoryStream(file.Data))
{
try
{
try
{
var reader = new PckFileReader(LittleEndianCheckBox.Checked ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian);
PckFile subPCKfile = reader.FromStream(stream);
// passes parent path to remove from sub pck filepaths
BuildPckTreeView(node.Nodes, subPCKfile, file.Filename + "/");
}
catch (OverflowException ex)
{
MessageBox.Show("Failed to open pck\n" +
"Try checking the 'Open/Save as Switch/Vita/PS4 pck' checkbox in the upper right corner.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Debug.WriteLine(ex.Message);
}
var reader = new PckFileReader(LittleEndianCheckBox.Checked ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian);
PckFile subPCKfile = reader.FromStream(stream);
// passes parent path to remove from sub pck filepaths
BuildPckTreeView(node.Nodes, subPCKfile, file.Filename + "/");
}
catch (OverflowException ex)
{
MessageBox.Show("Failed to open pck\n" +
"Try checking the 'Open/Save as Switch/Vita/PS4 pck' checkbox in the upper right corner.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Debug.WriteLine(ex.Message);
}
}
}
SetNodeIcon(node, file.Filetype);
};
@@ -352,10 +353,10 @@ namespace PckStudio
treeViewMain.Sort();
TreeNode[] selectedNodes;
if (!string.IsNullOrEmpty(selectedNodeText) &&
if (!string.IsNullOrEmpty(selectedNodeText) &&
(selectedNodes = treeViewMain.Nodes.Find(selectedNodeText, true)).Length > 0)
{
treeViewMain.SelectedNode = selectedNodes[0];
treeViewMain.SelectedNode = selectedNodes[0];
}
}
@@ -373,8 +374,8 @@ namespace PckStudio
{
var img = file.GetTexture();
var res = img.Width / 16; // texture count on X axes
var size = new Size(res, res);
var viewer = new TextureAtlasEditor(currentPCK, file.Filename, img, size);
var size = new Size(res, res);
var viewer = new TextureAtlasEditor(currentPCK, file.Filename, img, size);
if (viewer.ShowDialog() == DialogResult.OK)
{
file.SetData(viewer.FinalTexture, ImageFormat.Png);
@@ -437,17 +438,17 @@ namespace PckStudio
}
return;
}
var img = file.GetTexture();
using var skinViewer = new SkinPreview(img, file.Properties.GetPropertyValue("ANIM", SkinANIM.FromString));
skinViewer.ShowDialog(this);
}
skinViewer.ShowDialog(this);
}
public void HandleModelsFile(PckFileData file)
{
MessageBox.Show("Models.bin support has not been implemented. You can use the Spark Editor for the time being to edit these files.", "Not implemented yet.");
}
public void HandleBehavioursFile(PckFileData file)
{
using BehaviourEditor edit = new BehaviourEditor(file);
@@ -459,7 +460,7 @@ namespace PckStudio
using MaterialsEditor edit = new MaterialsEditor(file);
wasModified = edit.ShowDialog(this) == DialogResult.OK;
}
private void selectNode(object sender, TreeViewEventArgs e)
{
ReloadMetaTreeView();
@@ -499,7 +500,7 @@ namespace PckStudio
img = new Bitmap(img);
}
try
try
{
previewPictureBox.Image = img;
labelImageSize.Text = $"{previewPictureBox.Image.Size.Width}x{previewPictureBox.Image.Size.Height}";
@@ -567,7 +568,7 @@ namespace PckStudio
File.WriteAllBytes(extractFilePath, file.Data);
if (file.Properties.Count > 0)
{
using var fs = File.CreateText($"{extractFilePath}.txt");
using var fs = File.CreateText($"{extractFilePath}.txt");
file.Properties.ForEach(property => fs.WriteLine($"{property.Key}: {property.Value}"));
}
// Verification that file extraction path was successful
@@ -682,29 +683,29 @@ namespace PckStudio
/// <returns>True if the remove should be canceled, otherwise False</returns>
private bool BeforeFileRemove(PckFileData file)
{
string itemPath = "res/textures/items/";
string itemPath = "res/textures/items/";
// warn the user about deleting compass.png and clock.png
if (file.Filetype == PckFileType.TextureFile &&
(file.Filename == itemPath + "compass.png" || file.Filename == itemPath + "clock.png"))
{
if (MessageBox.Show("Are you sure want to delete this file? If \"compass.png\" or \"clock.png\" are missing, your game will crash upon loading this pack.", "Warning",
// warn the user about deleting compass.png and clock.png
if (file.Filetype == PckFileType.TextureFile &&
(file.Filename == itemPath + "compass.png" || file.Filename == itemPath + "clock.png"))
{
if (MessageBox.Show("Are you sure want to delete this file? If \"compass.png\" or \"clock.png\" are missing, your game will crash upon loading this pack.", "Warning",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
return true;
}
}
// remove loc key if its a skin/cape
if (file.Filetype == PckFileType.SkinFile || file.Filetype == PckFileType.CapeFile)
{
if (TryGetLocFile(out LOCFile locFile))
{
// remove loc key if its a skin/cape
if (file.Filetype == PckFileType.SkinFile || file.Filetype == PckFileType.CapeFile)
{
if (TryGetLocFile(out LOCFile locFile))
{
locFile.RemoveLocKey(file.Properties.GetPropertyValue("THEMENAMEID"));
locFile.RemoveLocKey(file.Properties.GetPropertyValue("DISPLAYNAMEID"));
TrySetLocFile(locFile);
}
}
TrySetLocFile(locFile);
}
}
return false;
}
}
private void deleteFileToolStripMenuItem_Click(object sender, EventArgs e)
{
@@ -716,7 +717,7 @@ namespace PckStudio
if (node.TryGetTagData(out PckFileData file))
{
if (!BeforeFileRemove(file) && currentPCK.RemoveFile(file))
if (!BeforeFileRemove(file) && currentPCK.RemoveFile(file))
{
node.Remove();
wasModified = true;
@@ -824,7 +825,7 @@ namespace PckStudio
audioPck.AddCategory(PckAudioFile.AudioCategory.EAudioType.Nether);
audioPck.AddCategory(PckAudioFile.AudioCategory.EAudioType.End);
PckFileData pckFileData = new PckFileData("audio.pck", PckFileType.AudioFile);
pckFileData.SetData(new PckAudioFileWriter(audioPck, isLittle ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian));
pckFileData.SetData(new PckAudioFileWriter(audioPck, isLittle ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian));
return pckFileData;
}
@@ -844,7 +845,7 @@ namespace PckStudio
var file = CreateNewAudioFile(LittleEndianCheckBox.Checked);
AudioEditor diag = new AudioEditor(file, LittleEndianCheckBox.Checked);
if(diag.ShowDialog(this) == DialogResult.OK)
if (diag.ShowDialog(this) == DialogResult.OK)
{
currentPCK.AddFile(file);
}
@@ -875,7 +876,7 @@ namespace PckStudio
{
wasModified = true;
AnimationHelper.SaveAnimationToFile(file, animation);
currentPCK.AddFile(file);
currentPCK.AddFile(file);
BuildMainTreeView();
ReloadMetaTreeView();
}
@@ -898,7 +899,7 @@ namespace PckStudio
List<TreeNode> GetAllChildNodes(TreeNodeCollection root)
{
List<TreeNode> childNodes = new List<TreeNode>();
foreach(TreeNode node in root)
foreach (TreeNode node in root)
{
childNodes.Add(node);
if (node.Nodes.Count > 0)
@@ -914,7 +915,7 @@ namespace PckStudio
string parentPath = childPath.Replace('\\', '/');
Debug.WriteLine(parentPath);
string[] s = parentPath.Split('/');
Debug.WriteLine(s.Length);
Debug.WriteLine(s.Length);
foreach (var node in s)
{
TreeNode parent = treeViewMain.Nodes.Find(node, true)[0];
@@ -931,16 +932,16 @@ namespace PckStudio
{
// Support for if a file is edited within a nested PCK File (AKA SubPCK)
if(!IsSubPCKNode(childPath)) return;
if (!IsSubPCKNode(childPath)) return;
TreeNode parent = GetSubPCK(childPath);
Debug.WriteLine(parent.Name);
Debug.WriteLine(parent.Name);
if (parent == null) return;
PckFileData parent_file = parent.Tag as PckFileData;
if (parent_file.Filetype is PckFileType.TexturePackInfoFile || parent_file.Filetype is PckFileType.SkinDataFile)
{
Debug.WriteLine("Rebuilding " + parent_file.Filename);
Debug.WriteLine("Rebuilding " + parent_file.Filename);
PckFile newPCKFile = new PckFile(3, parent_file.Filetype is PckFileType.SkinDataFile);
foreach (TreeNode node in GetAllChildNodes(parent.Nodes))
@@ -964,12 +965,12 @@ namespace PckStudio
{
if (treeViewMain.SelectedNode.TryGetTagData(out PckFileData file))
{
if (file.Size <= 0)
{
Trace.WriteLine($"'{file.Filename}' has no data attached.", category: nameof(treeViewMain_DoubleClick));
return;
}
pckFileTypeHandler[file.Filetype]?.Invoke(file);
if (file.Size <= 0)
{
Trace.WriteLine($"'{file.Filename}' has no data attached.", category: nameof(treeViewMain_DoubleClick));
return;
}
pckFileTypeHandler[file.Filetype]?.Invoke(file);
}
}
@@ -1080,9 +1081,9 @@ namespace PckStudio
if (GetAllChildNodes(treeViewMain.Nodes).Find(n => n.FullPath == diag.NewText) != null)
{
MessageBox.Show(
this,
this,
$"A file with the path \"{diag.NewText}\" already exists. " +
$"Please try again with a different name.",
$"Please try again with a different name.",
"Key already exists");
return;
}
@@ -1119,7 +1120,7 @@ namespace PckStudio
foreach (var property in file.Properties)
{
treeMeta.Nodes.Add(CreateNode(property.Key, property));
}
}
}
}
@@ -1173,7 +1174,7 @@ namespace PckStudio
private PckFile InitializePack(int packId, int packVersion, string packName, bool createSkinsPCK)
{
var pack = new PckFile(3);
var zeroFile = pack.CreateNewFile("0", PckFileType.InfoFile);
zeroFile.Properties.Add("PACKID", packId.ToString());
zeroFile.Properties.Add("PACKVERSION", packVersion.ToString());
@@ -1186,7 +1187,7 @@ namespace PckStudio
LittleEndianCheckBox.Checked
? OMI.Endianness.LittleEndian
: OMI.Endianness.BigEndian));
return pack;
}
@@ -1231,9 +1232,9 @@ namespace PckStudio
new KeyValuePair<string, string>("spawnY", "0"),
new KeyValuePair<string, string>("spawnZ", "0")
);
gameRuleFile.SetData(new GameRuleFileWriter(grfFile));
return pack;
}
@@ -1357,7 +1358,7 @@ namespace PckStudio
FileInfo fileinfo = new FileInfo(filepath);
fileinfo.Directory.Create();
File.WriteAllBytes(filepath, file.Data); // writes data to file
//attempts to generate reimportable metadata file out of minefiles metadata
//attempts to generate reimportable metadata file out of minefiles metadata
string metaData = "";
foreach (var entry in file.Properties)
@@ -1433,7 +1434,7 @@ namespace PckStudio
if (File.Exists(fullfilename + ".txt"))
{
string[] properties = File.ReadAllText(fullfilename + ".txt").Split(new string[]{ Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
string[] properties = File.ReadAllText(fullfilename + ".txt").Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
foreach (string property in properties)
{
string[] param = property.Split(':');
@@ -1588,7 +1589,7 @@ namespace PckStudio
private void folderToolStripMenuItem_Click(object sender, EventArgs e)
{
TextPrompt folderNamePrompt = new TextPrompt();
if(treeViewMain.SelectedNode is not null) folderNamePrompt.contextLabel.Text = $"New folder at the location of \"{treeViewMain.SelectedNode.FullPath}\"";
if (treeViewMain.SelectedNode is not null) folderNamePrompt.contextLabel.Text = $"New folder at the location of \"{treeViewMain.SelectedNode.FullPath}\"";
folderNamePrompt.OKButtonText = "Add";
if (folderNamePrompt.ShowDialog() == DialogResult.OK)
{
@@ -1619,9 +1620,9 @@ namespace PckStudio
MessageBox.Show("This feature is currently being reworked.", "Currently unavailable", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void openPckCenterToolStripMenuItem_Click(object sender, EventArgs e)
private void openPckCenterToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("This feature is currently being reworked.", "Currently unavailable", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show("This feature is currently being reworked.", "Currently unavailable", MessageBoxButtons.OK, MessageBoxIcon.Information);
#if false
DateTime Begin = DateTime.Now;
//pckCenter open = new pckCenter();
@@ -1703,14 +1704,14 @@ namespace PckStudio
if (currentPCK is not null &&
wasModified &&
MessageBox.Show("Save PCK?", "Unsaved PCK", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
if (isTemplateFile || string.IsNullOrEmpty(saveLocation))
{
if (isTemplateFile || string.IsNullOrEmpty(saveLocation))
{
SaveTemplate();
return;
}
Save(saveLocation);
SaveTemplate();
return;
}
Save(saveLocation);
}
}
private void OpenPck_DragEnter(object sender, DragEventArgs e)
@@ -1892,15 +1893,15 @@ namespace PckStudio
{
string mippedPath = $"{textureDirectory}/{textureName}MipMapLevel{i}{textureExtension}";
Debug.WriteLine(mippedPath);
if (currentPCK.HasFile(mippedPath, PckFileType.TextureFile))
if (currentPCK.HasFile(mippedPath, PckFileType.TextureFile))
currentPCK.RemoveFile(currentPCK.GetFile(mippedPath, PckFileType.TextureFile));
PckFileData MipMappedFile = new PckFileData(mippedPath, PckFileType.TextureFile);
Image originalTexture = Image.FromStream(new MemoryStream(file.Data));
int NewWidth = Math.Max(originalTexture.Width / (int)Math.Pow(2,i - 1), 1);
int NewWidth = Math.Max(originalTexture.Width / (int)Math.Pow(2, i - 1), 1);
int NewHeight = Math.Max(originalTexture.Height / (int)Math.Pow(2, i - 1), 1);
Rectangle tileArea = new Rectangle(0, 0, NewWidth, NewHeight);
Image mippedTexture = new Bitmap(NewWidth, NewHeight);
using (Graphics gfx = Graphics.FromImage(mippedTexture))
@@ -1910,7 +1911,7 @@ namespace PckStudio
gfx.PixelOffsetMode = PixelOffsetMode.HighQuality;
gfx.DrawImage(originalTexture, tileArea);
}
MipMappedFile.SetData(mippedTexture, ImageFormat.Png);
currentPCK.InsertFile(currentPCK.IndexOfFile(file) + i - 1, MipMappedFile);
@@ -1985,9 +1986,9 @@ namespace PckStudio
if (treeViewMain.SelectedNode.TryGetTagData(out PckFileData file) &&
file.Filetype == PckFileType.SkinFile)
{
foreach(var p in file.Properties.FindAll(s => s.Key == "BOX" || s.Key == "OFFSET"))
foreach (var p in file.Properties.FindAll(s => s.Key == "BOX" || s.Key == "OFFSET"))
{
file.Properties[file.Properties.IndexOf(p)] = new KeyValuePair<string, string>(p.Key, p.Value.Replace(',','.'));
file.Properties[file.Properties.IndexOf(p)] = new KeyValuePair<string, string>(p.Key, p.Value.Replace(',', '.'));
}
ReloadMetaTreeView();
RebuildSubPCK(treeViewMain.SelectedNode.FullPath);
@@ -2007,9 +2008,9 @@ namespace PckStudio
if (currentPCK is not null)
{
DialogResult prompt = MessageBox.Show(this,
"Would you like to use the current PackID? You can enter any PackID if not.",
"",
DialogResult prompt = MessageBox.Show(this,
"Would you like to use the current PackID? You can enter any PackID if not.",
"",
MessageBoxButtons.YesNoCancel);
switch (prompt)
@@ -2018,9 +2019,9 @@ namespace PckStudio
if (!currentPCK.TryGetFile("0", PckFileType.InfoFile, out PckFileData file) ||
string.IsNullOrEmpty(file.Properties.GetPropertyValue("PACKID")))
{
MessageBox.Show(this,
MessageBox.Show(this,
"No PackID is present in this PCK. " +
"To avoid this error, ensure that the PCK has a proper PackID property on the \"0\" Info file before trying again.",
"To avoid this error, ensure that the PCK has a proper PackID property on the \"0\" Info file before trying again.",
"Operation Aborted", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
@@ -2191,21 +2192,21 @@ namespace PckStudio
if (!PckManager.Visible)
{
PckManager.Show();
PckManager.BringToFront();
}
PckManager.BringToFront();
}
if (PckManager.Focus())
PckManager.BringToFront();
}
private void wavBinkaToolStripMenuItem_Click(object sender, EventArgs e)
{
using OpenFileDialog fileDialog = new OpenFileDialog
{
Multiselect = true,
Filter = "WAV files (*.wav)|*.wav",
Title = "Please choose WAV files to convert to BINKA"
};
if (fileDialog.ShowDialog() == DialogResult.OK)
using OpenFileDialog fileDialog = new OpenFileDialog
{
Multiselect = true,
Filter = "WAV files (*.wav)|*.wav",
Title = "Please choose WAV files to convert to BINKA"
};
if (fileDialog.ShowDialog() == DialogResult.OK)
{
BinkaConverter.ToBinka(fileDialog.FileNames, new DirectoryInfo(Path.GetDirectoryName(fileDialog.FileName)));
}
@@ -2213,32 +2214,32 @@ namespace PckStudio
private void binkaWavToolStripMenuItem_Click(object sender, EventArgs e)
{
using OpenFileDialog fileDialog = new OpenFileDialog
{
Multiselect = true,
Filter = "BINKA files (*.binka)|*.binka",
Title = "Please choose BINKA files to convert to WAV"
};
if (fileDialog.ShowDialog() == DialogResult.OK)
using OpenFileDialog fileDialog = new OpenFileDialog
{
Multiselect = true,
Filter = "BINKA files (*.binka)|*.binka",
Title = "Please choose BINKA files to convert to WAV"
};
if (fileDialog.ShowDialog() == DialogResult.OK)
{
BinkaConverter.ToWav(fileDialog.FileNames, new DirectoryInfo(Path.GetDirectoryName(fileDialog.FileName)));
}
}
private void fullBoxSupportToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
{
private void fullBoxSupportToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
{
currentPCK.SetVersion(fullBoxSupportToolStripMenuItem.Checked);
}
}
private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
{
private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
{
var appSettings = new AppSettingsForm();
appSettings.ShowDialog(this);
}
}
private void addBOXEntryToolStripMenuItem1_Click(object sender, EventArgs e)
{
if(treeViewMain.SelectedNode is TreeNode t && t.Tag is PckFileData file)
if (treeViewMain.SelectedNode is TreeNode t && t.Tag is PckFileData file)
{
using BoxEditor diag = new BoxEditor(SkinBOX.Empty, IsSubPCKNode(treeViewMain.SelectedNode.FullPath));
if (diag.ShowDialog(this) == DialogResult.OK)
@@ -2268,10 +2269,20 @@ namespace PckStudio
}
}
private void skinRenderer3DToolStripMenuItem_Click(object sender, EventArgs e)
{
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");
}
private void skinRenderer3DToolStripMenuItem_Click(object sender, EventArgs e)
{
var gl = new TestGL();
gl.Show();
}
}
}
}
}

View File

@@ -815,6 +815,9 @@
<data name="toolStripSeparator1.Size" type="System.Drawing.Size, System.Drawing">
<value>177, 6</value>
</data>
<data name="toolStripSeparator3.Size" type="System.Drawing.Size, System.Drawing">
<value>177, 6</value>
</data>
<metadata name="toolStripSeparator3.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
@@ -1570,6 +1573,12 @@
<data name="storeToolStripMenuItem.Text" xml:space="preserve">
<value>More</value>
</data>
<data name="checkForUpdatesToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
</data>
<data name="checkForUpdatesToolStripMenuItem.Text" xml:space="preserve">
<value>Check for updates</value>
</data>
<data name="aboutToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAtAAAALQCAYAAAC5V0ecAAAABGdBTUEAALGPC/xhBQAAazFJREFUeF7t
@@ -6810,6 +6819,12 @@
<data name="&gt;&gt;helpToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;checkForUpdatesToolStripMenuItem.Name" xml:space="preserve">
<value>checkForUpdatesToolStripMenuItem</value>
</data>
<data name="&gt;&gt;checkForUpdatesToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;aboutToolStripMenuItem.Name" xml:space="preserve">
<value>aboutToolStripMenuItem</value>
</data>

View File

@@ -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>
@@ -228,9 +229,7 @@
<Compile Include="Internal\SkinBOX.cs" />
<Compile Include="Extensions\ImageExtensions.cs" />
<Compile Include="Internal\SkinANIM.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>
@@ -571,6 +570,7 @@
</EmbeddedResource>
<EmbeddedResource Include="Forms\Skins-And-Textures\generateModel.resx">
<DependentUpon>generateModel.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Skins-And-Textures\SkinPreview.resx">
<DependentUpon>SkinPreview.cs</DependentUpon>
@@ -734,6 +734,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>

View File

@@ -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();
}
}
}
}
}

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")]
[assembly: AssemblyFileVersion("7.0")]
[assembly: AssemblyVersion("7.0.0.0")]
[assembly: AssemblyFileVersion("7.0.0.0")]
[assembly: NeutralResourcesLanguage("")]

View File

@@ -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")]

View File

@@ -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>

View File

@@ -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