; Copyleft (c) n/a-n/a Azure Zanculmarktum

!define FILENAME    "Kerish_Doctor_Portable_${VER}_${APPLANG}"
!define APPNAME     "Kerish Doctor"
!define APP         "KerishDoctor"
!define APPVER      "4.60.0.0"
!define VER         "4.60"
!define APPLANG     "en-US_ru-RU"
!define FOLDER      "KerishDoctorPortable"
!define LAUNCHER    "KerishDoctorPortable"
!define APPDIR      "KerishDoctor"
!define APPINFO
	!define PUBLISHER    "Kerish Products"
	!define HOMEPAGE     "http://www.google.com/search?q=${FILENAME}.paf"
	!define CATEGORY     "Utilities"
	!define DESCRIPTION  "Prevents your computer from crashes, fixes system bugs, takes out digital trash, optimizes performance, and keeps the computer safe"
	!define LANGUAGE     "Multilingual"
!define HELP
!define SOURCE
!define INIT
!define MULTILANG

; === Best Compression ===
SetCompress Auto
SetCompressor /SOLID lzma
SetCompressorDictSize 32
SetDatablockOptimize On

; === Include ===
!include Include\Installer.nsh

Section "${APPNAME} Portable" Main
	SetDetailsPrint textonly
	DetailPrint "Extracting ${APPNAME} Portable..."
	SetDetailsPrint listonly
	SetDetailsView hide

	SectionIn RO

	!ifndef COMMONFILESPLUGIN
		SetOutPath "$INSTDIR"
			File "..\..\${LAUNCHER}.exe"
		!ifndef LANGDIR
			SetOutPath "$INSTDIR\App\${APPDIR}"
				File /r /x thumbs.db "..\..\App\${APPDIR}\*.*"
		!else
			SetOutPath "$INSTDIR\App\${APPDIR}"
				File /r /x thumbs.db /x ${LANGDIR} "..\..\App\${APPDIR}\*.*"
		!endif
		SetOutPath "$INSTDIR\App\DefaultData\${APPDIR}\Database"
			File "..\..\App\DefaultData\${APPDIR}\Database\Daily.sec"
			File "..\..\App\DefaultData\${APPDIR}\Database\Daily2.sec"
			File "..\..\App\DefaultData\${APPDIR}\Database\Daily3.sec"
			File "..\..\App\DefaultData\${APPDIR}\Database\Daily4.sec"
			File "..\..\App\DefaultData\${APPDIR}\Database\GPUTemp.dll"
			File "..\..\App\DefaultData\${APPDIR}\Database\Heuristics.dat"
			File "..\..\App\DefaultData\${APPDIR}\Database\Keys.lic"
			File "..\..\App\DefaultData\${APPDIR}\Database\Main.sec"
			File "..\..\App\DefaultData\${APPDIR}\Database\System.ilg"
			File "..\..\App\DefaultData\${APPDIR}\Database\System.prt"
		SetOutPath "$INSTDIR\App\DefaultData\${APPDIR}\Help"
			File "..\..\App\DefaultData\${APPDIR}\Help\Readme.txt"
		SetOutPath "$INSTDIR\App\DefaultData\${APPDIR}\Resources"
			File /r /x thumbs.db "..\..\App\DefaultData\${APPDIR}\Resources\*.*"
	!else
		SetOutPath "$INSTDIR\CommonFiles\${APPDIR}\files"
			File /r /x thumbs.db "..\..\files\*.*"
	!endif

	Call AppInfo

	Call Help

	Call Source
SectionEnd

!ifdef MULTILANG
	SectionGroup "Language"
		Section "English" en-US ; selected by default
			SectionIn RO        ; user cannot change
			SetOutPath "$INSTDIR\App\DefaultData\${APPDIR}\Help"
				File "..\..\App\DefaultData\${APPDIR}\Help\English.chm"
			SetOutPath "$INSTDIR\App\DefaultData\${APPDIR}\Locale"
				File "..\..\App\DefaultData\${APPDIR}\Locale\English.lng"
			SetOutPath "$INSTDIR\App\DefaultData\${APPDIR}\Resources\English"
				File /r /x thumbs.db "..\..\App\DefaultData\${APPDIR}\Resources\English\*.*"
		SectionEnd
		Section /o "Russian" ru-RU
			SetOutPath "$INSTDIR\App\DefaultData\${APPDIR}\Help"
				File "..\..\App\DefaultData\${APPDIR}\Help\Russian.chm"
			SetOutPath "$INSTDIR\App\DefaultData\${APPDIR}\Locale"
				File "..\..\App\DefaultData\${APPDIR}\Locale\Russian.lng"
			SetOutPath "$INSTDIR\App\DefaultData\${APPDIR}\Resources\Russian"
				File /r /x thumbs.db "..\..\App\DefaultData\${APPDIR}\Resources\Russian\*.*"
		SectionEnd
	SectionGroupEnd

	Function MultiLang
		; === Automatically select language with the same language of Windows language ===
		System::Call `kernel32::GetUserDefaultLangID() i .r0`
		StrCmp $0 "1033" "" "" ; English
		StrCmp $0 "1049" "" +2
			SectionSetFlags ${ru-RU} 1
	FunctionEnd
!endif

!ifdef INIT
	Function Init
		; === Destroy size lol ===
		SectionSetSize ${Main} 0
		SectionSetSize ${en-US} 0
		SectionSetSize ${ru-RU} 0
	FunctionEnd
!endif
