From 8ea1713f19ad251680bbc0894330e435b229cbad Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Mon, 25 Nov 2019 02:12:10 -0500 Subject: [PATCH] add 'CRI Extensions for FileSystemEditor' to plugins --- .../FileSystemEditorExtensions.cs | 191 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 46 +++++ ...salEditor.Plugins.CRI.UserInterface.csproj | 62 ++++++ CSharp/UniversalEditor.sln | 7 + 4 files changed, 306 insertions(+) create mode 100644 CSharp/Plugins.UserInterface/UniversalEditor.Plugins.CRI.UserInterface/FileSystemEditorExtensions.cs create mode 100644 CSharp/Plugins.UserInterface/UniversalEditor.Plugins.CRI.UserInterface/Properties/AssemblyInfo.cs create mode 100644 CSharp/Plugins.UserInterface/UniversalEditor.Plugins.CRI.UserInterface/UniversalEditor.Plugins.CRI.UserInterface.csproj diff --git a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.CRI.UserInterface/FileSystemEditorExtensions.cs b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.CRI.UserInterface/FileSystemEditorExtensions.cs new file mode 100644 index 00000000..f3607b5d --- /dev/null +++ b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.CRI.UserInterface/FileSystemEditorExtensions.cs @@ -0,0 +1,191 @@ +// +// MyClass.cs +// +// Author: +// Mike Becker +// +// Copyright (c) 2019 Mike Becker +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +using MBS.Framework.UserInterface; +using UniversalEditor.Plugins.CRI.DataFormats.FileSystem.CPK; +using UniversalEditor.UserInterface; + +namespace UniversalEditor.Plugins.CRI.UserInterface +{ + public class FileSystemEditorExtensions : EditorPlugin + { + public FileSystemEditorExtensions() + { + SupportedEditors.Add(typeof(Editors.FileSystem.FileSystemEditor)); + } + + protected override void InitializeInternal() + { + Context = new Context(new Guid("{7A5A7675-529E-46B1-A4FF-0786956DAE47}"), "CRI Extensions for FileSystemEditor"); + } + + private bool _initOnce = false; + protected override void OnEditorCreated(EventArgs e) + { + base.OnEditorCreated(e); + + if (_initOnce) + return; + + EditorReference er = Editor.MakeReference(); + + if (Document == null) + return; + if (!(Document.DataFormat is CPKDataFormat)) + return; + + Application.Commands.Add(new Command("CRI_FileSystem_Extensions", "CRI Tools", new CommandItem[] + { + new CommandReferenceCommandItem("CRI_FileSystem_Extensions_Export_Header"), + new CommandReferenceCommandItem("CRI_FileSystem_Extensions_Export_TOC"), + new CommandReferenceCommandItem("CRI_FileSystem_Extensions_Export_ITOC"), + new CommandReferenceCommandItem("CRI_FileSystem_Extensions_Export_GTOC"), + new CommandReferenceCommandItem("CRI_FileSystem_Extensions_Export_ETOC") + })); + Application.Commands.Add(new Command("CRI_FileSystem_Extensions_Export_Header", "Export Header UTF")); + Application.Commands.Add(new Command("CRI_FileSystem_Extensions_Export_TOC", "Export TOC UTF")); + Application.Commands.Add(new Command("CRI_FileSystem_Extensions_Export_ITOC", "Export ITOC UTF")); + Application.Commands.Add(new Command("CRI_FileSystem_Extensions_Export_GTOC", "Export GTOC UTF")); + Application.Commands.Add(new Command("CRI_FileSystem_Extensions_Export_ETOC", "Export ETOC UTF")); + + er.Commands["FileSystemContextMenu_Unselected"].Items.Add(new SeparatorCommandItem()); + er.Commands["FileSystemContextMenu_Unselected"].Items.Add(new CommandReferenceCommandItem("CRI_FileSystem_Extensions")); + + Context.AttachCommandEventHandler("CRI_FileSystem_Extensions_Export_Header", CRI_FileSystem_Extensions_Export_Header_Click); + Context.AttachCommandEventHandler("CRI_FileSystem_Extensions_Export_TOC", CRI_FileSystem_Extensions_Export_TOC_Click); + Context.AttachCommandEventHandler("CRI_FileSystem_Extensions_Export_ITOC", CRI_FileSystem_Extensions_Export_ITOC_Click); + Context.AttachCommandEventHandler("CRI_FileSystem_Extensions_Export_GTOC", CRI_FileSystem_Extensions_Export_GTOC_Click); + Context.AttachCommandEventHandler("CRI_FileSystem_Extensions_Export_ETOC", CRI_FileSystem_Extensions_Export_ETOC_Click); + + _initOnce = true; + } + + private void CRI_FileSystem_Extensions_Export_Header_Click(object sender, EventArgs e) + { + CPKDataFormat cpk = (Document.DataFormat as CPKDataFormat); + if (cpk == null) + return; + + if (cpk.HeaderData == null) + { + MBS.Framework.UserInterface.Dialogs.MessageDialog.ShowDialog("This archive does not contain a header (CPK ) table.", "Error", MBS.Framework.UserInterface.Dialogs.MessageDialogButtons.OK, MBS.Framework.UserInterface.Dialogs.MessageDialogIcon.Error); + return; + } + + MBS.Framework.UserInterface.Dialogs.FileDialog dlg = new MBS.Framework.UserInterface.Dialogs.FileDialog(); + dlg.Text = "Export header UTF"; + dlg.SelectedFileNames.Add("CpkHeader.utf"); + dlg.Mode = MBS.Framework.UserInterface.Dialogs.FileDialogMode.Save; + dlg.FileNameFilters.Add("CRI Middleware UTF table", "*.utf"); + if (dlg.ShowDialog() == MBS.Framework.UserInterface.DialogResult.OK) + { + System.IO.File.WriteAllBytes(dlg.SelectedFileNames[dlg.SelectedFileNames.Count - 1], cpk.HeaderData); + } + } + private void CRI_FileSystem_Extensions_Export_TOC_Click(object sender, EventArgs e) + { + CPKDataFormat cpk = (Document.DataFormat as CPKDataFormat); + if (cpk == null) + return; + + if (cpk.TocData == null) + { + MBS.Framework.UserInterface.Dialogs.MessageDialog.ShowDialog("This archive does not contain a file list TOC (TOC ) table.", "Error", MBS.Framework.UserInterface.Dialogs.MessageDialogButtons.OK, MBS.Framework.UserInterface.Dialogs.MessageDialogIcon.Error); + return; + } + + MBS.Framework.UserInterface.Dialogs.FileDialog dlg = new MBS.Framework.UserInterface.Dialogs.FileDialog(); + dlg.Text = "Export file list (TOC) UTF"; + dlg.SelectedFileNames.Add("CpkTocInfo.utf"); + dlg.Mode = MBS.Framework.UserInterface.Dialogs.FileDialogMode.Save; + dlg.FileNameFilters.Add("CRI Middleware UTF table", "*.utf"); + if (dlg.ShowDialog() == MBS.Framework.UserInterface.DialogResult.OK) + { + System.IO.File.WriteAllBytes(dlg.SelectedFileNames[dlg.SelectedFileNames.Count - 1], cpk.TocData); + } + } + private void CRI_FileSystem_Extensions_Export_ITOC_Click(object sender, EventArgs e) + { + CPKDataFormat cpk = (Document.DataFormat as CPKDataFormat); + if (cpk == null) + return; + + if (cpk.ITocData == null) + { + MBS.Framework.UserInterface.Dialogs.MessageDialog.ShowDialog("This archive does not contain an indexes TOC (ITOC) table.", "Error", MBS.Framework.UserInterface.Dialogs.MessageDialogButtons.OK, MBS.Framework.UserInterface.Dialogs.MessageDialogIcon.Error); + return; + } + + MBS.Framework.UserInterface.Dialogs.FileDialog dlg = new MBS.Framework.UserInterface.Dialogs.FileDialog(); + dlg.Text = "Export indexes (ITOC) UTF"; + dlg.SelectedFileNames.Add("CpkExtendId.utf"); + dlg.Mode = MBS.Framework.UserInterface.Dialogs.FileDialogMode.Save; + dlg.FileNameFilters.Add("CRI Middleware UTF table", "*.utf"); + if (dlg.ShowDialog() == MBS.Framework.UserInterface.DialogResult.OK) + { + System.IO.File.WriteAllBytes(dlg.SelectedFileNames[dlg.SelectedFileNames.Count - 1], cpk.ITocData); + } + } + private void CRI_FileSystem_Extensions_Export_GTOC_Click(object sender, EventArgs e) + { + CPKDataFormat cpk = (Document.DataFormat as CPKDataFormat); + if (cpk == null) + return; + + if (cpk.GTocData == null) + { + MBS.Framework.UserInterface.Dialogs.MessageDialog.ShowDialog("This archive does not contain a groups TOC (GTOC) table.", "Error", MBS.Framework.UserInterface.Dialogs.MessageDialogButtons.OK, MBS.Framework.UserInterface.Dialogs.MessageDialogIcon.Error); + return; + } + + MBS.Framework.UserInterface.Dialogs.FileDialog dlg = new MBS.Framework.UserInterface.Dialogs.FileDialog(); + dlg.Text = "Export groups (GTOC) UTF"; + dlg.Mode = MBS.Framework.UserInterface.Dialogs.FileDialogMode.Save; + dlg.FileNameFilters.Add("CRI Middleware UTF table", "*.utf"); + if (dlg.ShowDialog() == MBS.Framework.UserInterface.DialogResult.OK) + { + System.IO.File.WriteAllBytes(dlg.SelectedFileNames[dlg.SelectedFileNames.Count - 1], cpk.GTocData); + } + } + private void CRI_FileSystem_Extensions_Export_ETOC_Click(object sender, EventArgs e) + { + CPKDataFormat cpk = (Document.DataFormat as CPKDataFormat); + if (cpk == null) + return; + + if (cpk.ETocData == null) + { + MBS.Framework.UserInterface.Dialogs.MessageDialog.ShowDialog("This archive does not contain an end-of-file TOC (ETOC) table.", "Error", MBS.Framework.UserInterface.Dialogs.MessageDialogButtons.OK, MBS.Framework.UserInterface.Dialogs.MessageDialogIcon.Error); + return; + } + + MBS.Framework.UserInterface.Dialogs.FileDialog dlg = new MBS.Framework.UserInterface.Dialogs.FileDialog(); + dlg.Text = "Export end-of-file (ETOC) UTF"; + dlg.SelectedFileNames.Add("CpkEtocInfo.utf"); + dlg.Mode = MBS.Framework.UserInterface.Dialogs.FileDialogMode.Save; + dlg.FileNameFilters.Add("CRI Middleware UTF table", "*.utf"); + if (dlg.ShowDialog() == MBS.Framework.UserInterface.DialogResult.OK) + { + System.IO.File.WriteAllBytes(dlg.SelectedFileNames[dlg.SelectedFileNames.Count - 1], cpk.ETocData); + } + } + } +} diff --git a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.CRI.UserInterface/Properties/AssemblyInfo.cs b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.CRI.UserInterface/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..f36e487c --- /dev/null +++ b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.CRI.UserInterface/Properties/AssemblyInfo.cs @@ -0,0 +1,46 @@ +// +// AssemblyInfo.cs +// +// Author: +// Mike Becker +// +// Copyright (c) 2019 Mike Becker +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("UniversalEditor.Plugins.CRI.UserInterface")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("Mike Becker")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] diff --git a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.CRI.UserInterface/UniversalEditor.Plugins.CRI.UserInterface.csproj b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.CRI.UserInterface/UniversalEditor.Plugins.CRI.UserInterface.csproj new file mode 100644 index 00000000..ba42f87a --- /dev/null +++ b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.CRI.UserInterface/UniversalEditor.Plugins.CRI.UserInterface.csproj @@ -0,0 +1,62 @@ + + + + Debug + AnyCPU + {83709A63-8C43-4C67-80F6-00022986A086} + Library + UniversalEditor.Plugins.CRI.UserInterface + UniversalEditor.Plugins.CRI.UserInterface + + + true + full + false + ..\..\Output\Debug\Plugins + DEBUG; + prompt + 4 + false + + + true + ..\..\Output\Release\Plugins + prompt + 4 + false + + + + + + + + + + + {00266B21-35C9-4A7F-A6BA-D54D7FDCC25C} + MBS.Framework + + + {29E1C1BB-3EA5-4062-B62F-85EEC703FE07} + MBS.Framework.UserInterface + + + {2D4737E6-6D95-408A-90DB-8DFF38147E85} + UniversalEditor.Core + + + {30467E5C-05BC-4856-AADC-13906EF4CADD} + UniversalEditor.Essential + + + {8622EBC4-8E20-476E-B284-33D472081F5C} + UniversalEditor.UserInterface + + + {DBA93D1B-01BC-4218-8309-85FA0D5402FC} + UniversalEditor.Plugins.CRI + + + + \ No newline at end of file diff --git a/CSharp/UniversalEditor.sln b/CSharp/UniversalEditor.sln index 838da99c..df6c726f 100644 --- a/CSharp/UniversalEditor.sln +++ b/CSharp/UniversalEditor.sln @@ -147,6 +147,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Syn EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.CRI", "Plugins\UniversalEditor.Plugins.CRI\UniversalEditor.Plugins.CRI.csproj", "{DBA93D1B-01BC-4218-8309-85FA0D5402FC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.CRI.UserInterface", "Plugins.UserInterface\UniversalEditor.Plugins.CRI.UserInterface\UniversalEditor.Plugins.CRI.UserInterface.csproj", "{83709A63-8C43-4C67-80F6-00022986A086}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -423,6 +425,10 @@ Global {DBA93D1B-01BC-4218-8309-85FA0D5402FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {DBA93D1B-01BC-4218-8309-85FA0D5402FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {DBA93D1B-01BC-4218-8309-85FA0D5402FC}.Release|Any CPU.Build.0 = Release|Any CPU + {83709A63-8C43-4C67-80F6-00022986A086}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {83709A63-8C43-4C67-80F6-00022986A086}.Debug|Any CPU.Build.0 = Debug|Any CPU + {83709A63-8C43-4C67-80F6-00022986A086}.Release|Any CPU.ActiveCfg = Release|Any CPU + {83709A63-8C43-4C67-80F6-00022986A086}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {6F0AB1AF-E1A1-4D19-B19C-05BBB15C94B2} = {05D15661-E684-4EC9-8FBD-C014BA433CC5} @@ -491,6 +497,7 @@ Global {00266B21-35C9-4A7F-A6BA-D54D7FDCC25C} = {20F315E0-52AE-479F-AF43-3402482C1FC8} {0EEC3646-9749-48AF-848E-0F699247E76F} = {2ED32D16-6C06-4450-909A-40D32DA67FB4} {DBA93D1B-01BC-4218-8309-85FA0D5402FC} = {2ED32D16-6C06-4450-909A-40D32DA67FB4} + {83709A63-8C43-4C67-80F6-00022986A086} = {7B535D74-5496-4802-B809-89ED88274A91} EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution Policies = $0