Skip to content

Commit

Permalink
Atomic Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunaretic committed Aug 20, 2020
0 parents commit d074ba5
Show file tree
Hide file tree
Showing 5 changed files with 495 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FFXIV_TexTools*.zip
Install_TexTools.exe
FFXIV_Textools/*
20*_redist*.exe
141 changes: 141 additions & 0 deletions DotNetChecker.nsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
!macro CheckNetFramework FrameworkVersion
Var /GLOBAL dotNetUrl${FrameworkVersion}
Var /GLOBAL dotNetReadableVersion${FrameworkVersion}

!ifndef DOTNET472_URL
!define DOTNET472_URL "https://go.microsoft.com/fwlink/?LinkId=863265"
!define DOTNET471_URL "https://go.microsoft.com/fwlink/?LinkId=852104"
!define DOTNET47_URL "https://go.microsoft.com/fwlink/?LinkId=825302"
!define DOTNET462_URL "https://go.microsoft.com/fwlink/?LinkId=780600"
!define DOTNET461_URL "https://go.microsoft.com/fwlink/?LinkId=671743"
!define DOTNET46_URL "https://go.microsoft.com/fwlink/?LinkId=528232"
!define DOTNET452_URL "https://go.microsoft.com/fwlink/?LinkId=397708"
!define DOTNET451_URL "https://go.microsoft.com/fwlink/?LinkId=322116"
!define DOTNET45_URL "https://go.microsoft.com/fwlink/?LinkId=225702"
!define DOTNET40Full_URL "https://www.microsoft.com/downloads/info.aspx?na=41&srcfamilyid=0a391abd-25c1-4fc0-919f-b21f31ab88b7&srcdisplaylang=en&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f9%2f5%2fA%2f95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE%2fdotNetFx40_Full_x86_x64.exe"
!define DOTNET40Client_URL "https://www.microsoft.com/downloads/info.aspx?na=41&srcfamilyid=e5ad0459-cbcc-4b4f-97b6-fb17111cf544&srcdisplaylang=en&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f5%2f6%2f2%2f562A10F9-C9F4-4313-A044-9C94E0A8FAC8%2fdotNetFx40_Client_x86_x64.exe"
!define DOTNET35_URL "https://download.microsoft.com/download/2/0/e/20e90413-712f-438c-988e-fdaa79a8ac3d/dotnetfx35.exe"
!define DOTNET30_URL "https://download.microsoft.com/download/2/0/e/20e90413-712f-438c-988e-fdaa79a8ac3d/dotnetfx35.exe"
!define DOTNET20_URL "https://www.microsoft.com/downloads/info.aspx?na=41&srcfamilyid=0856eacb-4362-4b0d-8edd-aab15c5e04f5&srcdisplaylang=en&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f5%2f6%2f7%2f567758a3-759e-473e-bf8f-52154438565a%2fdotnetfx.exe"
!define DOTNET11_URL "https://www.microsoft.com/downloads/info.aspx?na=41&srcfamilyid=262d25e3-f589-4842-8157-034d1e7cf3a3&srcdisplaylang=en&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2fa%2fa%2fc%2faac39226-8825-44ce-90e3-bf8203e74006%2fdotnetfx.exe"
!define DOTNET10_URL "https://www.microsoft.com/downloads/info.aspx?na=41&srcfamilyid=262d25e3-f589-4842-8157-034d1e7cf3a3&srcdisplaylang=en&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2fa%2fa%2fc%2faac39226-8825-44ce-90e3-bf8203e74006%2fdotnetfx.exe"
!endif

${If} ${FrameworkVersion} == "472"
StrCpy $dotNetUrl${FrameworkVersion} ${DOTNET472_URL}
StrCpy $dotNetReadableVersion${FrameworkVersion} "4.7.2"
${ElseIf} ${FrameworkVersion} == "471"
StrCpy $dotNetUrl${FrameworkVersion} ${DOTNET471_URL}
StrCpy $dotNetReadableVersion${FrameworkVersion} "4.7.1"
${ElseIf} ${FrameworkVersion} == "47"
StrCpy $dotNetUrl${FrameworkVersion} ${DOTNET47_URL}
StrCpy $dotNetReadableVersion${FrameworkVersion} "4.7"
${ElseIf} ${FrameworkVersion} == "462"
StrCpy $dotNetUrl${FrameworkVersion} ${DOTNET462_URL}
StrCpy $dotNetReadableVersion${FrameworkVersion} "4.6.2"
${ElseIf} ${FrameworkVersion} == "461"
StrCpy $dotNetUrl${FrameworkVersion} ${DOTNET461_URL}
StrCpy $dotNetReadableVersion${FrameworkVersion} "4.6.1"
${ElseIf} ${FrameworkVersion} == "46"
StrCpy $dotNetUrl${FrameworkVersion} ${DOTNET46_URL}
StrCpy $dotNetReadableVersion${FrameworkVersion} "4.6"
${ElseIf} ${FrameworkVersion} == "452"
StrCpy $dotNetUrl${FrameworkVersion} ${DOTNET452_URL}
StrCpy $dotNetReadableVersion${FrameworkVersion} "4.52"
${ElseIf} ${FrameworkVersion} == "451"
StrCpy $dotNetUrl${FrameworkVersion} ${DOTNET451_URL}
StrCpy $dotNetReadableVersion${FrameworkVersion} "4.51"
${ElseIf} ${FrameworkVersion} == "45"
StrCpy $dotNetUrl${FrameworkVersion} ${DOTNET45_URL}
StrCpy $dotNetReadableVersion${FrameworkVersion} "4.5"
${ElseIf} ${FrameworkVersion} == "40Full"
StrCpy $dotNetUrl${FrameworkVersion} ${DOTNET40Full_URL}
StrCpy $dotNetReadableVersion${FrameworkVersion} "4.0 Full"
${ElseIf} ${FrameworkVersion} == "40Client"
StrCpy $dotNetUrl${FrameworkVersion} ${DOTNET40Client_URL}
StrCpy $dotNetReadableVersion${FrameworkVersion} "4.0 Client"
${ElseIf} ${FrameworkVersion} == "35"
StrCpy $dotNetUrl${FrameworkVersion} ${DOTNET35_URL}
StrCpy $dotNetReadableVersion${FrameworkVersion} "3.5"
${ElseIf} ${FrameworkVersion} == "30"
StrCpy $dotNetUrl${FrameworkVersion} ${DOTNET30_URL}
StrCpy $dotNetReadableVersion${FrameworkVersion} "3.0"
${ElseIf} ${FrameworkVersion} == "20"
StrCpy $dotNetUrl${FrameworkVersion} ${DOTNET20_URL}
StrCpy $dotNetReadableVersion${FrameworkVersion} "2.0"
${ElseIf} ${FrameworkVersion} == "11"
StrCpy $dotNetUrl${FrameworkVersion} ${DOTNET11_URL}
StrCpy $dotNetReadableVersion${FrameworkVersion} "1.1"
${ElseIf} ${FrameworkVersion} == "10"
StrCpy $dotNetUrl${FrameworkVersion} ${DOTNET10_URL}
StrCpy $dotNetReadableVersion${FrameworkVersion} "1.0"
${EndIf}

DetailPrint "Checking .NET Framework version..."

Push $0
Push $1
Push $2
Push $3
Push $4
Push $5
Push $6
Push $7

DotNetChecker::IsDotNet${FrameworkVersion}Installed
Pop $0

${If} $0 == "false"
${OrIf} $0 == "f" ; if script is compiled in ANSI mode then we get only an "f" https://github.com/ReVolly/NsisDotNetChecker/issues/4
DetailPrint ".NET Framework $dotNetReadableVersion${FrameworkVersion} not found, download is required for program to run."
Goto NoDotNET${FrameworkVersion}
${Else}
DetailPrint ".NET Framework $dotNetReadableVersion${FrameworkVersion} found, no need to install."
Goto NewDotNET${FrameworkVersion}
${EndIf}

NoDotNET${FrameworkVersion}:
MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
".NET Framework not installed. Required version: $dotNetReadableVersion${FrameworkVersion}.$\nDownload .NET Framework $dotNetReadableVersion${FrameworkVersion} from microsoft.com?" \
/SD IDYES IDYES DownloadDotNET${FrameworkVersion} IDNO NewDotNET${FrameworkVersion}
goto GiveUpDotNET${FrameworkVersion} ;IDCANCEL

DownloadDotNET${FrameworkVersion}:
DetailPrint "Beginning download of .NET Framework $dotNetReadableVersion${FrameworkVersion}."
NSISDL::download $dotNetUrl${FrameworkVersion} "$TEMP\dotnetfx.exe"
DetailPrint "Completed download."

Pop $0
${If} $0 == "cancel"
MessageBox MB_YESNO|MB_ICONEXCLAMATION \
"Download canceled. Continue Installation?" \
IDYES NewDotNET${FrameworkVersion} IDNO GiveUpDotNET${FrameworkVersion}
${ElseIf} $0 != "success"
MessageBox MB_YESNO|MB_ICONEXCLAMATION \
"Download failed:$\n$0$\n$\nContinue Installation?" \
IDYES NewDotNET${FrameworkVersion} IDNO GiveUpDotNET${FrameworkVersion}
${EndIf}

DetailPrint "Pausing installation while downloaded .NET Framework installer runs."
ExecWait '$TEMP\dotnetfx.exe /q /c:"install /q"'

DetailPrint "Completed .NET Framework install/update. Removing .NET Framework installer."
Delete "$TEMP\dotnetfx.exe"
DetailPrint ".NET Framework installer removed."
goto NewDotNet${FrameworkVersion}

GiveUpDotNET${FrameworkVersion}:
Abort "Installation canceled by user."

NewDotNET${FrameworkVersion}:
DetailPrint "Proceeding with remainder of installation."
Pop $7
Pop $6
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Pop $0

!macroend
190 changes: 190 additions & 0 deletions FileAssociation.nsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
/*
_____________________________________________________________________________
File Association
_____________________________________________________________________________
Based on code taken from http://nsis.sourceforge.net/File_Association
Usage in script:
1. !include "FileAssociation.nsh"
2. [Section|Function]
${FileAssociationFunction} "Param1" "Param2" "..." $var
[SectionEnd|FunctionEnd]
FileAssociationFunction=[RegisterExtension|UnRegisterExtension]
_____________________________________________________________________________
${RegisterExtension} "[executable]" "[extension]" "[description]"
"[executable]" ; executable which opens the file format
;
"[extension]" ; extension, which represents the file format to open
;
"[description]" ; description for the extension. This will be display in Windows Explorer.
;
${UnRegisterExtension} "[extension]" "[description]"
"[extension]" ; extension, which represents the file format to open
;
"[description]" ; description for the extension. This will be display in Windows Explorer.
;
_____________________________________________________________________________
Macros
_____________________________________________________________________________
Change log window verbosity (default: 3=no script)
Example:
!include "FileAssociation.nsh"
!insertmacro RegisterExtension
${FileAssociation_VERBOSE} 4 # all verbosity
!insertmacro UnRegisterExtension
${FileAssociation_VERBOSE} 3 # no script
*/


