Skip to content

Commit 3ae9a1f

Browse files
committed
refactor: Use clearer method name for internal texture loading
1 parent 41ec7a8 commit 3ae9a1f

File tree

18 files changed

+131
-131
lines changed

18 files changed

+131
-131
lines changed

Source/Contrib/TrackViewer/Drawing/BasicShapes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private static void LoadAndHighlightTexture(GraphicsDevice graphicsDevice, strin
113113
Texture2D tempTexture;
114114
try
115115
{
116-
tempTexture = SharedTextureManager.Get(graphicsDevice, fullFileName);
116+
tempTexture = SharedTextureManager.LoadInternal(graphicsDevice, fullFileName);
117117
}
118118
catch
119119
{

Source/RunActivity/Viewer3D/Lights.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ public LightGlowMaterial(Viewer viewer, string textureName)
988988
: base(viewer, textureName)
989989
{
990990
// TODO: This should happen on the loader thread.
991-
LightGlowTexture = textureName.StartsWith(Viewer.ContentPath, StringComparison.OrdinalIgnoreCase) ? SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, textureName) : Viewer.TextureManager.Get(textureName);
991+
LightGlowTexture = textureName.StartsWith(Viewer.ContentPath, StringComparison.OrdinalIgnoreCase) ? SharedTextureManager.LoadInternal(Viewer.RenderProcess.GraphicsDevice, textureName) : Viewer.TextureManager.Get(textureName);
992992
}
993993

994994
public override void SetState(GraphicsDevice graphicsDevice, Material previousMaterial)

Source/RunActivity/Viewer3D/MSTSSky.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@ public MSTSSkyMaterial(Viewer viewer)
533533
}
534534
else
535535
{
536-
MSTSSkyTexture.Add(SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "SkyDome1.png")));
537-
MSTSSkyStarTexture = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "Starmap_N.png"));
536+
MSTSSkyTexture.Add(SharedTextureManager.LoadInternal(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "SkyDome1.png")));
537+
MSTSSkyStarTexture = SharedTextureManager.LoadInternal(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "Starmap_N.png"));
538538
}
539539
if (viewer.ENVFile.SkySatellites != null)
540540
{
@@ -547,9 +547,9 @@ public MSTSSkyMaterial(Viewer viewer)
547547
MSTSSkyMoonTexture = Viewer.TextureManager.Get(mstsSkyMoonTexture);
548548
}
549549
else
550-
MSTSSkyMoonTexture = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "MoonMap.png"));
550+
MSTSSkyMoonTexture = SharedTextureManager.LoadInternal(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "MoonMap.png"));
551551

552-
MSTSSkyMoonMask = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "MoonMask.png")); //ToDo: No MSTS equivalent - will need to be fixed in MSTSSky.cs
552+
MSTSSkyMoonMask = SharedTextureManager.LoadInternal(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "MoonMask.png")); //ToDo: No MSTS equivalent - will need to be fixed in MSTSSky.cs
553553
//MSTSSkyCloudTexture[0] = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "Clouds01.png"));
554554

555555
ShaderPassesSky = MSTSSkyShader.Techniques["Sky"].Passes.GetEnumerator();

Source/RunActivity/Viewer3D/Materials.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ Texture2D invalid()
173173
}
174174
}
175175

176-
public static Texture2D Get(GraphicsDevice graphicsDevice, string path)
176+
public static Texture2D LoadInternal(GraphicsDevice graphicsDevice, string path)
177177
{
178178
if (path == null || path == "")
179179
return SharedMaterialManager.MissingTexture;
@@ -210,7 +210,7 @@ public static Texture2D Get(GraphicsDevice graphicsDevice, string path)
210210
}
211211
}
212212

