Skip to content

Commit

Permalink
Locator now finds eye textures
Browse files Browse the repository at this point in the history
  • Loading branch information
Tormak9970 committed May 8, 2021
1 parent 6f0f144 commit 4ea720f
Showing 1 changed file with 50 additions and 8 deletions.
58 changes: 50 additions & 8 deletions SWTOR File Locator and Populator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,68 @@
import shutil
import json

eyeMatInfo = None

def main():
config_data = read_config()
paths_json = read_paths(config_data['toon-folder'])
parsed_paths = grab_files_to_load(paths_json)
extraction_resource_folder = config_data['extraction-folder']
for path_obj in parsed_paths:
locate_and_copy_files(path_obj, config_data['toon-folder'], extraction_resource_folder)
if os.path.exists(extraction_resource_folder) and os.path.exists(config_data['toon-folder']):
if eyeMatInfo is not None:
material_folder_copy_location = os.path.join(config_data['toon-folder'], 'assets\\materials\\eye\\')
if not os.path.exists(material_folder_copy_location):
os.makedirs(material_folder_copy_location)

for texture in eyeMatInfo.textures:
if (texture != None):
texture_path = os.path.join(extraction_resource_folder, texture[1:])
if os.path.exists(texture_path):
shutil.copy(texture_path, material_folder_copy_location)

for path_obj in parsed_paths:
locate_and_copy_files(path_obj, config_data['toon-folder'], extraction_resource_folder)

else:
print("your extraction or toon folder does not exist")


def locate_and_copy_files(path_obj, toon_folder_path, extracted_files_location):
if path_obj.slot_name == "skinMats":
for mat in path_obj.mats:
material_folder_copy_location = os.path.join(toon_folder_path, 'assets\\materials\\skinMats\\', mat.slot_name + "\\")
material_file_path = os.path.join(extracted_files_location, mat.mat_path[1:])
shutil.copy(material_file_path, material_folder_copy_location)
if os.path.exists(material_file_path):
shutil.copy(material_file_path, material_folder_copy_location)

for texture in mat.textures:
if (texture != None):
texture_path = os.path.join(extracted_files_location, texture[1:])
shutil.copy(texture_path, material_folder_copy_location)
if os.path.exists(texture_path):
shutil.copy(texture_path, material_folder_copy_location)

else:
model_folder_copy_location = os.path.join(toon_folder_path, 'assets\\models\\', path_obj.slot_name + "\\")
material_folder_copy_location = os.path.join(toon_folder_path, 'assets\\materials\\', path_obj.slot_name + "\\")
for model in path_obj.models:
model_path = os.path.join(extracted_files_location, model[1:])
shutil.copy(model_path, model_folder_copy_location)
if os.path.exists(model_path):
shutil.copy(model_path, model_folder_copy_location)

material_file_path = os.path.join(extracted_files_location, path_obj.mat_path[1:])
shutil.copy(material_file_path, material_folder_copy_location)
if os.path.exists(material_file_path):
shutil.copy(material_file_path, material_folder_copy_location)

for texture in path_obj.textures:
if (texture != None):
texture_path = os.path.join(extracted_files_location, texture[1:])
shutil.copy(texture_path, material_folder_copy_location)
if os.path.exists(texture_path):
shutil.copy(texture_path, material_folder_copy_location)


def grab_files_to_load(paths_json):
parsed_objs = []
global eyeMatInfo
for entry in paths_json:
if entry['slotName'] == "skinMats":
to_push = skin_mats_list_obj()
Expand All @@ -50,7 +73,11 @@ def grab_files_to_load(paths_json):
parsed_objs.append(to_push)

else:
parsed_objs.append(slot_obj(entry))
s = slot_obj(entry)
if s.slot_name == "head":
eyeMatInfo = slot_obj_mat_only(entry['materialInfo']['eyeMatInfo'])

parsed_objs.append(s)

return parsed_objs

Expand Down Expand Up @@ -91,6 +118,21 @@ def __repr__ (self):
return "{\n" + "slotName: " + self.slot_name + "\n" + "models: " + ", ".join(self.models) + "\n" + "matPath: " + self.mat_path + "\n" + "textures: " + ", ".join(self.textures) + "\n" + "}"


class slot_obj_mat_only():
def __init__(self, dict_from_json):
dds_dict = dict_from_json['ddsPaths']
self.textures = [
dds_dict['diffuseMap'] if 'diffuseMap' in dds_dict else None,
dds_dict['glossMap'] if 'glossMap'in dds_dict else None,
dds_dict['rotationMap'] if 'rotationMap'in dds_dict else None,
dds_dict['paletteMap'] if 'paletteMap'in dds_dict else None,
dds_dict['paletteMaskMap'] if 'paletteMaskMap'in dds_dict else None
]

def __repr__ (self):
return "{\n" + "textures: " + ", ".join(self.textures) + "\n" + "}"


class skin_mats_obj():
def __init__(self, dict_from_json):
self.slot_name = dict_from_json['slotName']
Expand Down

0 comments on commit 4ea720f

Please sign in to comment.