Skip to content

Commit 15a3bb8

Browse files
committed
Automatic merge of T1.6-rc7-38-ge57a7a113 and 15 pull requests
- Pull request #1086 at e10390b: Add Settings Exporter tool (copy settings to INI, etc) - Pull request #1091 at 2e06f85: Automatic speed control - Pull request #1104 at 87cdd9f: Handle simple adhesion within the axle module - Pull request #1115 at 270f22f: Do not activate ETS switch if no suitable cars are attached - Pull request #1120 at ba3c47f: Automatically Calculate Friction Values if Missing - Pull request #1121 at 91d2d26: Manually Override Articulation - Pull request #1130 at 8ae6bb7: Fix F9 points to an incorrect car ID. - Pull request #1139 at 03c6f8f: Fix for bug https://bugs.launchpad.net/or/+bug/2117357. - Pull request #1143 at 71e57d2: Status in Work Orders popup set too fast - Pull request #1151 at 5e59187: fix: Do not allow non-ACE/DDS textures in content - Pull request #1152 at 66dfd09: fix: Clean up multiple issues with data logger - Pull request #1082 at 5845a1a: Allow variable water level in glass gauge - Pull request #1081 at 689494b: Brake cuts power unification - Pull request #1124 at fab5457: Built-in PBL2 brake controller - Pull request #1128 at 278d8ff: Particle Emitter Overhaul
17 parents f2195db + e57a7a1 + e10390b + 2e06f85 + 87cdd9f + 270f22f + ba3c47f + 91d2d26 + 8ae6bb7 + 03c6f8f + 71e57d2 + 5e59187 + 66dfd09 + 5845a1a + 689494b + fab5457 + 278d8ff commit 15a3bb8

File tree

3 files changed

+20
-36
lines changed

3 files changed

+20
-36
lines changed

Source/Documentation/Manual/physics.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2639,7 +2639,8 @@ be included to further customize effect emitters:
26392639
particles from this emitter. The default texture is "smokemain.ace" for steam-type emitters and
26402640
"dieselsmoke.ace" for diesel-type emitters. If the texture cannot be found from the engine's/wagon's
26412641
folder, then the ``GLOBAL\TEXTURES`` folder is checked, and if the texture is not there the ``Content``
2642-
folder included with OR is checked. Allowed texture formats are ``.png, .jpg, .bmp, .gif, .ace, or .dds``.
2642+
folder included with OR is checked. OR will search for any ``.ace`` or ``.dds`` textures with the name
2643+
specified, though .dds is preferred over .ace.
26432644
A path to a texture can also be used, such as ``ORTSGraphic ( "..\\SmokeTextures\\steam.dds" )``, to search
26442645
for textures not in the same folder as the engine or wagon.
26452646
- ``ORTSGraphicAtlasLayout ( w h )`` -- Particle textures generally include multiple sprites in a single file

Source/RunActivity/Viewer3D/Materials.cs

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,12 @@ public Texture2D Get(string path, Texture2D defaultTexture, bool required = fals
6565
return defaultTexture;
6666

6767
path = path.ToLowerInvariant();
68-
var ext = Path.GetExtension(path);
69-
7068
if (!Textures.ContainsKey(path))
7169
{
7270
try
7371
{
7472
Texture2D texture;
75-
if (ext == ".dds")
73+
if (Path.GetExtension(path) == ".dds")
7674
{
7775
if (File.Exists(path))
7876
{
@@ -91,10 +89,10 @@ public Texture2D Get(string path, Texture2D defaultTexture, bool required = fals
9189
else return defaultTexture;
9290
}
9391
}
94-
else if (ext == ".ace")
92+
else if (Path.GetExtension(path) == ".ace")
9593
{
9694
var alternativeTexture = Path.ChangeExtension(path, ".dds");
97-
95+
9896
if (File.Exists(alternativeTexture))
9997
{
10098
DDSLib.DDSFromFile(alternativeTexture, GraphicsDevice, true, out texture);
@@ -147,30 +145,7 @@ Texture2D invalid()
147145
}
148146
}
149147
else
150-
{
151-
using (var stream = File.OpenRead(path))
152-
{
153-
if (ext == ".gif" || ext == ".jpg" || ext == ".png")
154-
texture = Texture2D.FromStream(GraphicsDevice, stream);
155-
else if (ext == ".bmp")
156-
{
157-
using (var image = System.Drawing.Image.FromStream(stream))
158-
{
159-
using (var memoryStream = new MemoryStream())
160-
{
161-
image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);
162-
memoryStream.Seek(0, SeekOrigin.Begin);
163-
texture = Texture2D.FromStream(GraphicsDevice, memoryStream);
164-
}
165-
}
166-
}
167-
else
168-
{
169-
Trace.TraceWarning("Unsupported texture format: {0}", path);
170-
return defaultTexture;
171-
}
172-
}
173-
}
148+
return defaultTexture;
174149

175150
Textures.Add(path, texture);
176151
return texture;

Source/RunActivity/Viewer3D/ParticleEmitter.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,21 @@ public void Initialize(string defaultTextureName)
8787
else
8888
TexturePath = defaultTextureName;
8989

90+
string noExtension = Path.ChangeExtension(TexturePath, null);
91+
92+
string wagPath = Path.Combine(Path.GetDirectoryName(Emitter.CarViewer.Car.WagFilePath), noExtension);
93+
string globalPath = Path.Combine(Viewer.Simulator.BasePath + @"\GLOBAL\TEXTURES\", noExtension);
94+
string contentPath = Path.Combine(Viewer.ContentPath, noExtension);
95+
9096
// Texture location preference is eng/wag folder -> MSTS GLOBAL\TEXTURES folder -> OR CONTENT folder
91-
if (File.Exists(Path.Combine(Path.GetDirectoryName(Emitter.CarViewer.Car.WagFilePath), TexturePath)))
92-
TexturePath = Path.Combine(Path.GetDirectoryName(Emitter.CarViewer.Car.WagFilePath), TexturePath);
93-
else if (File.Exists(Path.Combine(Viewer.Simulator.BasePath + @"\GLOBAL\TEXTURES\", TexturePath)))
94-
TexturePath = Path.Combine(Viewer.Simulator.BasePath + @"\GLOBAL\TEXTURES\", TexturePath);
95-
else if (customTexture && File.Exists(Path.Combine(Viewer.ContentPath, TexturePath)))
96-
TexturePath = Path.Combine(Viewer.ContentPath, TexturePath);
97+
// File type agnostic: We should detect a match if a .ace OR .dds is present, regardless of the specific file type requested
98+
// We give the material manager the path to the .dds file, but it will automatically load the .ace file if the .dds is missing
99+
if (File.Exists(wagPath + ".dds") || File.Exists(wagPath + ".ace"))
100+
TexturePath = wagPath + ".dds";
101+
else if (File.Exists(globalPath + ".dds") || File.Exists(globalPath + ".ace"))
102+
TexturePath = globalPath + ".dds";
103+
else if (File.Exists(contentPath + ".dds") || File.Exists(contentPath + ".ace"))
104+
TexturePath = contentPath + ".dds";
97105
else // Fall back to default texture in CONTENT folder
98106
{
99107
TexturePath = Path.Combine(Viewer.ContentPath, defaultTextureName);

0 commit comments

Comments
 (0)