mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-06-27 11:05:37 +00:00
Changed IPckEditor to IEditor to be generic
This commit is contained in:
@@ -32,9 +32,9 @@ using PckStudio.Helper;
|
||||
|
||||
namespace PckStudio.Controls
|
||||
{
|
||||
public partial class PckEditor : UserControl, IPckEditor
|
||||
public partial class PckEditor : UserControl, IEditor<PckFile>
|
||||
{
|
||||
public PckFile Pck => _pck;
|
||||
public PckFile Value => _pck;
|
||||
|
||||
private PckFile _pck;
|
||||
private string _location = string.Empty;
|
||||
|
||||
@@ -7,13 +7,13 @@ using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Interfaces
|
||||
{
|
||||
internal interface IPckEditor
|
||||
internal interface IEditor<T> where T : class
|
||||
{
|
||||
PckFile Pck { get; }
|
||||
T Value { get; }
|
||||
|
||||
bool Open(string filepath, OMI.Endianness endianness);
|
||||
|
||||
bool Open(PckFile pck);
|
||||
bool Open(T value);
|
||||
|
||||
void Save();
|
||||
|
||||
@@ -102,9 +102,9 @@ namespace PckStudio
|
||||
MessageBox.Show(string.Format("Failed to load {0}", Path.GetFileName(filepath)), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
private bool TryGetEditor(TabPage page, out IPckEditor editor)
|
||||
private bool TryGetEditor(TabPage page, out IEditor<PckFile> editor)
|
||||
{
|
||||
if (page.Controls[0] is IPckEditor _editor)
|
||||
if (page.Controls[0] is IEditor<PckFile> _editor)
|
||||
{
|
||||
editor = _editor;
|
||||
return true;
|
||||
@@ -113,7 +113,7 @@ namespace PckStudio
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool TryGetEditor(out IPckEditor editor)
|
||||
private bool TryGetEditor(out IEditor<PckFile> editor)
|
||||
{
|
||||
return TryGetEditor(tabControl.SelectedTab, out editor);
|
||||
}
|
||||
@@ -251,7 +251,7 @@ namespace PckStudio
|
||||
|
||||
private void CloseTab(TabControl.TabPageCollection collection, TabPage page)
|
||||
{
|
||||
if (TryGetEditor(page, out IPckEditor editor))
|
||||
if (TryGetEditor(page, out var editor))
|
||||
{
|
||||
editor.Close();
|
||||
RemoveOpenFile(page);
|
||||
@@ -277,7 +277,7 @@ namespace PckStudio
|
||||
{
|
||||
if (TryGetEditor(out var editor))
|
||||
{
|
||||
using AdvancedOptions advanced = new AdvancedOptions(editor.Pck);
|
||||
using AdvancedOptions advanced = new AdvancedOptions(editor.Value);
|
||||
advanced.IsLittleEndian = LittleEndianCheckBox.Checked;
|
||||
if (advanced.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
@@ -536,7 +536,7 @@ namespace PckStudio
|
||||
numericPrompt.ContextLabel.Text = "Please insert the desired Pack ID";
|
||||
numericPrompt.TextLabel.Text = "Pack ID";
|
||||
|
||||
if (TryGetEditor(out IPckEditor editor))
|
||||
if (TryGetEditor(out var editor))
|
||||
{
|
||||
DialogResult prompt = MessageBox.Show(this,
|
||||
"Would you like to use the current PackID? You can enter any PackID if not.",
|
||||
@@ -546,7 +546,7 @@ namespace PckStudio
|
||||
switch (prompt)
|
||||
{
|
||||
case DialogResult.Yes:
|
||||
if (!editor.Pck.TryGetFile("0", PckFileType.InfoFile, out PckFileData file) ||
|
||||
if (!editor.Value.TryGetFile("0", PckFileType.InfoFile, out PckFileData file) ||
|
||||
string.IsNullOrEmpty(file.Properties.GetPropertyValue("PACKID")))
|
||||
{
|
||||
MessageBox.Show(this,
|
||||
@@ -665,7 +665,7 @@ namespace PckStudio
|
||||
{
|
||||
if (TryGetEditor(out var editor))
|
||||
{
|
||||
editor.Pck.SetVersion(fullBoxSupportToolStripMenuItem.Checked);
|
||||
editor.Value.SetVersion(fullBoxSupportToolStripMenuItem.Checked);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -677,7 +677,7 @@ namespace PckStudio
|
||||
|
||||
private void tabControl_PageClosing(object sender, PageClosingEventArgs e)
|
||||
{
|
||||
if (TryGetEditor(e.Page, out IPckEditor editor))
|
||||
if (TryGetEditor(e.Page, out var editor))
|
||||
{
|
||||
editor.Close();
|
||||
RemoveOpenFile();
|
||||
|
||||
@@ -183,7 +183,7 @@
|
||||
<Compile Include="Forms\Editor\TextureAtlasEditor.Designer.cs">
|
||||
<DependentUpon>TextureAtlasEditor.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Interfaces\IPckEditor.cs" />
|
||||
<Compile Include="Interfaces\IEditor.cs" />
|
||||
<Compile Include="Classes\API\PCKCenter\model\PCKCenterJSON.cs" />
|
||||
<Compile Include="Classes\API\PCKCenter\PCKCollections.cs" />
|
||||
<Compile Include="Classes\API\PCKCenter\PCKCollectionsLocal.cs" />
|
||||
|
||||
Reference in New Issue
Block a user