From 96bc2e0026a369ecf8598fb2168d0a4e02e9e1bd Mon Sep 17 00:00:00 2001 From: Treeki Date: Mon, 30 Jan 2012 00:40:28 +0100 Subject: message boxes are now functional --- tools/msgbox_data.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tools/msgbox_data.py (limited to 'tools') 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) + -- cgit v1.2.3