!ifndef FileAssociation_INCLUDED
!define FileAssociation_INCLUDED

!include Util.nsh

!verbose push
!verbose 3
!ifndef _FileAssociation_VERBOSE
!define _FileAssociation_VERBOSE 3
!endif
!verbose ${_FileAssociation_VERBOSE}
!define FileAssociation_VERBOSE `!insertmacro FileAssociation_VERBOSE`
!verbose pop

!macro FileAssociation_VERBOSE _VERBOSE
!verbose push
!verbose 3
!undef _FileAssociation_VERBOSE
!define _FileAssociation_VERBOSE ${_VERBOSE}
!verbose pop
!macroend



!macro RegisterExtensionCall _EXECUTABLE _EXTENSION _DESCRIPTION
!verbose push
!verbose ${_FileAssociation_VERBOSE}
Push `${_DESCRIPTION}`
Push `${_EXTENSION}`
Push `${_EXECUTABLE}`
${CallArtificialFunction} RegisterExtension_
!verbose pop
!macroend

!macro UnRegisterExtensionCall _EXTENSION _DESCRIPTION
!verbose push
!verbose ${_FileAssociation_VERBOSE}
Push `${_EXTENSION}`
Push `${_DESCRIPTION}`
${CallArtificialFunction} UnRegisterExtension_
!verbose pop
!macroend



