Page 1 of 2

This War of Mine (.binfont, .texture)

Posted: Fri Nov 28, 2014 12:29 pm
by merlinsvk
So I finally managed to make a texture converting BMS scripts for both, the .binfont and .texture files.

For easier localization, there would by neat to have some tool/script to convert/import/export strings from l??n.bin file (editing is doable via hex or Notepad++, but plain text would be better) :(

EDIT2: Mipmaps in .texture files are supported and written in the correct way :keke:

Code: Select all

# This War of Mine
# BINFONT to DDS converter
# by MerlinSVK    Nov 2014
# version 1.0
# script for QuickBMS    http://aluigi.org/papers.htm#quickbms

get SIZE asize
get NAME basename
string HNAME = NAME
string TNAME = NAME
string HNAME += ".head"
string TNAME += ".tail"
string NAME += ".dds"

idstring "\xE3\x0A\xF2\x23"
get UNK long
get TYPE byte
get COUNT long
math HEIGHT = 0

for i = 0 < COUNT
	get TMP long
	math HEIGHT += TMP
next i
savepos OFFSET

xmath DATASZ "(SIZE / 0x1000) * 0x1000"		# length of texture data
xmath TOFFSET "OFFSET + DATASZ"				# start of tail
xmath TSIZE "SIZE - TOFFSET"				# length of tail

if COUNT > 1 then
	xmath OFFSET "(COUNT * 4) + (OFFSET - 4)"
endif

if TYPE == 1		# L8A8 format
	set MEMORY_FILE binary "\x44\x44\x53\x20\x7C\x00\x00\x00\x07\x10\x08\x00\xAA\xAA\xAA\xAA\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\x00\x00\x00\x00\x00\x00\x00\x00\x4D\x45\x52\x4C\x49\x4E\x3A\x29\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x01\x00\x02\x00\x00\x00\x00\x00\x10\x00\x00\x00\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
	xmath WIDTH "(DATASZ / HEIGHT) / 2"
else				# L8 format
	set MEMORY_FILE binary "\x44\x44\x53\x20\x7C\x00\x00\x00\x0F\x10\x00\x00\xAA\xAA\xAA\xAA\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\x00\x00\x00\x00\x01\x00\x00\x00\x4D\x45\x52\x4C\x49\x4E\x3A\x29\x01\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x08\x00\x00\x00\xFF\x00\x00\x00\xFF\x00\x00\x00\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
	xmath WIDTH "DATASZ / HEIGHT"
endif

putVarChr MEMORY_FILE 0XC HEIGHT long
putVarChr MEMORY_FILE 0x10 WIDTH long
putVarChr MEMORY_FILE 0x14 DATASZ long

append
log MEMORY_FILE OFFSET DATASZ
append

get DDSSIZE asize MEMORY_FILE
log HNAME 0 OFFSET				# save header
log TNAME TOFFSET TSIZE			# save tail (char descriptions)
log NAME 0 DDSSIZE MEMORY_FILE	# save DDS texture

Code: Select all

# This War of Mine
# DDS to BINFONT converter
# version 1.0
# by MerlinSVK    Nov 2014
# script for QuickBMS    http://aluigi.org/papers.htm#quickbms

open FDDE DDS 0
open FDDE HEAD 1
open FDDE TAIL 2

get NAME basename
string NAME += ".binfont_NEW"

get DSIZE asize 0
get HSIZE asize 1
get TSIZE asize 2

math DSIZE -= 0x80				# subtract the DDS header

log MEMORY_FILE 0 HSIZE 1		# copy header into memory_file
append
log MEMORY_FILE 0x80 DSIZE 0	# append texture data
log MEMORY_FILE 0 TSIZE 2		# append tail
append

get BINSZ asize MEMORY_FILE
log NAME 0 BINSZ MEMORY_FILE

Code: Select all

# This War of Mine
# TEXTURE to DDS converter
# by MerlinSVK    		Dec 2014
# version 1.2			(added support for RGBA format & mipmaps)
# script for QuickBMS	http://aluigi.org/papers.htm#quickbms

get SIZE asize
get NAME basename
string HNAME = NAME
string MNAME = NAME
string HNAME += ".head"
string NAME += ".dds"

get WIDTH long
get HEIGHT long
get TYPE long
get MIPS long

xmath DATASZ "SIZE - 0x90"

if TYPE == "0x31545844"			# DXT1
	set MEMORY_FILE binary "\x44\x44\x53\x20\x7C\x00\x00\x00\x07\x10\x08\x00\xAA\xAA\xAA\xAA\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\x00\x00\x00\x00\x01\x00\x00\x00\x4D\x45\x52\x4C\x49\x4E\x3A\x29\x01\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x04\x00\x00\x00\x44\x58\x54\x31\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
elif TYPE == "0x33545844"		# DXT3
	set MEMORY_FILE binary "\x44\x44\x53\x20\x7C\x00\x00\x00\x07\x10\x08\x00\xAA\xAA\xAA\xAA\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\x00\x00\x00\x00\x01\x00\x00\x00\x4D\x45\x52\x4C\x49\x4E\x3A\x29\x01\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x04\x00\x00\x00\x44\x58\x54\x33\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
elif TYPE == "0x35545844"		# DXT5
	set MEMORY_FILE binary "\x44\x44\x53\x20\x7C\x00\x00\x00\x07\x10\x08\x00\xAA\xAA\xAA\xAA\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\x00\x00\x00\x00\x01\x00\x00\x00\x4D\x45\x52\x4C\x49\x4E\x3A\x29\x01\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x04\x00\x00\x00\x44\x58\x54\x35\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
elif TYPE == "0x15"				# RGBA8
	set MEMORY_FILE binary "\x44\x44\x53\x20\x7C\x00\x00\x00\x0F\x10\x00\x00\x41\x41\x41\x41\x42\x42\x42\x42\x43\x43\x43\x43\x43\x00\x00\x00\x01\x00\x00\x00\x4D\x45\x52\x4C\x49\x4E\x3A\x29\x01\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x41\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\xFF\x00\x00\xFF\x00\x00\xFF\x00\x00\x00\x00\x00\x00\xFF\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
endif

	putVarChr MEMORY_FILE 0XC HEIGHT long
	putVarChr MEMORY_FILE 0x10 WIDTH long
	putVarChr MEMORY_FILE 0x14 DATASZ long

if MIPS == 1
	append
	log MEMORY_FILE 0x90 DATASZ
	append
else
	putVarChr MEMORY_FILE 0XA 0x0A byte
	putVarChr MEMORY_FILE 0X1C MIPS long
	putVarChr MEMORY_FILE 0X6C 0x08 byte
	putVarChr MEMORY_FILE 0X6E 0x40 byte

	math MIPOFFSET = 0x90					# offset of the smallest mipmap
	for i = 1 <= MIPS						# read mipmap lenghts
		get MIPWIDTH short
		get MIPHEIGHT short
		get MIPSIZE[i] long

		set MIPSTART[i] long MIPOFFSET
		set MIPSZ long MIPSIZE[i]
		xmath MIPOFFSET "MIPOFFSET + MIPSZ"	# calculate next mipmap offset
	next i
			
	append
	for i = MIPS >= 1						# writing mipmaps in reversed order
		log MEMORY_FILE MIPSTART[i] MIPSIZE[i]
	next i - 1
	append
endif

get DDSSIZE asize MEMORY_FILE
log HNAME 0 0x90				# save header
log NAME 0 DDSSIZE MEMORY_FILE	# save DDS texture

Code: Select all

# This War of Mine
# DDS to TEXTURE converter
# by MerlinSVK    		Dec 2014
# version 1.1			(added support for mipmaps)
# script for QuickBMS	http://aluigi.org/papers.htm#quickbms

open FDDE DDS 0
open FDDE HEAD 1

get NAME basename
string NAME += ".texture_NEW"

get DSIZE asize 0
get HSIZE asize 1

goto 0xC 1						# read number of mipmaps from header
get MIPS long 1

math DDSSIZE = DSIZE
math DSIZE -= 0x80				# subtract the DDS header
log MEMORY_FILE 0 HSIZE 1		# copy header into memory_file

if MIPS == 1
	append
	log MEMORY_FILE 0x80 DSIZE 0	# append whole texture data
	append
else
	for i = 1 <= MIPS				# read mipmap lenghts
		get MIPWIDTH short 1
		get MIPHEIGHT short 1
		get MIPSIZE[i] long 1
	next i

	math MIPOFFSET = 0x80			# offset of the biggest texture
	for i = MIPS >= 1
		set MIPSTART[i] long MIPOFFSET
		set MIPSZ long MIPSIZE[i]
		xmath MIPOFFSET "MIPOFFSET + MIPSZ"			# calculate next mipmap offset
	next i - 1
			
	append
	for i = 1 <= MIPS								# writing mipmaps in reversed order
		log MEMORY_FILE MIPSTART[i] MIPSIZE[i]
	next i
	append
endif

get BINSZ asize MEMORY_FILE
log NAME 0 BINSZ MEMORY_FILE

Code: Select all

Bin file with strings, if somebody wants to look at it.
https://www.dropbox.com/s/dz1ygg7uv2koh82/l01n.7z

Re: This War of Mine (.binfont, .texture)

Posted: Fri Nov 28, 2014 1:31 pm
by merlinsvk
And I also have partially done font description reader, for those who would like to add new letters into font textures.
But I don't know what UNK1 and UNK2 represents.

Image

Code: Select all

https://www.dropbox.com/s/dtamrn1ulg9nx0y/font_example.7z

Code: Select all

# This War of Mine
# Font descripion reader (from .tail file)

get COUNT long
for i = 0 < COUNT
	get CHAR short
	get UNK1 short
	get UNK2 short
	get X1 short
	get X2 short
	get Y1 short
	get Y2 short
	xmath WIDTH  "X2 - X1"
	xmath HEIGHT "Y2 - Y1"
	print "Char: %CHAR|h%, X1: %X1%, Y1: %Y1%, X2: %X2%, Y2: %Y2%, Width: %WIDTH%, Height: %HEIGHT%"
next i

Re: This War of Mine (.binfont, .texture)

Posted: Tue Dec 02, 2014 4:54 am
by shadowlonely1989
You can use Cartographer to dump text with your table to extract text and use atlas to insert your text.

Re: This War of Mine (.binfont, .texture)

Posted: Tue Dec 09, 2014 1:28 pm
by merlinsvk
Scripts for converting .texture/.dds texture in first post were updated. Now they support mipmaps :)
The only "disadvantage" is that you can't change: format of texture (DXT, RGBA, etc.), resolution or number of mipmaps, because DDS to TEXTURE script reads the original .head file. But if you don't change any of these, everything is OK.

