Skip to content

Commit b551ce4

Browse files
committed
Automatic merge of T1.5.1-794-g4cad06780 and 14 pull requests
- Pull request #570 at 3539862: Experimental glTF 2.0 support with PBR lighting - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder - Pull request #882 at a055bca: Blueprint/train car operations UI window - Pull request #885 at d9ce84b: feat: Add notifications to Menu - Pull request #886 at 6c0785b: Scene viewer extension to TrackViewer - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #896 at 5866028: First implementation of https://blueprints.launchpad.net/or/+spec/specific-sounds-for-ai-trains - Pull request #897 at 0a9d939: feat: Improved system information collection - Pull request #899 at 0fb4d1c: Duplex steam engines - Booster Engine addition - Pull request #903 at 7c404cd: Downloading route content (Github, zip) - Pull request #906 at 5850660: Bug fix for https://bugs.launchpad.net/or/+bug/2047299 Crash loading a 3Dcab-only loco - Pull request #907 at 9b0b04f: Bug fix for https://bugs.launchpad.net/or/+bug/2047300 Dynamic tracks disappear after long tunnel - Pull request #908 at a325039: feat: supports switching adhesion precisions
16 parents c148262 + 4cad067 + 3539862 + d00beb9 + f92de76 + a055bca + d9ce84b + 6c0785b + 1f5ba4c + 5866028 + 0a9d939 + 0fb4d1c + 7c404cd + 5850660 + 9b0b04f + a325039 commit b551ce4

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

Source/Menu/DownloadContentForm.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,25 @@ private void DownloadContentButton_Click(object sender, EventArgs e)
9090

9191
// various checks for the directory where the route is installed
9292

93+
DriveInfo dInfo = new DriveInfo(installPathRoute);
94+
95+
long size = Routes[RouteName].InstallSize + Routes[RouteName].DownloadSize;
96+
97+
if (size > (dInfo.AvailableFreeSpace * 1.1))
98+
{
99+
message = Catalog.GetStringFmt("Not enough diskspace on drive {0} ({1}), available {2} kB, needed {3} kB, still continue?",
100+
dInfo.Name,
101+
dInfo.VolumeLabel,
102+
(dInfo.AvailableFreeSpace / 1024).ToString("N0"),
103+
(size / 1024).ToString("N0"));
104+
105+
if (MessageBox.Show(message, Catalog.GetString("Attention"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
106+
{
107+
// cancelled
108+
return;
109+
}
110+
}
111+
93112
message = Catalog.GetStringFmt("Route to be installed in \"{0}\", are you sure?", installPathRoute);
94113

95114
if (MessageBox.Show(message, Catalog.GetString("Attention"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)

Source/Menu/Menu.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<HintPath>..\3rdPartyLibs\GNU.Gettext.WinForms.dll</HintPath>
3232
</Reference>
3333
<Reference Include="System.DirectoryServices" />
34+
<Reference Include="System.Net.Http" />
3435
<Reference Include="WindowsBase" />
3536
</ItemGroup>
3637
<ItemGroup>

Source/ORTS.Settings/RouteSettings.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@ public class Route
3333
public string DateInstalled { get; set; }
3434
public string Url { get; set; }
3535

36-
public Route(string dateInstalled, string url)
36+
public long DownloadSize;
37+
public long InstallSize;
38+
39+
public Route(string dateInstalled, string url, long downloadSize, long installSize)
3740
{
3841
DateInstalled = dateInstalled;
3942
Url = url;
43+
DownloadSize = downloadSize;
44+
InstallSize = installSize;
4045
}
4146
}
4247

@@ -109,12 +114,14 @@ public void LoadContentAndInstalled()
109114
{
110115
string routeName = result["name"].ToString();
111116
string url = result["url"].ToString();
117+
long downloadSize = convertResultToLong(result, "downloadSize");
118+
long installSize = convertResultToLong(result, "installSize");
112119

113120
if (url.EndsWith(".git") || url.EndsWith(".zip"))
114121
{
115122
if (!Routes.ContainsKey(routeName))
116123
{
117-
Routes.Add(routeName, new RouteSettings.Route("", url));
124+
Routes.Add(routeName, new RouteSettings.Route("", url, downloadSize, installSize));
118125
}
119126
}
120127
}
@@ -130,6 +137,18 @@ public void LoadContentAndInstalled()
130137
return;
131138
}
132139

140+
long convertResultToLong(JToken result, string fieldName)
141+
{
142+
if (result[fieldName] != null)
143+
{
144+
return (long)Convert.ToDouble(result[fieldName].ToString());
145+
}
146+
else
147+
{
148+
return 0;
149+
}
150+
}
151+
133152
private void directoryDelete(string directoryName)
134153
{
135154
if (Directory.Exists(directoryName))

0 commit comments

Comments
 (0)