Add loading pck via terminal

This commit is contained in:
miku-666
2022-08-27 14:16:45 +02:00
parent fcf3018d0d
commit 14746d8c51
2 changed files with 19 additions and 14 deletions

View File

@@ -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)

View File

@@ -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);
}
}
}