Re: This War of Mine (.binfont, .texture)

Posted: Tue Dec 09, 2014 5:28 pm
by geraldhu
merlinsvk wrote:Scripts for converting .texture/.dds texture in first post were updated. Now they support mipmaps :)
The only "disadvantage" is that you can't change: format of texture (DXT, RGBA, etc.), resolution or number of mipmaps, because DDS to TEXTURE script reads the original .head file. But if you don't change any of these, everything is OK.
Can translate?Thanks for your Scripts,but I tried to use Ekey's unpacker/packer and don't edit any file,it create much unknow files ,the common.dat are bigger, and game can't start.
I haven't tried your Scripts,because i can't pack the "common.dat"
Sorry for my English,and i'm beginner,please help me. :<

Re: This War of Mine (.binfont, .texture)

Posted: Tue Dec 09, 2014 7:22 pm
by merlinsvk
Yes, I'm translating (version 1.0.0). I wrote a script to import/export text file. And some other scripts (QuickBMS, Lua, Batch files and 010 scripts) to split l10n.bin file into thousands string files. It's a mess and not real tools to publish. :eek:

Re: This War of Mine (.binfont, .texture)

Posted: Fri Dec 12, 2014 5:08 am
by shadowlonely1989
merlinsvk wrote:Yes, I'm translating (version 1.0.0). I wrote a script to import/export text file. And some other scripts (QuickBMS, LUA, Batch files and 010 scripts) to split l10n.bin file into thousands string files. It's a mess and not real tools to publish. :eek:
Could you help me extract text from this game, please? Thanks for any help!

