diff --git a/PCK-Studio/Controls/PckEditor.cs b/PCK-Studio/Controls/PckEditor.cs index c65e15ce..492fac77 100644 --- a/PCK-Studio/Controls/PckEditor.cs +++ b/PCK-Studio/Controls/PckEditor.cs @@ -32,9 +32,9 @@ using PckStudio.Helper; namespace PckStudio.Controls { - public partial class PckEditor : UserControl, IPckEditor + public partial class PckEditor : UserControl, IEditor { - public PckFile Pck => _pck; + public PckFile Value => _pck; private PckFile _pck; private string _location = string.Empty; diff --git a/PCK-Studio/Interfaces/IPckEditor.cs b/PCK-Studio/Interfaces/IEditor.cs similarity index 79% rename from PCK-Studio/Interfaces/IPckEditor.cs rename to PCK-Studio/Interfaces/IEditor.cs index 5473832b..dff71c5f 100644 --- a/PCK-Studio/Interfaces/IPckEditor.cs +++ b/PCK-Studio/Interfaces/IEditor.cs @@ -7,13 +7,13 @@ using OMI.Formats.Pck; namespace PckStudio.Interfaces { - internal interface IPckEditor + internal interface IEditor 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(); diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index 752567a2..b961a52e 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -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 editor) { - if (page.Controls[0] is IPckEditor _editor) + if (page.Controls[0] is IEditor _editor) { editor = _editor; return true; @@ -113,7 +113,7 @@ namespace PckStudio return false; } - private bool TryGetEditor(out IPckEditor editor) + private bool TryGetEditor(out IEditor 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(); diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index 08283f13..04bca953 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -183,7 +183,7 @@ TextureAtlasEditor.cs - +