213-
public static Texture2D Get(GraphicsDevice graphicsDevice, string path, Microsoft.Xna.Framework.Rectangle MapRectangle)
213+
public static Texture2D LoadInternal(GraphicsDevice graphicsDevice, string path, Microsoft.Xna.Framework.Rectangle MapRectangle)
214214
{
215215
if (path == null || path == "")
216216
return SharedMaterialManager.MissingTexture;
@@ -338,7 +338,7 @@ public SharedMaterialManager(Viewer viewer)
338338
CabShader = new CabShader(viewer.RenderProcess.GraphicsDevice, Vector4.One, Vector4.One, Vector3.One, Vector3.One);
339339

340340
// TODO: This should happen on the loader thread.
341-
MissingTexture = SharedTextureManager.Get(viewer.RenderProcess.GraphicsDevice, Path.Combine(viewer.ContentPath, "blank.bmp"));
341+
MissingTexture = SharedTextureManager.LoadInternal(viewer.RenderProcess.GraphicsDevice, Path.Combine(viewer.ContentPath, "blank.bmp"));
342342

343343
// Managing default snow textures
344344
var defaultSnowTexturePath = viewer.Simulator.RoutePath + @"\TERRTEX\SNOW\ORTSDefaultSnow.ace";

Source/RunActivity/Viewer3D/Popups/HelpWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ private void AddAggregatedTrainInfo(Train playerTrain, ControlLayout scrollbox,
12061206
int numOperativeBrakes = 0;
12071207
bool isMetric = false; bool isUK = false; // isImperial* does not seem to be used in simulation
12081208

1209-
if (TrainInfoSpriteSheet == null) { TrainInfoSpriteSheet = SharedTextureManager.Get(Owner.Viewer.RenderProcess.GraphicsDevice, Path.Combine(Owner.Viewer.ContentPath, "TrainInfoSprites.png")); }
1209+
if (TrainInfoSpriteSheet == null) { TrainInfoSpriteSheet = SharedTextureManager.LoadInternal(Owner.Viewer.RenderProcess.GraphicsDevice, Path.Combine(Owner.Viewer.ContentPath, "TrainInfoSprites.png")); }
12101210
const int spriteWidth = 6; const int spriteHeight = 26;
12111211
var carInfoList = new List<CarInfo>(playerTrain.Cars.Count);
12121212

Source/RunActivity/Viewer3D/Popups/SwitchWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected internal override void Initialize()
5252
base.Initialize();
5353
if (SwitchStates == null)
5454
// TODO: This should happen on the loader thread.
55-
SwitchStates = SharedTextureManager.Get(Owner.Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Owner.Viewer.ContentPath, "SwitchStates.png"));
55+
SwitchStates = SharedTextureManager.LoadInternal(Owner.Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Owner.Viewer.ContentPath, "SwitchStates.png"));
5656
}
5757

5858
protected override ControlLayout Layout(ControlLayout layout)

