Improve windows installer: .prc file assoc, use DOS newlines for prc, error if installing 64-bit version on 32-bit Windows

This commit is contained in:
rdb 2016-11-29 21:53:37 +01:00
parent 7db45cb647
commit 1e2961f7ef
3 changed files with 42 additions and 8 deletions

View File

@ -31,6 +31,7 @@ SetCompressor ${COMPRESSOR}
!include "Sections.nsh" !include "Sections.nsh"
!include "WinMessages.nsh" !include "WinMessages.nsh"
!include "WordFunc.nsh" !include "WordFunc.nsh"
!include "x64.nsh"
!define MUI_WELCOMEFINISHPAGE_BITMAP "panda-install.bmp" !define MUI_WELCOMEFINISHPAGE_BITMAP "panda-install.bmp"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "panda-install.bmp" !define MUI_UNWELCOMEFINISHPAGE_BITMAP "panda-install.bmp"
@ -120,6 +121,14 @@ Function runFunction
ExecShell "open" "$SMPROGRAMS\${TITLE}\Panda3D Manual.lnk" ExecShell "open" "$SMPROGRAMS\${TITLE}\Panda3D Manual.lnk"
FunctionEnd FunctionEnd
Function .onInit
${If} ${REGVIEW} = 64
${AndIfNot} ${RunningX64}
MessageBox MB_OK|MB_ICONEXCLAMATION "You are attempting to install the 64-bit version of Panda3D on a 32-bit version of Windows. Please download and install the 32-bit version of Panda3D instead."
Abort
${EndIf}
FunctionEnd
SectionGroup "Panda3D Libraries" SectionGroup "Panda3D Libraries"
Section "Core Libraries" SecCore Section "Core Libraries" SecCore
SectionIn 1 2 RO SectionIn 1 2 RO
@ -634,6 +643,9 @@ Section -post
WriteRegStr HKCU "Software\Classes\.pz" "PerceivedType" "compressed" WriteRegStr HKCU "Software\Classes\.pz" "PerceivedType" "compressed"
WriteRegStr HKCU "Software\Classes\.mf" "" "Panda3D.Multifile" WriteRegStr HKCU "Software\Classes\.mf" "" "Panda3D.Multifile"
WriteRegStr HKCU "Software\Classes\.mf" "PerceivedType" "compressed" WriteRegStr HKCU "Software\Classes\.mf" "PerceivedType" "compressed"
WriteRegStr HKCU "Software\Classes\.prc" "" "inifile"
WriteRegStr HKCU "Software\Classes\.prc" "Content Type" "text/plain"
WriteRegStr HKCU "Software\Classes\.prc" "PerceivedType" "text"
; For convenience, if nobody registered .pyd, we will. ; For convenience, if nobody registered .pyd, we will.
ReadRegStr $0 HKCR "Software\Classes\.pyd" "" ReadRegStr $0 HKCR "Software\Classes\.pyd" ""

View File

@ -2781,8 +2781,13 @@ if (GetTarget() == 'darwin'):
# OpenAL is not yet working well on OSX for us, so let's do this for now. # OpenAL is not yet working well on OSX for us, so let's do this for now.
configprc = configprc.replace("p3openal_audio", "p3fmod_audio") configprc = configprc.replace("p3openal_audio", "p3fmod_audio")
ConditionalWriteFile(GetOutputDir()+"/etc/Config.prc", configprc) if GetTarget() == 'windows':
ConditionalWriteFile(GetOutputDir()+"/etc/Confauto.prc", confautoprc) # Convert to Windows newlines.
ConditionalWriteFile(GetOutputDir()+"/etc/Config.prc", configprc, newline='\r\n')
ConditionalWriteFile(GetOutputDir()+"/etc/Confauto.prc", confautoprc, newline='\r\n')
else:
ConditionalWriteFile(GetOutputDir()+"/etc/Config.prc", configprc)
ConditionalWriteFile(GetOutputDir()+"/etc/Confauto.prc", confautoprc)
########################################################################################## ##########################################################################################
# #
@ -2902,8 +2907,14 @@ if tp_dir is not None:
## ##
######################################################################## ########################################################################
CopyFile(GetOutputDir()+"/", "doc/LICENSE") if GetTarget() == 'windows':
CopyFile(GetOutputDir()+"/", "doc/ReleaseNotes") # Convert to Windows newlines so they can be opened by notepad.
WriteFile(GetOutputDir() + "/LICENSE", ReadFile("doc/LICENSE"), newline='\r\n')
WriteFile(GetOutputDir() + "/ReleaseNotes", ReadFile("doc/ReleaseNotes"), newline='\r\n')
else:
CopyFile(GetOutputDir()+"/", "doc/LICENSE")
CopyFile(GetOutputDir()+"/", "doc/ReleaseNotes")
if (PkgSkip("PANDATOOL")==0): if (PkgSkip("PANDATOOL")==0):
CopyAllFiles(GetOutputDir()+"/plugins/", "pandatool/src/scripts/", ".mel") CopyAllFiles(GetOutputDir()+"/plugins/", "pandatool/src/scripts/", ".mel")
CopyAllFiles(GetOutputDir()+"/plugins/", "pandatool/src/scripts/", ".ms") CopyAllFiles(GetOutputDir()+"/plugins/", "pandatool/src/scripts/", ".ms")

View File

@ -966,7 +966,12 @@ def ReadBinaryFile(wfile):
ex = sys.exc_info()[1] ex = sys.exc_info()[1]
exit("Cannot read %s: %s" % (wfile, ex)) exit("Cannot read %s: %s" % (wfile, ex))
def WriteFile(wfile, data): def WriteFile(wfile, data, newline=None):
if newline is not None:
data = data.replace('\r\n', '\n')
data = data.replace('\r', '\n')
data = data.replace('\n', newline)
try: try:
dsthandle = open(wfile, "w") dsthandle = open(wfile, "w")
dsthandle.write(data) dsthandle.write(data)
@ -984,18 +989,24 @@ def WriteBinaryFile(wfile, data):
ex = sys.exc_info()[1] ex = sys.exc_info()[1]
exit("Cannot write to %s: %s" % (wfile, ex)) exit("Cannot write to %s: %s" % (wfile, ex))
def ConditionalWriteFile(dest, desiredcontents): def ConditionalWriteFile(dest, data, newline=None):
if newline is not None:
data = data.replace('\r\n', '\n')
data = data.replace('\r', '\n')
data = data.replace('\n', newline)
try: try:
rfile = open(dest, 'r') rfile = open(dest, 'r')
contents = rfile.read(-1) contents = rfile.read(-1)
rfile.close() rfile.close()
except: except:
contents = 0 contents = 0
if contents != desiredcontents:
if contents != data:
if VERBOSE: if VERBOSE:
print("Writing %s" % (dest)) print("Writing %s" % (dest))
sys.stdout.flush() sys.stdout.flush()
WriteFile(dest, desiredcontents) WriteFile(dest, data)
def DeleteVCS(dir): def DeleteVCS(dir):
if dir == "": dir = "." if dir == "": dir = "."