;ZipDLL include file for NSIS
;Written by Tim Kosse (mailto:tim.kosse@gmx.de)
;Spanish translation By Dark_Boy :D
;Compatible with Modern UI 1.62

!ifndef MUI_MACROS_USED
  !error "Please include modern UI first!!"
!endif

!ifndef MUI_ZIPDLL_USED

!define MUI_ZIPDLL_USED

function ZipDLL_ExtractAllFunc

  Push $R3
  Exch
  Exch $R2
  Exch 2
  Exch $R1

  StrCpy $R3 ""

  ;The strings that will be translated are:

  ;"Extracting contents of %s to %s"
  ;"  Extracting %d files and directories"
  ;"  Extract : %s"
  ;"  Error: Could not extract %s"
  ;"Could not extract %s"
  ;"Error: Could not get file attributes."
  ;"Could not get file attributes."
  ;"  Error: %s"


  !ifdef "MUI_LANGUAGEFILE_SPANISH_USED"
    strcmp $LANGUAGE ${LANG_SPANISH} 0 ZipDLL_Spanish_Done
    StrCpy $R3 "done"
    ZipDLL::extractall "/TRANSLATE" \
                       "Extraer archivos de %s a %s" \
                       "  Extrayendo %d archivos y directorios" \
                       "  Extraer: %s" \
                       "  Error: No se pudo extraer %s" \
                       "No se pudo extraer %s" \
                       "Error al leer atributos" \
                       "No se pudieron leer los atributos del archivo" \
                       "Error: %s" \
                       "$R1" "$R2"
    goto ZipDLL_Done
   ZipDLL_Spanish_Done:
  !endif

  StrCmp $R3 "" 0 ZipDLL_Done
  ZipDLL::extractall "$R1" "$R2"

 ZipDLL_Done:
  
  Pop $R1
  Pop $R2
  Pop $R3
  Exch $R1

functionend

function ZipDLL_ExtractFileFunc

  Push $R4
  Exch
  Exch $R3
  Exch 2
  Exch $R2
  Exch 3
  Exch $R1

  StrCpy $R4 ""

  ;The strings that will be translated are:

  ;"Extracting the file %s from %s to %s"
  ;"Error: Specified file does not exist in archive."
  ;"Specified file does not exist in archive."
  ;"  Error: Could not extract %s"
  ;"Could not extract %s"
  ;"Error: Could not get file attributes."
  ;"Could not get file attributes."
  ;"  Error: %s"

  !ifdef "MUI_LANGUAGEFILE_SPANISH_USED"
    strcmp $LANGUAGE ${LANG_SPANISH} 0 ZipDLL_File_Spanish_Done
    StrCpy $R4 "done"
    ZipDLL::extractfile "/TRANSLATE" \
                       "Extrayendo el archivo %s de %s a %s" \
                       "Error: El archivo especificado no existe en el ZIP" \
                       "Archivo especificado no existe en el ZIP" \
                       "  Error no se pudo extraer %s" \
                       "No se pudo extraer %s" \
                       "Error: No se obtuvieron atributos del archivo" \
                       "No se obtuvieron atributos del archivo" \
                       "  Error: %s" \
                       "$R1" "$R2" "$R3"
    goto ZipDLL_File_Done
   ZipDLL_File_Spanish_Done:
  !endif

  StrCmp $R4 "" 0 ZipDLL_File_Done
  ZipDLL::extractfile "$R1" "$R2" "$3"

 ZipDLL_File_Done:
  
  Pop $R2
  Pop $R1
  Pop $R4
  Pop $R3
  Exch $R2

functionend

!macro MUI_ZIPDLL_EXTRACTFILE SOURCE DESTINATION FILE

  Push "${SOURCE}"
  Push "${DESTINATION}"
  Push "${FILE}"
  call ZipDLL_ExtractFileFunc

!macroend

!macro MUI_ZIPDLL_EXTRACTALL SOURCE DESTINATION

  Push "${SOURCE}"
  Push "${DESTINATION}"
  call ZipDLL_ExtractAllFunc

!macroend

!endif