Skip to content
Snippets Groups Projects
Select Git revision
  • 87aa081434f00216fa2964abf9fee84d58f4534f
  • master default protected
  • 63-upgrade-framework-and-dependencies
  • 45-improve-app-metadata
  • Release_0.9.0_57 protected
  • Release_0.8.2_56 protected
  • Release_0.8.1_55 protected
  • Release_0.8.0_54 protected
  • Release_0.7.0_53 protected
  • Release_0.6.0_52 protected
  • Release_0.5.0_51 protected
  • Release_0.4.2_50 protected
  • Release_0.4.1_49 protected
  • Release_0.4.0_48 protected
  • Release_0.3.1_47 protected
  • Release_0.3.0_46 protected
  • Release_0.2.2_45 protected
  • Release_0.2.1_44 protected
  • Release_0.2.0_43 protected
  • Release_0.1.2_42 protected
  • Release_0.1.1_41 protected
  • Release_0.1.0_40 protected
  • Release_0.0.39_39 protected
  • Release_0.0.38_38 protected
24 results

.gitignore

Blame
  • build_game_icons.sh 2.14 KiB
    #! /bin/bash
    
    # Check dependencies
    command -v inkscape >/dev/null 2>&1 || { echo >&2 "I require inkscape but it's not installed. Aborting."; exit 1; }
    command -v scour >/dev/null 2>&1 || { echo >&2 "I require scour but it's not installed. Aborting."; exit 1; }
    command -v optipng >/dev/null 2>&1 || { echo >&2 "I require optipng but it's not installed. Aborting."; exit 1; }
    
    CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
    BASE_DIR="$(dirname "${CURRENT_DIR}")"
    
    OPTIPNG_OPTIONS="-preserve -quiet -o7"
    
    # optimize svg
    function optimize_svg() {
      SOURCE="$1"
    
      cp ${SOURCE} ${SOURCE}.tmp
      scour \
          --remove-descriptive-elements \
          --enable-id-stripping \
          --enable-viewboxing \
          --enable-comment-stripping \
          --nindent=4 \
          -i ${SOURCE}.tmp \
          -o ${SOURCE}
      rm ${SOURCE}.tmp
    }
    
    # build icons
    function build_icon() {
      ICON_SIZE=192
      SOURCE="$1"
      TARGET="$2"
    
      optimize_svg "${SOURCE}"
    
      inkscape \
          --export-width=${ICON_SIZE} \
          --export-height=${ICON_SIZE} \
          --export-filename=${TARGET} \
          ${SOURCE}
    
      optipng ${OPTIPNG_OPTIONS} ${TARGET}
    }
    
    function build_icon_for_skin() {
      SKIN_CODE="$1"
    
      build_icon ${CURRENT_DIR}/skin_${SKIN_CODE}.svg             ${BASE_DIR}/assets/icons/skin_${SKIN_CODE}.png
    
      build_icon ${CURRENT_DIR}/skins/${SKIN_CODE}/empty.svg      ${BASE_DIR}/assets/skins/${SKIN_CODE}_empty.png
      build_icon ${CURRENT_DIR}/skins/${SKIN_CODE}/good.svg       ${BASE_DIR}/assets/skins/${SKIN_CODE}_good.png
      build_icon ${CURRENT_DIR}/skins/${SKIN_CODE}/misplaced.svg  ${BASE_DIR}/assets/skins/${SKIN_CODE}_misplaced.png
    }
    
    # Game icons
    build_icon ${CURRENT_DIR}/button_back.svg   ${BASE_DIR}/assets/icons/button_back.png
    build_icon ${CURRENT_DIR}/button_help.svg   ${BASE_DIR}/assets/icons/button_help.png
    build_icon ${CURRENT_DIR}/button_start.svg  ${BASE_DIR}/assets/icons/button_start.png
    build_icon ${CURRENT_DIR}/game_win.svg      ${BASE_DIR}/assets/icons/game_win.png
    
    build_icon ${CURRENT_DIR}/lang_fr.svg       ${BASE_DIR}/assets/icons/lang_fr.png
    build_icon ${CURRENT_DIR}/length_5.svg      ${BASE_DIR}/assets/icons/length_5.png
    
    # Skins
    build_icon_for_skin "default"