Re: This War of Mine (.binfont, .texture)

Posted: Fri Dec 12, 2014 11:46 am
by merlinsvk
For text export use this script. It can be also used to reimporting, just type "force" when QBMS prompt you.

Code: Select all

# This War of Mine (common.dat)
# uncomment the appropriate line
comtype gzip
#clog "l10n.bin" 0xC9C0EA 0x1310E2 0x1310E2		# version 1.0.0
#clog "l10n.bin" 0xD455D0 0x131179 0x131179		# version 1.1.0
clog "l10n.bin" 0xD41BF5 0x156BE6 0x156BE6		# version 1.1.3
But there is still no easy way to extract the strings.

Re: This War of Mine (.binfont, .texture)

Posted: Fri Dec 12, 2014 4:47 pm
by WRS
merlinsvk wrote:But there is still no easy way to extract the strings.
take a look here: viewtopic.php?p=101705#p101705 8)

(credit to rengareng)

Re: This War of Mine (.binfont, .texture)

Posted: Sat Dec 13, 2014 2:07 pm
by geraldhu
merlinsvk wrote:For text export use this script. It can be also used to reimporting, just type "force" when QBMS prompt you.

Code: Select all

# This War of Mine (common.dat)
# uncomment the appropriate line
comtype gzip
#clog "l10n.bin" 0xC9C0EA 0x1310E2 0x1310E2		# version 1.0.0
#clog "l10n.bin" 0xD455D0 0x131179 0x131179		# version 1.1.0
clog "l10n.bin" 0xD41BF5 0x156BE6 0x156BE6		# version 1.1.3
But there is still no easy way to extract the strings.
I try to use [clog "l10n.bin" 0xC9C0EA 0x1310E2 0x1310E2] for Ver 1.1.0.
[clog "l10n.bin" 0xD455D0 0x131179 0x131179] for Ver 1.1.0 error.
May be my problem.

