Skip to content

Commit

Permalink
Replace some uses of System.IO.File with TitleContainer.OpenStream
Browse files Browse the repository at this point in the history
  • Loading branch information
flibitijibibo committed Dec 12, 2024
1 parent c3f14e7 commit db4d7a7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions RogueCastle/src/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ public void InitializeMaleNameArray(bool forceCreate)
{
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");
Expand Down Expand Up @@ -1047,7 +1047,7 @@ public void InitializeFemaleNameArray(bool forceCreate)
{
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");
Expand Down
7 changes: 5 additions & 2 deletions RogueCastle/src/LevelParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,10 +28,12 @@ public static void ParseRooms(string filePath, ContentManager contentManager = n
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.
Expand Down
2 changes: 1 addition & 1 deletion RogueCastle/src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private static string GetOSDir()
}
else if (!os.Equals("Windows"))
{
throw new NotSupportedException("Unhandled SDL3 platform!");
return SDL.SDL_GetPrefPath("Cellar Door Games", "Rogue Legacy");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion SpriteSystem/SpriteLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static List<string> LoadSpritesheet(ContentManager content, string sprite
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);
}

Expand Down

0 comments on commit db4d7a7

Please sign in to comment.