name: c-evo
title: "C-evo: New Horizons"
version: '1.3.4'
summary: A turn-based empire building game inspired by Civilization II game.
description: |
  This is a fork and Lazarus/FPC port of the original C-evo 1.2.0 game.
  Now it is finally possible to play C-evo natively on Linux.
  * Zoomable map by mouse wheel with three tile sizes
  * Support for user defined key mapping
  * Many sample maps included
  * Multiple localizations included
  * High DPI support
  * Many other small improvements
confinement: strict
base: core22
grade: stable
icon: Graphics/c-evo_64x64.png
license: NLPL

environment:
  LD_LIBRARY_PATH: $SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/usr/lib/x86_64-linux-gnu:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio
  PULSE_SERVER: unix:/run/user/1000/pulse/native

layout:
  /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/sox:
    bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/sox

parts:
  c-evo:
    plugin: nil
    source: .
    source-type: local
    after: [lazarus]
    stage-packages:
    - sox
    - libsox-fmt-mp3
    - libsox-fmt-pulse
    - libpulse0
    # Autodetected dependencies
    - libatk1.0-0
    - libcairo2
    - libdatrie1
    - libfontconfig1
    - libfreetype6
    - libgdk-pixbuf2.0-0
    - libgraphite2-3
    - libgtk2.0-0
    - libharfbuzz0b
    - libpango-1.0-0
    - libpangocairo-1.0-0
    - libpangoft2-1.0-0
    - libpixman-1-0
    - libpng16-16
    - libthai0
    - libx11-6
    - libxau6
    - libxcb-render0
    - libxcb-shm0
    - libxcb1
    - libxcomposite1
    - libxcursor1
    - libxdamage1
    - libxdmcp6
    - libxext6
    - libxfixes3
    - libxi6
    - libxinerama1
    - libxrandr2
    - libxrender1
    override-build: |
      snapcraftctl build
      (cd AI/StdAI &&lazbuild --build-mode=Release StdAI.lpi)
      mv AI/StdAI/libstdai.so AI/StdAI/libstdai-amd64.so
      lazbuild --build-mode=Release Integrated.lpi
      install -d -m 755 $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      install -s -m 755 c-evo $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      install -m 644 Language.txt $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      install -m 644 Language2.txt $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      install -m 644 Fonts.txt $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      install -d -m 755 $SNAPCRAFT_PART_INSTALL/usr/share/applications
      install -m 755 Install/deb/c-evo.desktop $SNAPCRAFT_PART_INSTALL/usr/share/applications
      install -d -m 755 $SNAPCRAFT_PART_INSTALL/usr/share/mime/packages
      install -m 644 Install/deb/c-evo.xml $SNAPCRAFT_PART_INSTALL/usr/share/mime/packages
      install -d -m 755 $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps
      install -m 644 Graphics/c-evo_64x64.png $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps/c-evo.png
      install -m 644 Graphics/c-evo_64x64.png $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps/application-cevo.png
      install -m 644 Graphics/c-evo_64x64.png $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps/application-cevomap.png
      install -d -m 755 $SNAPCRAFT_PART_INSTALL/usr/share/c-evo/AI/StdAI
      install -m 644 AI/StdAI/libstdai-amd64.so $SNAPCRAFT_PART_INSTALL/usr/share/c-evo/AI/StdAI
      install -m 644 AI/StdAI/StdAI.ai.txt $SNAPCRAFT_PART_INSTALL/usr/share/c-evo/AI/StdAI
      install -m 644 AI/StdAI/StdAI.png $SNAPCRAFT_PART_INSTALL/usr/share/c-evo/AI/StdAI
      cp -r Graphics $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      cp -r Help $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      cp -r Sounds $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      cp -r Tribes $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      cp -r Localization $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      cp -r Maps $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      cp -r Saved $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      cp -r "AI Template" $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
    stage:
      - etc
      - usr
      - usr/share/c-evo
      - usr/share/applications/c-evo.desktop
      - usr/share/mime/packages/c-evo.xml
  lazarus:
    plugin: nil
    source: .
    source-type: local
    build-packages:
    - wget
    - libgtk2.0-dev
    override-build: |
      wget -nc https://downloads.sourceforge.net/project/lazarus/Lazarus%20Linux%20amd64%20DEB/Lazarus%203.2/lazarus-project_3.2.0-0_amd64.deb
      wget -nc https://downloads.sourceforge.net/project/lazarus/Lazarus%20Linux%20amd64%20DEB/Lazarus%203.2/fpc-laz_3.2.2-210709_amd64.deb
      wget -nc https://downloads.sourceforge.net/project/lazarus/Lazarus%20Linux%20amd64%20DEB/Lazarus%203.2/fpc-src_3.2.2-210709_amd64.deb
      apt install ./lazarus-project_3.2.0-0_amd64.deb ./fpc-laz_3.2.2-210709_amd64.deb ./fpc-src_3.2.2-210709_amd64.deb
    stage: [-*]
    prime: [-*]

apps:
  c-evo:
    command: usr/share/c-evo/c-evo
    desktop: usr/share/applications/c-evo.desktop
    plugs:
      - home
      - audio-playback
      - desktop
      - x11
