name: scidcommunity
base: core24
version: git
platforms:
  amd64:
title: scidCommunity
summary: Community-enhanced chess database and analysis application
license: GPL-2.0
website: https://github.com/whelanh/scidCommunity
source-code: https://github.com/whelanh/scidCommunity
issues: https://github.com/whelanh/scidCommunity/issues
contact: brickhousedevevelopers@gmail.com
icon: data/io.github.whelanh.scidCommunity.svg
description: |
  scidCommunity is a community-driven fork of Scid (Shane's Chess Information Database),
  focused on adding enhancements while maintaining full compatibility with existing Scid databases.
  It allows you to store, organize, and search through large collections of chess games with
  support for any compatible UCI chess engine.
  
  Key enhancements in scidCommunity:
  - Improved Header Search with saveable search layouts for frequently-used parameters
  - Engine analysis controls with configurable depth and time limits
  - Integrated TWIC (The Week in Chess) game downloads
  - Direct game uploads to Lichess and Chess.com from the PGN window
  - Tablebase integration via Lichess 7-man endgames with auto-play finish game feature
  - ChessDB.cn engine tree integration for position analysis
  - Direct import of Lichess and Chess.com games by username
  - Open and auto-update live Lichess broadcast tournament games
  - Configurable variation length limits in engine annotation
  - Additional theme options (Sand and cobalt2)
  - Automatic 2-fold and 3-fold repetition detection
  - Play/Tactical Game feature now works with any configured UCI engine
  
  This fork welcomes community suggestions and aims to be responsive to user feature requests.

grade: stable
confinement: strict

layout:
  /usr/share/tcltk:
    bind: $SNAP/usr/share/tcltk
  /usr/lib/tcltk:
    bind: $SNAP/usr/lib/tcltk
  /usr/share/alsa:
    bind: $SNAP/usr/share/alsa

apps:
  scidcommunity:
    command: usr/bin/scidCommunity
    desktop: usr/share/applications/io.github.whelanh.scidCommunity.desktop
    plugs:
      - home
      - network
      - network-bind
      - desktop
      - desktop-legacy
      - x11
      - wayland
      - unity7
      - audio-playback
      - pulseaudio
      - pipewire
    environment:
      SCID_SHAREDIR: $SNAP/usr/share/scid
      TCL_LIBRARY: $SNAP/usr/share/tcltk/tcl8.6
      TK_LIBRARY: $SNAP/usr/share/tcltk/tk8.6
      TCL8_6_TM_PATH: $SNAP/usr/share/tcltk/tcl8/8.6:$SNAP/usr/share/tcltk/tcl8/8.5
      TCLLIBPATH: $SNAP/usr/share/tcltk/tcl8.6/tcl8 $SNAP/usr/share/tcltk $SNAP/usr/share/tcltk/tcl8/8.6 $SNAP/usr/share/tcltk/tcl8/8.5
      LD_LIBRARY_PATH: $SNAP/usr/lib/x86_64-linux-gnu/pulseaudio:$SNAP/usr/lib/x86_64-linux-gnu:$SNAP/usr/lib:$LD_LIBRARY_PATH

parts:
  scidcommunity:
    plugin: cmake
    source: .
    cmake-parameters:
      - -DCMAKE_INSTALL_PREFIX=/usr
      - -DCMAKE_BUILD_TYPE=Release
    build-packages:
      - make
      - tcl8.6-dev
      - tk8.6-dev
    stage-packages:
      - tk8.6
      - tcl8.6
      - libtcl8.6
      - libtk8.6
      - alsa-utils
      - alsa-base
      - pipewire-bin
      - pulseaudio-utils
      - libpulse0
      - libasound2-plugins
      - curl
      - ca-certificates
      - unzip
      - libx11-6
      - libxft2
      - libxss1
      - libfontconfig1
      - libfreetype6
      - libpng16-16t64
      - zlib1g
    override-build: |
      craftctl default
    override-prime: |
      craftctl default
      # Debug: List Tcl/Tk installation to verify paths
      echo "=== Checking Tcl/Tk files ==="
      find . -name "init.tcl" -o -name "tk.tcl" -o -name "msgcat*" | head -30 || true
      ls -la usr/share/tcltk/ || true
      ls -la usr/share/tcltk/tcl8.6/ || true
