Skip to content

Commit a776df5

Browse files
committed
Automatic merge of T1.5.1-776-g362e836a2 and 15 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 #893 at bf8876b: Signal errors - Pull request #894 at 5ff1e73: Correct Decrease Colour - 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 e5db0a2: Duplex steam engines - Booster Engine addition - Pull request #903 at c5f6638: first phase downloading from Github - Pull request #904 at 71beb33: fix: adds downgrade to low precision - Pull request #906 at 0e0aa8b: Bug fix for https://bugs.launchpad.net/or/+bug/2047299 Crash loading a 3Dcab-only loco
17 parents bb17bd0 + 362e836 + 3539862 + d00beb9 + f92de76 + a055bca + d9ce84b + 6c0785b + 1f5ba4c + bf8876b + 5ff1e73 + 5866028 + 0a9d939 + e5db0a2 + c5f6638 + 71beb33 + 0e0aa8b commit a776df5

File tree

3 files changed

+70
-27
lines changed

3 files changed

+70
-27
lines changed

Source/Menu/DownloadContentForm.cs

Lines changed: 70 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
using GNU.Gettext;
2424
using LibGit2Sharp;
2525
using ORTS.Settings;
26-
using Newtonsoft.Json;
2726
using System.Linq;
28-
using System.Security.Policy;
27+
using System.Diagnostics;
28+
using System.Threading;
2929

3030
namespace ORTS
3131
{
@@ -79,7 +79,7 @@ void dataGridViewDownloadContent_SelectionChanged(object sender, EventArgs e)
7979

8080
private void InstallPathButton_Click(object sender, EventArgs e)
8181
{
82-
using (var folderBrowser = new FolderBrowserDialog())
82+
using (FolderBrowserDialog folderBrowser = new FolderBrowserDialog())
8383
{
8484
folderBrowser.SelectedPath = InstallPathTextBox.Text;
8585
folderBrowser.Description = "Main Path where route is to be installed";
@@ -154,19 +154,13 @@ private void DownloadContentButton_Click(object sender, EventArgs e)
154154
Cursor.Current = Cursors.WaitCursor;
155155

156156
dataGridViewDownloadContent.CurrentRow.Cells[1].Value = Catalog.GetString("Installing...");
157-
this.Refresh();
157+
Refresh();
158158

159-
try
160-
{
161-
Repository.Clone(Routes[RouteName].Url, installPathRoute);
162-
}
163-
catch (LibGit2SharpException libGit2SharpException)
159+
// actual download
160+
161+
if (!downloadRoute(installPathRoute))
164162
{
165-
{
166-
message = Catalog.GetStringFmt("Error during download: {0}", libGit2SharpException.Message);
167-
MessageBox.Show(message, Catalog.GetString("Attention"), MessageBoxButtons.OK, MessageBoxIcon.Error);
168-
return;
169-
}
163+
return;
170164
}
171165

172166
// insert row in Options, tab Content
@@ -228,5 +222,67 @@ private void DownloadContentButton_Click(object sender, EventArgs e)
228222

229223
Close();
230224
}
225+
226+
private bool downloadRoute(string installPathRoute)
227+
{
228+
bool returnValue = false;
229+
230+
Thread cloneThread = new Thread(() =>
231+
{
232+
returnValue = doTheClone(installPathRoute);
233+
});
234+
cloneThread.Start();
235+
236+
while (cloneThread.IsAlive)
237+
{
238+
Stopwatch sw = Stopwatch.StartNew();
239+
240+
TotalBytes = 0;
241+
sumMB(installPathRoute);
242+
dataGridViewDownloadContent.CurrentRow.Cells[1].Value =
243+
string.Format("downloaded: {0} kB", Math.Round((double)(TotalBytes / 1024)));
244+
Refresh();
245+
246+
while ((cloneThread.IsAlive) && (sw.ElapsedMilliseconds <= 3000)) { }
247+
}
248+
249+
dataGridViewDownloadContent.CurrentRow.Cells[1].Value = "";
250+
251+
return returnValue;
252+
}
253+
254+
private bool doTheClone(string installPathRoute)
255+
{
256+
try
257+
{
258+
Repository.Clone(Routes[RouteName].Url, installPathRoute);
259+
}
260+
catch (LibGit2SharpException libGit2SharpException)
261+
{
262+
{
263+
string message = Catalog.GetStringFmt("Error during download: {0}", libGit2SharpException.Message);
264+
MessageBox.Show(message, Catalog.GetString("Attention"), MessageBoxButtons.OK, MessageBoxIcon.Error);
265+
return false;
266+
}
267+
}
268+
269+
return true;
270+
}
271+
272+
long TotalBytes = 0;
273+
274+
private void sumMB(string path)
275+
{
276+
foreach (string fileName in Directory.GetFiles(path))
277+
{
278+
TotalBytes += new System.IO.FileInfo(fileName).Length;
279+
}
280+
281+
foreach (string directoryName in Directory.GetDirectories(path))
282+
{
283+
sumMB(directoryName);
284+
}
285+
}
231286
}
287+
232288
}

Source/RunActivity/Viewer3D/DynamicTrack.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -710,17 +710,6 @@ public static PitchControls GetPitchControl(string sPitchControl)
710710

711711
}
712712
}
713-
714-
/// <summary>
715-
/// Marks the generic track profile, so that its textures never get deleted
716-
/// </summary>
717-
[CallOnThread("Loader")]
718-
public void Mark()
719-
{
720-
foreach (LOD lod in LODs)
721-
lod.Mark();
722-
}
723-
724713
}
725714

726715
public class LOD

Source/RunActivity/Viewer3D/World.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ public void Load()
116116
Precipitation.Mark();
117117
Terrain.Mark();
118118
Scenery.Mark();
119-
Viewer.TRP?.TrackProfile?.Mark();
120-
Viewer.TRP?.TrackProfileTun?.Mark();
121119
Trains.Mark();
122120
RoadCars.Mark();
123121
Containers.Mark();

0 commit comments

Comments
 (0)