!define RegisterExtension `!insertmacro RegisterExtensionCall`
!define un.RegisterExtension `!insertmacro RegisterExtensionCall`

!macro RegisterExtension
!macroend

!macro un.RegisterExtension
!macroend

!macro RegisterExtension_
!verbose push
!verbose ${_FileAssociation_VERBOSE}

Exch $R2 ;exe
Exch
Exch $R1 ;ext
Exch
Exch 2
Exch $R0 ;desc
Exch 2
Push $0
Push $1

ReadRegStr $1 HKCR $R1 "" ; read current file association
StrCmp "$1" "" NoBackup ; is it empty
StrCmp "$1" "$R0" NoBackup ; is it our own
WriteRegStr HKCR $R1 "backup_val" "$1" ; backup current value
NoBackup:
WriteRegStr HKCR $R1 "" "$R0" ; set our file association

ReadRegStr $0 HKCR $R0 ""
StrCmp $0 "" 0 Skip
WriteRegStr HKCR "$R0" "" "$R0"
WriteRegStr HKCR "$R0\shell" "" "open"
WriteRegStr HKCR "$R0\DefaultIcon" "" "$R2,0"
Skip:
WriteRegStr HKCR "$R0\shell\open\command" "" '"$R2" "%1"'
WriteRegStr HKCR "$R0\shell\edit" "" "Edit $R0"
WriteRegStr HKCR "$R0\shell\edit\command" "" '"$R2" "%1"'

