mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-26 08:52:52 +08:00
Support for saving files outside of RPFs in MetaForm, ModelForm and RelForm
This commit is contained in:
parent
ff93caafcd
commit
f98a7c8411
@ -343,7 +343,6 @@ namespace CodeWalker.Forms
|
||||
//(currently just return false and revert to XML file save)
|
||||
|
||||
if (!(exploreForm?.EditMode ?? false)) return false;
|
||||
if (rpfFileEntry?.Parent == null) return false;
|
||||
|
||||
byte[] data = null;
|
||||
|
||||
@ -409,6 +408,8 @@ namespace CodeWalker.Forms
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rpfFileEntry?.Parent != null)
|
||||
{
|
||||
if (!rpfFileEntry.Path.ToLowerInvariant().StartsWith("mods"))
|
||||
{
|
||||
if (MessageBox.Show("This file is NOT located in the mods folder - Are you SURE you want to save this file?\r\nWARNING: This could cause permanent damage to your game!!!", "WARNING: Are you sure about this?", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
@ -438,6 +439,26 @@ namespace CodeWalker.Forms
|
||||
{
|
||||
MessageBox.Show("Error saving file to RPF! The RPF archive may be corrupted...\r\n" + ex.ToString(), "Really Bad Error");
|
||||
}
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(rpfFileEntry?.Path))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(rpfFileEntry.Path, data);
|
||||
|
||||
exploreForm?.RefreshMainListViewInvoke(); //update the file details in explorer...
|
||||
|
||||
modified = false;
|
||||
|
||||
StatusLabel.Text = metaFormat.ToString() + " file saved successfully at " + DateTime.Now.ToString();
|
||||
|
||||
return true; //victory!
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error saving file to filesystem!\r\n" + ex.ToString(), "File I/O Error");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -1223,7 +1223,7 @@ namespace CodeWalker.Forms
|
||||
if (string.IsNullOrEmpty(FilePath))
|
||||
{
|
||||
if (!editMode) saveAs = true;
|
||||
if (rpfFileEntry?.Parent == null) saveAs = true;
|
||||
if (rpfFileEntry == null) saveAs = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1251,6 +1251,7 @@ namespace CodeWalker.Forms
|
||||
|
||||
if (SaveFileDialog.ShowDialog() != DialogResult.OK) return;
|
||||
fn = SaveFileDialog.FileName;
|
||||
FilePath = fn;
|
||||
}
|
||||
|
||||
|
||||
@ -1335,12 +1336,18 @@ namespace CodeWalker.Forms
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(fn))
|
||||
{
|
||||
fn = rpfFileEntry?.Path;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(fn, fileBytes);
|
||||
|
||||
fileName = Path.GetFileName(fn);
|
||||
FilePath = fn;
|
||||
|
||||
exploreForm?.RefreshMainListViewInvoke(); //update the file details in explorer...
|
||||
|
||||
StatusLabel.Text = fileName + " saved successfully at " + DateTime.Now.ToString();
|
||||
}
|
||||
|
@ -182,7 +182,6 @@ namespace CodeWalker.Forms
|
||||
{
|
||||
|
||||
if (!(exploreForm?.EditMode ?? false)) return false;
|
||||
if (rpfFileEntry?.Parent == null) return false;
|
||||
|
||||
byte[] data = null;
|
||||
|
||||
@ -219,6 +218,8 @@ namespace CodeWalker.Forms
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rpfFileEntry?.Parent != null)
|
||||
{
|
||||
if (!rpfFileEntry.Path.ToLowerInvariant().StartsWith("mods"))
|
||||
{
|
||||
if (MessageBox.Show("This file is NOT located in the mods folder - Are you SURE you want to save this file?\r\nWARNING: This could cause permanent damage to your game!!!", "WARNING: Are you sure about this?", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
@ -248,6 +249,26 @@ namespace CodeWalker.Forms
|
||||
{
|
||||
MessageBox.Show("Error saving file to RPF! The RPF archive may be corrupted...\r\n" + ex.ToString(), "Really Bad Error");
|
||||
}
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(rpfFileEntry?.Path))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(rpfFileEntry.Path, data);
|
||||
|
||||
exploreForm?.RefreshMainListViewInvoke(); //update the file details in explorer...
|
||||
|
||||
modified = false;
|
||||
|
||||
StatusLabel.Text = metaFormat.ToString() + " file saved successfully at " + DateTime.Now.ToString();
|
||||
|
||||
return true; //victory!
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error saving file to filesystem!\r\n" + ex.ToString(), "File I/O Error");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user