private static GetRailwayFolder ( string RouteFile ) : string | ||
RouteFile | string | |
return | string |
private static void routeWorkerThread_doWork(object sender, DoWorkEventArgs e) { if (string.IsNullOrEmpty(currentFile)) { return; } RouteEncoding = TextEncoding.GetSystemEncodingFromFile(currentFile); Program.CurrentHost.RegisterTexture(Path.CombineFile(Program.FileSystem.DataFolder, "Menu\\loading.png"), new TextureParameters(null, null), out routePictureBox.Texture); routeDescriptionBox.Text = Translations.GetInterfaceString("start_route_processing"); Game.Reset(false); bool loaded = false; for (int i = 0; i < Program.CurrentHost.Plugins.Length; i++) { if (Program.CurrentHost.Plugins[i].Route != null && Program.CurrentHost.Plugins[i].Route.CanLoadRoute(currentFile)) { object Route = (object)Program.CurrentRoute; //must cast to allow us to use the ref keyword. string RailwayFolder = Loading.GetRailwayFolder(currentFile); string ObjectFolder = OpenBveApi.Path.CombineDirectory(RailwayFolder, "Object"); string SoundFolder = OpenBveApi.Path.CombineDirectory(RailwayFolder, "Sound"); if (Program.CurrentHost.Plugins[i].Route.LoadRoute(currentFile, RouteEncoding, null, ObjectFolder, SoundFolder, true, ref Route)) { Program.CurrentRoute = (CurrentRoute)Route; } else { if (Program.CurrentHost.Plugins[i].Route.LastException != null) { throw Program.CurrentHost.Plugins[i].Route.LastException; //Re-throw last exception generated by the route parser plugin so that the UI thread captures it } routeDescriptionBox.Text = "An unknown error was enountered whilst attempting to parse the routefile " + currentFile; RoutefileState = RouteState.Error; } loaded = true; break; } } if (!loaded) { throw new Exception("No plugins capable of loading routefile " + currentFile + " were found."); } }