Pop $1
Pop $0
Pop $R2
Pop $R1
Pop $R0

!verbose pop
!macroend



!define UnRegisterExtension `!insertmacro UnRegisterExtensionCall`
!define un.UnRegisterExtension `!insertmacro UnRegisterExtensionCall`

!macro UnRegisterExtension
!macroend

!macro un.UnRegisterExtension
!macroend

!macro UnRegisterExtension_
!verbose push
!verbose ${_FileAssociation_VERBOSE}

Exch $R1 ;desc
Exch
Exch $R0 ;ext
Exch
Push $0
Push $1

ReadRegStr $1 HKCR $R0 ""
StrCmp $1 $R1 0 NoOwn ; only do this if we own it
ReadRegStr $1 HKCR $R0 "backup_val"
StrCmp $1 "" 0 Restore ; if backup="" then delete the whole key
DeleteRegKey HKCR $R0
Goto NoOwn

Restore:
WriteRegStr HKCR $R0 "" $1
DeleteRegValue HKCR $R0 "backup_val"
DeleteRegKey HKCR $R1 ;Delete key with association name settings

NoOwn:

Pop $1
Pop $0
Pop $R1
Pop $R0

!verbose pop
!macroend

!endif # !FileAssociation_INCLUDED
Binary file added ffxiv2.ico
Binary file not shown.
Loading

0 comments on commit d074ba5

Please sign in to comment.