mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-07-18 21:48:52 +00:00
Merge 'main' into 'UI-UpdateBranch'
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +1,6 @@
|
||||
[submodule "OMI-Lib"]
|
||||
path = Vendor/OMI-Lib
|
||||
url = https://github.com/PhoenixARC/-OMI-Filetype-Library.git
|
||||
[submodule "Vendor/CrEaTiiOn-Brotherhood-Official-C-Theme"]
|
||||
path = Vendor/CrEaTiiOn-Brotherhood-Official-C-Theme
|
||||
url = https://github.com/NessieHax/CrEaTiiOn-Brotherhood-Official-C-Theme.git
|
||||
|
||||
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,7 +1,13 @@
|
||||
7.0 (BETA)
|
||||
==========
|
||||
7.0 (IN DEVELOPMENT)
|
||||
====================
|
||||
Some features may be completely missing or incomplete at this point in time!
|
||||
|
||||
|
||||
-Added .3dst (3DS Texture) support
|
||||
-Semi-added Sub-Pck editing
|
||||
-Add an edit all properties tool item
|
||||
-Skin Preview has been improved
|
||||
-Added Pack Icon Injection into .arc file
|
||||
-Improved COL Editor
|
||||
-Massive codebase overhaul and optimization lead by miku-666 (aka NessieHax)!!!
|
||||
-Some UI redesigned by yaboiFoxx
|
||||
-Improved the changelog!
|
||||
|
||||
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
@@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<section name="PckStudio.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
||||
</startup>
|
||||
@@ -35,4 +40,11 @@
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<applicationSettings>
|
||||
<PckStudio.Properties.Settings>
|
||||
<setting name="RichPresenceId" serializeAs="String">
|
||||
<value>825875166574673940</value>
|
||||
</setting>
|
||||
</PckStudio.Properties.Settings>
|
||||
</applicationSettings>
|
||||
</configuration>
|
||||
|
||||
140
PCK-Studio/Classes/API/PCKCenter/PCKCollections.cs
Normal file
140
PCK-Studio/Classes/API/PCKCenter/PCKCollections.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Drawing;
|
||||
using Newtonsoft.Json;
|
||||
using PckStudio.API.PCKCenter.model;
|
||||
|
||||
namespace PckStudio.API.PCKCenter
|
||||
{
|
||||
public class PCKCollections
|
||||
{
|
||||
WebClient client = new WebClient();
|
||||
public string CurrentPackDl = "";
|
||||
string cache = Program.AppDataCache + "/packs";
|
||||
public PCKCenterJSON CenterPacks;
|
||||
public LocalActions LocalAction = new LocalActions();
|
||||
|
||||
public string[] GetCategories() => GetCategories(false);
|
||||
|
||||
public string[] GetCategories(bool isVita)
|
||||
{
|
||||
try
|
||||
{
|
||||
return DownloadAndDeserializeJson<string[]>
|
||||
($"{Program.BaseAPIUrl}/center/packs/{(isVita ? "VitaCategiories.json" : "Categiories.json")}", client);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
|
||||
public PCKCenterJSON GetPackDescs(string category, bool isVita)
|
||||
{
|
||||
string cat;
|
||||
try
|
||||
{
|
||||
cat = client.DownloadString($"{Program.BaseAPIUrl}/center/packs/{(isVita ? "vita" : "normal")}/{category}.json");
|
||||
}
|
||||
catch
|
||||
{
|
||||
cat = client.DownloadString($"{Program.BackUpAPIUrl}/center/packs/{(isVita ? "vita" : "normal")}/{category}.json");
|
||||
}
|
||||
PCKCenterJSON Data = JsonConvert.DeserializeObject<PCKCenterJSON>(cat);
|
||||
return Data;
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public string[] GetPackDescription(string category, bool isVita)
|
||||
{
|
||||
return Array.Empty<string>();
|
||||
string cat;
|
||||
try
|
||||
{
|
||||
cat = client.DownloadString($"{Program.BaseAPIUrl}/studio/PCK/api/pcks{(isVita ? "/Vita" : "")}/{category}.desc");
|
||||
}
|
||||
catch
|
||||
{
|
||||
cat = client.DownloadString($"{Program.BackUpAPIUrl}/studio/PCK/api/pcks{(isVita ? "/Vita" : "")}/{category}.desc");
|
||||
}
|
||||
return cat.Split(new[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public Image GetPackImage(int packId, bool isVita)
|
||||
{
|
||||
byte[] data;
|
||||
try
|
||||
{
|
||||
data = client.DownloadData($"{Program.BaseAPIUrl}/center/packs/{(isVita ? "vita" : "normal")}/images/{packId}.png");
|
||||
}
|
||||
catch
|
||||
{
|
||||
data = client.DownloadData($"{Program.BackUpAPIUrl}/center/packs/{(isVita ? "vita" : "normal")}/images/{packId}.png");
|
||||
}
|
||||
Image image;
|
||||
using (MemoryStream fs = new MemoryStream(data))
|
||||
{
|
||||
image = Image.FromStream(fs);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
public bool TryDownloadPack(string category, int packId, bool isVita)
|
||||
{
|
||||
try
|
||||
{
|
||||
Image packImage = GetPackImage(packId, isVita);
|
||||
packImage.Save($"{cache}/{(isVita ? "vita" : "normal")}/images/" + packId + ".png");
|
||||
packImage.Dispose();
|
||||
|
||||
Directory.CreateDirectory(cache + "/normal/");
|
||||
Directory.CreateDirectory(cache + "/normal/images");
|
||||
Directory.CreateDirectory(cache + "/normal/pcks");
|
||||
Directory.CreateDirectory(cache + "/vita/");
|
||||
Directory.CreateDirectory(cache + "/vita/images");
|
||||
Directory.CreateDirectory(cache + "/vita/pcks");
|
||||
PCKCenterJSON Local = LocalAction.GetLocalJSON(category, isVita);
|
||||
client.DownloadFile($"{Program.BaseAPIUrl}/center/packs/{(isVita ? "vita" : "normal")}/pcks/{packId}.pck", $"{cache}/vita/pcks/{packId}.pck");
|
||||
|
||||
Local = LocalAction.AddPack(Local, CenterPacks.Data[packId.ToString()], packId);
|
||||
LocalAction.SaveLocalJSON(Local, category, isVita);
|
||||
LocalAction.SaveLocalCategories(isVita);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
T DownloadAndDeserializeJson<T>(string address, WebClient client = null)
|
||||
{
|
||||
WebClient wc = client ?? new WebClient();
|
||||
string jsonData = wc.DownloadString(address);
|
||||
return JsonConvert.DeserializeObject<T>(jsonData);
|
||||
}
|
||||
|
||||
PCKCenterJSON DownloadCategoryJson(string categorie, bool isVita, WebClient client = null)
|
||||
{
|
||||
return DownloadAndDeserializeJson<PCKCenterJSON>
|
||||
($"{Program.BaseAPIUrl}/center/packs/{(isVita ? "vita" :"normal")}/{categorie}.json", client);
|
||||
}
|
||||
|
||||
public void TryTestPackInfo(bool isVita)
|
||||
{
|
||||
try
|
||||
{
|
||||
WebClient client = new WebClient();
|
||||
string categoryJSON = client.DownloadString(Program.BaseAPIUrl + "/center/packs/Categiories.json");
|
||||
string[] categories = JsonConvert.DeserializeObject<string[]>(categoryJSON);
|
||||
PCKCenterJSON result = DownloadCategoryJson(categories[2], false, client);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,11 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
using Newtonsoft.Json;
|
||||
using PckStudio.API.PCKCenter.model;
|
||||
using PckStudio.API.PCKCenter;
|
||||
|
||||
namespace PckStudio.Classes.IO
|
||||
namespace PckStudio.API.PCKCenter
|
||||
{
|
||||
public class PCKCollectionsLocal
|
||||
{
|
||||
@@ -42,7 +42,7 @@ namespace PckStudio.API.PCKCenter
|
||||
return JSONData;
|
||||
}
|
||||
}
|
||||
public PCKCenterJSON AddPack(PCKCenterJSON JSONData,EntryInfo EInfo, int PackID)
|
||||
public PCKCenterJSON AddPack(PCKCenterJSON JSONData, EntryInfo EInfo, int PackID)
|
||||
{
|
||||
JSONData.Data.Add(PackID.ToString(), EInfo);
|
||||
return JSONData;
|
||||
|
||||
17
PCK-Studio/Classes/Extentions/EnumerableExtentions.cs
Normal file
17
PCK-Studio/Classes/Extentions/EnumerableExtentions.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PckStudio.Classes.Extentions
|
||||
{
|
||||
internal static class EnumerableExtentions
|
||||
{
|
||||
public static IEnumerable<(int index, T type)>enumerate<T>(this IEnumerable<T> array)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var item in array)
|
||||
{
|
||||
yield return (i++, item);
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
110
PCK-Studio/Classes/Extentions/ImageExtentions.cs
Normal file
110
PCK-Studio/Classes/Extentions/ImageExtentions.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing;
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
|
||||
namespace PckStudio.Classes.Extentions
|
||||
{
|
||||
internal static class ImageExtentions
|
||||
{
|
||||
|
||||
public enum ImageLayoutDirection
|
||||
{
|
||||
Horizontal,
|
||||
Vertical
|
||||
}
|
||||
|
||||
private struct ImageLayoutInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Size of sub section of the image
|
||||
/// </summary>
|
||||
public Size SectionSize;
|
||||
public Point SectionPoint;
|
||||
|
||||
public ImageLayoutInfo(int width, int height, int index, ImageLayoutDirection layoutDirection)
|
||||
{
|
||||
bool horizontal = layoutDirection == ImageLayoutDirection.Horizontal;
|
||||
SectionSize = horizontal ? new Size(width, width) : new Size(height, height);
|
||||
SectionPoint = horizontal ? new Point(0, index * width) : new Point(index * height, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static Image GetTileImage(Image source, Rectangle area, Size size, GraphicsUnit unit = GraphicsUnit.Pixel)
|
||||
{
|
||||
Image tileImage = new Bitmap(size.Width, size.Height);
|
||||
using (Graphics gfx = Graphics.FromImage(tileImage))
|
||||
{
|
||||
gfx.SmoothingMode = SmoothingMode.None;
|
||||
gfx.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||
gfx.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
gfx.DrawImage(source, new Rectangle(Point.Empty, size), area, unit);
|
||||
}
|
||||
return tileImage;
|
||||
}
|
||||
|
||||
public static IEnumerable<Image> CreateImageList(this Image source, Size size)
|
||||
{
|
||||
int img_row_count = source.Width / size.Width;
|
||||
int img_column_count = source.Height / size.Height;
|
||||
Debug.WriteLine($"{source.Width} {source.Height} {size} {img_column_count} {img_row_count}");
|
||||
for (int i = 0; i < img_column_count * img_row_count; i++)
|
||||
{
|
||||
int row = i / img_row_count;
|
||||
int column = i % img_row_count;
|
||||
Rectangle tileArea = new Rectangle(new Point(column * size.Height, row * size.Width), size);
|
||||
yield return GetTileImage(source, tileArea, size);
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
public static IEnumerable<Image> CreateImageList(this Image source, int scalar)
|
||||
{
|
||||
return CreateImageList(source, new Size(scalar, scalar));
|
||||
}
|
||||
|
||||
public static IEnumerable<Image> CreateImageList(this Image source, ImageLayoutDirection layoutDirection)
|
||||
{
|
||||
for (int i = 0; i < source.Height / source.Width; i++)
|
||||
{
|
||||
ImageLayoutInfo locationInfo = new ImageLayoutInfo(source.Width, source.Height, i, layoutDirection);
|
||||
Rectangle tileArea = new Rectangle(locationInfo.SectionPoint, locationInfo.SectionSize);
|
||||
yield return GetTileImage(source, tileArea, locationInfo.SectionSize);
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
public static Image ImageFromImageArray(Image[] sources, ImageLayoutDirection layoutDirection)
|
||||
{
|
||||
Size imageSize = CalculateImageSize(sources, layoutDirection);
|
||||
var result = new Bitmap(imageSize.Width, imageSize.Height);
|
||||
|
||||
using (var graphic = Graphics.FromImage(result))
|
||||
{
|
||||
foreach (var (i, texture) in sources.enumerate())
|
||||
{
|
||||
var info = new ImageLayoutInfo(imageSize.Width, imageSize.Height, i, layoutDirection);
|
||||
graphic.DrawImage(texture, info.SectionPoint);
|
||||
};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Size CalculateImageSize(Image[] sources, ImageLayoutDirection layoutDirection)
|
||||
{
|
||||
var horizontal = layoutDirection == ImageLayoutDirection.Horizontal;
|
||||
|
||||
// TODO: Validate all source images to be the same size.
|
||||
int width = sources[0].Width;
|
||||
int heigh = sources[0].Height;
|
||||
|
||||
if (horizontal)
|
||||
width *= sources.Length;
|
||||
else
|
||||
heigh *= sources.Length;
|
||||
|
||||
return new Size(width, heigh);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PckStudio.Classes.FileTypes
|
||||
{
|
||||
// filepath to file data
|
||||
public class ConsoleArchive : Dictionary<string, byte[]>
|
||||
{
|
||||
public int SizeOfFile(string filepath) => this[filepath].Length;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PckStudio.Classes.FileTypes
|
||||
{
|
||||
public class BehaviourFile
|
||||
{
|
||||
public List<RiderPositionOverride> overrides { get; } = new List<RiderPositionOverride>();
|
||||
public struct RiderPositionOverride
|
||||
{
|
||||
public string name;
|
||||
public List<PositionOverride> overrides { get; }
|
||||
|
||||
public RiderPositionOverride(string name) : this()
|
||||
{
|
||||
this.name = name;
|
||||
overrides = new List<PositionOverride>();
|
||||
}
|
||||
|
||||
public struct PositionOverride
|
||||
{
|
||||
public bool _1;
|
||||
public bool _2;
|
||||
public float x, y, z;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace PckStudio.Classes
|
||||
{
|
||||
internal class Bink
|
||||
{
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr LoadLibrary(string lpFileName);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr FreeLibrary(IntPtr library);
|
||||
|
||||
public int temp_error_code;
|
||||
string binka_enc_loc;
|
||||
string mss32_loc;
|
||||
string binkawin_loc;
|
||||
public string working = null;
|
||||
|
||||
public async void WavToBinka(string infile, string outFile, int compression)
|
||||
{
|
||||
var process = Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = binka_enc_loc,
|
||||
Arguments = $"\"{infile}\" \"{outFile}\" -s -b{compression}",
|
||||
UseShellExecute = true,
|
||||
CreateNoWindow = true,
|
||||
WindowStyle = ProcessWindowStyle.Hidden
|
||||
});
|
||||
process.WaitForExit();
|
||||
temp_error_code = process.ExitCode;
|
||||
}
|
||||
|
||||
public unsafe void BinkaToWav(string infile, string outFile)
|
||||
{
|
||||
string[] array2 = createArg(infile, outFile);
|
||||
byte[] array3 = File.ReadAllBytes(array2[0]);
|
||||
Console.WriteLine(array3.Length);
|
||||
uint num = 0U;
|
||||
AIL_set_redist_directory(".");
|
||||
AIL_startup();
|
||||
IntPtr intPtr;
|
||||
// crash happens in AIL_decompress_ASI
|
||||
if (AIL_decompress_ASI(array3, (uint)array3.Length, ".binka", &intPtr, &num, 0U) == 0)
|
||||
throw new Exception("AIL ERROR");
|
||||
byte[] array4 = new byte[num];
|
||||
Marshal.Copy(intPtr, array4, 0, array4.Length);
|
||||
AIL_mem_free_lock(intPtr);
|
||||
AIL_shutdown();
|
||||
File.WriteAllBytes(array2[1], array4);
|
||||
}
|
||||
|
||||
public void SetUpBinka()
|
||||
{
|
||||
if (working == null)
|
||||
{
|
||||
working = (Path.GetTempPath() + "PCKStudio").Replace("\\","/");
|
||||
Directory.CreateDirectory(working);
|
||||
binka_enc_loc = ExtractResource("binka_encode.exe", working);
|
||||
mss32_loc = ExtractResource("mss32.dll", working);
|
||||
binkawin_loc = ExtractResource("binkawin.asi", working);
|
||||
library = LoadLibrary(mss32_loc);
|
||||
}
|
||||
else
|
||||
{
|
||||
binka_enc_loc = working + "\\binka_encode.exe";
|
||||
mss32_loc = working + "\\mss32.dll";
|
||||
binkawin_loc = working + "\\binkawin.asi";
|
||||
}
|
||||
}
|
||||
|
||||
public void CleanUpBinka()
|
||||
{
|
||||
File.Delete(binka_enc_loc);
|
||||
File.Delete(binkawin_loc);
|
||||
while (File.Exists(mss32_loc))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(mss32_loc);
|
||||
}
|
||||
catch
|
||||
{
|
||||
FreeLibrary(library);
|
||||
}
|
||||
}
|
||||
Directory.Delete(working);
|
||||
}
|
||||
|
||||
private static string getType(string loc)
|
||||
{
|
||||
string a = Path.GetExtension(loc).ToLower();
|
||||
bool flag = a == ".binka";
|
||||
string result;
|
||||
if (flag)
|
||||
{
|
||||
result = "BINKA";
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag2 = !(a == ".wav");
|
||||
if (flag2)
|
||||
{
|
||||
throw new Exception("File type not valid. To use MP3 or other audio formats, convert to wav format before using this tool");
|
||||
}
|
||||
result = "WAV";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string[] createArg(string inFile, string outdir = null)
|
||||
{
|
||||
string[] array = new string[2];
|
||||
array[0] = inFile;
|
||||
string[] array2 = array;
|
||||
string type = getType(inFile);
|
||||
bool flag = type == "BINKA";
|
||||
if (flag)
|
||||
{
|
||||
array2[1] = ((outdir.Length <= 3) ? Path.GetFullPath(inFile.Replace(".binka", ".wav")) : (outdir + "\\" + Path.GetFileName(inFile.Replace(".binka", ".wav"))));
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag2 = type == "WAV";
|
||||
if (flag2)
|
||||
{
|
||||
array2[1] = ((outdir.Length <= 3) ? Path.GetFullPath(inFile.Replace(".wav", ".binka")) : (outdir + "\\" + Path.GetFileName(inFile.Replace(".wav", ".binka"))));
|
||||
}
|
||||
}
|
||||
bool flag3 = !Directory.Exists(Path.GetDirectoryName(array2[1]));
|
||||
if (flag3)
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(array2[1]));
|
||||
}
|
||||
return array2;
|
||||
}
|
||||
|
||||
internal static string ExtractResource(string resource, string working)
|
||||
{
|
||||
object ob = Properties.Resources.ResourceManager.GetObject(Path.GetFileNameWithoutExtension(resource));
|
||||
byte[] myResBytes = (byte[])ob;
|
||||
if(File.Exists(Path.Combine(working, resource))) File.Delete(Path.Combine(working, resource));
|
||||
using (FileStream fsDst = new FileStream(Path.Combine(working, resource), FileMode.CreateNew, FileAccess.Write))
|
||||
{
|
||||
fsDst.Write(myResBytes, 0, myResBytes.Length);
|
||||
fsDst.Close();
|
||||
fsDst.Dispose();
|
||||
}
|
||||
return "\"" + working + "/" + resource + "\"";
|
||||
}
|
||||
|
||||
[DllImport("mss32.dll", EntryPoint = "_AIL_decompress_ASI@24")]
|
||||
private unsafe static extern int AIL_decompress_ASI([MarshalAs(UnmanagedType.LPArray)] byte[] indata, uint insize, [MarshalAs(UnmanagedType.LPStr)] string ext, IntPtr* result, uint* resultsize, uint zero);
|
||||
|
||||
[DllImport("mss32.dll", EntryPoint = "_AIL_last_error@0")]
|
||||
private static extern IntPtr AIL_last_error();
|
||||
|
||||
[DllImport("mss32.dll", EntryPoint = "_AIL_set_redist_directory@4")]
|
||||
private static extern IntPtr AIL_set_redist_directory([MarshalAs(UnmanagedType.LPStr)] string redistDir);
|
||||
|
||||
[DllImport("mss32.dll", EntryPoint = "_AIL_mem_free_lock@4")]
|
||||
private static extern void AIL_mem_free_lock(IntPtr ptr);
|
||||
|
||||
[DllImport("mss32.dll", EntryPoint = "_AIL_startup@0")]
|
||||
private static extern int AIL_startup();
|
||||
|
||||
[DllImport("mss32.dll", EntryPoint = "_AIL_shutdown@0")]
|
||||
private static extern int AIL_shutdown();
|
||||
|
||||
public Bink()
|
||||
{
|
||||
}
|
||||
|
||||
private static IntPtr library;
|
||||
}
|
||||
}
|
||||
141
PCK-Studio/Classes/FileTypes/Binka.cs
Normal file
141
PCK-Studio/Classes/FileTypes/Binka.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace PckStudio.Classes
|
||||
{
|
||||
internal static class Binka
|
||||
{
|
||||
private class LibHandle
|
||||
{
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr LoadLibrary(string lpFileName);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern int FreeLibrary(IntPtr library);
|
||||
|
||||
private IntPtr libHandle;
|
||||
|
||||
public IntPtr Handle => libHandle;
|
||||
|
||||
public LibHandle(string libraryPath)
|
||||
{
|
||||
libHandle = LoadLibrary(libraryPath);
|
||||
}
|
||||
|
||||
~LibHandle()
|
||||
{
|
||||
FreeLibrary(libHandle);
|
||||
}
|
||||
}
|
||||
|
||||
private static string dataCache = Program.AppDataCache;
|
||||
|
||||
public static uint LastAILErrorCode = 0xffffffff;
|
||||
|
||||
public static int FromWav(string inputFilepath, string outputFilepath, int compressionLevel)
|
||||
{
|
||||
var process = Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = GetAndCacheResource("binka_encode.exe"),
|
||||
Arguments = $"\"{inputFilepath}\" \"{outputFilepath}\" -s -b{compressionLevel}",
|
||||
UseShellExecute = true,
|
||||
CreateNoWindow = true,
|
||||
WindowStyle = ProcessWindowStyle.Hidden
|
||||
});
|
||||
process.WaitForExit();
|
||||
return process.ExitCode;
|
||||
}
|
||||
|
||||
public static unsafe void ToWav(string inputFilename, string outputFilepath)
|
||||
{
|
||||
// handle should be closed when function gets out of scope
|
||||
LibHandle mss32LibHandle = new LibHandle(GetAndCacheResource("mss32.dll"));
|
||||
|
||||
string ext = Path.GetExtension(inputFilename).ToLower();
|
||||
switch (ext)
|
||||
{
|
||||
case ".binka":
|
||||
case ".wav":
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException(nameof(ext)+":"+ext);
|
||||
}
|
||||
string outputDirectory = Path.GetDirectoryName(outputFilepath);
|
||||
Directory.CreateDirectory(outputDirectory);
|
||||
string destinationFilepath = Path.Combine(outputDirectory, Path.GetFileName(inputFilename));
|
||||
|
||||
byte[] inputFiledata = File.ReadAllBytes(inputFilename);
|
||||
Debug.WriteLine($"{nameof(inputFiledata)}: {inputFiledata.Length}");
|
||||
|
||||
AILInternalCalls.SetRedistDirectory(".");
|
||||
AILInternalCalls.Startup(); // __fastcall
|
||||
|
||||
int resultBufferSize = 0;
|
||||
IntPtr resultBuffer = new IntPtr();
|
||||
// crash happens in AIL_decompress_ASI
|
||||
LastAILErrorCode = (uint)AILInternalCalls.DecompressASI(inputFiledata, inputFiledata.Length, ".binka", resultBuffer, &resultBufferSize);
|
||||
Debug.WriteLine("AIL Error Code: " + LastAILErrorCode.ToString());
|
||||
|
||||
byte[] buffer = new byte[resultBufferSize];
|
||||
Marshal.Copy(resultBuffer, buffer, 0, resultBufferSize);
|
||||
AILInternalCalls.MemFreeLock(resultBuffer);
|
||||
AILInternalCalls.Shutdown();
|
||||
File.WriteAllBytes(destinationFilepath, buffer);
|
||||
}
|
||||
|
||||
// Move to a cache class ?
|
||||
private static string GetAndCacheResource(string resourceName)
|
||||
{
|
||||
_ = resourceName ?? throw new ArgumentNullException(nameof(resourceName));
|
||||
string destinationFilepath = Path.Combine(dataCache, resourceName);
|
||||
if (!File.Exists(destinationFilepath))
|
||||
{
|
||||
byte[] resourceData = ExtractResource(resourceName);
|
||||
using (FileStream fsDst = File.OpenWrite(destinationFilepath))
|
||||
{
|
||||
fsDst.Write(resourceData, 0, resourceData.Length);
|
||||
}
|
||||
}
|
||||
return destinationFilepath;
|
||||
}
|
||||
|
||||
internal static byte[] ExtractResource(string resourceName)
|
||||
{
|
||||
byte[] resourceData = (byte[])Properties.Resources.ResourceManager.GetObject(Path.GetFileNameWithoutExtension(resourceName));
|
||||
return resourceData;
|
||||
}
|
||||
|
||||
private class AILInternalCalls
|
||||
{
|
||||
public delegate int AIL_decomp_func();
|
||||
|
||||
[DllImport("mss32.dll", EntryPoint = "_AIL_decompress_ASI@24")]
|
||||
public unsafe static extern int DecompressASI(
|
||||
[MarshalAs(UnmanagedType.LPArray)] byte[] indata,
|
||||
int insize,
|
||||
[MarshalAs(UnmanagedType.LPStr)] string ext,
|
||||
IntPtr result,
|
||||
int *resultSize,
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] AIL_decomp_func func = null);
|
||||
|
||||
[DllImport("mss32.dll", EntryPoint = "_AIL_last_error@0")]
|
||||
[return: MarshalAs(UnmanagedType.LPStr)]
|
||||
public static extern string LastError();
|
||||
|
||||
[DllImport("mss32.dll", EntryPoint = "_AIL_set_redist_directory@4")]
|
||||
[return: MarshalAs(UnmanagedType.LPStr)]
|
||||
public static extern string SetRedistDirectory([MarshalAs(UnmanagedType.LPStr)] string redistDir);
|
||||
|
||||
[DllImport("mss32.dll", EntryPoint = "_AIL_mem_free_lock@4")]
|
||||
public static extern void MemFreeLock(IntPtr ptr);
|
||||
|
||||
[DllImport("mss32.dll", EntryPoint = "_AIL_startup@0")]
|
||||
public static extern int Startup();
|
||||
|
||||
[DllImport("mss32.dll", EntryPoint = "_AIL_shutdown@0")]
|
||||
public static extern int Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PckStudio.Classes.FileTypes
|
||||
{
|
||||
public class COLFile
|
||||
{
|
||||
public class ColorEntry
|
||||
{
|
||||
public readonly string name;
|
||||
public uint color;
|
||||
|
||||
public ColorEntry(string name, uint color)
|
||||
{
|
||||
this.name = name;
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
public class ExtendedColorEntry : ColorEntry
|
||||
{
|
||||
public uint color_b;
|
||||
public uint color_c;
|
||||
|
||||
// Water entries consist of three colors
|
||||
// color_a - the surface of the water
|
||||
// color_b - the color displayed underwater
|
||||
// color_c - the color for the distant "fog" displayed while underwater
|
||||
public ExtendedColorEntry(string name, uint color_a, uint color_b, uint color_c) : base(name, color_a)
|
||||
{
|
||||
this.color_b = color_b;
|
||||
this.color_c = color_c;
|
||||
}
|
||||
}
|
||||
|
||||
public bool hasWaterTable;
|
||||
public List<ColorEntry> entries = new List<ColorEntry>();
|
||||
public List<ExtendedColorEntry> waterEntries = new List<ExtendedColorEntry>();
|
||||
}
|
||||
}
|
||||
@@ -1,277 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace PckStudio.Classes.FileTypes
|
||||
{
|
||||
public class GRFFile
|
||||
{
|
||||
public static readonly string[] ValidGameRules = new string[]
|
||||
{
|
||||
"MapOptions",
|
||||
"ApplySchematic",
|
||||
"GenerateStructure",
|
||||
"GenerateBox",
|
||||
"PlaceBlock",
|
||||
"PlaceContainer",
|
||||
"PlaceSpawner",
|
||||
"BiomeOverride",
|
||||
"StartFeature",
|
||||
"AddItem",
|
||||
"AddEnchantment",
|
||||
"WeighedTreasureItem",
|
||||
"RandomItemSet",
|
||||
"DistributeItems",
|
||||
"WorldPosition",
|
||||
"LevelRules",
|
||||
"NamedArea",
|
||||
"ActiveChunkArea",
|
||||
"TargetArea",
|
||||
"ScoreRing",
|
||||
"ThermalArea",
|
||||
"PlayerBoundsVolume",
|
||||
"Killbox",
|
||||
"BlockLayer",
|
||||
"UseBlock",
|
||||
"CollectItem",
|
||||
"CompleteAll",
|
||||
"UpdatePlayer",
|
||||
"OnGameStartSpawnPositions",
|
||||
"OnInitialiseWorld",
|
||||
"SpawnPositionSet",
|
||||
"PopulateContainer",
|
||||
"DegradationSequence",
|
||||
"RandomDissolveDegrade",
|
||||
"DirectionalDegrade",
|
||||
"GrantPermissions",
|
||||
"AllowIn",
|
||||
"LayerGeneration",
|
||||
"LayerAsset",
|
||||
"AnyCombinationOf",
|
||||
"CombinationDefinition",
|
||||
"Variations",
|
||||
"BlockDef",
|
||||
"LayerSize",
|
||||
"UniformSize",
|
||||
"RandomizeSize",
|
||||
"LinearBlendSize",
|
||||
"LayerShape",
|
||||
"BasicShape",
|
||||
"StarShape",
|
||||
"PatchyShape",
|
||||
"RingShape",
|
||||
"SpiralShape",
|
||||
"LayerFill",
|
||||
"BasicLayerFill",
|
||||
"CurvedLayerFill",
|
||||
"WarpedLayerFill",
|
||||
"LayerTheme",
|
||||
"NullTheme",
|
||||
"FilterTheme",
|
||||
"ShaftsTheme",
|
||||
"BasicPatchesTheme",
|
||||
"BlockStackTheme",
|
||||
"RainbowTheme",
|
||||
"TerracottaTheme",
|
||||
"FunctionPatchesTheme",
|
||||
"SimplePatchesTheme",
|
||||
"CarpetTrapTheme",
|
||||
"MushroomBlockTheme",
|
||||
"TextureTheme",
|
||||
"SchematicTheme",
|
||||
"BlockCollisionException",
|
||||
"Powerup",
|
||||
"Checkpoint",
|
||||
"CustomBeacon",
|
||||
"ActiveViewArea",
|
||||
};
|
||||
|
||||
public readonly GameRule Root = null;
|
||||
public int Crc => _crc;
|
||||
public bool IsWorld => _isWorld;
|
||||
|
||||
private int _crc = 0;
|
||||
private bool _isWorld = false;
|
||||
|
||||
public enum eCompressionType : byte
|
||||
{
|
||||
None = 0,
|
||||
Zlib = 1,
|
||||
ZlibRle = 2,
|
||||
ZlibRleCrc = 3,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new GRFFile as a non-world grf file
|
||||
/// </summary>
|
||||
public GRFFile() : this(-1, false)
|
||||
{}
|
||||
|
||||
public GRFFile(int crc, bool isWolrd)
|
||||
{
|
||||
Root = new GameRule("__ROOT__", null);
|
||||
_crc = crc;
|
||||
_isWorld = isWolrd;
|
||||
}
|
||||
|
||||
public class GameRule
|
||||
{
|
||||
/// <summary> Contains all valid Parameter names </summary>
|
||||
public static readonly string[] ValidParameters = new string[]
|
||||
{
|
||||
"plus_x",
|
||||
"minus_x",
|
||||
"plus_z",
|
||||
"minus_z",
|
||||
"omni_plus_x",
|
||||
"omni_minus_x",
|
||||
"omni_plus_z",
|
||||
"omni_minus_z",
|
||||
"none",
|
||||
"plus_y",
|
||||
"minus_y",
|
||||
"plus_x",
|
||||
"minus_x",
|
||||
"plus_z",
|
||||
"minus_z",
|
||||
"descriptionName",
|
||||
"promptName",
|
||||
"dataTag",
|
||||
"enchantmentId",
|
||||
"enchantmentLevel",
|
||||
"itemId",
|
||||
"quantity",
|
||||
"auxValue",
|
||||
"slot",
|
||||
"name",
|
||||
"food",
|
||||
"health",
|
||||
"blockId",
|
||||
"useCoords",
|
||||
"seed",
|
||||
"flatworld",
|
||||
"filename",
|
||||
"rot",
|
||||
"data",
|
||||
"block",
|
||||
"entity",
|
||||
"facing",
|
||||
"edgeBlock",
|
||||
"fillBlock",
|
||||
"skipAir",
|
||||
"x",
|
||||
"x0",
|
||||
"x1",
|
||||
"y",
|
||||
"y0",
|
||||
"y1",
|
||||
"z",
|
||||
"z0",
|
||||
"z1",
|
||||
"chunkX",
|
||||
"chunkZ",
|
||||
"yRot",
|
||||
"xRot",
|
||||
"spawnX",
|
||||
"spawnY",
|
||||
"spawnZ",
|
||||
"orientation",
|
||||
"dimension",
|
||||
"topblockId",
|
||||
"biomeId",
|
||||
"feature",
|
||||
"minCount",
|
||||
"maxCount",
|
||||
"weight",
|
||||
"id",
|
||||
"probability",
|
||||
"method",
|
||||
"hasBeenInCreative",
|
||||
"cloudHeight",
|
||||
"fogDistance",
|
||||
"dayTime",
|
||||
"target",
|
||||
"speed",
|
||||
"dir",
|
||||
"type",
|
||||
"pass",
|
||||
"for",
|
||||
"random",
|
||||
"blockAux",
|
||||
"size",
|
||||
"scale",
|
||||
"freq",
|
||||
"func",
|
||||
"upper",
|
||||
"lower",
|
||||
"dY",
|
||||
"thickness",
|
||||
"points",
|
||||
"holeSize",
|
||||
"variant",
|
||||
"startHeight",
|
||||
"pattern",
|
||||
"colour",
|
||||
"primary",
|
||||
"laps",
|
||||
"liftForceModifier",
|
||||
"staticLift",
|
||||
"targetHeight",
|
||||
"speedBoost",
|
||||
"boostDirection",
|
||||
"condition_type",
|
||||
"condition_value_0",
|
||||
"condition_value_1",
|
||||
"beam_length",
|
||||
};
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public GameRule Parent { get; } = null;
|
||||
public Dictionary<string, string> Parameters { get; } = new Dictionary<string, string>();
|
||||
public List<GameRule> SubRules { get; } = new List<GameRule>();
|
||||
|
||||
public GameRule(string name, GameRule parent)
|
||||
{
|
||||
Name = name;
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
public GameRule AddRule(string gameRuleName) => AddRule(gameRuleName, false);
|
||||
|
||||
/// <summary>Adds a new gamerule</summary>
|
||||
/// <param name="gameRuleName">Game rule to add</param>
|
||||
/// <param name="validate">Wether to check the given game rule</param>
|
||||
/// <returns>The Added GRFTag</returns>
|
||||
public GameRule AddRule(string gameRuleName, bool validate)
|
||||
{
|
||||
if (validate && !ValidGameRules.Contains(gameRuleName)) return null;
|
||||
var tag = new GameRule(gameRuleName, this);
|
||||
SubRules.Add(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
public GameRule AddRule(string gameRuleName, params KeyValuePair<string,string>[] parameters)
|
||||
{
|
||||
var tag = AddRule(gameRuleName); // should never return null unless its called with the validate bool set to true
|
||||
foreach(var param in parameters)
|
||||
{
|
||||
tag.Parameters[param.Key] = param.Value;
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddGameRules(IEnumerable<GameRule> gameRules) => Root.SubRules.AddRange(gameRules);
|
||||
|
||||
public GameRule AddRule(string gameRuleName)
|
||||
=> AddRule(gameRuleName, false);
|
||||
|
||||
public GameRule AddRule(string gameRuleName, bool validate)
|
||||
=> Root.AddRule(gameRuleName, validate);
|
||||
|
||||
public GameRule AddRule(string gameRuleName, params KeyValuePair<string, string>[] parameters)
|
||||
=> Root.AddRule(gameRuleName, parameters);
|
||||
}
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PckStudio.Classes.FileTypes
|
||||
{
|
||||
public class LOCFile
|
||||
{
|
||||
public class InvalidLanguageException : Exception
|
||||
{
|
||||
public string Language { get; }
|
||||
public InvalidLanguageException(string message, string language) : base(message)
|
||||
{
|
||||
Language = language;
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly string[] ValidLanguages = new string[]
|
||||
{
|
||||
"cs-CS",
|
||||
"cs-CZ",
|
||||
|
||||
"da-CH",
|
||||
"da-DA",
|
||||
"da-DK",
|
||||
|
||||
"de-AT",
|
||||
"de-DE",
|
||||
|
||||
"el-EL",
|
||||
"el-GR",
|
||||
|
||||
"en-AU",
|
||||
"en-CA",
|
||||
"en-EN",
|
||||
"en-GB",
|
||||
"en-GR",
|
||||
"en-IE",
|
||||
"en-NZ",
|
||||
"en-US",
|
||||
|
||||
"es-ES",
|
||||
"es-MX",
|
||||
|
||||
"fi-BE",
|
||||
"fi-CH",
|
||||
"fi-FI",
|
||||
|
||||
"fr-FR",
|
||||
"fr-CA",
|
||||
|
||||
"it-IT",
|
||||
|
||||
"ja-JP",
|
||||
|
||||
"ko-KR",
|
||||
|
||||
"la-LAS",
|
||||
|
||||
"no-NO",
|
||||
|
||||
"nb-NO",
|
||||
|
||||
"nl-NL",
|
||||
"nl-BE",
|
||||
|
||||
"pl-PL",
|
||||
|
||||
"pt-BR",
|
||||
"pt-PT",
|
||||
|
||||
"ru-RU",
|
||||
|
||||
"sk-SK",
|
||||
|
||||
"sv-SE",
|
||||
|
||||
"tr-TR",
|
||||
|
||||
"zh-CN",
|
||||
"zh-HK",
|
||||
"zh-SG",
|
||||
"zh-TW",
|
||||
"zh-CHT",
|
||||
"zh-HanS",
|
||||
"zh-HanT",
|
||||
};
|
||||
|
||||
private Dictionary<string, Dictionary<string, string>> _lockeys = new Dictionary<string, Dictionary<string, string>>();
|
||||
private List<string> _languages = new List<string>(ValidLanguages.Length);
|
||||
|
||||
public Dictionary<string, Dictionary<string, string>> LocKeys => _lockeys;
|
||||
public List<string> Languages => _languages;
|
||||
|
||||
public void InitializeDefault(string packName)
|
||||
=> Initialize("en-EN", ("IDS_DISPLAY_NAME", packName));
|
||||
public void Initialize(string language, params (string, string)[] locKeyValuePairs)
|
||||
{
|
||||
AddLanguage(language);
|
||||
foreach (var locKeyValue in locKeyValuePairs)
|
||||
AddLocKey(locKeyValue.Item1, locKeyValue.Item2);
|
||||
}
|
||||
|
||||
private Dictionary<string, string> GetTranslation(string locKey)
|
||||
{
|
||||
if (!LocKeys.ContainsKey(locKey))
|
||||
LocKeys.Add(locKey, new Dictionary<string, string>());
|
||||
return LocKeys[locKey];
|
||||
}
|
||||
|
||||
public Dictionary<string, string> GetLocEntries(string locKey)
|
||||
{
|
||||
if (!LocKeys.ContainsKey(locKey))
|
||||
throw new KeyNotFoundException("Loc key not found");
|
||||
return LocKeys[locKey];
|
||||
}
|
||||
|
||||
public bool HasLocEntry(string locKey)
|
||||
=> LocKeys.ContainsKey(locKey);
|
||||
|
||||
public string GetLocEntry(string locKey, string language)
|
||||
{
|
||||
if (!LocKeys.ContainsKey(locKey))
|
||||
throw new KeyNotFoundException(nameof(locKey));
|
||||
if (!Languages.Contains(language)) throw new KeyNotFoundException("Language Entry not found");
|
||||
return GetTranslation(locKey)[language]?? string.Empty;
|
||||
}
|
||||
|
||||
public void SetLocEntry(string locKey, string value)
|
||||
{
|
||||
foreach (var language in Languages)
|
||||
{
|
||||
GetTranslation(locKey)[language] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLocEntry(string locKey, string language, string value)
|
||||
{
|
||||
if (!Languages.Contains(language))
|
||||
throw new KeyNotFoundException(nameof(language));
|
||||
GetTranslation(locKey)[language] = value;
|
||||
}
|
||||
|
||||
public bool AddLocKey(string locKey, string value)
|
||||
{
|
||||
if (LocKeys.ContainsKey(locKey))
|
||||
return false;
|
||||
Languages.ForEach( language => SetLocEntry(locKey, language, value) );
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool RemoveLocKey(string locKey)
|
||||
{
|
||||
if (!LocKeys.ContainsKey(locKey))
|
||||
return false;
|
||||
return LocKeys.Remove(locKey);
|
||||
}
|
||||
|
||||
public void AddLanguage(string language)
|
||||
{
|
||||
if (!ValidLanguages.Contains(language))
|
||||
throw new InvalidLanguageException("Invalid language", language);
|
||||
if (Languages.Contains(language))
|
||||
throw new InvalidLanguageException("Language already exists", language);
|
||||
Languages.Add(language);
|
||||
foreach(var key in LocKeys.Keys)
|
||||
SetLocEntry(key, language, "");
|
||||
}
|
||||
|
||||
public void RemoveLanguage(string language)
|
||||
{
|
||||
if (!ValidLanguages.Contains(language))
|
||||
throw new InvalidLanguageException("Invalid language", language);
|
||||
if (!Languages.Contains(language))
|
||||
throw new InvalidLanguageException("Language doesn't exist", language);
|
||||
if (Languages.Remove(language))
|
||||
foreach (var translation in LocKeys.Values)
|
||||
translation.Remove(language);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Documents;
|
||||
|
||||
namespace PckStudio.Classes.FileTypes
|
||||
{
|
||||
[Serializable]
|
||||
internal class ModelNotFoundException : Exception
|
||||
{
|
||||
public ModelNotFoundException()
|
||||
{
|
||||
}
|
||||
|
||||
public ModelNotFoundException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public ModelNotFoundException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
protected ModelNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
public class ModelFile
|
||||
{
|
||||
public List<Model> Models { get; } = new List<Model>();
|
||||
|
||||
public void AddModel(Model model)
|
||||
{
|
||||
Models.Add(model);
|
||||
}
|
||||
|
||||
bool Contains(string name) => Models.FindIndex(m => m.name == name) > -1;
|
||||
|
||||
/// <exception cref="ModelNotFoundException"></exception>
|
||||
Model GetModelByName(string name)
|
||||
{
|
||||
return Contains(name) ? Models.First(m => m.name.Equals(name)) : throw new ModelNotFoundException(nameof(name));
|
||||
}
|
||||
|
||||
public struct Model
|
||||
{
|
||||
public readonly string name;
|
||||
public Size textureSize;
|
||||
public List<Part> parts { get; } = new List<Part>();
|
||||
|
||||
public Model(string name, int textureWidth, int textureHeight)
|
||||
{
|
||||
this.name = name;
|
||||
textureSize = new Size(textureWidth, textureHeight);
|
||||
}
|
||||
|
||||
public struct Part
|
||||
{
|
||||
public string name;
|
||||
public (float x, float y, float z) position;
|
||||
public (float yaw, float pitch, float roll) rotation;
|
||||
public List<Box> Boxes { get; } = new List<Box>();
|
||||
|
||||
public struct Box
|
||||
{
|
||||
public (float x, float y, float z) Position;
|
||||
public (int width, int height, int length) Size;
|
||||
public float U, V;
|
||||
public float Scale;
|
||||
public bool Mirror;
|
||||
|
||||
public Box((float x, float y, float z) position,
|
||||
(int width, int height, int length) size,
|
||||
float u, float v, float scale, bool mirror)
|
||||
{
|
||||
Position = position;
|
||||
Size = size;
|
||||
U = u;
|
||||
V = v;
|
||||
Scale = scale;
|
||||
Mirror = mirror;
|
||||
}
|
||||
}
|
||||
|
||||
public Part(string name,
|
||||
(float x, float y, float z) pos,
|
||||
(float yaw, float pitch, float roll) rot) : this(name)
|
||||
{
|
||||
position = pos;
|
||||
rotation = rot;
|
||||
}
|
||||
|
||||
public Part(string name)
|
||||
{
|
||||
this.name = name;
|
||||
this.position = (0, 0, 0);
|
||||
this.rotation = (0, 0, 0);
|
||||
}
|
||||
|
||||
public void AddBox((float x, float y, float z) position,
|
||||
(int width, int height, int length) size,
|
||||
float u, float v, float scale, bool mirror)
|
||||
{
|
||||
Boxes.Add(new Box(position, size, u, v, scale, mirror));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void AddPart(Part part)
|
||||
{
|
||||
parts.Add(part);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OMI.Formats.Languages;
|
||||
|
||||
namespace PckStudio.Classes.FileTypes
|
||||
{
|
||||
|
||||
@@ -1,154 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace PckStudio.Classes.FileTypes
|
||||
{
|
||||
public class PCKFile
|
||||
{
|
||||
public int type { get; }
|
||||
public List<FileData> Files { get; } = new List<FileData>();
|
||||
|
||||
public class FileData
|
||||
{
|
||||
public enum FileType : int
|
||||
{
|
||||
SkinFile = 0, // *.png
|
||||
CapeFile = 1, // *.png
|
||||
TextureFile = 2, // *.png
|
||||
UIDataFile = 3, // *.fui ????
|
||||
/// <summary>
|
||||
/// "0" file
|
||||
/// </summary>
|
||||
InfoFile = 4,
|
||||
/// <summary>
|
||||
/// (x16|x32|x64)Info.pck
|
||||
/// </summary>
|
||||
TexturePackInfoFile = 5,
|
||||
/// <summary>
|
||||
/// languages.loc/localisation.loc
|
||||
/// </summary>
|
||||
LocalisationFile = 6,
|
||||
/// <summary>
|
||||
/// GameRules.grf
|
||||
/// </summary>
|
||||
GameRulesFile = 7,
|
||||
/// <summary>
|
||||
/// audio.pck
|
||||
/// </summary>
|
||||
AudioFile = 8,
|
||||
/// <summary>
|
||||
/// colours.col
|
||||
/// </summary>
|
||||
ColourTableFile = 9,
|
||||
/// <summary>
|
||||
/// GameRules.grh
|
||||
/// </summary>
|
||||
GameRulesHeader = 10,
|
||||
/// <summary>
|
||||
/// Skins.pck
|
||||
/// </summary>
|
||||
SkinDataFile = 11,
|
||||
/// <summary>
|
||||
/// models.bin
|
||||
/// </summary>
|
||||
ModelsFile = 12,
|
||||
/// <summary>
|
||||
/// behaviours.bin
|
||||
/// </summary>
|
||||
BehavioursFile = 13,
|
||||
/// <summary>
|
||||
/// entityMaterials.bin
|
||||
/// </summary>
|
||||
MaterialFile = 14,
|
||||
}
|
||||
|
||||
public string filepath { get; set; }
|
||||
public FileType filetype { get; set; }
|
||||
public byte[] data => _data;
|
||||
public int size => _size;
|
||||
public PCKProperties properties { get; } = new PCKProperties();
|
||||
|
||||
private byte[] _data = new byte[0];
|
||||
private int _size = 0;
|
||||
|
||||
public FileData(string path, FileType type)
|
||||
{
|
||||
filetype = type;
|
||||
filepath = path;
|
||||
}
|
||||
|
||||
public FileData(string path, FileType type, int dataSize) : this(path, type)
|
||||
{
|
||||
_size = dataSize;
|
||||
_data = new byte[dataSize];
|
||||
}
|
||||
|
||||
public FileData(FileData file) : this(file.filepath, file.filetype)
|
||||
{
|
||||
properties = file.properties;
|
||||
SetData(file.data);
|
||||
}
|
||||
|
||||
public void SetData(byte[] data)
|
||||
{
|
||||
_data = data;
|
||||
_size = data.Length;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public PCKFile(int type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<string> GatherPropertiesList()
|
||||
{
|
||||
var LUT = new List<string>();
|
||||
Files.ForEach(file => file.properties.ForEach(pair =>
|
||||
{
|
||||
if (!LUT.Contains(pair.property))
|
||||
LUT.Add(pair.property);
|
||||
})
|
||||
);
|
||||
return LUT;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks wether a file with <paramref name="filepath"/> and <paramref name="type"/> exists
|
||||
/// </summary>
|
||||
/// <param name="filepath">Path to the file in the pck</param>
|
||||
/// <param name="type">Type of the file <see cref="FileData.FileType"/></param>
|
||||
/// <returns>True when file exists, otherwise false </returns>
|
||||
public bool HasFile(string filepath, FileData.FileType type)
|
||||
{
|
||||
return GetFile(filepath, type) is FileData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first file that Equals <paramref name="filepath"/> and <paramref name="type"/>
|
||||
/// </summary>
|
||||
/// <param name="filepath">Path to the file in the pck</param>
|
||||
/// <param name="type">Type of the file <see cref="FileData.FileType"/></param>
|
||||
/// <returns>FileData if found, otherwise null</returns>
|
||||
public FileData GetFile(string filepath, FileData.FileType type)
|
||||
{
|
||||
return Files.FirstOrDefault(file => file.filepath.Equals(filepath) && file.filetype.Equals(type));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get a file with <paramref name="filepath"/> and <paramref name="type"/>.
|
||||
/// </summary>
|
||||
/// <param name="filepath">Path to the file in the pck</param>
|
||||
/// <param name="type">Type of the file <see cref="FileData.FileType"/></param>
|
||||
/// <param name="file">If succeeded <paramref name="file"/> will be non-null, otherwise null</param>
|
||||
/// <returns>True if succeeded, otherwise false</returns>
|
||||
public bool TryGetFile(string filepath, FileData.FileType type, out FileData file)
|
||||
{
|
||||
file = GetFile(filepath, type);
|
||||
return file is FileData;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PckStudio.Classes.FileTypes
|
||||
{
|
||||
public class PCKProperties : List<(string property, string value)>
|
||||
{
|
||||
public bool Contains(string property)
|
||||
{
|
||||
return HasProperty(property);
|
||||
}
|
||||
|
||||
public bool HasProperty(string property)
|
||||
{
|
||||
return GetProperty(property) != default;
|
||||
}
|
||||
|
||||
public (string, string) GetProperty(string property)
|
||||
{
|
||||
return this.FirstOrDefault(p => p.property.Equals(property));
|
||||
}
|
||||
|
||||
public T GetPropertyValue<T>(string property, Func<string, T> func)
|
||||
{
|
||||
return func(GetPropertyValue(property));
|
||||
}
|
||||
|
||||
public string GetPropertyValue(string property)
|
||||
{
|
||||
return GetProperty(property).Item2;
|
||||
}
|
||||
|
||||
public (string, string)[] GetProperties(string property)
|
||||
{
|
||||
return FindAll(p => p.property == property).ToArray();
|
||||
}
|
||||
|
||||
public bool HasMoreThanOneOf(string property)
|
||||
{
|
||||
return GetProperties(property).Length > 1;
|
||||
}
|
||||
|
||||
public void SetProperty(string property, string value)
|
||||
{
|
||||
if (HasProperty(property))
|
||||
{
|
||||
this[IndexOf(GetProperty(property))] = (property, value);
|
||||
return;
|
||||
}
|
||||
Add((property, value));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
|
||||
namespace PckStudio.Classes.IO.ARC
|
||||
{
|
||||
internal class ARCFileReader : StreamDataReader<ConsoleArchive>
|
||||
{
|
||||
public static ConsoleArchive Read(Stream stream, bool useLittleEndian = false)
|
||||
{
|
||||
return new ARCFileReader(useLittleEndian).ReadFromStream(stream);
|
||||
}
|
||||
|
||||
private ARCFileReader(bool useLittleEndian) : base(useLittleEndian)
|
||||
{
|
||||
}
|
||||
|
||||
protected override ConsoleArchive ReadFromStream(Stream stream)
|
||||
{
|
||||
ConsoleArchive _archive = new ConsoleArchive();
|
||||
int numberOfFiles = ReadInt(stream);
|
||||
for(int i = 0; i < numberOfFiles; i++)
|
||||
{
|
||||
string name = ReadString(stream);
|
||||
int offset = ReadInt(stream);
|
||||
int size = ReadInt(stream);
|
||||
_archive[name] = ReadBytesFromPosition(stream, offset, size);
|
||||
}
|
||||
return _archive;
|
||||
}
|
||||
|
||||
private string ReadString(Stream stream)
|
||||
{
|
||||
short length = ReadShort(stream);
|
||||
return ReadString(stream, length, Encoding.UTF8);
|
||||
}
|
||||
|
||||
private byte[] ReadBytesFromPosition(Stream stream, int position, int size)
|
||||
{
|
||||
long originalPOS = stream.Position;
|
||||
if (stream.Seek(position, SeekOrigin.Begin) != position) throw new Exception();
|
||||
byte[] data = ReadBytes(stream, size);
|
||||
if (stream.Seek(originalPOS, SeekOrigin.Begin) != originalPOS) throw new Exception();
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
|
||||
namespace PckStudio.Classes.IO.ARC
|
||||
{
|
||||
internal class ARCFileWriter : StreamDataWriter
|
||||
{
|
||||
private ConsoleArchive _archive;
|
||||
|
||||
public static void Write(Stream stream, ConsoleArchive archive, bool useLittleEndian = false)
|
||||
{
|
||||
new ARCFileWriter(archive, useLittleEndian).WriteToStream(stream);
|
||||
}
|
||||
|
||||
public ARCFileWriter(ConsoleArchive archive, bool useLittleEndian) : base(useLittleEndian)
|
||||
{
|
||||
_archive = archive;
|
||||
}
|
||||
|
||||
protected override void WriteToStream(Stream stream)
|
||||
{
|
||||
var arc = _archive.ToArray();
|
||||
WriteInt(stream, arc.Length);
|
||||
int offset = 4 + arc.Sum(pair => 10 + pair.Key.Length);
|
||||
foreach (var pair in arc)
|
||||
{
|
||||
int size = pair.Value.Length;
|
||||
WriteString(stream, pair.Key);
|
||||
WriteInt(stream, offset);
|
||||
WriteInt(stream, size);
|
||||
offset += size;
|
||||
}
|
||||
foreach (var pair in arc)
|
||||
{
|
||||
WriteBytes(stream, pair.Value);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteString(Stream stream, string s)
|
||||
{
|
||||
WriteShort(stream, (short)s.Length);
|
||||
WriteString(stream, s, Encoding.ASCII);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PckStudio.Classes.IO.Behaviour
|
||||
{
|
||||
public class BehavioursReader : StreamDataReader<BehaviourFile>
|
||||
{
|
||||
public static BehaviourFile Read(Stream stream, bool useLittleEndian)
|
||||
{
|
||||
return new BehavioursReader(useLittleEndian).ReadFromStream(stream);
|
||||
}
|
||||
|
||||
protected BehavioursReader(bool useLittleEndian) : base(useLittleEndian)
|
||||
{
|
||||
}
|
||||
|
||||
protected override BehaviourFile ReadFromStream(Stream stream)
|
||||
{
|
||||
BehaviourFile behaviourFile = new BehaviourFile();
|
||||
_ = ReadInt(stream);
|
||||
int riderPosOverrideCount = ReadInt(stream);
|
||||
for (int i = 0; i < riderPosOverrideCount; i++)
|
||||
{
|
||||
string name = ReadString(stream);
|
||||
var riderPositionOverride = new BehaviourFile.RiderPositionOverride(name);
|
||||
int posOverideCount = ReadInt(stream);
|
||||
for (; 0 < posOverideCount; posOverideCount--)
|
||||
{
|
||||
var posOverride = new BehaviourFile.RiderPositionOverride.PositionOverride();
|
||||
posOverride._1 = ReadBool(stream);
|
||||
posOverride._2 = ReadBool(stream);
|
||||
posOverride.x = ReadFloat(stream);
|
||||
posOverride.y = ReadFloat(stream);
|
||||
posOverride.z = ReadFloat(stream);
|
||||
riderPositionOverride.overrides.Add(posOverride);
|
||||
}
|
||||
behaviourFile.overrides.Add(riderPositionOverride);
|
||||
}
|
||||
return behaviourFile;
|
||||
}
|
||||
|
||||
private string ReadString(Stream stream)
|
||||
{
|
||||
short length = ReadShort(stream);
|
||||
return ReadString(stream, length, Encoding.ASCII);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace PckStudio.Classes.IO.COL
|
||||
{
|
||||
internal class COLFileReader : StreamDataReader<COLFile>
|
||||
{
|
||||
public static COLFile Read(Stream stream)
|
||||
{
|
||||
return new COLFileReader().ReadFromStream(stream);
|
||||
}
|
||||
|
||||
private COLFileReader() : base(false)
|
||||
{}
|
||||
|
||||
protected override COLFile ReadFromStream(Stream stream)
|
||||
{
|
||||
COLFile colourFile = new COLFile();
|
||||
int has_water_colors = ReadInt(stream);
|
||||
colourFile.hasWaterTable = has_water_colors > 0;
|
||||
int color_entries = ReadInt(stream);
|
||||
for (int i = 0; i < color_entries; i++)
|
||||
{
|
||||
string name = ReadString(stream);
|
||||
uint color = ReadUInt(stream);
|
||||
colourFile.entries.Add(new COLFile.ColorEntry(name, color));
|
||||
}
|
||||
if (has_water_colors > 0)
|
||||
{
|
||||
int water_color_entries = ReadInt(stream);
|
||||
for (int i = 0; i < water_color_entries; i++)
|
||||
{
|
||||
string name = ReadString(stream);
|
||||
uint colorA = ReadUInt(stream);
|
||||
uint colorB = ReadUInt(stream);
|
||||
uint colorC = ReadUInt(stream);
|
||||
colourFile.waterEntries.Add(new COLFile.ExtendedColorEntry(name, colorA, colorB, colorC));
|
||||
}
|
||||
}
|
||||
return colourFile;
|
||||
}
|
||||
|
||||
private string ReadString(Stream stream)
|
||||
{
|
||||
short strlen = ReadShort(stream);
|
||||
return ReadString(stream, strlen, Encoding.ASCII);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace PckStudio.Classes.IO.COL
|
||||
{
|
||||
internal class COLFileWriter : StreamDataWriter
|
||||
{
|
||||
private COLFile colourFile;
|
||||
|
||||
public static void Write(Stream stream, COLFile file)
|
||||
{
|
||||
new COLFileWriter(file).WriteToStream(stream);
|
||||
}
|
||||
|
||||
public COLFileWriter(COLFile file) : base(false)
|
||||
{
|
||||
colourFile = file;
|
||||
}
|
||||
|
||||
protected override void WriteToStream(Stream stream)
|
||||
{
|
||||
WriteInt(stream, Convert.ToInt32(colourFile.waterEntries.Count > 0));
|
||||
WriteInt(stream, colourFile.entries.Count);
|
||||
foreach (var colorEntry in colourFile.entries)
|
||||
{
|
||||
WriteString(stream, colorEntry.name);
|
||||
WriteUInt(stream, colorEntry.color);
|
||||
}
|
||||
if (colourFile.waterEntries.Count > 0)
|
||||
{
|
||||
WriteInt(stream, colourFile.waterEntries.Count);
|
||||
foreach (var colorEntry in colourFile.waterEntries)
|
||||
{
|
||||
WriteString(stream, colorEntry.name);
|
||||
WriteUInt(stream, colorEntry.color);
|
||||
WriteUInt(stream, colorEntry.color_b);
|
||||
WriteUInt(stream, colorEntry.color_c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteString(Stream stream, string s)
|
||||
{
|
||||
WriteShort(stream, (short)s.Length);
|
||||
WriteString(stream, s, Encoding.ASCII);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
using PckStudio.Classes.Utils;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace PckStudio.Classes.IO.GRF
|
||||
{
|
||||
internal class GRFFileReader : StreamDataReader<GRFFile>
|
||||
{
|
||||
private IList<string> StringLookUpTable;
|
||||
private GRFFile _file;
|
||||
|
||||
public static GRFFile Read(Stream stream)
|
||||
{
|
||||
return new GRFFileReader().ReadFromStream(stream);
|
||||
}
|
||||
|
||||
private GRFFileReader() : base(false)
|
||||
{ }
|
||||
|
||||
protected override GRFFile ReadFromStream(Stream stream)
|
||||
{
|
||||
stream = ReadHeader(stream);
|
||||
ReadBody(stream);
|
||||
return _file;
|
||||
}
|
||||
|
||||
private Stream ReadHeader(Stream stream)
|
||||
{
|
||||
int x = ReadShort(stream);
|
||||
if (((x >> 31) | x) == 0)
|
||||
{
|
||||
// 14 bools ?...
|
||||
ReadBytes(stream, 14);
|
||||
return stream;
|
||||
}
|
||||
|
||||
GRFFile.eCompressionType compression_type = (GRFFile.eCompressionType)stream.ReadByte();
|
||||
int crc = ReadInt(stream);
|
||||
int byte1 = stream.ReadByte();
|
||||
int byte2 = stream.ReadByte();
|
||||
int byte3 = stream.ReadByte();
|
||||
int byte4 = stream.ReadByte();
|
||||
if (byte4 > 0)
|
||||
{
|
||||
compression_type = (GRFFile.eCompressionType)byte4;
|
||||
}
|
||||
_file = new GRFFile(crc, byte4 > 0);
|
||||
|
||||
if (compression_type == GRFFile.eCompressionType.None && byte4 == 0)
|
||||
return stream;
|
||||
|
||||
int buf_size = ReadInt(stream);
|
||||
var new_stream = stream;
|
||||
if (byte4 != 0)
|
||||
{
|
||||
new_stream = new MemoryStream(ReadBytes(stream, buf_size));
|
||||
buf_size = ReadInt(new_stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadInt(stream); // ignored cuz rest of data is compressed
|
||||
}
|
||||
var decompressed_stream = DecompressZLX(new_stream);
|
||||
new_stream.Dispose();
|
||||
if (compression_type > GRFFile.eCompressionType.Zlib)
|
||||
{
|
||||
byte[] data = ReadBytes(decompressed_stream, buf_size);
|
||||
byte[] decoded_data = RLE<byte>.Decode(data).ToArray();
|
||||
decompressed_stream.Dispose();
|
||||
decompressed_stream = new MemoryStream(decoded_data);
|
||||
}
|
||||
|
||||
if (byte4 != 0)
|
||||
ReadBytes(decompressed_stream, 23);
|
||||
|
||||
return decompressed_stream;
|
||||
}
|
||||
|
||||
private void ReadBody(Stream stream)
|
||||
{
|
||||
ReadStringLookUpTable(stream);
|
||||
string Name = GetString(stream);
|
||||
Debug.WriteLine("[{0}] Root Name: {1}", nameof(GRFFile), Name);
|
||||
ReadGameRuleHierarchy(stream, _file.Root);
|
||||
}
|
||||
|
||||
private Stream DecompressZLX(Stream compressedStream)
|
||||
{
|
||||
Stream outputstream = new MemoryStream();
|
||||
using (var inputStream = new InflaterInputStream(compressedStream))
|
||||
{
|
||||
inputStream.IsStreamOwner = false;
|
||||
inputStream.CopyTo(outputstream);
|
||||
outputstream.Position = 0;
|
||||
};
|
||||
return outputstream;
|
||||
}
|
||||
|
||||
private void ReadStringLookUpTable(Stream stream)
|
||||
{
|
||||
int tableSize = ReadInt(stream);
|
||||
StringLookUpTable = new List<string>(tableSize);
|
||||
for (int i = 0; i < tableSize; i++)
|
||||
{
|
||||
string s = ReadString(stream);
|
||||
StringLookUpTable.Add(s);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadGameRuleHierarchy(Stream stream, GRFFile.GameRule parent)
|
||||
{
|
||||
_ = parent ?? throw new ArgumentNullException(nameof(parent));
|
||||
int count = ReadInt(stream);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
(string Name, int Count) parameter = (GetString(stream), ReadInt(stream));
|
||||
var rule = parent.AddRule(parameter.Name);
|
||||
for (int j = 0; j < parameter.Count; j++)
|
||||
{
|
||||
rule.Parameters.Add(GetString(stream), ReadString(stream));
|
||||
}
|
||||
ReadGameRuleHierarchy(stream, rule);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetString(Stream stream) => StringLookUpTable[ReadInt(stream)];
|
||||
|
||||
private string ReadString(Stream stream)
|
||||
{
|
||||
short stringLength = ReadShort(stream);
|
||||
return ReadString(stream, stringLength, Encoding.ASCII);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
using PckStudio.Classes;
|
||||
using PckStudio.Classes.Utils.grf;
|
||||
using PckStudio.Classes.Utils;
|
||||
|
||||
namespace PckStudio.Classes.IO.GRF
|
||||
{
|
||||
internal class GRFFileWriter : StreamDataWriter
|
||||
{
|
||||
private readonly GRFFile _grfFile;
|
||||
private List<string> StringLookUpTable;
|
||||
|
||||
private GRFFile.eCompressionType _compressionType;
|
||||
|
||||
public static void Write(in Stream stream, GRFFile grfFile, GRFFile.eCompressionType compressionType)
|
||||
{
|
||||
new GRFFileWriter(grfFile, compressionType).WriteToStream(stream);
|
||||
}
|
||||
|
||||
private GRFFileWriter(GRFFile grfFile, GRFFile.eCompressionType compressionType) : base(false)
|
||||
{
|
||||
_compressionType = compressionType;
|
||||
if (grfFile.IsWorld)
|
||||
throw new NotImplementedException("World grf saving is currently unsupported");
|
||||
_grfFile = grfFile;
|
||||
StringLookUpTable = new List<string>();
|
||||
PrepareLookUpTable(_grfFile.Root, StringLookUpTable);
|
||||
}
|
||||
|
||||
private void PrepareLookUpTable(GRFFile.GameRule tag, List<string> LUT)
|
||||
{
|
||||
if (!LUT.Contains(tag.Name)) LUT.Add(tag.Name);
|
||||
tag.SubRules.ForEach(tag => PrepareLookUpTable(tag, LUT));
|
||||
foreach (var param in tag.Parameters)
|
||||
if (!LUT.Contains(param.Key)) LUT.Add(param.Key);
|
||||
}
|
||||
|
||||
protected override void WriteToStream(Stream stream)
|
||||
{
|
||||
WriteHeader(stream);
|
||||
using (var uncompressed_stream = new MemoryStream())
|
||||
{
|
||||
WriteBody(uncompressed_stream);
|
||||
HandleCompression(stream, uncompressed_stream);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleCompression(Stream destinationStream, MemoryStream sourceStream)
|
||||
{
|
||||
byte[] _buffer = sourceStream.ToArray();
|
||||
int _original_length = _buffer.Length;
|
||||
|
||||
if (_compressionType >= GRFFile.eCompressionType.ZlibRle)
|
||||
_buffer = CompressRle(_buffer);
|
||||
if (_compressionType >= GRFFile.eCompressionType.Zlib)
|
||||
{
|
||||
_buffer = CompressZib(_buffer);
|
||||
WriteInt(destinationStream, _original_length);
|
||||
WriteInt(destinationStream, _buffer.Length);
|
||||
}
|
||||
if (_compressionType >= GRFFile.eCompressionType.ZlibRleCrc)
|
||||
MakeAndWriteCrc(destinationStream, _buffer);
|
||||
WriteBytes(destinationStream, _buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
private byte[] CompressZib(byte[] buffer)
|
||||
{
|
||||
byte[] result;
|
||||
var outputStream = new MemoryStream(); // Stream gets Disposed in DeflaterOutputStream
|
||||
using (var deflateStream = new DeflaterOutputStream(outputStream))
|
||||
{
|
||||
WriteBytes(deflateStream, buffer);
|
||||
deflateStream.Flush();
|
||||
deflateStream.Finish();
|
||||
outputStream.Position = 0;
|
||||
result = outputStream.ToArray();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private byte[] CompressRle(byte[] buffer) => Utils.RLE<byte>.Encode(buffer).ToArray();
|
||||
|
||||
private void MakeAndWriteCrc(Stream stream, byte[] data)
|
||||
{
|
||||
uint crc = CRC32.CRC(data);
|
||||
if (crc != _grfFile.Crc) // no writting needed if there is no change
|
||||
{
|
||||
stream.Position = 3;
|
||||
WriteInt(stream, (int)crc);
|
||||
stream.Seek(0, SeekOrigin.End); // reset to the end of the stream
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteHeader(Stream stream)
|
||||
{
|
||||
WriteShort(stream, 1);
|
||||
if (_compressionType < GRFFile.eCompressionType.None ||
|
||||
_compressionType > GRFFile.eCompressionType.ZlibRleCrc)
|
||||
throw new ArgumentException(nameof(_compressionType));
|
||||
stream.WriteByte((byte)_compressionType);
|
||||
WriteInt(stream, _grfFile.Crc);
|
||||
stream.WriteByte(0);
|
||||
stream.WriteByte(0);
|
||||
stream.WriteByte(0);
|
||||
stream.WriteByte(0); // <- used in world grf
|
||||
}
|
||||
|
||||
private void WriteBody(Stream stream)
|
||||
{
|
||||
WriteTagLookUpTable(stream);
|
||||
SetString(stream, _grfFile.Root.Name);
|
||||
WriteInt(stream, _grfFile.Root.SubRules.Count);
|
||||
WriteGameRuleHierarchy(stream, _grfFile.Root);
|
||||
}
|
||||
|
||||
private void WriteTagLookUpTable(Stream stream)
|
||||
{
|
||||
WriteInt(stream, StringLookUpTable.Count);
|
||||
StringLookUpTable.ForEach( s => WriteString(stream, s) );
|
||||
}
|
||||
|
||||
private void WriteGameRuleHierarchy(Stream stream, GRFFile.GameRule parent)
|
||||
{
|
||||
foreach (var rule in parent.SubRules)
|
||||
{
|
||||
SetString(stream, rule.Name);
|
||||
WriteInt(stream, rule.Parameters.Count);
|
||||
foreach (var param in rule.Parameters) WriteParameter(stream, param);
|
||||
WriteInt(stream, rule.SubRules.Count);
|
||||
WriteGameRuleHierarchy(stream, rule);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteParameter(Stream stream, KeyValuePair<string, string> param)
|
||||
{
|
||||
SetString(stream, param.Key);
|
||||
WriteString(stream, param.Value);
|
||||
}
|
||||
|
||||
private void SetString(Stream stream, string s)
|
||||
{
|
||||
int i = StringLookUpTable.IndexOf(s);
|
||||
if (i == -1) throw new Exception(nameof(s));
|
||||
WriteInt(stream, i);
|
||||
}
|
||||
|
||||
private void WriteString(Stream stream, string s)
|
||||
{
|
||||
WriteShort(stream, (short)s.Length);
|
||||
WriteString(stream, s, Encoding.ASCII);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
|
||||
namespace PckStudio.Classes.IO.LOC
|
||||
{
|
||||
internal class LOCFileReader : StreamDataReader<LOCFile>
|
||||
{
|
||||
internal LOCFile _file;
|
||||
|
||||
public static LOCFile Read(Stream stream)
|
||||
{
|
||||
return new LOCFileReader().ReadFromStream(stream);
|
||||
}
|
||||
|
||||
private LOCFileReader() : base(false)
|
||||
{
|
||||
_file = new LOCFile();
|
||||
}
|
||||
|
||||
protected override LOCFile ReadFromStream(Stream stream)
|
||||
{
|
||||
int loc_type = ReadInt(stream);
|
||||
int language_count = ReadInt(stream);
|
||||
bool lookUpKey = loc_type == 2;
|
||||
List<string> keys = lookUpKey ? ReadKeys(stream) : null;
|
||||
for (int i = 0; i < language_count; i++)
|
||||
{
|
||||
string language = ReadString(stream);
|
||||
ReadInt(stream); // unknown value
|
||||
_file.Languages.Add(language);
|
||||
}
|
||||
for (int i = 0; i < language_count; i++)
|
||||
{
|
||||
if (0 < ReadInt(stream))
|
||||
stream.ReadByte();
|
||||
string language = ReadString(stream);
|
||||
if (!_file.Languages.Contains(language))
|
||||
throw new KeyNotFoundException(nameof(language));
|
||||
int count = ReadInt(stream);
|
||||
for (int j = 0; j < count; j++)
|
||||
{
|
||||
string key = lookUpKey ? keys[j] : ReadString(stream);
|
||||
string value = ReadString(stream);
|
||||
_file.SetLocEntry(key, language, value);
|
||||
}
|
||||
}
|
||||
return _file;
|
||||
}
|
||||
|
||||
private List<string> ReadKeys(Stream stream)
|
||||
{
|
||||
bool useUniqueIds = Convert.ToBoolean(stream.ReadByte());
|
||||
int keyCount = ReadInt(stream);
|
||||
List<string> keys = new List<string>(keyCount);
|
||||
for (int i = 0; i < keyCount; i++)
|
||||
{
|
||||
string key = useUniqueIds ? ReadInt(stream).ToString("X08") : ReadString(stream);
|
||||
keys.Add(key);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
private string ReadString(Stream stream)
|
||||
{
|
||||
int length = ReadShort(stream);
|
||||
return ReadString(stream, length, Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace PckStudio.Classes.IO.LOC
|
||||
{
|
||||
internal class LOCFileWriter : StreamDataWriter
|
||||
{
|
||||
private LOCFile _locfile;
|
||||
private int _type;
|
||||
public static void Write(Stream stream, LOCFile file, int type = 2)
|
||||
{
|
||||
new LOCFileWriter(file, type).WriteToStream(stream);
|
||||
}
|
||||
|
||||
private LOCFileWriter(LOCFile file, int type) : base(false)
|
||||
{
|
||||
_type = type;
|
||||
_locfile = file;
|
||||
}
|
||||
|
||||
protected override void WriteToStream(Stream stream)
|
||||
{
|
||||
_ = _locfile ?? throw new ArgumentNullException(nameof(_locfile));
|
||||
WriteInt(stream, _type);
|
||||
WriteInt(stream, _locfile.Languages.Count);
|
||||
if (_type == 2) WriteLocKeys(stream);
|
||||
WriteLanguages(stream, _type);
|
||||
WriteLanguageEntries(stream, _type);
|
||||
}
|
||||
|
||||
|
||||
private void WriteLocKeys(Stream stream)
|
||||
{
|
||||
stream.WriteByte(0); // dont use stringIds(ints)
|
||||
WriteInt(stream, _locfile.LocKeys.Count);
|
||||
foreach (var key in _locfile.LocKeys.Keys)
|
||||
WriteString(stream, key);
|
||||
}
|
||||
|
||||
private void WriteLanguages(Stream stream, int type)
|
||||
{
|
||||
foreach(var language in _locfile.Languages)
|
||||
{
|
||||
WriteString(stream, language);
|
||||
|
||||
//Calculate the size of the language entry
|
||||
|
||||
int size = 0;
|
||||
size += sizeof(int); // null long
|
||||
size += sizeof(byte); // null byte
|
||||
size += (sizeof(short) + Encoding.UTF8.GetByteCount(language)); // language name string
|
||||
size += sizeof(int); // key count
|
||||
|
||||
foreach (var locKey in _locfile.LocKeys.Keys)
|
||||
{
|
||||
if (type == 0) size += (2 + Encoding.UTF8.GetByteCount(locKey)); // loc key string
|
||||
size += (2 + Encoding.UTF8.GetByteCount(_locfile.LocKeys[locKey][language])); // loc key string
|
||||
}
|
||||
|
||||
WriteInt(stream, size);
|
||||
};
|
||||
}
|
||||
|
||||
private void WriteLanguageEntries(Stream stream, int type)
|
||||
{
|
||||
foreach (var language in _locfile.Languages)
|
||||
{
|
||||
WriteInt(stream, 0x6D696B75); // :P
|
||||
stream.WriteByte(0); // <- only write when the previous written int was >0
|
||||
|
||||
WriteString(stream, language);
|
||||
WriteInt(stream, _locfile.LocKeys.Keys.Count);
|
||||
foreach(var locKey in _locfile.LocKeys.Keys)
|
||||
{
|
||||
if (type == 0) WriteString(stream, locKey);
|
||||
WriteString(stream, _locfile.LocKeys[locKey][language]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void WriteString(Stream stream, string s)
|
||||
{
|
||||
WriteShort(stream, Convert.ToInt16(Encoding.UTF8.GetByteCount(s)));
|
||||
WriteString(stream, s, Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace PckStudio.Classes.IO.Model
|
||||
{
|
||||
public class ModelReader : StreamDataReader<ModelFile>
|
||||
{
|
||||
public static ModelFile Read(Stream stream, bool useLittleEndian = false)
|
||||
{
|
||||
return new ModelReader(useLittleEndian).ReadFromStream(stream);
|
||||
}
|
||||
|
||||
private ModelReader(bool useLittleEndian) : base(useLittleEndian)
|
||||
{
|
||||
}
|
||||
|
||||
protected override ModelFile ReadFromStream(Stream stream)
|
||||
{
|
||||
var modelFile = new ModelFile();
|
||||
int version = ReadInt(stream);
|
||||
int modelCount = ReadInt(stream);
|
||||
for (; 0 < modelCount; modelCount--)
|
||||
{
|
||||
string name = ReadString(stream);
|
||||
int width = ReadInt(stream);
|
||||
int height = ReadInt(stream);
|
||||
var model = new ModelFile.Model(name, width, height);
|
||||
|
||||
int partCount = ReadInt(stream);
|
||||
for (; 0 < partCount; partCount--)
|
||||
{
|
||||
string partname = ReadString(stream);
|
||||
float x = ReadFloat(stream);
|
||||
float y = ReadFloat(stream);
|
||||
float z = ReadFloat(stream);
|
||||
|
||||
float yaw = ReadFloat(stream);
|
||||
float pitch = ReadFloat(stream);
|
||||
float roll = ReadFloat(stream);
|
||||
var part = new ModelFile.Model.Part(partname, (x, y, z), (yaw, pitch, roll));
|
||||
if (version > 0)
|
||||
{
|
||||
float _1 = ReadFloat(stream);
|
||||
float _2 = ReadFloat(stream);
|
||||
float _3 = ReadFloat(stream);
|
||||
Debug.WriteLine("[{0}]: {1}, {2}, {3}", nameof(ModelReader), _1, _2, _3);
|
||||
}
|
||||
|
||||
int boxCount = ReadInt(stream);
|
||||
for (; 0 < boxCount; boxCount--)
|
||||
{
|
||||
var pos = (ReadFloat(stream), ReadFloat(stream), ReadFloat(stream));
|
||||
var size = (ReadInt(stream), ReadInt(stream), ReadInt(stream));
|
||||
float u = ReadFloat(stream), v = ReadFloat(stream);
|
||||
float scale = ReadFloat(stream);
|
||||
bool mirrored = ReadBool(stream);
|
||||
part.AddBox(pos, size, u, v, scale, mirrored);
|
||||
}
|
||||
model.AddPart(part);
|
||||
}
|
||||
modelFile.AddModel(model);
|
||||
|
||||
}
|
||||
return modelFile;
|
||||
}
|
||||
|
||||
private string ReadString(Stream stream)
|
||||
{
|
||||
short length = ReadShort(stream);
|
||||
return ReadString(stream, length, Encoding.ASCII);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PckStudio.Classes.IO.Model
|
||||
{
|
||||
internal class ModelWriter : StreamDataWriter
|
||||
{
|
||||
private ModelFile _modelFile;
|
||||
public static void Write(Stream stream, ModelFile modelFile)
|
||||
{
|
||||
new ModelWriter(modelFile, false).WriteToStream(stream);
|
||||
}
|
||||
|
||||
public ModelWriter(ModelFile modelFile, bool littleEndian) : base(littleEndian)
|
||||
{
|
||||
_modelFile = modelFile;
|
||||
}
|
||||
|
||||
protected override void WriteToStream(Stream stream)
|
||||
{
|
||||
int version = 0;
|
||||
WriteInt(stream, version);
|
||||
WriteInt(stream, _modelFile.Models.Count);
|
||||
foreach (var model in _modelFile.Models)
|
||||
{
|
||||
WriteString(stream, model.name);
|
||||
WriteInt(stream, model.textureSize.Width);
|
||||
WriteInt(stream, model.textureSize.Height);
|
||||
WriteInt(stream, model.parts.Count);
|
||||
foreach (var part in model.parts)
|
||||
{
|
||||
WriteString(stream, part.name);
|
||||
WriteFloat(stream, part.position.x);
|
||||
WriteFloat(stream, part.position.y);
|
||||
WriteFloat(stream, part.position.z);
|
||||
|
||||
WriteFloat(stream, part.rotation.yaw);
|
||||
WriteFloat(stream, part.rotation.pitch);
|
||||
WriteFloat(stream, part.rotation.roll);
|
||||
|
||||
if (version > 0)
|
||||
{
|
||||
WriteFloat(stream, 0.0f);
|
||||
WriteFloat(stream, 0.0f);
|
||||
WriteFloat(stream, 0.0f);
|
||||
}
|
||||
|
||||
WriteInt(stream, part.Boxes.Count);
|
||||
foreach (var box in part.Boxes)
|
||||
{
|
||||
WriteFloat(stream, box.Position.x);
|
||||
WriteFloat(stream, box.Position.y);
|
||||
WriteFloat(stream, box.Position.z);
|
||||
|
||||
WriteInt(stream, box.Size.width);
|
||||
WriteInt(stream, box.Size.height);
|
||||
WriteInt(stream, box.Size.length);
|
||||
|
||||
WriteFloat(stream, box.U);
|
||||
WriteFloat(stream, box.V);
|
||||
WriteFloat(stream, box.Scale);
|
||||
|
||||
WriteBool(stream, box.Mirror);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteString(Stream stream, string s)
|
||||
{
|
||||
WriteShort(stream, (short)s.Length);
|
||||
WriteString(stream, s, Encoding.ASCII);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace PckStudio.Classes.IO.PCK
|
||||
{
|
||||
internal class PCKFileReader : StreamDataReader<PCKFile>
|
||||
{
|
||||
private PCKFile _file;
|
||||
private List<string> LUT;
|
||||
|
||||
public static PCKFile Read(Stream stream, bool isLittleEndian)
|
||||
{
|
||||
return new PCKFileReader(isLittleEndian).ReadFromStream(stream);
|
||||
}
|
||||
|
||||
private PCKFileReader(bool isLittleEndian) : base(isLittleEndian)
|
||||
{
|
||||
}
|
||||
|
||||
protected override PCKFile ReadFromStream(Stream stream)
|
||||
{
|
||||
int pck_type = ReadInt(stream);
|
||||
if (pck_type > 0xf0_00_00) // 03 00 00 00 == true
|
||||
throw new OverflowException(nameof(pck_type));
|
||||
_file = new PCKFile(pck_type);
|
||||
ReadLookUpTable(stream);
|
||||
ReadFileEntries(stream);
|
||||
ReadFileContents(stream);
|
||||
return _file;
|
||||
}
|
||||
|
||||
private void ReadLookUpTable(Stream stream)
|
||||
{
|
||||
int count = ReadInt(stream);
|
||||
LUT = new List<string>(count);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int index = ReadInt(stream);
|
||||
string value = ReadString(stream);
|
||||
LUT.Insert(index, value);
|
||||
}
|
||||
if (LUT.Contains("XMLVERSION"))
|
||||
Console.WriteLine(ReadInt(stream)); // xml version num ??
|
||||
}
|
||||
|
||||
private void ReadFileEntries(Stream stream)
|
||||
{
|
||||
int file_entry_count = ReadInt(stream);
|
||||
for (; 0 < file_entry_count; file_entry_count--)
|
||||
{
|
||||
int file_size = ReadInt(stream);
|
||||
var file_type = (PCKFile.FileData.FileType)ReadInt(stream);
|
||||
string file_path = ReadString(stream).Replace('\\', '/');
|
||||
var entry = new PCKFile.FileData(file_path, file_type, file_size);
|
||||
_file.Files.Add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadFileContents(Stream stream)
|
||||
{
|
||||
foreach (var file in _file.Files)
|
||||
{
|
||||
int property_count = ReadInt(stream);
|
||||
for (; 0 < property_count; property_count--)
|
||||
{
|
||||
string key = LUT[ReadInt(stream)];
|
||||
string value = ReadString(stream);
|
||||
file.properties.Add((key, value));
|
||||
}
|
||||
stream.Read(file.data, 0, file.size);
|
||||
};
|
||||
}
|
||||
|
||||
private string ReadString(Stream stream)
|
||||
{
|
||||
int len = ReadInt(stream);
|
||||
string s = ReadString(stream, len, IsUsingLittleEndian ? Encoding.Unicode : Encoding.BigEndianUnicode);
|
||||
ReadInt(stream); // padding
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace PckStudio.Classes.IO.PCK
|
||||
{
|
||||
internal class PCKFileWriter : StreamDataWriter
|
||||
{
|
||||
private PCKFile _pckfile;
|
||||
private List<string> LUT = new List<string>();
|
||||
|
||||
public static void Write(Stream stream, PCKFile file, bool isLittleEndian, bool isSkinsPCK = false)
|
||||
{
|
||||
new PCKFileWriter(file, isLittleEndian, isSkinsPCK).WriteToStream(stream);
|
||||
}
|
||||
|
||||
private PCKFileWriter(PCKFile file, bool isLittleEndian, bool isSkinsPCK) : base(isLittleEndian)
|
||||
{
|
||||
_pckfile = file;
|
||||
LUT = _pckfile.GatherPropertiesList();
|
||||
if (!LUT.Contains("XMLVERSION") && isSkinsPCK) LUT.Insert(0, "XMLVERSION");
|
||||
}
|
||||
|
||||
protected override void WriteToStream(Stream stream)
|
||||
{
|
||||
WriteInt(stream, _pckfile.type);
|
||||
WriteLookUpTable(stream);
|
||||
WriteFileEntries(stream);
|
||||
WriteFileContents(stream);
|
||||
}
|
||||
|
||||
private void WriteString(Stream stream, string s)
|
||||
{
|
||||
WriteInt(stream, s.Length);
|
||||
WriteString(stream, s, IsUsingLittleEndian ? Encoding.Unicode : Encoding.BigEndianUnicode);
|
||||
WriteInt(stream, 0); // padding
|
||||
}
|
||||
|
||||
private void WriteLookUpTable(Stream stream)
|
||||
{
|
||||
WriteInt(stream, LUT.Count);
|
||||
LUT.ForEach(entry =>
|
||||
{
|
||||
WriteInt(stream, LUT.IndexOf(entry));
|
||||
WriteString(stream, entry);
|
||||
});
|
||||
if (LUT.Contains("XMLVERSION"))
|
||||
WriteInt(stream, 0x1337); // :^)
|
||||
}
|
||||
|
||||
private void WriteFileEntries(Stream stream)
|
||||
{
|
||||
WriteInt(stream, _pckfile.Files.Count);
|
||||
foreach (var file in _pckfile.Files)
|
||||
{
|
||||
WriteInt(stream, file.size);
|
||||
WriteInt(stream, (int)file.filetype);
|
||||
WriteString(stream, file.filepath);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteFileContents(Stream stream)
|
||||
{
|
||||
foreach (var file in _pckfile.Files)
|
||||
{
|
||||
WriteInt(stream, file.properties.Count);
|
||||
foreach (var property in file.properties)
|
||||
{
|
||||
if (!LUT.Contains(property.Item1))
|
||||
throw new Exception("Tag not in Look Up Table: " + property.Item1);
|
||||
WriteInt(stream, LUT.IndexOf(property.Item1));
|
||||
WriteString(stream, property.Item2);
|
||||
}
|
||||
WriteBytes(stream, file.data, file.size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace PckStudio.Classes.IO
|
||||
protected static string ReadString(Stream stream, int length, Encoding encoding)
|
||||
{
|
||||
byte[] buffer = ReadBytes(stream, length << Convert.ToInt32(encoding is UnicodeEncoding));
|
||||
return encoding.GetString(buffer);
|
||||
return encoding.GetString(buffer).TrimEnd('\0');
|
||||
}
|
||||
|
||||
protected static byte[] ReadBytes(Stream stream, int count)
|
||||
|
||||
325
PCK-Studio/Classes/Misc/FTPClient.cs
Normal file
325
PCK-Studio/Classes/Misc/FTPClient.cs
Normal file
@@ -0,0 +1,325 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace PckStudio.Classes.Misc
|
||||
{
|
||||
public class FTPClient : IDisposable
|
||||
{
|
||||
private const int bufferSize = 2048;
|
||||
|
||||
private Uri hostUri;
|
||||
private NetworkCredential credentials;
|
||||
|
||||
private FtpWebRequest request = null;
|
||||
private FtpWebResponse response = null;
|
||||
private Stream _stream = null;
|
||||
|
||||
public FTPClient(string host, string username)
|
||||
: this(new Uri(host), username, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public FTPClient(Uri uri, string username)
|
||||
: this(uri, username, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public FTPClient(string host, string username, string password)
|
||||
: this(new Uri(host), username, password)
|
||||
{
|
||||
}
|
||||
|
||||
public FTPClient(Uri uri, string username, string password)
|
||||
{
|
||||
hostUri = uri;
|
||||
credentials = new NetworkCredential(username, password);
|
||||
|
||||
if (hostUri.Scheme != Uri.UriSchemeFtp)
|
||||
{
|
||||
throw new InvalidOperationException("Not a valid FTP Scheme");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new FTP Request
|
||||
/// </summary>
|
||||
/// <param name="uri"></param>
|
||||
/// <param name="credentials"></param>
|
||||
/// <param name="method">See <see cref="WebRequestMethods.Ftp"/></param>
|
||||
/// <returns><see cref="FtpWebRequest"/></returns>
|
||||
public static FtpWebRequest CreateFTPWebRequest(Uri uri, ICredentials credentials, string method)
|
||||
{
|
||||
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(uri);
|
||||
request.Credentials = credentials;
|
||||
request.Method = method;
|
||||
return request;
|
||||
}
|
||||
|
||||
// TODO: let it accept a destination Stream ?
|
||||
public void DownloadFile(string remoteFilepath, string localFilepath)
|
||||
{
|
||||
try
|
||||
{
|
||||
request = CreateFTPWebRequest(new Uri(hostUri, remoteFilepath), credentials, WebRequestMethods.Ftp.DownloadFile);
|
||||
//request = (FtpWebRequest)WebRequest.Create(host + "/" + remoteFile);
|
||||
//request.Credentials = credentials;
|
||||
//request.Method = WebRequestMethods.Ftp.DownloadFile;
|
||||
|
||||
request.UseBinary = true;
|
||||
request.UsePassive = true;
|
||||
request.KeepAlive = true;
|
||||
|
||||
response = (FtpWebResponse)request.GetResponse();
|
||||
_stream = response.GetResponseStream();
|
||||
byte[] buffer = new byte[Convert.ToInt32(GetFileSize(remoteFilepath))];
|
||||
int num = _stream.Read(buffer, 0, Convert.ToInt32(GetFileSize(remoteFilepath)));
|
||||
|
||||
using (FileStream fileStream = new FileStream(localFilepath, FileMode.OpenOrCreate))
|
||||
{
|
||||
try
|
||||
{
|
||||
while (num > 0)
|
||||
{
|
||||
fileStream.Write(buffer, 0, num);
|
||||
num = _stream.Read(buffer, 0, Convert.ToInt32(GetFileSize(remoteFilepath)));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
_stream.Close();
|
||||
response.Close();
|
||||
request = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string[] ListDirectory(string directory)
|
||||
{
|
||||
try
|
||||
{
|
||||
request = CreateFTPWebRequest(new Uri(hostUri, directory), credentials, WebRequestMethods.Ftp.ListDirectory);
|
||||
//request = (FtpWebRequest)WebRequest.Create(host + "/" + directory);
|
||||
//request.Credentials = credentials;
|
||||
//request.Method = WebRequestMethods.Ftp.ListDirectory;
|
||||
|
||||
request.UseBinary = true;
|
||||
request.UsePassive = true;
|
||||
request.KeepAlive = true;
|
||||
|
||||
response = (FtpWebResponse)request.GetResponse();
|
||||
_stream = response.GetResponseStream();
|
||||
StreamReader streamReader = new StreamReader(_stream);
|
||||
string text = string.Empty;
|
||||
try
|
||||
{
|
||||
while (streamReader.Peek() != -1)
|
||||
{
|
||||
text += streamReader.ReadLine() + "|";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
|
||||
streamReader.Close();
|
||||
_stream.Close();
|
||||
response.Close();
|
||||
request = null;
|
||||
|
||||
try
|
||||
{
|
||||
return text.Split("|".ToCharArray());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
|
||||
public void UploadFile(string localFile, string remoteFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
request = CreateFTPWebRequest(new Uri(hostUri, remoteFile), credentials, WebRequestMethods.Ftp.UploadFile);
|
||||
//request = (FtpWebRequest)WebRequest.Create(host + "/" + remoteFile);
|
||||
//request.Credentials = credentials;
|
||||
//request.Method = WebRequestMethods.Ftp.UploadFile;
|
||||
|
||||
request.UseBinary = true;
|
||||
request.UsePassive = true;
|
||||
request.KeepAlive = true;
|
||||
|
||||
_stream = request.GetRequestStream();
|
||||
FileStream fileStream = new FileStream(localFile, FileMode.Open);
|
||||
byte[] buffer = new byte[fileStream.Length];
|
||||
int num = fileStream.Read(buffer, 0, (int)fileStream.Length);
|
||||
try
|
||||
{
|
||||
while (num != 0)
|
||||
{
|
||||
_stream.Write(buffer, 0, num);
|
||||
num = fileStream.Read(buffer, 0, (int)fileStream.Length);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
|
||||
fileStream.Close();
|
||||
_stream.Close();
|
||||
request = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteFile(string filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
request = CreateFTPWebRequest(new Uri(hostUri, filename), credentials, WebRequestMethods.Ftp.DeleteFile);
|
||||
//request = (FtpWebRequest)WebRequest.Create(host + "/" + filename);
|
||||
//request.Credentials = credentials;
|
||||
//request.Method = WebRequestMethods.Ftp.DeleteFile;
|
||||
|
||||
request.UseBinary = true;
|
||||
request.UsePassive = true;
|
||||
request.KeepAlive = true;
|
||||
|
||||
response = (FtpWebResponse)request.GetResponse();
|
||||
response.Close();
|
||||
|
||||
request = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void Rename(string name, string newName)
|
||||
{
|
||||
try
|
||||
{
|
||||
request = CreateFTPWebRequest(new Uri(hostUri, name), credentials, WebRequestMethods.Ftp.Rename);
|
||||
//request = (FtpWebRequest)WebRequest.Create(host + "/" + name);
|
||||
//request.Credentials = credentials;
|
||||
//request.Method = WebRequestMethods.Ftp.Rename;
|
||||
|
||||
request.UseBinary = true;
|
||||
request.UsePassive = true;
|
||||
request.KeepAlive = true;
|
||||
|
||||
request.RenameTo = newName;
|
||||
response = (FtpWebResponse)request.GetResponse();
|
||||
response.Close();
|
||||
request = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void AppendFile(string serverFilepath, byte[] data)
|
||||
{
|
||||
try
|
||||
{
|
||||
request = CreateFTPWebRequest(new Uri(hostUri, serverFilepath), credentials, WebRequestMethods.Ftp.AppendFile);
|
||||
//request = (FtpWebRequest)WebRequest.Create(host + "/" + name);
|
||||
//request.Credentials = credentials;
|
||||
//request.Method = WebRequestMethods.Ftp.MakeDirectory;
|
||||
|
||||
request.UseBinary = true;
|
||||
request.UsePassive = true;
|
||||
request.KeepAlive = true;
|
||||
|
||||
request.ContentLength = data.Length;
|
||||
|
||||
// This example assumes the FTP site uses anonymous logon.
|
||||
Stream requestStream = request.GetRequestStream();
|
||||
requestStream.Write(data, 0, data.Length);
|
||||
requestStream.Close();
|
||||
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
|
||||
|
||||
Console.WriteLine("Append status: {0}", response.StatusDescription);
|
||||
|
||||
response.Close();
|
||||
request = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateDirectory(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
request = CreateFTPWebRequest(new Uri(hostUri, name), credentials, WebRequestMethods.Ftp.MakeDirectory);
|
||||
//request = (FtpWebRequest)WebRequest.Create(host + "/" + name);
|
||||
//request.Credentials = credentials;
|
||||
//request.Method = WebRequestMethods.Ftp.MakeDirectory;
|
||||
|
||||
request.UseBinary = true;
|
||||
request.UsePassive = true;
|
||||
request.KeepAlive = true;
|
||||
|
||||
response = (FtpWebResponse)request.GetResponse();
|
||||
response.Close();
|
||||
|
||||
request = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public long GetFileSize(string filepath)
|
||||
{
|
||||
FtpWebRequest ftpWebRequest = CreateFTPWebRequest(new Uri(hostUri, filepath), credentials, WebRequestMethods.Ftp.GetFileSize);
|
||||
//FtpWebRequest ftpWebRequest = (FtpWebRequest)WebRequest.Create(host + "/" + fileName);
|
||||
//ftpWebRequest.Credentials = credentials;
|
||||
//ftpWebRequest.Method = WebRequestMethods.Ftp.GetFileSize;
|
||||
|
||||
ftpWebRequest.UseBinary = true;
|
||||
|
||||
FtpWebResponse response = (FtpWebResponse)ftpWebRequest.GetResponse();
|
||||
long contentLength = response.ContentLength;
|
||||
response.Close();
|
||||
return contentLength;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_stream.Dispose();
|
||||
response.Dispose();
|
||||
request = null;
|
||||
response = null;
|
||||
_stream = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using DiscordRPC;
|
||||
using PckStudio.Properties;
|
||||
|
||||
namespace PckStudio.Classes.Misc
|
||||
{
|
||||
@@ -11,7 +12,7 @@ namespace PckStudio.Classes.Misc
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
Client = new DiscordRpcClient("825875166574673940");
|
||||
Client = new DiscordRpcClient(Settings.Default.RichPresenceId);
|
||||
Client.Initialize();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace PckStudio.Classes.Models.DefaultModels
|
||||
_ = Textures[0] ?? throw new NullReferenceException(nameof(Textures));
|
||||
Image source = Textures[0].Source;
|
||||
|
||||
(int top, int side) armWidth = _skinANIM.GetANIMFlag(eANIM_EFFECTS.SLIM_MODEL) ? (6, 14) : (8, 16);
|
||||
(int top, int side) armWidth = _skinANIM.GetFlag(ANIM_EFFECTS.SLIM_MODEL) ? (6, 14) : (8, 16);
|
||||
|
||||
Box head = new Box(source, new Rectangle(8, 0, 16, 8), new Rectangle(0, 8, 32, 8), new Point3D(0f, 0f, 0f));
|
||||
Box headOverlay = new Box(source, new Rectangle(40, 0, 16, 8), new Rectangle(32, 8, 32, 8), new Point3D(0f, 0f, 0f));
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace PckStudio.Classes.Networking
|
||||
{
|
||||
class Network
|
||||
{
|
||||
public static string Version = "6.51";
|
||||
public static string Version = Application.ProductVersion;
|
||||
public static bool IsBeta = true;
|
||||
public static bool Portable = false;
|
||||
public static bool NeedsUpdate = false;
|
||||
@@ -21,6 +21,8 @@ namespace PckStudio.Classes.Networking
|
||||
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);
|
||||
|
||||
@@ -1,190 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Drawing;
|
||||
using Newtonsoft.Json;
|
||||
using PckStudio.API.PCKCenter.model;
|
||||
using PckStudio.API.PCKCenter;
|
||||
|
||||
namespace PckStudio.Classes.Networking
|
||||
{
|
||||
public class PCKCollections
|
||||
{
|
||||
WebClient client = new WebClient();
|
||||
public string CurrentPackDl = "";
|
||||
string cache = Program.AppDataCache + "/packs/";
|
||||
public PCKCenterJSON CenterPacks;
|
||||
public LocalActions LocalAction = new LocalActions();
|
||||
public string[] GetCategories()
|
||||
{
|
||||
string cat = "";
|
||||
try
|
||||
{
|
||||
cat = client.DownloadString(Program.BaseAPIUrl + "/center/packs/Categiories.json");
|
||||
}
|
||||
catch
|
||||
{
|
||||
cat = client.DownloadString(Program.BaseAPIUrl + "/center/packs/VitaCategiories.json");
|
||||
}
|
||||
return JsonConvert.DeserializeObject<string[]>(cat);
|
||||
}
|
||||
|
||||
public PCKCenterJSON GetPackDescs(string Category, bool IsVita)
|
||||
{
|
||||
string cat = "";
|
||||
try
|
||||
{
|
||||
switch (IsVita)
|
||||
{
|
||||
case (true):
|
||||
cat = client.DownloadString(Program.BaseAPIUrl + "/center/packs/vita/" + Category + ".json");
|
||||
break;
|
||||
case (false):
|
||||
cat = client.DownloadString(Program.BaseAPIUrl + "/center/packs/normal/" + Category + ".json");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
switch (IsVita)
|
||||
{
|
||||
case (true):
|
||||
cat = client.DownloadString(Program.BackUpAPIUrl + "/center/packs/vita/" + Category + ".json");
|
||||
break;
|
||||
case (false):
|
||||
cat = client.DownloadString(Program.BackUpAPIUrl + "/center/packs/normal/" + Category + ".json");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PCKCenterJSON Data = JsonConvert.DeserializeObject<PCKCenterJSON>(cat);
|
||||
return Data;
|
||||
}
|
||||
public string[] GetPackData(string Category, bool IsVita)
|
||||
{
|
||||
string cat = "";
|
||||
try
|
||||
{
|
||||
switch (IsVita)
|
||||
{
|
||||
case (true):
|
||||
cat = client.DownloadString(Network.MainURL + "/studio/PCK/api/pcks/Vita/" + Category + ".desc");
|
||||
break;
|
||||
case (false):
|
||||
cat = client.DownloadString(Network.MainURL + "/studio/PCK/api/pcks/" + Category + ".desc");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
switch (IsVita)
|
||||
{
|
||||
case (true):
|
||||
cat = client.DownloadString(Network.BackUpURL + "/studio/PCK/api/pcks/Vita/" + Category + ".desc");
|
||||
break;
|
||||
case (false):
|
||||
cat = client.DownloadString(Network.BackUpURL + "/studio/PCK/api/pcks/" + Category + ".desc");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return cat.Split(new[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public Image GetPackImage(int packID, bool IsVita)
|
||||
{
|
||||
byte[] cat = new byte[] { };
|
||||
try
|
||||
{
|
||||
switch (IsVita)
|
||||
{
|
||||
case (true):
|
||||
cat = client.DownloadData(Program.BaseAPIUrl + "/center/packs/vita/images/" + packID + ".png");
|
||||
break;
|
||||
case (false):
|
||||
cat = client.DownloadData(Program.BaseAPIUrl + "/center/packs/normal/images/" + packID + ".png");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
switch (IsVita)
|
||||
{
|
||||
case (true):
|
||||
cat = client.DownloadData(Program.BackUpAPIUrl + "/center/packs/vita/images/" + packID + ".png");
|
||||
break;
|
||||
case (false):
|
||||
cat = client.DownloadData(Program.BackUpAPIUrl + "/center/packs/normal/images/" + packID + ".png");
|
||||
break;
|
||||
}
|
||||
}
|
||||
Stream fs = new MemoryStream(cat);
|
||||
Image image;
|
||||
image = Image.FromStream(fs);
|
||||
fs.Flush();
|
||||
fs.Dispose();
|
||||
return image;
|
||||
}
|
||||
|
||||
public bool TryDownloadPack(int packID, bool IsVita, string Category)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Image image = GetPackImage(packID, IsVita);
|
||||
string DescPath = cache;
|
||||
Directory.CreateDirectory(cache + "normal/");
|
||||
Directory.CreateDirectory(cache + "normal/images");
|
||||
Directory.CreateDirectory(cache + "normal/pcks");
|
||||
Directory.CreateDirectory(cache + "vita/");
|
||||
Directory.CreateDirectory(cache + "vita/images");
|
||||
Directory.CreateDirectory(cache + "vita/pcks");
|
||||
PCKCenterJSON Local = LocalAction.GetLocalJSON(Category, IsVita);
|
||||
switch (IsVita)
|
||||
{
|
||||
case (false):
|
||||
image.Save(cache + "normal/images/" + packID + ".png");
|
||||
client.DownloadFile(Program.BaseAPIUrl + "/center/packs/normal/pcks/" + packID + ".pck", cache + "normal/pcks/" + packID + ".pck");
|
||||
break;
|
||||
case (true):
|
||||
image.Save(cache + "vita/images/" + packID + ".png");
|
||||
client.DownloadFile(Program.BaseAPIUrl + "/center/packs/vita/pcks/" + packID + ".pck", cache + "vita/pcks/" + packID + ".pck");
|
||||
break;
|
||||
}
|
||||
Local = LocalAction.AddPack(Local, CenterPacks.Data[packID.ToString()], packID);
|
||||
LocalAction.SaveLocalJSON(Local, Category, IsVita);
|
||||
LocalAction.SaveLocalCategories(IsVita);
|
||||
/**/
|
||||
image.Dispose();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void TryTestPackInfo(bool IsVita)
|
||||
{
|
||||
try
|
||||
{
|
||||
WebClient wc = new WebClient();
|
||||
string CategoryJSON = wc.DownloadString(Program.BaseAPIUrl + "/center/packs/Categiories.json");
|
||||
string[] Categories = JsonConvert.DeserializeObject<string[]>(CategoryJSON);
|
||||
PCKCenterJSON Result = pk1(Categories[2]);
|
||||
Console.Write(""); // this is a breakpoint
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.Write(""); // this is a breakpoint
|
||||
}
|
||||
}
|
||||
PCKCenterJSON pk1(string categorie)
|
||||
{
|
||||
WebClient wc = new WebClient();
|
||||
string DataJSON = wc.DownloadString(Program.BaseAPIUrl + "/center/packs/normal/" + categorie + ".json");
|
||||
PCKCenterJSON Data = JsonConvert.DeserializeObject<PCKCenterJSON>(DataJSON);
|
||||
return Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,18 @@ using System.Windows.Forms;
|
||||
|
||||
namespace PckStudio.Classes.Networking
|
||||
{
|
||||
public enum UpdateResult
|
||||
{
|
||||
// Base Failure value
|
||||
Failure = -1,
|
||||
// Base Success value
|
||||
Success,
|
||||
|
||||
UpdateAvailable,
|
||||
|
||||
UpdateFailure,
|
||||
}
|
||||
|
||||
class UpdateOptions
|
||||
{
|
||||
public bool IsBeta { get; set; }
|
||||
@@ -35,6 +47,12 @@ namespace PckStudio.Classes.Networking
|
||||
|
||||
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;
|
||||
|
||||
@@ -55,29 +55,29 @@ namespace PckStudio.Classes._3ds.Utils
|
||||
stream.Write(buffer, 0, 4);
|
||||
}
|
||||
|
||||
public static int CalcBufferSize(_3DSTextureFormat fmt, int w, int h)
|
||||
public static int CalcBufferSize(_3DSTextureFormat textureFormat, int width, int height)
|
||||
{
|
||||
switch (fmt)
|
||||
switch (textureFormat)
|
||||
{
|
||||
case _3DSTextureFormat.argb8:
|
||||
return w * h * 4;
|
||||
return width * height * 4;
|
||||
case _3DSTextureFormat.rgb8:
|
||||
return w * h * 3;
|
||||
return width * height * 3;
|
||||
case _3DSTextureFormat.rgba5551:
|
||||
case _3DSTextureFormat.rgb565:
|
||||
case _3DSTextureFormat.rgba4:
|
||||
case _3DSTextureFormat.la8:
|
||||
case _3DSTextureFormat.hilo8:
|
||||
return w * h * 2;
|
||||
return width * height * 2;
|
||||
case _3DSTextureFormat.l8:
|
||||
case _3DSTextureFormat.a8:
|
||||
case _3DSTextureFormat.la4:
|
||||
case _3DSTextureFormat.etc1a4:
|
||||
return w * h;
|
||||
return width * height;
|
||||
case _3DSTextureFormat.l4:
|
||||
case _3DSTextureFormat.a4:
|
||||
case _3DSTextureFormat.etc1:
|
||||
return w * h >> 1;
|
||||
return width * height >> 1;
|
||||
default:
|
||||
throw new InvalidDataException("Invalid texture format on BCH!");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Runtime.InteropServices;
|
||||
using PckStudio.Classes._3ds.Utils;
|
||||
|
||||
namespace PckStudio.Classes._3ds
|
||||
@@ -9,6 +11,39 @@ namespace PckStudio.Classes._3ds
|
||||
private static int[] tileOrder = { 0, 1, 8, 9, 2, 3, 10, 11, 16, 17, 24, 25, 18, 19, 26, 27, 4, 5, 12, 13, 6, 7, 14, 15, 20, 21, 28, 29, 22, 23, 30, 31, 32, 33, 40, 41, 34, 35, 42, 43, 48, 49, 56, 57, 50, 51, 58, 59, 36, 37, 44, 45, 38, 39, 46, 47, 52, 53, 60, 61, 54, 55, 62, 63 };
|
||||
private static int[,] etc1LUT = { { 2, 8, -2, -8 }, { 5, 17, -5, -17 }, { 9, 29, -9, -29 }, { 13, 42, -13, -42 }, { 18, 60, -18, -60 }, { 24, 80, -24, -80 }, { 33, 106, -33, -106 }, { 47, 183, -47, -183 } };
|
||||
|
||||
private static class TextureConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a Bitmap from a RGBA8 Texture buffer.
|
||||
/// </summary>
|
||||
/// <param name="array">The Buffer</param>
|
||||
/// <param name="width">Width of the Texture</param>
|
||||
/// <param name="height">Height of the Texture</param>
|
||||
/// <returns></returns>
|
||||
public static Bitmap ToBitmap(byte[] array, int width, int height)
|
||||
{
|
||||
Bitmap img = new Bitmap(width, height, PixelFormat.Format32bppArgb);
|
||||
BitmapData imgData = img.LockBits(new Rectangle(0, 0, img.Width, img.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
Marshal.Copy(array, 0, imgData.Scan0, array.Length);
|
||||
img.UnlockBits(imgData);
|
||||
return img;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a RGBA8 Texture Buffer from a Bitmap.
|
||||
/// </summary>
|
||||
/// <param name="img">The Bitmap</param>
|
||||
/// <returns></returns>
|
||||
public static byte[] ToArray(Bitmap img)
|
||||
{
|
||||
BitmapData imgData = img.LockBits(new Rectangle(0, 0, img.Width, img.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||
byte[] array = new byte[imgData.Stride * img.Height];
|
||||
Marshal.Copy(imgData.Scan0, array, 0, array.Length);
|
||||
img.UnlockBits(imgData);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodes a PICA200 Texture.
|
||||
/// </summary>
|
||||
@@ -309,7 +344,7 @@ namespace PckStudio.Classes._3ds
|
||||
break;
|
||||
}
|
||||
|
||||
return TextureUtils.ToBitmap(output, width, height);
|
||||
return TextureConverter.ToBitmap(output, width, height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -320,7 +355,7 @@ namespace PckStudio.Classes._3ds
|
||||
/// <returns></returns>
|
||||
public static byte[] Encode(Bitmap img, _3DSTextureFormat format)
|
||||
{
|
||||
byte[] data = TextureUtils.ToArray(img);
|
||||
byte[] data = TextureConverter.ToArray(img);
|
||||
byte[] output = new byte[data.Length];
|
||||
|
||||
int outputOffset = 0;
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace PckStudio.Classes._3ds
|
||||
{
|
||||
class TextureUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a Bitmap from a RGBA8 Texture buffer.
|
||||
/// </summary>
|
||||
/// <param name="array">The Buffer</param>
|
||||
/// <param name="width">Width of the Texture</param>
|
||||
/// <param name="height">Height of the Texture</param>
|
||||
/// <returns></returns>
|
||||
public static Bitmap ToBitmap(byte[] array, int width, int height)
|
||||
{
|
||||
Bitmap img = new Bitmap(width, height, PixelFormat.Format32bppArgb);
|
||||
BitmapData imgData = img.LockBits(new Rectangle(0, 0, img.Width, img.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
Marshal.Copy(array, 0, imgData.Scan0, array.Length);
|
||||
img.UnlockBits(imgData);
|
||||
return img;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a RGBA8 Texture Buffer from a Bitmap.
|
||||
/// </summary>
|
||||
/// <param name="img">The Bitmap</param>
|
||||
/// <returns></returns>
|
||||
public static byte[] ToArray(Bitmap img)
|
||||
{
|
||||
BitmapData imgData = img.LockBits(new Rectangle(0, 0, img.Width, img.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||
byte[] array = new byte[imgData.Stride * img.Height];
|
||||
Marshal.Copy(imgData.Scan0, array, 0, array.Length);
|
||||
img.UnlockBits(imgData);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,18 @@
|
||||
using PckStudio.Classes.IO.ARC;
|
||||
using OMI.Workers.Archive;
|
||||
using System.IO;
|
||||
|
||||
namespace PckStudio.Classes.Utils.ARC
|
||||
{
|
||||
public static class ARCUtil
|
||||
{
|
||||
public static void Inject(string filepath, (string filepath, byte[] data) entry)
|
||||
public static void Inject(Stream stream, (string filepath, byte[] data) entry)
|
||||
{
|
||||
using (var fs = File.Open(filepath, FileMode.Open, FileAccess.ReadWrite))
|
||||
{
|
||||
var archive = ARCFileReader.Read(fs);
|
||||
fs.Seek(0, SeekOrigin.Begin);
|
||||
archive.Add(entry.filepath, entry.data);
|
||||
ARCFileWriter.Write(fs, archive);
|
||||
}
|
||||
var reader = new ARCFileReader();
|
||||
var archive = reader.FromStream(stream);
|
||||
archive.Add(entry.filepath, entry.data);
|
||||
var writer = new ARCFileWriter(archive);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
writer.WriteToStream(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,212 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
namespace PckStudio.Classes.Utils;
|
||||
|
||||
///! Credits
|
||||
///! <see cref="https://nicoschertler.wordpress.com/2014/06/04/generic-run-length-encoding-rle-for-c/"/>
|
||||
|
||||
/// <summary>
|
||||
/// Provides the RLE codec for any integer data type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The data's type. Must be an integer type or an ArgumentException will be thrown</typeparam>
|
||||
static class RLE<T> where T : struct, IConvertible
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the marker that identifies a compressed run
|
||||
/// </summary>
|
||||
private static T rleMarker;
|
||||
|
||||
/// <summary>
|
||||
/// A run can be at most as long as the marker - 1
|
||||
/// </summary>
|
||||
private static ulong maxLength;
|
||||
|
||||
static RLE()
|
||||
{
|
||||
GetMaxValues();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RLE-Encodes a data set.
|
||||
/// </summary>
|
||||
/// <param name="data">The data to encode</param>
|
||||
/// <returns>Encoded data</returns>
|
||||
public static IEnumerable<T> Encode(IEnumerable<T> data)
|
||||
{
|
||||
var enumerator = data.GetEnumerator();
|
||||
|
||||
if (!enumerator.MoveNext())
|
||||
yield break;
|
||||
|
||||
var firstRunValue = enumerator.Current;
|
||||
ulong runLength = 1;
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
var currentValue = enumerator.Current;
|
||||
// if the current value is the value of the current run, don't yield anything,
|
||||
// just extend the run
|
||||
if (currentValue.Equals(firstRunValue))
|
||||
runLength++;
|
||||
else
|
||||
{
|
||||
// the current value is different from the current run
|
||||
// yield what we have so far
|
||||
foreach (var item in MakeRun(firstRunValue, runLength))
|
||||
yield return item;
|
||||
|
||||
// and reset the run
|
||||
firstRunValue = currentValue;
|
||||
runLength = 1;
|
||||
}
|
||||
// if there are very many identical values, don't exceed the max length
|
||||
if (runLength > maxLength)
|
||||
{
|
||||
foreach (var item in MakeRun(firstRunValue, maxLength))
|
||||
yield return item;
|
||||
runLength -= maxLength;
|
||||
}
|
||||
}
|
||||
//yield everything that has been buffered
|
||||
foreach (var item in MakeRun(firstRunValue, runLength))
|
||||
yield return item;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodes RLE-encoded data
|
||||
/// </summary>
|
||||
/// <param name="data">RLE-encoded data</param>
|
||||
/// <returns>The original data</returns>
|
||||
public static IEnumerable<T> Decode(IEnumerable<T> data)
|
||||
{
|
||||
var enumerator = data.GetEnumerator();
|
||||
if (!enumerator.MoveNext())
|
||||
yield break;
|
||||
|
||||
do
|
||||
{
|
||||
var value = enumerator.Current;
|
||||
if (!value.Equals(rleMarker))
|
||||
{
|
||||
//an ordinary value
|
||||
yield return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
//might be flag or escape
|
||||
//examine the next value
|
||||
if (!enumerator.MoveNext())
|
||||
throw new ArgumentException("The provided data is not properly encoded.");
|
||||
if (enumerator.Current.Equals(rleMarker))
|
||||
{
|
||||
//escaped value
|
||||
yield return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
//rle marker
|
||||
var length = enumerator.Current.ToInt64(CultureInfo.InvariantCulture);
|
||||
if (!enumerator.MoveNext())
|
||||
throw new ArgumentException("The provided data is not properly encoded.");
|
||||
var val = enumerator.Current;
|
||||
for (var j = 0; j < length+1; ++j)
|
||||
yield return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (enumerator.MoveNext());
|
||||
}
|
||||
|
||||
private static IEnumerable<T> MakeRun(T value, ulong length)
|
||||
{
|
||||
if ((length <= 3 && !value.Equals(rleMarker)) || length <= 1)
|
||||
{
|
||||
//don't compress this run, it is just too small
|
||||
for (ulong i = 0; i < length; i++)
|
||||
{
|
||||
yield return value.Equals(rleMarker) ? rleMarker : value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//compressed run
|
||||
yield return rleMarker;
|
||||
yield return (T)(dynamic)(length-1);
|
||||
yield return value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void GetMaxValues()
|
||||
{
|
||||
TypeCode typeCode = Type.GetTypeCode(typeof(T));
|
||||
switch (typeCode)
|
||||
{
|
||||
case TypeCode.Byte:
|
||||
{
|
||||
var limit = byte.MaxValue;
|
||||
rleMarker = __refvalue(__makeref(limit), T);
|
||||
maxLength = (ulong)(limit - 1);
|
||||
break;
|
||||
}
|
||||
case TypeCode.Char:
|
||||
{
|
||||
var limit = char.MaxValue;
|
||||
rleMarker = __refvalue(__makeref(limit), T);
|
||||
maxLength = (ulong)(limit - 1);
|
||||
break;
|
||||
}
|
||||
case TypeCode.Int16:
|
||||
{
|
||||
var limit = short.MaxValue;
|
||||
rleMarker = __refvalue(__makeref(limit), T);
|
||||
maxLength = (ulong)(limit - 1);
|
||||
break;
|
||||
}
|
||||
case TypeCode.Int32:
|
||||
{
|
||||
var limit = int.MaxValue;
|
||||
rleMarker = __refvalue(__makeref(limit), T);
|
||||
maxLength = (ulong)(limit - 1);
|
||||
break;
|
||||
}
|
||||
case TypeCode.Int64:
|
||||
{
|
||||
var limit = long.MaxValue;
|
||||
rleMarker = __refvalue(__makeref(limit), T);
|
||||
maxLength = (ulong)(limit - 1);
|
||||
break;
|
||||
}
|
||||
case TypeCode.SByte:
|
||||
{
|
||||
var limit = sbyte.MaxValue;
|
||||
rleMarker = __refvalue(__makeref(limit), T);
|
||||
maxLength = (ulong)(limit - 1);
|
||||
break;
|
||||
}
|
||||
case TypeCode.UInt16:
|
||||
{
|
||||
var limit = ushort.MaxValue;
|
||||
rleMarker = __refvalue(__makeref(limit), T);
|
||||
maxLength = (ulong)(limit - 1);
|
||||
break;
|
||||
}
|
||||
case TypeCode.UInt32:
|
||||
{
|
||||
var limit = uint.MaxValue;
|
||||
rleMarker = __refvalue(__makeref(limit), T);
|
||||
maxLength = (ulong)(limit - 1);
|
||||
break;
|
||||
}
|
||||
case TypeCode.UInt64:
|
||||
{
|
||||
var limit = ulong.MaxValue;
|
||||
rleMarker = __refvalue(__makeref(limit), T);
|
||||
maxLength = (ulong)(limit - 1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new ArgumentException("The provided type parameter is not an integer type");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,30 @@
|
||||
using System;
|
||||
/* Copyright (c) 2022-present miku-666, MattNL
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace PckStudio.Classes.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// For usage see <see cref="SkinANIM"/>
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum eANIM_EFFECTS : int
|
||||
public enum ANIM_EFFECTS : int
|
||||
{
|
||||
NONE = 0, // 0x00
|
||||
STATIC_ARMS = 1 << 0, // 0x01
|
||||
@@ -12,8 +32,8 @@ namespace PckStudio.Classes.Utils
|
||||
STATIC_LEGS = 1 << 2, // 0x04
|
||||
BAD_SANTA = 1 << 3, // 0x08
|
||||
|
||||
// Whatever effect this is should be a simple one as it's existed for a while
|
||||
unk_BIT4 = 1 << 4, // 0x10
|
||||
// Whatever effect this is should be a simple one as it's existed for a while
|
||||
__BIT_4 = 1 << 4, // 0x10
|
||||
SYNCED_LEGS = 1 << 5, // 0x20
|
||||
SYNCED_ARMS = 1 << 6, // 0x40
|
||||
STATUE_OF_LIBERTY = 1 << 7, // 0x80
|
||||
@@ -51,15 +71,20 @@ namespace PckStudio.Classes.Utils
|
||||
|
||||
public struct SkinANIM
|
||||
{
|
||||
eANIM_EFFECTS _ANIM = 0;
|
||||
private ANIM_EFFECTS _ANIM;
|
||||
public static readonly Regex animRegex = new Regex(@"^0x[0-9a-f]{1,8}\b", RegexOptions.IgnoreCase);
|
||||
|
||||
public SkinANIM(string anim)
|
||||
public SkinANIM()
|
||||
: this(ANIM_EFFECTS.NONE)
|
||||
{
|
||||
_ANIM = Parse(anim);
|
||||
}
|
||||
|
||||
public SkinANIM(string anim)
|
||||
: this(ParseString(anim))
|
||||
{
|
||||
}
|
||||
|
||||
public SkinANIM(eANIM_EFFECTS anim)
|
||||
public SkinANIM(ANIM_EFFECTS anim)
|
||||
{
|
||||
_ANIM = anim;
|
||||
}
|
||||
@@ -68,58 +93,46 @@ namespace PckStudio.Classes.Utils
|
||||
|
||||
public static bool IsValidANIM(string anim) => animRegex.IsMatch(anim ?? string.Empty);
|
||||
|
||||
public static eANIM_EFFECTS Parse(string anim)
|
||||
public static ANIM_EFFECTS ParseString(string anim)
|
||||
=> IsValidANIM(anim)
|
||||
? (eANIM_EFFECTS)Convert.ToInt32(anim.TrimEnd(' ', '\n', '\r'), 16)
|
||||
: eANIM_EFFECTS.NONE;
|
||||
? (ANIM_EFFECTS)Convert.ToInt32(anim.TrimEnd(' ', '\n', '\r'), 16)
|
||||
: ANIM_EFFECTS.NONE;
|
||||
|
||||
public void SetANIM(int anim) => SetANIM((eANIM_EFFECTS)anim);
|
||||
public void SetANIM(eANIM_EFFECTS anim) => _ANIM = anim;
|
||||
public void SetANIM(ANIM_EFFECTS anim) => _ANIM = anim;
|
||||
|
||||
public static SkinANIM operator |(SkinANIM a, SkinANIM b) => new SkinANIM(a._ANIM | b._ANIM);
|
||||
public static SkinANIM operator |(SkinANIM a, eANIM_EFFECTS anim) => new SkinANIM(a._ANIM | anim);
|
||||
public static implicit operator SkinANIM(eANIM_EFFECTS anim) => new SkinANIM(anim);
|
||||
|
||||
public static bool operator ==(SkinANIM a, eANIM_EFFECTS b)
|
||||
{
|
||||
return a._ANIM == b;
|
||||
}
|
||||
|
||||
public static bool operator !=(SkinANIM a, eANIM_EFFECTS b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
public static SkinANIM operator |(SkinANIM a, ANIM_EFFECTS anim) => new SkinANIM(a._ANIM | anim);
|
||||
|
||||
public static implicit operator SkinANIM(ANIM_EFFECTS anim) => new SkinANIM(anim);
|
||||
|
||||
public static bool operator ==(SkinANIM a, ANIM_EFFECTS b) => a._ANIM == b;
|
||||
|
||||
public static bool operator !=(SkinANIM a, ANIM_EFFECTS b) => !(a == b);
|
||||
|
||||
public override bool Equals(object obj) => obj is SkinANIM a && a == _ANIM;
|
||||
|
||||
public override int GetHashCode() => (int)_ANIM;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the desired flag in the bitfield
|
||||
/// </summary>
|
||||
/// <param name="flag">ANIM Flag to set</param>
|
||||
/// <param name="state">Wether to enable the flag</param>
|
||||
public void SetANIMFlag(eANIM_EFFECTS flag, bool state)
|
||||
/// <param name="state">State of the flag</param>
|
||||
public void SetFlag(ANIM_EFFECTS flag, bool state)
|
||||
{
|
||||
if (state) _ANIM |= flag;
|
||||
else _ANIM &= ~flag;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the desired flag is set in the bitfield, otherwise false
|
||||
/// Gets a desired flags state
|
||||
/// </summary>
|
||||
/// <param name="flag">ANIM Flag to check</param>
|
||||
/// <returns>Bool wether its set or not</returns>
|
||||
public bool GetANIMFlag(eANIM_EFFECTS flag)
|
||||
/// <param name="flag">Flag to check</param>
|
||||
/// <returns>True if flag is set, otherwise false</returns>
|
||||
public bool GetFlag(ANIM_EFFECTS flag)
|
||||
{
|
||||
return (_ANIM & flag) != 0;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is SkinANIM a && _ANIM == a._ANIM;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (int)_ANIM;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
namespace PckStudio.Classes.Utils.grf
|
||||
{
|
||||
public class CRC32
|
||||
{
|
||||
static readonly private byte[] offsets =
|
||||
{
|
||||
0x05, 0x06, 0x07, 0x03,
|
||||
0x04, 0x05, 0x06, 0x07,
|
||||
0x01, 0x02, 0x06, 0x01,
|
||||
0x01, 0x02, 0x03, 0x04,
|
||||
0x05, 0x05, 0x06, 0x07,
|
||||
0x03, 0x04, 0x05, 0x06,
|
||||
0x07, 0x01, 0x02, 0x06,
|
||||
0x01, 0x01, 0x02, 0x03,
|
||||
0x04, 0x05, 0x05, 0x06,
|
||||
0x07, 0x03, 0x04, 0x05,
|
||||
0x06, 0x07, 0x07, 0x05,
|
||||
0x04, 0x07, 0x05, 0x04,
|
||||
0x07, 0x05, 0x04, 0x07,
|
||||
0x06, 0x05, 0x04, 0x03,
|
||||
};
|
||||
|
||||
static private uint[] CRCTable;
|
||||
static private bool hasCRCTable = false;
|
||||
|
||||
static void MakeCRCTable()
|
||||
{
|
||||
const uint val = 0xedb88320;
|
||||
CRCTable = new uint[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
uint temp = (uint)i;
|
||||
|
||||
for (int j = 0; j < 8; j++)
|
||||
{
|
||||
if ((temp & 1) == 1)
|
||||
{
|
||||
temp >>= 1;
|
||||
temp ^= val;
|
||||
}
|
||||
else { temp >>= 1; }
|
||||
}
|
||||
CRCTable[i] = temp;
|
||||
}
|
||||
hasCRCTable = true;
|
||||
}
|
||||
public static uint UpdateCRC(uint _crc, byte[] data)
|
||||
{
|
||||
uint crc = _crc;
|
||||
if (!hasCRCTable)
|
||||
MakeCRCTable();
|
||||
long pos = 0;
|
||||
long offset = 0;
|
||||
do
|
||||
{
|
||||
var value = data[pos];
|
||||
pos += offsets[offset];
|
||||
crc = CRCTable[(crc ^ value) & 0xff] ^ crc >> 8;
|
||||
offset = offset + 1U + ((offset + 1U >> 3) / 7) * -0x38;
|
||||
} while (pos < data.Length);
|
||||
return crc;
|
||||
}
|
||||
|
||||
public static uint CRC(byte[] data)
|
||||
{
|
||||
return ~UpdateCRC(0xffffffff, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,785 +0,0 @@
|
||||
#region HEADER
|
||||
/* This file was derived from libmspack
|
||||
* (C) 2003-2004 Stuart Caie.
|
||||
* (C) 2011 Ali Scissons.
|
||||
*
|
||||
* The LZX method was created by Jonathan Forbes and Tomi Poutanen, adapted
|
||||
* by Microsoft Corporation.
|
||||
*
|
||||
* This source file is Dual licensed; meaning the end-user of this source file
|
||||
* may redistribute/modify it under the LGPL 2.1 or MS-PL licenses.
|
||||
*/
|
||||
#region LGPL License
|
||||
/* GNU LESSER GENERAL PUBLIC LICENSE version 2.1
|
||||
* LzxDecoder is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General Public License (LGPL) version 2.1
|
||||
*/
|
||||
#endregion
|
||||
#region MS-PL License
|
||||
/*
|
||||
* MICROSOFT PUBLIC LICENSE
|
||||
* This source code is subject to the terms of the Microsoft Public License (Ms-PL).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* is permitted provided that redistributions of the source code retain the above
|
||||
* copyright notices and this file header.
|
||||
*
|
||||
* Additional copyright notices should be appended to the list above.
|
||||
*
|
||||
* For details, see <http://www.opensource.org/licenses/ms-pl.html>.
|
||||
*/
|
||||
#endregion
|
||||
/*
|
||||
* This derived work is recognized by Stuart Caie and is authorized to adapt
|
||||
* any changes made to lzxd.c in his libmspack library and will still retain
|
||||
* this dual licensing scheme. Big thanks to Stuart Caie!
|
||||
*
|
||||
* DETAILS
|
||||
* This file is a pure C# port of the lzxd.c file from libmspack, with minor
|
||||
* changes towards the decompression of XNB files. The original decompression
|
||||
* software of LZX encoded data was written by Suart Caie in his
|
||||
* libmspack/cabextract projects, which can be located at
|
||||
* http://http://www.cabextract.org.uk/
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Microsoft.Xna.Framework.Content
|
||||
{
|
||||
using System.IO;
|
||||
|
||||
class LzxDecoder
|
||||
{
|
||||
public static uint[] position_base = null;
|
||||
public static byte[] extra_bits = null;
|
||||
|
||||
private LzxState m_state;
|
||||
|
||||
public LzxDecoder(int window)
|
||||
{
|
||||
uint wndsize = (uint)(1 << window);
|
||||
int posn_slots;
|
||||
|
||||
// setup proper exception
|
||||
if (window < 15 || window > 21) throw new UnsupportedWindowSizeRange();
|
||||
|
||||
// let's initialise our state
|
||||
m_state = new LzxState();
|
||||
m_state.actual_size = 0;
|
||||
m_state.window = new byte[wndsize];
|
||||
for (int i = 0; i < wndsize; i++) m_state.window[i] = 0xDC;
|
||||
m_state.actual_size = wndsize;
|
||||
m_state.window_size = wndsize;
|
||||
m_state.window_posn = 0;
|
||||
|
||||
/* initialize static tables */
|
||||
if (extra_bits == null)
|
||||
{
|
||||
extra_bits = new byte[52];
|
||||
for (int i = 0, j = 0; i <= 50; i += 2)
|
||||
{
|
||||
extra_bits[i] = extra_bits[i + 1] = (byte)j;
|
||||
if ((i != 0) && (j < 17)) j++;
|
||||
}
|
||||
}
|
||||
if (position_base == null)
|
||||
{
|
||||
position_base = new uint[51];
|
||||
for (int i = 0, j = 0; i <= 50; i++)
|
||||
{
|
||||
position_base[i] = (uint)j;
|
||||
j += 1 << extra_bits[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* calculate required position slots */
|
||||
if (window == 20) posn_slots = 42;
|
||||
else if (window == 21) posn_slots = 50;
|
||||
else posn_slots = window << 1;
|
||||
|
||||
m_state.R0 = m_state.R1 = m_state.R2 = 1;
|
||||
m_state.main_elements = (ushort)(LzxConstants.NUM_CHARS + (posn_slots << 3));
|
||||
m_state.header_read = 0;
|
||||
m_state.frames_read = 0;
|
||||
m_state.block_remaining = 0;
|
||||
m_state.block_type = LzxConstants.BLOCKTYPE.INVALID;
|
||||
m_state.intel_curpos = 0;
|
||||
m_state.intel_started = 0;
|
||||
|
||||
// yo dawg i herd u liek arrays so we put arrays in ur arrays so u can array while u array
|
||||
m_state.PRETREE_table = new ushort[(1 << LzxConstants.PRETREE_TABLEBITS) + (LzxConstants.PRETREE_MAXSYMBOLS << 1)];
|
||||
m_state.PRETREE_len = new byte[LzxConstants.PRETREE_MAXSYMBOLS + LzxConstants.LENTABLE_SAFETY];
|
||||
m_state.MAINTREE_table = new ushort[(1 << LzxConstants.MAINTREE_TABLEBITS) + (LzxConstants.MAINTREE_MAXSYMBOLS << 1)];
|
||||
m_state.MAINTREE_len = new byte[LzxConstants.MAINTREE_MAXSYMBOLS + LzxConstants.LENTABLE_SAFETY];
|
||||
m_state.LENGTH_table = new ushort[(1 << LzxConstants.LENGTH_TABLEBITS) + (LzxConstants.LENGTH_MAXSYMBOLS << 1)];
|
||||
m_state.LENGTH_len = new byte[LzxConstants.LENGTH_MAXSYMBOLS + LzxConstants.LENTABLE_SAFETY];
|
||||
m_state.ALIGNED_table = new ushort[(1 << LzxConstants.ALIGNED_TABLEBITS) + (LzxConstants.ALIGNED_MAXSYMBOLS << 1)];
|
||||
m_state.ALIGNED_len = new byte[LzxConstants.ALIGNED_MAXSYMBOLS + LzxConstants.LENTABLE_SAFETY];
|
||||
/* initialise tables to 0 (because deltas will be applied to them) */
|
||||
for (int i = 0; i < LzxConstants.MAINTREE_MAXSYMBOLS; i++) m_state.MAINTREE_len[i] = 0;
|
||||
for (int i = 0; i < LzxConstants.LENGTH_MAXSYMBOLS; i++) m_state.LENGTH_len[i] = 0;
|
||||
}
|
||||
|
||||
public int Decompress(Stream inData, int inLen, Stream outData, int outLen)
|
||||
{
|
||||
BitBuffer bitbuf = new BitBuffer(inData);
|
||||
long startpos = inData.Position;
|
||||
long endpos = inData.Position + inLen;
|
||||
|
||||
byte[] window = m_state.window;
|
||||
|
||||
uint window_posn = m_state.window_posn;
|
||||
uint window_size = m_state.window_size;
|
||||
uint R0 = m_state.R0;
|
||||
uint R1 = m_state.R1;
|
||||
uint R2 = m_state.R2;
|
||||
uint i, j;
|
||||
|
||||
int togo = outLen, this_run, main_element, match_length, match_offset, length_footer, extra, verbatim_bits;
|
||||
int rundest, runsrc, copy_length, aligned_bits;
|
||||
|
||||
bitbuf.InitBitStream();
|
||||
|
||||
/* read header if necessary */
|
||||
if (m_state.header_read == 0)
|
||||
{
|
||||
uint intel = bitbuf.ReadBits(1);
|
||||
if (intel != 0)
|
||||
{
|
||||
// read the filesize
|
||||
i = bitbuf.ReadBits(16); j = bitbuf.ReadBits(16);
|
||||
m_state.intel_filesize = (int)((i << 16) | j);
|
||||
}
|
||||
m_state.header_read = 1;
|
||||
}
|
||||
|
||||
/* main decoding loop */
|
||||
while (togo > 0)
|
||||
{
|
||||
/* last block finished, new block expected */
|
||||
if (m_state.block_remaining == 0)
|
||||
{
|
||||
// TODO may screw something up here
|
||||
if (m_state.block_type == LzxConstants.BLOCKTYPE.UNCOMPRESSED)
|
||||
{
|
||||
if ((m_state.block_length & 1) == 1) inData.ReadByte(); /* realign bitstream to word */
|
||||
bitbuf.InitBitStream();
|
||||
}
|
||||
|
||||
m_state.block_type = (LzxConstants.BLOCKTYPE)bitbuf.ReadBits(3); ;
|
||||
i = bitbuf.ReadBits(16);
|
||||
j = bitbuf.ReadBits(8);
|
||||
m_state.block_remaining = m_state.block_length = (uint)((i << 8) | j);
|
||||
|
||||
switch (m_state.block_type)
|
||||
{
|
||||
case LzxConstants.BLOCKTYPE.ALIGNED:
|
||||
for (i = 0, j = 0; i < 8; i++) { j = bitbuf.ReadBits(3); m_state.ALIGNED_len[i] = (byte)j; }
|
||||
MakeDecodeTable(LzxConstants.ALIGNED_MAXSYMBOLS, LzxConstants.ALIGNED_TABLEBITS,
|
||||
m_state.ALIGNED_len, m_state.ALIGNED_table);
|
||||
/* rest of aligned header is same as verbatim */
|
||||
goto case LzxConstants.BLOCKTYPE.VERBATIM;
|
||||
|
||||
case LzxConstants.BLOCKTYPE.VERBATIM:
|
||||
ReadLengths(m_state.MAINTREE_len, 0, 256, bitbuf);
|
||||
ReadLengths(m_state.MAINTREE_len, 256, m_state.main_elements, bitbuf);
|
||||
MakeDecodeTable(LzxConstants.MAINTREE_MAXSYMBOLS, LzxConstants.MAINTREE_TABLEBITS,
|
||||
m_state.MAINTREE_len, m_state.MAINTREE_table);
|
||||
if (m_state.MAINTREE_len[0xE8] != 0) m_state.intel_started = 1;
|
||||
|
||||
ReadLengths(m_state.LENGTH_len, 0, LzxConstants.NUM_SECONDARY_LENGTHS, bitbuf);
|
||||
MakeDecodeTable(LzxConstants.LENGTH_MAXSYMBOLS, LzxConstants.LENGTH_TABLEBITS,
|
||||
m_state.LENGTH_len, m_state.LENGTH_table);
|
||||
break;
|
||||
|
||||
case LzxConstants.BLOCKTYPE.UNCOMPRESSED:
|
||||
m_state.intel_started = 1; /* because we can't assume otherwise */
|
||||
bitbuf.EnsureBits(16); /* get up to 16 pad bits into the buffer */
|
||||
if (bitbuf.GetBitsLeft() > 16) inData.Seek(-2, SeekOrigin.Current); /* and align the bitstream! */
|
||||
byte hi, mh, ml, lo;
|
||||
lo = (byte)inData.ReadByte(); ml = (byte)inData.ReadByte(); mh = (byte)inData.ReadByte(); hi = (byte)inData.ReadByte();
|
||||
R0 = (uint)(lo | ml << 8 | mh << 16 | hi << 24);
|
||||
lo = (byte)inData.ReadByte(); ml = (byte)inData.ReadByte(); mh = (byte)inData.ReadByte(); hi = (byte)inData.ReadByte();
|
||||
R1 = (uint)(lo | ml << 8 | mh << 16 | hi << 24);
|
||||
lo = (byte)inData.ReadByte(); ml = (byte)inData.ReadByte(); mh = (byte)inData.ReadByte(); hi = (byte)inData.ReadByte();
|
||||
R2 = (uint)(lo | ml << 8 | mh << 16 | hi << 24);
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1; // TODO throw proper exception
|
||||
}
|
||||
}
|
||||
|
||||
/* buffer exhaustion check */
|
||||
if (inData.Position > (startpos + inLen))
|
||||
{
|
||||
/* it's possible to have a file where the next run is less than
|
||||
* 16 bits in size. In this case, the READ_HUFFSYM() macro used
|
||||
* in building the tables will exhaust the buffer, so we should
|
||||
* allow for this, but not allow those accidentally read bits to
|
||||
* be used (so we check that there are at least 16 bits
|
||||
* remaining - in this boundary case they aren't really part of
|
||||
* the compressed data)
|
||||
*/
|
||||
//Debug.WriteLine("WTF");
|
||||
|
||||
if (inData.Position > (startpos + inLen + 2) || bitbuf.GetBitsLeft() < 16) return -1; //TODO throw proper exception
|
||||
}
|
||||
|
||||
while ((this_run = (int)m_state.block_remaining) > 0 && togo > 0)
|
||||
{
|
||||
if (this_run > togo) this_run = togo;
|
||||
togo -= this_run;
|
||||
m_state.block_remaining -= (uint)this_run;
|
||||
|
||||
/* apply 2^x-1 mask */
|
||||
window_posn &= window_size - 1;
|
||||
/* runs can't straddle the window wraparound */
|
||||
if ((window_posn + this_run) > window_size)
|
||||
return -1; //TODO throw proper exception
|
||||
|
||||
switch (m_state.block_type)
|
||||
{
|
||||
case LzxConstants.BLOCKTYPE.VERBATIM:
|
||||
while (this_run > 0)
|
||||
{
|
||||
main_element = (int)ReadHuffSym(m_state.MAINTREE_table, m_state.MAINTREE_len,
|
||||
LzxConstants.MAINTREE_MAXSYMBOLS, LzxConstants.MAINTREE_TABLEBITS,
|
||||
bitbuf);
|
||||
if (main_element < LzxConstants.NUM_CHARS)
|
||||
{
|
||||
/* literal: 0 to NUM_CHARS-1 */
|
||||
window[window_posn++] = (byte)main_element;
|
||||
this_run--;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* match: NUM_CHARS + ((slot<<3) | length_header (3 bits)) */
|
||||
main_element -= LzxConstants.NUM_CHARS;
|
||||
|
||||
match_length = main_element & LzxConstants.NUM_PRIMARY_LENGTHS;
|
||||
if (match_length == LzxConstants.NUM_PRIMARY_LENGTHS)
|
||||
{
|
||||
length_footer = (int)ReadHuffSym(m_state.LENGTH_table, m_state.LENGTH_len,
|
||||
LzxConstants.LENGTH_MAXSYMBOLS, LzxConstants.LENGTH_TABLEBITS,
|
||||
bitbuf);
|
||||
match_length += length_footer;
|
||||
}
|
||||
match_length += LzxConstants.MIN_MATCH;
|
||||
|
||||
match_offset = main_element >> 3;
|
||||
|
||||
if (match_offset > 2)
|
||||
{
|
||||
/* not repeated offset */
|
||||
if (match_offset != 3)
|
||||
{
|
||||
extra = extra_bits[match_offset];
|
||||
verbatim_bits = (int)bitbuf.ReadBits((byte)extra);
|
||||
match_offset = (int)position_base[match_offset] - 2 + verbatim_bits;
|
||||
}
|
||||
else
|
||||
{
|
||||
match_offset = 1;
|
||||
}
|
||||
|
||||
/* update repeated offset LRU queue */
|
||||
R2 = R1; R1 = R0; R0 = (uint)match_offset;
|
||||
}
|
||||
else if (match_offset == 0)
|
||||
{
|
||||
match_offset = (int)R0;
|
||||
}
|
||||
else if (match_offset == 1)
|
||||
{
|
||||
match_offset = (int)R1;
|
||||
R1 = R0; R0 = (uint)match_offset;
|
||||
}
|
||||
else /* match_offset == 2 */
|
||||
{
|
||||
match_offset = (int)R2;
|
||||
R2 = R0; R0 = (uint)match_offset;
|
||||
}
|
||||
|
||||
rundest = (int)window_posn;
|
||||
this_run -= match_length;
|
||||
|
||||
/* copy any wrapped around source data */
|
||||
if (window_posn >= match_offset)
|
||||
{
|
||||
/* no wrap */
|
||||
runsrc = rundest - match_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
runsrc = rundest + ((int)window_size - match_offset);
|
||||
copy_length = match_offset - (int)window_posn;
|
||||
if (copy_length < match_length)
|
||||
{
|
||||
match_length -= copy_length;
|
||||
window_posn += (uint)copy_length;
|
||||
while (copy_length-- > 0) window[rundest++] = window[runsrc++];
|
||||
runsrc = 0;
|
||||
}
|
||||
}
|
||||
window_posn += (uint)match_length;
|
||||
|
||||
/* copy match data - no worries about destination wraps */
|
||||
while (match_length-- > 0) window[rundest++] = window[runsrc++];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LzxConstants.BLOCKTYPE.ALIGNED:
|
||||
while (this_run > 0)
|
||||
{
|
||||
main_element = (int)ReadHuffSym(m_state.MAINTREE_table, m_state.MAINTREE_len,
|
||||
LzxConstants.MAINTREE_MAXSYMBOLS, LzxConstants.MAINTREE_TABLEBITS,
|
||||
bitbuf);
|
||||
|
||||
if (main_element < LzxConstants.NUM_CHARS)
|
||||
{
|
||||
/* literal 0 to NUM_CHARS-1 */
|
||||
window[window_posn++] = (byte)main_element;
|
||||
this_run--;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* match: NUM_CHARS + ((slot<<3) | length_header (3 bits)) */
|
||||
main_element -= LzxConstants.NUM_CHARS;
|
||||
|
||||
match_length = main_element & LzxConstants.NUM_PRIMARY_LENGTHS;
|
||||
if (match_length == LzxConstants.NUM_PRIMARY_LENGTHS)
|
||||
{
|
||||
length_footer = (int)ReadHuffSym(m_state.LENGTH_table, m_state.LENGTH_len,
|
||||
LzxConstants.LENGTH_MAXSYMBOLS, LzxConstants.LENGTH_TABLEBITS,
|
||||
bitbuf);
|
||||
match_length += length_footer;
|
||||
}
|
||||
match_length += LzxConstants.MIN_MATCH;
|
||||
|
||||
match_offset = main_element >> 3;
|
||||
|
||||
if (match_offset > 2)
|
||||
{
|
||||
/* not repeated offset */
|
||||
extra = extra_bits[match_offset];
|
||||
match_offset = (int)position_base[match_offset] - 2;
|
||||
if (extra > 3)
|
||||
{
|
||||
/* verbatim and aligned bits */
|
||||
extra -= 3;
|
||||
verbatim_bits = (int)bitbuf.ReadBits((byte)extra);
|
||||
match_offset += (verbatim_bits << 3);
|
||||
aligned_bits = (int)ReadHuffSym(m_state.ALIGNED_table, m_state.ALIGNED_len,
|
||||
LzxConstants.ALIGNED_MAXSYMBOLS, LzxConstants.ALIGNED_TABLEBITS,
|
||||
bitbuf);
|
||||
match_offset += aligned_bits;
|
||||
}
|
||||
else if (extra == 3)
|
||||
{
|
||||
/* aligned bits only */
|
||||
aligned_bits = (int)ReadHuffSym(m_state.ALIGNED_table, m_state.ALIGNED_len,
|
||||
LzxConstants.ALIGNED_MAXSYMBOLS, LzxConstants.ALIGNED_TABLEBITS,
|
||||
bitbuf);
|
||||
match_offset += aligned_bits;
|
||||
}
|
||||
else if (extra > 0) /* extra==1, extra==2 */
|
||||
{
|
||||
/* verbatim bits only */
|
||||
verbatim_bits = (int)bitbuf.ReadBits((byte)extra);
|
||||
match_offset += verbatim_bits;
|
||||
}
|
||||
else /* extra == 0 */
|
||||
{
|
||||
/* ??? */
|
||||
match_offset = 1;
|
||||
}
|
||||
|
||||
/* update repeated offset LRU queue */
|
||||
R2 = R1; R1 = R0; R0 = (uint)match_offset;
|
||||
}
|
||||
else if (match_offset == 0)
|
||||
{
|
||||
match_offset = (int)R0;
|
||||
}
|
||||
else if (match_offset == 1)
|
||||
{
|
||||
match_offset = (int)R1;
|
||||
R1 = R0; R0 = (uint)match_offset;
|
||||
}
|
||||
else /* match_offset == 2 */
|
||||
{
|
||||
match_offset = (int)R2;
|
||||
R2 = R0; R0 = (uint)match_offset;
|
||||
}
|
||||
|
||||
rundest = (int)window_posn;
|
||||
this_run -= match_length;
|
||||
|
||||
/* copy any wrapped around source data */
|
||||
if (window_posn >= match_offset)
|
||||
{
|
||||
/* no wrap */
|
||||
runsrc = rundest - match_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
runsrc = rundest + ((int)window_size - match_offset);
|
||||
copy_length = match_offset - (int)window_posn;
|
||||
if (copy_length < match_length)
|
||||
{
|
||||
match_length -= copy_length;
|
||||
window_posn += (uint)copy_length;
|
||||
while (copy_length-- > 0) window[rundest++] = window[runsrc++];
|
||||
runsrc = 0;
|
||||
}
|
||||
}
|
||||
window_posn += (uint)match_length;
|
||||
|
||||
/* copy match data - no worries about destination wraps */
|
||||
while (match_length-- > 0) window[rundest++] = window[runsrc++];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LzxConstants.BLOCKTYPE.UNCOMPRESSED:
|
||||
if ((inData.Position + this_run) > endpos) return -1; //TODO throw proper exception
|
||||
byte[] temp_buffer = new byte[this_run];
|
||||
inData.Read(temp_buffer, 0, this_run);
|
||||
temp_buffer.CopyTo(window, (int)window_posn);
|
||||
window_posn += (uint)this_run;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1; //TODO throw proper exception
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (togo != 0) return -1; //TODO throw proper exception
|
||||
int start_window_pos = (int)window_posn;
|
||||
if (start_window_pos == 0) start_window_pos = (int)window_size;
|
||||
start_window_pos -= outLen;
|
||||
outData.Write(window, start_window_pos, outLen);
|
||||
|
||||
m_state.window_posn = window_posn;
|
||||
m_state.R0 = R0;
|
||||
m_state.R1 = R1;
|
||||
m_state.R2 = R2;
|
||||
|
||||
// TODO finish intel E8 decoding
|
||||
/* intel E8 decoding */
|
||||
if ((m_state.frames_read++ < 32768) && m_state.intel_filesize != 0)
|
||||
{
|
||||
if (outLen <= 6 || m_state.intel_started == 0)
|
||||
{
|
||||
m_state.intel_curpos += outLen;
|
||||
}
|
||||
else
|
||||
{
|
||||
int dataend = outLen - 10;
|
||||
uint curpos = (uint)m_state.intel_curpos;
|
||||
|
||||
m_state.intel_curpos = (int)curpos + outLen;
|
||||
|
||||
while (outData.Position < dataend)
|
||||
{
|
||||
if (outData.ReadByte() != 0xE8) { curpos++; continue; }
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// READ_LENGTHS(table, first, last)
|
||||
// if(lzx_read_lens(LENTABLE(table), first, last, bitsleft))
|
||||
// return ERROR (ILLEGAL_DATA)
|
||||
//
|
||||
|
||||
// TODO make returns throw exceptions
|
||||
private int MakeDecodeTable(uint nsyms, uint nbits, byte[] length, ushort[] table)
|
||||
{
|
||||
ushort sym;
|
||||
uint leaf;
|
||||
byte bit_num = 1;
|
||||
uint fill;
|
||||
uint pos = 0; /* the current position in the decode table */
|
||||
uint table_mask = (uint)(1 << (int)nbits);
|
||||
uint bit_mask = table_mask >> 1; /* don't do 0 length codes */
|
||||
uint next_symbol = bit_mask; /* base of allocation for long codes */
|
||||
|
||||
/* fill entries for codes short enough for a direct mapping */
|
||||
while (bit_num <= nbits)
|
||||
{
|
||||
for (sym = 0; sym < nsyms; sym++)
|
||||
{
|
||||
if (length[sym] == bit_num)
|
||||
{
|
||||
leaf = pos;
|
||||
|
||||
if ((pos += bit_mask) > table_mask) return 1; /* table overrun */
|
||||
|
||||
/* fill all possible lookups of this symbol with the symbol itself */
|
||||
fill = bit_mask;
|
||||
while (fill-- > 0) table[leaf++] = sym;
|
||||
}
|
||||
}
|
||||
bit_mask >>= 1;
|
||||
bit_num++;
|
||||
}
|
||||
|
||||
/* if there are any codes longer than nbits */
|
||||
if (pos != table_mask)
|
||||
{
|
||||
/* clear the remainder of the table */
|
||||
for (sym = (ushort)pos; sym < table_mask; sym++) table[sym] = 0;
|
||||
|
||||
/* give ourselves room for codes to grow by up to 16 more bits */
|
||||
pos <<= 16;
|
||||
table_mask <<= 16;
|
||||
bit_mask = 1 << 15;
|
||||
|
||||
while (bit_num <= 16)
|
||||
{
|
||||
for (sym = 0; sym < nsyms; sym++)
|
||||
{
|
||||
if (length[sym] == bit_num)
|
||||
{
|
||||
leaf = pos >> 16;
|
||||
for (fill = 0; fill < bit_num - nbits; fill++)
|
||||
{
|
||||
/* if this path hasn't been taken yet, 'allocate' two entries */
|
||||
if (table[leaf] == 0)
|
||||
{
|
||||
table[(next_symbol << 1)] = 0;
|
||||
table[(next_symbol << 1) + 1] = 0;
|
||||
table[leaf] = (ushort)(next_symbol++);
|
||||
}
|
||||
/* follow the path and select either left or right for next bit */
|
||||
leaf = (uint)(table[leaf] << 1);
|
||||
if (((pos >> (int)(15 - fill)) & 1) == 1) leaf++;
|
||||
}
|
||||
table[leaf] = sym;
|
||||
|
||||
if ((pos += bit_mask) > table_mask) return 1;
|
||||
}
|
||||
}
|
||||
bit_mask >>= 1;
|
||||
bit_num++;
|
||||
}
|
||||
}
|
||||
|
||||
/* full talbe? */
|
||||
if (pos == table_mask) return 0;
|
||||
|
||||
/* either erroneous table, or all elements are 0 - let's find out. */
|
||||
for (sym = 0; sym < nsyms; sym++) if (length[sym] != 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO throw exceptions instead of returns
|
||||
private void ReadLengths(byte[] lens, uint first, uint last, BitBuffer bitbuf)
|
||||
{
|
||||
uint x, y;
|
||||
int z;
|
||||
|
||||
// hufftbl pointer here?
|
||||
|
||||
for (x = 0; x < 20; x++)
|
||||
{
|
||||
y = bitbuf.ReadBits(4);
|
||||
m_state.PRETREE_len[x] = (byte)y;
|
||||
}
|
||||
MakeDecodeTable(LzxConstants.PRETREE_MAXSYMBOLS, LzxConstants.PRETREE_TABLEBITS,
|
||||
m_state.PRETREE_len, m_state.PRETREE_table);
|
||||
|
||||
for (x = first; x < last;)
|
||||
{
|
||||
z = (int)ReadHuffSym(m_state.PRETREE_table, m_state.PRETREE_len,
|
||||
LzxConstants.PRETREE_MAXSYMBOLS, LzxConstants.PRETREE_TABLEBITS, bitbuf);
|
||||
if (z == 17)
|
||||
{
|
||||
y = bitbuf.ReadBits(4); y += 4;
|
||||
while (y-- != 0) lens[x++] = 0;
|
||||
}
|
||||
else if (z == 18)
|
||||
{
|
||||
y = bitbuf.ReadBits(5); y += 20;
|
||||
while (y-- != 0) lens[x++] = 0;
|
||||
}
|
||||
else if (z == 19)
|
||||
{
|
||||
y = bitbuf.ReadBits(1); y += 4;
|
||||
z = (int)ReadHuffSym(m_state.PRETREE_table, m_state.PRETREE_len,
|
||||
LzxConstants.PRETREE_MAXSYMBOLS, LzxConstants.PRETREE_TABLEBITS, bitbuf);
|
||||
z = lens[x] - z; if (z < 0) z += 17;
|
||||
while (y-- != 0) lens[x++] = (byte)z;
|
||||
}
|
||||
else
|
||||
{
|
||||
z = lens[x] - z; if (z < 0) z += 17;
|
||||
lens[x++] = (byte)z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private uint ReadHuffSym(ushort[] table, byte[] lengths, uint nsyms, uint nbits, BitBuffer bitbuf)
|
||||
{
|
||||
uint i, j;
|
||||
bitbuf.EnsureBits(16);
|
||||
if ((i = table[bitbuf.PeekBits((byte)nbits)]) >= nsyms)
|
||||
{
|
||||
j = (uint)(1 << (int)((sizeof(uint) * 8) - nbits));
|
||||
do
|
||||
{
|
||||
j >>= 1; i <<= 1; i |= (bitbuf.GetBuffer() & j) != 0 ? (uint)1 : 0;
|
||||
if (j == 0) return 0; // TODO throw proper exception
|
||||
} while ((i = table[i]) >= nsyms);
|
||||
}
|
||||
j = lengths[i];
|
||||
bitbuf.RemoveBits((byte)j);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
#region Our BitBuffer Class
|
||||
private class BitBuffer
|
||||
{
|
||||
uint buffer;
|
||||
byte bitsleft;
|
||||
Stream byteStream;
|
||||
|
||||
public BitBuffer(Stream stream)
|
||||
{
|
||||
byteStream = stream;
|
||||
InitBitStream();
|
||||
}
|
||||
|
||||
public void InitBitStream()
|
||||
{
|
||||
buffer = 0;
|
||||
bitsleft = 0;
|
||||
}
|
||||
|
||||
public void EnsureBits(byte bits)
|
||||
{
|
||||
while (bitsleft < bits)
|
||||
{
|
||||
int lo = (byte)byteStream.ReadByte();
|
||||
int hi = (byte)byteStream.ReadByte();
|
||||
//int amount2shift = sizeof(uint)*8 - 16 - bitsleft;
|
||||
buffer |= (uint)(((hi << 8) | lo) << (sizeof(uint) * 8 - 16 - bitsleft));
|
||||
bitsleft += 16;
|
||||
}
|
||||
}
|
||||
|
||||
public uint PeekBits(byte bits)
|
||||
{
|
||||
return (buffer >> ((sizeof(uint) * 8) - bits));
|
||||
}
|
||||
|
||||
public void RemoveBits(byte bits)
|
||||
{
|
||||
buffer <<= bits;
|
||||
bitsleft -= bits;
|
||||
}
|
||||
|
||||
public uint ReadBits(byte bits)
|
||||
{
|
||||
uint ret = 0;
|
||||
|
||||
if (bits > 0)
|
||||
{
|
||||
EnsureBits(bits);
|
||||
ret = PeekBits(bits);
|
||||
RemoveBits(bits);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public uint GetBuffer()
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public byte GetBitsLeft()
|
||||
{
|
||||
return bitsleft;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
struct LzxState
|
||||
{
|
||||
public uint R0, R1, R2; /* for the LRU offset system */
|
||||
public ushort main_elements; /* number of main tree elements */
|
||||
public int header_read; /* have we started decoding at all yet? */
|
||||
public LzxConstants.BLOCKTYPE block_type; /* type of this block */
|
||||
public uint block_length; /* uncompressed length of this block */
|
||||
public uint block_remaining; /* uncompressed bytes still left to decode */
|
||||
public uint frames_read; /* the number of CFDATA blocks processed */
|
||||
public int intel_filesize; /* magic header value used for transform */
|
||||
public int intel_curpos; /* current offset in transform space */
|
||||
public int intel_started; /* have we seen any translateable data yet? */
|
||||
|
||||
public ushort[] PRETREE_table;
|
||||
public byte[] PRETREE_len;
|
||||
public ushort[] MAINTREE_table;
|
||||
public byte[] MAINTREE_len;
|
||||
public ushort[] LENGTH_table;
|
||||
public byte[] LENGTH_len;
|
||||
public ushort[] ALIGNED_table;
|
||||
public byte[] ALIGNED_len;
|
||||
|
||||
// NEEDED MEMBERS
|
||||
// CAB actualsize
|
||||
// CAB window
|
||||
// CAB window_size
|
||||
// CAB window_posn
|
||||
public uint actual_size;
|
||||
public byte[] window;
|
||||
public uint window_size;
|
||||
public uint window_posn;
|
||||
}
|
||||
}
|
||||
|
||||
/* CONSTANTS */
|
||||
struct LzxConstants
|
||||
{
|
||||
public const ushort MIN_MATCH = 2;
|
||||
public const ushort MAX_MATCH = 257;
|
||||
public const ushort NUM_CHARS = 256;
|
||||
public enum BLOCKTYPE
|
||||
{
|
||||
INVALID = 0,
|
||||
VERBATIM = 1,
|
||||
ALIGNED = 2,
|
||||
UNCOMPRESSED = 3
|
||||
}
|
||||
public const ushort PRETREE_NUM_ELEMENTS = 20;
|
||||
public const ushort ALIGNED_NUM_ELEMENTS = 8;
|
||||
public const ushort NUM_PRIMARY_LENGTHS = 7;
|
||||
public const ushort NUM_SECONDARY_LENGTHS = 249;
|
||||
|
||||
public const ushort PRETREE_MAXSYMBOLS = PRETREE_NUM_ELEMENTS;
|
||||
public const ushort PRETREE_TABLEBITS = 6;
|
||||
public const ushort MAINTREE_MAXSYMBOLS = NUM_CHARS + 50 * 8;
|
||||
public const ushort MAINTREE_TABLEBITS = 12;
|
||||
public const ushort LENGTH_MAXSYMBOLS = NUM_SECONDARY_LENGTHS + 1;
|
||||
public const ushort LENGTH_TABLEBITS = 12;
|
||||
public const ushort ALIGNED_MAXSYMBOLS = ALIGNED_NUM_ELEMENTS;
|
||||
public const ushort ALIGNED_TABLEBITS = 7;
|
||||
|
||||
public const ushort LENTABLE_SAFETY = 64;
|
||||
}
|
||||
|
||||
/* EXCEPTIONS */
|
||||
class UnsupportedWindowSizeRange : Exception
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
|
||||
namespace MonoGame.Framework.Utilities
|
||||
{
|
||||
internal class LzxDecoderStream : Stream
|
||||
{
|
||||
LzxDecoder dec;
|
||||
MemoryStream decompressedStream;
|
||||
|
||||
public LzxDecoderStream(Stream input, int decompressedSize, int compressedSize)
|
||||
{
|
||||
dec = new LzxDecoder(16);
|
||||
|
||||
// TODO: Rewrite using block decompression like Lz4DecoderStream
|
||||
Decompress(input, decompressedSize, compressedSize);
|
||||
}
|
||||
|
||||
// Decompress into MemoryStream
|
||||
private void Decompress(Stream stream, int decompressedSize, int compressedSize)
|
||||
{
|
||||
//thanks to ShinAli (https://bitbucket.org/alisci01/xnbdecompressor)
|
||||
// default window size for XNB encoded files is 64Kb (need 16 bits to represent it)
|
||||
decompressedStream = new MemoryStream(decompressedSize);
|
||||
long startPos = stream.Position;
|
||||
long pos = startPos;
|
||||
|
||||
while (pos - startPos < compressedSize)
|
||||
{
|
||||
// the compressed stream is seperated into blocks that will decompress
|
||||
// into 32Kb or some other size if specified.
|
||||
// normal, 32Kb output blocks will have a short indicating the size
|
||||
// of the block before the block starts
|
||||
// blocks that have a defined output will be preceded by a byte of value
|
||||
// 0xFF (255), then a short indicating the output size and another
|
||||
// for the block size
|
||||
// all shorts for these cases are encoded in big endian order
|
||||
int hi = stream.ReadByte();
|
||||
int lo = stream.ReadByte();
|
||||
int block_size = (hi << 8) | lo;
|
||||
int frame_size = 0x8000; // frame size is 32Kb by default
|
||||
// does this block define a frame size?
|
||||
if (hi == 0xFF)
|
||||
{
|
||||
hi = lo;
|
||||
lo = (byte)stream.ReadByte();
|
||||
frame_size = (hi << 8) | lo;
|
||||
hi = (byte)stream.ReadByte();
|
||||
lo = (byte)stream.ReadByte();
|
||||
block_size = (hi << 8) | lo;
|
||||
pos += 5;
|
||||
}
|
||||
else
|
||||
pos += 2;
|
||||
|
||||
// either says there is nothing to decode
|
||||
if (block_size == 0 || frame_size == 0)
|
||||
break;
|
||||
|
||||
dec.Decompress(stream, block_size, decompressedStream, frame_size);
|
||||
pos += block_size;
|
||||
|
||||
// reset the position of the input just incase the bit buffer
|
||||
// read in some unused bytes
|
||||
stream.Seek(pos, SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
Console.WriteLine(decompressedStream.Position);
|
||||
Console.WriteLine(decompressedSize);
|
||||
//if (decompressedStream.Position != decompressedSize)
|
||||
//{
|
||||
// throw new Exception("Decompression failed.");
|
||||
//}
|
||||
|
||||
decompressedStream.Seek(0, SeekOrigin.Begin);
|
||||
using (var fs = File.OpenWrite("xmem_test.grf"))
|
||||
{
|
||||
decompressedStream.CopyTo(fs);
|
||||
}
|
||||
decompressedStream.Seek(0, SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (disposing)
|
||||
{
|
||||
decompressedStream.Dispose();
|
||||
}
|
||||
dec = null;
|
||||
decompressedStream = null;
|
||||
}
|
||||
|
||||
#region Stream internals
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
return decompressedStream.Read(buffer, offset, count);
|
||||
}
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get { throw new NotSupportedException(); }
|
||||
set { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
145
PCK-Studio/Forms/Additional-Popups/AddFilePrompt.Designer.cs
generated
Normal file
145
PCK-Studio/Forms/Additional-Popups/AddFilePrompt.Designer.cs
generated
Normal file
@@ -0,0 +1,145 @@
|
||||
namespace PckStudio
|
||||
{
|
||||
partial class AddFilePrompt
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddFilePrompt));
|
||||
this.TextLabel = new System.Windows.Forms.Label();
|
||||
this.OKButton = new System.Windows.Forms.Button();
|
||||
this.InputTextBox = new MetroFramework.Controls.MetroTextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.FileTypeComboBox = new MetroFramework.Controls.MetroComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// TextLabel
|
||||
//
|
||||
resources.ApplyResources(this.TextLabel, "TextLabel");
|
||||
this.TextLabel.ForeColor = System.Drawing.Color.White;
|
||||
this.TextLabel.Name = "TextLabel";
|
||||
//
|
||||
// OKButton
|
||||
//
|
||||
resources.ApplyResources(this.OKButton, "OKButton");
|
||||
this.OKButton.ForeColor = System.Drawing.Color.White;
|
||||
this.OKButton.Name = "OKButton";
|
||||
this.OKButton.UseVisualStyleBackColor = true;
|
||||
this.OKButton.Click += new System.EventHandler(this.OKBtn_Click);
|
||||
//
|
||||
// InputTextBox
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.InputTextBox.CustomButton.Image = ((System.Drawing.Image)(resources.GetObject("resource.Image")));
|
||||
this.InputTextBox.CustomButton.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("resource.ImeMode")));
|
||||
this.InputTextBox.CustomButton.Location = ((System.Drawing.Point)(resources.GetObject("resource.Location")));
|
||||
this.InputTextBox.CustomButton.Name = "";
|
||||
this.InputTextBox.CustomButton.Size = ((System.Drawing.Size)(resources.GetObject("resource.Size")));
|
||||
this.InputTextBox.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||
this.InputTextBox.CustomButton.TabIndex = ((int)(resources.GetObject("resource.TabIndex")));
|
||||
this.InputTextBox.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||
this.InputTextBox.CustomButton.UseSelectable = true;
|
||||
this.InputTextBox.CustomButton.Visible = ((bool)(resources.GetObject("resource.Visible")));
|
||||
this.InputTextBox.Lines = new string[0];
|
||||
resources.ApplyResources(this.InputTextBox, "InputTextBox");
|
||||
this.InputTextBox.MaxLength = 255;
|
||||
this.InputTextBox.Name = "InputTextBox";
|
||||
this.InputTextBox.PasswordChar = '\0';
|
||||
this.InputTextBox.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||
this.InputTextBox.SelectedText = "";
|
||||
this.InputTextBox.SelectionLength = 0;
|
||||
this.InputTextBox.SelectionStart = 0;
|
||||
this.InputTextBox.ShortcutsEnabled = true;
|
||||
this.InputTextBox.Style = MetroFramework.MetroColorStyle.White;
|
||||
this.InputTextBox.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.InputTextBox.UseSelectable = true;
|
||||
this.InputTextBox.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||
this.InputTextBox.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
resources.ApplyResources(this.label1, "label1");
|
||||
this.label1.ForeColor = System.Drawing.Color.White;
|
||||
this.label1.Name = "label1";
|
||||
//
|
||||
// FileTypeComboBox
|
||||
//
|
||||
this.FileTypeComboBox.FormattingEnabled = true;
|
||||
resources.ApplyResources(this.FileTypeComboBox, "FileTypeComboBox");
|
||||
this.FileTypeComboBox.Items.AddRange(new object[] {
|
||||
resources.GetString("FileTypeComboBox.Items"),
|
||||
resources.GetString("FileTypeComboBox.Items1"),
|
||||
resources.GetString("FileTypeComboBox.Items2"),
|
||||
resources.GetString("FileTypeComboBox.Items3"),
|
||||
resources.GetString("FileTypeComboBox.Items4"),
|
||||
resources.GetString("FileTypeComboBox.Items5"),
|
||||
resources.GetString("FileTypeComboBox.Items6"),
|
||||
resources.GetString("FileTypeComboBox.Items7"),
|
||||
resources.GetString("FileTypeComboBox.Items8"),
|
||||
resources.GetString("FileTypeComboBox.Items9"),
|
||||
resources.GetString("FileTypeComboBox.Items10"),
|
||||
resources.GetString("FileTypeComboBox.Items11"),
|
||||
resources.GetString("FileTypeComboBox.Items12"),
|
||||
resources.GetString("FileTypeComboBox.Items13"),
|
||||
resources.GetString("FileTypeComboBox.Items14")});
|
||||
this.FileTypeComboBox.Name = "FileTypeComboBox";
|
||||
this.FileTypeComboBox.Style = MetroFramework.MetroColorStyle.Blue;
|
||||
this.FileTypeComboBox.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.FileTypeComboBox.UseSelectable = true;
|
||||
//
|
||||
// AddFilePrompt
|
||||
//
|
||||
this.AcceptButton = this.OKButton;
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.FileTypeComboBox);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.InputTextBox);
|
||||
this.Controls.Add(this.OKButton);
|
||||
this.Controls.Add(this.TextLabel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "AddFilePrompt";
|
||||
this.Resizable = false;
|
||||
this.ShadowType = MetroFramework.Forms.MetroFormShadowType.DropShadow;
|
||||
this.Style = MetroFramework.MetroColorStyle.Silver;
|
||||
this.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
public System.Windows.Forms.Button OKButton;
|
||||
public System.Windows.Forms.Label TextLabel;
|
||||
private MetroFramework.Controls.MetroTextBox InputTextBox;
|
||||
public System.Windows.Forms.Label label1;
|
||||
private MetroFramework.Controls.MetroComboBox FileTypeComboBox;
|
||||
}
|
||||
}
|
||||
37
PCK-Studio/Forms/Additional-Popups/AddFilePrompt.cs
Normal file
37
PCK-Studio/Forms/Additional-Popups/AddFilePrompt.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using MetroFramework.Forms;
|
||||
|
||||
namespace PckStudio
|
||||
{
|
||||
public partial class AddFilePrompt : MetroForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Text entered <c>only access when DialogResult == DialogResult.OK</c>
|
||||
/// </summary>
|
||||
public string filepath => InputTextBox.Text;
|
||||
public int filetype => FileTypeComboBox.SelectedIndex;
|
||||
|
||||
public AddFilePrompt(string InitialText) : this(InitialText, -1)
|
||||
{ }
|
||||
|
||||
public AddFilePrompt(string InitialText, int maxChar)
|
||||
{
|
||||
InitializeComponent();
|
||||
InputTextBox.Text = InitialText;
|
||||
InputTextBox.MaxLength = maxChar < 0 ? short.MaxValue : maxChar;
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
}
|
||||
|
||||
private void OKBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
if(FileTypeComboBox.SelectedIndex > -1) DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void InputTextBox_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
OKBtn_Click(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,21 +117,215 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="TextLabel.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="addToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>100, 22</value>
|
||||
<data name="TextLabel.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>19, 22</value>
|
||||
</data>
|
||||
<data name="addToolStripMenuItem.Text" xml:space="preserve">
|
||||
<value>追加</value>
|
||||
<data name="TextLabel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>29, 13</value>
|
||||
</data>
|
||||
<data name="deleteToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>100, 22</value>
|
||||
<data name="TextLabel.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="deleteToolStripMenuItem.Text" xml:space="preserve">
|
||||
<value>削除</value>
|
||||
<data name="TextLabel.Text" xml:space="preserve">
|
||||
<value>Path</value>
|
||||
</data>
|
||||
<data name="contextMenuStrip1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>101, 48</value>
|
||||
<data name="TextLabel.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
|
||||
<value>MiddleCenter</value>
|
||||
</data>
|
||||
<data name=">>TextLabel.Name" xml:space="preserve">
|
||||
<value>TextLabel</value>
|
||||
</data>
|
||||
<data name=">>TextLabel.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>TextLabel.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>TextLabel.ZOrder" xml:space="preserve">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="OKButton.FlatStyle" type="System.Windows.Forms.FlatStyle, System.Windows.Forms">
|
||||
<value>Flat</value>
|
||||
</data>
|
||||
<data name="OKButton.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>165, 93</value>
|
||||
</data>
|
||||
<data name="OKButton.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>75, 23</value>
|
||||
</data>
|
||||
<data name="OKButton.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="OKButton.Text" xml:space="preserve">
|
||||
<value>Add File</value>
|
||||
</data>
|
||||
<data name=">>OKButton.Name" xml:space="preserve">
|
||||
<value>OKButton</value>
|
||||
</data>
|
||||
<data name=">>OKButton.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>OKButton.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>OKButton.ZOrder" xml:space="preserve">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="resource.Image" type="System.Resources.ResXNullRef, System.Windows.Forms">
|
||||
<value />
|
||||
</data>
|
||||
<data name="resource.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="resource.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>303, 1</value>
|
||||
</data>
|
||||
<data name="resource.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>21, 21</value>
|
||||
</data>
|
||||
<data name="resource.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="resource.Visible" type="System.Boolean, mscorlib">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="InputTextBox.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>60, 17</value>
|
||||
</data>
|
||||
<data name="InputTextBox.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>325, 23</value>
|
||||
</data>
|
||||
<data name="InputTextBox.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name=">>InputTextBox.Name" xml:space="preserve">
|
||||
<value>InputTextBox</value>
|
||||
</data>
|
||||
<data name=">>InputTextBox.Type" xml:space="preserve">
|
||||
<value>MetroFramework.Controls.MetroTextBox, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a</value>
|
||||
</data>
|
||||
<data name=">>InputTextBox.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>InputTextBox.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="label1.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>19, 61</value>
|
||||
</data>
|
||||
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>31, 13</value>
|
||||
</data>
|
||||
<data name="label1.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>6</value>
|
||||
</data>
|
||||
<data name="label1.Text" xml:space="preserve">
|
||||
<value>Type</value>
|
||||
</data>
|
||||
<data name="label1.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
|
||||
<value>MiddleCenter</value>
|
||||
</data>
|
||||
<data name=">>label1.Name" xml:space="preserve">
|
||||
<value>label1</value>
|
||||
</data>
|
||||
<data name=">>label1.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>label1.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>label1.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.ItemHeight" type="System.Int32, mscorlib">
|
||||
<value>23</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Items" xml:space="preserve">
|
||||
<value>SkinFile (*.png)</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Items1" xml:space="preserve">
|
||||
<value>CapeFile (*.png)</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Items2" xml:space="preserve">
|
||||
<value>TextureFile (*.png)</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Items3" xml:space="preserve">
|
||||
<value>UIDataFile (UNUSED)</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Items4" xml:space="preserve">
|
||||
<value>InfoFile (0)</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Items5" xml:space="preserve">
|
||||
<value>TexturePackInfoFile (x<Resolution>Info.pck)</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Items6" xml:space="preserve">
|
||||
<value>LocalisationFile (languages.loc/localisation.loc)</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Items7" xml:space="preserve">
|
||||
<value>GameRulesFile (*.grf)</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Items8" xml:space="preserve">
|
||||
<value>AudioFile (*.pck)</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Items9" xml:space="preserve">
|
||||
<value>ColourTableFile (colours.col)</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Items10" xml:space="preserve">
|
||||
<value>GameRulesHeader (*.grh)</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Items11" xml:space="preserve">
|
||||
<value>SkinDataFile (*.pck)</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Items12" xml:space="preserve">
|
||||
<value>ModelsFile (models.bin)</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Items13" xml:space="preserve">
|
||||
<value>BehavioursFile (behaviours.bin)</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Items14" xml:space="preserve">
|
||||
<value>MaterialFile (entityMaterials.bin)</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>60, 51</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>325, 29</value>
|
||||
</data>
|
||||
<data name="FileTypeComboBox.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>7</value>
|
||||
</data>
|
||||
<data name=">>FileTypeComboBox.Name" xml:space="preserve">
|
||||
<value>FileTypeComboBox</value>
|
||||
</data>
|
||||
<data name=">>FileTypeComboBox.Type" xml:space="preserve">
|
||||
<value>MetroFramework.Controls.MetroComboBox, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a</value>
|
||||
</data>
|
||||
<data name=">>FileTypeComboBox.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>FileTypeComboBox.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
|
||||
<value>6, 13</value>
|
||||
</data>
|
||||
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>405, 124</value>
|
||||
</data>
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
@@ -2353,7 +2547,16 @@
|
||||
vbLH9tge22N7bI/tsT22x/bYHttjC+3/B71iqRn22EDpAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<data name="$this.Text" xml:space="preserve">
|
||||
<value>メタデータベース</value>
|
||||
<data name="$this.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
|
||||
<value>CenterParent</value>
|
||||
</data>
|
||||
<data name=">>$this.Name" xml:space="preserve">
|
||||
<value>AddFilePrompt</value>
|
||||
</data>
|
||||
<data name=">>$this.Type" xml:space="preserve">
|
||||
<value>MetroFramework.Forms.MetroForm, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1,122 +0,0 @@
|
||||
|
||||
namespace PckStudio.Forms
|
||||
{
|
||||
partial class AddPCKPassword
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddPCKPassword));
|
||||
this.textBoxPass = new MetroFramework.Controls.MetroTextBox();
|
||||
this.LockPCKButton = new CBH.Ultimate.Controls.CrEaTiiOn_Ultimate_GradientButton();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxPass
|
||||
//
|
||||
this.textBoxPass.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
|
||||
//
|
||||
//
|
||||
//
|
||||
this.textBoxPass.CustomButton.Image = null;
|
||||
this.textBoxPass.CustomButton.Location = new System.Drawing.Point(226, 2);
|
||||
this.textBoxPass.CustomButton.Name = "";
|
||||
this.textBoxPass.CustomButton.Size = new System.Drawing.Size(15, 15);
|
||||
this.textBoxPass.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||
this.textBoxPass.CustomButton.TabIndex = 1;
|
||||
this.textBoxPass.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||
this.textBoxPass.CustomButton.UseSelectable = true;
|
||||
this.textBoxPass.CustomButton.Visible = false;
|
||||
this.textBoxPass.Lines = new string[0];
|
||||
this.textBoxPass.Location = new System.Drawing.Point(55, 12);
|
||||
this.textBoxPass.MaxLength = 32767;
|
||||
this.textBoxPass.Name = "textBoxPass";
|
||||
this.textBoxPass.PasswordChar = '●';
|
||||
this.textBoxPass.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||
this.textBoxPass.SelectedText = "";
|
||||
this.textBoxPass.SelectionLength = 0;
|
||||
this.textBoxPass.SelectionStart = 0;
|
||||
this.textBoxPass.ShortcutsEnabled = true;
|
||||
this.textBoxPass.Size = new System.Drawing.Size(245, 20);
|
||||
this.textBoxPass.Style = MetroFramework.MetroColorStyle.Silver;
|
||||
this.textBoxPass.TabIndex = 2;
|
||||
this.textBoxPass.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.textBoxPass.UseSelectable = true;
|
||||
this.textBoxPass.UseSystemPasswordChar = true;
|
||||
this.textBoxPass.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||
this.textBoxPass.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||
//
|
||||
// LockPCKButton
|
||||
//
|
||||
this.LockPCKButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(25)))), ((int)(((byte)(25)))));
|
||||
this.LockPCKButton.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(25)))), ((int)(((byte)(25)))));
|
||||
this.LockPCKButton.BorderRadius = 10;
|
||||
this.LockPCKButton.BorderSize = 1;
|
||||
this.LockPCKButton.ClickedColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
|
||||
this.LockPCKButton.FlatAppearance.BorderSize = 0;
|
||||
this.LockPCKButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
|
||||
this.LockPCKButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
|
||||
this.LockPCKButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.LockPCKButton.Font = new System.Drawing.Font("Segoe UI", 12F);
|
||||
this.LockPCKButton.ForeColor = System.Drawing.Color.White;
|
||||
this.LockPCKButton.GradientColorPrimary = System.Drawing.Color.FromArgb(((int)(((byte)(70)))), ((int)(((byte)(70)))), ((int)(((byte)(70)))));
|
||||
this.LockPCKButton.GradientColorSecondary = System.Drawing.Color.FromArgb(((int)(((byte)(70)))), ((int)(((byte)(70)))), ((int)(((byte)(70)))));
|
||||
this.LockPCKButton.HoverOverColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
|
||||
this.LockPCKButton.Image = ((System.Drawing.Image)(resources.GetObject("LockPCKButton.Image")));
|
||||
this.LockPCKButton.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.LockPCKButton.Location = new System.Drawing.Point(117, 38);
|
||||
this.LockPCKButton.Name = "LockPCKButton";
|
||||
this.LockPCKButton.Size = new System.Drawing.Size(120, 40);
|
||||
this.LockPCKButton.TabIndex = 16;
|
||||
this.LockPCKButton.Text = "Lock!";
|
||||
this.LockPCKButton.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
this.LockPCKButton.TextColor = System.Drawing.Color.White;
|
||||
this.LockPCKButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.LockPCKButton.UseVisualStyleBackColor = false;
|
||||
this.LockPCKButton.Click += new System.EventHandler(this.LockPCKButton_Click);
|
||||
//
|
||||
// AddPCKPassword
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
|
||||
this.ClientSize = new System.Drawing.Size(354, 91);
|
||||
this.Controls.Add(this.LockPCKButton);
|
||||
this.Controls.Add(this.textBoxPass);
|
||||
this.Font = new System.Drawing.Font("Segoe UI", 8.25F);
|
||||
this.ForeColor = System.Drawing.Color.White;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Name = "AddPCKPassword";
|
||||
this.Text = "Add Password";
|
||||
this.Load += new System.EventHandler(this.AddPCKPassword_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private MetroFramework.Controls.MetroTextBox textBoxPass;
|
||||
private CBH.Ultimate.Controls.CrEaTiiOn_Ultimate_GradientButton LockPCKButton;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using PckStudio.ToolboxItems;
|
||||
|
||||
namespace PckStudio.Forms
|
||||
{
|
||||
public partial class AddPCKPassword : ThemeForm
|
||||
{
|
||||
public string Password { get; private set; }
|
||||
public AddPCKPassword()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public string MD5(string s)
|
||||
{
|
||||
using (var provider = System.Security.Cryptography.MD5.Create())
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
foreach (byte b in provider.ComputeHash(Encoding.UTF8.GetBytes(s)))
|
||||
builder.Append(b.ToString("x2").ToLower());
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void AddPCKPassword_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void LockPCKButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Password = MD5(textBoxPass.Text);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,118 +0,0 @@
|
||||
namespace PckStudio.Forms.Additional_Popups.Audio
|
||||
{
|
||||
partial class AddCategory
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddCategory));
|
||||
this.CancelButton = new CBH.Ultimate.Controls.CrEaTiiOn_Ultimate_GradientButton();
|
||||
this.AddButton = new CBH.Ultimate.Controls.CrEaTiiOn_Ultimate_GradientButton();
|
||||
this.comboBox1 = new System.Windows.Forms.ComboBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
this.CancelButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(25)))), ((int)(((byte)(25)))));
|
||||
this.CancelButton.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(25)))), ((int)(((byte)(25)))));
|
||||
this.CancelButton.BorderRadius = 10;
|
||||
this.CancelButton.BorderSize = 1;
|
||||
this.CancelButton.ClickedColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
|
||||
this.CancelButton.FlatAppearance.BorderSize = 0;
|
||||
this.CancelButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
|
||||
this.CancelButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(36)))), ((int)(((byte)(38)))));
|
||||
resources.ApplyResources(this.CancelButton, "CancelButton");
|
||||
this.CancelButton.ForeColor = System.Drawing.Color.White;
|
||||
this.CancelButton.GradientColorPrimary = System.Drawing.Color.FromArgb(((int)(((byte)(70)))), ((int)(((byte)(70)))), ((int)(((byte)(70)))));
|
||||
this.CancelButton.GradientColorSecondary = System.Drawing.Color.FromArgb(((int)(((byte)(70)))), ((int)(((byte)(70)))), ((int)(((byte)(70)))));
|
||||
this.CancelButton.HoverOverColor = System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(36)))), ((int)(((byte)(38)))));
|
||||
this.CancelButton.Name = "CancelButton";
|
||||
this.CancelButton.TextColor = System.Drawing.Color.White;
|
||||
this.CancelButton.UseVisualStyleBackColor = false;
|
||||
this.CancelButton.Click += new System.EventHandler(this.CancelButton_Click_1);
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
this.AddButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(25)))), ((int)(((byte)(25)))));
|
||||
this.AddButton.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(25)))), ((int)(((byte)(25)))));
|
||||
this.AddButton.BorderRadius = 10;
|
||||
this.AddButton.BorderSize = 1;
|
||||
this.AddButton.ClickedColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
|
||||
this.AddButton.FlatAppearance.BorderSize = 0;
|
||||
this.AddButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
|
||||
this.AddButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(250)))), ((int)(((byte)(165)))));
|
||||
resources.ApplyResources(this.AddButton, "AddButton");
|
||||
this.AddButton.ForeColor = System.Drawing.Color.White;
|
||||
this.AddButton.GradientColorPrimary = System.Drawing.Color.FromArgb(((int)(((byte)(70)))), ((int)(((byte)(70)))), ((int)(((byte)(70)))));
|
||||
this.AddButton.GradientColorSecondary = System.Drawing.Color.FromArgb(((int)(((byte)(70)))), ((int)(((byte)(70)))), ((int)(((byte)(70)))));
|
||||
this.AddButton.HoverOverColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(250)))), ((int)(((byte)(165)))));
|
||||
this.AddButton.Name = "AddButton";
|
||||
this.AddButton.TextColor = System.Drawing.Color.White;
|
||||
this.AddButton.UseVisualStyleBackColor = false;
|
||||
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
|
||||
//
|
||||
// comboBox1
|
||||
//
|
||||
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBox1.FormattingEnabled = true;
|
||||
resources.ApplyResources(this.comboBox1, "comboBox1");
|
||||
this.comboBox1.Name = "comboBox1";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
resources.ApplyResources(this.label2, "label2");
|
||||
this.label2.ForeColor = System.Drawing.Color.White;
|
||||
this.label2.Name = "label2";
|
||||
//
|
||||
// AddCategory
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.CancelButton);
|
||||
this.Controls.Add(this.AddButton);
|
||||
this.Controls.Add(this.comboBox1);
|
||||
this.Controls.Add(this.label2);
|
||||
this.ForeColor = System.Drawing.Color.White;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "AddCategory";
|
||||
this.Load += new System.EventHandler(this.addCategory_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.ComboBox comboBox1;
|
||||
public System.Windows.Forms.Label label2;
|
||||
private CBH.Ultimate.Controls.CrEaTiiOn_Ultimate_GradientButton AddButton;
|
||||
private CBH.Ultimate.Controls.CrEaTiiOn_Ultimate_GradientButton CancelButton;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
using PckStudio.ToolboxItems;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
// Audio Editor by MattNL
|
||||
|
||||
namespace PckStudio.Forms.Additional_Popups.Audio
|
||||
{
|
||||
public partial class AddCategory : ThemeForm
|
||||
{
|
||||
private string _category = string.Empty;
|
||||
public string Category => _category;
|
||||
public AddCategory(string[] avalibleCategories)
|
||||
{
|
||||
InitializeComponent();
|
||||
comboBox1.Items.AddRange(avalibleCategories);
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void cancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void addCategory_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void CancelButton_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
_category = comboBox1.Text;
|
||||
DialogResult = DialogResult.OK;
|
||||
if (comboBox1.SelectedIndex > -1) Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,6 @@
|
||||
this.Padding = new System.Windows.Forms.Padding(10);
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "What\'s new in PCK Studio?";
|
||||
this.Load += new System.EventHandler(this.ChangeLogForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
@@ -11,10 +11,5 @@ namespace PckStudio.Forms.Additional_Popups
|
||||
InitializeComponent();
|
||||
ChangelogRichTextBox.Text = Resources.CHANGELOG;
|
||||
}
|
||||
|
||||
private void ChangeLogForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
162
PCK-Studio/Forms/Additional-Popups/CreditsForm.Designer.cs
generated
Normal file
162
PCK-Studio/Forms/Additional-Popups/CreditsForm.Designer.cs
generated
Normal file
@@ -0,0 +1,162 @@
|
||||
namespace PckStudio
|
||||
{
|
||||
partial class CreditsForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.metroLabel1 = new MetroFramework.Controls.MetroLabel();
|
||||
this.metroLabel2 = new MetroFramework.Controls.MetroLabel();
|
||||
this.metroLabel3 = new MetroFramework.Controls.MetroLabel();
|
||||
this.metroLabel4 = new MetroFramework.Controls.MetroLabel();
|
||||
this.metroLabel5 = new MetroFramework.Controls.MetroLabel();
|
||||
this.metroLabel6 = new MetroFramework.Controls.MetroLabel();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
|
||||
this.pictureBox1.Enabled = false;
|
||||
this.pictureBox1.Image = global::PckStudio.Properties.Resources.Splash;
|
||||
this.pictureBox1.Location = new System.Drawing.Point(4, 5);
|
||||
this.pictureBox1.Margin = new System.Windows.Forms.Padding(0, 0, 11, 0);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(550, 293);
|
||||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.pictureBox1.TabIndex = 0;
|
||||
this.pictureBox1.TabStop = false;
|
||||
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
|
||||
this.pictureBox1.DoubleClick += new System.EventHandler(this.pictureBox1_Click);
|
||||
//
|
||||
// metroLabel1
|
||||
//
|
||||
this.metroLabel1.AutoSize = true;
|
||||
this.metroLabel1.Enabled = false;
|
||||
this.metroLabel1.Location = new System.Drawing.Point(4, 301);
|
||||
this.metroLabel1.Name = "metroLabel1";
|
||||
this.metroLabel1.Size = new System.Drawing.Size(250, 19);
|
||||
this.metroLabel1.TabIndex = 1;
|
||||
this.metroLabel1.Text = "Restored and maintained by PhoenixARC";
|
||||
this.metroLabel1.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// metroLabel2
|
||||
//
|
||||
this.metroLabel2.AutoSize = true;
|
||||
this.metroLabel2.Enabled = false;
|
||||
this.metroLabel2.Location = new System.Drawing.Point(314, 301);
|
||||
this.metroLabel2.Name = "metroLabel2";
|
||||
this.metroLabel2.Size = new System.Drawing.Size(269, 19);
|
||||
this.metroLabel2.TabIndex = 2;
|
||||
this.metroLabel2.Text = "Utilizing the Nobledez Website by Newagent";
|
||||
this.metroLabel2.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// metroLabel3
|
||||
//
|
||||
this.metroLabel3.AutoSize = true;
|
||||
this.metroLabel3.Enabled = false;
|
||||
this.metroLabel3.Location = new System.Drawing.Point(314, 339);
|
||||
this.metroLabel3.Name = "metroLabel3";
|
||||
this.metroLabel3.Size = new System.Drawing.Size(212, 19);
|
||||
this.metroLabel3.TabIndex = 3;
|
||||
this.metroLabel3.Text = "3D skin renderer by Łukasz Rejman";
|
||||
this.metroLabel3.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// metroLabel4
|
||||
//
|
||||
this.metroLabel4.AutoSize = true;
|
||||
this.metroLabel4.Enabled = false;
|
||||
this.metroLabel4.Location = new System.Drawing.Point(314, 320);
|
||||
this.metroLabel4.Name = "metroLabel4";
|
||||
this.metroLabel4.Size = new System.Drawing.Size(199, 19);
|
||||
this.metroLabel4.TabIndex = 4;
|
||||
this.metroLabel4.Text = "3D renderer found by Newagent";
|
||||
this.metroLabel4.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// metroLabel5
|
||||
//
|
||||
this.metroLabel5.AutoSize = true;
|
||||
this.metroLabel5.Enabled = false;
|
||||
this.metroLabel5.Location = new System.Drawing.Point(4, 320);
|
||||
this.metroLabel5.Name = "metroLabel5";
|
||||
this.metroLabel5.Size = new System.Drawing.Size(300, 19);
|
||||
this.metroLabel5.TabIndex = 5;
|
||||
this.metroLabel5.Text = "Additional development by MattNL and Miku-666";
|
||||
this.metroLabel5.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// metroLabel6
|
||||
//
|
||||
this.metroLabel6.AutoSize = true;
|
||||
this.metroLabel6.Enabled = false;
|
||||
this.metroLabel6.Location = new System.Drawing.Point(4, 339);
|
||||
this.metroLabel6.Name = "metroLabel6";
|
||||
this.metroLabel6.Size = new System.Drawing.Size(203, 19);
|
||||
this.metroLabel6.TabIndex = 6;
|
||||
this.metroLabel6.Text = "Code base overhaul by Miku-666";
|
||||
this.metroLabel6.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// programInfo
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(585, 364);
|
||||
this.Controls.Add(this.metroLabel6);
|
||||
this.Controls.Add(this.metroLabel1);
|
||||
this.Controls.Add(this.metroLabel5);
|
||||
this.Controls.Add(this.metroLabel4);
|
||||
this.Controls.Add(this.metroLabel3);
|
||||
this.Controls.Add(this.metroLabel2);
|
||||
this.Controls.Add(this.pictureBox1);
|
||||
this.DisplayHeader = false;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "programInfo";
|
||||
this.Padding = new System.Windows.Forms.Padding(20, 30, 20, 20);
|
||||
this.Resizable = false;
|
||||
this.ShadowType = MetroFramework.Forms.MetroFormShadowType.DropShadow;
|
||||
this.Style = MetroFramework.MetroColorStyle.Black;
|
||||
this.Text = "programInfo";
|
||||
this.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel1;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel2;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel3;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel4;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel5;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel6;
|
||||
}
|
||||
}
|
||||
185
PCK-Studio/Forms/Additional-Popups/EntityForms/AddEntry.Designer.cs
generated
Normal file
185
PCK-Studio/Forms/Additional-Popups/EntityForms/AddEntry.Designer.cs
generated
Normal file
@@ -0,0 +1,185 @@
|
||||
namespace PckStudio.Forms.Additional_Popups.EntityForms
|
||||
{
|
||||
partial class AddEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.acceptBtn = new System.Windows.Forms.Button();
|
||||
this.CancelBtn = new System.Windows.Forms.Button();
|
||||
this.treeViewEntity = new System.Windows.Forms.TreeView();
|
||||
this.metroLabel2 = new MetroFramework.Controls.MetroLabel();
|
||||
this.metroTextBox1 = new MetroFramework.Controls.MetroTextBox();
|
||||
this.metroTabControl1 = new MetroFramework.Controls.MetroTabControl();
|
||||
this.Blocks = new System.Windows.Forms.TabPage();
|
||||
this.metroTabControl1.SuspendLayout();
|
||||
this.Blocks.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// acceptBtn
|
||||
//
|
||||
this.acceptBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.acceptBtn.ForeColor = System.Drawing.Color.White;
|
||||
this.acceptBtn.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.acceptBtn.Location = new System.Drawing.Point(92, 196);
|
||||
this.acceptBtn.Name = "acceptBtn";
|
||||
this.acceptBtn.Size = new System.Drawing.Size(75, 23);
|
||||
this.acceptBtn.TabIndex = 7;
|
||||
this.acceptBtn.Text = "Add";
|
||||
this.acceptBtn.UseVisualStyleBackColor = true;
|
||||
this.acceptBtn.Click += new System.EventHandler(this.AcceptBtn_Click);
|
||||
//
|
||||
// CancelBtn
|
||||
//
|
||||
this.CancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.CancelBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.CancelBtn.ForeColor = System.Drawing.Color.White;
|
||||
this.CancelBtn.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.CancelBtn.Location = new System.Drawing.Point(172, 196);
|
||||
this.CancelBtn.Name = "CancelBtn";
|
||||
this.CancelBtn.Size = new System.Drawing.Size(75, 23);
|
||||
this.CancelBtn.TabIndex = 13;
|
||||
this.CancelBtn.Text = "Cancel";
|
||||
this.CancelBtn.UseVisualStyleBackColor = true;
|
||||
this.CancelBtn.Click += new System.EventHandler(this.CancelBtn_Click);
|
||||
//
|
||||
// treeViewEntity
|
||||
//
|
||||
this.treeViewEntity.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.treeViewEntity.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.treeViewEntity.ForeColor = System.Drawing.Color.White;
|
||||
this.treeViewEntity.Location = new System.Drawing.Point(0, 0);
|
||||
this.treeViewEntity.Name = "treeViewEntity";
|
||||
this.treeViewEntity.Size = new System.Drawing.Size(318, 142);
|
||||
this.treeViewEntity.TabIndex = 14;
|
||||
this.treeViewEntity.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViews_AfterSelect);
|
||||
//
|
||||
// metroLabel2
|
||||
//
|
||||
this.metroLabel2.AutoSize = true;
|
||||
this.metroLabel2.Location = new System.Drawing.Point(133, 19);
|
||||
this.metroLabel2.Name = "metroLabel2";
|
||||
this.metroLabel2.Size = new System.Drawing.Size(46, 19);
|
||||
this.metroLabel2.TabIndex = 16;
|
||||
this.metroLabel2.Text = "Filter: ";
|
||||
this.metroLabel2.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// metroTextBox1
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.metroTextBox1.CustomButton.Image = null;
|
||||
this.metroTextBox1.CustomButton.Location = new System.Drawing.Point(134, 1);
|
||||
this.metroTextBox1.CustomButton.Name = "";
|
||||
this.metroTextBox1.CustomButton.Size = new System.Drawing.Size(21, 21);
|
||||
this.metroTextBox1.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||
this.metroTextBox1.CustomButton.TabIndex = 1;
|
||||
this.metroTextBox1.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||
this.metroTextBox1.CustomButton.UseSelectable = true;
|
||||
this.metroTextBox1.CustomButton.Visible = false;
|
||||
this.metroTextBox1.Lines = new string[0];
|
||||
this.metroTextBox1.Location = new System.Drawing.Point(173, 18);
|
||||
this.metroTextBox1.MaxLength = 32767;
|
||||
this.metroTextBox1.Name = "metroTextBox1";
|
||||
this.metroTextBox1.PasswordChar = '\0';
|
||||
this.metroTextBox1.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||
this.metroTextBox1.SelectedText = "";
|
||||
this.metroTextBox1.SelectionLength = 0;
|
||||
this.metroTextBox1.SelectionStart = 0;
|
||||
this.metroTextBox1.ShortcutsEnabled = true;
|
||||
this.metroTextBox1.Size = new System.Drawing.Size(156, 23);
|
||||
this.metroTextBox1.TabIndex = 17;
|
||||
this.metroTextBox1.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.metroTextBox1.UseSelectable = true;
|
||||
this.metroTextBox1.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||
this.metroTextBox1.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.metroTextBox1.TextChanged += new System.EventHandler(this.filter_TextChanged);
|
||||
//
|
||||
// metroTabControl1
|
||||
//
|
||||
this.metroTabControl1.Controls.Add(this.Blocks);
|
||||
this.metroTabControl1.Location = new System.Drawing.Point(6, 8);
|
||||
this.metroTabControl1.Name = "metroTabControl1";
|
||||
this.metroTabControl1.SelectedIndex = 0;
|
||||
this.metroTabControl1.Size = new System.Drawing.Size(326, 184);
|
||||
this.metroTabControl1.Style = MetroFramework.MetroColorStyle.White;
|
||||
this.metroTabControl1.TabIndex = 18;
|
||||
this.metroTabControl1.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.metroTabControl1.UseSelectable = true;
|
||||
//
|
||||
// Blocks
|
||||
//
|
||||
this.Blocks.BackColor = System.Drawing.SystemColors.WindowFrame;
|
||||
this.Blocks.Controls.Add(this.treeViewEntity);
|
||||
this.Blocks.Location = new System.Drawing.Point(4, 38);
|
||||
this.Blocks.Name = "Blocks";
|
||||
this.Blocks.Size = new System.Drawing.Size(318, 142);
|
||||
this.Blocks.TabIndex = 0;
|
||||
this.Blocks.Text = "Entities";
|
||||
//
|
||||
// AddBehaviour
|
||||
//
|
||||
this.AcceptButton = this.acceptBtn;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.CancelBtn;
|
||||
this.ClientSize = new System.Drawing.Size(338, 228);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.metroTextBox1);
|
||||
this.Controls.Add(this.metroLabel2);
|
||||
this.Controls.Add(this.metroTabControl1);
|
||||
this.Controls.Add(this.CancelBtn);
|
||||
this.Controls.Add(this.acceptBtn);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "AddBehaviour";
|
||||
this.Resizable = false;
|
||||
this.Style = MetroFramework.MetroColorStyle.Silver;
|
||||
this.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.metroTabControl1.ResumeLayout(false);
|
||||
this.Blocks.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
private void MetroTextBox1_TextChanged(object sender, System.EventArgs e)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.Button CancelBtn;
|
||||
private System.Windows.Forms.TreeView treeViewEntity;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel2;
|
||||
private MetroFramework.Controls.MetroTextBox metroTextBox1;
|
||||
private MetroFramework.Controls.MetroTabControl metroTabControl1;
|
||||
private System.Windows.Forms.TabPage Blocks;
|
||||
public System.Windows.Forms.Button acceptBtn;
|
||||
}
|
||||
}
|
||||
115
PCK-Studio/Forms/Additional-Popups/EntityForms/AddEntry.cs
Normal file
115
PCK-Studio/Forms/Additional-Popups/EntityForms/AddEntry.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using MetroFramework.Forms;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace PckStudio.Forms.Additional_Popups.EntityForms
|
||||
{
|
||||
public partial class AddEntry : MetroForm
|
||||
{
|
||||
string selectedEntity = "";
|
||||
|
||||
JObject EntityJSONData;
|
||||
public string SelectedEntity => selectedEntity;
|
||||
|
||||
List<TreeNode> treeViewEntityCache = new List<TreeNode>();
|
||||
|
||||
public AddEntry(JObject entityData, System.Drawing.Image[] entityImages)
|
||||
{
|
||||
InitializeComponent();
|
||||
EntityJSONData = entityData;
|
||||
ImageList entities = new ImageList();
|
||||
entities.ColorDepth = ColorDepth.Depth32Bit;
|
||||
entities.ImageSize = new System.Drawing.Size(32, 32);
|
||||
entities.Images.AddRange(entityImages);
|
||||
treeViewEntity.ImageList = entities;
|
||||
|
||||
try
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if (EntityJSONData["entities"] != null)
|
||||
{
|
||||
foreach (JObject content in EntityJSONData["entities"].Children())
|
||||
{
|
||||
foreach (JProperty prop in content.Properties())
|
||||
{
|
||||
if (!string.IsNullOrEmpty((string)prop.Value))
|
||||
{
|
||||
TreeNode entityNode = new TreeNode((string)prop.Value)
|
||||
{
|
||||
Tag = prop.Name,
|
||||
ImageIndex = i,
|
||||
SelectedImageIndex = i,
|
||||
};
|
||||
treeViewEntity.Nodes.Add(entityNode);
|
||||
treeViewEntityCache.Add(entityNode);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Newtonsoft.Json.JsonException j_ex)
|
||||
{
|
||||
MessageBox.Show(j_ex.Message, "Error");
|
||||
return;
|
||||
}
|
||||
|
||||
treeViewEntity.Sort();
|
||||
}
|
||||
|
||||
private void treeViews_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
if (e.Node.Tag is string entityData)
|
||||
{
|
||||
selectedEntity = entityData;
|
||||
Console.WriteLine(selectedEntity);
|
||||
}
|
||||
}
|
||||
|
||||
void filter_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
// Some code in this function is modified code from this StackOverflow answer - MattNL
|
||||
//https://stackoverflow.com/questions/8260322/filter-a-treeview-with-a-textbox-in-a-c-sharp-winforms-app
|
||||
|
||||
//blocks repainting tree until all objects loaded
|
||||
treeViewEntity.BeginUpdate();
|
||||
treeViewEntity.Nodes.Clear();
|
||||
if (!string.IsNullOrEmpty(metroTextBox1.Text))
|
||||
{
|
||||
foreach (TreeNode _node in treeViewEntityCache)
|
||||
{
|
||||
if (_node.Text.ToLower().Contains(metroTextBox1.Text.ToLower()) ||
|
||||
(_node.Tag as string).ToLower().Contains(metroTextBox1.Text.ToLower()))
|
||||
{
|
||||
treeViewEntity.Nodes.Add((TreeNode)_node.Clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (TreeNode _node in treeViewEntityCache)
|
||||
{
|
||||
treeViewEntity.Nodes.Add((TreeNode)_node.Clone());
|
||||
}
|
||||
}
|
||||
//enables redrawing tree after all objects have been added
|
||||
treeViewEntity.EndUpdate();
|
||||
}
|
||||
|
||||
private void CancelBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void AcceptBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(selectedEntity)) CancelBtn_Click(sender, e);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
120
PCK-Studio/Forms/Additional-Popups/EntityForms/AddEntry.resx
Normal file
120
PCK-Studio/Forms/Additional-Popups/EntityForms/AddEntry.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
96
PCK-Studio/Forms/Additional-Popups/ItemSelectionPopUp.Designer.cs
generated
Normal file
96
PCK-Studio/Forms/Additional-Popups/ItemSelectionPopUp.Designer.cs
generated
Normal file
@@ -0,0 +1,96 @@
|
||||
namespace PckStudio.Forms.Additional_Popups
|
||||
{
|
||||
partial class ItemSelectionPopUp
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ItemSelectionPopUp));
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.okBtn = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.ComboBox = new MetroFramework.Controls.MetroComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label2
|
||||
//
|
||||
resources.ApplyResources(this.label2, "label2");
|
||||
this.label2.ForeColor = System.Drawing.Color.White;
|
||||
this.label2.Name = "label2";
|
||||
//
|
||||
// okBtn
|
||||
//
|
||||
resources.ApplyResources(this.okBtn, "okBtn");
|
||||
this.okBtn.ForeColor = System.Drawing.Color.White;
|
||||
this.okBtn.Name = "okBtn";
|
||||
this.okBtn.UseVisualStyleBackColor = true;
|
||||
this.okBtn.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
resources.ApplyResources(this.cancelButton, "cancelButton");
|
||||
this.cancelButton.ForeColor = System.Drawing.Color.White;
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// ComboBox
|
||||
//
|
||||
this.ComboBox.FormattingEnabled = true;
|
||||
resources.ApplyResources(this.ComboBox, "ComboBox");
|
||||
this.ComboBox.Name = "ComboBox";
|
||||
this.ComboBox.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.ComboBox.UseSelectable = true;
|
||||
//
|
||||
// ItemSelectionPopUp
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.ComboBox);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okBtn);
|
||||
this.Controls.Add(this.label2);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ItemSelectionPopUp";
|
||||
this.Resizable = false;
|
||||
this.ShadowType = MetroFramework.Forms.MetroFormShadowType.DropShadow;
|
||||
this.Style = MetroFramework.MetroColorStyle.Silver;
|
||||
this.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
public System.Windows.Forms.Label label2;
|
||||
public System.Windows.Forms.Button okBtn;
|
||||
private MetroFramework.Controls.MetroComboBox ComboBox;
|
||||
}
|
||||
}
|
||||
31
PCK-Studio/Forms/Additional-Popups/ItemSelectionPopUp.cs
Normal file
31
PCK-Studio/Forms/Additional-Popups/ItemSelectionPopUp.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
// Audio Editor by MattNL
|
||||
|
||||
namespace PckStudio.Forms.Additional_Popups
|
||||
{
|
||||
public partial class ItemSelectionPopUp : MetroFramework.Forms.MetroForm
|
||||
{
|
||||
public string SelectedItem => DialogResult == DialogResult.OK ? ComboBox.Text : string.Empty;
|
||||
|
||||
public ItemSelectionPopUp(string[] items)
|
||||
{
|
||||
InitializeComponent();
|
||||
ComboBox.Items.AddRange(items);
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
if(ComboBox.SelectedIndex > -1)
|
||||
cancelButton_Click(sender, e);
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void cancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
namespace PckStudio.Forms
|
||||
{
|
||||
partial class LockPrompt
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LockPrompt));
|
||||
this.textBoxPass = new System.Windows.Forms.TextBox();
|
||||
this.UnlockPCKButton = new CBH.Ultimate.Controls.CrEaTiiOn_Ultimate_GradientButton();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxPass
|
||||
//
|
||||
this.textBoxPass.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
|
||||
this.textBoxPass.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.textBoxPass.ForeColor = System.Drawing.Color.White;
|
||||
resources.ApplyResources(this.textBoxPass, "textBoxPass");
|
||||
this.textBoxPass.Name = "textBoxPass";
|
||||
this.textBoxPass.Click += new System.EventHandler(this.textBoxPass_Click);
|
||||
this.textBoxPass.TextChanged += new System.EventHandler(this.textBoxPass_TextChanged);
|
||||
this.textBoxPass.Enter += new System.EventHandler(this.textBoxPass_Enter);
|
||||
//
|
||||
// UnlockPCKButton
|
||||
//
|
||||
this.UnlockPCKButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(25)))), ((int)(((byte)(25)))));
|
||||
this.UnlockPCKButton.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(25)))), ((int)(((byte)(25)))));
|
||||
this.UnlockPCKButton.BorderRadius = 10;
|
||||
this.UnlockPCKButton.BorderSize = 1;
|
||||
this.UnlockPCKButton.ClickedColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
|
||||
this.UnlockPCKButton.FlatAppearance.BorderSize = 0;
|
||||
this.UnlockPCKButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
|
||||
this.UnlockPCKButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
|
||||
resources.ApplyResources(this.UnlockPCKButton, "UnlockPCKButton");
|
||||
this.UnlockPCKButton.ForeColor = System.Drawing.Color.White;
|
||||
this.UnlockPCKButton.GradientColorPrimary = System.Drawing.Color.FromArgb(((int)(((byte)(70)))), ((int)(((byte)(70)))), ((int)(((byte)(70)))));
|
||||
this.UnlockPCKButton.GradientColorSecondary = System.Drawing.Color.FromArgb(((int)(((byte)(70)))), ((int)(((byte)(70)))), ((int)(((byte)(70)))));
|
||||
this.UnlockPCKButton.HoverOverColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
|
||||
this.UnlockPCKButton.Name = "UnlockPCKButton";
|
||||
this.UnlockPCKButton.TextColor = System.Drawing.Color.White;
|
||||
this.UnlockPCKButton.UseVisualStyleBackColor = false;
|
||||
this.UnlockPCKButton.Click += new System.EventHandler(this.UnlockPCKButton_Click);
|
||||
//
|
||||
// LockPrompt
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
|
||||
this.Controls.Add(this.UnlockPCKButton);
|
||||
this.Controls.Add(this.textBoxPass);
|
||||
this.ForeColor = System.Drawing.Color.White;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "LockPrompt";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox textBoxPass;
|
||||
private CBH.Ultimate.Controls.CrEaTiiOn_Ultimate_GradientButton UnlockPCKButton;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
using PckStudio.ToolboxItems;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PckStudio.Forms
|
||||
{
|
||||
public partial class LockPrompt : ThemeForm
|
||||
{
|
||||
string pass;
|
||||
|
||||
public LockPrompt(string pass)
|
||||
{
|
||||
this.pass = pass;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void textBoxPass_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void textBoxPass_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void textBoxPass_Enter(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
public string MD5(string s)
|
||||
{
|
||||
using (var provider = System.Security.Cryptography.MD5.Create())
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
foreach (byte b in provider.ComputeHash(Encoding.UTF8.GetBytes(s)))
|
||||
builder.Append(b.ToString("x2").ToLower());
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void UnlockPCKButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MD5(textBoxPass.Text) == pass || MD5(textBoxPass.Text) == MD5(pass))
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Incorrect password!");
|
||||
DialogResult = DialogResult.Abort;
|
||||
textBoxPass.Text = "";
|
||||
}
|
||||
#if DEBUG
|
||||
DialogResult = DialogResult.OK;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,61 +0,0 @@
|
||||
namespace PckStudio
|
||||
{
|
||||
partial class MetaList
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MetaList));
|
||||
this.MetaTreeView = new System.Windows.Forms.TreeView();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// MetaTreeView
|
||||
//
|
||||
this.MetaTreeView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
|
||||
this.MetaTreeView.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
resources.ApplyResources(this.MetaTreeView, "MetaTreeView");
|
||||
this.MetaTreeView.ForeColor = System.Drawing.Color.White;
|
||||
this.MetaTreeView.Name = "MetaTreeView";
|
||||
//
|
||||
// MetaList
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
|
||||
this.Controls.Add(this.MetaTreeView);
|
||||
this.ForeColor = System.Drawing.Color.White;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "MetaList";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TreeView MetaTreeView;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using PckStudio.ToolboxItems;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PckStudio
|
||||
{
|
||||
public partial class MetaList : ThemeForm
|
||||
{
|
||||
public MetaList(List<string> metaTags)
|
||||
{
|
||||
InitializeComponent();
|
||||
MetaTreeView.Nodes.Clear();
|
||||
metaTags.ForEach(s => MetaTreeView.Nodes.Add(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
150
PCK-Studio/Forms/Editor/Animation.cs
Normal file
150
PCK-Studio/Forms/Editor/Animation.cs
Normal file
@@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using PckStudio.Classes.Extentions;
|
||||
using System.Text;
|
||||
|
||||
|
||||
// TODO: change namespace
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
sealed class Animation
|
||||
{
|
||||
public const int MinimumFrameTime = 1;
|
||||
|
||||
public int FrameCount => frames.Count;
|
||||
|
||||
public int FrameTextureCount => frameTextures.Count;
|
||||
|
||||
public Frame this[int frameIndex] => frames[frameIndex];
|
||||
|
||||
// not implemented rn...
|
||||
public bool Interpolate { get; set; } = false;
|
||||
|
||||
private readonly List<Image> frameTextures;
|
||||
|
||||
private readonly List<Frame> frames = new List<Frame>();
|
||||
|
||||
|
||||
public Animation(IEnumerable<Image> image)
|
||||
{
|
||||
frameTextures = new List<Image>(image);
|
||||
}
|
||||
|
||||
public Animation(IEnumerable<Image> frameTextures, string ANIM) : this(frameTextures)
|
||||
{
|
||||
ParseAnim(ANIM);
|
||||
}
|
||||
|
||||
public struct Frame
|
||||
{
|
||||
public readonly Image Texture;
|
||||
public int Ticks;
|
||||
|
||||
public static implicit operator Image(Frame f) => f.Texture;
|
||||
|
||||
public Frame(Image texture) : this(texture, MinimumFrameTime)
|
||||
{ }
|
||||
|
||||
public Frame(Image texture, int frameTime)
|
||||
{
|
||||
Texture = texture;
|
||||
Ticks = frameTime;
|
||||
}
|
||||
}
|
||||
|
||||
public void ParseAnim(string ANIM)
|
||||
{
|
||||
_ = ANIM ?? throw new ArgumentNullException(nameof(ANIM));
|
||||
ANIM = (Interpolate = ANIM.StartsWith("#")) ? ANIM.Substring(1) : ANIM;
|
||||
string[] animData = ANIM.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
int lastFrameTime = MinimumFrameTime;
|
||||
if (animData.Length <= 0)
|
||||
{
|
||||
for (int i = 0; i < FrameTextureCount; i++)
|
||||
{
|
||||
AddFrame(i, MinimumFrameTime);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (string frameInfo in animData)
|
||||
{
|
||||
string[] frameData = frameInfo.Split('*');
|
||||
//if (frameData.Length < 2)
|
||||
// continue; // shouldn't happen
|
||||
int currentFrameIndex = int.TryParse(frameData[0], out currentFrameIndex) ? currentFrameIndex : 0;
|
||||
|
||||
// Some textures like the Halloween 2015's Lava texture don't have a
|
||||
// frame time parameter for certain frames.
|
||||
// This will detect that and place the last frame time in its place.
|
||||
// This is accurate to console edition behavior.
|
||||
// - MattNL
|
||||
int currentFrameTime = string.IsNullOrEmpty(frameData[1]) ? lastFrameTime : int.Parse(frameData[1]);
|
||||
AddFrame(currentFrameIndex, currentFrameTime);
|
||||
lastFrameTime = currentFrameTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
public Frame AddFrame(int frameTextureIndex) => AddFrame(frameTextureIndex, MinimumFrameTime);
|
||||
public Frame AddFrame(int frameTextureIndex, int frameTime)
|
||||
{
|
||||
if (frameTextureIndex < 0 || frameTextureIndex >= frameTextures.Count)
|
||||
throw new ArgumentOutOfRangeException(nameof(frameTextureIndex));
|
||||
Frame f = new Frame(frameTextures[frameTextureIndex], frameTime);
|
||||
frames.Add(f);
|
||||
return f;
|
||||
}
|
||||
|
||||
public bool RemoveFrame(int frameIndex)
|
||||
{
|
||||
frames.RemoveAt(frameIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Frame GetFrame(int index) => frames[index];
|
||||
|
||||
public List<Frame> GetFrames()
|
||||
{
|
||||
return frames;
|
||||
}
|
||||
|
||||
public List<Image> GetFrameTextures()
|
||||
{
|
||||
return frameTextures;
|
||||
}
|
||||
|
||||
public int GetTextureIndex(Image frameTexture)
|
||||
{
|
||||
_ = frameTexture ?? throw new ArgumentNullException(nameof(frameTexture));
|
||||
return frameTextures.IndexOf(frameTexture);
|
||||
}
|
||||
|
||||
public void SetFrame(Frame frame, int frameTextureIndex, int frameTime = MinimumFrameTime)
|
||||
=> SetFrame(frames.IndexOf(frame), frameTextureIndex, frameTime);
|
||||
public void SetFrame(int frameIndex, int frameTextureIndex, int frameTime = MinimumFrameTime)
|
||||
{
|
||||
frames[frameIndex] = new Frame(frameTextures[frameTextureIndex], frameTime);
|
||||
}
|
||||
|
||||
public string BuildAnim()
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder(Interpolate ? "#" : string.Empty);
|
||||
foreach (var frame in frames)
|
||||
stringBuilder.Append($"{GetTextureIndex(frame)}*{frame.Ticks},");
|
||||
return stringBuilder.ToString(0, stringBuilder.Length - 1);
|
||||
}
|
||||
|
||||
public Image BuildTexture(bool isClockOrCompass, List<Image> linearImages = default!)
|
||||
{
|
||||
int width = frameTextures[0].Width;
|
||||
int height = frameTextures[0].Height;
|
||||
if (width != height)
|
||||
throw new Exception("Invalid size");
|
||||
|
||||
var textures = isClockOrCompass ? linearImages : frameTextures;
|
||||
|
||||
return ImageExtentions.ImageFromImageArray(textures.ToArray(), ImageExtentions.ImageLayoutDirection.Vertical);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,24 +2,23 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using PckStudio.Forms.Additional_Popups.Animation;
|
||||
using PckStudio.Forms.Utilities;
|
||||
using PckStudio.Classes.Extentions;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
public partial class AnimationEditor : ThemeForm
|
||||
{
|
||||
PCKFile.FileData animationFile;
|
||||
PckFile.FileData animationFile;
|
||||
Animation currentAnimation;
|
||||
AnimationPlayer player;
|
||||
|
||||
@@ -28,238 +27,35 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
public string TileName = string.Empty;
|
||||
|
||||
sealed class Animation
|
||||
{
|
||||
public const int MinimumFrameTime = 1;
|
||||
private bool IsEditingSpecial => IsSpecialTile(TileName);
|
||||
|
||||
private readonly List<Image> frameTextures;
|
||||
|
||||
private readonly List<Frame> frames = new List<Frame>();
|
||||
|
||||
public Frame this[int frameIndex] => frames[frameIndex];
|
||||
|
||||
// not implemented rn...
|
||||
public bool Interpolate { get; set; } = false;
|
||||
|
||||
public Animation(Image image)
|
||||
{
|
||||
frameTextures = new List<Image>(SplitImageToFrameTextures(image));
|
||||
}
|
||||
|
||||
public Animation(Image image, string ANIM) : this(image)
|
||||
{
|
||||
ParseAnim(ANIM);
|
||||
}
|
||||
|
||||
public struct Frame
|
||||
{
|
||||
public readonly Image Texture;
|
||||
public int Ticks;
|
||||
|
||||
public static implicit operator Image(Frame f) => f.Texture;
|
||||
|
||||
public Frame(Image texture) : this(texture, MinimumFrameTime)
|
||||
{}
|
||||
|
||||
public Frame(Image texture, int frameTime)
|
||||
{
|
||||
Texture = texture;
|
||||
Ticks = frameTime;
|
||||
}
|
||||
}
|
||||
|
||||
public void ParseAnim(string ANIM)
|
||||
{
|
||||
_ = ANIM ?? throw new ArgumentNullException(nameof(ANIM));
|
||||
ANIM = (Interpolate = ANIM.StartsWith("#")) ? ANIM.Substring(1) : ANIM;
|
||||
string[] animData = ANIM.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
int lastFrameTime = MinimumFrameTime;
|
||||
if (animData.Length <= 0)
|
||||
{
|
||||
for(int i = 0; i < FrameTextureCount; i++)
|
||||
{
|
||||
AddFrame(i, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (string frameInfo in animData)
|
||||
{
|
||||
string[] frameData = frameInfo.Split('*');
|
||||
//if (frameData.Length < 2)
|
||||
// continue; // shouldn't happen
|
||||
int currentFrameIndex = int.TryParse(frameData[0], out currentFrameIndex) ? currentFrameIndex : 0;
|
||||
|
||||
// Some textures like the Halloween 2015's Lava texture don't have a
|
||||
// frame time parameter for certain frames.
|
||||
// This will detect that and place the last frame time in its place.
|
||||
// This is accurate to console edition behavior.
|
||||
// - MattNL
|
||||
int currentFrameTime = string.IsNullOrEmpty(frameData[1]) ? lastFrameTime : int.Parse(frameData[1]);
|
||||
AddFrame(currentFrameIndex, currentFrameTime);
|
||||
lastFrameTime = currentFrameTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
public Frame AddFrame(int frameTextureIndex) => AddFrame(frameTextureIndex, MinimumFrameTime);
|
||||
public Frame AddFrame(int frameTextureIndex, int frameTime)
|
||||
{
|
||||
if (frameTextureIndex < 0 || frameTextureIndex >= frameTextures.Count)
|
||||
throw new ArgumentOutOfRangeException(nameof(frameTextureIndex));
|
||||
Frame f = new Frame(frameTextures[frameTextureIndex], frameTime);
|
||||
frames.Add(f);
|
||||
return f;
|
||||
}
|
||||
|
||||
public bool RemoveFrame(int frameIndex)
|
||||
{
|
||||
frames.RemoveAt(frameIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static IEnumerable<Image> SplitImageToFrameTextures(Image source)
|
||||
{
|
||||
for (int i = 0; i < source.Height / source.Width; i++)
|
||||
{
|
||||
Rectangle tileArea = new Rectangle(0, i * source.Width, source.Width, source.Width);
|
||||
Bitmap tileImage = new Bitmap(source.Width, source.Width);
|
||||
using (Graphics gfx = Graphics.FromImage(tileImage))
|
||||
{
|
||||
gfx.SmoothingMode = SmoothingMode.None;
|
||||
gfx.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||
gfx.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
gfx.DrawImage(source, new Rectangle(0, 0, source.Width, source.Width), tileArea, GraphicsUnit.Pixel);
|
||||
}
|
||||
yield return tileImage;
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
public Frame GetFrame(int index) => frames[index];
|
||||
|
||||
public List<Frame> GetFrames()
|
||||
{
|
||||
return frames;
|
||||
}
|
||||
|
||||
public List<Image> GetFrameTextures()
|
||||
{
|
||||
return frameTextures;
|
||||
}
|
||||
|
||||
public int GetFrameIndex(Image frameTexture)
|
||||
{
|
||||
_ = frameTexture ?? throw new ArgumentNullException(nameof(frameTexture));
|
||||
return frameTextures.IndexOf(frameTexture);
|
||||
}
|
||||
|
||||
public int FrameCount => frames.Count;
|
||||
public int FrameTextureCount => frameTextures.Count;
|
||||
|
||||
public void SetFrame(Frame frame, int frameTextureIndex, int frameTime = MinimumFrameTime)
|
||||
=> SetFrame(frames.IndexOf(frame), frameTextureIndex, frameTime);
|
||||
public void SetFrame(int frameIndex, int frameTextureIndex, int frameTime = MinimumFrameTime)
|
||||
{
|
||||
frames[frameIndex] = new Frame(frameTextures[frameTextureIndex], frameTime);
|
||||
}
|
||||
|
||||
public string BuildAnim()
|
||||
{
|
||||
string animationData = Interpolate ? "#" : string.Empty;
|
||||
frames.ForEach(frame => animationData += $"{GetFrameIndex(frame)}*{frame.Ticks},");
|
||||
return animationData.TrimEnd(',');
|
||||
}
|
||||
|
||||
public Image BuildTexture()
|
||||
{
|
||||
int width = frameTextures[0].Width;
|
||||
int height = frameTextures[0].Height;
|
||||
if (width != height) throw new Exception("Invalid size");
|
||||
var img = new Bitmap(width, height * FrameTextureCount);
|
||||
int pos_y = 0;
|
||||
using (var g = Graphics.FromImage(img))
|
||||
frameTextures.ForEach(texture =>
|
||||
{
|
||||
g.DrawImage(texture, 0, pos_y);
|
||||
pos_y += height;
|
||||
});
|
||||
return img;
|
||||
}
|
||||
}
|
||||
|
||||
sealed class AnimationPlayer
|
||||
private bool IsSpecialTile(string tileName)
|
||||
{
|
||||
public const int BaseTickSpeed = 48;
|
||||
public bool IsPlaying { get; private set; } = false;
|
||||
return tileName == "clock" || tileName == "compass";
|
||||
}
|
||||
|
||||
private int currentAnimationFrameIndex = 0;
|
||||
private PictureBox display;
|
||||
private Animation _animation;
|
||||
private CancellationTokenSource cts = new CancellationTokenSource();
|
||||
|
||||
public AnimationPlayer(PictureBox display)
|
||||
{
|
||||
SetContext(display);
|
||||
}
|
||||
|
||||
private async void DoAnimate()
|
||||
{
|
||||
_ = display ?? throw new ArgumentNullException(nameof(display));
|
||||
_ = _animation ?? throw new ArgumentNullException(nameof(_animation));
|
||||
IsPlaying = true;
|
||||
while (!cts.IsCancellationRequested)
|
||||
{
|
||||
if (currentAnimationFrameIndex >= _animation.FrameCount)
|
||||
currentAnimationFrameIndex = 0;
|
||||
Animation.Frame frame = SetFrameDisplayed(currentAnimationFrameIndex++);
|
||||
await Task.Delay(BaseTickSpeed * frame.Ticks);
|
||||
}
|
||||
IsPlaying = false;
|
||||
}
|
||||
|
||||
public void Start(Animation animation)
|
||||
{
|
||||
_animation = animation;
|
||||
cts = new CancellationTokenSource();
|
||||
Task.Run(DoAnimate, cts.Token);
|
||||
}
|
||||
|
||||
public void Stop() => cts.Cancel();
|
||||
|
||||
public Animation.Frame GetCurrentFrame() => _animation[currentAnimationFrameIndex];
|
||||
|
||||
public void SetContext(PictureBox display) => this.display = display;
|
||||
|
||||
public void SelectFrame(Animation animation, int index)
|
||||
{
|
||||
_animation = animation;
|
||||
if (IsPlaying) Stop();
|
||||
SetFrameDisplayed(index);
|
||||
currentAnimationFrameIndex = index;
|
||||
}
|
||||
|
||||
private Animation.Frame SetFrameDisplayed(int i)
|
||||
{
|
||||
Monitor.Enter(_animation);
|
||||
Animation.Frame frame = _animation[i];
|
||||
display.Image = frame;
|
||||
Monitor.Exit(_animation);
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
|
||||
public AnimationEditor(PCKFile.FileData file)
|
||||
public AnimationEditor(PckFile.FileData file)
|
||||
{
|
||||
InitializeComponent();
|
||||
isItem = file.filepath.Split('/').Contains("items");
|
||||
TileName = Path.GetFileNameWithoutExtension(file.filepath);
|
||||
|
||||
isItem = file.Filename.Split('/').Contains("items");
|
||||
TileName = Path.GetFileNameWithoutExtension(file.Filename);
|
||||
|
||||
InterpolationCheckbox.Visible = !IsEditingSpecial;
|
||||
InterpolationCheckbox.Checked = InterpolationCheckbox.Visible;
|
||||
bulkAnimationSpeedToolStripMenuItem.Enabled = InterpolationCheckbox.Visible;
|
||||
importJavaAnimationToolStripMenuItem.Enabled = InterpolationCheckbox.Visible;
|
||||
exportJavaAnimationToolStripMenuItem.Enabled = InterpolationCheckbox.Visible;
|
||||
|
||||
animationFile = file;
|
||||
|
||||
using MemoryStream textureMem = new MemoryStream(animationFile.data);
|
||||
using MemoryStream textureMem = new MemoryStream(animationFile.Data);
|
||||
var texture = new Bitmap(textureMem);
|
||||
currentAnimation = animationFile.properties.HasProperty("ANIM")
|
||||
? new Animation(texture, animationFile.properties.GetProperty("ANIM").Item2)
|
||||
: new Animation(texture);
|
||||
var frameTextures = texture.CreateImageList(ImageExtentions.ImageLayoutDirection.Horizontal);
|
||||
|
||||
currentAnimation = animationFile.Properties.HasProperty("ANIM")
|
||||
? new Animation(frameTextures, animationFile.Properties.GetPropertyValue("ANIM"))
|
||||
: new Animation(frameTextures);
|
||||
player = new AnimationPlayer(pictureBoxWithInterpolationMode1);
|
||||
|
||||
foreach (JObject content in AnimationUtil.tileData[animationSection].Children())
|
||||
@@ -281,7 +77,15 @@ namespace PckStudio.Forms.Editor
|
||||
// $"Frame: {i}, Frame Time: {Animation.MinimumFrameTime}"
|
||||
TextureIcons.Images.Clear();
|
||||
TextureIcons.Images.AddRange(currentAnimation.GetFrameTextures().ToArray());
|
||||
currentAnimation.GetFrames().ForEach(f => frameTreeView.Nodes.Add("", $"for {f.Ticks} frame" + (f.Ticks > 1 ? "s" : "" ), currentAnimation.GetFrameIndex(f.Texture), currentAnimation.GetFrameIndex(f.Texture)));
|
||||
foreach (var frame in currentAnimation.GetFrames())
|
||||
{
|
||||
var imageIndex = currentAnimation.GetTextureIndex(frame.Texture);
|
||||
frameTreeView.Nodes.Add(new TreeNode($"for {frame.Ticks} frames")
|
||||
{
|
||||
ImageIndex = imageIndex,
|
||||
SelectedImageIndex = imageIndex,
|
||||
});
|
||||
}
|
||||
player.SelectFrame(currentAnimation, 0);
|
||||
}
|
||||
|
||||
@@ -299,8 +103,8 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void StartAnimationBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
// crash fix: when pushing the play button on occasions, the animation will play twice the intended speed and crash PCK Studio after one iteration
|
||||
player.Stop(); // force the player to stop before starting
|
||||
// prevent player from crashing
|
||||
player.Stop();
|
||||
AnimationPlayBtn.Enabled = !(AnimationStopBtn.Enabled = !AnimationStopBtn.Enabled);
|
||||
if (currentAnimation.FrameCount > 1)
|
||||
{
|
||||
@@ -333,12 +137,13 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void saveToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
string anim = currentAnimation.BuildAnim();
|
||||
animationFile.properties.SetProperty("ANIM", anim);
|
||||
|
||||
animationFile.Properties.SetProperty("ANIM", IsEditingSpecial ? "" : anim);
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
currentAnimation.BuildTexture().Save(stream, ImageFormat.Png);
|
||||
var texture = currentAnimation.BuildTexture(IsEditingSpecial);
|
||||
texture.Save(stream, ImageFormat.Png);
|
||||
animationFile.SetData(stream.ToArray());
|
||||
}
|
||||
//Reusing this for the tile path
|
||||
@@ -426,7 +231,7 @@ namespace PckStudio.Forms.Editor
|
||||
private void treeView1_doubleClick(object sender, EventArgs e)
|
||||
{
|
||||
var frame = currentAnimation.GetFrame(frameTreeView.SelectedNode.Index);
|
||||
using FrameEditor diag = new FrameEditor(frame.Ticks, currentAnimation.GetFrameIndex(frame.Texture), TextureIcons);
|
||||
using FrameEditor diag = new FrameEditor(frame.Ticks, currentAnimation.GetTextureIndex(frame.Texture), TextureIcons);
|
||||
if (diag.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
/* Found a bug here. When passing the frame variable, it would replace the first instance of that frame and time
|
||||
@@ -450,7 +255,7 @@ namespace PckStudio.Forms.Editor
|
||||
//diag.SaveButton.Text = "Add";
|
||||
if (diag.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
currentAnimation.AddFrame(diag.FrameTextureIndex, diag.FrameTime);
|
||||
currentAnimation.AddFrame(diag.FrameTextureIndex, TileName == "clock" || TileName == "compass" ? 1 : diag.FrameTime);
|
||||
LoadAnimationTreeView();
|
||||
}
|
||||
}
|
||||
@@ -472,7 +277,7 @@ namespace PckStudio.Forms.Editor
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
Animation.Frame f = list[i];
|
||||
currentAnimation.SetFrame(f, currentAnimation.GetFrameIndex(f), diag.time);
|
||||
currentAnimation.SetFrame(f, currentAnimation.GetTextureIndex(f), diag.time);
|
||||
}
|
||||
LoadAnimationTreeView();
|
||||
}
|
||||
@@ -486,15 +291,12 @@ namespace PckStudio.Forms.Editor
|
||||
if (query == DialogResult.No) return;
|
||||
|
||||
OpenFileDialog fileDialog = new OpenFileDialog();
|
||||
fileDialog.Multiselect = false;
|
||||
fileDialog.Title = "Please select a valid Minecaft: Java Edition animation script";
|
||||
|
||||
// It's marked as .png.mcmeta just in case
|
||||
// some weirdo tries to pass a pack.mcmeta or something
|
||||
// -MattNL
|
||||
fileDialog.Filter = "Animation Scripts (*.mcmeta)|*.png.mcmeta";
|
||||
fileDialog.CheckPathExists = true;
|
||||
fileDialog.CheckFileExists = true;
|
||||
if (fileDialog.ShowDialog(this) != DialogResult.OK) return;
|
||||
Console.WriteLine("Selected Animation Script: " + fileDialog.FileName);
|
||||
|
||||
@@ -505,8 +307,8 @@ namespace PckStudio.Forms.Editor
|
||||
return;
|
||||
}
|
||||
using MemoryStream textureMem = new MemoryStream(File.ReadAllBytes(textureFile));
|
||||
var new_animation = new Animation(Image.FromStream(textureMem));
|
||||
|
||||
var textures = Image.FromStream(textureMem).CreateImageList(ImageExtentions.ImageLayoutDirection.Horizontal);
|
||||
var new_animation = new Animation(textures);
|
||||
try
|
||||
{
|
||||
JObject mcmeta = JObject.Parse(File.ReadAllText(fileDialog.FileName));
|
||||
@@ -566,6 +368,13 @@ namespace PckStudio.Forms.Editor
|
||||
Console.WriteLine(diag.SelectedTile);
|
||||
if (TileName != diag.SelectedTile) isItem = diag.IsItem;
|
||||
TileName = diag.SelectedTile;
|
||||
|
||||
InterpolationCheckbox.Checked =
|
||||
bulkAnimationSpeedToolStripMenuItem.Enabled =
|
||||
importJavaAnimationToolStripMenuItem.Enabled =
|
||||
exportJavaAnimationToolStripMenuItem.Enabled =
|
||||
InterpolationCheckbox.Visible = !IsEditingSpecial;
|
||||
|
||||
foreach (JObject content in AnimationUtil.tileData[animationSection].Children())
|
||||
{
|
||||
var first = content.Properties().FirstOrDefault(p => p.Name == TileName);
|
||||
@@ -578,31 +387,39 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
SaveFileDialog fileDialog = new SaveFileDialog();
|
||||
fileDialog.Title = "Please choose where you want to save your new animation";
|
||||
|
||||
fileDialog.Filter = "Animation Scripts (*.mcmeta)|*.png.mcmeta";
|
||||
fileDialog.CheckPathExists = true;
|
||||
if (fileDialog.ShowDialog(this) != DialogResult.OK) return;
|
||||
if (fileDialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
JObject mcmeta = ConvertAnimationToJava(currentAnimation);
|
||||
string jsondata = JsonConvert.SerializeObject(mcmeta, Formatting.Indented);
|
||||
string filename = fileDialog.FileName;
|
||||
File.WriteAllText(filename, jsondata);
|
||||
var finalTexture = currentAnimation.BuildTexture(isClockOrCompass: false);
|
||||
finalTexture.Save(Path.GetFileNameWithoutExtension(filename)); // removes ".mcmeta" from filename!
|
||||
MessageBox.Show("Animation was successfully exported to " + filename, "Export successful!");
|
||||
}
|
||||
}
|
||||
|
||||
JObject mcmeta = new JObject();
|
||||
JObject animation = new JObject();
|
||||
JArray frames = new JArray();
|
||||
currentAnimation.GetFrames().ForEach(f => {
|
||||
JObject frame = new JObject();
|
||||
frame["index"] = currentAnimation.GetFrameIndex(f.Texture);
|
||||
frame["time"] = f.Ticks;
|
||||
frames.Add(frame);
|
||||
});
|
||||
animation["interpolation"] = InterpolationCheckbox.Checked;
|
||||
animation["frames"] = frames;
|
||||
mcmeta["comment"] = "Animation converted via PCK Studio";
|
||||
mcmeta["animation"] = animation;
|
||||
File.WriteAllText(fileDialog.FileName, JsonConvert.SerializeObject(mcmeta, Formatting.Indented));
|
||||
string fn = fileDialog.FileName;
|
||||
currentAnimation.BuildTexture().Save(fn.Remove(fn.Length - 7));
|
||||
MessageBox.Show("Your animation was successfully exported at " + fn, "Successful export");
|
||||
}
|
||||
private JObject ConvertAnimationToJava(Animation animation)
|
||||
{
|
||||
JObject janimation = new JObject();
|
||||
JObject mcmeta = new JObject();
|
||||
mcmeta["comment"] = $"Animation converted by {ProductName}";
|
||||
mcmeta["animation"] = janimation;
|
||||
JArray jframes = new JArray();
|
||||
foreach (var frame in animation.GetFrames())
|
||||
{
|
||||
JObject jframe = new JObject();
|
||||
jframe["index"] = animation.GetTextureIndex(frame.Texture);
|
||||
jframe["time"] = frame.Ticks;
|
||||
jframes.Add(jframe);
|
||||
};
|
||||
janimation["interpolation"] = InterpolationCheckbox.Checked;
|
||||
janimation["frames"] = jframes;
|
||||
return mcmeta;
|
||||
}
|
||||
|
||||
private void howToInterpolation_Click(object sender, EventArgs e)
|
||||
private void howToInterpolation_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("The Interpolation effect is when the animtion smoothly translates between the frames instead of simply displaying the next one. This can be seen with some vanilla Minecraft textures such as Magma and Prismarine.\n\nThe \"Interpolates\" checkbox at the bottom controls this.", "Interpolation");
|
||||
}
|
||||
@@ -629,5 +446,13 @@ namespace PckStudio.Forms.Editor
|
||||
// Interpolation flag wasn't being updated when the check box changed, this fixes the issue
|
||||
currentAnimation.Interpolate = InterpolationCheckbox.Checked;
|
||||
}
|
||||
}
|
||||
|
||||
private void AnimationEditor_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (player.IsPlaying)
|
||||
{
|
||||
player.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
76
PCK-Studio/Forms/Editor/AnimationPlayer.cs
Normal file
76
PCK-Studio/Forms/Editor/AnimationPlayer.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
// TODO: write as a UI control ??
|
||||
sealed class AnimationPlayer
|
||||
{
|
||||
public const int BaseTickSpeed = 48;
|
||||
public bool IsPlaying { get; private set; } = false;
|
||||
|
||||
private int currentAnimationFrameIndex = 0;
|
||||
private PictureBox display;
|
||||
private Animation _animation;
|
||||
private CancellationTokenSource cts = new CancellationTokenSource();
|
||||
|
||||
public AnimationPlayer(PictureBox display)
|
||||
{
|
||||
SetContext(display);
|
||||
}
|
||||
|
||||
private async void DoAnimate()
|
||||
{
|
||||
_ = display ?? throw new ArgumentNullException(nameof(display));
|
||||
_ = _animation ?? throw new ArgumentNullException(nameof(_animation));
|
||||
IsPlaying = true;
|
||||
while (!cts.IsCancellationRequested)
|
||||
{
|
||||
if (currentAnimationFrameIndex >= _animation.FrameCount)
|
||||
currentAnimationFrameIndex = 0;
|
||||
Animation.Frame frame = SetDisplayFrame(currentAnimationFrameIndex++);
|
||||
await Task.Delay(BaseTickSpeed * frame.Ticks);
|
||||
}
|
||||
IsPlaying = false;
|
||||
}
|
||||
|
||||
public void Start(Animation animation)
|
||||
{
|
||||
_animation = animation;
|
||||
cts = new CancellationTokenSource();
|
||||
Task.Run(DoAnimate, cts.Token);
|
||||
}
|
||||
|
||||
public void Stop([CallerMemberName] string callerName = default!)
|
||||
{
|
||||
Debug.WriteLine($"{nameof(AnimationPlayer.Stop)} called from {callerName}!");
|
||||
cts.Cancel();
|
||||
}
|
||||
|
||||
public Animation.Frame GetCurrentFrame() => _animation[currentAnimationFrameIndex];
|
||||
|
||||
public void SetContext(PictureBox display) => this.display = display;
|
||||
|
||||
public void SelectFrame(Animation animation, int index)
|
||||
{
|
||||
_animation = animation;
|
||||
if (IsPlaying)
|
||||
Stop();
|
||||
SetDisplayFrame(index);
|
||||
currentAnimationFrameIndex = index;
|
||||
}
|
||||
|
||||
private Animation.Frame SetDisplayFrame(int frameIndex)
|
||||
{
|
||||
Monitor.Enter(_animation);
|
||||
Animation.Frame frame = _animation[frameIndex];
|
||||
display.Image = frame;
|
||||
Monitor.Exit(_animation);
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
PCK-Studio/Forms/Editor/AudioEditor.Designer.cs
generated
2
PCK-Studio/Forms/Editor/AudioEditor.Designer.cs
generated
@@ -343,5 +343,7 @@ namespace PckStudio.Forms.Editor
|
||||
private MetroFramework.Controls.MetroLabel metroLabel1;
|
||||
private System.Windows.Forms.ToolStripMenuItem openDataFolderToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem bulkReplaceExistingTracksToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem changeCategoryToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem organizeTracksToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,18 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Diagnostics;
|
||||
using PckStudio.ToolboxItems;
|
||||
using MetroFramework.Forms;
|
||||
using NAudio.Wave;
|
||||
using PckStudio.Classes;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using PckStudio.Classes.IO.PCK;
|
||||
using OMI.Formats.Languages;
|
||||
using OMI.Formats.Pck;
|
||||
using PckStudio.Forms.Additional_Popups;
|
||||
using PckStudio.Forms.Additional_Popups.Audio;
|
||||
|
||||
// Audio Editor by MattNL
|
||||
@@ -18,9 +26,8 @@ namespace PckStudio.Forms.Editor
|
||||
public partial class AudioEditor : ThemeForm
|
||||
{
|
||||
public string defaultType = "yes";
|
||||
Classes.Bink BINK = new Classes.Bink();
|
||||
PCKAudioFile audioFile = null;
|
||||
PCKFile.FileData audioPCK;
|
||||
PckFile.FileData audioPCK;
|
||||
LOCFile loc;
|
||||
bool _isLittleEndian = false;
|
||||
MainForm parent = null;
|
||||
@@ -49,32 +56,40 @@ namespace PckStudio.Forms.Editor
|
||||
return (PCKAudioFile.AudioCategory.EAudioType)Categories.IndexOf(category);
|
||||
}
|
||||
|
||||
public AudioEditor(PCKFile.FileData file, LOCFile locFile, bool isLittleEndian)
|
||||
public AudioEditor(PckFile.FileData file, LOCFile locFile, bool isLittleEndian)
|
||||
{
|
||||
InitializeComponent();
|
||||
loc = locFile;
|
||||
_isLittleEndian = isLittleEndian;
|
||||
|
||||
BINK.SetUpBinka();
|
||||
|
||||
audioPCK = file;
|
||||
using (var stream = new MemoryStream(file.data))
|
||||
using (var stream = new MemoryStream(file.Data))
|
||||
{
|
||||
audioFile = PCKAudioFileReader.Read(stream, isLittleEndian);
|
||||
}
|
||||
|
||||
SetUpTree();
|
||||
}
|
||||
|
||||
public void SetUpTree()
|
||||
{
|
||||
treeView1.BeginUpdate();
|
||||
treeView1.Nodes.Clear();
|
||||
foreach (var category in audioFile.Categories)
|
||||
{
|
||||
if (category.Name == "include_overworld" &&
|
||||
category.audioType == PCKAudioFile.AudioCategory.EAudioType.Creative &&
|
||||
audioFile.TryGetCategory(PCKAudioFile.AudioCategory.EAudioType.Overworld, out PCKAudioFile.AudioCategory overworldCategory))
|
||||
if(category.audioType == PCKAudioFile.AudioCategory.EAudioType.Creative)
|
||||
{
|
||||
foreach (var name in category.SongNames.ToList())
|
||||
if (category.Name == "include_overworld" &&
|
||||
audioFile.TryGetCategory(PCKAudioFile.AudioCategory.EAudioType.Overworld, out PCKAudioFile.AudioCategory overworldCategory))
|
||||
{
|
||||
if (overworldCategory.SongNames.Contains(name))
|
||||
category.SongNames.Remove(name);
|
||||
foreach (var name in category.SongNames.ToList())
|
||||
{
|
||||
if (overworldCategory.SongNames.Contains(name))
|
||||
category.SongNames.Remove(name);
|
||||
}
|
||||
playOverworldInCreative.Checked = true;
|
||||
}
|
||||
playOverworldInCreative.Checked = true;
|
||||
playOverworldInCreative.Visible = true;
|
||||
}
|
||||
|
||||
TreeNode treeNode = new TreeNode(GetCategoryFromId(category.audioType), (int)category.audioType, (int)category.audioType);
|
||||
@@ -82,6 +97,7 @@ namespace PckStudio.Forms.Editor
|
||||
treeView1.Nodes.Add(treeNode);
|
||||
}
|
||||
playOverworldInCreative.Enabled = audioFile.HasCategory(PCKAudioFile.AudioCategory.EAudioType.Creative);
|
||||
treeView1.EndUpdate();
|
||||
}
|
||||
|
||||
private void AudioEditor_FormClosed(object sender, FormClosedEventArgs e)
|
||||
@@ -115,22 +131,31 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void addCategoryStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
string[] avalible = Categories.FindAll(str => !audioFile.HasCategory(GetCategoryId(str))).ToArray();
|
||||
if (avalible.Length > 0)
|
||||
string[] available = Categories.FindAll(str => !audioFile.HasCategory(GetCategoryId(str))).ToArray();
|
||||
if (available.Length > 0)
|
||||
{
|
||||
using AddCategory add = new AddCategory(avalible);
|
||||
using ItemSelectionPopUp add = new ItemSelectionPopUp(available);
|
||||
if (add.ShowDialog() == DialogResult.OK)
|
||||
audioFile.AddCategory(GetCategoryId(add.Category));
|
||||
audioFile.AddCategory(GetCategoryId(add.SelectedItem));
|
||||
else return;
|
||||
|
||||
var category = audioFile.GetCategory(GetCategoryId(add.Category));
|
||||
var category = audioFile.GetCategory(GetCategoryId(add.SelectedItem));
|
||||
|
||||
if (GetCategoryId(add.SelectedItem) == PCKAudioFile.AudioCategory.EAudioType.Creative)
|
||||
{
|
||||
playOverworldInCreative.Visible = true;
|
||||
playOverworldInCreative.Checked = false;
|
||||
}
|
||||
|
||||
TreeNode treeNode = new TreeNode(GetCategoryFromId(category.audioType), (int)category.audioType, (int)category.audioType);
|
||||
treeNode.Tag = category;
|
||||
treeView1.Nodes.Add(treeNode);
|
||||
|
||||
SetUpTree();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("All possible categories are used", "There are no more categories that could be added");
|
||||
MessageBox.Show("There are no more categories that could be added", "All possible categories are used");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +182,11 @@ namespace PckStudio.Forms.Editor
|
||||
if (treeView1.SelectedNode is TreeNode main &&
|
||||
audioFile.RemoveCategory(GetCategoryId(treeView1.SelectedNode.Text)))
|
||||
{
|
||||
if(GetCategoryId(treeView1.SelectedNode.Text) == PCKAudioFile.AudioCategory.EAudioType.Creative)
|
||||
{
|
||||
playOverworldInCreative.Visible = false;
|
||||
playOverworldInCreative.Checked = false;
|
||||
}
|
||||
treeView2.Nodes.Clear();
|
||||
main.Remove();
|
||||
}
|
||||
@@ -185,52 +215,109 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
async void ProcessEntries(string[] FileList)
|
||||
{
|
||||
int success = 0;
|
||||
int exitCode = 0;
|
||||
PleaseWait waitDiag = new PleaseWait();
|
||||
waitDiag.Show(this);
|
||||
foreach (string file in FileList)
|
||||
{
|
||||
if (Path.GetExtension(file) == ".binka" || Path.GetExtension(file) == ".wav")
|
||||
{
|
||||
string new_loc = Path.Combine(parent.GetDataPath(), Path.GetFileNameWithoutExtension(file) + ".binka");
|
||||
bool duplicate_song = false; // To handle if a file already in the pack is dropped back in
|
||||
if (File.Exists(new_loc))
|
||||
string songName = string.Join("_", Path.GetFileNameWithoutExtension(file).Split(Path.GetInvalidFileNameChars()));
|
||||
songName = Regex.Replace(songName, @"[^\u0000-\u007F]+", "_"); // Replace UTF characters
|
||||
string cacheSongLoc = Path.Combine(Program.AppDataCache, songName + Path.GetExtension(file));
|
||||
|
||||
if(File.Exists(cacheSongLoc)) File.Delete(cacheSongLoc);
|
||||
|
||||
string new_loc = Path.Combine(parent.GetDataPath(), songName + ".binka");
|
||||
bool is_duplicate_file = false; // To handle if a file already in the pack is dropped back in
|
||||
bool loc_is_occupied = File.Exists(new_loc);
|
||||
if (loc_is_occupied)
|
||||
{
|
||||
duplicate_song = File.ReadAllBytes(file) == File.ReadAllBytes(new_loc);
|
||||
if (duplicate_song)
|
||||
FileStream fs1 = File.OpenRead(file);
|
||||
FileStream fs2 = File.OpenRead(new_loc);
|
||||
|
||||
string hash1_str = BitConverter.ToString(MD5.Create().ComputeHash(fs1));
|
||||
string hash2_str = BitConverter.ToString(MD5.Create().ComputeHash(fs2));
|
||||
|
||||
// close the file streams after calculating the hash
|
||||
fs1.Close();
|
||||
fs2.Close();
|
||||
|
||||
is_duplicate_file = hash1_str == hash2_str;
|
||||
|
||||
string diag_text = "A file named \"" + Path.GetFileNameWithoutExtension(file) + ".binka\" already exists in the Data folder.";
|
||||
|
||||
if (is_duplicate_file) diag_text = "\"" + Path.GetFileNameWithoutExtension(file) + ".binka\" has an identical copy present in the Data folder.";
|
||||
|
||||
diag_text += " Pressing yes will replace the existing file. By pressing no, the song entry will be added without affecting the file." +
|
||||
"You can also cancel this operation and all files in queue.";
|
||||
|
||||
DialogResult user_prompt = MessageBox.Show(diag_text, "File already exists", MessageBoxButtons.YesNoCancel);
|
||||
while (user_prompt == DialogResult.None) ; // Stops the editor from adding or processing the file until the user has made their choice
|
||||
if (user_prompt == DialogResult.Cancel)
|
||||
{
|
||||
DialogResult user_prompt = MessageBox.Show("\"" + Path.GetFileNameWithoutExtension(file) + ".binka\" already exists. Continuing will replace the existing file. Are you sure you want to continue moving the file? By pressing no, the song entry will be added without moving the file. You can also cancel this operation and all files in queue.", "File already exists", MessageBoxButtons.YesNoCancel);
|
||||
while (user_prompt == DialogResult.None) ; // Stops the editor from adding or processing the file until the user had made their choice
|
||||
if (user_prompt == DialogResult.Cancel)
|
||||
break;
|
||||
}
|
||||
else if (user_prompt == DialogResult.No)
|
||||
{
|
||||
if (treeView1.SelectedNode is TreeNode node && node.Tag is PCKAudioFile.AudioCategory cat)
|
||||
{
|
||||
break;
|
||||
//adds song without affecting the binka file
|
||||
cat.SongNames.Add(songName);
|
||||
treeView2.Nodes.Add(songName);
|
||||
success++;
|
||||
}
|
||||
else if (user_prompt == DialogResult.No) continue;
|
||||
continue;
|
||||
}
|
||||
else if (user_prompt == DialogResult.Yes)
|
||||
{
|
||||
// deletes the file so that the copy function can happen safely
|
||||
// and ignore duplicate files because well... they're duplicates lol
|
||||
if (File.Exists(new_loc) && !is_duplicate_file) File.Delete(new_loc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (Path.GetExtension(file) == ".wav") // Convert Wave to BINKA
|
||||
{
|
||||
using (var reader = new WaveFileReader(file)) //read from original location
|
||||
{
|
||||
var newFormat = new WaveFormat(reader.WaveFormat.SampleRate, 16, reader.WaveFormat.Channels);
|
||||
using (var conversionStream = new WaveFormatConversionStream(newFormat, reader))
|
||||
{
|
||||
WaveFileWriter.CreateWaveFile(cacheSongLoc, conversionStream); //write to new location
|
||||
}
|
||||
reader.Close();
|
||||
reader.Dispose();
|
||||
}
|
||||
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
PleaseWait waitDiag = new PleaseWait();
|
||||
waitDiag.Show(this);
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
BINK.WavToBinka(file, new_loc, (int)compressionUpDown.Value);
|
||||
exitCode = Binka.FromWav(cacheSongLoc, new_loc, (int)compressionUpDown.Value);
|
||||
});
|
||||
|
||||
waitDiag.Close();
|
||||
waitDiag.Dispose();
|
||||
if (!File.Exists(cacheSongLoc)) MessageBox.Show(this, $"\"{songName}.wav\" failed to convert for some reason. Please reach out to MNL#8935 on the communtiy Discord server and provide details. Thanks!", "Conversion failed");
|
||||
else
|
||||
{
|
||||
success++;
|
||||
File.Delete(cacheSongLoc); //cleanup song
|
||||
}
|
||||
|
||||
Cursor.Current = Cursors.Default;
|
||||
|
||||
if (BINK.temp_error_code != 0) continue;
|
||||
}
|
||||
else if (!duplicate_song)
|
||||
{
|
||||
Console.WriteLine(Path.GetFileName(file));
|
||||
File.Delete(Path.Combine(parent.GetDataPath(), Path.GetFileName(file)));
|
||||
File.Copy(file, Path.Combine(parent.GetDataPath(), Path.GetFileName(file)));
|
||||
if (exitCode != 0) continue;
|
||||
}
|
||||
|
||||
var songName = Path.GetFileNameWithoutExtension(file);
|
||||
// if the file is NOT a .wav and doesn't exist, copy the file
|
||||
else if (!File.Exists(new_loc))
|
||||
{
|
||||
File.Copy(file, new_loc);
|
||||
success++;
|
||||
}
|
||||
|
||||
// this is repeated again becuase this is meant to prevent any files that fail to convert from being added to the category
|
||||
if (treeView1.SelectedNode is TreeNode t && t.Tag is PCKAudioFile.AudioCategory category)
|
||||
{
|
||||
category.SongNames.Add(songName);
|
||||
@@ -238,6 +325,10 @@ namespace PckStudio.Forms.Editor
|
||||
}
|
||||
}
|
||||
}
|
||||
waitDiag.Close();
|
||||
waitDiag.Dispose();
|
||||
|
||||
MessageBox.Show(this, $"Successfully processed and/or converted {success}/{FileList.Length} file{(FileList.Length != 1 ? "s" : "" )}", "Done!");
|
||||
}
|
||||
|
||||
private void Binka_DragDrop(object sender, DragEventArgs e)
|
||||
@@ -263,8 +354,26 @@ namespace PckStudio.Forms.Editor
|
||||
}
|
||||
|
||||
PCKAudioFile.AudioCategory overworldCategory = audioFile.GetCategory(PCKAudioFile.AudioCategory.EAudioType.Overworld);
|
||||
|
||||
bool songs_missing = false;
|
||||
foreach (var category in audioFile.Categories)
|
||||
{
|
||||
if (category.SongNames.Count < 1)
|
||||
{
|
||||
MessageBox.Show("The game will crash upon loading your pack if any of the categories are empty. Please remove or occupy the category.", "Empty Category");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach(var song in category.SongNames)
|
||||
{
|
||||
string FileName = Path.Combine(parent.GetDataPath(), song + ".binka");
|
||||
if (!File.Exists(FileName))
|
||||
{
|
||||
songs_missing = true;
|
||||
MessageBox.Show("\"" + song + ".binka\" does not exist in the \"Data\" folder. The game will crash when attempting to load this track.", "File missing");
|
||||
}
|
||||
}
|
||||
|
||||
category.Name = "";
|
||||
if (playOverworldInCreative.Checked && category.audioType == PCKAudioFile.AudioCategory.EAudioType.Creative)
|
||||
{
|
||||
@@ -280,11 +389,9 @@ namespace PckStudio.Forms.Editor
|
||||
}
|
||||
}
|
||||
|
||||
bool emptyCat = false;
|
||||
|
||||
if (emptyCat)
|
||||
if (songs_missing)
|
||||
{
|
||||
MessageBox.Show("The game will crash upon loading your pack if a category is empty", "Empty Category");
|
||||
MessageBox.Show("Failed to save AudioData file because there are missing song entries", "Error");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -362,15 +469,15 @@ namespace PckStudio.Forms.Editor
|
||||
MessageBox.Show("Categories are pretty self explanatory. The game controls when each category should play.\n" +
|
||||
"\nGAMEPLAY - Plays in the specified dimensions and game modes.\n" +
|
||||
"-Overworld: Plays in survival mode and in Creative if no songs are set\n" +
|
||||
"-Nether: Nothing special to note.\n" +
|
||||
"-End: Prioritizes the final track when the dragon is alive.\n" +
|
||||
"-Nether: Plays in the Nether.\n" +
|
||||
"-End: Plays in the End. Prioritizes the final track when the dragon is alive.\n" +
|
||||
"-Creative: Does not play survival tracks unless they're included.\n" +
|
||||
"-Menu: Plays on the title screen and only once when the pack is loading. Perfect for intro songs.\n" +
|
||||
"\nMINI GAMES - Will only play if you change the map grf files to load your pack and set the ThemeID to 0 for Vanilla maps.\n" +
|
||||
"-Battle: Plays in the Battle Mini Game.\n" +
|
||||
"-Tumble: Plays in the Tumble Mini Game.\n" +
|
||||
"-Glide: Plays in the Glide Mini Game.\n",
|
||||
"What is each category?");
|
||||
"What are the categories?");
|
||||
}
|
||||
|
||||
private void howToEditCreditsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
@@ -406,7 +513,10 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
if (!parent.CreateDataFolder()) return;
|
||||
|
||||
OpenFileDialog ofn = new OpenFileDialog();
|
||||
int exitCode = 0;
|
||||
|
||||
|
||||
OpenFileDialog ofn = new OpenFileDialog();
|
||||
ofn.Multiselect = true;
|
||||
ofn.Filter = "Supported audio files (*.binka,*.wav)|*.binka;*.wav";
|
||||
ofn.Title = "Please choose WAV or BINKA files to replace existing track files";
|
||||
@@ -438,16 +548,16 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
BINK.WavToBinka(file, new_loc, (int)compressionUpDown.Value);
|
||||
exitCode = Binka.FromWav(file, new_loc, (int)compressionUpDown.Value);
|
||||
});
|
||||
|
||||
waitDiag.Close();
|
||||
waitDiag.Dispose();
|
||||
Cursor.Current = Cursors.Default;
|
||||
|
||||
if (BINK.temp_error_code != 0) continue;
|
||||
if (exitCode != 0) continue;
|
||||
}
|
||||
else if(file_ext == ".binka") File.Copy(file, Path.Combine(parent.GetDataPath(), Path.GetFileName(file)));
|
||||
else if(file_ext == ".binka") File.Copy(file, Path.Combine(parent.GetDataPath(), Path.GetFileName(file)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,7 +565,60 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
if (treeView2.SelectedNode != null && treeView1.SelectedNode.Tag is PCKAudioFile.AudioCategory)
|
||||
{
|
||||
BINK.BinkaToWav(Path.Combine(parent.GetDataPath(), treeView2.SelectedNode.Text + ".binka"), Path.Combine(parent.GetDataPath()));
|
||||
Binka.ToWav(Path.Combine(parent.GetDataPath(), treeView2.SelectedNode.Text + ".binka"), Path.Combine(parent.GetDataPath()));
|
||||
}
|
||||
}
|
||||
|
||||
private void setCategoryToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!(treeView1.SelectedNode is TreeNode t && t.Tag is PCKAudioFile.AudioCategory category)) return;
|
||||
|
||||
string[] available = Categories.FindAll(str => !audioFile.HasCategory(GetCategoryId(str))).ToArray();
|
||||
if (available.Length > 0)
|
||||
{
|
||||
using ItemSelectionPopUp add = new ItemSelectionPopUp(available);
|
||||
add.okBtn.Text = "Save";
|
||||
if (add.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
audioFile.RemoveCategory(category.audioType);
|
||||
|
||||
audioFile.AddCategory(category.parameterType, GetCategoryId(add.SelectedItem), category.audioType == PCKAudioFile.AudioCategory.EAudioType.Overworld && playOverworldInCreative.Checked ? "include_overworld" : "");
|
||||
|
||||
var newCategory = audioFile.GetCategory(GetCategoryId(add.SelectedItem));
|
||||
|
||||
category.SongNames.ForEach(c => newCategory.SongNames.Add(c));
|
||||
|
||||
SetUpTree();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("There are no categories that aren't already used", "All possible categories are used");
|
||||
}
|
||||
}
|
||||
|
||||
private void organizeTracksToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if(MessageBox.Show("This function will move all binka files in the \"Data\" folder into a \"Music\" folder, to keep your data better organized. Would you like to continue?", "Move tracks?", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
if (treeView1.Nodes.Count < 1 || !parent.CreateDataFolder()) return;
|
||||
string musicdir = Path.Combine(parent.GetDataPath(), "Music");
|
||||
Directory.CreateDirectory(musicdir);
|
||||
foreach (var category in audioFile.Categories)
|
||||
{
|
||||
for (var i = 0; i < category.SongNames.Count; i++) // using standard for loop so the list can be modified
|
||||
{
|
||||
string song = category.SongNames[i];
|
||||
string songpath = Path.Combine(parent.GetDataPath(), song + ".binka");
|
||||
if (File.Exists(songpath))
|
||||
{
|
||||
File.Move(songpath, Path.Combine(musicdir, song + ".binka"));
|
||||
}
|
||||
|
||||
category.SongNames[i] = Path.Combine("Music", song.Replace(song, Path.GetFileNameWithoutExtension(songpath)));
|
||||
}
|
||||
}
|
||||
treeView2.Nodes.Clear();
|
||||
treeView1.SelectedNode = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,8 +145,14 @@
|
||||
<data name="removeCategoryStripMenuItem.Text" xml:space="preserve">
|
||||
<value>Remove Category</value>
|
||||
</data>
|
||||
<data name="changeCategoryToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>168, 22</value>
|
||||
</data>
|
||||
<data name="changeCategoryToolStripMenuItem.Text" xml:space="preserve">
|
||||
<value>Set Category</value>
|
||||
</data>
|
||||
<data name="contextMenuStrip1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>169, 48</value>
|
||||
<value>169, 70</value>
|
||||
</data>
|
||||
<data name=">>contextMenuStrip1.Name" xml:space="preserve">
|
||||
<value>contextMenuStrip1</value>
|
||||
@@ -456,6 +462,12 @@
|
||||
<data name="bulkReplaceExistingTracksToolStripMenuItem.Text" xml:space="preserve">
|
||||
<value>Bulk Replace Existing Tracks</value>
|
||||
</data>
|
||||
<data name="organizeTracksToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>220, 22</value>
|
||||
</data>
|
||||
<data name="organizeTracksToolStripMenuItem.Text" xml:space="preserve">
|
||||
<value>Organize Tracks</value>
|
||||
</data>
|
||||
<data name="toolsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>46, 20</value>
|
||||
</data>
|
||||
@@ -468,11 +480,11 @@
|
||||
<data name="howToAddSongsToolStripMenuItem.Text" xml:space="preserve">
|
||||
<value>How to add songs</value>
|
||||
</data>
|
||||
<data name="whatIsEachCategoryToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<data name="whatAreTheCategoriesToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>243, 22</value>
|
||||
</data>
|
||||
<data name="whatIsEachCategoryToolStripMenuItem.Text" xml:space="preserve">
|
||||
<value>What is each category?</value>
|
||||
<data name="whatAreTheCategoriesToolStripMenuItem.Text" xml:space="preserve">
|
||||
<value>What are the categories?</value>
|
||||
</data>
|
||||
<data name="howToEditCreditsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>243, 22</value>
|
||||
@@ -599,6 +611,9 @@
|
||||
<data name="playOverworldInCreative.Text" xml:space="preserve">
|
||||
<value>Play overworld songs in Creative</value>
|
||||
</data>
|
||||
<data name="playOverworldInCreative.Visible" type="System.Boolean, mscorlib">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name=">>playOverworldInCreative.Name" xml:space="preserve">
|
||||
<value>playOverworldInCreative</value>
|
||||
</data>
|
||||
@@ -3201,6 +3216,12 @@
|
||||
<data name=">>removeCategoryStripMenuItem.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=">>changeCategoryToolStripMenuItem.Name" xml:space="preserve">
|
||||
<value>changeCategoryToolStripMenuItem</value>
|
||||
</data>
|
||||
<data name=">>changeCategoryToolStripMenuItem.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=">>catImages.Name" xml:space="preserve">
|
||||
<value>catImages</value>
|
||||
</data>
|
||||
@@ -3249,6 +3270,12 @@
|
||||
<data name=">>bulkReplaceExistingTracksToolStripMenuItem.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=">>organizeTracksToolStripMenuItem.Name" xml:space="preserve">
|
||||
<value>organizeTracksToolStripMenuItem</value>
|
||||
</data>
|
||||
<data name=">>organizeTracksToolStripMenuItem.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=">>helpToolStripMenuItem.Name" xml:space="preserve">
|
||||
<value>helpToolStripMenuItem</value>
|
||||
</data>
|
||||
@@ -3261,10 +3288,10 @@
|
||||
<data name=">>howToAddSongsToolStripMenuItem.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=">>whatIsEachCategoryToolStripMenuItem.Name" xml:space="preserve">
|
||||
<value>whatIsEachCategoryToolStripMenuItem</value>
|
||||
<data name=">>whatAreTheCategoriesToolStripMenuItem.Name" xml:space="preserve">
|
||||
<value>whatAreTheCategoriesToolStripMenuItem</value>
|
||||
</data>
|
||||
<data name=">>whatIsEachCategoryToolStripMenuItem.Type" xml:space="preserve">
|
||||
<data name=">>whatAreTheCategoriesToolStripMenuItem.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=">>howToEditCreditsToolStripMenuItem.Name" xml:space="preserve">
|
||||
|
||||
319
PCK-Studio/Forms/Editor/BehaviourEditor.Designer.cs
generated
Normal file
319
PCK-Studio/Forms/Editor/BehaviourEditor.Designer.cs
generated
Normal file
@@ -0,0 +1,319 @@
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
partial class BehaviourEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BehaviourEditor));
|
||||
this.treeView1 = new System.Windows.Forms.TreeView();
|
||||
this.metroContextMenu1 = new MetroFramework.Controls.MetroContextMenu(this.components);
|
||||
this.addToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.addNewEntryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.addNewPositionOverrideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.renameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.MobIsTamedCheckbox = new MetroFramework.Controls.MetroCheckBox();
|
||||
this.MobHasSaddleCheckbox = new MetroFramework.Controls.MetroCheckBox();
|
||||
this.zUpDown = new System.Windows.Forms.NumericUpDown();
|
||||
this.yUpDown = new System.Windows.Forms.NumericUpDown();
|
||||
this.zLabel = new MetroFramework.Controls.MetroLabel();
|
||||
this.yLabel = new MetroFramework.Controls.MetroLabel();
|
||||
this.xUpDown = new System.Windows.Forms.NumericUpDown();
|
||||
this.xLabel = new MetroFramework.Controls.MetroLabel();
|
||||
this.metroContextMenu1.SuspendLayout();
|
||||
this.menuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.zUpDown)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.yUpDown)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.xUpDown)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// treeView1
|
||||
//
|
||||
this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.treeView1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.treeView1.ContextMenuStrip = this.metroContextMenu1;
|
||||
this.treeView1.ForeColor = System.Drawing.Color.White;
|
||||
this.treeView1.Location = new System.Drawing.Point(20, 84);
|
||||
this.treeView1.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.treeView1.Name = "treeView1";
|
||||
this.treeView1.Size = new System.Drawing.Size(186, 176);
|
||||
this.treeView1.TabIndex = 13;
|
||||
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
|
||||
this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick);
|
||||
this.treeView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeView1_KeyDown);
|
||||
this.treeView1.MouseHover += new System.EventHandler(this.treeView1_MouseHover);
|
||||
//
|
||||
// metroContextMenu1
|
||||
//
|
||||
this.metroContextMenu1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.addToolStripMenuItem,
|
||||
this.renameToolStripMenuItem,
|
||||
this.removeToolStripMenuItem});
|
||||
this.metroContextMenu1.Name = "metroContextMenu1";
|
||||
this.metroContextMenu1.Size = new System.Drawing.Size(118, 70);
|
||||
//
|
||||
// addToolStripMenuItem
|
||||
//
|
||||
this.addToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.addNewEntryToolStripMenuItem,
|
||||
this.addNewPositionOverrideToolStripMenuItem});
|
||||
this.addToolStripMenuItem.Name = "addToolStripMenuItem";
|
||||
this.addToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
|
||||
this.addToolStripMenuItem.Text = "Add";
|
||||
//
|
||||
// addNewEntryToolStripMenuItem
|
||||
//
|
||||
this.addNewEntryToolStripMenuItem.Name = "addNewEntryToolStripMenuItem";
|
||||
this.addNewEntryToolStripMenuItem.Size = new System.Drawing.Size(217, 22);
|
||||
this.addNewEntryToolStripMenuItem.Text = "Add New Entry";
|
||||
this.addNewEntryToolStripMenuItem.Click += new System.EventHandler(this.addNewEntryToolStripMenuItem_Click);
|
||||
//
|
||||
// addNewPositionOverrideToolStripMenuItem
|
||||
//
|
||||
this.addNewPositionOverrideToolStripMenuItem.Name = "addNewPositionOverrideToolStripMenuItem";
|
||||
this.addNewPositionOverrideToolStripMenuItem.Size = new System.Drawing.Size(217, 22);
|
||||
this.addNewPositionOverrideToolStripMenuItem.Text = "Add New Position Override";
|
||||
this.addNewPositionOverrideToolStripMenuItem.Click += new System.EventHandler(this.addNewPositionOverrideToolStripMenuItem_Click);
|
||||
//
|
||||
// renameToolStripMenuItem
|
||||
//
|
||||
this.renameToolStripMenuItem.Name = "renameToolStripMenuItem";
|
||||
this.renameToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
|
||||
this.renameToolStripMenuItem.Text = "Change";
|
||||
this.renameToolStripMenuItem.Click += new System.EventHandler(this.changeToolStripMenuItem_Click);
|
||||
//
|
||||
// removeToolStripMenuItem
|
||||
//
|
||||
this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
|
||||
this.removeToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
|
||||
this.removeToolStripMenuItem.Text = "Remove";
|
||||
this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click);
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
this.menuStrip.AutoSize = false;
|
||||
this.menuStrip.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem,
|
||||
this.helpToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(20, 60);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Size = new System.Drawing.Size(309, 24);
|
||||
this.menuStrip.TabIndex = 14;
|
||||
this.menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.saveToolStripMenuItem1});
|
||||
this.fileToolStripMenuItem.ForeColor = System.Drawing.Color.White;
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileToolStripMenuItem.Text = "File";
|
||||
//
|
||||
// saveToolStripMenuItem1
|
||||
//
|
||||
this.saveToolStripMenuItem1.Image = ((System.Drawing.Image)(resources.GetObject("saveToolStripMenuItem1.Image")));
|
||||
this.saveToolStripMenuItem1.Name = "saveToolStripMenuItem1";
|
||||
this.saveToolStripMenuItem1.Size = new System.Drawing.Size(98, 22);
|
||||
this.saveToolStripMenuItem1.Text = "Save";
|
||||
this.saveToolStripMenuItem1.Click += new System.EventHandler(this.saveToolStripMenuItem1_Click);
|
||||
//
|
||||
// helpToolStripMenuItem
|
||||
//
|
||||
this.helpToolStripMenuItem.ForeColor = System.Drawing.Color.White;
|
||||
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
|
||||
this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
|
||||
this.helpToolStripMenuItem.Text = "Help";
|
||||
//
|
||||
// MobIsTamedCheckbox
|
||||
//
|
||||
this.MobIsTamedCheckbox.AutoSize = true;
|
||||
this.MobIsTamedCheckbox.Enabled = false;
|
||||
this.MobIsTamedCheckbox.Location = new System.Drawing.Point(221, 104);
|
||||
this.MobIsTamedCheckbox.Name = "MobIsTamedCheckbox";
|
||||
this.MobIsTamedCheckbox.Size = new System.Drawing.Size(96, 15);
|
||||
this.MobIsTamedCheckbox.TabIndex = 22;
|
||||
this.MobIsTamedCheckbox.Text = "Mob is tamed";
|
||||
this.MobIsTamedCheckbox.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.MobIsTamedCheckbox.UseSelectable = true;
|
||||
this.MobIsTamedCheckbox.CheckedChanged += new System.EventHandler(this.MobIsTamedCheckbox_CheckedChanged);
|
||||
//
|
||||
// MobHasSaddleCheckbox
|
||||
//
|
||||
this.MobHasSaddleCheckbox.AutoSize = true;
|
||||
this.MobHasSaddleCheckbox.Enabled = false;
|
||||
this.MobHasSaddleCheckbox.Location = new System.Drawing.Point(221, 136);
|
||||
this.MobHasSaddleCheckbox.Name = "MobHasSaddleCheckbox";
|
||||
this.MobHasSaddleCheckbox.Size = new System.Drawing.Size(106, 15);
|
||||
this.MobHasSaddleCheckbox.TabIndex = 23;
|
||||
this.MobHasSaddleCheckbox.Text = "Mob has saddle";
|
||||
this.MobHasSaddleCheckbox.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.MobHasSaddleCheckbox.UseSelectable = true;
|
||||
this.MobHasSaddleCheckbox.CheckedChanged += new System.EventHandler(this.MobHasSaddleCheckbox_CheckedChanged);
|
||||
//
|
||||
// zUpDown
|
||||
//
|
||||
this.zUpDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(17)))), ((int)(((byte)(17)))));
|
||||
this.zUpDown.DecimalPlaces = 3;
|
||||
this.zUpDown.Enabled = false;
|
||||
this.zUpDown.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(204)))), ((int)(((byte)(204)))));
|
||||
this.zUpDown.Location = new System.Drawing.Point(254, 220);
|
||||
this.zUpDown.Maximum = new decimal(new int[] {
|
||||
255,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.zUpDown.Name = "zUpDown";
|
||||
this.zUpDown.Size = new System.Drawing.Size(75, 20);
|
||||
this.zUpDown.TabIndex = 29;
|
||||
this.zUpDown.ValueChanged += new System.EventHandler(this.zUpDown_ValueChanged);
|
||||
//
|
||||
// yUpDown
|
||||
//
|
||||
this.yUpDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(17)))), ((int)(((byte)(17)))));
|
||||
this.yUpDown.DecimalPlaces = 3;
|
||||
this.yUpDown.Enabled = false;
|
||||
this.yUpDown.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(204)))), ((int)(((byte)(204)))));
|
||||
this.yUpDown.Location = new System.Drawing.Point(254, 194);
|
||||
this.yUpDown.Maximum = new decimal(new int[] {
|
||||
255,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.yUpDown.Name = "yUpDown";
|
||||
this.yUpDown.Size = new System.Drawing.Size(75, 20);
|
||||
this.yUpDown.TabIndex = 28;
|
||||
this.yUpDown.ValueChanged += new System.EventHandler(this.yUpDown_ValueChanged);
|
||||
//
|
||||
// zLabel
|
||||
//
|
||||
this.zLabel.AutoSize = true;
|
||||
this.zLabel.Location = new System.Drawing.Point(221, 220);
|
||||
this.zLabel.Name = "zLabel";
|
||||
this.zLabel.Size = new System.Drawing.Size(20, 19);
|
||||
this.zLabel.TabIndex = 25;
|
||||
this.zLabel.Text = "Z:";
|
||||
this.zLabel.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// yLabel
|
||||
//
|
||||
this.yLabel.AutoSize = true;
|
||||
this.yLabel.Location = new System.Drawing.Point(222, 194);
|
||||
this.yLabel.Name = "yLabel";
|
||||
this.yLabel.Size = new System.Drawing.Size(20, 19);
|
||||
this.yLabel.TabIndex = 24;
|
||||
this.yLabel.Text = "Y:";
|
||||
this.yLabel.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// xUpDown
|
||||
//
|
||||
this.xUpDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(17)))), ((int)(((byte)(17)))));
|
||||
this.xUpDown.DecimalPlaces = 3;
|
||||
this.xUpDown.Enabled = false;
|
||||
this.xUpDown.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(204)))), ((int)(((byte)(204)))));
|
||||
this.xUpDown.Location = new System.Drawing.Point(254, 168);
|
||||
this.xUpDown.Maximum = new decimal(new int[] {
|
||||
255,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.xUpDown.Name = "xUpDown";
|
||||
this.xUpDown.Size = new System.Drawing.Size(75, 20);
|
||||
this.xUpDown.TabIndex = 31;
|
||||
this.xUpDown.ValueChanged += new System.EventHandler(this.xUpDown_ValueChanged);
|
||||
//
|
||||
// xLabel
|
||||
//
|
||||
this.xLabel.AutoSize = true;
|
||||
this.xLabel.Location = new System.Drawing.Point(222, 168);
|
||||
this.xLabel.Name = "xLabel";
|
||||
this.xLabel.Size = new System.Drawing.Size(20, 19);
|
||||
this.xLabel.TabIndex = 30;
|
||||
this.xLabel.Text = "X:";
|
||||
this.xLabel.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// BehaviourEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(349, 280);
|
||||
this.Controls.Add(this.xUpDown);
|
||||
this.Controls.Add(this.xLabel);
|
||||
this.Controls.Add(this.zUpDown);
|
||||
this.Controls.Add(this.yUpDown);
|
||||
this.Controls.Add(this.zLabel);
|
||||
this.Controls.Add(this.yLabel);
|
||||
this.Controls.Add(this.MobHasSaddleCheckbox);
|
||||
this.Controls.Add(this.MobIsTamedCheckbox);
|
||||
this.Controls.Add(this.menuStrip);
|
||||
this.Controls.Add(this.treeView1);
|
||||
this.Name = "BehaviourEditor";
|
||||
this.Resizable = false;
|
||||
this.Style = MetroFramework.MetroColorStyle.Silver;
|
||||
this.Text = "Behaviour Editor";
|
||||
this.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.metroContextMenu1.ResumeLayout(false);
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
this.menuStrip.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.zUpDown)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.yUpDown)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.xUpDown)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TreeView treeView1;
|
||||
private System.Windows.Forms.MenuStrip menuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
|
||||
private MetroFramework.Controls.MetroCheckBox MobIsTamedCheckbox;
|
||||
private MetroFramework.Controls.MetroCheckBox MobHasSaddleCheckbox;
|
||||
private System.Windows.Forms.NumericUpDown zUpDown;
|
||||
private System.Windows.Forms.NumericUpDown yUpDown;
|
||||
private MetroFramework.Controls.MetroLabel zLabel;
|
||||
private MetroFramework.Controls.MetroLabel yLabel;
|
||||
private System.Windows.Forms.NumericUpDown xUpDown;
|
||||
private MetroFramework.Controls.MetroLabel xLabel;
|
||||
private MetroFramework.Controls.MetroContextMenu metroContextMenu1;
|
||||
private System.Windows.Forms.ToolStripMenuItem addToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem renameToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem addNewPositionOverrideToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem addNewEntryToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
279
PCK-Studio/Forms/Editor/BehaviourEditor.cs
Normal file
279
PCK-Studio/Forms/Editor/BehaviourEditor.cs
Normal file
@@ -0,0 +1,279 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using MetroFramework.Forms;
|
||||
using PckStudio.Forms.Additional_Popups.EntityForms;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OMI.Formats.Behaviour;
|
||||
using OMI.Workers.Behaviour;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
public partial class BehaviourEditor : MetroForm
|
||||
{
|
||||
// Behaviours File Format research by Miku and MattNL
|
||||
private readonly PckFile.FileData _file;
|
||||
BehaviourFile behaviourFile;
|
||||
|
||||
void SetUpTree()
|
||||
{
|
||||
treeView1.BeginUpdate();
|
||||
treeView1.Nodes.Clear();
|
||||
foreach (var entry in behaviourFile.entries)
|
||||
{
|
||||
TreeNode EntryNode = new TreeNode(entry.name);
|
||||
|
||||
foreach (JObject content in Utilities.BehaviourUtil.entityData["entities"].Children())
|
||||
{
|
||||
var prop = content.Properties().FirstOrDefault(prop => prop.Name == entry.name);
|
||||
if (prop is JProperty)
|
||||
{
|
||||
EntryNode.Text = (string)prop.Value;
|
||||
EntryNode.ImageIndex = Utilities.BehaviourUtil.entityData["entities"].Children().ToList().IndexOf(content);
|
||||
EntryNode.SelectedImageIndex = EntryNode.ImageIndex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
EntryNode.Tag = entry;
|
||||
|
||||
foreach (var posOverride in entry.overrides)
|
||||
{
|
||||
TreeNode OverrideNode = new TreeNode("Position Override");
|
||||
OverrideNode.Tag = posOverride;
|
||||
EntryNode.Nodes.Add(OverrideNode);
|
||||
OverrideNode.ImageIndex = 103;
|
||||
OverrideNode.SelectedImageIndex = OverrideNode.ImageIndex;
|
||||
}
|
||||
|
||||
treeView1.Nodes.Add(EntryNode);
|
||||
}
|
||||
treeView1.EndUpdate();
|
||||
}
|
||||
|
||||
public BehaviourEditor(PckFile.FileData file)
|
||||
{
|
||||
InitializeComponent();
|
||||
_file = file;
|
||||
|
||||
using (var stream = new MemoryStream(file.Data))
|
||||
{
|
||||
var reader = new BehavioursReader();
|
||||
behaviourFile = reader.FromStream(stream);
|
||||
}
|
||||
|
||||
treeView1.ImageList = new ImageList();
|
||||
treeView1.ImageList.Images.AddRange(Utilities.BehaviourUtil.entityImages);
|
||||
treeView1.ImageList.ColorDepth = ColorDepth.Depth32Bit;
|
||||
SetUpTree();
|
||||
}
|
||||
|
||||
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
if (e.Node is null) return;
|
||||
|
||||
bool isValidOverride = e.Node.Tag is BehaviourFile.RiderPositionOverride.PositionOverride &&
|
||||
treeView1.SelectedNode != null;
|
||||
MobIsTamedCheckbox.Enabled = isValidOverride;
|
||||
MobHasSaddleCheckbox.Enabled = isValidOverride;
|
||||
xUpDown.Enabled = isValidOverride;
|
||||
yUpDown.Enabled = isValidOverride;
|
||||
zUpDown.Enabled = isValidOverride;
|
||||
renameToolStripMenuItem.Visible = !isValidOverride;
|
||||
|
||||
|
||||
if (isValidOverride)
|
||||
{
|
||||
var posOverride = e.Node.Tag as BehaviourFile.RiderPositionOverride.PositionOverride;
|
||||
MobIsTamedCheckbox.Checked = posOverride.EntityIsTamed;
|
||||
MobHasSaddleCheckbox.Checked = posOverride.EntityHasSaddle;
|
||||
xUpDown.Value = (decimal)posOverride.x;
|
||||
yUpDown.Value = (decimal)posOverride.y;
|
||||
zUpDown.Value = (decimal)posOverride.z;
|
||||
}
|
||||
}
|
||||
|
||||
private void removeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (treeView1.SelectedNode is null) return;
|
||||
treeView1.SelectedNode.Remove();
|
||||
}
|
||||
|
||||
private void MobIsTamedCheckbox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (treeView1.SelectedNode.Tag is BehaviourFile.RiderPositionOverride.PositionOverride posOverride)
|
||||
{
|
||||
posOverride.EntityIsTamed = MobIsTamedCheckbox.Checked;
|
||||
}
|
||||
}
|
||||
|
||||
private void MobHasSaddleCheckbox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (treeView1.SelectedNode.Tag is BehaviourFile.RiderPositionOverride.PositionOverride posOverride)
|
||||
{
|
||||
posOverride.EntityHasSaddle = MobHasSaddleCheckbox.Checked;
|
||||
}
|
||||
}
|
||||
|
||||
private void xUpDown_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (treeView1.SelectedNode.Tag is BehaviourFile.RiderPositionOverride.PositionOverride posOverride)
|
||||
{
|
||||
posOverride.x = (float)xUpDown.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private void yUpDown_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (treeView1.SelectedNode.Tag is BehaviourFile.RiderPositionOverride.PositionOverride posOverride)
|
||||
{
|
||||
posOverride.y = (float)yUpDown.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private void zUpDown_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (treeView1.SelectedNode.Tag is BehaviourFile.RiderPositionOverride.PositionOverride posOverride)
|
||||
{
|
||||
posOverride.z = (float)zUpDown.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private void changeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (treeView1.SelectedNode == null) return;
|
||||
if (!(treeView1.SelectedNode.Tag is BehaviourFile.RiderPositionOverride entry)) return;
|
||||
|
||||
var diag = new Additional_Popups.EntityForms.AddEntry(Utilities.BehaviourUtil.entityData, Utilities.BehaviourUtil.entityImages);
|
||||
diag.acceptBtn.Text = "Save";
|
||||
|
||||
if (diag.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (String.IsNullOrEmpty(diag.SelectedEntity)) return;
|
||||
if (behaviourFile.entries.FindAll(behaviour => behaviour.name == diag.SelectedEntity).Count() > 0)
|
||||
{
|
||||
MessageBox.Show(this, "You cannot have two entries for one entity. Please use the \"Add New Position Override\" tool to add multiple overrides for entities", "Error", MessageBoxButtons.OK);
|
||||
return;
|
||||
}
|
||||
|
||||
entry.name = diag.SelectedEntity;
|
||||
treeView1.SelectedNode.Tag = entry;
|
||||
|
||||
foreach (JObject content in Utilities.BehaviourUtil.entityData["entities"].Children())
|
||||
{
|
||||
var prop = content.Properties().FirstOrDefault(prop => prop.Name == entry.name);
|
||||
if (prop is JProperty)
|
||||
{
|
||||
treeView1.SelectedNode.Text = (string)prop.Value;
|
||||
treeView1.SelectedNode.ImageIndex = Utilities.BehaviourUtil.entityData["entities"].Children().ToList().IndexOf(content);
|
||||
treeView1.SelectedNode.SelectedImageIndex = treeView1.SelectedNode.ImageIndex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
||||
{
|
||||
MobIsTamedCheckbox.Enabled = false;
|
||||
MobHasSaddleCheckbox.Enabled = false;
|
||||
xUpDown.Enabled = false;
|
||||
yUpDown.Enabled = false;
|
||||
zUpDown.Enabled = false;
|
||||
}
|
||||
|
||||
private void addNewPositionOverrideToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (treeView1.SelectedNode.Tag is BehaviourFile.RiderPositionOverride.PositionOverride) treeView1.SelectedNode = treeView1.SelectedNode.Parent;
|
||||
|
||||
if (treeView1.SelectedNode.Tag is BehaviourFile.RiderPositionOverride)
|
||||
{
|
||||
TreeNode OverrideNode = new TreeNode("Position Override");
|
||||
OverrideNode.Tag = new BehaviourFile.RiderPositionOverride.PositionOverride();
|
||||
OverrideNode.ImageIndex = 103;
|
||||
OverrideNode.SelectedImageIndex = 103;
|
||||
treeView1.SelectedNode.Nodes.Add(OverrideNode);
|
||||
}
|
||||
}
|
||||
|
||||
private void addNewEntryToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var diag = new AddEntry(Utilities.BehaviourUtil.entityData, Utilities.BehaviourUtil.entityImages);
|
||||
|
||||
if(diag.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (string.IsNullOrEmpty(diag.SelectedEntity)) return;
|
||||
if (behaviourFile.entries.FindAll(behaviour => behaviour.name == diag.SelectedEntity).Count() > 0)
|
||||
{
|
||||
MessageBox.Show(this, "You cannot have two entries for one entity. Please use the \"Add New Position Override\" tool to add multiple overrides for entities", "Error", MessageBoxButtons.OK);
|
||||
return;
|
||||
}
|
||||
BehaviourFile.RiderPositionOverride NewOverride = new BehaviourFile.RiderPositionOverride(diag.SelectedEntity);
|
||||
|
||||
TreeNode NewOverrideNode = new TreeNode(NewOverride.name);
|
||||
NewOverrideNode.Tag = NewOverride;
|
||||
foreach (JObject content in Utilities.BehaviourUtil.entityData["entities"].Children())
|
||||
{
|
||||
var prop = content.Properties().FirstOrDefault(prop => prop.Name == NewOverride.name);
|
||||
if (prop is JProperty)
|
||||
{
|
||||
NewOverrideNode.Text = (string)prop.Value;
|
||||
NewOverrideNode.ImageIndex = Utilities.BehaviourUtil.entityData["entities"].Children().ToList().IndexOf(content);
|
||||
NewOverrideNode.SelectedImageIndex = NewOverrideNode.ImageIndex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
treeView1.Nodes.Add(NewOverrideNode);
|
||||
treeView1.SelectedNode = NewOverrideNode;
|
||||
|
||||
addNewPositionOverrideToolStripMenuItem_Click(sender, e); // adds a Position Override to the new Override
|
||||
}
|
||||
}
|
||||
|
||||
private void treeView1_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Delete) removeToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
|
||||
private void treeView1_MouseHover(object sender, EventArgs e)
|
||||
{
|
||||
addNewPositionOverrideToolStripMenuItem.Visible = treeView1.SelectedNode != null;
|
||||
}
|
||||
|
||||
private void saveToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
behaviourFile = new BehaviourFile();
|
||||
|
||||
foreach (TreeNode node in treeView1.Nodes)
|
||||
{
|
||||
if(node.Tag is BehaviourFile.RiderPositionOverride entry)
|
||||
{
|
||||
entry.overrides.Clear();
|
||||
Console.WriteLine();
|
||||
foreach (TreeNode overrideNode in node.Nodes)
|
||||
{
|
||||
if(overrideNode.Tag is BehaviourFile.RiderPositionOverride.PositionOverride overrideEntry)
|
||||
{
|
||||
entry.overrides.Add(overrideEntry);
|
||||
}
|
||||
}
|
||||
|
||||
behaviourFile.entries.Add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
var writer = new BehavioursWriter(behaviourFile);
|
||||
writer.WriteToStream(stream);
|
||||
_file.SetData(stream.ToArray());
|
||||
}
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
137
PCK-Studio/Forms/Editor/BehaviourEditor.resx
Normal file
137
PCK-Studio/Forms/Editor/BehaviourEditor.resx
Normal file
@@ -0,0 +1,137 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="metroContextMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>125, 17</value>
|
||||
</metadata>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="saveToolStripMenuItem1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vAAADrwBlbxySQAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4yMfEgaZUAAADfSURBVDhPYxg8
|
||||
QLt++3yTGbf/Fm599P/Nh49wfPXxq/+rTt37f+Dak/8gOSBgAGEMANIMxGBFyAasPf/0v8GE8//z1t8C
|
||||
y4HU4DIALIluwLpLL+HiMANAGKoNAWASCavv/n/57gPcgOvP3oENOXj7NViOoAFGU6791+k4ghWD5Aga
|
||||
QCyGakMAkODcU89R/I8Ng9TgNADk14dPn/8/c+kqVgySgwUqVBsCwAx49urN/zsPHmPFIDmaGvAXJInN
|
||||
38gYasBfqDYE0K7dOn/Wvut/sfkdGYPUgJI9VNuAAwYGAGn6yvdevWgPAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -4,34 +4,35 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using MetroFramework.Forms;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using PckStudio.Classes.IO.COL;
|
||||
using OMI.Formats.Color;
|
||||
using OMI.Formats.Pck;
|
||||
using OMI.Workers.Color;
|
||||
using PckStudio.ToolboxItems;
|
||||
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
public partial class COLEditor : ThemeForm
|
||||
{
|
||||
COLFile default_colourfile = COLFileReader.Read(new MemoryStream(Properties.Resources.tu69colours));
|
||||
COLFile colourfile;
|
||||
COLFile.ColorEntry clipboard_color;
|
||||
ColorContainer default_colourfile;
|
||||
ColorContainer colourfile;
|
||||
ColorContainer.Color clipboard_color;
|
||||
|
||||
private readonly PCKFile.FileData _file;
|
||||
private readonly PckFile.FileData _file;
|
||||
|
||||
List<TreeNode> colorCache = new List<TreeNode>();
|
||||
List<TreeNode> waterCache = new List<TreeNode>();
|
||||
List<TreeNode> underwaterCache = new List<TreeNode>();
|
||||
List<TreeNode> fogCache = new List<TreeNode>();
|
||||
|
||||
public COLEditor(PCKFile.FileData file)
|
||||
public COLEditor(PckFile.FileData file)
|
||||
{
|
||||
InitializeComponent();
|
||||
_file = file;
|
||||
|
||||
using(var stream = new MemoryStream(file.data))
|
||||
using(var stream = new MemoryStream(file.Data))
|
||||
{
|
||||
colourfile = COLFileReader.Read(stream);
|
||||
var reader = new COLFileReader();
|
||||
colourfile = reader.FromStream(stream);
|
||||
}
|
||||
|
||||
TU12ToolStripMenuItem.Click += (sender, e) => SetUpDefaultFile(sender, e, 0);
|
||||
@@ -48,32 +49,37 @@ namespace PckStudio.Forms.Editor
|
||||
TU69ToolStripMenuItem.Click += (sender, e) => SetUpDefaultFile(sender, e, 11);
|
||||
_1_9_1ToolStripMenuItem.Click += (sender, e) => SetUpDefaultFile(sender, e, 12);
|
||||
|
||||
SetUpTable(false);
|
||||
SetUpDefaultFile(null, EventArgs.Empty, 11, false);
|
||||
}
|
||||
|
||||
private void SetUpDefaultFile(object sender, EventArgs e, int ID)
|
||||
private void SetUpDefaultFile(object sender, EventArgs e, int ID, bool targetVersion = true)
|
||||
{
|
||||
var result = MessageBox.Show(this, "This function will set up your colour table to match that of the chosen version. You may lose some entries in the table. Are you sure you would like to continue?", "Target update version?", MessageBoxButtons.YesNo);
|
||||
if (result == DialogResult.No) return;
|
||||
|
||||
switch(ID)
|
||||
if(targetVersion)
|
||||
{
|
||||
case 0: using (var stream = new MemoryStream(Properties.Resources.tu12colours)) default_colourfile = COLFileReader.Read(stream); break;
|
||||
case 1: using (var stream = new MemoryStream(Properties.Resources.tu13colours)) default_colourfile = COLFileReader.Read(stream); break;
|
||||
case 2: using (var stream = new MemoryStream(Properties.Resources.tu14colours)) default_colourfile = COLFileReader.Read(stream); break;
|
||||
case 3: using (var stream = new MemoryStream(Properties.Resources.tu19colours)) default_colourfile = COLFileReader.Read(stream); break;
|
||||
case 4: using (var stream = new MemoryStream(Properties.Resources.tu31colours)) default_colourfile = COLFileReader.Read(stream); break;
|
||||
case 5: using (var stream = new MemoryStream(Properties.Resources.tu32colours)) default_colourfile = COLFileReader.Read(stream); break;
|
||||
case 6: using (var stream = new MemoryStream(Properties.Resources.tu43colours)) default_colourfile = COLFileReader.Read(stream); break;
|
||||
case 7: using (var stream = new MemoryStream(Properties.Resources.tu46colours)) default_colourfile = COLFileReader.Read(stream); break;
|
||||
case 8: using (var stream = new MemoryStream(Properties.Resources.tu51colours)) default_colourfile = COLFileReader.Read(stream); break;
|
||||
case 9: using (var stream = new MemoryStream(Properties.Resources.tu53colours)) default_colourfile = COLFileReader.Read(stream); break;
|
||||
case 10: using (var stream = new MemoryStream(Properties.Resources.tu54colours)) default_colourfile = COLFileReader.Read(stream); break;
|
||||
case 11: using (var stream = new MemoryStream(Properties.Resources.tu69colours)) default_colourfile = COLFileReader.Read(stream); break;
|
||||
case 12: using (var stream = new MemoryStream(Properties.Resources._1_91_colours)) default_colourfile = COLFileReader.Read(stream); break;
|
||||
var result = MessageBox.Show(this, "This function will set up your colour table to match that of the chosen version. You may lose some entries in the table. Are you sure you would like to continue?", "Target update version?", MessageBoxButtons.YesNo);
|
||||
if (result == DialogResult.No) return;
|
||||
}
|
||||
|
||||
var reader = new COLFileReader();
|
||||
|
||||
switch (ID)
|
||||
{
|
||||
case 0: using (var stream = new MemoryStream(Properties.Resources.tu12colours)) default_colourfile = reader.FromStream(stream); break;
|
||||
case 1: using (var stream = new MemoryStream(Properties.Resources.tu13colours)) default_colourfile = reader.FromStream(stream); break;
|
||||
case 2: using (var stream = new MemoryStream(Properties.Resources.tu14colours)) default_colourfile = reader.FromStream(stream); break;
|
||||
case 3: using (var stream = new MemoryStream(Properties.Resources.tu19colours)) default_colourfile = reader.FromStream(stream); break;
|
||||
case 4: using (var stream = new MemoryStream(Properties.Resources.tu31colours)) default_colourfile = reader.FromStream(stream); break;
|
||||
case 5: using (var stream = new MemoryStream(Properties.Resources.tu32colours)) default_colourfile = reader.FromStream(stream); break;
|
||||
case 6: using (var stream = new MemoryStream(Properties.Resources.tu43colours)) default_colourfile = reader.FromStream(stream); break;
|
||||
case 7: using (var stream = new MemoryStream(Properties.Resources.tu46colours)) default_colourfile = reader.FromStream(stream); break;
|
||||
case 8: using (var stream = new MemoryStream(Properties.Resources.tu51colours)) default_colourfile = reader.FromStream(stream); break;
|
||||
case 9: using (var stream = new MemoryStream(Properties.Resources.tu53colours)) default_colourfile = reader.FromStream(stream); break;
|
||||
case 10: using (var stream = new MemoryStream(Properties.Resources.tu54colours)) default_colourfile = reader.FromStream(stream); break;
|
||||
case 11: using (var stream = new MemoryStream(Properties.Resources.tu69colours)) default_colourfile = reader.FromStream(stream); break;
|
||||
case 12: using (var stream = new MemoryStream(Properties.Resources._1_91_colours)) default_colourfile = reader.FromStream(stream); break;
|
||||
default: return;
|
||||
}
|
||||
SetUpTable(true);
|
||||
SetUpTable(targetVersion);
|
||||
}
|
||||
|
||||
void SetUpTable(bool targetVersion)
|
||||
@@ -83,35 +89,35 @@ namespace PckStudio.Forms.Editor
|
||||
underwaterTreeView.Nodes.Clear();
|
||||
fogTreeView.Nodes.Clear();
|
||||
|
||||
COLFile temp = targetVersion ? default_colourfile : colourfile;
|
||||
ColorContainer temp = targetVersion ? default_colourfile : colourfile;
|
||||
|
||||
List<string> CurrentEntries = new List<string>();
|
||||
|
||||
foreach (var obj in temp.entries)
|
||||
foreach (var obj in temp.Colors)
|
||||
{
|
||||
COLFile.ColorEntry entry = colourfile.entries.Find(color => color.name == obj.name);
|
||||
TreeNode tn = new TreeNode(obj.name);
|
||||
var entry = colourfile.Colors.Find(color => color.Name == obj.Name);
|
||||
TreeNode tn = new TreeNode(obj.Name);
|
||||
tn.Tag = entry != null ? entry : obj;
|
||||
if (CurrentEntries.Contains(obj.name)) continue;
|
||||
CurrentEntries.Add(obj.name);
|
||||
if (CurrentEntries.Contains(obj.Name)) continue;
|
||||
CurrentEntries.Add(obj.Name);
|
||||
colorTreeView.Nodes.Add(tn);
|
||||
colorCache.Add(tn);
|
||||
}
|
||||
CurrentEntries.Clear();
|
||||
foreach (var obj in temp.waterEntries)
|
||||
foreach (var obj in temp.WaterColors)
|
||||
{
|
||||
COLFile.ExtendedColorEntry entry = colourfile.waterEntries.Find(color => color.name == obj.name);
|
||||
TreeNode tn = new TreeNode(obj.name);
|
||||
var entry = colourfile.WaterColors.Find(color => color.Name == obj.Name);
|
||||
TreeNode tn = new TreeNode(obj.Name);
|
||||
tn.Tag = entry != null ? entry : obj;
|
||||
if (CurrentEntries.Contains(obj.name)) continue;
|
||||
CurrentEntries.Add(obj.name);
|
||||
if (CurrentEntries.Contains(obj.Name)) continue;
|
||||
CurrentEntries.Add(obj.Name);
|
||||
waterTreeView.Nodes.Add(tn);
|
||||
waterCache.Add(tn);
|
||||
TreeNode tnB = new TreeNode(obj.name);
|
||||
TreeNode tnB = new TreeNode(obj.Name);
|
||||
tnB.Tag = entry != null ? entry : obj;
|
||||
underwaterTreeView.Nodes.Add(tnB);
|
||||
underwaterCache.Add(tnB);
|
||||
TreeNode tnC = new TreeNode(obj.name);
|
||||
TreeNode tnC = new TreeNode(obj.Name);
|
||||
tnC.Tag = entry != null ? entry : obj;
|
||||
fogTreeView.Nodes.Add(tnC);
|
||||
fogCache.Add(tnC);
|
||||
@@ -141,8 +147,8 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
if (colorTreeView.SelectedNode.Tag == null)
|
||||
return;
|
||||
var colorEntry = (COLFile.ColorEntry)colorTreeView.SelectedNode.Tag;
|
||||
var color = colorEntry.color;
|
||||
var colorEntry = (ColorContainer.Color)colorTreeView.SelectedNode.Tag;
|
||||
var color = colorEntry.ColorPallette.ToArgb();
|
||||
SetUpValueChanged(false);
|
||||
//alphaUpDown.Visible = false;
|
||||
//alphaLabel.Visible = false;
|
||||
@@ -157,8 +163,8 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
if (waterTreeView.SelectedNode.Tag == null)
|
||||
return;
|
||||
var colorEntry = (COLFile.ExtendedColorEntry)waterTreeView.SelectedNode.Tag;
|
||||
int color = (int)colorEntry.color;
|
||||
var colorEntry = (ColorContainer.WaterColor)waterTreeView.SelectedNode.Tag;
|
||||
int color = colorEntry.SurfaceColor.ToArgb();
|
||||
SetUpValueChanged(false);
|
||||
//alphaUpDown.Enabled = true;
|
||||
//alphaUpDown.Visible = true;
|
||||
@@ -175,8 +181,8 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
if (underwaterTreeView.SelectedNode.Tag == null)
|
||||
return;
|
||||
var colorEntry = (COLFile.ExtendedColorEntry)underwaterTreeView.SelectedNode.Tag;
|
||||
int color = (int)colorEntry.color_b;
|
||||
var colorEntry = (ColorContainer.WaterColor)underwaterTreeView.SelectedNode.Tag;
|
||||
int color = colorEntry.UnderwaterColor.ToArgb();
|
||||
SetUpValueChanged(false);
|
||||
//alphaUpDown.Visible = false;
|
||||
alphaLabel.Visible = false;
|
||||
@@ -191,8 +197,8 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
if (fogTreeView.SelectedNode.Tag == null)
|
||||
return;
|
||||
var colorEntry = (COLFile.ExtendedColorEntry)fogTreeView.SelectedNode.Tag;
|
||||
int color = (int)colorEntry.color_c;
|
||||
var colorEntry = (ColorContainer.WaterColor)fogTreeView.SelectedNode.Tag;
|
||||
int color = colorEntry.FogColor.ToArgb();
|
||||
SetUpValueChanged(false);
|
||||
//alphaUpDown.Visible = false;
|
||||
alphaLabel.Visible = false;
|
||||
@@ -214,15 +220,15 @@ namespace PckStudio.Forms.Editor
|
||||
"mega_taiga_mutated"
|
||||
};
|
||||
|
||||
if (colourfile.waterEntries.Find(e => PS4Biomes.Contains(e.name)) != null)
|
||||
if (colourfile.WaterColors.Find(e => PS4Biomes.Contains(e.Name)) != null)
|
||||
{
|
||||
var result = MessageBox.Show(this, "Biomes exclusive to PS4 Edition v1.91 were found in the water section of this colour table. This will crash all other editions of the game and PS4 Edition v1.90 and below. Would you like to remove them?", "Potentially unsupported biomes found", MessageBoxButtons.YesNoCancel);
|
||||
switch (result)
|
||||
{
|
||||
case DialogResult.Yes:
|
||||
foreach (var col in colourfile.waterEntries)
|
||||
foreach (var col in colourfile.WaterColors.ToList())
|
||||
{
|
||||
if(PS4Biomes.Contains(col.name)) colourfile.waterEntries.Remove(col);
|
||||
if(PS4Biomes.Contains(col.Name)) colourfile.WaterColors.Remove(col);
|
||||
}
|
||||
break;
|
||||
case DialogResult.No:
|
||||
@@ -233,45 +239,25 @@ namespace PckStudio.Forms.Editor
|
||||
}
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
COLFileWriter.Write(stream, colourfile);
|
||||
var writer = new COLFileWriter(colourfile);
|
||||
writer.WriteToStream(stream);
|
||||
_file.SetData(stream.ToArray());
|
||||
}
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
static byte[] StringToByteArrayFastest(string hex)
|
||||
{
|
||||
if (hex.Length % 2 == 1)
|
||||
throw new Exception("The binary key cannot have an odd number of digits");
|
||||
|
||||
byte[] arr = new byte[hex.Length >> 1];
|
||||
|
||||
for (int i = 0; i < hex.Length >> 1; ++i)
|
||||
{
|
||||
arr[i] = (byte)((GetHexVal(hex[i << 1]) << 4) + (GetHexVal(hex[(i << 1) + 1])));
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
static int GetHexVal(char hex)
|
||||
{
|
||||
int val = hex;
|
||||
return val - (val < 58 ? 48 : (val < 97 ? 55 : 87));
|
||||
}
|
||||
|
||||
public void treeView1_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
var node = colorTreeView.SelectedNode;
|
||||
if (e.KeyCode == Keys.Delete && node.Tag is COLFile.ColorEntry)
|
||||
if (e.KeyCode == Keys.Delete && node.Tag is ColorContainer.Color)
|
||||
{
|
||||
restoreOriginalColorToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
else if (e.Control && e.KeyCode == Keys.C && node.Tag is COLFile.ColorEntry)
|
||||
else if (e.Control && e.KeyCode == Keys.C && node.Tag is ColorContainer.Color)
|
||||
{
|
||||
copyColorToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
else if (e.Control && e.KeyCode == Keys.V && node.Tag is COLFile.ColorEntry)
|
||||
else if (e.Control && e.KeyCode == Keys.V && node.Tag is ColorContainer.Color)
|
||||
{
|
||||
pasteColorToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
@@ -280,15 +266,15 @@ namespace PckStudio.Forms.Editor
|
||||
private void treeView2_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
var node = waterTreeView.SelectedNode;
|
||||
if (e.KeyCode == Keys.Delete && node.Tag is COLFile.ExtendedColorEntry)
|
||||
if (e.KeyCode == Keys.Delete && node.Tag is ColorContainer.WaterColor)
|
||||
{
|
||||
restoreOriginalColorToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
else if (e.Control && e.KeyCode == Keys.C && node.Tag is COLFile.ExtendedColorEntry)
|
||||
else if (e.Control && e.KeyCode == Keys.C && node.Tag is ColorContainer.WaterColor)
|
||||
{
|
||||
copyColorToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
else if (e.Control && e.KeyCode == Keys.V && node.Tag is COLFile.ExtendedColorEntry)
|
||||
else if (e.Control && e.KeyCode == Keys.V && node.Tag is ColorContainer.WaterColor)
|
||||
{
|
||||
pasteColorToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
@@ -297,15 +283,15 @@ namespace PckStudio.Forms.Editor
|
||||
private void treeView3_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
var node = underwaterTreeView.SelectedNode;
|
||||
if (e.KeyCode == Keys.Delete && node.Tag is COLFile.ExtendedColorEntry)
|
||||
if (e.KeyCode == Keys.Delete && node.Tag is ColorContainer.WaterColor)
|
||||
{
|
||||
restoreOriginalColorToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
else if (e.Control && e.KeyCode == Keys.C && node.Tag is COLFile.ExtendedColorEntry)
|
||||
else if (e.Control && e.KeyCode == Keys.C && node.Tag is ColorContainer.WaterColor)
|
||||
{
|
||||
copyColorToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
else if (e.Control && e.KeyCode == Keys.V && node.Tag is COLFile.ExtendedColorEntry)
|
||||
else if (e.Control && e.KeyCode == Keys.V && node.Tag is ColorContainer.WaterColor)
|
||||
{
|
||||
pasteColorToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
@@ -314,15 +300,15 @@ namespace PckStudio.Forms.Editor
|
||||
private void treeView4_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
var node = fogTreeView.SelectedNode;
|
||||
if (e.KeyCode == Keys.Delete && node.Tag is COLFile.ExtendedColorEntry)
|
||||
if (e.KeyCode == Keys.Delete && node.Tag is ColorContainer.WaterColor)
|
||||
{
|
||||
restoreOriginalColorToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
else if (e.Control && e.KeyCode == Keys.C && node.Tag is COLFile.ExtendedColorEntry)
|
||||
else if (e.Control && e.KeyCode == Keys.C && node.Tag is ColorContainer.WaterColor)
|
||||
{
|
||||
copyColorToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
else if (e.Control && e.KeyCode == Keys.V && node.Tag is COLFile.ExtendedColorEntry)
|
||||
else if (e.Control && e.KeyCode == Keys.V && node.Tag is ColorContainer.WaterColor)
|
||||
{
|
||||
pasteColorToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
@@ -353,96 +339,59 @@ namespace PckStudio.Forms.Editor
|
||||
//pictureBox1.BackColor = Color.FromArgb(argb);
|
||||
}
|
||||
|
||||
private void color_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
Color fixed_color = new Color();
|
||||
if (tabControl.SelectedTab == colorsTab)
|
||||
{
|
||||
var colorEntry = (COLFile.ColorEntry)colorTreeView.SelectedNode.Tag;
|
||||
//fixed_color = Color.FromArgb(255, (int)redUpDown.Value, (int)greenUpDown.Value, (int)blueUpDown.Value);
|
||||
colorEntry.color = (uint)(((255 << 24) | (fixed_color.R << 16) | (fixed_color.G << 8) | fixed_color.B) & 0xffffffffL);
|
||||
}
|
||||
else if (tabControl.SelectedTab != null && waterTreeView.SelectedNode != null) // just in case
|
||||
{
|
||||
var colorEntry = (COLFile.ExtendedColorEntry)waterTreeView.SelectedNode.Tag;
|
||||
//fixed_color = Color.FromArgb(tabControl.SelectedTab == waterTab ? (int)alphaUpDown.Value : 255, (int)redUpDown.Value, (int)greenUpDown.Value, (int)blueUpDown.Value);
|
||||
uint value = (uint)(((fixed_color.A << 24) | (fixed_color.R << 16) | (fixed_color.G << 8) | fixed_color.B) & 0xffffffffL);
|
||||
if (tabControl.SelectedTab == waterTab) colorEntry.color = value;
|
||||
else if (tabControl.SelectedTab == underwaterTab) colorEntry.color_b = value;
|
||||
else colorEntry.color_c = value;
|
||||
fixed_color = Color.FromArgb((int)value);
|
||||
}
|
||||
|
||||
pictureBox1.BackColor = fixed_color;
|
||||
}
|
||||
|
||||
private void setColorBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void alpha_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (tabControl.SelectedTab == waterTab && waterTreeView.SelectedNode != null &&
|
||||
waterTreeView.SelectedNode.Tag != null && waterTreeView.SelectedNode.Tag is COLFile.ExtendedColorEntry)
|
||||
waterTreeView.SelectedNode.Tag != null && waterTreeView.SelectedNode.Tag is ColorContainer.WaterColor)
|
||||
{
|
||||
//NML Miku PhoenixARC, more errors
|
||||
var colorEntry = ((COLFile.ExtendedColorEntry)waterTreeView.SelectedNode.Tag);
|
||||
//Color fixed_color = Color.FromArgb((int)alphaUpDown.Value, Color.FromArgb((int)colorEntry.color));
|
||||
//colorEntry.color = (uint)fixed_color.ToArgb();
|
||||
//pictureBox1.BackColor = fixed_color;
|
||||
}
|
||||
}
|
||||
var colorEntry = (ColorContainer.WaterColor)waterTreeView.SelectedNode.Tag;
|
||||
//pictureBox1.BackColor = colorEntry.SurfaceColor = Color.FromArgb((int)alphaUpDown.Value, colorEntry.SurfaceColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void restoreOriginalColorToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SetUpValueChanged(false);
|
||||
if (tabControl.SelectedTab == colorsTab && colorTreeView.SelectedNode != null &&
|
||||
colorTreeView.SelectedNode.Tag != null && colorTreeView.SelectedNode.Tag is COLFile.ColorEntry colorInfoD)
|
||||
colorTreeView.SelectedNode.Tag != null && colorTreeView.SelectedNode.Tag is ColorContainer.Color colorInfoD)
|
||||
{
|
||||
COLFile.ColorEntry entry = default_colourfile.entries.Find(color => color.name == colorTreeView.SelectedNode.Text);
|
||||
colorInfoD.color = entry.color;
|
||||
//redUpDown.Value = colorInfoD.color >> 16 & 0xff;
|
||||
//greenUpDown.Value = colorInfoD.color >> 8 & 0xff;
|
||||
//blueUpDown.Value = colorInfoD.color & 0xff;
|
||||
pictureBox1.BackColor = Color.FromArgb(0xff << 24 | (int)colorInfoD.color);
|
||||
var entry = default_colourfile.Colors.Find(color => color.Name == colorTreeView.SelectedNode.Text);
|
||||
colorInfoD.ColorPallette = entry.ColorPallette;
|
||||
UpdateDisplayColor(entry.ColorPallette);
|
||||
}
|
||||
else if (tabControl.SelectedTab == waterTab && waterTreeView.SelectedNode != null &&
|
||||
waterTreeView.SelectedNode.Tag != null && waterTreeView.SelectedNode.Tag is COLFile.ExtendedColorEntry colorInfo)
|
||||
waterTreeView.SelectedNode.Tag != null && waterTreeView.SelectedNode.Tag is ColorContainer.WaterColor colorInfo)
|
||||
{
|
||||
COLFile.ExtendedColorEntry entry = default_colourfile.waterEntries.Find(color => color.name == waterTreeView.SelectedNode.Text);
|
||||
colorInfo.color = entry.color;
|
||||
//alphaUpDown.Value = colorInfo.color >> 24 & 0xff;
|
||||
//redUpDown.Value = colorInfo.color >> 16 & 0xff;
|
||||
//greenUpDown.Value = colorInfo.color >> 8 & 0xff;
|
||||
//blueUpDown.Value = colorInfo.color & 0xff;
|
||||
pictureBox1.BackColor = Color.FromArgb((int)colorInfo.color);
|
||||
var entry = default_colourfile.WaterColors.Find(color => color.Name == waterTreeView.SelectedNode.Text);
|
||||
colorInfo.SurfaceColor = entry.SurfaceColor;
|
||||
UpdateDisplayColor(entry.SurfaceColor);
|
||||
}
|
||||
else if (tabControl.SelectedTab == underwaterTab && underwaterTreeView.SelectedNode != null &&
|
||||
underwaterTreeView.SelectedNode.Tag != null && underwaterTreeView.SelectedNode.Tag is COLFile.ExtendedColorEntry colorInfoB)
|
||||
underwaterTreeView.SelectedNode.Tag != null && underwaterTreeView.SelectedNode.Tag is ColorContainer.WaterColor colorInfoB)
|
||||
{
|
||||
COLFile.ExtendedColorEntry entry = default_colourfile.waterEntries.Find(color => color.name == underwaterTreeView.SelectedNode.Text);
|
||||
colorInfoB.color_b = entry.color_b;
|
||||
//alphaUpDown.Value = colorInfoB.color_b >> 24 & 0xff;
|
||||
//redUpDown.Value = colorInfoB.color_b >> 16 & 0xff;
|
||||
//greenUpDown.Value = colorInfoB.color_b >> 8 & 0xff;
|
||||
//blueUpDown.Value = colorInfoB.color_b & 0xff;
|
||||
pictureBox1.BackColor = Color.FromArgb(0xff << 24 | (int)colorInfoB.color_b);
|
||||
var entry = default_colourfile.WaterColors.Find(color => color.Name == underwaterTreeView.SelectedNode.Text);
|
||||
colorInfoB.UnderwaterColor = entry.UnderwaterColor;
|
||||
UpdateDisplayColor(entry.UnderwaterColor);
|
||||
}
|
||||
else if (tabControl.SelectedTab == fogTab && fogTreeView.SelectedNode != null &&
|
||||
fogTreeView.SelectedNode.Tag != null && fogTreeView.SelectedNode.Tag is COLFile.ExtendedColorEntry colorInfoC)
|
||||
fogTreeView.SelectedNode.Tag != null && fogTreeView.SelectedNode.Tag is ColorContainer.WaterColor colorInfoC)
|
||||
{
|
||||
COLFile.ExtendedColorEntry entry = default_colourfile.waterEntries.Find(color => color.name == fogTreeView.SelectedNode.Text);
|
||||
colorInfoC.color_c = entry.color_c;
|
||||
//alphaUpDown.Value = colorInfoC.color_c >> 24 & 0xff;
|
||||
//redUpDown.Value = colorInfoC.color_c >> 16 & 0xff;
|
||||
//greenUpDown.Value = colorInfoC.color_c >> 8 & 0xff;
|
||||
//blueUpDown.Value = colorInfoC.color_c & 0xff;
|
||||
//pictureBox1.BackColor = Color.FromArgb(0xff << 24 | (int)colorInfoC.color_c);
|
||||
var entry = default_colourfile.WaterColors.Find(color => color.Name == fogTreeView.SelectedNode.Text);
|
||||
colorInfoC.FogColor = entry.FogColor;
|
||||
UpdateDisplayColor(entry.FogColor);
|
||||
}
|
||||
SetUpValueChanged(true);
|
||||
SetUpValueChanged(true);
|
||||
}
|
||||
|
||||
private void UpdateDisplayColor(Color color)
|
||||
{
|
||||
//alphaUpDown.Value = color.A;
|
||||
//redUpDown.Value = color.R;
|
||||
//greenUpDown.Value = color.G;
|
||||
//blueUpDown.Value = color.B;
|
||||
pictureBox1.BackColor = Color.FromArgb(tabControl.SelectedTab == colorsTab ? 0xFF : color.A, color);
|
||||
}
|
||||
|
||||
private void metroTextBox1_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
// Some code in this function is modified code from this StackOverflow answer - MattNL
|
||||
@@ -516,22 +465,26 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void copyColorToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
COLFile.ColorEntry colorToCopy = new COLFile.ColorEntry("", 0);
|
||||
if (tabControl.SelectedTab == colorsTab && colorTreeView.SelectedNode.Tag is COLFile.ColorEntry colorInfoD)
|
||||
var colorToCopy = new ColorContainer.Color()
|
||||
{
|
||||
Name = "",
|
||||
ColorPallette = new Color()
|
||||
};
|
||||
if (tabControl.SelectedTab == colorsTab && colorTreeView.SelectedNode.Tag is ColorContainer.Color colorInfoD)
|
||||
{
|
||||
colorToCopy = colorInfoD;
|
||||
}
|
||||
else if (tabControl.SelectedTab == waterTab && waterTreeView.SelectedNode.Tag is COLFile.ExtendedColorEntry colorInfo)
|
||||
else if (tabControl.SelectedTab == waterTab && waterTreeView.SelectedNode.Tag is ColorContainer.WaterColor colorInfo)
|
||||
{
|
||||
colorToCopy = colorInfo;
|
||||
colorToCopy.ColorPallette = colorInfo.SurfaceColor;
|
||||
}
|
||||
else if (tabControl.SelectedTab == underwaterTab && underwaterTreeView.SelectedNode.Tag is COLFile.ExtendedColorEntry colorInfoB)
|
||||
else if (tabControl.SelectedTab == underwaterTab && underwaterTreeView.SelectedNode.Tag is ColorContainer.WaterColor colorInfoB)
|
||||
{
|
||||
colorToCopy = colorInfoB;
|
||||
colorToCopy.ColorPallette = colorInfoB.UnderwaterColor;
|
||||
}
|
||||
else if (tabControl.SelectedTab == fogTab && fogTreeView.SelectedNode.Tag is COLFile.ExtendedColorEntry colorInfoC)
|
||||
else if (tabControl.SelectedTab == fogTab && fogTreeView.SelectedNode.Tag is ColorContainer.WaterColor colorInfoC)
|
||||
{
|
||||
colorToCopy = colorInfoC;
|
||||
colorToCopy.ColorPallette = colorInfoC.FogColor;
|
||||
}
|
||||
clipboard_color = colorToCopy;
|
||||
}
|
||||
@@ -540,31 +493,31 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
if (clipboard_color == null) return;
|
||||
SetUpValueChanged(false);
|
||||
Color fixed_color = Color.FromArgb(255, Color.FromArgb(0xff << 24 | (int)clipboard_color.color));
|
||||
Color fixed_color = Color.FromArgb(255, Color.FromArgb(0xff, clipboard_color.ColorPallette));
|
||||
|
||||
if (tabControl.SelectedTab == waterTab && waterTreeView.SelectedNode != null &&
|
||||
waterTreeView.SelectedNode.Tag != null && waterTreeView.SelectedNode.Tag is COLFile.ExtendedColorEntry)
|
||||
waterTreeView.SelectedNode.Tag != null && waterTreeView.SelectedNode.Tag is ColorContainer.WaterColor)
|
||||
{
|
||||
var colorEntry = ((COLFile.ExtendedColorEntry)waterTreeView.SelectedNode.Tag);
|
||||
colorEntry.color = (uint)fixed_color.ToArgb();
|
||||
var colorEntry = ((ColorContainer.WaterColor)waterTreeView.SelectedNode.Tag);
|
||||
colorEntry.SurfaceColor = fixed_color;
|
||||
}
|
||||
else if (tabControl.SelectedTab == underwaterTab && underwaterTreeView.SelectedNode != null &&
|
||||
underwaterTreeView.SelectedNode.Tag != null && underwaterTreeView.SelectedNode.Tag is COLFile.ExtendedColorEntry)
|
||||
underwaterTreeView.SelectedNode.Tag != null && underwaterTreeView.SelectedNode.Tag is ColorContainer.WaterColor)
|
||||
{
|
||||
var colorEntry = ((COLFile.ExtendedColorEntry)underwaterTreeView.SelectedNode.Tag);
|
||||
colorEntry.color_b = (uint)fixed_color.ToArgb();
|
||||
var colorEntry = ((ColorContainer.WaterColor)underwaterTreeView.SelectedNode.Tag);
|
||||
colorEntry.UnderwaterColor = fixed_color;
|
||||
}
|
||||
else if (tabControl.SelectedTab == fogTab && fogTreeView.SelectedNode != null &&
|
||||
fogTreeView.SelectedNode.Tag != null && fogTreeView.SelectedNode.Tag is COLFile.ExtendedColorEntry)
|
||||
fogTreeView.SelectedNode.Tag != null && fogTreeView.SelectedNode.Tag is ColorContainer.WaterColor)
|
||||
{
|
||||
var colorEntry = ((COLFile.ExtendedColorEntry)fogTreeView.SelectedNode.Tag);
|
||||
colorEntry.color_c = (uint)fixed_color.ToArgb();
|
||||
var colorEntry = ((ColorContainer.WaterColor)fogTreeView.SelectedNode.Tag);
|
||||
colorEntry.FogColor = fixed_color;
|
||||
}
|
||||
else if (tabControl.SelectedTab == colorsTab && colorTreeView.SelectedNode != null &&
|
||||
colorTreeView.SelectedNode.Tag != null && colorTreeView.SelectedNode.Tag is COLFile.ColorEntry)
|
||||
colorTreeView.SelectedNode.Tag != null && colorTreeView.SelectedNode.Tag is ColorContainer.Color)
|
||||
{
|
||||
var colorEntry = ((COLFile.ColorEntry)colorTreeView.SelectedNode.Tag);
|
||||
colorEntry.color = (uint)fixed_color.ToArgb() & 0xffffff;
|
||||
var colorEntry = ((ColorContainer.Color)colorTreeView.SelectedNode.Tag);
|
||||
colorEntry.ColorPallette = fixed_color;
|
||||
}
|
||||
|
||||
//redUpDown.Value = clipboard_color.color >> 16 & 0xff;
|
||||
@@ -583,12 +536,12 @@ namespace PckStudio.Forms.Editor
|
||||
if (colorPick.ShowDialog() != DialogResult.OK) return;
|
||||
pictureBox1.BackColor = colorPick.Color;
|
||||
if (tabControl.SelectedTab == waterTab && waterTreeView.SelectedNode != null &&
|
||||
waterTreeView.SelectedNode.Tag != null && waterTreeView.SelectedNode.Tag is COLFile.ExtendedColorEntry)
|
||||
waterTreeView.SelectedNode.Tag != null && waterTreeView.SelectedNode.Tag is ColorContainer.WaterColor)
|
||||
{
|
||||
var colorEntry = ((COLFile.ExtendedColorEntry)waterTreeView.SelectedNode.Tag);
|
||||
var colorEntry = ((ColorContainer.WaterColor)waterTreeView.SelectedNode.Tag);
|
||||
// preserves the alpha so the user can handle it since the color picker doesn't support alpha
|
||||
Color fixed_color = Color.FromArgb(Color.FromArgb((int)colorEntry.color).A, colorPick.Color);
|
||||
colorEntry.color = (uint)fixed_color.ToArgb();
|
||||
Color fixed_color = Color.FromArgb(colorEntry.SurfaceColor.A, colorPick.Color);
|
||||
colorEntry.SurfaceColor = fixed_color;
|
||||
pictureBox1.BackColor = fixed_color;
|
||||
//redUpDown.Value = colorPick.Color.R;
|
||||
//greenUpDown.Value = colorPick.Color.G;
|
||||
@@ -596,30 +549,30 @@ namespace PckStudio.Forms.Editor
|
||||
//MNL Miku or PhoenixARC all of these were errors
|
||||
}
|
||||
else if (tabControl.SelectedTab == underwaterTab && underwaterTreeView.SelectedNode != null &&
|
||||
underwaterTreeView.SelectedNode.Tag != null && underwaterTreeView.SelectedNode.Tag is COLFile.ExtendedColorEntry)
|
||||
underwaterTreeView.SelectedNode.Tag != null && underwaterTreeView.SelectedNode.Tag is ColorContainer.WaterColor)
|
||||
{
|
||||
var colorEntry = ((COLFile.ExtendedColorEntry)underwaterTreeView.SelectedNode.Tag);
|
||||
var colorEntry = ((ColorContainer.WaterColor)underwaterTreeView.SelectedNode.Tag);
|
||||
// the game doesn't care about the alpha value for underwater colors
|
||||
colorEntry.color_b = (uint)Color.FromArgb(0, colorPick.Color).ToArgb();
|
||||
colorEntry.UnderwaterColor = Color.FromArgb(0, colorPick.Color);
|
||||
//redUpDown.Value = colorPick.Color.R;
|
||||
//greenUpDown.Value = colorPick.Color.G;
|
||||
//blueUpDown.Value = colorPick.Color.B;
|
||||
}
|
||||
else if (tabControl.SelectedTab == fogTab && fogTreeView.SelectedNode != null &&
|
||||
fogTreeView.SelectedNode.Tag != null && fogTreeView.SelectedNode.Tag is COLFile.ExtendedColorEntry)
|
||||
fogTreeView.SelectedNode.Tag != null && fogTreeView.SelectedNode.Tag is ColorContainer.WaterColor)
|
||||
{
|
||||
var colorEntry = ((COLFile.ExtendedColorEntry)fogTreeView.SelectedNode.Tag);
|
||||
var colorEntry = ((ColorContainer.WaterColor)fogTreeView.SelectedNode.Tag);
|
||||
// the game doesn't care about the alpha value for fog colors
|
||||
colorEntry.color_c = (uint)Color.FromArgb(0, colorPick.Color).ToArgb();
|
||||
colorEntry.FogColor = Color.FromArgb(0, colorPick.Color);
|
||||
//redUpDown.Value = colorPick.Color.R;
|
||||
//greenUpDown.Value = colorPick.Color.G;
|
||||
//blueUpDown.Value = colorPick.Color.B;
|
||||
}
|
||||
else if (tabControl.SelectedTab == colorsTab && colorTreeView.SelectedNode != null &&
|
||||
colorTreeView.SelectedNode.Tag != null && colorTreeView.SelectedNode.Tag is COLFile.ColorEntry)
|
||||
colorTreeView.SelectedNode.Tag != null && colorTreeView.SelectedNode.Tag is ColorContainer.Color)
|
||||
{
|
||||
var colorEntry = ((COLFile.ColorEntry)colorTreeView.SelectedNode.Tag);
|
||||
colorEntry.color = (uint)colorPick.Color.ToArgb() & 0xffffff;
|
||||
var colorEntry = ((ColorContainer.Color)colorTreeView.SelectedNode.Tag);
|
||||
colorEntry.ColorPallette = colorPick.Color;
|
||||
//redUpDown.Value = colorPick.Color.R;
|
||||
//greenUpDown.Value = colorPick.Color.G;
|
||||
//blueUpDown.Value = colorPick.Color.B;
|
||||
|
||||
254
PCK-Studio/Forms/Editor/GRFEditor.Designer.cs
generated
254
PCK-Studio/Forms/Editor/GRFEditor.Designer.cs
generated
@@ -1,254 +0,0 @@
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
partial class GRFEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GRFEditor));
|
||||
this.GrfTreeView = new System.Windows.Forms.TreeView();
|
||||
this.MessageContextMenu = new MetroFramework.Controls.MetroContextMenu(this.components);
|
||||
this.addGameRuleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.removeGameRuleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.GrfParametersTreeView = new System.Windows.Forms.TreeView();
|
||||
this.DetailContextMenu = new MetroFramework.Controls.MetroContextMenu(this.components);
|
||||
this.addToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.metroLabel1 = new MetroFramework.Controls.MetroLabel();
|
||||
this.metroLabel2 = new MetroFramework.Controls.MetroLabel();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.metroPanel1 = new MetroFramework.Controls.MetroPanel();
|
||||
this.MessageContextMenu.SuspendLayout();
|
||||
this.DetailContextMenu.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.metroPanel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// GrfTreeView
|
||||
//
|
||||
this.GrfTreeView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.GrfTreeView.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.GrfTreeView.ContextMenuStrip = this.MessageContextMenu;
|
||||
this.GrfTreeView.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.GrfTreeView.ForeColor = System.Drawing.SystemColors.MenuBar;
|
||||
this.GrfTreeView.Location = new System.Drawing.Point(0, 0);
|
||||
this.GrfTreeView.Name = "GrfTreeView";
|
||||
this.GrfTreeView.Size = new System.Drawing.Size(223, 312);
|
||||
this.GrfTreeView.TabIndex = 0;
|
||||
this.GrfTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.GrfTreeView_AfterSelect);
|
||||
this.GrfTreeView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GrfTreeView_KeyDown);
|
||||
//
|
||||
// MessageContextMenu
|
||||
//
|
||||
this.MessageContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.addGameRuleToolStripMenuItem,
|
||||
this.removeGameRuleToolStripMenuItem});
|
||||
this.MessageContextMenu.Name = "MessageContextMenu";
|
||||
this.MessageContextMenu.Size = new System.Drawing.Size(178, 48);
|
||||
//
|
||||
// addGameRuleToolStripMenuItem
|
||||
//
|
||||
this.addGameRuleToolStripMenuItem.Name = "addGameRuleToolStripMenuItem";
|
||||
this.addGameRuleToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
|
||||
this.addGameRuleToolStripMenuItem.Text = "Add Game Rule";
|
||||
this.addGameRuleToolStripMenuItem.Click += new System.EventHandler(this.addGameRuleToolStripMenuItem_Click);
|
||||
//
|
||||
// removeGameRuleToolStripMenuItem
|
||||
//
|
||||
this.removeGameRuleToolStripMenuItem.Name = "removeGameRuleToolStripMenuItem";
|
||||
this.removeGameRuleToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
|
||||
this.removeGameRuleToolStripMenuItem.Text = "Remove Game Rule";
|
||||
this.removeGameRuleToolStripMenuItem.Click += new System.EventHandler(this.removeGameRuleToolStripMenuItem_Click);
|
||||
//
|
||||
// GrfParametersTreeView
|
||||
//
|
||||
this.GrfParametersTreeView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.GrfParametersTreeView.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.GrfParametersTreeView.ContextMenuStrip = this.DetailContextMenu;
|
||||
this.GrfParametersTreeView.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.GrfParametersTreeView.ForeColor = System.Drawing.SystemColors.MenuBar;
|
||||
this.GrfParametersTreeView.Location = new System.Drawing.Point(227, 0);
|
||||
this.GrfParametersTreeView.Name = "GrfParametersTreeView";
|
||||
this.GrfParametersTreeView.Size = new System.Drawing.Size(223, 312);
|
||||
this.GrfParametersTreeView.TabIndex = 1;
|
||||
this.GrfParametersTreeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.GrfDetailsTreeView_NodeMouseDoubleClick);
|
||||
this.GrfParametersTreeView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GrfDetailsTreeView_KeyDown);
|
||||
//
|
||||
// DetailContextMenu
|
||||
//
|
||||
this.DetailContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.addToolStripMenuItem1,
|
||||
this.removeToolStripMenuItem});
|
||||
this.DetailContextMenu.Name = "DetailContextMenu";
|
||||
this.DetailContextMenu.Size = new System.Drawing.Size(118, 48);
|
||||
//
|
||||
// addToolStripMenuItem1
|
||||
//
|
||||
this.addToolStripMenuItem1.Name = "addToolStripMenuItem1";
|
||||
this.addToolStripMenuItem1.Size = new System.Drawing.Size(117, 22);
|
||||
this.addToolStripMenuItem1.Text = "Add";
|
||||
this.addToolStripMenuItem1.Click += new System.EventHandler(this.addDetailContextMenuItem_Click);
|
||||
//
|
||||
// removeToolStripMenuItem
|
||||
//
|
||||
this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
|
||||
this.removeToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
|
||||
this.removeToolStripMenuItem.Text = "Remove";
|
||||
this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click);
|
||||
//
|
||||
// metroLabel1
|
||||
//
|
||||
this.metroLabel1.AutoSize = true;
|
||||
this.metroLabel1.Location = new System.Drawing.Point(25, 88);
|
||||
this.metroLabel1.Name = "metroLabel1";
|
||||
this.metroLabel1.Size = new System.Drawing.Size(73, 19);
|
||||
this.metroLabel1.TabIndex = 2;
|
||||
this.metroLabel1.Text = "Game Rule";
|
||||
this.metroLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.metroLabel1.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// metroLabel2
|
||||
//
|
||||
this.metroLabel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.metroLabel2.AutoSize = true;
|
||||
this.metroLabel2.Location = new System.Drawing.Point(252, 88);
|
||||
this.metroLabel2.Name = "metroLabel2";
|
||||
this.metroLabel2.Size = new System.Drawing.Size(75, 19);
|
||||
this.metroLabel2.TabIndex = 0;
|
||||
this.metroLabel2.Text = "Parameters";
|
||||
this.metroLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.metroLabel2.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(25, 60);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(450, 24);
|
||||
this.menuStrip1.TabIndex = 3;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.openToolStripMenuItem,
|
||||
this.saveToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.ForeColor = System.Drawing.SystemColors.Menu;
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileToolStripMenuItem.Text = "File";
|
||||
//
|
||||
// openToolStripMenuItem
|
||||
//
|
||||
this.openToolStripMenuItem.Enabled = false;
|
||||
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
|
||||
this.openToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
|
||||
this.openToolStripMenuItem.Text = "Open";
|
||||
//
|
||||
// saveToolStripMenuItem
|
||||
//
|
||||
this.saveToolStripMenuItem.BackColor = System.Drawing.Color.Transparent;
|
||||
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
|
||||
this.saveToolStripMenuItem.Text = "Save";
|
||||
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
|
||||
//
|
||||
// metroPanel1
|
||||
//
|
||||
this.metroPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.metroPanel1.Controls.Add(this.GrfParametersTreeView);
|
||||
this.metroPanel1.Controls.Add(this.GrfTreeView);
|
||||
this.metroPanel1.HorizontalScrollbarBarColor = true;
|
||||
this.metroPanel1.HorizontalScrollbarHighlightOnWheel = false;
|
||||
this.metroPanel1.HorizontalScrollbarSize = 10;
|
||||
this.metroPanel1.Location = new System.Drawing.Point(25, 110);
|
||||
this.metroPanel1.Name = "metroPanel1";
|
||||
this.metroPanel1.Size = new System.Drawing.Size(450, 312);
|
||||
this.metroPanel1.TabIndex = 4;
|
||||
this.metroPanel1.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.metroPanel1.VerticalScrollbarBarColor = true;
|
||||
this.metroPanel1.VerticalScrollbarHighlightOnWheel = false;
|
||||
this.metroPanel1.VerticalScrollbarSize = 10;
|
||||
this.metroPanel1.Resize += new System.EventHandler(this.metroPanel1_Resize);
|
||||
//
|
||||
// GRFEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
|
||||
this.ClientSize = new System.Drawing.Size(500, 450);
|
||||
this.Controls.Add(this.metroPanel1);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.Controls.Add(this.metroLabel2);
|
||||
this.Controls.Add(this.metroLabel1);
|
||||
this.Font = new System.Drawing.Font("Segoe UI", 8.25F);
|
||||
this.ForeColor = System.Drawing.Color.White;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.MinimumSize = new System.Drawing.Size(500, 450);
|
||||
this.Name = "GRFEditor";
|
||||
this.Padding = new System.Windows.Forms.Padding(25, 60, 25, 25);
|
||||
this.Text = "GRF Editor";
|
||||
this.Load += new System.EventHandler(this.OnLoad);
|
||||
this.MessageContextMenu.ResumeLayout(false);
|
||||
this.DetailContextMenu.ResumeLayout(false);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.metroPanel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TreeView GrfTreeView;
|
||||
private System.Windows.Forms.TreeView GrfParametersTreeView;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel1;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel2;
|
||||
private MetroFramework.Controls.MetroContextMenu MessageContextMenu;
|
||||
private MetroFramework.Controls.MetroContextMenu DetailContextMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem addGameRuleToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem addToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem removeGameRuleToolStripMenuItem;
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
|
||||
private MetroFramework.Controls.MetroPanel metroPanel1;
|
||||
}
|
||||
}
|
||||
301
PCK-Studio/Forms/Editor/GameRuleFileEditor.Designer.cs
generated
Normal file
301
PCK-Studio/Forms/Editor/GameRuleFileEditor.Designer.cs
generated
Normal file
@@ -0,0 +1,301 @@
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
partial class GameRuleFileEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GameRuleFileEditor));
|
||||
this.GrfTreeView = new System.Windows.Forms.TreeView();
|
||||
this.MessageContextMenu = new MetroFramework.Controls.MetroContextMenu(this.components);
|
||||
this.addGameRuleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.removeGameRuleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.GrfParametersTreeView = new System.Windows.Forms.TreeView();
|
||||
this.DetailContextMenu = new MetroFramework.Controls.MetroContextMenu(this.components);
|
||||
this.addToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.metroLabel1 = new MetroFramework.Controls.MetroLabel();
|
||||
this.metroLabel2 = new MetroFramework.Controls.MetroLabel();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.compressionLvlToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox();
|
||||
this.compressionTypeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.compressionTypeComboBox = new System.Windows.Forms.ToolStripComboBox();
|
||||
this.metroPanel1 = new MetroFramework.Controls.MetroPanel();
|
||||
this.MessageContextMenu.SuspendLayout();
|
||||
this.DetailContextMenu.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.metroPanel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// GrfTreeView
|
||||
//
|
||||
this.GrfTreeView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.GrfTreeView.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.GrfTreeView.ContextMenuStrip = this.MessageContextMenu;
|
||||
this.GrfTreeView.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.GrfTreeView.ForeColor = System.Drawing.SystemColors.MenuBar;
|
||||
this.GrfTreeView.Location = new System.Drawing.Point(0, 0);
|
||||
this.GrfTreeView.Name = "GrfTreeView";
|
||||
this.GrfTreeView.Size = new System.Drawing.Size(223, 312);
|
||||
this.GrfTreeView.TabIndex = 0;
|
||||
this.GrfTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.GrfTreeView_AfterSelect);
|
||||
this.GrfTreeView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GrfTreeView_KeyDown);
|
||||
//
|
||||
// MessageContextMenu
|
||||
//
|
||||
this.MessageContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.addGameRuleToolStripMenuItem,
|
||||
this.removeGameRuleToolStripMenuItem});
|
||||
this.MessageContextMenu.Name = "MessageContextMenu";
|
||||
this.MessageContextMenu.Size = new System.Drawing.Size(178, 48);
|
||||
//
|
||||
// addGameRuleToolStripMenuItem
|
||||
//
|
||||
this.addGameRuleToolStripMenuItem.Name = "addGameRuleToolStripMenuItem";
|
||||
this.addGameRuleToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
|
||||
this.addGameRuleToolStripMenuItem.Text = "Add Game Rule";
|
||||
this.addGameRuleToolStripMenuItem.Click += new System.EventHandler(this.addGameRuleToolStripMenuItem_Click);
|
||||
//
|
||||
// removeGameRuleToolStripMenuItem
|
||||
//
|
||||
this.removeGameRuleToolStripMenuItem.Name = "removeGameRuleToolStripMenuItem";
|
||||
this.removeGameRuleToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
|
||||
this.removeGameRuleToolStripMenuItem.Text = "Remove Game Rule";
|
||||
this.removeGameRuleToolStripMenuItem.Click += new System.EventHandler(this.removeGameRuleToolStripMenuItem_Click);
|
||||
//
|
||||
// GrfParametersTreeView
|
||||
//
|
||||
this.GrfParametersTreeView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.GrfParametersTreeView.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.GrfParametersTreeView.ContextMenuStrip = this.DetailContextMenu;
|
||||
this.GrfParametersTreeView.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.GrfParametersTreeView.ForeColor = System.Drawing.SystemColors.MenuBar;
|
||||
this.GrfParametersTreeView.Location = new System.Drawing.Point(227, 0);
|
||||
this.GrfParametersTreeView.Name = "GrfParametersTreeView";
|
||||
this.GrfParametersTreeView.Size = new System.Drawing.Size(223, 312);
|
||||
this.GrfParametersTreeView.TabIndex = 1;
|
||||
this.GrfParametersTreeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.GrfDetailsTreeView_NodeMouseDoubleClick);
|
||||
this.GrfParametersTreeView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GrfDetailsTreeView_KeyDown);
|
||||
//
|
||||
// DetailContextMenu
|
||||
//
|
||||
this.DetailContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.addToolStripMenuItem1,
|
||||
this.removeToolStripMenuItem});
|
||||
this.DetailContextMenu.Name = "DetailContextMenu";
|
||||
this.DetailContextMenu.Size = new System.Drawing.Size(118, 48);
|
||||
//
|
||||
// addToolStripMenuItem1
|
||||
//
|
||||
this.addToolStripMenuItem1.Name = "addToolStripMenuItem1";
|
||||
this.addToolStripMenuItem1.Size = new System.Drawing.Size(117, 22);
|
||||
this.addToolStripMenuItem1.Text = "Add";
|
||||
this.addToolStripMenuItem1.Click += new System.EventHandler(this.addDetailContextMenuItem_Click);
|
||||
//
|
||||
// removeToolStripMenuItem
|
||||
//
|
||||
this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
|
||||
this.removeToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
|
||||
this.removeToolStripMenuItem.Text = "Remove";
|
||||
this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click);
|
||||
//
|
||||
// metroLabel1
|
||||
//
|
||||
this.metroLabel1.AutoSize = true;
|
||||
this.metroLabel1.Location = new System.Drawing.Point(25, 88);
|
||||
this.metroLabel1.Name = "metroLabel1";
|
||||
this.metroLabel1.Size = new System.Drawing.Size(73, 19);
|
||||
this.metroLabel1.TabIndex = 2;
|
||||
this.metroLabel1.Text = "Game Rule";
|
||||
this.metroLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.metroLabel1.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// metroLabel2
|
||||
//
|
||||
this.metroLabel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.metroLabel2.AutoSize = true;
|
||||
this.metroLabel2.Location = new System.Drawing.Point(252, 88);
|
||||
this.metroLabel2.Name = "metroLabel2";
|
||||
this.metroLabel2.Size = new System.Drawing.Size(75, 19);
|
||||
this.metroLabel2.TabIndex = 0;
|
||||
this.metroLabel2.Text = "Parameters";
|
||||
this.metroLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.metroLabel2.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem,
|
||||
this.compressionLvlToolStripMenuItem,
|
||||
this.compressionTypeToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(25, 60);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(450, 24);
|
||||
this.menuStrip1.TabIndex = 3;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.openToolStripMenuItem,
|
||||
this.saveToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.ForeColor = System.Drawing.SystemColors.Menu;
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileToolStripMenuItem.Text = "File";
|
||||
//
|
||||
// openToolStripMenuItem
|
||||
//
|
||||
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
|
||||
this.openToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
|
||||
this.openToolStripMenuItem.Text = "Open";
|
||||
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
|
||||
//
|
||||
// saveToolStripMenuItem
|
||||
//
|
||||
this.saveToolStripMenuItem.BackColor = System.Drawing.Color.Transparent;
|
||||
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
|
||||
this.saveToolStripMenuItem.Text = "Save";
|
||||
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
|
||||
//
|
||||
// compressionLvlToolStripMenuItem
|
||||
//
|
||||
this.compressionLvlToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripComboBox1});
|
||||
this.compressionLvlToolStripMenuItem.ForeColor = System.Drawing.SystemColors.Menu;
|
||||
this.compressionLvlToolStripMenuItem.Name = "compressionLvlToolStripMenuItem";
|
||||
this.compressionLvlToolStripMenuItem.Size = new System.Drawing.Size(106, 20);
|
||||
this.compressionLvlToolStripMenuItem.Text = "Compression Lvl";
|
||||
//
|
||||
// toolStripComboBox1
|
||||
//
|
||||
this.toolStripComboBox1.Items.AddRange(new object[] {
|
||||
"None",
|
||||
"Compressed",
|
||||
"Compressed + RLE",
|
||||
"Compressed + RLE + CRC"});
|
||||
this.toolStripComboBox1.Name = "toolStripComboBox1";
|
||||
this.toolStripComboBox1.Size = new System.Drawing.Size(121, 23);
|
||||
this.toolStripComboBox1.Text = "None";
|
||||
//
|
||||
// compressionTypeToolStripMenuItem
|
||||
//
|
||||
this.compressionTypeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.compressionTypeComboBox});
|
||||
this.compressionTypeToolStripMenuItem.ForeColor = System.Drawing.SystemColors.Menu;
|
||||
this.compressionTypeToolStripMenuItem.Name = "compressionTypeToolStripMenuItem";
|
||||
this.compressionTypeToolStripMenuItem.Size = new System.Drawing.Size(116, 20);
|
||||
this.compressionTypeToolStripMenuItem.Text = "Compression Type";
|
||||
//
|
||||
// compressionTypeComboBox
|
||||
//
|
||||
this.compressionTypeComboBox.Items.AddRange(new object[] {
|
||||
"Zlib",
|
||||
"Deflate",
|
||||
"XMem"});
|
||||
this.compressionTypeComboBox.Name = "compressionTypeComboBox";
|
||||
this.compressionTypeComboBox.Size = new System.Drawing.Size(121, 23);
|
||||
//
|
||||
// metroPanel1
|
||||
//
|
||||
this.metroPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.metroPanel1.Controls.Add(this.GrfParametersTreeView);
|
||||
this.metroPanel1.Controls.Add(this.GrfTreeView);
|
||||
this.metroPanel1.HorizontalScrollbarBarColor = true;
|
||||
this.metroPanel1.HorizontalScrollbarHighlightOnWheel = false;
|
||||
this.metroPanel1.HorizontalScrollbarSize = 10;
|
||||
this.metroPanel1.Location = new System.Drawing.Point(25, 110);
|
||||
this.metroPanel1.Name = "metroPanel1";
|
||||
this.metroPanel1.Size = new System.Drawing.Size(450, 312);
|
||||
this.metroPanel1.TabIndex = 4;
|
||||
this.metroPanel1.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.metroPanel1.VerticalScrollbarBarColor = true;
|
||||
this.metroPanel1.VerticalScrollbarHighlightOnWheel = false;
|
||||
this.metroPanel1.VerticalScrollbarSize = 10;
|
||||
this.metroPanel1.Resize += new System.EventHandler(this.metroPanel1_Resize);
|
||||
//
|
||||
// GameRuleFileEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(500, 450);
|
||||
this.Controls.Add(this.metroPanel1);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.Controls.Add(this.metroLabel2);
|
||||
this.Controls.Add(this.metroLabel1);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.MinimumSize = new System.Drawing.Size(500, 450);
|
||||
this.Name = "GameRuleFileEditor";
|
||||
this.Padding = new System.Windows.Forms.Padding(25, 60, 25, 25);
|
||||
this.Style = MetroFramework.MetroColorStyle.Silver;
|
||||
this.Text = "GRF Editor";
|
||||
this.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.Load += new System.EventHandler(this.OnLoad);
|
||||
this.MessageContextMenu.ResumeLayout(false);
|
||||
this.DetailContextMenu.ResumeLayout(false);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.metroPanel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TreeView GrfTreeView;
|
||||
private System.Windows.Forms.TreeView GrfParametersTreeView;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel1;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel2;
|
||||
private MetroFramework.Controls.MetroContextMenu MessageContextMenu;
|
||||
private MetroFramework.Controls.MetroContextMenu DetailContextMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem addGameRuleToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem addToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem removeGameRuleToolStripMenuItem;
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
|
||||
private MetroFramework.Controls.MetroPanel metroPanel1;
|
||||
private System.Windows.Forms.ToolStripMenuItem compressionLvlToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripComboBox toolStripComboBox1;
|
||||
private System.Windows.Forms.ToolStripMenuItem compressionTypeToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripComboBox compressionTypeComboBox;
|
||||
}
|
||||
}
|
||||
@@ -4,82 +4,103 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using PckStudio.Classes.IO.GRF;
|
||||
using PckStudio.Forms.Additional_Popups.Grf;
|
||||
using PckStudio.Classes.Misc;
|
||||
using OMI.Formats.GameRule;
|
||||
using OMI.Workers.GameRule;
|
||||
using System.Diagnostics;
|
||||
using OMI.Formats.Pck;
|
||||
using PckStudio.Forms.Additional_Popups;
|
||||
using PckStudio.ToolboxItems;
|
||||
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
public partial class GRFEditor : ThemeForm
|
||||
public partial class GameRuleFileEditor : MetroFramework.Forms.MetroForm
|
||||
{
|
||||
private PCKFile.FileData _pckfile;
|
||||
private GRFFile _file;
|
||||
private PckFile.FileData _pckfile;
|
||||
private GameRuleFile _file;
|
||||
|
||||
|
||||
private GRFEditor()
|
||||
public GameRuleFileEditor()
|
||||
{
|
||||
InitializeComponent();
|
||||
PromptForCompressionType();
|
||||
}
|
||||
|
||||
public GRFEditor(PCKFile.FileData file) : this()
|
||||
private void PromptForCompressionType()
|
||||
{
|
||||
ItemSelectionPopUp dialog = new ItemSelectionPopUp(compressionTypeComboBox.Items.Cast<string>().ToArray());
|
||||
dialog.label2.Text = "Type";
|
||||
dialog.okBtn.Text = "Ok";
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
compressionTypeComboBox.SelectedIndex = compressionTypeComboBox.Items.IndexOf(dialog.SelectedItem);
|
||||
}
|
||||
|
||||
public GameRuleFileEditor(PckFile.FileData file) : this()
|
||||
{
|
||||
_pckfile = file;
|
||||
using(var stream = new MemoryStream(file.data))
|
||||
using (var stream = new MemoryStream(file.Data))
|
||||
{
|
||||
try
|
||||
{
|
||||
_file = GRFFileReader.Read(stream);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
MessageBox.Show("Faild to open .grf/.grh file");
|
||||
}
|
||||
_file = OpenGameRuleFile(stream, (GameRuleFile.CompressionType)compressionTypeComboBox.SelectedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public GRFEditor(Stream stream) : this()
|
||||
public GameRuleFileEditor(Stream stream) : this()
|
||||
{
|
||||
_file = OpenGameRuleFile(stream, (GameRuleFile.CompressionType)compressionTypeComboBox.SelectedIndex);
|
||||
}
|
||||
|
||||
private GameRuleFile OpenGameRuleFile(Stream stream, GameRuleFile.CompressionType compressionType)
|
||||
{
|
||||
try
|
||||
{
|
||||
_file = GRFFileReader.Read(stream);
|
||||
var reader = new GameRuleFileReader(compressionType);
|
||||
return reader.FromStream(stream);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Debug.WriteLine(ex.Message);
|
||||
MessageBox.Show("Faild to open .grf/.grh file");
|
||||
}
|
||||
return default!;
|
||||
}
|
||||
|
||||
private void OnLoad(object sender, EventArgs e)
|
||||
{
|
||||
RPC.SetPresence("GRF Editor", "Editing a GRF File");
|
||||
loadGRFTreeView(GrfTreeView.Nodes, _file.Root);
|
||||
ReloadGameRuleTree();
|
||||
}
|
||||
|
||||
private void loadGRFTreeView(TreeNodeCollection root, GRFFile.GameRule parentRule)
|
||||
private void LoadGameRuleTree(TreeNodeCollection root, GameRuleFile.GameRule parentRule)
|
||||
{
|
||||
foreach (var rule in parentRule.SubRules)
|
||||
foreach (var rule in parentRule.ChildRules)
|
||||
{
|
||||
TreeNode node = new TreeNode(rule.Name);
|
||||
node.Tag = rule;
|
||||
root.Add(node);
|
||||
loadGRFTreeView(node.Nodes, rule);
|
||||
LoadGameRuleTree(node.Nodes, rule);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReloadGameRuleTree()
|
||||
{
|
||||
GrfTreeView.Nodes.Clear();
|
||||
if (_file is not null)
|
||||
{
|
||||
toolStripComboBox1.SelectedIndex = (int)_file.FileHeader.CompressionLevel;
|
||||
LoadGameRuleTree(GrfTreeView.Nodes, _file.Root);
|
||||
}
|
||||
}
|
||||
|
||||
private void GrfTreeView_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
if (e.Node is TreeNode t && t.Tag is GRFFile.GameRule)
|
||||
if (e.Node is TreeNode t && t.Tag is GameRuleFile.GameRule)
|
||||
ReloadParameterTreeView();
|
||||
}
|
||||
|
||||
private void ReloadParameterTreeView()
|
||||
{
|
||||
GrfParametersTreeView.Nodes.Clear();
|
||||
if (GrfTreeView.SelectedNode is TreeNode t && t.Tag is GRFFile.GameRule rule)
|
||||
if (GrfTreeView.SelectedNode is TreeNode t && t.Tag is GameRuleFile.GameRule rule)
|
||||
foreach (var param in rule.Parameters)
|
||||
{
|
||||
GrfParametersTreeView.Nodes.Add(new TreeNode($"{param.Key}: {param.Value}") { Tag = param});
|
||||
@@ -88,8 +109,8 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void addDetailContextMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (GrfTreeView.SelectedNode == null || !(GrfTreeView.SelectedNode.Tag is GRFFile.GameRule)) return;
|
||||
var grfTag = GrfTreeView.SelectedNode.Tag as GRFFile.GameRule;
|
||||
if (GrfTreeView.SelectedNode == null || !(GrfTreeView.SelectedNode.Tag is GameRuleFile.GameRule)) return;
|
||||
var grfTag = GrfTreeView.SelectedNode.Tag as GameRuleFile.GameRule;
|
||||
AddParameter prompt = new AddParameter();
|
||||
if (prompt.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
@@ -105,7 +126,7 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void removeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (GrfTreeView.SelectedNode is TreeNode t && t.Tag is GRFFile.GameRule rule &&
|
||||
if (GrfTreeView.SelectedNode is TreeNode t && t.Tag is GameRuleFile.GameRule rule &&
|
||||
GrfParametersTreeView.SelectedNode is TreeNode paramNode && paramNode.Tag is KeyValuePair<string, string> pair &&
|
||||
rule.Parameters.ContainsKey(pair.Key) && rule.Parameters.Remove(pair.Key))
|
||||
{
|
||||
@@ -123,7 +144,7 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void GrfDetailsTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
|
||||
{
|
||||
if (GrfTreeView.SelectedNode is TreeNode t && t.Tag is GRFFile.GameRule rule &&
|
||||
if (GrfTreeView.SelectedNode is TreeNode t && t.Tag is GameRuleFile.GameRule rule &&
|
||||
GrfParametersTreeView.SelectedNode is TreeNode paramNode && paramNode.Tag is KeyValuePair<string, string> param)
|
||||
{
|
||||
AddParameter prompt = new AddParameter(param.Key, param.Value, false);
|
||||
@@ -137,9 +158,9 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void addGameRuleToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
bool isValidNode = GrfTreeView.SelectedNode is TreeNode t && t.Tag is GRFFile.GameRule;
|
||||
GRFFile.GameRule parentRule = isValidNode
|
||||
? GrfTreeView.SelectedNode.Tag as GRFFile.GameRule
|
||||
bool isValidNode = GrfTreeView.SelectedNode is TreeNode t && t.Tag is GameRuleFile.GameRule;
|
||||
var parentRule = isValidNode
|
||||
? GrfTreeView.SelectedNode.Tag as GameRuleFile.GameRule
|
||||
: _file.Root;
|
||||
|
||||
TreeNodeCollection root = isValidNode
|
||||
@@ -167,16 +188,16 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void removeGameRuleToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (GrfTreeView.SelectedNode is TreeNode t && t.Tag is GRFFile.GameRule tag && removeTag(tag))
|
||||
if (GrfTreeView.SelectedNode is TreeNode t && t.Tag is GameRuleFile.GameRule tag && removeTag(tag))
|
||||
t.Remove();
|
||||
}
|
||||
|
||||
private bool removeTag(GRFFile.GameRule rule)
|
||||
private bool removeTag(GameRuleFile.GameRule rule)
|
||||
{
|
||||
_ = rule.Parent ?? throw new ArgumentNullException(nameof(rule.Parent));
|
||||
foreach (var subTag in rule.SubRules.ToList())
|
||||
foreach (var subTag in rule.ChildRules.ToList())
|
||||
return removeTag(subTag);
|
||||
return rule.Parent.SubRules.Remove(rule);
|
||||
return rule.Parent.ChildRules.Remove(rule);
|
||||
}
|
||||
|
||||
private void GrfTreeView_KeyDown(object sender, KeyEventArgs e)
|
||||
@@ -187,7 +208,7 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_file.IsWorld)
|
||||
if (_file.FileHeader.unknownData[3] != 0)
|
||||
{
|
||||
MessageBox.Show("World grf saving is currently unsupported");
|
||||
return;
|
||||
@@ -196,7 +217,11 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
try
|
||||
{
|
||||
GRFFileWriter.Write(stream, _file, GRFFile.eCompressionType.ZlibRleCrc);
|
||||
var writer = new GameRuleFileWriter(
|
||||
_file,
|
||||
(GameRuleFile.CompressionLevel)toolStripComboBox1.SelectedIndex,
|
||||
(GameRuleFile.CompressionType)compressionTypeComboBox.SelectedIndex);
|
||||
writer.WriteToStream(stream);
|
||||
_pckfile?.SetData(stream.ToArray());
|
||||
MessageBox.Show("Saved!");
|
||||
}
|
||||
@@ -216,5 +241,20 @@ namespace PckStudio.Forms.Editor
|
||||
// good enough
|
||||
metroLabel2.Location = new Point(metroPanel1.Size.Width / 2 + 25, metroLabel2.Location.Y);
|
||||
}
|
||||
|
||||
private void openToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog dialog = new OpenFileDialog();
|
||||
dialog.Filter = "Game Rule File|*.grf";
|
||||
PromptForCompressionType();
|
||||
if (dialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
using (var fs = File.OpenRead(dialog.FileName))
|
||||
{
|
||||
_file = OpenGameRuleFile(fs, (GameRuleFile.CompressionType)compressionTypeComboBox.SelectedIndex);
|
||||
ReloadGameRuleTree();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,10 @@ using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using PckStudio.ToolboxItems;
|
||||
using PckStudio.Classes.Misc;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using PckStudio.Classes.IO.LOC;
|
||||
using PckStudio.Forms.Additional_Popups.Loc;
|
||||
using OMI.Formats.Languages;
|
||||
using OMI.Workers.Language;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
@@ -16,15 +17,16 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
DataTable tbl;
|
||||
LOCFile currentLoc;
|
||||
PCKFile.FileData _file;
|
||||
PckFile.FileData _file;
|
||||
|
||||
public LOCEditor(PCKFile.FileData file)
|
||||
public LOCEditor(PckFile.FileData file)
|
||||
{
|
||||
InitializeComponent();
|
||||
_file = file;
|
||||
using (var ms = new MemoryStream(file.data))
|
||||
using (var ms = new MemoryStream(file.Data))
|
||||
{
|
||||
currentLoc = LOCFileReader.Read(ms);
|
||||
var reader = new LOCFileReader();
|
||||
currentLoc = reader.FromStream(ms);
|
||||
}
|
||||
tbl = new DataTable();
|
||||
tbl.Columns.Add(new DataColumn("Language") { ReadOnly = true });
|
||||
|
||||
185
PCK-Studio/Forms/Editor/MaterialsEditor.Designer.cs
generated
Normal file
185
PCK-Studio/Forms/Editor/MaterialsEditor.Designer.cs
generated
Normal file
@@ -0,0 +1,185 @@
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
partial class MaterialsEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MaterialsEditor));
|
||||
this.treeView1 = new System.Windows.Forms.TreeView();
|
||||
this.metroContextMenu1 = new MetroFramework.Controls.MetroContextMenu(this.components);
|
||||
this.addToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.xLabel = new MetroFramework.Controls.MetroLabel();
|
||||
this.materialComboBox = new MetroFramework.Controls.MetroComboBox();
|
||||
this.metroContextMenu1.SuspendLayout();
|
||||
this.menuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// treeView1
|
||||
//
|
||||
this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.treeView1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.treeView1.ContextMenuStrip = this.metroContextMenu1;
|
||||
this.treeView1.ForeColor = System.Drawing.Color.White;
|
||||
this.treeView1.Location = new System.Drawing.Point(20, 84);
|
||||
this.treeView1.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.treeView1.Name = "treeView1";
|
||||
this.treeView1.Size = new System.Drawing.Size(136, 176);
|
||||
this.treeView1.TabIndex = 13;
|
||||
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
|
||||
this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick);
|
||||
this.treeView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeView1_KeyDown);
|
||||
this.treeView1.MouseHover += new System.EventHandler(this.treeView1_MouseHover);
|
||||
//
|
||||
// metroContextMenu1
|
||||
//
|
||||
this.metroContextMenu1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.addToolStripMenuItem,
|
||||
this.removeToolStripMenuItem});
|
||||
this.metroContextMenu1.Name = "metroContextMenu1";
|
||||
this.metroContextMenu1.Size = new System.Drawing.Size(127, 48);
|
||||
//
|
||||
// addToolStripMenuItem
|
||||
//
|
||||
this.addToolStripMenuItem.Name = "addToolStripMenuItem";
|
||||
this.addToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.addToolStripMenuItem.Text = "Add Entry";
|
||||
this.addToolStripMenuItem.Click += new System.EventHandler(this.addToolStripMenuItem_Click);
|
||||
//
|
||||
// removeToolStripMenuItem
|
||||
//
|
||||
this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
|
||||
this.removeToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.removeToolStripMenuItem.Text = "Remove";
|
||||
this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click);
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
this.menuStrip.AutoSize = false;
|
||||
this.menuStrip.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem,
|
||||
this.helpToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(20, 60);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Size = new System.Drawing.Size(348, 24);
|
||||
this.menuStrip.TabIndex = 14;
|
||||
this.menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.saveToolStripMenuItem1});
|
||||
this.fileToolStripMenuItem.ForeColor = System.Drawing.Color.White;
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileToolStripMenuItem.Text = "File";
|
||||
//
|
||||
// saveToolStripMenuItem1
|
||||
//
|
||||
this.saveToolStripMenuItem1.Image = ((System.Drawing.Image)(resources.GetObject("saveToolStripMenuItem1.Image")));
|
||||
this.saveToolStripMenuItem1.Name = "saveToolStripMenuItem1";
|
||||
this.saveToolStripMenuItem1.Size = new System.Drawing.Size(98, 22);
|
||||
this.saveToolStripMenuItem1.Text = "Save";
|
||||
this.saveToolStripMenuItem1.Click += new System.EventHandler(this.saveToolStripMenuItem1_Click);
|
||||
//
|
||||
// helpToolStripMenuItem
|
||||
//
|
||||
this.helpToolStripMenuItem.ForeColor = System.Drawing.Color.White;
|
||||
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
|
||||
this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
|
||||
this.helpToolStripMenuItem.Text = "Help";
|
||||
//
|
||||
// xLabel
|
||||
//
|
||||
this.xLabel.AutoSize = true;
|
||||
this.xLabel.Location = new System.Drawing.Point(159, 147);
|
||||
this.xLabel.Name = "xLabel";
|
||||
this.xLabel.Size = new System.Drawing.Size(91, 19);
|
||||
this.xLabel.TabIndex = 30;
|
||||
this.xLabel.Text = "Material Type:";
|
||||
this.xLabel.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// materialComboBox
|
||||
//
|
||||
this.materialComboBox.FormattingEnabled = true;
|
||||
this.materialComboBox.ItemHeight = 23;
|
||||
this.materialComboBox.Items.AddRange(new object[] {
|
||||
"entity_alphatest",
|
||||
"entity_emissive_alpha",
|
||||
"entity_emissive_alpha_only",
|
||||
"entity_alphatest_change_color",
|
||||
"entity_change_color"});
|
||||
this.materialComboBox.Location = new System.Drawing.Point(159, 169);
|
||||
this.materialComboBox.Name = "materialComboBox";
|
||||
this.materialComboBox.Size = new System.Drawing.Size(209, 29);
|
||||
this.materialComboBox.TabIndex = 31;
|
||||
this.materialComboBox.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.materialComboBox.UseSelectable = true;
|
||||
this.materialComboBox.SelectedIndexChanged += new System.EventHandler(this.materialComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// MaterialsEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(388, 280);
|
||||
this.Controls.Add(this.materialComboBox);
|
||||
this.Controls.Add(this.xLabel);
|
||||
this.Controls.Add(this.menuStrip);
|
||||
this.Controls.Add(this.treeView1);
|
||||
this.Name = "MaterialsEditor";
|
||||
this.Style = MetroFramework.MetroColorStyle.Silver;
|
||||
this.Text = "Materials Editor";
|
||||
this.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.metroContextMenu1.ResumeLayout(false);
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
this.menuStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TreeView treeView1;
|
||||
private System.Windows.Forms.MenuStrip menuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
|
||||
private MetroFramework.Controls.MetroLabel xLabel;
|
||||
private MetroFramework.Controls.MetroContextMenu metroContextMenu1;
|
||||
private System.Windows.Forms.ToolStripMenuItem addToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem;
|
||||
private MetroFramework.Controls.MetroComboBox materialComboBox;
|
||||
}
|
||||
}
|
||||
175
PCK-Studio/Forms/Editor/MaterialsEditor.cs
Normal file
175
PCK-Studio/Forms/Editor/MaterialsEditor.cs
Normal file
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using MetroFramework.Forms;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OMI.Formats.Pck;
|
||||
using OMI.Formats.Material;
|
||||
using OMI.Workers.Material;
|
||||
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
public partial class MaterialsEditor : MetroForm
|
||||
{
|
||||
// Behaviours File Format research by Miku and MattNL
|
||||
private readonly PckFile.FileData _file;
|
||||
MaterialContainer materialFile;
|
||||
|
||||
void SetUpTree()
|
||||
{
|
||||
treeView1.BeginUpdate();
|
||||
treeView1.Nodes.Clear();
|
||||
foreach (var entry in materialFile)
|
||||
{
|
||||
TreeNode EntryNode = new TreeNode(entry.Name);
|
||||
|
||||
foreach (JObject content in Utilities.MaterialUtil.entityData["entities"].Children())
|
||||
{
|
||||
var prop = content.Properties().FirstOrDefault(prop => prop.Name == entry.Name);
|
||||
if (prop is JProperty)
|
||||
{
|
||||
EntryNode.Text = (string)prop.Value;
|
||||
EntryNode.ImageIndex = Utilities.MaterialUtil.entityData["entities"].Children().ToList().IndexOf(content);
|
||||
EntryNode.SelectedImageIndex = EntryNode.ImageIndex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
EntryNode.Tag = entry;
|
||||
|
||||
treeView1.Nodes.Add(EntryNode);
|
||||
}
|
||||
treeView1.EndUpdate();
|
||||
}
|
||||
|
||||
public MaterialsEditor(PckFile.FileData file)
|
||||
{
|
||||
InitializeComponent();
|
||||
_file = file;
|
||||
|
||||
using (var stream = new MemoryStream(file.Data))
|
||||
{
|
||||
var reader = new MaterialFileReader();
|
||||
materialFile = reader.FromStream(stream);
|
||||
}
|
||||
|
||||
treeView1.ImageList = new ImageList();
|
||||
Utilities.MaterialUtil.entityImages.ToList().ForEach(img => treeView1.ImageList.Images.Add(img));
|
||||
treeView1.ImageList.ColorDepth = ColorDepth.Depth32Bit;
|
||||
SetUpTree();
|
||||
}
|
||||
|
||||
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
if (e.Node == null) return;
|
||||
|
||||
bool enable = e.Node.Tag is MaterialContainer.Material && treeView1.SelectedNode != null;
|
||||
materialComboBox.Enabled = enable;
|
||||
|
||||
if (e.Node.Tag is MaterialContainer.Material entry)
|
||||
{
|
||||
materialComboBox.SelectedIndexChanged -= materialComboBox_SelectedIndexChanged;
|
||||
materialComboBox.SelectedIndex = materialComboBox.Items.IndexOf(entry.Type);
|
||||
materialComboBox.SelectedIndexChanged += materialComboBox_SelectedIndexChanged;
|
||||
}
|
||||
}
|
||||
private void removeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (treeView1.SelectedNode == null) return;
|
||||
|
||||
treeView1.SelectedNode.Remove();
|
||||
}
|
||||
|
||||
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
||||
{
|
||||
materialComboBox.Enabled = false;
|
||||
}
|
||||
|
||||
private void addNewPositionOverrideToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void addNewEntryToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void treeView1_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Delete) removeToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
|
||||
private void treeView1_MouseHover(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void saveToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
materialFile = new MaterialContainer();
|
||||
|
||||
foreach (TreeNode node in treeView1.Nodes)
|
||||
{
|
||||
if(node.Tag is MaterialContainer.Material entry)
|
||||
{
|
||||
materialFile.Add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
var writer = new MaterialFileWriter(materialFile);
|
||||
writer.WriteToStream(stream);
|
||||
_file.SetData(stream.ToArray());
|
||||
}
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void addToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var diag = new Additional_Popups.EntityForms.AddEntry(Utilities.MaterialUtil.entityData, Utilities.MaterialUtil.entityImages);
|
||||
|
||||
if (diag.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (string.IsNullOrEmpty(diag.SelectedEntity)) return;
|
||||
if (materialFile.FindAll(mat => mat.Name == diag.SelectedEntity).Count() > 0)
|
||||
{
|
||||
MessageBox.Show(this, "You cannot have two entries for one entity. Please use the \"Add New Position Override\" tool to add multiple overrides for entities", "Error", MessageBoxButtons.OK);
|
||||
return;
|
||||
}
|
||||
var NewEntry = new MaterialContainer.Material(diag.SelectedEntity, "entity_alphatest");
|
||||
|
||||
TreeNode NewEntryNode = new TreeNode(NewEntry.Name);
|
||||
NewEntryNode.Tag = NewEntry;
|
||||
foreach (JObject content in Utilities.MaterialUtil.entityData["entities"].Children())
|
||||
{
|
||||
var prop = content.Properties().FirstOrDefault(prop => prop.Name == NewEntry.Name);
|
||||
if (prop is JProperty)
|
||||
{
|
||||
NewEntryNode.Text = (string)prop.Value;
|
||||
NewEntryNode.ImageIndex = Utilities.MaterialUtil.entityData["entities"].Children().ToList().IndexOf(content);
|
||||
NewEntryNode.SelectedImageIndex = NewEntryNode.ImageIndex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
treeView1.Nodes.Add(NewEntryNode);
|
||||
|
||||
addNewPositionOverrideToolStripMenuItem_Click(sender, e); // adds a Position Override to the new Override
|
||||
}
|
||||
}
|
||||
|
||||
private void materialComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (treeView1.SelectedNode.Tag is MaterialContainer.Material entry)
|
||||
{
|
||||
entry.Type = materialComboBox.SelectedItem.ToString();
|
||||
treeView1.SelectedNode.Tag = entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
137
PCK-Studio/Forms/Editor/MaterialsEditor.resx
Normal file
137
PCK-Studio/Forms/Editor/MaterialsEditor.resx
Normal file
@@ -0,0 +1,137 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="metroContextMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>125, 17</value>
|
||||
</metadata>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="saveToolStripMenuItem1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vAAADrwBlbxySQAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4yMfEgaZUAAADfSURBVDhPYxg8
|
||||
QLt++3yTGbf/Fm599P/Nh49wfPXxq/+rTt37f+Dak/8gOSBgAGEMANIMxGBFyAasPf/0v8GE8//z1t8C
|
||||
y4HU4DIALIluwLpLL+HiMANAGKoNAWASCavv/n/57gPcgOvP3oENOXj7NViOoAFGU6791+k4ghWD5Aga
|
||||
QCyGakMAkODcU89R/I8Ng9TgNADk14dPn/8/c+kqVgySgwUqVBsCwAx49urN/zsPHmPFIDmaGvAXJInN
|
||||
38gYasBfqDYE0K7dOn/Wvut/sfkdGYPUgJI9VNuAAwYGAGn6yvdevWgPAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1,4 +1,5 @@
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using OMI.Formats.Pck;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using PckStudio.ToolboxItems;
|
||||
using System;
|
||||
using System.Data;
|
||||
@@ -11,14 +12,14 @@ namespace PckStudio
|
||||
{
|
||||
public partial class AdvancedOptions : ThemeForm
|
||||
{
|
||||
PCKFile currentPCK;
|
||||
PckFile currentPCK;
|
||||
|
||||
public AdvancedOptions(PCKFile currentPCKIn)
|
||||
public AdvancedOptions(PckFile currentPCKIn)
|
||||
{
|
||||
InitializeComponent();
|
||||
currentPCK = currentPCKIn;
|
||||
treeMeta.Nodes.Clear();
|
||||
treeMeta.Nodes.AddRange(currentPCK.GatherPropertiesList().Select((s) => new TreeNode(s)).ToArray());
|
||||
treeMeta.Nodes.AddRange(currentPCK.GetPropertyList().Select((s) => new TreeNode(s)).ToArray());
|
||||
}
|
||||
|
||||
private void applyButton_Click(object sender, EventArgs e)
|
||||
@@ -27,22 +28,22 @@ namespace PckStudio
|
||||
{
|
||||
case "All":
|
||||
{
|
||||
foreach (PCKFile.FileData file in currentPCK.Files)
|
||||
foreach (PckFile.FileData file in currentPCK.Files)
|
||||
{
|
||||
file.properties.Add((entryTypeTextBox.Text, entryDataTextBox.Text));
|
||||
file.Properties.Add((entryTypeTextBox.Text, entryDataTextBox.Text));
|
||||
}
|
||||
MessageBox.Show("Data Added to All Entries");
|
||||
}
|
||||
break;
|
||||
case "64x64":
|
||||
{
|
||||
foreach (PCKFile.FileData file in currentPCK.Files)
|
||||
foreach (PckFile.FileData file in currentPCK.Files)
|
||||
{
|
||||
MemoryStream png = new MemoryStream(file.data);
|
||||
if (Path.GetExtension(file.filepath) == ".png" &&
|
||||
MemoryStream png = new MemoryStream(file.Data);
|
||||
if (Path.GetExtension(file.Filename) == ".png" &&
|
||||
Image.FromStream(png).Size.Height == Image.FromStream(png).Size.Width)
|
||||
{
|
||||
file.properties.Add((entryTypeTextBox.Text, entryDataTextBox.Text));
|
||||
file.Properties.Add((entryTypeTextBox.Text, entryDataTextBox.Text));
|
||||
}
|
||||
}
|
||||
MessageBox.Show("Data Added to 64x64 Image Entries");
|
||||
@@ -50,13 +51,13 @@ namespace PckStudio
|
||||
break;
|
||||
case "64x32":
|
||||
{
|
||||
foreach (PCKFile.FileData file in currentPCK.Files)
|
||||
foreach (PckFile.FileData file in currentPCK.Files)
|
||||
{
|
||||
MemoryStream png = new MemoryStream(file.data);
|
||||
if (Path.GetExtension(file.filepath) == ".png" &&
|
||||
MemoryStream png = new MemoryStream(file.Data);
|
||||
if (Path.GetExtension(file.Filename) == ".png" &&
|
||||
Image.FromStream(png).Size.Height == Image.FromStream(png).Size.Width / 2)
|
||||
{
|
||||
file.properties.Add((entryTypeTextBox.Text, entryDataTextBox.Text));
|
||||
file.Properties.Add((entryTypeTextBox.Text, entryDataTextBox.Text));
|
||||
}
|
||||
}
|
||||
MessageBox.Show("Data Added to 64x32 Image Entries");
|
||||
@@ -64,12 +65,12 @@ namespace PckStudio
|
||||
break;
|
||||
case "PNG Files":
|
||||
{
|
||||
foreach (PCKFile.FileData file in currentPCK.Files)
|
||||
foreach (PckFile.FileData file in currentPCK.Files)
|
||||
{
|
||||
MemoryStream png = new MemoryStream(file.data);
|
||||
if (Path.GetExtension(file.filepath) == ".png")
|
||||
MemoryStream png = new MemoryStream(file.Data);
|
||||
if (Path.GetExtension(file.Filename) == ".png")
|
||||
{
|
||||
file.properties.Add((entryTypeTextBox.Text, entryDataTextBox.Text));
|
||||
file.Properties.Add((entryTypeTextBox.Text, entryDataTextBox.Text));
|
||||
}
|
||||
}
|
||||
MessageBox.Show("Data Added to All PNG Image Entries");
|
||||
|
||||
@@ -3,28 +3,28 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Drawing2D;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System.Drawing.Imaging;
|
||||
using PckStudio.Classes.Utils;
|
||||
using PckStudio.Classes._3ds.Utils;
|
||||
using PckStudio.ToolboxItems;
|
||||
using OMI.Formats.Languages;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio
|
||||
{
|
||||
public partial class AddNewSkin : ThemeForm
|
||||
{
|
||||
|
||||
public PCKFile.FileData SkinFile => skin;
|
||||
public PCKFile.FileData CapeFile => cape;
|
||||
public PckFile.FileData SkinFile => skin;
|
||||
public PckFile.FileData CapeFile => cape;
|
||||
public bool HasCape = false;
|
||||
|
||||
LOCFile currentLoc;
|
||||
PCKFile.FileData skin = new PCKFile.FileData("dlcskinXYXYXYXY", PCKFile.FileData.FileType.SkinFile);
|
||||
PCKFile.FileData cape = new PCKFile.FileData("dlccapeXYXYXYXY", PCKFile.FileData.FileType.CapeFile);
|
||||
SkinANIM anim = new SkinANIM(eANIM_EFFECTS.NONE);
|
||||
PckFile.FileData skin = new PckFile.FileData("dlcskinXYXYXYXY", PckFile.FileData.FileType.SkinFile);
|
||||
PckFile.FileData cape = new PckFile.FileData("dlccapeXYXYXYXY", PckFile.FileData.FileType.CapeFile);
|
||||
SkinANIM anim = new SkinANIM();
|
||||
|
||||
eSkinType skinType;
|
||||
PCKProperties generatedModel = new PCKProperties();
|
||||
PckFile.PCKProperties generatedModel = new PckFile.PCKProperties();
|
||||
|
||||
enum eSkinType : int
|
||||
{
|
||||
@@ -48,7 +48,7 @@ namespace PckStudio
|
||||
switch (img.Height) // 64x64
|
||||
{
|
||||
case 64:
|
||||
anim.SetANIMFlag(eANIM_EFFECTS.RESOLUTION_64x64, true);
|
||||
anim.SetFlag(ANIM_EFFECTS.RESOLUTION_64x64, true);
|
||||
MessageBox.Show("64x64 Skin Detected");
|
||||
skinPictureBoxTexture.Width = skinPictureBoxTexture.Height;
|
||||
if (skinType != eSkinType._64x64 && skinType != eSkinType._64x64HD)
|
||||
@@ -59,8 +59,8 @@ namespace PckStudio
|
||||
skinType = eSkinType._64x64;
|
||||
break;
|
||||
case 32:
|
||||
anim.SetANIMFlag(eANIM_EFFECTS.RESOLUTION_64x64, false);
|
||||
anim.SetANIMFlag(eANIM_EFFECTS.SLIM_MODEL, false);
|
||||
anim.SetFlag(ANIM_EFFECTS.RESOLUTION_64x64, false);
|
||||
anim.SetFlag(ANIM_EFFECTS.SLIM_MODEL, false);
|
||||
MessageBox.Show("64x32 Skin Detected");
|
||||
skinPictureBoxTexture.Width = skinPictureBoxTexture.Height * 2;
|
||||
if (skinType == eSkinType._64x64)
|
||||
@@ -77,7 +77,7 @@ namespace PckStudio
|
||||
default:
|
||||
if (img.Width == img.Height) // 64x64 HD
|
||||
{
|
||||
anim.SetANIMFlag(eANIM_EFFECTS.RESOLUTION_64x64, true);
|
||||
anim.SetFlag(ANIM_EFFECTS.RESOLUTION_64x64, true);
|
||||
MessageBox.Show("64x64 HD Skin Detected");
|
||||
skinPictureBoxTexture.Width = skinPictureBoxTexture.Height;
|
||||
if (skinType != eSkinType._64x64 && skinType != eSkinType._64x64HD)
|
||||
@@ -89,8 +89,8 @@ namespace PckStudio
|
||||
}
|
||||
else if (img.Width == img.Height / 2) // 64x32 HD
|
||||
{
|
||||
anim.SetANIMFlag(eANIM_EFFECTS.RESOLUTION_64x64, false);
|
||||
anim.SetANIMFlag(eANIM_EFFECTS.SLIM_MODEL, false);
|
||||
anim.SetFlag(ANIM_EFFECTS.RESOLUTION_64x64, false);
|
||||
anim.SetFlag(ANIM_EFFECTS.SLIM_MODEL, false);
|
||||
MessageBox.Show("64x32 HD Skin Detected");
|
||||
skinPictureBoxTexture.Width = skinPictureBoxTexture.Height * 2;
|
||||
if (skinType == eSkinType._64x64)
|
||||
@@ -121,40 +121,40 @@ namespace PckStudio
|
||||
private void DrawModel()
|
||||
{
|
||||
Bitmap bmp = new Bitmap(displayBox.Width, displayBox.Height);
|
||||
bool isSlim = anim.GetANIMFlag(eANIM_EFFECTS.SLIM_MODEL);
|
||||
bool isSlim = anim.GetFlag(ANIM_EFFECTS.SLIM_MODEL);
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
{
|
||||
if(!anim.GetANIMFlag(eANIM_EFFECTS.HEAD_DISABLED))
|
||||
if(!anim.GetFlag(ANIM_EFFECTS.HEAD_DISABLED))
|
||||
{
|
||||
//Head
|
||||
g.DrawRectangle(Pens.Black, 70, 15, 40, 40);
|
||||
g.FillRectangle(Brushes.Gray, 71, 16, 39, 39);
|
||||
}
|
||||
if (!anim.GetANIMFlag(eANIM_EFFECTS.BODY_DISABLED))
|
||||
if (!anim.GetFlag(ANIM_EFFECTS.BODY_DISABLED))
|
||||
{
|
||||
//Body
|
||||
g.DrawRectangle(Pens.Black, 70, 55, 40, 60);
|
||||
g.FillRectangle(Brushes.Gray, 71, 56, 39, 59);
|
||||
}
|
||||
if (!anim.GetANIMFlag(eANIM_EFFECTS.RIGHT_ARM_DISABLED))
|
||||
if (!anim.GetFlag(ANIM_EFFECTS.RIGHT_ARM_DISABLED))
|
||||
{
|
||||
//Arm0
|
||||
g.DrawRectangle(Pens.Black , isSlim ? 55 : 50, 55, isSlim ? 15 : 20, 60);
|
||||
g.FillRectangle(Brushes.Gray, isSlim ? 56 : 51, 56, isSlim ? 14 : 19, 59);
|
||||
}
|
||||
if (!anim.GetANIMFlag(eANIM_EFFECTS.LEFT_ARM_DISABLED))
|
||||
if (!anim.GetFlag(ANIM_EFFECTS.LEFT_ARM_DISABLED))
|
||||
{
|
||||
//Arm1
|
||||
g.DrawRectangle(Pens.Black, 110, 55, isSlim ? 15 : 20, 60);
|
||||
g.FillRectangle(Brushes.Gray, 111, 56, isSlim ? 14 : 19, 59);
|
||||
}
|
||||
if (!anim.GetANIMFlag(eANIM_EFFECTS.RIGHT_LEG_DISABLED))
|
||||
if (!anim.GetFlag(ANIM_EFFECTS.RIGHT_LEG_DISABLED))
|
||||
{
|
||||
//Leg0
|
||||
g.DrawRectangle(Pens.Black, 70, 115, 20, 60);
|
||||
g.FillRectangle(Brushes.Gray, 71, 116, 19, 59);
|
||||
}
|
||||
if (!anim.GetANIMFlag(eANIM_EFFECTS.LEFT_LEG_DISABLED))
|
||||
if (!anim.GetFlag(ANIM_EFFECTS.LEFT_LEG_DISABLED))
|
||||
{
|
||||
//Leg1
|
||||
g.DrawRectangle(Pens.Black, 90, 115, 20, 60);
|
||||
@@ -216,6 +216,45 @@ namespace PckStudio
|
||||
|
||||
private void CreateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
int _skinId = -1;
|
||||
if (!int.TryParse(textSkinID.Text, out _skinId))
|
||||
{
|
||||
MessageBox.Show("The Skin ID Must be a Unique 8 Digit Number Thats Not Already in Use", "Invalid Skin ID", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
string skinId = _skinId.ToString("d08");
|
||||
skin.Filename = $"dlcskin{skinId}.png";
|
||||
string skinDisplayNameLocKey = $"IDS_dlcskin{skinId}_DISPLAYNAME";
|
||||
currentLoc.AddLocKey(skinDisplayNameLocKey, textSkinName.Text);
|
||||
skin.Properties.Add(("DISPLAYNAME", textSkinName.Text));
|
||||
skin.Properties.Add(("DISPLAYNAMEID", skinDisplayNameLocKey));
|
||||
if (!string.IsNullOrEmpty(textThemeName.Text))
|
||||
{
|
||||
skin.Properties.Add(("THEMENAME", textThemeName.Text));
|
||||
skin.Properties.Add(("THEMENAMEID", $"IDS_dlcskin{skinId}_THEMENAME"));
|
||||
currentLoc.AddLocKey($"IDS_dlcskin{skinId}_THEMENAME", textThemeName.Text);
|
||||
}
|
||||
skin.Properties.Add(("ANIM", anim.ToString()));
|
||||
skin.Properties.Add(("GAME_FLAGS", "0x18"));
|
||||
skin.Properties.Add(("FREE", "1"));
|
||||
|
||||
if (HasCape)
|
||||
{
|
||||
try
|
||||
{
|
||||
cape.Filename = $"dlccape{skinId}.png";
|
||||
skin.Properties.Add(("CAPEPATH", cape.Filename));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Cape could not be added.");
|
||||
}
|
||||
}
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
skinPictureBoxTexture.Image.Save(stream, ImageFormat.Png);
|
||||
skin.SetData(stream.ToArray());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -289,27 +328,27 @@ namespace PckStudio
|
||||
return;
|
||||
}
|
||||
string skinId = _skinId.ToString("d08");
|
||||
skin.filepath = $"dlcskin{skinId}.png";
|
||||
skin.Filename = $"dlcskin{skinId}.png";
|
||||
string skinDisplayNameLocKey = $"IDS_dlcskin{skinId}_DISPLAYNAME";
|
||||
currentLoc.AddLocKey(skinDisplayNameLocKey, textSkinName.Text);
|
||||
skin.properties.Add(("DISPLAYNAME", textSkinName.Text));
|
||||
skin.properties.Add(("DISPLAYNAMEID", skinDisplayNameLocKey));
|
||||
skin.Properties.Add(("DISPLAYNAME", textSkinName.Text));
|
||||
skin.Properties.Add(("DISPLAYNAMEID", skinDisplayNameLocKey));
|
||||
if (!string.IsNullOrEmpty(textThemeName.Text))
|
||||
{
|
||||
skin.properties.Add(("THEMENAME", textThemeName.Text));
|
||||
skin.properties.Add(("THEMENAMEID", $"IDS_dlcskin{skinId}_THEMENAME"));
|
||||
skin.Properties.Add(("THEMENAME", textThemeName.Text));
|
||||
skin.Properties.Add(("THEMENAMEID", $"IDS_dlcskin{skinId}_THEMENAME"));
|
||||
currentLoc.AddLocKey($"IDS_dlcskin{skinId}_THEMENAME", textThemeName.Text);
|
||||
}
|
||||
skin.properties.Add(("ANIM", anim.ToString()));
|
||||
skin.properties.Add(("GAME_FLAGS", "0x18"));
|
||||
skin.properties.Add(("FREE", "1"));
|
||||
skin.Properties.Add(("ANIM", anim.ToString()));
|
||||
skin.Properties.Add(("GAME_FLAGS", "0x18"));
|
||||
skin.Properties.Add(("FREE", "1"));
|
||||
|
||||
if (HasCape)
|
||||
{
|
||||
try
|
||||
{
|
||||
cape.filepath = $"dlccape{skinId}.png";
|
||||
skin.properties.Add(("CAPEPATH", cape.filepath));
|
||||
cape.Filename = $"dlccape{skinId}.png";
|
||||
skin.Properties.Add(("CAPEPATH", cape.Filename));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@ using Newtonsoft.Json;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System.Text.RegularExpressions;
|
||||
using PckStudio.ToolboxItems;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio
|
||||
{
|
||||
@@ -28,7 +29,7 @@ namespace PckStudio
|
||||
right
|
||||
}
|
||||
|
||||
PCKProperties boxes;
|
||||
PckFile.PCKProperties boxes;
|
||||
|
||||
Color backgroundColor = Color.FromArgb(0xff, 0x50, 0x50, 0x50);
|
||||
|
||||
@@ -127,7 +128,7 @@ namespace PckStudio
|
||||
}
|
||||
|
||||
|
||||
public GenerateModel(PCKProperties skinProperties, PictureBox preview)
|
||||
public GenerateModel(PckFile.PCKProperties skinProperties, PictureBox preview)
|
||||
{
|
||||
InitializeComponent();
|
||||
boxes = skinProperties;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using PckStudio.Properties;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using PckStudio.Classes.Extentions;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Forms.Utilities
|
||||
{
|
||||
@@ -17,18 +16,13 @@ namespace PckStudio.Forms.Utilities
|
||||
|
||||
public static readonly JObject tileData = JObject.Parse(Resources.tileData);
|
||||
private static Image[] _tileImages;
|
||||
public static Image[] tileImages
|
||||
|
||||
public static Image[] tileImages => _tileImages ??= Resources.terrain_sheet.CreateImageList(16).Concat(Resources.items_sheet.CreateImageList(16)).ToArray();
|
||||
|
||||
public static PckFile.FileData CreateNewAnimationFile(Image source, string tileName, bool isItem)
|
||||
{
|
||||
get {
|
||||
if (_tileImages == null)
|
||||
_tileImages = CreateImageList(Resources.terrain_sheet, 16, 16).Concat(CreateImageList(Resources.items_sheet, 16, 16)).ToArray();
|
||||
return _tileImages;
|
||||
}
|
||||
}
|
||||
public static PCKFile.FileData CreateNewAnimationFile(Image source, string tileName, bool isItem)
|
||||
{
|
||||
PCKFile.FileData file = new PCKFile.FileData($"res/textures/{GetAnimationSection(isItem)}/{tileName}.png", PCKFile.FileData.FileType.TextureFile);
|
||||
file.properties.Add(("ANIM", string.Empty));
|
||||
PckFile.FileData file = new PckFile.FileData($"res/textures/{GetAnimationSection(isItem)}/{tileName}.png", PckFile.FileData.FileType.TextureFile);
|
||||
file.Properties.Add(("ANIM", string.Empty));
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
source.Save(stream, ImageFormat.Png);
|
||||
@@ -36,30 +30,5 @@ namespace PckStudio.Forms.Utilities
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
private static IEnumerable<Image> CreateImageList(Image source, int width, int height)
|
||||
{
|
||||
int img_row_count = source.Width / width;
|
||||
int img_column_count = source.Height / height;
|
||||
for (int i = 0; i < img_column_count * img_row_count; i++)
|
||||
{
|
||||
int row = i / width;
|
||||
int column = i % height;
|
||||
Rectangle tileArea = new Rectangle(new Point(column * width, row * height), new Size(width, height));
|
||||
Bitmap tileImage = new Bitmap(width, height);
|
||||
using (Graphics gfx = Graphics.FromImage(tileImage))
|
||||
{
|
||||
gfx.SmoothingMode = SmoothingMode.None;
|
||||
gfx.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||
gfx.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
|
||||
gfx.DrawImage(source, new Rectangle(0, 0, width, height), tileArea, GraphicsUnit.Pixel);
|
||||
}
|
||||
yield return tileImage;
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
35
PCK-Studio/Forms/Utilities/BehaviourUtil.cs
Normal file
35
PCK-Studio/Forms/Utilities/BehaviourUtil.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using PckStudio.Properties;
|
||||
using PckStudio.Classes.Extentions;
|
||||
using OMI.Formats.Behaviour;
|
||||
using OMI.Workers.Behaviour;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Forms.Utilities
|
||||
{
|
||||
public static class BehaviourUtil
|
||||
{
|
||||
public static readonly JObject entityData = JObject.Parse(Resources.entityBehaviourData);
|
||||
private static Image[] _entityImages;
|
||||
|
||||
public static Image[] entityImages => _entityImages ??= Resources.entities_sheet.CreateImageList(32).ToArray();
|
||||
|
||||
public static PckFile.FileData CreateNewBehaviourFile()
|
||||
{
|
||||
PckFile.FileData file = new PckFile.FileData($"behaviours.bin", PckFile.FileData.FileType.BehavioursFile);
|
||||
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
var writer = new BehavioursWriter(new BehaviourFile());
|
||||
writer.WriteToStream(stream);
|
||||
file.SetData(stream.ToArray());
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
}
|
||||
}
|
||||
38
PCK-Studio/Forms/Utilities/MaterialUtil.cs
Normal file
38
PCK-Studio/Forms/Utilities/MaterialUtil.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using PckStudio.Properties;
|
||||
using PckStudio.Classes.Extentions;
|
||||
using OMI.Formats.Pck;
|
||||
using OMI.Formats.Material;
|
||||
using OMI.Workers.Material;
|
||||
|
||||
namespace PckStudio.Forms.Utilities
|
||||
{
|
||||
public static class MaterialUtil
|
||||
{
|
||||
public static readonly JObject entityData = JObject.Parse(Resources.entityMaterialData);
|
||||
private static Image[] _entityImages;
|
||||
public static Image[] entityImages => _entityImages ??= Resources.entities_sheet.CreateImageList(32).ToArray();
|
||||
|
||||
public static PckFile.FileData CreateNewMaterialsFile()
|
||||
{
|
||||
PckFile.FileData file = new PckFile.FileData($"entityMaterials.bin", PckFile.FileData.FileType.MaterialFile);
|
||||
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
var matFile = new MaterialContainer
|
||||
{
|
||||
new MaterialContainer.Material("bat", "entity_alphatest")
|
||||
};
|
||||
var writer = new MaterialFileWriter(matFile);
|
||||
writer.WriteToStream(stream);
|
||||
file.SetData(stream.ToArray());
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
}
|
||||
}
|
||||
35
PCK-Studio/Forms/Utilities/ModelsUtil.cs
Normal file
35
PCK-Studio/Forms/Utilities/ModelsUtil.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using PckStudio.Properties;
|
||||
using PckStudio.Classes.Extentions;
|
||||
using OMI.Formats.Model;
|
||||
using OMI.Formats.Pck;
|
||||
using OMI.Workers.Model;
|
||||
|
||||
namespace PckStudio.Forms.Utilities
|
||||
{
|
||||
public static class ModelsUtil
|
||||
{
|
||||
public static readonly JObject entityData = JObject.Parse(Resources.entityModelData);
|
||||
private static Image[] _entityImages;
|
||||
|
||||
public static Image[] entityImages => _entityImages ??= Resources.entities_sheet.CreateImageList(32).ToArray();
|
||||
|
||||
public static PckFile.FileData CreateNewModelsFile()
|
||||
{
|
||||
PckFile.FileData file = new PckFile.FileData($"models.bin", PckFile.FileData.FileType.ModelsFile);
|
||||
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
var writer = new ModelFileWriter(new ModelContainer());
|
||||
writer.WriteToStream(stream);
|
||||
file.SetData(stream.ToArray());
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,7 @@ namespace PckStudio.Forms.Utilities
|
||||
{
|
||||
try
|
||||
{
|
||||
Collections.TryDownloadPack(int.Parse(OnlineTreeView.SelectedNode.Tag.ToString()), VitaCheckBox.Checked, CategoryComboBox.Text);
|
||||
Collections.TryDownloadPack(CategoryComboBox.Text, int.Parse(OnlineTreeView.SelectedNode.Tag.ToString()), VitaCheckBox.Checked);
|
||||
MessageBox.Show("Download complete");/**/
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using PckStudio.Classes.Utils;
|
||||
using PckStudio.Forms.Additional_Popups;
|
||||
using PckStudio.ToolboxItems;
|
||||
|
||||
namespace PckStudio.Forms.Utilities.Skins
|
||||
@@ -19,52 +20,52 @@ namespace PckStudio.Forms.Utilities.Skins
|
||||
void processCheckBoxes(bool set_all = false, bool value = false)
|
||||
{
|
||||
#region processes every single checkbox with the correct ANIM flags
|
||||
helmetCheckBox.Enabled = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.HEAD_DISABLED);
|
||||
chestplateCheckBox.Enabled = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.BODY_DISABLED);
|
||||
leftArmorCheckBox.Enabled = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.LEFT_ARM_DISABLED);
|
||||
rightArmorCheckBox.Enabled = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.RIGHT_ARM_DISABLED);
|
||||
leftLeggingCheckBox.Enabled = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.LEFT_LEG_DISABLED);
|
||||
rightLeggingCheckBox.Enabled = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.RIGHT_LEG_DISABLED);
|
||||
helmetCheckBox.Enabled = set_all ? value : anim.GetFlag(ANIM_EFFECTS.HEAD_DISABLED);
|
||||
chestplateCheckBox.Enabled = set_all ? value : anim.GetFlag(ANIM_EFFECTS.BODY_DISABLED);
|
||||
leftArmorCheckBox.Enabled = set_all ? value : anim.GetFlag(ANIM_EFFECTS.LEFT_ARM_DISABLED);
|
||||
rightArmorCheckBox.Enabled = set_all ? value : anim.GetFlag(ANIM_EFFECTS.RIGHT_ARM_DISABLED);
|
||||
leftLeggingCheckBox.Enabled = set_all ? value : anim.GetFlag(ANIM_EFFECTS.LEFT_LEG_DISABLED);
|
||||
rightLeggingCheckBox.Enabled = set_all ? value : anim.GetFlag(ANIM_EFFECTS.RIGHT_LEG_DISABLED);
|
||||
|
||||
bobbingCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.HEAD_BOBBING_DISABLED);
|
||||
bodyCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.BODY_DISABLED);
|
||||
bodyOCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.BODY_OVERLAY_DISABLED);
|
||||
chestplateCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.FORCE_BODY_ARMOR);
|
||||
bobbingCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.HEAD_BOBBING_DISABLED);
|
||||
bodyCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.BODY_DISABLED);
|
||||
bodyOCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.BODY_OVERLAY_DISABLED);
|
||||
chestplateCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.FORCE_BODY_ARMOR);
|
||||
|
||||
classicCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.RESOLUTION_64x64);
|
||||
crouchCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.DO_BACKWARDS_CROUCH);
|
||||
dinnerboneCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.DINNERBONE);
|
||||
headCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.HEAD_DISABLED);
|
||||
classicCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.RESOLUTION_64x64);
|
||||
crouchCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.DO_BACKWARDS_CROUCH);
|
||||
dinnerboneCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.DINNERBONE);
|
||||
headCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.HEAD_DISABLED);
|
||||
|
||||
headOCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.HEAD_OVERLAY_DISABLED);
|
||||
helmetCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.FORCE_HEAD_ARMOR);
|
||||
leftArmCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.LEFT_ARM_DISABLED);
|
||||
leftArmOCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.LEFT_ARM_OVERLAY_DISABLED);
|
||||
headOCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.HEAD_OVERLAY_DISABLED);
|
||||
helmetCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.FORCE_HEAD_ARMOR);
|
||||
leftArmCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.LEFT_ARM_DISABLED);
|
||||
leftArmOCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.LEFT_ARM_OVERLAY_DISABLED);
|
||||
|
||||
leftArmorCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.FORCE_LEFT_ARM_ARMOR);
|
||||
leftLegCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.LEFT_LEG_DISABLED);
|
||||
leftLeggingCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.FORCE_LEFT_LEG_ARMOR);
|
||||
leftLegOCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.LEFT_LEG_OVERLAY_DISABLED);
|
||||
leftArmorCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.FORCE_LEFT_ARM_ARMOR);
|
||||
leftLegCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.LEFT_LEG_DISABLED);
|
||||
leftLeggingCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.FORCE_LEFT_LEG_ARMOR);
|
||||
leftLegOCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.LEFT_LEG_OVERLAY_DISABLED);
|
||||
|
||||
noArmorCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.ALL_ARMOR_DISABLED);
|
||||
rightArmCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.RIGHT_ARM_DISABLED);
|
||||
rightArmOCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.RIGHT_ARM_OVERLAY_DISABLED);
|
||||
rightArmorCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.FORCE_RIGHT_ARM_ARMOR);
|
||||
noArmorCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.ALL_ARMOR_DISABLED);
|
||||
rightArmCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.RIGHT_ARM_DISABLED);
|
||||
rightArmOCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.RIGHT_ARM_OVERLAY_DISABLED);
|
||||
rightArmorCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.FORCE_RIGHT_ARM_ARMOR);
|
||||
|
||||
rightLegCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.RIGHT_LEG_DISABLED);
|
||||
rightLeggingCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.FORCE_RIGHT_LEG_ARMOR);
|
||||
rightLegOCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.RIGHT_LEG_OVERLAY_DISABLED);
|
||||
santaCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.BAD_SANTA);
|
||||
rightLegCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.RIGHT_LEG_DISABLED);
|
||||
rightLeggingCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.FORCE_RIGHT_LEG_ARMOR);
|
||||
rightLegOCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.RIGHT_LEG_OVERLAY_DISABLED);
|
||||
santaCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.BAD_SANTA);
|
||||
|
||||
slimCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.SLIM_MODEL);
|
||||
staticArmsCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.STATIC_ARMS);
|
||||
staticLegsCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.STATIC_LEGS);
|
||||
statueCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.STATUE_OF_LIBERTY);
|
||||
slimCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.SLIM_MODEL);
|
||||
staticArmsCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.STATIC_ARMS);
|
||||
staticLegsCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.STATIC_LEGS);
|
||||
statueCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.STATUE_OF_LIBERTY);
|
||||
|
||||
syncArmsCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.SYNCED_ARMS);
|
||||
syncLegsCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.SYNCED_LEGS);
|
||||
unknownCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.unk_BIT4);
|
||||
zombieCheckBox.Checked = set_all ? value : anim.GetANIMFlag(eANIM_EFFECTS.ZOMBIE_ARMS);
|
||||
syncArmsCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.SYNCED_ARMS);
|
||||
syncLegsCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.SYNCED_LEGS);
|
||||
unknownCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.__BIT_4);
|
||||
zombieCheckBox.Checked = set_all ? value : anim.GetFlag(ANIM_EFFECTS.ZOMBIE_ARMS);
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -79,52 +80,52 @@ namespace PckStudio.Forms.Utilities.Skins
|
||||
initialANIM = anim = new SkinANIM(ANIM);
|
||||
|
||||
#region Event definitions, since the designer can't parse lambda experessions
|
||||
bobbingCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.HEAD_BOBBING_DISABLED); };
|
||||
bodyCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.BODY_DISABLED); };
|
||||
bodyOCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.BODY_OVERLAY_DISABLED); };
|
||||
chestplateCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.FORCE_BODY_ARMOR); };
|
||||
bobbingCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.HEAD_BOBBING_DISABLED); };
|
||||
bodyCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.BODY_DISABLED); };
|
||||
bodyOCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.BODY_OVERLAY_DISABLED); };
|
||||
chestplateCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.FORCE_BODY_ARMOR); };
|
||||
|
||||
classicCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.RESOLUTION_64x64); };
|
||||
crouchCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.DO_BACKWARDS_CROUCH); };
|
||||
dinnerboneCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.DINNERBONE); };
|
||||
headCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.HEAD_DISABLED); };
|
||||
classicCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.RESOLUTION_64x64); };
|
||||
crouchCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.DO_BACKWARDS_CROUCH); };
|
||||
dinnerboneCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.DINNERBONE); };
|
||||
headCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.HEAD_DISABLED); };
|
||||
|
||||
headOCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.HEAD_OVERLAY_DISABLED); };
|
||||
helmetCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.FORCE_HEAD_ARMOR); };
|
||||
leftArmCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.LEFT_ARM_DISABLED); };
|
||||
leftArmOCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.LEFT_ARM_OVERLAY_DISABLED); };
|
||||
headOCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.HEAD_OVERLAY_DISABLED); };
|
||||
helmetCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.FORCE_HEAD_ARMOR); };
|
||||
leftArmCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.LEFT_ARM_DISABLED); };
|
||||
leftArmOCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.LEFT_ARM_OVERLAY_DISABLED); };
|
||||
|
||||
leftArmorCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.FORCE_LEFT_ARM_ARMOR); };
|
||||
leftLegCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.LEFT_LEG_DISABLED); };
|
||||
leftLeggingCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.FORCE_LEFT_LEG_ARMOR); };
|
||||
leftLegOCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.LEFT_LEG_OVERLAY_DISABLED); };
|
||||
leftArmorCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.FORCE_LEFT_ARM_ARMOR); };
|
||||
leftLegCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.LEFT_LEG_DISABLED); };
|
||||
leftLeggingCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.FORCE_LEFT_LEG_ARMOR); };
|
||||
leftLegOCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.LEFT_LEG_OVERLAY_DISABLED); };
|
||||
|
||||
noArmorCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.ALL_ARMOR_DISABLED); };
|
||||
rightArmCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.RIGHT_ARM_DISABLED); };
|
||||
rightArmOCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.RIGHT_ARM_OVERLAY_DISABLED); };
|
||||
rightArmorCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.FORCE_RIGHT_ARM_ARMOR); };
|
||||
noArmorCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.ALL_ARMOR_DISABLED); };
|
||||
rightArmCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.RIGHT_ARM_DISABLED); };
|
||||
rightArmOCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.RIGHT_ARM_OVERLAY_DISABLED); };
|
||||
rightArmorCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.FORCE_RIGHT_ARM_ARMOR); };
|
||||
|
||||
rightLegCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.RIGHT_LEG_DISABLED); };
|
||||
rightLeggingCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.FORCE_RIGHT_LEG_ARMOR); };
|
||||
rightLegOCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.RIGHT_LEG_OVERLAY_DISABLED); };
|
||||
santaCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.BAD_SANTA); };
|
||||
rightLegCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.RIGHT_LEG_DISABLED); };
|
||||
rightLeggingCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.FORCE_RIGHT_LEG_ARMOR); };
|
||||
rightLegOCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.RIGHT_LEG_OVERLAY_DISABLED); };
|
||||
santaCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.BAD_SANTA); };
|
||||
|
||||
slimCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.SLIM_MODEL); };
|
||||
staticArmsCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.STATIC_ARMS); };
|
||||
staticLegsCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.STATIC_LEGS); };
|
||||
statueCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.STATUE_OF_LIBERTY); };
|
||||
slimCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.SLIM_MODEL); };
|
||||
staticArmsCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.STATIC_ARMS); };
|
||||
staticLegsCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.STATIC_LEGS); };
|
||||
statueCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.STATUE_OF_LIBERTY); };
|
||||
|
||||
syncArmsCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.SYNCED_ARMS); };
|
||||
syncLegsCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.SYNCED_LEGS); };
|
||||
unknownCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.unk_BIT4); };
|
||||
zombieCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.ZOMBIE_ARMS); };
|
||||
syncArmsCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.SYNCED_ARMS); };
|
||||
syncLegsCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.SYNCED_LEGS); };
|
||||
unknownCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.__BIT_4); };
|
||||
zombieCheckBox.CheckedChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.ZOMBIE_ARMS); };
|
||||
|
||||
helmetCheckBox.EnabledChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.FORCE_HEAD_ARMOR); };
|
||||
chestplateCheckBox.EnabledChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.FORCE_BODY_ARMOR); };
|
||||
rightArmorCheckBox.EnabledChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.FORCE_RIGHT_ARM_ARMOR); };
|
||||
leftArmorCheckBox.EnabledChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.FORCE_LEFT_ARM_ARMOR); };
|
||||
rightLeggingCheckBox.EnabledChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.FORCE_RIGHT_LEG_ARMOR); };
|
||||
leftLeggingCheckBox.EnabledChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, eANIM_EFFECTS.FORCE_LEFT_LEG_ARMOR); };
|
||||
helmetCheckBox.EnabledChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.FORCE_HEAD_ARMOR); };
|
||||
chestplateCheckBox.EnabledChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.FORCE_BODY_ARMOR); };
|
||||
rightArmorCheckBox.EnabledChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.FORCE_RIGHT_ARM_ARMOR); };
|
||||
leftArmorCheckBox.EnabledChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.FORCE_LEFT_ARM_ARMOR); };
|
||||
rightLeggingCheckBox.EnabledChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.FORCE_RIGHT_LEG_ARMOR); };
|
||||
leftLeggingCheckBox.EnabledChanged += (sender, EventArgs) => { flagChanged(sender, EventArgs, ANIM_EFFECTS.FORCE_LEFT_LEG_ARMOR); };
|
||||
#endregion
|
||||
processCheckBoxes();
|
||||
}
|
||||
@@ -137,18 +138,18 @@ namespace PckStudio.Forms.Utilities.Skins
|
||||
Close();
|
||||
}
|
||||
|
||||
private void flagChanged(object sender, EventArgs e, eANIM_EFFECTS flag)
|
||||
private void flagChanged(object sender, EventArgs e, ANIM_EFFECTS flag)
|
||||
{
|
||||
// Set value
|
||||
anim.SetANIMFlag(flag, ((CheckBox)sender).Checked && ((CheckBox)sender).Enabled);
|
||||
anim.SetFlag(flag, ((CheckBox)sender).Checked && ((CheckBox)sender).Enabled);
|
||||
|
||||
// Armor flags don't work if the respective parts are not enabled
|
||||
helmetCheckBox.Enabled = anim.GetANIMFlag(eANIM_EFFECTS.HEAD_DISABLED);
|
||||
chestplateCheckBox.Enabled = anim.GetANIMFlag(eANIM_EFFECTS.BODY_DISABLED);
|
||||
rightArmorCheckBox.Enabled = anim.GetANIMFlag(eANIM_EFFECTS.RIGHT_ARM_DISABLED);
|
||||
leftArmorCheckBox.Enabled = anim.GetANIMFlag(eANIM_EFFECTS.LEFT_ARM_DISABLED);
|
||||
rightLeggingCheckBox.Enabled = anim.GetANIMFlag(eANIM_EFFECTS.RIGHT_LEG_DISABLED);
|
||||
leftLeggingCheckBox.Enabled = anim.GetANIMFlag(eANIM_EFFECTS.LEFT_LEG_DISABLED);
|
||||
helmetCheckBox.Enabled = anim.GetFlag(ANIM_EFFECTS.HEAD_DISABLED);
|
||||
chestplateCheckBox.Enabled = anim.GetFlag(ANIM_EFFECTS.BODY_DISABLED);
|
||||
rightArmorCheckBox.Enabled = anim.GetFlag(ANIM_EFFECTS.RIGHT_ARM_DISABLED);
|
||||
leftArmorCheckBox.Enabled = anim.GetFlag(ANIM_EFFECTS.LEFT_ARM_DISABLED);
|
||||
rightLeggingCheckBox.Enabled = anim.GetFlag(ANIM_EFFECTS.RIGHT_LEG_DISABLED);
|
||||
leftLeggingCheckBox.Enabled = anim.GetFlag(ANIM_EFFECTS.LEFT_LEG_DISABLED);
|
||||
|
||||
animValue.Text = anim.ToString();
|
||||
}
|
||||
@@ -201,8 +202,8 @@ namespace PckStudio.Forms.Utilities.Skins
|
||||
saveFileDialog.Filter = "Skin textures|*.png";
|
||||
if (saveFileDialog.ShowDialog() != DialogResult.OK ||
|
||||
string.IsNullOrWhiteSpace(Path.GetDirectoryName(saveFileDialog.FileName))) return;
|
||||
bool isSlim = anim.GetANIMFlag(eANIM_EFFECTS.SLIM_MODEL);
|
||||
bool isClassic64 = anim.GetANIMFlag(eANIM_EFFECTS.RESOLUTION_64x64);
|
||||
bool isSlim = anim.GetFlag(ANIM_EFFECTS.SLIM_MODEL);
|
||||
bool isClassic64 = anim.GetFlag(ANIM_EFFECTS.RESOLUTION_64x64);
|
||||
bool isClassic32 = !isSlim && !isClassic64;
|
||||
|
||||
Image skin = isSlim ? Properties.Resources.slim_template : Properties.Resources.classic_template;
|
||||
@@ -212,28 +213,28 @@ namespace PckStudio.Forms.Utilities.Skins
|
||||
using (Graphics g = Graphics.FromImage(nb))
|
||||
{
|
||||
g.DrawImage(skin, new Rectangle(0, 0, 64, isClassic32 ? 32 : 64), new Rectangle(0, 0, 64, isClassic32 ? 32 : 64), GraphicsUnit.Pixel);
|
||||
if (anim.GetANIMFlag(eANIM_EFFECTS.HEAD_OVERLAY_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(32, 0, 32, 16));
|
||||
if (anim.GetANIMFlag(eANIM_EFFECTS.HEAD_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(0, 0, 32, 16));
|
||||
if (anim.GetANIMFlag(eANIM_EFFECTS.BODY_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(16, 16, 24, 16));
|
||||
if (anim.GetFlag(ANIM_EFFECTS.HEAD_OVERLAY_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(32, 0, 32, 16));
|
||||
if (anim.GetFlag(ANIM_EFFECTS.HEAD_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(0, 0, 32, 16));
|
||||
if (anim.GetFlag(ANIM_EFFECTS.BODY_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(16, 16, 24, 16));
|
||||
if (nb.Height == 64)
|
||||
{
|
||||
if (anim.GetANIMFlag(eANIM_EFFECTS.RIGHT_ARM_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(40, 16, 16, 16));
|
||||
if (anim.GetANIMFlag(eANIM_EFFECTS.RIGHT_LEG_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(0, 16, 16, 16));
|
||||
if (anim.GetANIMFlag(eANIM_EFFECTS.BODY_OVERLAY_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(16, 32, 24, 16));
|
||||
if (anim.GetANIMFlag(eANIM_EFFECTS.RIGHT_ARM_OVERLAY_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(40, 32, 16, 16));
|
||||
if (anim.GetANIMFlag(eANIM_EFFECTS.RIGHT_LEG_OVERLAY_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(0, 32, 16, 16));
|
||||
if (anim.GetANIMFlag(eANIM_EFFECTS.LEFT_LEG_OVERLAY_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(0, 48, 16, 16));
|
||||
if (anim.GetANIMFlag(eANIM_EFFECTS.LEFT_LEG_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(16, 48, 16, 16));
|
||||
if (anim.GetANIMFlag(eANIM_EFFECTS.LEFT_ARM_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(32, 48, 16, 16));
|
||||
if (anim.GetANIMFlag(eANIM_EFFECTS.LEFT_ARM_OVERLAY_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(48, 48, 16, 16));
|
||||
if (anim.GetFlag(ANIM_EFFECTS.RIGHT_ARM_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(40, 16, 16, 16));
|
||||
if (anim.GetFlag(ANIM_EFFECTS.RIGHT_LEG_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(0, 16, 16, 16));
|
||||
if (anim.GetFlag(ANIM_EFFECTS.BODY_OVERLAY_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(16, 32, 24, 16));
|
||||
if (anim.GetFlag(ANIM_EFFECTS.RIGHT_ARM_OVERLAY_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(40, 32, 16, 16));
|
||||
if (anim.GetFlag(ANIM_EFFECTS.RIGHT_LEG_OVERLAY_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(0, 32, 16, 16));
|
||||
if (anim.GetFlag(ANIM_EFFECTS.LEFT_LEG_OVERLAY_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(0, 48, 16, 16));
|
||||
if (anim.GetFlag(ANIM_EFFECTS.LEFT_LEG_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(16, 48, 16, 16));
|
||||
if (anim.GetFlag(ANIM_EFFECTS.LEFT_ARM_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(32, 48, 16, 16));
|
||||
if (anim.GetFlag(ANIM_EFFECTS.LEFT_ARM_OVERLAY_DISABLED)) g.FillRectangle(Brushes.Magenta, new Rectangle(48, 48, 16, 16));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Since both classic 32 arms and legs use the same texture, removing the texture would remove both limbs instead of just one.
|
||||
// So both must be disabled by the user before they're removed from the texture;
|
||||
if (anim.GetANIMFlag(eANIM_EFFECTS.RIGHT_ARM_DISABLED) && anim.GetANIMFlag(eANIM_EFFECTS.LEFT_ARM_DISABLED))
|
||||
if (anim.GetFlag(ANIM_EFFECTS.RIGHT_ARM_DISABLED) && anim.GetFlag(ANIM_EFFECTS.LEFT_ARM_DISABLED))
|
||||
g.FillRectangle(Brushes.Magenta, new Rectangle(40, 16, 16, 16));
|
||||
if (anim.GetANIMFlag(eANIM_EFFECTS.RIGHT_LEG_DISABLED) && anim.GetANIMFlag(eANIM_EFFECTS.LEFT_LEG_DISABLED))
|
||||
if (anim.GetFlag(ANIM_EFFECTS.RIGHT_LEG_DISABLED) && anim.GetFlag(ANIM_EFFECTS.LEFT_LEG_DISABLED))
|
||||
g.FillRectangle(Brushes.Magenta, new Rectangle(0, 16, 16, 16));
|
||||
}
|
||||
nb.MakeTransparent(Color.Magenta);
|
||||
@@ -250,25 +251,23 @@ namespace PckStudio.Forms.Utilities.Skins
|
||||
processCheckBoxes();
|
||||
}
|
||||
|
||||
static readonly Dictionary<string, eANIM_EFFECTS> Templates = new Dictionary<string, eANIM_EFFECTS>()
|
||||
static readonly Dictionary<string, ANIM_EFFECTS> Templates = new Dictionary<string, ANIM_EFFECTS>()
|
||||
{
|
||||
{ "Steve (64x32)", eANIM_EFFECTS.NONE },
|
||||
{ "Steve (64x64)", eANIM_EFFECTS.RESOLUTION_64x64 },
|
||||
{ "Alex (64x64)", eANIM_EFFECTS.SLIM_MODEL },
|
||||
{ "Zombie Skins", eANIM_EFFECTS.ZOMBIE_ARMS },
|
||||
{ "Cetacean Skins", eANIM_EFFECTS.SYNCED_ARMS | eANIM_EFFECTS.SYNCED_LEGS },
|
||||
{ "Ski Skins", eANIM_EFFECTS.SYNCED_ARMS | eANIM_EFFECTS.STATIC_LEGS },
|
||||
{ "Ghost Skins", eANIM_EFFECTS.STATIC_LEGS | eANIM_EFFECTS.ZOMBIE_ARMS },
|
||||
{ "Medusa (Greek Myth.)", eANIM_EFFECTS.SYNCED_LEGS },
|
||||
{ "Librarian (Halo)", eANIM_EFFECTS.STATIC_LEGS },
|
||||
{ "Grim Reaper (Halloween)", eANIM_EFFECTS.STATIC_LEGS | eANIM_EFFECTS.STATIC_ARMS }
|
||||
{ "Steve (64x32)", ANIM_EFFECTS.NONE },
|
||||
{ "Steve (64x64)", ANIM_EFFECTS.RESOLUTION_64x64 },
|
||||
{ "Alex (64x64)", ANIM_EFFECTS.SLIM_MODEL },
|
||||
{ "Zombie Skins", ANIM_EFFECTS.ZOMBIE_ARMS },
|
||||
{ "Cetacean Skins", ANIM_EFFECTS.SYNCED_ARMS | ANIM_EFFECTS.SYNCED_LEGS },
|
||||
{ "Ski Skins", ANIM_EFFECTS.SYNCED_ARMS | ANIM_EFFECTS.STATIC_LEGS },
|
||||
{ "Ghost Skins", ANIM_EFFECTS.STATIC_LEGS | ANIM_EFFECTS.ZOMBIE_ARMS },
|
||||
{ "Medusa (Greek Myth.)", ANIM_EFFECTS.SYNCED_LEGS },
|
||||
{ "Librarian (Halo)", ANIM_EFFECTS.STATIC_LEGS },
|
||||
{ "Grim Reaper (Halloween)", ANIM_EFFECTS.STATIC_LEGS | ANIM_EFFECTS.STATIC_ARMS }
|
||||
};
|
||||
|
||||
private void templateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Recycling the AddCategory popup to handle the ANIM templates (:
|
||||
// diag.Category will be the ANIM codes
|
||||
var diag = new Additional_Popups.Audio.AddCategory(Templates.Keys.ToArray());
|
||||
var diag = new ItemSelectionPopUp(Templates.Keys.ToArray());
|
||||
diag.label2.Text = "Presets";
|
||||
//diag.button1.Text = "Load";
|
||||
//MNL or PhoenixARC or Miku, here is one problem. I removed the old button (button1) and relpaced it with the 'AddButton' but for osme reason, it does not work here.
|
||||
@@ -276,7 +275,7 @@ namespace PckStudio.Forms.Utilities.Skins
|
||||
|
||||
if (diag.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
var templateANIM = Templates[diag.Category];
|
||||
var templateANIM = Templates[diag.SelectedItem];
|
||||
DialogResult prompt = MessageBox.Show(this, "Would you like to add this preset's effects to your current ANIM? Otherwise all of your effects will be cleared. Either choice can be undone by pressing \"Restore ANIM\".", "", MessageBoxButtons.YesNo);
|
||||
if (prompt == DialogResult.Yes) anim |= templateANIM;
|
||||
else anim = templateANIM;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user