Use File.Exits instead of relying ona try/catch and change system resource exception format a bit
This commit is contained in:
parent
df7a393584
commit
7287041050
3 changed files with 16 additions and 16 deletions
|
@ -50,19 +50,22 @@ namespace Ryujinx.HLE.Font
|
||||||
public byte[] GetData(string FontName)
|
public byte[] GetData(string FontName)
|
||||||
{
|
{
|
||||||
string FontFilePath = Path.Combine(FontsPath, $"{FontName}.ttf");
|
string FontFilePath = Path.Combine(FontsPath, $"{FontName}.ttf");
|
||||||
try
|
if (File.Exists(FontFilePath))
|
||||||
{
|
{
|
||||||
return File.ReadAllBytes(FontFilePath);
|
return File.ReadAllBytes(FontFilePath);
|
||||||
} catch (FileNotFoundException e)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
throw new SystemResourceNotFoundException($"Font \"{FontName}.ttf\" not found. Please provide it in {FontsPath}", e);
|
throw new SystemResourceNotFoundException($"Font \"{FontName}.ttf\" not found. Please provide it in \"{FontsPath}\".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MapFont(SharedFontType FontType, AMemory Memory, long Position)
|
public void MapFont(SharedFontType FontType, AMemory Memory, long Position)
|
||||||
{
|
{
|
||||||
|
uint SharedMemoryAddressOffset = GetSharedMemoryAddressOffset(FontType);
|
||||||
// TODO: find what are the 8 bytes before the font
|
// TODO: find what are the 8 bytes before the font
|
||||||
Memory.WriteBytes(Position + GetSharedMemoryAddressOffset(FontType), FontEmbeddedPaths[FontType]);
|
Memory.WriteUInt64(Position + SharedMemoryAddressOffset - 8, 0);
|
||||||
|
Memory.WriteBytes(Position + SharedMemoryAddressOffset, FontEmbeddedPaths[FontType]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PropagateNewMapFont(SharedFontType Type)
|
public void PropagateNewMapFont(SharedFontType Type)
|
||||||
|
@ -97,11 +100,11 @@ namespace Ryujinx.HLE.Font
|
||||||
|
|
||||||
(AMemory Memory, long Position, long Size) = ShMemPositions[ShMemPositions.Length - 1];
|
(AMemory Memory, long Position, long Size) = ShMemPositions[ShMemPositions.Length - 1];
|
||||||
|
|
||||||
for (SharedFontType Type = SharedFontType.JapanUsEurope; (int)Type < LoadedFonts.Length; Type++)
|
for (int Type = 0; Type < LoadedFonts.Length; Type++)
|
||||||
{
|
{
|
||||||
if (LoadedFonts[(int)Type] == 1)
|
if (LoadedFonts[(int)Type] == 1)
|
||||||
{
|
{
|
||||||
MapFont(Type, Memory, Position);
|
MapFont((SharedFontType)Type, Memory, Position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,7 +143,7 @@ namespace Ryujinx.HLE.Font
|
||||||
|
|
||||||
public uint GetFontSize(SharedFontType FontType)
|
public uint GetFontSize(SharedFontType FontType)
|
||||||
{
|
{
|
||||||
return Convert.ToUInt32(FontEmbeddedPaths[FontType].Length);
|
return (uint)FontEmbeddedPaths[FontType].Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint GetSharedMemoryAddressOffset(SharedFontType FontType)
|
public uint GetSharedMemoryAddressOffset(SharedFontType FontType)
|
||||||
|
@ -156,9 +159,6 @@ namespace Ryujinx.HLE.Font
|
||||||
return Pos;
|
return Pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Count()
|
public int Count => FontEmbeddedPaths.Count;
|
||||||
{
|
|
||||||
return FontEmbeddedPaths.Count;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,14 +102,14 @@ namespace Ryujinx.HLE.OsHle.Services.Pl
|
||||||
uint BufferPos = 0;
|
uint BufferPos = 0;
|
||||||
uint Loaded = 0;
|
uint Loaded = 0;
|
||||||
|
|
||||||
for (SharedFontType Type = SharedFontType.JapanUsEurope; (int)Type < Context.Ns.Font.Count(); Type++)
|
for (int Type = 0; Type < Context.Ns.Font.Count; Type++)
|
||||||
{
|
{
|
||||||
BufferPos = AddFontToOrderOfPriorityList(Context, Type, BufferPos, out Loaded);
|
BufferPos = AddFontToOrderOfPriorityList(Context, (SharedFontType)Type, BufferPos, out Loaded);
|
||||||
LoadedCount += Loaded;
|
LoadedCount += Loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
Context.ResponseData.Write(LoadedCount);
|
Context.ResponseData.Write(LoadedCount);
|
||||||
Context.ResponseData.Write(Context.Ns.Font.Count());
|
Context.ResponseData.Write(Context.Ns.Font.Count);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ namespace Ryujinx.HLE.Resource
|
||||||
public class SystemResourceNotFoundException: Exception
|
public class SystemResourceNotFoundException: Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
public SystemResourceNotFoundException(string message, Exception inner)
|
public SystemResourceNotFoundException(string message)
|
||||||
: base(message, inner)
|
: base(message)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue