mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-21 20:13:06 +00:00
Add some useful shortcuts. Add Text editor fixes.
This commit is contained in:
parent
e4aa9272be
commit
655cdff142
12 changed files with 254 additions and 8 deletions
Binary file not shown.
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Toolbox.Library.IO;
|
||||
|
||||
namespace HedgehogLibrary
|
||||
{
|
||||
public class HeaderCommon
|
||||
{
|
||||
public const uint Signature = 0x133054A;
|
||||
|
||||
public Node Root;
|
||||
|
||||
public void Read(FileReader reader)
|
||||
{
|
||||
//Not sure but i've seen this used for checking game version
|
||||
ushort version = reader.ReadUInt16();
|
||||
if (version == 0x80)
|
||||
{
|
||||
ushort fileSize = reader.ReadUInt16();
|
||||
uint signature = reader.ReadUInt32();
|
||||
uint offsetTable = reader.ReadUInt32();
|
||||
uint offsetTableEntryCount = reader.ReadUInt32();
|
||||
|
||||
while (true)
|
||||
{
|
||||
ushort sectionFlag = reader.ReadUInt16();
|
||||
ushort sectionAddress = reader.ReadUInt16();
|
||||
uint sectionValue = reader.ReadUInt32();
|
||||
string sectionName = reader.ReadString(8, Encoding.ASCII);
|
||||
|
||||
if (sectionName == "Contexts")
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Node
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
56
File_Format_Library/FileFormats/HedgehogEngine/HedgeModel.cs
Normal file
56
File_Format_Library/FileFormats/HedgehogEngine/HedgeModel.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Toolbox.Library;
|
||||
|
||||
namespace HedgehogLibrary
|
||||
{
|
||||
public class HedgeModel : IFileFormat
|
||||
{
|
||||
public FileType FileType { get; set; } = FileType.Layout;
|
||||
|
||||
public bool CanSave { get; set; }
|
||||
public string[] Description { get; set; } = new string[] { "Hedgehog Engine Model" };
|
||||
public string[] Extension { get; set; } = new string[] { "*.model" };
|
||||
public string FileName { get; set; }
|
||||
public string FilePath { get; set; }
|
||||
public IFileInfo IFileInfo { get; set; }
|
||||
|
||||
public bool Identify(System.IO.Stream stream)
|
||||
{
|
||||
using (var reader = new Toolbox.Library.IO.FileReader(stream, true))
|
||||
{
|
||||
reader.SetByteOrder(true);
|
||||
|
||||
reader.Seek(4);
|
||||
bool IsValid = reader.ReadInt32() == 0x133054A;
|
||||
reader.Position = 0;
|
||||
|
||||
return IsValid;
|
||||
}
|
||||
}
|
||||
|
||||
public Type[] Types
|
||||
{
|
||||
get
|
||||
{
|
||||
List<Type> types = new List<Type>();
|
||||
return types.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public void Load(System.IO.Stream stream)
|
||||
{
|
||||
}
|
||||
public void Unload()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Save(System.IO.Stream stream)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,14 +9,14 @@ using Toolbox.Library;
|
|||
using Toolbox.Library.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace FirstPlugin
|
||||
namespace HedgehogLibrary
|
||||
{
|
||||
public class PACx : IArchiveFile, IFileFormat
|
||||
{
|
||||
public FileType FileType { get; set; } = FileType.Archive;
|
||||
|
||||
public bool CanSave { get; set; }
|
||||
public string[] Description { get; set; } = new string[] { "Sonic Forces / Tokyo Olympics 2020 Archive" };
|
||||
public string[] Description { get; set; } = new string[] { "Hedgehog Engine Archive" };
|
||||
public string[] Extension { get; set; } = new string[] { "*.pac" };
|
||||
public string FileName { get; set; }
|
||||
public string FilePath { get; set; }
|
|
@ -208,7 +208,9 @@
|
|||
<Compile Include="FileFormats\Archives\ARC.cs" />
|
||||
<Compile Include="FileFormats\Archives\GFA.cs" />
|
||||
<Compile Include="FileFormats\Archives\LM2\LM2_Material.cs" />
|
||||
<Compile Include="FileFormats\Archives\Sonic Forces\PACx.cs" />
|
||||
<Compile Include="FileFormats\HedgehogEngine\HeaderCommon.cs" />
|
||||
<Compile Include="FileFormats\HedgehogEngine\HedgeModel.cs" />
|
||||
<Compile Include="FileFormats\HedgehogEngine\PACx.cs" />
|
||||
<Compile Include="FileFormats\CrashBandicoot\IGZ_Structure.cs" />
|
||||
<Compile Include="FileFormats\Grezzo\CMB_Enums.cs" />
|
||||
<Compile Include="FileFormats\Grezzo\CSAB.cs" />
|
||||
|
|
|
@ -359,7 +359,7 @@ namespace FirstPlugin
|
|||
Formats.Add(typeof(GCDisk));
|
||||
Formats.Add(typeof(TPL));
|
||||
Formats.Add(typeof(BFTTF));
|
||||
Formats.Add(typeof(PACx));
|
||||
Formats.Add(typeof(HedgehogLibrary.PACx));
|
||||
Formats.Add(typeof(BinGzArchive));
|
||||
Formats.Add(typeof(GAR));
|
||||
Formats.Add(typeof(CTXB));
|
||||
|
|
|
@ -203,7 +203,11 @@ namespace Toolbox.Library.Forms
|
|||
}
|
||||
private void UpdateLineNumbers(int startingAtLine)
|
||||
{
|
||||
scintilla1.Margins[0].Width = scintilla1.TextWidth(Style.LineNumber, new string('9', maxLineNumberCharLength + 1)) + 2;
|
||||
for (int i = startingAtLine; i < scintilla1.Lines.Count; i++)
|
||||
{
|
||||
scintilla1.Lines[i].MarginStyle = Style.LineNumber;
|
||||
scintilla1.Lines[i].MarginText = i.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -121,6 +121,7 @@ namespace Toolbox
|
|||
LoadRecentList();
|
||||
ReloadFiles();
|
||||
LoadPluginFileContextMenus();
|
||||
WindowsExplorer.ExplorerContextMenu.LoadMenus();
|
||||
|
||||
foreach (string file in OpenedFiles)
|
||||
{
|
||||
|
@ -224,7 +225,11 @@ namespace Toolbox
|
|||
|
||||
#region OpenFile
|
||||
|
||||
private void openToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void openToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||
OpenFileSelect();
|
||||
}
|
||||
|
||||
private void OpenFileSelect()
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = Utils.GetAllFilters(SupportedFormats);
|
||||
|
@ -822,12 +827,28 @@ namespace Toolbox
|
|||
#region Events
|
||||
private void MainForm_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Control && e.KeyCode == Keys.S) // Ctrl + S Save
|
||||
if (e.Control && e.KeyCode == Keys.O) // Ctrl + O Open
|
||||
{
|
||||
e.SuppressKeyPress = true;
|
||||
OpenFileSelect();
|
||||
}
|
||||
else if (e.Control && e.Alt && e.KeyCode == Keys.S) // Ctrl + Alt + S Save As
|
||||
{
|
||||
e.SuppressKeyPress = true;
|
||||
SaveActiveFile(true);
|
||||
}
|
||||
else if(e.Control && e.KeyCode == Keys.S) // Ctrl + S Save
|
||||
{
|
||||
e.SuppressKeyPress = true;
|
||||
|
||||
SaveActiveFile(false);
|
||||
}
|
||||
else if (e.Control && e.KeyCode == Keys.W) // Ctrl + W Exit
|
||||
{
|
||||
e.SuppressKeyPress = true;
|
||||
var notify = MessageBox.Show("Are you sure you want to exit the application?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
|
||||
if (notify == DialogResult.OK)
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
|
||||
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||
|
|
|
@ -139,6 +139,7 @@
|
|||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UpdateProgram.cs" />
|
||||
<Compile Include="VersionCheck.cs" />
|
||||
<Compile Include="WindowsExplorer\ExplorerContextMeny.cs" />
|
||||
<EmbeddedResource Include="GUI\Credits.resx">
|
||||
<DependentUpon>Credits.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
|
117
Toolbox/WindowsExplorer/ExplorerContextMeny.cs
Normal file
117
Toolbox/WindowsExplorer/ExplorerContextMeny.cs
Normal file
|
@ -0,0 +1,117 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Win32;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Toolbox.WindowsExplorer
|
||||
{
|
||||
static class FileShellExtension
|
||||
{
|
||||
public static void Register(string keyText, string menuText, string regType = "*", string command = "")
|
||||
{
|
||||
string regPath = string.Format(@"{0}\shell\{1}", regType, keyText);
|
||||
string cmdPath = string.Format(@"{0}\shell\{1}\command", regType, keyText);
|
||||
string iconPath = string.Format(@"{0}\shell\{1}\command", regType, keyText);
|
||||
|
||||
//Key for menu
|
||||
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(regPath))
|
||||
{
|
||||
key.SetValue(null, menuText);
|
||||
}
|
||||
|
||||
//Command key
|
||||
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(cmdPath)) {
|
||||
key.SetValue(null, command);
|
||||
}
|
||||
|
||||
//Add an icon key
|
||||
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(regPath)) {
|
||||
key.SetValue("Icon", System.Reflection.Assembly.GetEntryAssembly().Location, Microsoft.Win32.RegistryValueKind.String);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Unregister(string fileType, string shellKeyName)
|
||||
{
|
||||
Debug.Assert(!string.IsNullOrEmpty(fileType) &&
|
||||
!string.IsNullOrEmpty(shellKeyName));
|
||||
|
||||
// path to the registry location
|
||||
string regPath = string.Format(@"{0}\shell\{1}",
|
||||
fileType, shellKeyName);
|
||||
|
||||
// remove context menu from the registry
|
||||
Registry.ClassesRoot.DeleteSubKeyTree(regPath);
|
||||
}
|
||||
}
|
||||
|
||||
public class ExplorerContextMenu
|
||||
{
|
||||
private const string FileMenuName = "File\\shell";
|
||||
private const string DirectoryMenuName = "Directory\\Background\\Shell";
|
||||
private const string FolderMenuName = "Folder\\shell";
|
||||
|
||||
private static string ApplicationExecutable
|
||||
{
|
||||
get { return System.Reflection.Assembly.GetEntryAssembly().Location; }
|
||||
}
|
||||
|
||||
public static void LoadMenus()
|
||||
{
|
||||
// RemoveRegistry("Compress YAZ0");
|
||||
// RemoveRegistry("Decompress YAZ0");
|
||||
|
||||
string menuCommand = string.Format("\"{0}\" \"%L\" \"-YAZ0\" \"-d\" ", ApplicationExecutable);
|
||||
|
||||
// FileShellExtension.Register("Switch Toolbox", "Switch Toolbox/Decompress YAZ0","*", menuCommand);
|
||||
// FileShellExtension.Register("jpegfile", "Switch Toolbox", "Decompress YAZ0", menuCommand);
|
||||
// AddFileRegistry("Compress YAZ0", "-Yaz0 -c");
|
||||
// AddDirectoryRegistry("Create Archive/New SARC", "-sarc -p");
|
||||
|
||||
// AddDirectoryRegistry("Compress YAZ0", "-Yaz0 -c");
|
||||
// AddDirectoryRegistry("Decompress YAZ0", "-Yaz0 -d");
|
||||
}
|
||||
|
||||
private static void AddFileRegistry(string fileType, string shellKeyName, string menuText, string menuCommand)
|
||||
{
|
||||
string regPath = string.Format(@"{0}\shell\{1}", fileType, shellKeyName);
|
||||
|
||||
// add context menu to the registry
|
||||
using (RegistryKey key =
|
||||
Registry.ClassesRoot.CreateSubKey(regPath))
|
||||
{
|
||||
key.SetValue(null, menuText);
|
||||
}
|
||||
|
||||
// add command that is invoked to the registry
|
||||
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(
|
||||
string.Format(@"{0}\command", regPath)))
|
||||
{
|
||||
key.SetValue(null, menuCommand);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddDirectoryRegistry(string MenuName, string Arguments)
|
||||
{
|
||||
RegistryKey _key = Registry.ClassesRoot.OpenSubKey(FolderMenuName, true);
|
||||
RegistryKey newkey = _key.CreateSubKey(MenuName);
|
||||
RegistryKey subNewkey = newkey.CreateSubKey("Command");
|
||||
subNewkey.SetValue("",string.Format("{0} {1}", ApplicationExecutable, Arguments));
|
||||
subNewkey.Close();
|
||||
newkey.Close();
|
||||
_key.Close();
|
||||
}
|
||||
|
||||
private static void RemoveDirectoryRegistry(string MenuName)
|
||||
{
|
||||
RegistryKey _key = Registry.ClassesRoot.OpenSubKey("Directory\\Background\\Shell\\", true);
|
||||
_key.DeleteSubKey(MenuName);
|
||||
_key.Close();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue