mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2025-01-05 23:55:06 +01:00
Add pak utils
This commit is contained in:
parent
cd89009d6b
commit
bee8f590a3
4
.gitignore
vendored
4
.gitignore
vendored
@ -12,4 +12,8 @@ jni/src/MobileTouchControls/MobileTouchControls
|
||||
|
||||
local.properties
|
||||
|
||||
*.apk
|
||||
|
||||
assets/extras.pak
|
||||
|
||||
res/values/git-rev.xml
|
||||
|
@ -5,6 +5,7 @@ APKBUILDER=./../apkbuilder
|
||||
mkdir gen
|
||||
mkdir bin
|
||||
sh gen-version.sh test build
|
||||
python2.7 makepak.py xash-extras assets/extras.pak
|
||||
$AAPT package -m -J gen/ --rename-manifest-package in.celest.xash3d.hl -M AndroidManifest.xml -S test/res -I $ANDROID_JAR
|
||||
$JAVA_HOME/bin/javac -d bin/classes -s bin/classes -cp $ANDROID_JAR src/org/libsdl/app/SDLActivity.java gen/in/celest/xash3d/hl/R.java src/in/celest/xash3d/*
|
||||
$DX --dex --output=bin/classes.dex bin/classes/
|
||||
|
43
makepak.py
Normal file
43
makepak.py
Normal file
@ -0,0 +1,43 @@
|
||||
import sys
|
||||
import struct
|
||||
import os
|
||||
|
||||
#dummy class for stuffing the file headers into
|
||||
class FileEntry:
|
||||
pass
|
||||
|
||||
#arguments are source directory, then target filename e.g. "pak1.pak"
|
||||
rootdir = sys.argv[1]
|
||||
pakfilename = sys.argv[2]
|
||||
|
||||
pakfile = open(pakfilename,"wb")
|
||||
|
||||
#write a dummy header to start with
|
||||
pakfile.write(struct.Struct("<4s2l").pack(b"PACK",0,0))
|
||||
|
||||
#walk the directory recursively, add the files and record the file entries
|
||||
offset = 12
|
||||
fileentries = []
|
||||
for root, subFolders, files in os.walk(rootdir):
|
||||
for file in files:
|
||||
entry = FileEntry()
|
||||
impfilename = os.path.join(root,file)
|
||||
entry.filename = os.path.relpath(impfilename,rootdir).replace("\\","/")
|
||||
with open(impfilename, "rb") as importfile:
|
||||
pakfile.write(importfile.read())
|
||||
entry.offset = offset
|
||||
entry.length = importfile.tell()
|
||||
offset = offset + entry.length
|
||||
fileentries.append(entry)
|
||||
tablesize = 0
|
||||
|
||||
#after all the file data, write the list of entries
|
||||
for entry in fileentries:
|
||||
pakfile.write(struct.Struct("<56s").pack(entry.filename.encode("ascii")))
|
||||
pakfile.write(struct.Struct("<l").pack(entry.offset))
|
||||
pakfile.write(struct.Struct("<l").pack(entry.length))
|
||||
tablesize = tablesize + 64
|
||||
|
||||
#return to the header and write the values correctly
|
||||
pakfile.seek(0)
|
||||
pakfile.write(struct.Struct("<4s2l").pack(b"PACK",offset,tablesize))
|
@ -988,6 +988,10 @@ public class SDLActivity extends Activity {
|
||||
}
|
||||
os.close();
|
||||
is.close();
|
||||
SharedPreferences.Editor editor = mPref.edit();
|
||||
editor.putInt( "pakversion", PAK_VERSION );
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
} catch( Exception e )
|
||||
{
|
||||
Log.e( TAG, "Failed to extract PAK:" + e.toString() );
|
||||
|
Loading…
Reference in New Issue
Block a user