Skip to content

Commit 02dd21d

Browse files
committed
Adds block to stop use of content located in Open Rails folder
1 parent f0f9cb4 commit 02dd21d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Source/Menu/Options.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,11 @@ private void buttonContentAdd_Click(object sender, EventArgs e)
674674
}
675675

676676
private void buttonContentDelete_Click(object sender, EventArgs e)
677+
{
678+
DeleteContent();
679+
}
680+
681+
private void DeleteContent()
677682
{
678683
bindingSourceContent.RemoveCurrent();
679684
// ResetBindings() is to work around a bug in the binding and/or data grid where by deleting the bottom item doesn't show the selection moving to the new bottom item.
@@ -713,7 +718,19 @@ private void textBoxContentName_TextChanged(object sender, EventArgs e)
713718
var current = bindingSourceContent.Current as ContentFolder;
714719
if (current != null && current.Name != textBoxContentName.Text)
715720
{
716-
// Duplicate names lead to an exception, so append " copy" if not unique
721+
if (current.Path.ToLower().Contains(Application.StartupPath.ToLower()))
722+
{
723+
// Block added because a succesful Update operation will empty the Open Rails folder and lose any content stored within it.
724+
MessageBox.Show(catalog.GetString
725+
($"Cannot use content from any folder which lies inside the Open Rails folder {Application.StartupPath}\n\n")
726+
, "Invalid content location"
727+
, MessageBoxButtons.OK
728+
, MessageBoxIcon.Error);
729+
DeleteContent();
730+
return;
731+
}
732+
733+
// Duplicate names lead to an exception, so append " copy" repeatedly until no longer unique
717734
var suffix = "";
718735
var isNameUnique = true;
719736
while (isNameUnique)

0 commit comments

Comments
 (0)