From 78a819cd6990d28a5edcf0aa6e7ce9053fe89110 Mon Sep 17 00:00:00 2001 From: Josh Yelon Date: Wed, 20 Jun 2007 22:55:14 +0000 Subject: [PATCH] Added support for altering Config.prc in packpanda --- direct/src/directscripts/packpanda.nsi | 3 +- direct/src/directscripts/packpanda.py | 47 ++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/direct/src/directscripts/packpanda.nsi b/direct/src/directscripts/packpanda.nsi index f5b7ee36e2..3b26305bd8 100755 --- a/direct/src/directscripts/packpanda.nsi +++ b/direct/src/directscripts/packpanda.nsi @@ -18,6 +18,7 @@ ; UBITMAP - name of uninstaller bitmap (ie, "C:\Airblade\Airblade.bmp") ; ; PANDA - location of panda install tree. +; PANDACONF - name of panda config directory - usually $PANDA\etc ; PSOURCE - location of the panda source-tree if available, OR location of panda install tree. ; PYEXTRAS - directory containing python extras, if any. ; @@ -90,7 +91,7 @@ Section "${SMDIRECTORY}" SecCore File /r "${PANDA}\bin\*.dll" File /r "${PANDA}\bin\Microsoft.VC80.CRT.manifest" SetOutPath $INSTDIR\etc - File /r "${PANDA}\etc\*" + File /r "${PANDACONF}\*" SetOutPath $INSTDIR\direct\src\directscripts File /r /x CVS /x Opt?-Win32 "${PSOURCE}\direct\src\directscripts\*" SetOutPath $INSTDIR\direct diff --git a/direct/src/directscripts/packpanda.py b/direct/src/directscripts/packpanda.py index 68e4e1f8a0..c616dc65f7 100755 --- a/direct/src/directscripts/packpanda.py +++ b/direct/src/directscripts/packpanda.py @@ -1,4 +1,4 @@ -############################################################################## +############################################################################# # # packpanda - this is a tool that packages up a panda game into a # convenient, easily-downloaded windows executable. Packpanda relies on @@ -21,7 +21,7 @@ OPTIONLIST = [ ("rmdir", 2, "Delete all directories with given name"), ("rmext", 2, "Delete all files with given extension"), ("fast", 0, "Use fast compression instead of good compression"), -("bam", 0, "Generate BAM files"), +("bam", 0, "Generate BAM files, change default-model-extension to BAM"), ("pyc", 0, "Generate PYC files"), ] @@ -164,20 +164,52 @@ def limitedCopyTree(src, dst, rmdir): TMPDIR=os.path.abspath("packpanda-TMP") +TMPGAME=os.path.join(TMPDIR,"game") +TMPETC=os.path.join(TMPDIR,"etc") print "" print "Copying the game to "+TMPDIR+"..." if (os.path.exists(TMPDIR)): try: shutil.rmtree(TMPDIR) except: sys.exit("Cannot delete "+TMPDIR) try: + os.mkdir(TMPDIR) rmdir = {} for x in OPTIONS["rmdir"]: rmdir[x] = 1 - limitedCopyTree(DIR, TMPDIR, rmdir) - if not os.path.isdir( TMPDIR ): - os.mkdir(TMPDIR) + limitedCopyTree(DIR, TMPGAME, rmdir) + if not os.path.isdir( TMPGAME ): + os.mkdir(TMPGAME) + limitedCopyTree(os.path.join(PANDA, "etc"), TMPETC, {}) + if not os.path.isdir( TMPETC ): + os.mkdir(TMPETC) except: sys.exit("Cannot copy game to "+TMPDIR) +############################################################################## +# +# If --bam requested, change default-model-extension .egg to bam. +# +############################################################################## + +def ReadFile(wfile): + try: + srchandle = open(wfile, "rb") + data = srchandle.read() + srchandle.close() + return data + except: exit("Cannot read "+wfile) + +def WriteFile(wfile,data): + try: + dsthandle = open(wfile, "wb") + dsthandle.write(data) + dsthandle.close() + except: exit("Cannot write "+wfile) + +if OPTIONS["bam"]: + CONF=ReadFile(os.path.join(TMPETC,"Confauto.prc")) + CONF=CONF.replace("default-model-extension .egg","default-model-extension .bam") + WriteFile(os.path.join(TMPETC,"Confauto.prc"), CONF) + ############################################################################## # # Compile all py files, convert all egg files. @@ -244,7 +276,7 @@ def DeleteFiles(file): print "" print "Compiling BAM and PYC files..." -os.chdir(TMPDIR) +os.chdir(TMPGAME) CompileFiles(".") DeleteFiles(".") @@ -266,8 +298,9 @@ CMD=CMD+'/DRUNTEXT="Play '+NAME+'" ' CMD=CMD+'/DIBITMAP="'+BITMAP+'" ' CMD=CMD+'/DUBITMAP="'+BITMAP+'" ' CMD=CMD+'/DPANDA="'+PANDA+'" ' +CMD=CMD+'/DPANDACONF="'+TMPETC+'" ' CMD=CMD+'/DPSOURCE="'+PSOURCE+'" ' -CMD=CMD+'/DPPGAME="'+TMPDIR+'" ' +CMD=CMD+'/DPPGAME="'+TMPGAME+'" ' CMD=CMD+'/DPPMAIN="'+MAIN+'" ' CMD=CMD+'/DPPICON="'+PPICON+'" ' CMD=CMD+'"'+PSOURCE+'\\direct\\src\\directscripts\\packpanda.nsi"'