Sfoglia il codice sorgente

Add shell scripts for audio conversion and APK/AAB building

- scripts/convert_audio.sh: Converts audio files to proper formats using ffmpeg
- scripts/build_app.sh: Builds APK and AAB files in debug/release modes
- scripts/README.md: Documentation for both scripts

Features:
- Audio conversion according to assets/audio/README.md specifications
- Comprehensive build options with command-line arguments
- Color-coded output following fSociety.hu branding
- Error handling and validation
- Cross-platform compatibility
Fszontagh 9 mesi fa
parent
commit
c94e57365a
3 ha cambiato i file con 617 aggiunte e 0 eliminazioni
  1. 166 0
      scripts/README.md
  2. 272 0
      scripts/build_app.sh
  3. 179 0
      scripts/convert_audio.sh

+ 166 - 0
scripts/README.md

@@ -0,0 +1,166 @@
+# ZenTap Build Scripts
+
+This directory contains shell scripts for automating common development tasks for the ZenTap project.
+
+## Scripts Overview
+
+### 🎵 [`convert_audio.sh`](convert_audio.sh)
+Converts audio files to the proper format and specifications for the ZenTap game.
+
+### 📱 [`build_app.sh`](build_app.sh)
+Builds APK and AAB files for Android in debug and release modes.
+
+---
+
+## Audio Conversion Script
+
+### Prerequisites
+- **ffmpeg** must be installed on your system
+  - Ubuntu/Debian: `sudo apt install ffmpeg`
+  - macOS: `brew install ffmpeg`
+  - Windows: Download from [ffmpeg.org](https://ffmpeg.org/download.html)
+
+### Usage
+```bash
+./scripts/convert_audio.sh
+```
+
+### How it works
+1. Looks for source audio files in `assets/audio/source/`
+2. Converts them according to specifications in [`assets/audio/README.md`](../assets/audio/README.md):
+   - **Sound Effects**: WAV format, 44.1 kHz, 16-bit, mono, 0.1-0.5 seconds
+   - **Background Music**: MP3 format, 44.1 kHz, 192 kbps, stereo, 2-5 minutes
+3. Outputs converted files to `assets/audio/`
+4. Validates file durations and reports status
+
+### Required Files
+- `bubble_pop.wav` - Primary bubble pop sound effect
+- `bubble_pop_alt.wav` - Alternative bubble pop sound effect
+- `ambient_background.mp3` - Main gameplay background music
+- `zen_mode_background.mp3` - Zen mode background music
+
+### Supported Source Formats
+WAV, MP3, OGG, FLAC, M4A
+
+---
+
+## Build Script
+
+### Prerequisites
+- **Flutter SDK** must be installed and configured
+- **Android SDK** and build tools must be set up
+- Run `flutter doctor` to ensure all dependencies are satisfied
+
+### Usage
+
+#### Build all variants (default)
+```bash
+./scripts/build_app.sh
+```
+
+#### Build specific variants
+```bash
+# Debug only
+./scripts/build_app.sh --debug
+
+# Release only
+./scripts/build_app.sh --release
+
+# APK files only
+./scripts/build_app.sh --apk-only
+
+# AAB files only
+./scripts/build_app.sh --aab-only
+
+# Clean build before building
+./scripts/build_app.sh --clean --all
+```
+
+#### Get help
+```bash
+./scripts/build_app.sh --help
+```
+
+### Build Variants
+
+| Variant | Description | Use Case |
+|---------|-------------|----------|
+| **Debug APK** | Development build with debugging symbols | Testing on devices, debugging |
+| **Release APK** | Optimized build for production | Side-loading, testing stores |
+| **Debug AAB** | Development Android App Bundle | Play Console internal testing |
+| **Release AAB** | Production Android App Bundle | Google Play Store release |
+
+### Output Location
+Built files are saved in `build/outputs/` with timestamps:
+- APK files: `build/outputs/apk/`
+- AAB files: `build/outputs/bundle/`
+
+### File Naming Convention
+- `ZenTap_debug_YYYYMMDD_HHMMSS.apk`
+- `ZenTap_release_YYYYMMDD_HHMMSS.aab`
+
+---
+
+## Installation Instructions
+
+### Installing APK files
+```bash
+# Install via ADB
+adb install build/outputs/apk/ZenTap_release_*.apk
+
+# Or transfer to device and install manually
+```
+
+### Uploading AAB files
+1. Upload the AAB file to [Google Play Console](https://play.google.com/console)
+2. Use for app releases on Google Play Store
+
+---
+
+## Troubleshooting
+
+### Audio Conversion Issues
+- **ffmpeg not found**: Install ffmpeg using your system's package manager
+- **Missing source files**: Place original audio files in `assets/audio/source/`
+- **Duration warnings**: Check if your audio files meet the length requirements
+
+### Build Issues
+- **Flutter not found**: Ensure Flutter is installed and added to PATH
+- **Android toolchain issues**: Run `flutter doctor` and follow the suggestions
+- **Build failures**: Run `flutter clean` and try building again
+
+### Common Commands
+```bash
+# Check Flutter installation
+flutter doctor
+
+# Clean Flutter project
+flutter clean && flutter pub get
+
+# Run app in debug mode
+flutter run
+
+# Check connected devices
+flutter devices
+```
+
+---
+
+## Color Scheme Reference
+
+Both scripts follow the fSociety.hu color scheme defined in [`../SCHEME_COLORS.md`](../SCHEME_COLORS.md):
+- **Black** (#000000) - Primary background
+- **White** (#FFFFFF) - Primary text
+- **Red** (#FF0000) - Error messages
+- **Gray** (#808080) - Secondary elements
+- **Navy Blue** (#000080) - Information messages
+
+---
+
+## Contributing
+
+When modifying these scripts:
+1. Test thoroughly on different platforms
+2. Update this README if adding new features
+3. Follow the existing code style and error handling patterns
+4. Ensure cross-platform compatibility (Linux, macOS, Windows with WSL)

+ 272 - 0
scripts/build_app.sh

@@ -0,0 +1,272 @@
+#!/bin/bash
+
+# Build Script for ZenTap
+# Builds APK and AAB files in debug and release modes
+
+set -e  # Exit on any error
+
+# Colors for output
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[1;33m'
+BLUE='\033[0;34m'
+PURPLE='\033[0;35m'
+NC='\033[0m' # No Color
+
+# Build output directory
+BUILD_DIR="build/outputs"
+
+# App information
+APP_NAME="ZenTap"
+PACKAGE_NAME="com.fsociety.zentap"
+
+echo -e "${BLUE}$APP_NAME Build Script${NC}"
+echo "======================="
+
+# Function to check if Flutter is installed
+check_flutter() {
+    if ! command -v flutter &> /dev/null; then
+        echo -e "${RED}Error: Flutter is not installed or not in PATH${NC}"
+        echo "Please install Flutter: https://flutter.dev/docs/get-started/install"
+        exit 1
+    fi
+    
+    echo -e "${GREEN}✓ Flutter found: $(flutter --version --machine | grep -o '"flutterVersion":"[^"]*' | cut -d'"' -f4)${NC}"
+}
+
+# Function to check Flutter doctor
+check_flutter_doctor() {
+    echo -e "${YELLOW}Running Flutter doctor...${NC}"
+    flutter doctor --android-licenses > /dev/null 2>&1 || true
+    
+    # Check if Android toolchain is available
+    if ! flutter doctor | grep -q "Android toolchain"; then
+        echo -e "${RED}Warning: Android toolchain not properly configured${NC}"
+        echo "Run 'flutter doctor' to see detailed issues"
+    else
+        echo -e "${GREEN}✓ Android toolchain available${NC}"
+    fi
+}
+
+# Function to clean build
+clean_build() {
+    echo -e "${YELLOW}Cleaning previous builds...${NC}"
+    flutter clean
+    flutter pub get
+    echo -e "${GREEN}✓ Build cleaned${NC}"
+}
+
+# Function to build APK
+build_apk() {
+    local mode=$1
+    echo -e "${BLUE}Building $mode APK...${NC}"
+    
+    if [ "$mode" = "debug" ]; then
+        flutter build apk --debug
+        local apk_path="build/app/outputs/flutter-apk/app-debug.apk"
+        local output_name="${APP_NAME}_debug_$(date +%Y%m%d_%H%M%S).apk"
+    else
+        flutter build apk --release
+        local apk_path="build/app/outputs/flutter-apk/app-release.apk"
+        local output_name="${APP_NAME}_release_$(date +%Y%m%d_%H%M%S).apk"
+    fi
+    
+    if [ -f "$apk_path" ]; then
+        # Create output directory if it doesn't exist
+        mkdir -p "$BUILD_DIR/apk"
+        
+        # Copy APK to output directory with timestamp
+        cp "$apk_path" "$BUILD_DIR/apk/$output_name"
+        
+        # Get file size
+        local size=$(du -h "$apk_path" | cut -f1)
+        
+        echo -e "${GREEN}✓ $mode APK built successfully${NC}"
+        echo -e "${PURPLE}  File: $BUILD_DIR/apk/$output_name${NC}"
+        echo -e "${PURPLE}  Size: $size${NC}"
+        
+        return 0
+    else
+        echo -e "${RED}✗ Failed to build $mode APK${NC}"
+        return 1
+    fi
+}
+
+# Function to build AAB (Android App Bundle)
+build_aab() {
+    local mode=$1
+    echo -e "${BLUE}Building $mode AAB...${NC}"
+    
+    if [ "$mode" = "debug" ]; then
+        flutter build appbundle --debug
+        local aab_path="build/app/outputs/bundle/debug/app-debug.aab"
+        local output_name="${APP_NAME}_debug_$(date +%Y%m%d_%H%M%S).aab"
+    else
+        flutter build appbundle --release
+        local aab_path="build/app/outputs/bundle/release/app-release.aab"
+        local output_name="${APP_NAME}_release_$(date +%Y%m%d_%H%M%S).aab"
+    fi
+    
+    if [ -f "$aab_path" ]; then
+        # Create output directory if it doesn't exist
+        mkdir -p "$BUILD_DIR/bundle"
+        
+        # Copy AAB to output directory with timestamp
+        cp "$aab_path" "$BUILD_DIR/bundle/$output_name"
+        
+        # Get file size
+        local size=$(du -h "$aab_path" | cut -f1)
+        
+        echo -e "${GREEN}✓ $mode AAB built successfully${NC}"
+        echo -e "${PURPLE}  File: $BUILD_DIR/bundle/$output_name${NC}"
+        echo -e "${PURPLE}  Size: $size${NC}"
+        
+        return 0
+    else
+        echo -e "${RED}✗ Failed to build $mode AAB${NC}"
+        return 1
+    fi
+}
+
+# Function to show usage
+show_usage() {
+    echo "Usage: $0 [OPTIONS]"
+    echo ""
+    echo "Options:"
+    echo "  -h, --help          Show this help message"
+    echo "  -c, --clean         Clean build before building"
+    echo "  -d, --debug         Build debug versions only"
+    echo "  -r, --release       Build release versions only"
+    echo "  --apk-only          Build APK files only"
+    echo "  --aab-only          Build AAB files only"
+    echo "  --all               Build all variants (default)"
+    echo ""
+    echo "Examples:"
+    echo "  $0                  # Build all variants"
+    echo "  $0 --debug          # Build debug APK and AAB"
+    echo "  $0 --release --apk-only  # Build release APK only"
+    echo "  $0 --clean --all    # Clean and build all variants"
+}
+
+# Parse command line arguments
+BUILD_DEBUG=true
+BUILD_RELEASE=true
+BUILD_APK=true
+BUILD_AAB=true
+CLEAN_BUILD=false
+
+while [[ $# -gt 0 ]]; do
+    case $1 in
+        -h|--help)
+            show_usage
+            exit 0
+            ;;
+        -c|--clean)
+            CLEAN_BUILD=true
+            shift
+            ;;
+        -d|--debug)
+            BUILD_DEBUG=true
+            BUILD_RELEASE=false
+            shift
+            ;;
+        -r|--release)
+            BUILD_DEBUG=false
+            BUILD_RELEASE=true
+            shift
+            ;;
+        --apk-only)
+            BUILD_APK=true
+            BUILD_AAB=false
+            shift
+            ;;
+        --aab-only)
+            BUILD_APK=false
+            BUILD_AAB=true
+            shift
+            ;;
+        --all)
+            BUILD_DEBUG=true
+            BUILD_RELEASE=true
+            BUILD_APK=true
+            BUILD_AAB=true
+            shift
+            ;;
+        *)
+            echo -e "${RED}Unknown option: $1${NC}"
+            show_usage
+            exit 1
+            ;;
+    esac
+done
+
+# Main execution
+echo -e "${YELLOW}Build Configuration:${NC}"
+echo "  Debug: $BUILD_DEBUG"
+echo "  Release: $BUILD_RELEASE"
+echo "  APK: $BUILD_APK"
+echo "  AAB: $BUILD_AAB"
+echo "  Clean: $CLEAN_BUILD"
+echo ""
+
+# Check prerequisites
+check_flutter
+check_flutter_doctor
+
+# Clean if requested
+if [ "$CLEAN_BUILD" = true ]; then
+    clean_build
+    echo ""
+fi
+
+# Build variants
+BUILD_SUCCESS=true
+
+if [ "$BUILD_DEBUG" = true ]; then
+    if [ "$BUILD_APK" = true ]; then
+        build_apk "debug" || BUILD_SUCCESS=false
+        echo ""
+    fi
+    
+    if [ "$BUILD_AAB" = true ]; then
+        build_aab "debug" || BUILD_SUCCESS=false
+        echo ""
+    fi
+fi
+
+if [ "$BUILD_RELEASE" = true ]; then
+    if [ "$BUILD_APK" = true ]; then
+        build_apk "release" || BUILD_SUCCESS=false
+        echo ""
+    fi
+    
+    if [ "$BUILD_AAB" = true ]; then
+        build_aab "release" || BUILD_SUCCESS=false
+        echo ""
+    fi
+fi
+
+# Summary
+echo -e "${BLUE}Build Summary${NC}"
+echo "============="
+
+if [ "$BUILD_SUCCESS" = true ]; then
+    echo -e "${GREEN}✓ All builds completed successfully!${NC}"
+    
+    echo -e "${YELLOW}Output files location:${NC}"
+    if [ -d "$BUILD_DIR" ]; then
+        find "$BUILD_DIR" -name "*.apk" -o -name "*.aab" | while read -r file; do
+            size=$(du -h "$file" | cut -f1)
+            echo -e "${PURPLE}  $file ($size)${NC}"
+        done
+    fi
+    
+    echo ""
+    echo -e "${BLUE}Installation Instructions:${NC}"
+    echo "  APK: adb install <apk_file>"
+    echo "  AAB: Upload to Google Play Console"
+    
+else
+    echo -e "${RED}✗ Some builds failed. Check the output above for details.${NC}"
+    exit 1
+fi

+ 179 - 0
scripts/convert_audio.sh

@@ -0,0 +1,179 @@
+#!/bin/bash
+
+# Audio Conversion Script for ZenTap
+# Converts audio files according to specifications in assets/audio/README.md
+
+set -e  # Exit on any error
+
+# Colors for output
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[1;33m'
+BLUE='\033[0;34m'
+NC='\033[0m' # No Color
+
+# Directories
+AUDIO_DIR="assets/audio"
+SOURCE_DIR="assets/audio/source"
+OUTPUT_DIR="assets/audio"
+
+echo -e "${BLUE}ZenTap Audio Conversion Script${NC}"
+echo "=================================="
+
+# Check if ffmpeg is installed
+if ! command -v ffmpeg &> /dev/null; then
+    echo -e "${RED}Error: ffmpeg is not installed${NC}"
+    echo "Please install ffmpeg:"
+    echo "  Ubuntu/Debian: sudo apt install ffmpeg"
+    echo "  macOS: brew install ffmpeg"
+    echo "  Windows: Download from https://ffmpeg.org/download.html"
+    exit 1
+fi
+
+# Create directories if they don't exist
+mkdir -p "$SOURCE_DIR"
+mkdir -p "$OUTPUT_DIR"
+
+echo -e "${YELLOW}Audio Conversion Specifications:${NC}"
+echo "- Sound Effects: WAV format, 44.1 kHz, 16-bit, 0.1-0.5 seconds"
+echo "- Background Music: MP3 format, 44.1 kHz, 128-320 kbps, 2-5 minutes"
+echo ""
+
+# Function to convert sound effects to WAV
+convert_sound_effect() {
+    local input_file="$1"
+    local output_file="$2"
+    
+    echo -e "${BLUE}Converting sound effect: $(basename "$input_file")${NC}"
+    
+    ffmpeg -i "$input_file" \
+        -ar 44100 \
+        -sample_fmt s16 \
+        -ac 1 \
+        -t 0.5 \
+        -y \
+        "$output_file"
+        
+    if [ $? -eq 0 ]; then
+        echo -e "${GREEN}✓ Successfully converted $(basename "$output_file")${NC}"
+    else
+        echo -e "${RED}✗ Failed to convert $(basename "$input_file")${NC}"
+    fi
+}
+
+# Function to convert background music to MP3
+convert_background_music() {
+    local input_file="$1"
+    local output_file="$2"
+    
+    echo -e "${BLUE}Converting background music: $(basename "$input_file")${NC}"
+    
+    ffmpeg -i "$input_file" \
+        -ar 44100 \
+        -b:a 192k \
+        -ac 2 \
+        -y \
+        "$output_file"
+        
+    if [ $? -eq 0 ]; then
+        echo -e "${GREEN}✓ Successfully converted $(basename "$output_file")${NC}"
+    else
+        echo -e "${RED}✗ Failed to convert $(basename "$input_file")${NC}"
+    fi
+}
+
+# Function to validate audio file duration
+validate_duration() {
+    local file="$1"
+    local expected_min="$2"
+    local expected_max="$3"
+    
+    duration=$(ffprobe -v quiet -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$file" 2>/dev/null)
+    
+    if [ $? -eq 0 ]; then
+        duration_int=$(printf "%.0f" "$duration")
+        if [ "$duration_int" -ge "$expected_min" ] && [ "$duration_int" -le "$expected_max" ]; then
+            echo -e "${GREEN}✓ Duration validation passed: ${duration}s${NC}"
+        else
+            echo -e "${YELLOW}⚠ Duration warning: ${duration}s (expected ${expected_min}-${expected_max}s)${NC}"
+        fi
+    else
+        echo -e "${YELLOW}⚠ Could not validate duration${NC}"
+    fi
+}
+
+echo -e "${YELLOW}Looking for source files in $SOURCE_DIR${NC}"
+echo ""
+
+# Convert sound effects
+for sound_effect in "bubble_pop" "bubble_pop_alt"; do
+    # Look for various input formats
+    for ext in wav mp3 ogg flac m4a; do
+        source_file="$SOURCE_DIR/${sound_effect}.$ext"
+        if [ -f "$source_file" ]; then
+            output_file="$OUTPUT_DIR/${sound_effect}.wav"
+            convert_sound_effect "$source_file" "$output_file"
+            
+            if [ -f "$output_file" ]; then
+                validate_duration "$output_file" 0 1
+            fi
+            echo ""
+            break
+        fi
+    done
+done
+
+# Convert background music
+for music_track in "ambient_background" "zen_mode_background"; do
+    # Look for various input formats
+    for ext in wav mp3 ogg flac m4a; do
+        source_file="$SOURCE_DIR/${music_track}.$ext"
+        if [ -f "$source_file" ]; then
+            output_file="$OUTPUT_DIR/${music_track}.mp3"
+            convert_background_music "$source_file" "$output_file"
+            
+            if [ -f "$output_file" ]; then
+                validate_duration "$output_file" 120 300  # 2-5 minutes
+            fi
+            echo ""
+            break
+        fi
+    done
+done
+
+# Check if we have any missing files
+echo -e "${YELLOW}Checking for required audio files:${NC}"
+
+required_files=(
+    "bubble_pop.wav"
+    "bubble_pop_alt.wav"
+    "ambient_background.mp3"
+    "zen_mode_background.mp3"
+)
+
+missing_files=()
+for file in "${required_files[@]}"; do
+    if [ -f "$OUTPUT_DIR/$file" ]; then
+        echo -e "${GREEN}✓ $file${NC}"
+    else
+        echo -e "${RED}✗ $file (missing)${NC}"
+        missing_files+=("$file")
+    fi
+done
+
+echo ""
+
+if [ ${#missing_files[@]} -eq 0 ]; then
+    echo -e "${GREEN}All required audio files are present!${NC}"
+else
+    echo -e "${YELLOW}Missing files: ${missing_files[*]}${NC}"
+    echo ""
+    echo -e "${BLUE}To add missing files:${NC}"
+    echo "1. Place source audio files in $SOURCE_DIR/"
+    echo "2. Run this script again"
+    echo ""
+    echo -e "${BLUE}Supported source formats:${NC} WAV, MP3, OGG, FLAC, M4A"
+fi
+
+echo ""
+echo -e "${BLUE}Audio conversion complete!${NC}"