From 14746d8c5196e23f05fd2fb5242b11947f7282cb Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sat, 27 Aug 2022 14:16:45 +0200 Subject: [PATCH] Add loading pck via terminal --- PCK-Studio/MainForm.cs | 28 +++++++++++++++------------- PCK-Studio/Program.cs | 5 ++++- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index 4f9a00ca..6ccf3154 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -47,6 +47,17 @@ namespace PckStudio #endif } + public void LoadFromPath(string filepath) + { + currentPCK = openPck(filepath); + if (currentPCK == null) return; + if (addPasswordToolStripMenuItem.Enabled = checkForPassword()) + { + LoadEditorTab(); + } + } + + private void Form1_Load(object sender, EventArgs e) { RPC.Initialize(); @@ -90,11 +101,7 @@ namespace PckStudio ofd.Filter = "PCK (Minecraft Console Package)|*.pck"; if (ofd.ShowDialog() == DialogResult.OK) { - currentPCK = openPck(ofd.FileName); - if (currentPCK == null) return; - if (addPasswordToolStripMenuItem.Enabled = checkForPassword()) - { - LoadEditorTab(); + LoadFromPath(ofd.FileName); } } } @@ -2780,15 +2787,10 @@ namespace PckStudio private void OpenPck_DragDrop(object sender, DragEventArgs e) { - string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false); - if (FileList.Length > 1) + string[] Filepaths = (string[])e.Data.GetData(DataFormats.FileDrop, false); + if (Filepaths.Length > 1) MessageBox.Show("Only one pck file at a time is currently supported"); - currentPCK = openPck(FileList[0]); - if (currentPCK == null) return; - if (addPasswordToolStripMenuItem.Enabled = checkForPassword()) - { - LoadEditorTab(); - } + LoadFromPath(Filepaths[0]); } private void OpenPck_DragLeave(object sender, EventArgs e) diff --git a/PCK-Studio/Program.cs b/PCK-Studio/Program.cs index 6e1a581c..e072d80d 100644 --- a/PCK-Studio/Program.cs +++ b/PCK-Studio/Program.cs @@ -14,7 +14,10 @@ namespace PckStudio [STAThread] static void Main(string[] args) { - Application.Run(new MainForm()); + var f = new MainForm(); + if (args.Length > 0 && args[0].EndsWith(".pck")) + f.LoadFromPath(args[0]); + Application.Run(f); } } }