mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-22 02:35:21 +00:00
Merge branch 'main' into JavaResourcePackImport
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using PckStudio.Interfaces;
|
||||
using System.IO;
|
||||
|
||||
namespace PckStudio.Controls
|
||||
{
|
||||
@@ -15,15 +16,18 @@ namespace PckStudio.Controls
|
||||
{
|
||||
public T EditorValue { get; }
|
||||
|
||||
public ISaveContext<T> SaveContext { get; }
|
||||
public ISaveContext<T> SaveContext { get; private set; }
|
||||
|
||||
public string TitleName { get; }
|
||||
|
||||
public EditorControl()
|
||||
{
|
||||
}
|
||||
|
||||
protected EditorControl(T value, ISaveContext<T> saveContext)
|
||||
protected EditorControl(string titleName, T value, ISaveContext<T> saveContext)
|
||||
{
|
||||
_ = value ?? throw new ArgumentNullException(nameof(value));
|
||||
TitleName = titleName;
|
||||
EditorValue = value;
|
||||
SaveContext = saveContext;
|
||||
}
|
||||
@@ -35,9 +39,20 @@ namespace PckStudio.Controls
|
||||
base.OnControlRemoved(e);
|
||||
}
|
||||
|
||||
public void Save() => SaveContext.Save(EditorValue);
|
||||
public void SetSaveContext(ISaveContext<T> saveContext) => SaveContext = saveContext;
|
||||
|
||||
public virtual void SaveAs() => throw new NotImplementedException();
|
||||
protected virtual void PreSave()
|
||||
{ }
|
||||
|
||||
protected virtual void PostSave()
|
||||
{ }
|
||||
|
||||
public void Save()
|
||||
{
|
||||
PreSave();
|
||||
SaveContext.Save(EditorValue);
|
||||
PostSave();
|
||||
}
|
||||
|
||||
public virtual void Close() => throw new NotImplementedException();
|
||||
|
||||
|
||||
@@ -52,9 +52,6 @@ namespace PckStudio.Controls
|
||||
{
|
||||
internal partial class PckEditor : EditorControl<PackInfo>
|
||||
{
|
||||
|
||||
private string _location = string.Empty;
|
||||
|
||||
private readonly OMI.ByteOrder _originalEndianness;
|
||||
private OMI.ByteOrder _currentEndianness;
|
||||
private bool __modified = false;
|
||||
@@ -78,8 +75,8 @@ namespace PckStudio.Controls
|
||||
|
||||
private readonly Dictionary<PckAssetType, Action<PckAsset>> _pckAssetTypeHandler;
|
||||
|
||||
public PckEditor(PackInfo packInfo, ISaveContext<PackInfo> saveContext)
|
||||
: base(packInfo, saveContext)
|
||||
public PckEditor(string name, PackInfo packInfo, ISaveContext<PackInfo> saveContext)
|
||||
: base(name, packInfo, saveContext)
|
||||
{
|
||||
InitializeComponent();
|
||||
_onModifiedChangeDelegate = OnModify;
|
||||
@@ -140,26 +137,13 @@ namespace PckStudio.Controls
|
||||
[PckAssetType.MaterialFile] = HandleMaterialFile,
|
||||
};
|
||||
}
|
||||
|
||||
public new void Save()
|
||||
|
||||
protected override void PostSave()
|
||||
{
|
||||
base.Save();
|
||||
_timesSaved++;
|
||||
_wasModified = false;
|
||||
}
|
||||
|
||||
public override void SaveAs()
|
||||
{
|
||||
using SaveFileDialog saveFileDialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "PCK (Minecraft Console Package)|*.pck",
|
||||
DefaultExt = ".pck",
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
SaveTo(saveFileDialog.FileName);
|
||||
pckFileLabel.Text = "Current PCK File: " + Path.GetFileName(_location);
|
||||
}
|
||||
MessageBox.Show("Pck Saved.", "Saved");
|
||||
Debug.WriteLine($"_timesSaved: {_timesSaved}");
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
@@ -178,12 +162,6 @@ namespace PckStudio.Controls
|
||||
BuildMainTreeView();
|
||||
}
|
||||
|
||||
private void SaveTo(string filepath)
|
||||
{
|
||||
_location = filepath;
|
||||
Save();
|
||||
}
|
||||
|
||||
private void HandleInnerPckFile(PckAsset asset)
|
||||
{
|
||||
if (asset.Type != PckAssetType.SkinDataFile && asset.Type != PckAssetType.TexturePackInfoFile || asset.Size <= 0 || !Settings.Default.LoadSubPcks)
|
||||
@@ -199,7 +177,7 @@ namespace PckStudio.Controls
|
||||
});
|
||||
|
||||
string caption = Path.GetFileName(asset.Filename);
|
||||
string identifier = _location + Path.GetFileName(asset.Filename);
|
||||
string identifier = TitleName + Path.GetFileName(asset.Filename);
|
||||
PckFile pckFile = asset.GetData(new PckFileReader(_originalEndianness));
|
||||
PackInfo packInfo = PackInfo.Create(pckFile, _originalEndianness, false);
|
||||
|
||||
@@ -1313,7 +1291,8 @@ namespace PckStudio.Controls
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(_location))
|
||||
// TODO: ! -null
|
||||
if (true)
|
||||
{
|
||||
MessageBox.Show(this, "You must save your pck before creating or opening a music cues PCK file", "Can't create audio.pck");
|
||||
return;
|
||||
|
||||
4
PCK-Studio/Forms/ContributorsForm.Designer.cs
generated
4
PCK-Studio/Forms/ContributorsForm.Designer.cs
generated
@@ -70,9 +70,9 @@
|
||||
metroLabel5.Enabled = false;
|
||||
metroLabel5.Location = new System.Drawing.Point(397, 456);
|
||||
metroLabel5.Name = "metroLabel5";
|
||||
metroLabel5.Size = new System.Drawing.Size(300, 19);
|
||||
metroLabel5.Size = new System.Drawing.Size(298, 19);
|
||||
metroLabel5.TabIndex = 5;
|
||||
metroLabel5.Text = "Additional development by MattNL and Miku-666";
|
||||
metroLabel5.Text = "Additional development by Miku-666 and MayNL";
|
||||
metroLabel5.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// metroLabel6
|
||||
|
||||
@@ -35,7 +35,8 @@ using PckStudio.Properties;
|
||||
namespace PckStudio
|
||||
{
|
||||
public partial class MainForm : ImmersiveForm
|
||||
{
|
||||
{
|
||||
private const string DEFAULT_PCK_SAVECONTEXT_DESCRIPTION = "PCK (Minecraft Console Package)";
|
||||
private PckManager PckManager = null;
|
||||
|
||||
private Dictionary<string, TabPage> openTabPages = new Dictionary<string, TabPage>();
|
||||
@@ -92,7 +93,7 @@ namespace PckStudio
|
||||
|
||||
private void AddEditorPage(string caption, string identifier, RawAssetDLCPackage packInfo, ISaveContext<RawAssetDLCPackage> saveContext = null)
|
||||
{
|
||||
saveContext ??= GetDefaultSaveContext("./new.pck", "PCK (Minecraft Console Package)");
|
||||
saveContext ??= GetDefaultSaveContext("./new.pck", DEFAULT_PCK_SAVECONTEXT_DESCRIPTION);
|
||||
var editor = new RawAssetsEditor(packInfo, saveContext);
|
||||
AddPage(caption, identifier, editor);
|
||||
}
|
||||
@@ -102,7 +103,7 @@ namespace PckStudio
|
||||
switch (dlcPackage.GetDLCPackageType())
|
||||
{
|
||||
case DLCPackageType.RawAssets:
|
||||
ISaveContext<RawAssetDLCPackage> saveContext = GetDefaultSaveContext("", "PCK (Minecraft Console Package)");
|
||||
ISaveContext<RawAssetDLCPackage> saveContext = GetDefaultSaveContext("", DEFAULT_PCK_SAVECONTEXT_DESCRIPTION);
|
||||
var editor = new RawAssetsEditor(dlcPackage as RawAssetDLCPackage, saveContext);
|
||||
TabPage page = AddPage(dlcPackage.Name, dlcPackage.Name, editor);
|
||||
break;
|
||||
@@ -126,7 +127,7 @@ namespace PckStudio
|
||||
|
||||
private static ISaveContext<RawAssetDLCPackage> GetDefaultSaveContext(string filepath, string description)
|
||||
{
|
||||
return new DelegatedFileSaveContext<RawAssetDLCPackage>(filepath, false, new FileDialogFilter(description, "*" + Path.GetExtension(filepath)), (packInfo, stream) => new PckFileWriter(packInfo.PckFile, packInfo.ByteOrder).WriteToStream(stream));
|
||||
return new DelegatedFileSaveContext<RawAssetDLCPackage>(filepath, false, (packInfo, stream) => new PckFileWriter(packInfo.PckFile, packInfo.ByteOrder).WriteToStream(stream));
|
||||
}
|
||||
|
||||
private TabPage AddPage(string caption, string identifier, Control control)
|
||||
@@ -139,6 +140,7 @@ namespace PckStudio
|
||||
page.Name = identifier;
|
||||
page.Controls.Add(control);
|
||||
tabControl.TabPages.Add(page);
|
||||
openTabPages.Add(identifier, page);
|
||||
tabControl.SelectTab(page);
|
||||
return page;
|
||||
}
|
||||
@@ -272,7 +274,7 @@ namespace PckStudio
|
||||
{
|
||||
using var ofd = new OpenFileDialog();
|
||||
ofd.CheckFileExists = true;
|
||||
ofd.Filter = "PCK (Minecraft Console Package)|*.pck";
|
||||
ofd.Filter = $"{DEFAULT_PCK_SAVECONTEXT_DESCRIPTION}|*.pck";
|
||||
if (ofd.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
LoadPckFromFile(ofd.FileName);
|
||||
@@ -493,7 +495,17 @@ namespace PckStudio
|
||||
{
|
||||
if (TryGetCurrentEditor(out IEditor<RawAssetDLCPackage> editor))
|
||||
{
|
||||
editor.SaveAs();
|
||||
using SaveFileDialog saveFileDialog = new SaveFileDialog
|
||||
{
|
||||
FileName = editor.TitleName,
|
||||
Filter = "PCK (Minecraft Console Package)|*.pck",
|
||||
DefaultExt = ".pck",
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
||||
editor.SetSaveContext(GetDefaultSaveContext(saveFileDialog.FileName, DEFAULT_PCK_SAVECONTEXT_DESCRIPTION));
|
||||
editor.Save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace PckStudio
|
||||
Updater.SetOwner(MainInstance);
|
||||
if (args.Length > 0)
|
||||
{
|
||||
MainInstance.LoadPckFromFile(args.Where(arg => File.Exists(arg) && arg.EndsWith(".pck")));
|
||||
MainInstance.LoadPckFromFile(args.Where(arg => File.Exists(arg)));
|
||||
}
|
||||
Application.ApplicationExit += (sender, e) => { RPC.Deinitialize(); };
|
||||
MainInstance.Focus();
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Windows.Forms;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PckStudio.Interfaces;
|
||||
using PckStudio.Core;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace PckStudio.Core
|
||||
{
|
||||
@@ -18,26 +19,16 @@ namespace PckStudio.Core
|
||||
public bool AutoSave { get; }
|
||||
public string Filepath { get; private set; }
|
||||
private SerializeDataToStreamDelegate _serializeDataDelegate;
|
||||
private FileDialogFilter _dialogFilter;
|
||||
|
||||
public DelegatedFileSaveContext(string filepath, bool autoSave, FileDialogFilter dialogFilter, SerializeDataToStreamDelegate serializeDataDelegate)
|
||||
public DelegatedFileSaveContext(string filepath, bool autoSave, SerializeDataToStreamDelegate serializeDataDelegate)
|
||||
{
|
||||
AutoSave = autoSave;
|
||||
Filepath = filepath;
|
||||
_serializeDataDelegate = serializeDataDelegate;
|
||||
_dialogFilter = dialogFilter;
|
||||
}
|
||||
|
||||
public void Save(T value)
|
||||
{
|
||||
if (!File.Exists(Filepath))
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||
saveFileDialog.Filter = _dialogFilter.ToString();
|
||||
if (saveFileDialog.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
Filepath = saveFileDialog.FileName;
|
||||
}
|
||||
using (Stream stream = File.OpenWrite(Filepath))
|
||||
{
|
||||
_serializeDataDelegate(value, stream);
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Interfaces
|
||||
{
|
||||
public interface IEditor<T> where T : class
|
||||
public interface IEditor<T> where T : notnull
|
||||
{
|
||||
string TitleName { get; }
|
||||
|
||||
T EditorValue { get; }
|
||||
|
||||
ISaveContext<T> SaveContext { get; }
|
||||
|
||||
void Save();
|
||||
void SetSaveContext(ISaveContext<T> saveContext);
|
||||
|
||||
void SaveAs();
|
||||
void Save();
|
||||
|
||||
void Close();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{B1E19D0F-6DD5-4D91-9B45-9818759CA8EF}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<DefineConstants Condition="'$(Configuration)' != 'Debug'">NDEBUG</DefineConstants>
|
||||
<DefineConstants Condition="'$(Configuration)' != 'Debug'">NDEBUG</DefineConstants>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>PckStudio.Rendering</RootNamespace>
|
||||
<AssemblyName>PckStudio.Rendering</AssemblyName>
|
||||
|
||||
@@ -70,6 +70,13 @@ namespace PckStudio.ModelSupport
|
||||
if (!blockBenchModel.Format.UseBoxUv)
|
||||
{
|
||||
Trace.TraceError($"[{nameof(SkinModelImporter)}:{nameof(ImportBlockBenchModel)}] Failed to import skin '{blockBenchModel.Name}': Skin does not use box uv.");
|
||||
MessageBox.Show("Skin does not use box uv.", $"Failed to import skin '{blockBenchModel.Name}'", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return null;
|
||||
}
|
||||
if (!blockBenchModel.Elements.All(e => e.UseBoxUv))
|
||||
{
|
||||
Trace.TraceError($"[{nameof(SkinModelImporter)}:{nameof(ImportBlockBenchModel)}] Failed to import skin '{blockBenchModel.Name}': Some boxes do not use box uv.");
|
||||
MessageBox.Show("Some boxes do not use box uv.", $"Failed to import skin '{blockBenchModel.Name}'", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -443,6 +450,8 @@ namespace PckStudio.ModelSupport
|
||||
|
||||
private static string TryConvertToSkinBoxType(string name)
|
||||
{
|
||||
if (name is null)
|
||||
return string.Empty;
|
||||
if (!SkinBOX.IsValidType(name) && SkinBOX.IsValidType(name.ToUpper()))
|
||||
{
|
||||
return name.ToUpper();
|
||||
|
||||
@@ -48,7 +48,7 @@ $ cd PCK-Studio
|
||||
|
||||
## Active Developers:
|
||||
> [PhoenixARC](https://github.com/PhoenixARC)<br>
|
||||
> [MattNL](https://github.com/MattN-L)<br>
|
||||
> [MayNL](https://github.com/MayN-L)<br>
|
||||
> [Miku-666](https://github.com/NessieHax)<br>
|
||||
> [EternalModz](https://github.com/EternalModz)<br>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": "7.0.1.0",
|
||||
"url": "https://github.com/PhoenixARC/-PCK-Studio/releases/download/v7.0.1.0/PCK-Studio.zip",
|
||||
"changelog": "https://raw.githubusercontent.com/PhoenixARC/-PCK-Studio/main/CHANGELOG.md",
|
||||
"version": "7.0.1.1",
|
||||
"url": "https://github.com/LCERD/PCK-Studio/releases/download/v7.0.1.1/PCK-Studio.zip",
|
||||
"changelog": "https://raw.githubusercontent.com/LCERD/PCK-Studio/main/CHANGELOG.md",
|
||||
"mandatory": false
|
||||
}
|
||||
Reference in New Issue
Block a user