home *** CD-ROM | disk | FTP | other *** search
- #Middle-earth: Shadow of War [PC] - ".TEXA" Loader
- #By Zaramot
- #v1.0
-
- from inc_noesis import *
- import subprocess
-
- def registerNoesisTypes():
- handle = noesis.register("Middle-earth: Shadow of War [PC] .texa", ".texa")
- noesis.setHandlerTypeCheck(handle, texCheckType)
- noesis.setHandlerLoadRGBA(handle, texLoadDDS)
- noesis.logPopup()
- return 1
-
- def texCheckType(data):
- bs = NoeBitStream(data, NOE_BIGENDIAN)
- fileMagic = bs.readUInt()
- if fileMagic == 0x54455841:
- return 1
- else:
- print("Fatal Error: Unknown file magic: " + str(hex(fileMagic) + " expected 0x54455841!"))
- return 0
-
- def texLoadDDS(data, texList):
- bs = NoeBitStream(data)
-
- fileMagic = bs.readUInt()
- bs.seek(0x10, NOESEEK_ABS) #Name-Path
- Path = bs.readUShort()
- PathData = bs.readBytes(Path)
- bs.seek(0x16, NOESEEK_REL) #Entry start
- numTextures = bs.readUByte()
- for i in range (numTextures):
- Path2 = bs.readUShort()
- PathData2 = bs.readBytes(Path2)
- bs.seek(0xC, NOESEEK_REL) #Entry start
- Height = bs.readUInt()
- TWidth = bs.readUInt()
- bs.seek(0x40, NOESEEK_REL) #Texture type
- TexID = bs.readString()
- ddsName = rapi.getLocalFileName(rapi.getInputName())
- #DXT1
- if TexID == "DXT1":
- ddsSize = TWidth * Height // 2
- bs.seek(0x27, NOESEEK_REL) #Texture start
- #DXT3
- elif TexID == "DXT3":
- ddsSize = TWidth * Height // 2
- bs.seek(0x27, NOESEEK_REL) #Texture start
- #DXT5
- elif TexID == "DXT5":
- ddsSize = TWidth * Height * 2 // 2
- bs.seek(0x27, NOESEEK_REL) #Texture start
- #DXT10
- elif TexID == "DX10":
- ddsSize = TWidth * Height
- bs.seek(0x3B, NOESEEK_REL) #Texture start
- print (PathData)
- print (ddsName)
- print (TWidth)
- print (Height)
- print (TexID)
- print (ddsSize)
- ddsData = bs.readBytes(ddsSize)
- #DXT1
- if TexID == "DXT1":
- texFmt = noesis.NOESISTEX_DXT1
- #DXT3
- elif TexID == "DXT3":
- texFmt = noesis.NOESISTEX_DXT3
- #DXT5
- elif TexID == "DXT5":
- texFmt = noesis.NOESISTEX_DXT5
- #DXT10
- elif TexID == "DX10":
- ddsData = rapi.imageDecodeDXT(ddsData, TWidth, Height, noesis.FOURCC_BC3)
- texFmt = noesis.NOESISTEX_RGBA32
- tex1 = (NoeTexture(ddsName, TWidth, Height, ddsData, texFmt))
- texList.append(tex1)
-
- return 1
-