Source/RunActivity/Viewer3D/Popups/TrackMonitorWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,10 @@ public TrackMonitor(int width, int height, WindowManager owner)
309309
{
310310
if (SignalAspects == null)
311311
// TODO: This should happen on the loader thread.
312-
SignalAspects = SharedTextureManager.Get(owner.Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(owner.Viewer.ContentPath, "SignalAspects.png"));
312+
SignalAspects = SharedTextureManager.LoadInternal(owner.Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(owner.Viewer.ContentPath, "SignalAspects.png"));
313313
if (TrackMonitorImages == null)
314314
// TODO: This should happen on the loader thread.
315-
TrackMonitorImages = SharedTextureManager.Get(owner.Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(owner.Viewer.ContentPath, "TrackMonitorImages.png"));
315+
TrackMonitorImages = SharedTextureManager.LoadInternal(owner.Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(owner.Viewer.ContentPath, "TrackMonitorImages.png"));
316316

317317
Viewer = owner.Viewer;
318318
StateProperty = Viewer.Settings.GetSavingProperty<int>("TrackMonitorDisplayMode");

Source/RunActivity/Viewer3D/Popups/TrainCarOperationsViewerWindow.cs

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -253,59 +253,59 @@ protected internal override void Initialize()
253253
var TrainOperationsPath = System.IO.Path.Combine(Owner.Viewer.ContentPath, "TrainOperations\\TrainOperationsMap32.png");
254254

255255
// TODO: This should happen on the loader thread.
256-
BattAlwaysOn32 = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, BattAlwaysOnRect);
257-
BattOn32 = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, BattOnRect);
258-
BattOff32 = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, BattOffRect);
259-
260-
BleedOffValveClosed = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, BleedOffValveClosedRect);
261-
BleedOffValveOpened = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, BleedOffValveOpenedRect);
262-
BleedOffValveNotAvailable = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, BleedOffValveNotAvailableRect);
263-
264-
BrakeHoseCon = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, BrakeHoseConRect);
265-
BrakeHoseDis = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, BrakeHoseDisRect);
266-
BrakeHoseFirstDis = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, BrakeHoseFirstDisRect);
267-
BrakeHoseRearDis = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, BrakeHoseRearDisRect);
268-
BrakeHoseFirstCon = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, BrakeHoseFirstConRect);
269-
BrakeHoseRearCon = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, BrakeHoseRearConRect);
270-
271-
Coupler = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, CouplerRect);
272-
CouplerFront = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, CouplerFrontRect);
273-
CouplerRear = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, CouplerRearRect);
274-
CouplerNotAvailable = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, CouplerNotAvailableRect);
275-
276-
Empty = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, EmptyRect);
277-
278-
FrontAngleCockClosed = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, FrontAngleCockClosedRect);
279-
FrontAngleCockOpened = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, FrontAngleCockOpenedRect);
280-
FrontAngleCockPartial = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, FrontAngleCockPartialRect);
281-
FrontAngleCockNotAvailable = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, FrontAngleCockNotAvailableRect);
282-
283-
HandBrakeNotAvailable = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, HandBrakeNotAvailableRect);
284-
HandBrakeNotSet = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, HandBrakeNotSetRect);
285-
HandBrakeSet = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, HandBrakeSetRect);
286-
287-
LocoSymbol = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, LocoSymbolRect);
288-
LocoSymbolGreen = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, LocoSymbolGreenRect);
289-
LocoSymbolRed = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, LocoSymbolRedRect);
290-
291-
MUconnected = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, MUconnectedRect);
292-
MUdisconnected = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, MUdisconnectedRect);
293-
294-
ETSconnected32 = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, ETSconnected32Rect);
295-
ETSdisconnected32 = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, ETSdisconnected32Rect);
296-
297-
RearAngleCockClosed = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, RearAngleCockClosedRect);
298-
RearAngleCockOpened = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, RearAngleCockOpenedRect);
299-
RearAngleCockPartial = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, RearAngleCockPartialRect);
300-
RearAngleCockNotAvailable = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, RearAngleCockNotAvailableRect);
301-
302-
ResetBrakesOff = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, ResetBrakesOffRect);
303-
ResetBrakesOn = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, ResetBrakesOnRect);
304-
ResetBrakesWarning = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, ResetBrakesWarningRect);
305-
306-
PowerOn = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, PowerOnRect);
307-
PowerOff = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, PowerOffRect);
308-
PowerChanging = SharedTextureManager.Get(GraphicsDeviceRender, TrainOperationsPath, PowerChangingRect);
256+
BattAlwaysOn32 = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, BattAlwaysOnRect);
257+
BattOn32 = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, BattOnRect);
258+
BattOff32 = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, BattOffRect);
259+
260+
BleedOffValveClosed = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, BleedOffValveClosedRect);
261+
BleedOffValveOpened = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, BleedOffValveOpenedRect);
262+
BleedOffValveNotAvailable = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, BleedOffValveNotAvailableRect);
263+
264+
BrakeHoseCon = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, BrakeHoseConRect);
265+
BrakeHoseDis = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, BrakeHoseDisRect);
266+
BrakeHoseFirstDis = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, BrakeHoseFirstDisRect);
267+
BrakeHoseRearDis = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, BrakeHoseRearDisRect);
268+
BrakeHoseFirstCon = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, BrakeHoseFirstConRect);
269+
BrakeHoseRearCon = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, BrakeHoseRearConRect);
270+
271+
Coupler = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, CouplerRect);
272+
CouplerFront = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, CouplerFrontRect);
273+
CouplerRear = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, CouplerRearRect);
274+
CouplerNotAvailable = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, CouplerNotAvailableRect);
275+
276+
Empty = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, EmptyRect);
277+
278+
FrontAngleCockClosed = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, FrontAngleCockClosedRect);
279+
FrontAngleCockOpened = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, FrontAngleCockOpenedRect);
280+
FrontAngleCockPartial = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, FrontAngleCockPartialRect);
281+
FrontAngleCockNotAvailable = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, FrontAngleCockNotAvailableRect);
282+
283+
HandBrakeNotAvailable = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, HandBrakeNotAvailableRect);
284+
HandBrakeNotSet = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, HandBrakeNotSetRect);
285+
HandBrakeSet = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, HandBrakeSetRect);
286+
287+
LocoSymbol = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, LocoSymbolRect);
288+
LocoSymbolGreen = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, LocoSymbolGreenRect);
289+
LocoSymbolRed = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, LocoSymbolRedRect);
290+
291+
MUconnected = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, MUconnectedRect);
292+
MUdisconnected = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, MUdisconnectedRect);
293+
294+
ETSconnected32 = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, ETSconnected32Rect);
295+
ETSdisconnected32 = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, ETSdisconnected32Rect);
296+
297+
RearAngleCockClosed = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, RearAngleCockClosedRect);
298+
RearAngleCockOpened = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, RearAngleCockOpenedRect);
299+
RearAngleCockPartial = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, RearAngleCockPartialRect);
300+
RearAngleCockNotAvailable = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, RearAngleCockNotAvailableRect);
301+
302+
ResetBrakesOff = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, ResetBrakesOffRect);
303+
ResetBrakesOn = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, ResetBrakesOnRect);
304+
ResetBrakesWarning = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, ResetBrakesWarningRect);
305+
306+
PowerOn = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, PowerOnRect);
307+
PowerOff = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, PowerOffRect);
308+
PowerChanging = SharedTextureManager.LoadInternal(GraphicsDeviceRender, TrainOperationsPath, PowerChangingRect);
309309
}
310310
UpdateWindowSize();
311311
}

0 commit comments

Comments
 (0)