diff options
author | Treeki <treeki@gmail.com> | 2012-01-30 00:40:28 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-01-30 00:40:28 +0100 |
commit | 96bc2e0026a369ecf8598fb2168d0a4e02e9e1bd (patch) | |
tree | 75cad32a169d79f81c1adf1945d49c9b6fc3310b /tools/msgbox_data.py | |
parent | 4d1cccfc209619919c2cae99fb5e58aa62b2bc64 (diff) | |
download | kamek-96bc2e0026a369ecf8598fb2168d0a4e02e9e1bd.tar.gz kamek-96bc2e0026a369ecf8598fb2168d0a4e02e9e1bd.zip |
message boxes are now functional
Diffstat (limited to '')
-rw-r--r-- | tools/msgbox_data.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/msgbox_data.py b/tools/msgbox_data.py new file mode 100644 index 0000000..06eec2b --- /dev/null +++ b/tools/msgbox_data.py @@ -0,0 +1,36 @@ +messages = [ + # Message 0 + (0x100, 'A Test Message', + 'This is a test message.\nWith some lines.\nAnd more lines.\nAnd a really long line to see if nw4r::lyt can handle wrapping or not...\nFinal line.' + ), + ] + +import struct, sys, os.path, codecs + +if len(sys.argv) > 1: + target = sys.argv[1] +elif os.path.exists('/home/me/Games/Newer'): + target = '/home/me/Games/Newer/ISO/files/NewerRes/Messages.bin' +else: + target = 'Messages.bin' + +messageCount = len(messages) + +stringOffset = (messageCount * 0xC) + 4 +infoStruct = struct.Struct('>III') + +headerData = bytearray(struct.pack('>I', messageCount)) +stringData = bytearray() + +for msgID, title, msg in messages: + titleOffset = stringOffset + len(stringData) + stringData += codecs.utf_16_be_encode(title)[0] + '\0\0' + msgOffset = stringOffset + len(stringData) + stringData += codecs.utf_16_be_encode(msg)[0] + '\0\0' + + headerData += infoStruct.pack(msgID, titleOffset, msgOffset) + +with open(target, 'wb') as out: + out.write(headerData) + out.write(stringData) + |