Skip to content

Commit

Permalink
esthemes - added carbon-2021 pixel positioned themes and rework logic
Browse files Browse the repository at this point in the history
EmulationStation 2.10+ supports pixel based positioning in themes. @tomaz82 who authored the code also
redid the base themes to utilise this and also to use other new features such as variables.

This new code will install the carbon-2021 theme by default when the version of EmulationStation is 2.10 or newer.
It will also only show the new carbon-2021 pixel positioned themes to users via the gui if the installed
EmulationStation supports it.

Users upgrading EmulationStation once the latest changes have been merged to the stable branch will get the new
theme installed, but will need to manually switch to it. However the old theme should work fine still. Some older
themes may show some minor spacing issues due to fixed calculations in the ES code for lists etc.
  • Loading branch information
joolswills committed Oct 10, 2021
1 parent 8a39a76 commit 3ce6420
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion scriptmodules/supplementary/esthemes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,37 @@ function depends_esthemes() {
fi
}

function _has_pixel_pos_esthemes() {
# get the version of emulationstation installed so we can check whether to show
# themes that use the new pixel based positioning capabilities
local supp_path="$rootdir/supplementary"
local es_path="$supp_path/emulationstation"
local esdev_path="${es_path}-dev"
# check if emulationstation-dev is installed
if [[ -d "$esdev_path" ]]; then
es_path="$esdev_path"
fi
# extract the version number from emulationstation --help
local es_ver="$("$es_path/emulationstation" --help | grep -oP "Version \K[^,]+")"
# if emulationstation is newer than 2.10 enable pixel based themes
compareVersions "$es_ver" ge "2.10" && pixel_pos=1
echo "$pixel_pos"
}

function install_theme_esthemes() {
local theme="$1"
local repo="$2"
local default_branch

local pixel_pos="$(_has_pixel_pos_esthemes)"

if [[ -z "$repo" ]]; then
repo="RetroPie"
fi
if [[ -z "$theme" ]]; then
theme="carbon"
repo="RetroPie"
[[ "$pixel_pos" -eq 1 ]] && theme+="-2021"
fi
# Get the name of the default branch, fallback to 'master' if not found
default_branch=$(runCmd git ls-remote --symref --exit-code "https://github.com/$repo/es-theme-$theme.git" HEAD | grep -oP ".*/\K[^\t]+")
Expand All @@ -47,7 +68,19 @@ function uninstall_theme_esthemes() {
}

function gui_esthemes() {
local themes=(
local themes=()

local pixel_pos="$(_has_pixel_pos_esthemes)"

if [[ "$pixel_pos" -eq 1 ]]; then
themes+=(
'RetroPie carbon-2021'
'RetroPie carbon-centered-2021'
'RetroPie carbon-nometa-2021'
)
fi

local themes+=(
'RetroPie carbon'
'RetroPie carbon-centered'
'RetroPie carbon-nometa'
Expand Down

0 comments on commit 3ce6420

Please sign in to comment.