diff --git a/direct/src/directscripts/packpanda.nsi b/direct/src/directscripts/packpanda.nsi index c64d35825d..2f7c5f92a6 100755 --- a/direct/src/directscripts/packpanda.nsi +++ b/direct/src/directscripts/packpanda.nsi @@ -5,44 +5,45 @@ ; mangled by Josh Yelon ; Caller needs to define these variables: +; ; COMPRESSOR - either zlib or lzma -; FULLNAME - full name of what we're building (ie, "Panda3D" or "Airblade") -; SMDIRECTORY - where to put this in the start menu (ie, "Panda3D VERSION" or "Airblade VERSION") -; INSTALLDIR - where to install the program (ie, "C:\Program Files\Panda3D-VERSION") +; NAME - name of what we're building (ie, "Panda3D" or "Airblade") +; SMDIRECTORY - where to put this in the start menu (ie, "Panda3D 1.1.0" or "Airblade 1.1.0") +; INSTALLDIR - where to install the program (ie, "C:\Program Files\Panda3D-1.1.0") ; OUTFILE - where to put the output file (ie, "..\nsis-output.exe") +; LICENSE - location of the license file (ie, "C:\Airblade\LICENSE.TXT") +; LANGUAGE - name of the Language file to use (ie, "English" or "Panda3DEnglish") +; RUNTEXT - text for run-box at end of installation (ie, "Run the Panda Greeting Card") +; IBITMAP - name of installer bitmap (ie, "C:\Airblade\Airblade.bmp") +; UBITMAP - name of uninstaller bitmap (ie, "C:\Airblade\Airblade.bmp") ; ; PANDA - location of panda install tree. ; PSOURCE - location of the panda source-tree if available, OR location of panda install tree. ; PYEXTRAS - directory containing python extras, if any. ; -; PPGAMEID - id of prepackaged game, if any (ie, "airblade") -; PPGAMEPATH - directory containing prepagaged game, if any (ie, "C:\My Games\Airblade") -; PPGAMEPY - python program containing prepackaged game, if any (ie, "Airblade.py") +; PPGAME - directory containing prepagaged game, if any (ie, "C:\My Games\Airblade") +; PPMAIN - python program containing prepackaged game, if any (ie, "Airblade.py") -; Use the Modern UI -!include "PandaMUI.nsh" -; Windows system messaging support -!include "${NSISDIR}\Include\WinMessages.nsh" - -Name "${FULLNAME}" +!include "MUI.nsh" +!include "WinMessages.nsh" +Name "${NAME}" InstallDir "${INSTALLDIR}" OutFile "${OUTFILE}" SetCompress auto SetCompressor ${COMPRESSOR} +!define MUI_WELCOMEFINISHPAGE_BITMAP "${IBITMAP}" +!define MUI_UNWELCOMEFINISHPAGE_BITMAP "${UBITMAP}" + !define MUI_ABORTWARNING !define MUI_FINISHPAGE_NOREBOOTSUPPORT !define MUI_FINISHPAGE_RUN !define MUI_FINISHPAGE_RUN_FUNCTION runFunction -!ifdef PPGAMEID -!define MUI_FINISHPAGE_RUN_TEXT "Play ${FULLNAME}" -!else -!define MUI_FINISHPAGE_RUN_TEXT "Run the Panda Greeting Card" -!endif +!define MUI_FINISHPAGE_RUN_TEXT "${RUNTEXT}" !insertmacro MUI_PAGE_WELCOME -!insertmacro MUI_PAGE_LICENSE "${PANDA}\LICENSE" +!insertmacro MUI_PAGE_LICENSE "${LICENSE}" !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH @@ -52,11 +53,12 @@ SetCompressor ${COMPRESSOR} !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH -!insertmacro MUI_LANGUAGE "Panda3DEnglish" +!insertmacro MUI_LANGUAGE "${LANGUAGE}" ShowInstDetails nevershow ShowUninstDetails nevershow -LicenseData ${PANDA}\LICENSE + +LicenseData ${LICENSE} InstType "Typical" @@ -66,8 +68,8 @@ var READABLE var TUTNAME Function runFunction - !ifdef PPGAMEID - ExecShell "open" "$SMPROGRAMS\${SMDIRECTORY}\Play ${FULLNAME}.lnk" + !ifdef PPGAME + ExecShell "open" "$SMPROGRAMS\${SMDIRECTORY}\Play ${NAME}.lnk" !else ExecShell "open" "$SMPROGRAMS\${SMDIRECTORY}\Panda Greeting Card.lnk" !endif @@ -98,13 +100,13 @@ Section "${SMDIRECTORY}" SecCore RMDir /r "$SMPROGRAMS\${SMDIRECTORY}" CreateDirectory "$SMPROGRAMS\${SMDIRECTORY}" - !ifdef PPGAMEID + !ifdef PPGAME SetOutPath $INSTDIR\bin File /r ${PANDA}\bin\ppython.exe - SetOutpath $INSTDIR\${PPGAMEID} - File /r ${PPGAMEPATH}\* - CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Play ${FULLNAME}.lnk" "$INSTDIR\bin\ppython.exe" "${PPGAMEPY}" "$INSTDIR\bin\ppython.exe" 0 SW_SHOWMINIMIZED "" "Play ${FULLNAME}" + SetOutpath $INSTDIR\game + File /r ${PPGAME}\* + CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Play ${NAME}.lnk" "$INSTDIR\bin\ppython.exe" "${PPMAIN}" "$INSTDIR\bin\ppython.exe" 0 SW_SHOWMINIMIZED "" "Play ${NAME}" !else @@ -193,7 +195,7 @@ SectionEnd Section -post - !ifndef PPGAMEID + !ifndef PPGAME # Add the "bin" directory to the PATH. Push "$INSTDIR\bin" Call AddToPath @@ -210,13 +212,13 @@ Section -post WriteUninstaller "$INSTDIR\uninst.exe" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SMDIRECTORY}" "DisplayName" "${SMDIRECTORY}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SMDIRECTORY}" "UninstallString" '"$INSTDIR\uninst.exe"' - CreateShortcut "$SMPROGRAMS\${SMDIRECTORY}\Uninstall ${FULLNAME}.lnk" "$INSTDIR\uninst.exe" "" + CreateShortcut "$SMPROGRAMS\${SMDIRECTORY}\Uninstall ${NAME}.lnk" "$INSTDIR\uninst.exe" "" SectionEnd Section Uninstall - !ifndef PPGAMEID + !ifndef PPGAME Push "$INSTDIR\bin" Call un.RemoveFromPath !endif diff --git a/direct/src/directscripts/packpanda.py b/direct/src/directscripts/packpanda.py index 3d4b1e8038..8266ed55c8 100755 --- a/direct/src/directscripts/packpanda.py +++ b/direct/src/directscripts/packpanda.py @@ -12,14 +12,14 @@ # ############################################################################## -import sys,os,getopt,compileall +import sys,os,getopt,string,shutil,py_compile OPTIONLIST = [ ("game", 1, "Name of directory containing game"), ("version", 1, "Version number to add to game name"), ("fast", 0, "Use fast compression instead of good compression"), -("bam", 0, "Convert all EGG files to BAM"), -("pyc", 0, "Convert all PY files to PYC"), +("cplegg", 0, "Convert all EGG files to BAM"), +("cplpy", 0, "Convert all PY files to PYC"), ] def ParseFailure(): @@ -53,53 +53,6 @@ def ParseOptions(args): OPTIONS = ParseOptions(sys.argv[1:]) -############################################################################## -# -# Identify the main parts of the game: GAME, NAME, MAIN, ICON, IMAGE -# -############################################################################## - -VER=OPTIONS["version"] -GAME=OPTIONS["game"] -if (GAME==""): - print "You must specify the --game option." - ParseFailure() -GAME=os.path.abspath(GAME) -NAME=os.path.basename(GAME) -STARTMENU=os.path.basename(GAME) -if (VER!=""): STARTMENU=STARTMENU+" "+VER -MAIN=NAME+".py" -ICON=os.path.join(GAME,NAME+".ico") -IMAGE=os.path.join(GAME,NAME+".bmp") -OUTPUT=os.path.basename(GAME) -if (VER!=""): OUTPUT=OUTPUT+"-"+VER -OUTPUT=os.path.abspath(OUTPUT+".exe") -INSTALLTO='C:\\'+os.path.basename(GAME) -if (VER!=""): INSTALLTO=INSTALLTO+"-"+VER -COMPRESS="lzma" -if (OPTIONS["fast"]): COMPRESS="zlib" - -def PrintFileStatus(label, file): - if (os.path.exists(file)): - print "%-15s: %s"%(label,file) - else: - print "%-15s: %s (MISSING)"%(label,file) - -PrintFileStatus("Game",GAME) -print "%-15s: %s"%("Name",NAME) -print "%-15s: %s"%("Start Menu",STARTMENU) -PrintFileStatus("Main",os.path.join(GAME,MAIN)) -PrintFileStatus("Icon",ICON) -PrintFileStatus("Image",IMAGE) -print "%-15s: %s"%("Output",OUTPUT) -print "%-15s: %s"%("Install To",INSTALLTO) - -if (os.path.isdir(GAME)==0): - sys.exit("Difficulty reading "+GAME+". Cannot continue.") - -if (os.path.isfile(os.path.join(GAME,MAIN))==0): - sys.exit("Difficulty reading "+MAIN+". Cannot continue.") - ############################################################################## # # Locate the relevant trees. @@ -120,6 +73,113 @@ else: PSOURCE=PANDA NSIS=os.path.join(PANDA,"nsis") +############################################################################## +# +# Identify the main parts of the game: GAME, NAME, MAIN, ICON, BITMAP, etc +# +############################################################################## + +VER=OPTIONS["version"] +GAME=OPTIONS["game"] +if (GAME==""): + print "You must specify the --game option." + ParseFailure() +GAME=os.path.abspath(GAME) +NAME=os.path.basename(GAME) +SMDIRECTORY=os.path.basename(GAME) +if (VER!=""): SMDIRECTORY=SMDIRECTORY+" "+VER +if (OPTIONS["cplpy"]): MAIN=NAME+".pyc" +else: MAIN=NAME+".py" +ICON=os.path.join(GAME,NAME+".ico") +BITMAP=os.path.join(GAME,NAME+".bmp") +LICENSE=os.path.join(GAME,"LICENSE.TXT") +OUTFILE=os.path.basename(GAME) +if (VER!=""): OUTFILE=OUTFILE+"-"+VER +OUTFILE=os.path.abspath(OUTFILE+".exe") +INSTALLDIR='C:\\'+os.path.basename(GAME) +if (VER!=""): INSTALLDIR=INSTALLDIR+"-"+VER +COMPRESS="lzma" +if (OPTIONS["fast"]): COMPRESS="zlib" + +def PrintFileStatus(label, file): + if (os.path.exists(file)): + print "%-15s: %s"%(label,file) + else: + print "%-15s: %s (MISSING)"%(label,file) + +PrintFileStatus("Game",GAME) +print "%-15s: %s"%("Name",NAME) +print "%-15s: %s"%("Start Menu",SMDIRECTORY) +PrintFileStatus("Main",os.path.join(GAME,MAIN)) +PrintFileStatus("Icon",ICON) +PrintFileStatus("Bitmap",BITMAP) +PrintFileStatus("License",LICENSE) +print "%-15s: %s"%("Output",OUTFILE) +print "%-15s: %s"%("Install Dir",INSTALLDIR) + +if (os.path.isdir(GAME)==0): + sys.exit("Difficulty reading "+GAME+". Cannot continue.") + +if (os.path.isfile(os.path.join(GAME,NAME+".py"))==0): + sys.exit("Difficulty reading "+NAME+".py. Cannot continue.") + +if (os.path.isfile(LICENSE)==0): + LICENSE=os.path.join(PANDA,"LICENSE") + +if (os.path.isfile(BITMAP)==0): + BITMAP=os.path.join(NSIS,"Contrib","Modern UI","Graphics","Wizard","nsis.bmp") + +############################################################################## +# +# If necessary, make a copy of the game for compilation purposes. +# +############################################################################## + +EGG2BAM=os.path.join(PANDA,"bin","egg2bam.exe") + +def egg2bam(file): + orig = os.getcwd() + dir = os.path.dirname(file) + base = os.path.basename(file) + pre = base[:-4] + cmd = 'egg2bam -noabs "'+base+'" -o "'+pre+'.bam"' + print "Executing: "+cmd + os.chdir(dir) + res = os.spawnl(os.P_WAIT, EGG2BAM, cmd) + if (res != 0): sys.exit("Cannot convert egg to bam") + os.chdir(orig) + os.unlink(file) + +def py2pyc(file): + print "Compiling python "+file + try: py_compile.compile(file) + except: sys.exit("Cannot compile "+file) + os.unlink(file) + +def CompileFiles(file): + if (os.path.isfile(file)): + if OPTIONS["cplegg"] and (string.lower(file[-4:])==".egg"): + egg2bam(file) + elif OPTIONS["cplpy"] and (string.lower(file[-3:])==".py"): + py2pyc(file) + else: pass + elif (os.path.isdir(file)): + for x in os.listdir(file): + CompileFiles(os.path.join(file,x)) + +if (OPTIONS["cplpy"] or OPTIONS["cplegg"]): + TMPDIR=os.path.abspath("packpanda-TMP") + print "Copying the game to "+TMPDIR+"..." + if (os.path.exists(TMPDIR)): + try: shutil.rmtree(TMPDIR) + except: sys.exit("Cannot delete "+TMPDIR) + try: shutil.copytree(GAME, TMPDIR) + except: sys.exit("Cannot copy game to "+TMPDIR) + print "Searching for files to compile in "+TMPDIR+"..." + CompileFiles(TMPDIR) +else: + TMPDIR=GAME + ############################################################################## # # Run NSIS. Yay! @@ -128,18 +188,24 @@ else: CMD=NSIS+"\\makensis.exe /V2 " CMD=CMD+'/DCOMPRESSOR="'+COMPRESS+'" ' -CMD=CMD+'/DFULLNAME="'+NAME+'" ' -CMD=CMD+'/DSMDIRECTORY="'+STARTMENU+'" ' -CMD=CMD+'/DINSTALLDIR="'+INSTALLTO+'" ' +CMD=CMD+'/DNAME="'+NAME+'" ' +CMD=CMD+'/DSMDIRECTORY="'+SMDIRECTORY+'" ' +CMD=CMD+'/DINSTALLDIR="'+INSTALLDIR+'" ' +CMD=CMD+'/DOUTFILE="'+OUTFILE+'" ' +CMD=CMD+'/DLICENSE="'+LICENSE+'" ' +CMD=CMD+'/DLANGUAGE="English" ' +CMD=CMD+'/DRUNTEXT="Play '+NAME+'" ' +CMD=CMD+'/DIBITMAP="'+BITMAP+'" ' +CMD=CMD+'/DUBITMAP="'+BITMAP+'" ' CMD=CMD+'/DPANDA="'+PANDA+'" ' CMD=CMD+'/DPSOURCE="'+PSOURCE+'" ' -CMD=CMD+'/DOUTFILE="'+OUTPUT+'" ' -CMD=CMD+'/DPPGAMEID="'+NAME+'" ' -CMD=CMD+'/DPPGAMEPATH="'+GAME+'" ' -CMD=CMD+'/DPPGAMEPY="'+MAIN+'" ' +CMD=CMD+'/DPPGAME="'+TMPDIR+'" ' +CMD=CMD+'/DPPMAIN="'+MAIN+'" ' CMD=CMD+'"'+PSOURCE+'\\direct\\src\\directscripts\\packpanda.nsi"' print "" print CMD print "packing..." os.system(CMD) + + diff --git a/direct/src/directscripts/panda-install.bmp b/direct/src/directscripts/panda-install.bmp new file mode 100755 index 0000000000..416bb30311 Binary files /dev/null and b/direct/src/directscripts/panda-install.bmp differ diff --git a/direct/src/directscripts/panda-uninstall.bmp b/direct/src/directscripts/panda-uninstall.bmp new file mode 100755 index 0000000000..a63fea320f Binary files /dev/null and b/direct/src/directscripts/panda-uninstall.bmp differ