Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4c7cdc2

Browse files
committed
Added a user setting not to auto-mount archives when found
1 parent ebb3e0b commit 4c7cdc2

File tree

7 files changed

+87
-60
lines changed

7 files changed

+87
-60
lines changed

Source/Menu/MainForm.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ void RestartMenu()
365365
#region Folders
366366
void comboBoxFolder_SelectedIndexChanged(object sender, EventArgs e)
367367
{
368+
Vfs.LogLevel = Settings.VfsLogLevel;
369+
Vfs.NoAutoMount = Settings.VfsNoAutoMount;
368370
Vfs.Initialize(SelectedFolder.Path, System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath));
369371
LoadRouteList();
370372
LoadLocomotiveList();

Source/Menu/Options.Designer.cs

Lines changed: 68 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/Menu/Options.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ orderby folder.Key
339339
trackAdhesionFactor_ValueChanged(null, null);
340340
checkShapeWarnings.Checked = !Settings.SuppressShapeWarnings;
341341
numericVfsLogLevel.Value = Settings.VfsLogLevel;
342+
checkVfsNoAutoMount.Checked = Settings.VfsNoAutoMount;
342343
precipitationBoxHeight.Value = Settings.PrecipitationBoxHeight;
343344
precipitationBoxWidth.Value = Settings.PrecipitationBoxWidth;
344345
precipitationBoxLength.Value = Settings.PrecipitationBoxLength;
@@ -541,6 +542,7 @@ void buttonOK_Click(object sender, EventArgs e)
541542
Settings.AdhesionFactorChange = (int)trackAdhesionFactorChange.Value;
542543
Settings.SuppressShapeWarnings = !checkShapeWarnings.Checked;
543544
Settings.VfsLogLevel = Vfs.LogLevel = (int)numericVfsLogLevel.Value;
545+
Settings.VfsNoAutoMount = Vfs.NoAutoMount = checkVfsNoAutoMount.Checked;
544546
Settings.PrecipitationBoxHeight = (int)precipitationBoxHeight.Value;
545547
Settings.PrecipitationBoxWidth = (int)precipitationBoxWidth.Value;
546548
Settings.PrecipitationBoxLength = (int)precipitationBoxLength.Value;

Source/Menu/Options.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,4 @@
123123
<metadata name="bindingSourceContent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
124124
<value>114, 17</value>
125125
</metadata>
126-
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
127-
<value>17, 17</value>
128-
</metadata>
129126
</root>

Source/ORTS.Common/VirtualFileSystem.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static class Vfs
4444
static VfsNode VfsRoot;
4545
static readonly Stack<(string, VfsNode)> Stack = new Stack<(string, VfsNode)>();
4646
static readonly ConcurrentDictionary<string, object> OpenArchives = new ConcurrentDictionary<string, object>();
47-
static readonly List<string> SupportedArchiveExtensions = new List<string> { ".zip", ".rar", ".7z" };
47+
static readonly List<string> SupportedArchiveExtensions = new List<string> { ".zip", ".rar" };
4848
internal static readonly ConcurrentQueue<string> InitLog = new ConcurrentQueue<string>();
4949

5050
///////////////////////////////////////////////////////////////////////////////////////
@@ -85,6 +85,7 @@ public static class Vfs
8585
/// 3 is to log all runtime file accesses as well.
8686
/// </summary>
8787
public static int LogLevel { get; set; } = 1;
88+
public static bool NoAutoMount { get; set; }
8889
public static bool IsInitialized => VfsRoot != null;
8990

9091
/// <summary>
@@ -411,7 +412,16 @@ static void MountDirectory(string directory, string mountpoint)
411412
foreach (var file in Directory.GetFiles(dirpath))
412413
{
413414
if (IsArchiveSupported(file))
414-
MountArchive(file, null, vfsNode.GetVfsPath());
415+
{
416+
if (NoAutoMount)
417+
{
418+
message = $"VFS skipped auto-mounting archive by user settings: {file}";
419+
Trace.TraceInformation(message);
420+
InitLog.Enqueue(message);
421+
}
422+
else
423+
MountArchive(file, null, vfsNode.GetVfsPath());
424+
}
415425
else
416426
vfsNode.CreateFile(NormalizeVirtualPath(Path.GetFileName(file)), file);
417427
}

Source/ORTS.Settings/UserSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ public enum DirectXFeature
311311
public bool SuppressShapeWarnings { get; set; }
312312
[Default(1)]
313313
public int VfsLogLevel { get; set; }
314+
[Default(false)]
315+
public bool VfsNoAutoMount { get; set; }
314316
[Default(60)]
315317
public int PerformanceTunerTarget { get; set; }
316318
[Default(false)]

Source/RunActivity/Viewer3D/Processes/GameStateRunActivity.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ internal override void Load()
106106
{
107107
// The virtual file system must be initialized before loading anything.
108108
Vfs.LogLevel = Game.Settings.VfsLogLevel;
109+
Vfs.NoAutoMount = Game.Settings.VfsNoAutoMount;
109110
Vfs.Initialize(Game.Settings.Menu_Selection[0], Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath));
110111

111112
// Load loading image first!

0 commit comments

Comments
 (0)