Skip to content

Commit

Permalink
added a script that parses out the platforms, scrapers, aliases, file…
Browse files Browse the repository at this point in the history
…masks from the cpp source to generate a platforms.json for use by people using hte JSON modifications from https://github.com/torresflo/skyscraper-enhanced.git which ill be merging into this repo shortly
  • Loading branch information
detain committed Jul 30, 2022
1 parent b669333 commit b3c3ef4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/ARTWORK.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ The type to be exported. Can be:
* cover
* wheel
* marquee
* texture

#### 'resource' attribute [from v2.7.6] (Optional)
The resource attribute can be set to one of the following:
* screenshot
* cover
* wheel
* marquee
* texture

For instance, if you wish to export a 'marquee' image but want it to make use of the 'wheel' resource instead, you can set ```<output type="marquee" resource="wheel"/>```. It will then export a 'marquee' but use the raw unmanipulated 'wheel' image when doing so. So if your frontend theme, such as some EmulationStation themes, makes use of the 'marquee' artwork, it will then be using the 'wheel' for it. If this attribute is left out, 'resource' will be set to the same as 'type'.

Expand Down
2 changes: 1 addition & 1 deletion docs/PLATFORMS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
As Skyscraper was built to be used with RetroPie, the list of supported platforms is largely dictated by their naming scheme and [list of platforms](https://retropie.org.uk/docs/Supported-Systems). Skyscraper will only rarely add platforms that aren't already on that list.

### Skyscraper currently supports the following platforms (set with '-p PLATFORM'):
* 3do
* 3DO
* Amiga (OCS, ECS, AGA, CD32, CDTV)
* Amstrad CPC
* Apple 2
Expand Down
31 changes: 31 additions & 0 deletions map_platforms_cpp_to_json.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* Parses the src/platform.cpp file building a list of platforms and the scrapers,
* file masks, and aliases for each. It then writes a platforms.json to replace the
* existing one for the JSON backed list+options instead of CPP hardcoded list+options
*/
$platforms = [];
preg_match_all('/^(QString|QStringList) Platform::get(?P<list>[^\(]*)\([^\)]*\)(?P<data>.*)^}/msuU', file_get_contents(__DIR__.'/src/platform.cpp'), $matches);
foreach ($matches['list'] as $idx => $list) {
$list = strtolower($list);
$data = $matches['data'][$idx];
// Platforms Scrapers Formats DefaultScraper Aliases
if ($list == 'Platforms') {
preg_match_all('/^.*\s?\w[^\.]+\.append\("(?P<data>[^"]*)"\);/muU', $data, $listMatches);
foreach ($listMatches['data'] as $platform)
$platforms[$platform] = ['name' => $platform];
} elseif (in_array($list, ['scrapers', 'formats', 'aliases'])) {
preg_match_all('/platform == "(?P<platform>[^"]*)"\) \{(?P<data>[^\}]*)\}/msu', $data, $listMatches);
foreach ($listMatches['platform'] as $idxPlat => $platform) {
$platforms[$platform][$list] = [];
$platData = $listMatches['data'][$idxPlat];
preg_match_all('/^.*\s?\w[^\.]+\.append\("(?P<data>[^"]*)"\);/muU', $platData, $platMatches);
foreach ($platMatches['data'] as $idxValue => $value)
$platforms[$platform][$list][] = $value;
}
} else {
// do nothing
}
}
echo json_encode($platforms, JSON_PRETTY_PRINT).PHP_EOL;
file_put_contents('platforms_new.json', json_encode($platforms, JSON_PRETTY_PRINT));

0 comments on commit b3c3ef4

Please sign in to comment.