Skip to content

Commit

Permalink
Script to add includes in new overlays
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmo0 committed Mar 12, 2021
1 parent eef86e4 commit 4735cf8
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions check-includes.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# check all rom configs
gci "overlays/roms" | ? {
$_.Name.EndsWith('.cfg')
} | % {
$content = get-content $_ | Out-String

# echo $content.IndexOf('#include')
# echo $content.IndexOf('video_shader')
# echo $content.IndexOf('video_fullscreen_x')

# check if it doesn't have the include and config is not written directly
if (($content.IndexOf('#include') -lt 0)) {
# check that I have both shader and resolution
if ((($content.IndexOf('video_shader') -lt 0) -and ($content.IndexOf('video_fullscreen_x') -gt 0)) `
-or (($content.IndexOf('video_shader') -gt 0) -and ($content.IndexOf('video_fullscreen_x') -lt 0))) {

echo "$_ doesn't have the include, and is missing shader or resolution"
read-host
}
elseif (($content.IndexOf('video_shader') -lt 0) -and ($content.IndexOf('video_fullscreen_x') -lt 0)) {
echo "$_ doesn't have the include"

# get orientation
if ($content -match 'custom_viewport_width\s?=\s?\"?(\d+)\"?') {
$width = $matches[1]
}
if ($content -match 'custom_viewport_height\s?=\s?\"?(\d+)\"?') {
$height = $matches[1]
}

if ($width -gt $height) {
$orientation = "horizontal"
}
else {
$orientation = "vertical"
}

# add #include
$content = "#include `"/opt/retropie/configs/all/retroarch/overlay/arcade-realistic/common/$orientation.cfg`"`n`n$content"
$content | out-file $_
}
}
}

0 comments on commit 4735cf8

Please sign in to comment.