Skip to content

Commit

Permalink
adding exclusions for unwanted json manifests (#6)
Browse files Browse the repository at this point in the history
fixing paths for icons and background images
  • Loading branch information
Shawson authored Dec 5, 2019
1 parent a4713af commit e10b8d2
Showing 1 changed file with 37 additions and 8 deletions.
45 changes: 37 additions & 8 deletions OculusLibrary/OculusLibraryPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ public override IEnumerable<GameInfo> GetGames()
// set a default name
var executableName = Path.GetFileNameWithoutExtension(executableFullPath);

var icon = $@"{oculusBasePath}zCoreData\Software\StoreAssets\{manifest.CanonicalName}_assets\icon_image.jpg";
var icon = $@"{oculusBasePath}\..\CoreData\Software\StoreAssets\{manifest.CanonicalName}_assets\icon_image.jpg";

if (!File.Exists(icon))
{
logger.Debug($"Oculus store icon missing from file system- reverting to executable icon");
icon = executableFullPath;
}

var backgroundImage = $@"{oculusBasePath}zCoreData\Software\StoreAssets\{manifest.CanonicalName}_assets\cover_landscape_image_large.png";
var backgroundImage = $@"{oculusBasePath}\..\CoreData\Software\StoreAssets\{manifest.CanonicalName}_assets\cover_landscape_image_large.png";

if (!File.Exists(backgroundImage))
{
Expand Down Expand Up @@ -115,7 +115,7 @@ public override IEnumerable<GameInfo> GetGames()
return gameInfos;
}

private IEnumerable<OculusManifest> GetOculusAppManifests(string oculusBasePath)
private List<OculusManifest> GetOculusAppManifests(string oculusBasePath)
{
logger.Debug($"Listing Oculus manifests");

Expand All @@ -125,16 +125,45 @@ private IEnumerable<OculusManifest> GetOculusAppManifests(string oculusBasePath)
{
logger.Info($"No Oculus game manifests found");
}


var manifests = new List<OculusManifest>();

foreach (string fileName in fileEntries.Where(x => x.EndsWith(".json")))
{
var json = File.ReadAllText(fileName);
var manifest = serialiser.Deserialize<OculusManifest>(json);
try
{
if (fileName.EndsWith("_assets.json"))
{
// not interested in the asset json files
continue;
}

var json = File.ReadAllText(fileName);

if (string.IsNullOrWhiteSpace(json))
{
logger.Error($"JSON file is empty ({fileName})");
continue;
}

manifest.LaunchFile = manifest.LaunchFile.Replace("/", @"\");
var manifest = serialiser.Deserialize<OculusManifest>(json);

yield return manifest;
if (manifest == null)
{
logger.Error($"Could not deserialise json ({fileName})");
}

manifest.LaunchFile = manifest?.LaunchFile?.Replace("/", @"\");

manifests.Add(manifest);
}
catch (Exception ex)
{
logger.Error($"Exception while processing manifest ({fileName}) : {ex}");
}
}

return manifests;
}

private List<string> GetOculusLibraryLocations(RegistryView platformView)
Expand Down

0 comments on commit e10b8d2

Please sign in to comment.