From 3ce642043a347620b534cfd87888bda9b01620e9 Mon Sep 17 00:00:00 2001 From: Jools Wills Date: Mon, 27 Sep 2021 03:10:44 +0100 Subject: [PATCH] esthemes - added carbon-2021 pixel positioned themes and rework logic 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. --- scriptmodules/supplementary/esthemes.sh | 35 ++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/scriptmodules/supplementary/esthemes.sh b/scriptmodules/supplementary/esthemes.sh index a70fd1366c..abddce8a8c 100644 --- a/scriptmodules/supplementary/esthemes.sh +++ b/scriptmodules/supplementary/esthemes.sh @@ -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]+") @@ -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'