Re: This War of Mine (.binfont, .texture)

Posted: Sat Dec 13, 2014 2:41 pm
by merlinsvk
Sorry, I don't understand you. What is the problem?

Re: This War of Mine (.binfont, .texture)

Posted: Sat Dec 13, 2014 4:01 pm
by geraldhu
merlinsvk wrote:Sorry, I don't understand you. What is the problem?
My version = 1.1.0
can use
[clog "l10n.bin" 0xC9C0EA 0x1310E2 0x1310E2 # version 1.0.0]
not
[clog "l10n.bin" 0xD455D0 0x131179 0x131179 # version 1.1.0]

Re: This War of Mine (.binfont, .texture)

Posted: Sat Dec 13, 2014 5:38 pm
by merlinsvk
Well, it doesn't matter anymore. You can use Ekey's packer/unpacker tools.

Re: This War of Mine (.binfont, .texture)

Posted: Fri Dec 19, 2014 4:05 pm
by momo
Thank you for sharing scripts. I've made binfont converter based on your scripts.

http://www.mediafire.com/download/78ou3 ... ol_v1_1.7z (updated 2014/12/23)
(The readme in the package is Japanese only.)

* binfont tool
binfont tool converts .binfont file to dds and fnt files. fnt file is font information xml file which is as same format as Bitmap font generater's fnt file. You can also convert new fonts generated by Bitmap font generater to binfont.

- unpack
binfont_tool -u <binfont path> [<folder path to extract>]
- pack
binfont_tool -p <fnt file path> [<new binfont file path>]

To create new font, The following BMFont options are required.

- Export Options
Equalize the cell heights: Checked
Width: 1024(fixed)
Height: any
Bit depth: 32
Presets: White text with alpha
Font descriptor: XML
Textures: dds - DirectDraw Surface
Compression: None

There are 2 other tools in this package.

* l01n_tool
l01n_tool is unpack/repack tool of l10n.bin. it converts l01n.bin to csv and dat files. The csv file is English text file and you can edit this file for translation. The dat file is data file for repacking and should not be modified.

- unpack
l01n_tool -u <l01n.bin path> [<csv file path>]
- pack
l01n_tool -p <csv file path> [<new l01n.bin>]

* twom_idx
The file header of idx file repacked by Ekey's Packer is different from the valid file header for This War of Mine and the game won't start with repacked files. This tool rewrites idx header values correctly.

twom_idx <idx file path to rewrite>

Here is a sample screen shot with Japanese fonts and texts. :D

http://3.bp.blogspot.com/-Gvb4YxqV3A4/V ... _00001.jpg

Re: This War of Mine (.binfont, .texture)

Posted: Fri Dec 19, 2014 6:40 pm
by merlinsvk
Great tools, indeed :)

Do you know a tool for creating BMFont besides Angel Code's Editor? It makes crappy looking fonts, especially that smaller ones.