Skip to content

Instantly share code, notes, and snippets.

@JoshuaWierenga
Last active May 13, 2016 10:32
Show Gist options
  • Save JoshuaWierenga/07edf036c03e2dfec5ec84d0254d9567 to your computer and use it in GitHub Desktop.
Save JoshuaWierenga/07edf036c03e2dfec5ec84d0254d9567 to your computer and use it in GitHub Desktop.
Finding texture locations for quantum break models
import os
def get_Texture_Names(metafile, dirty):
infile = open(metafile, "r")
text = ""
line = infile.readline()
while line != '' and not "m_vecReferencedFiles" in line:
line = infile.readline()
while line != '':
line = infile.readline()
line = line.lstrip()
line = os.path.basename(line)
line = line.replace("tga", "tex.dds")
line = line.replace('"', '')
line = line.replace(',', '')
if "_d.tex.dds" in line:
if "_dirt_01_" in line:
if dirty:
temp = line
temp = temp.replace("_dirt_01_", "_")
for testline in text.split('\n'):
if testline == temp[:-1]:
text = text.replace(temp, "")
break
else:
continue
elif "_a.tex.dds" in line:
if not "eyelashes" in line or "hair" in line:
continue
else:
continue
text += line
infile.close()
return text.split("\n")
def get_Folders(metafile, qbextractfolder):
return [os.path.join(root, name)
for root, dirs, files in os.walk(qbextractfolder)
for name in files
if name.endswith(".dds")]
def find_Locations(metafile, ddslocations, textures):
outfile = open(metafile + ".locations.txt", "a")
for ddslocation in ddslocations:
for filename in textures:
if os.path.basename(ddslocation) == filename:
outfile.write(ddslocation + "\n")
continue
outfile.close()
#def select_Locations(metafile)
def get_Texture_Locations(metafile, qbextractfolder, dirty):
textures = get_Texture_Names(metafile, dirty)
ddsfiles = get_Folders(metafile, qbextractfolder)
find_Locations(metafile, ddsfiles, textures)
#select_Locations(metafile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment