Skip to content

Commit ca359cd

Browse files
authored
Merge pull request #655 from cjakeman/menu-block-bad-content-location
Menu block for bad content location
2 parents 748be1d + 6a2a582 commit ca359cd

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

Source/Documentation/Manual/options.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,10 @@ Content Options
447447

448448
.. image:: images/options-content.png
449449

450-
This window allows you to add, remove or modify access to additional MSTS
451-
installations or miniroute installations for Open Rails. Installations
452-
located on other drives, or on a USB key, can be added even if they are
450+
This window allows you to add, remove or modify access to content.
451+
Each profile may be a folder containing one or more routes, or an MSTS
452+
installation.
453+
Profiles located on other drives, or on a USB key, can be added even if they are
453454
not always available.
454455

455456
Click on the *Add* button, and locate the desired installation. ORTS will
@@ -458,6 +459,12 @@ appear in the *Installation set:* window on the main menu form. Modify
458459
the name if desired, then click *OK* to add the new path and name to
459460
Open Rails.
460461

462+
Please do not store content or any files within the folder containing the Open Rails software.
463+
This is because the Updater operates by wiping out the contents of that folder before replacing it
464+
with a new updated version.
465+
It would be unfriendly for users to lose content that they have stored there, so
466+
attempts to add a profile folder stored there are blocked and lead to an error message.
467+
461468
To remove an entry (note that this does not remove the installation
462469
itself!) select the entry in the window, and click *Delete*, then *OK*
463470
to close the window. To modify an entry, use the *Change...* button to

Source/Documentation/Manual/start.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,30 @@ After having successfully installed Open Rails (see the Installation
88
Manual), to run the game you must double-click on the Open Rails icon on
99
the desktop, or on the OpenRails.exe file.
1010

11-
The OpenRails main window will appear. This displays your available MSTS
12-
installation profiles.
11+
The OpenRails main window will appear.
12+
If you have an MSTS installation in place, this will be displayed as your available
13+
installation profile.
1314

1415
.. _start-picture:
1516

1617
.. image:: images/start-activity.png
1718

19+
If not, then you must download some content and add it as an Installation Profile.
20+
1821
Installation Profiles
1922
=====================
2023

21-
In the simplest case, where you have only a basic MSTS installation (see
24+
Each profile may be a folder containing one or more routes, or an optional MSTS
25+
installation.
26+
27+
In the case where you already have an MSTS installation (see
2228
paragraph :ref:`Does Open Rails need MSTS to run? <intro-MSTSneeded>` for a precise definition of
2329
a MSTS installation) OR should already correctly point to that
2430
installation. To check this, you should initially see under ``Installation
2531
Profile`` the string ``- Default -``. Under ``Route`` you should see the
2632
name of one of the MSTS routes in your MSTS installation.
2733

28-
You can easily add, remove or move other MSTS installations and select
34+
You can easily add, remove or move other content profiles and select
2935
among them (e.g. if you have any so-called ``mini-routes`` installed.).
3036
Click on the ``Options`` button and select the ``Content`` tab. See the
3137
:ref:`Content Options <options-Content>` discussed below for more instructions.

Source/Menu/Options.cs

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

679679
private void buttonContentDelete_Click(object sender, EventArgs e)
680+
{
681+
DeleteContent();
682+
}
683+
684+
private void DeleteContent()
680685
{
681686
bindingSourceContent.RemoveCurrent();
682687
// 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.
@@ -716,7 +721,19 @@ private void textBoxContentName_TextChanged(object sender, EventArgs e)
716721
var current = bindingSourceContent.Current as ContentFolder;
717722
if (current != null && current.Name != textBoxContentName.Text)
718723
{
719-
// Duplicate names lead to an exception, so append " copy" if not unique
724+
if (current.Path.ToLower().Contains(Application.StartupPath.ToLower()))
725+
{
726+
// Block added because a succesful Update operation will empty the Open Rails folder and lose any content stored within it.
727+
MessageBox.Show(catalog.GetString
728+
($"Cannot use content from any folder which lies inside the Open Rails folder {Application.StartupPath}\n\n")
729+
, "Invalid content location"
730+
, MessageBoxButtons.OK
731+
, MessageBoxIcon.Error);
732+
DeleteContent();
733+
return;
734+
}
735+
736+
// Duplicate names lead to an exception, so append " copy" repeatedly until no longer unique
720737
var suffix = "";
721738
var isNameUnique = true;
722739
while (isNameUnique)

0 commit comments

Comments
 (0)