Replace some uses of System.IO.File with TitleContainer.OpenStream
Some checks are pending
CI / Linux (push) Waiting to run

This commit is contained in:
Ethan Lee 2024-12-12 11:39:50 -05:00
parent c3f14e756d
commit db4d7a734b
4 changed files with 9 additions and 6 deletions

View file

@ -950,7 +950,7 @@ namespace RogueCastle
{
m_maleChineseNamesLoaded = false;
using (StreamReader sr = new StreamReader(Path.Combine("Content","HeroNames.txt")))
using (StreamReader sr = new StreamReader(TitleContainer.OpenStream(Path.Combine(Content.RootDirectory, "HeroNames.txt"))))
{
// A test to make sure no special characters are used in the game.
SpriteFont junicode = Content.Load<SpriteFont>("Fonts\\Junicode");
@ -1047,7 +1047,7 @@ namespace RogueCastle
{
m_femaleChineseNamesLoaded = false;
using (StreamReader sr = new StreamReader(Path.Combine("Content", "HeroineNames.txt")))
using (StreamReader sr = new StreamReader(TitleContainer.OpenStream(Path.Combine(Content.RootDirectory, "HeroineNames.txt"))))
{
// A test to make sure no special characters are used in the game.
SpriteFont junicode = Content.Load<SpriteFont>("Fonts\\Junicode");

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using System.Globalization;
using System.Xml;
@ -27,10 +28,12 @@ namespace RogueCastle
settings.IgnoreWhitespace = true;
XmlReader reader = null;
string levelPath;
if (contentManager == null)
reader = XmlReader.Create(filePath, settings);
levelPath = filePath;
else
reader = XmlReader.Create(System.IO.Path.Combine(contentManager.RootDirectory, "Levels", filePath + ".xml"), settings);
levelPath = System.IO.Path.Combine(contentManager.RootDirectory, "Levels", filePath + ".xml");
reader = XmlReader.Create(TitleContainer.OpenStream(levelPath), settings);
// STEPS:
// 1. Finds a room object in the XML doc and creates a new RoomObj based off that data.

View file

@ -160,7 +160,7 @@ namespace RogueCastle
}
else if (!os.Equals("Windows"))
{
throw new NotSupportedException("Unhandled SDL3 platform!");
return SDL.SDL_GetPrefPath("Cellar Door Games", "Rogue Legacy");
}
else
{

View file

@ -50,7 +50,7 @@ namespace SpriteSystem
settings.IgnoreComments = true;
settings.IgnoreWhitespace = true;
Texture2D newTexture2D = content.Load<Texture2D>(spritesheetName);
XmlReader reader = XmlReader.Create(content.RootDirectory + Path.DirectorySeparatorChar + spritesheetName + ".xml", settings);
XmlReader reader = XmlReader.Create(TitleContainer.OpenStream(content.RootDirectory + Path.DirectorySeparatorChar + spritesheetName + ".xml"), settings);
return ParseData(reader, newTexture2D, returnCharDataNames, spritesheetName);
}