Skip to content

Commit

Permalink
Update PES_Stadium_Exporter.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MjTs140914 committed Jan 13, 2023
1 parent bf0cb84 commit 82e265c
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions PES_Stadium_Exporter.py
Expand Up @@ -40,6 +40,7 @@
from Tools import FmdlFile, Ftex, IO, PesFoxShader, PesFoxXML, PesEnlighten, PesScarecrow, PesStaff
from xml.dom import minidom
from mathutils import Vector
from re import search

bl_info = {
"name": "PES Stadium Exporter",
Expand Down Expand Up @@ -697,7 +698,10 @@ def findDirectory(dirPath):
path = f"{listDir[0]}\\{os.path.join(*listDir).split(':')[1]}"
return path[:-4]


def findTextureDirectory(dirPath):
for root in os.walk(dirPath):
if "#windx11" in root[0]:
return root[0]

def getDirPath(dirPath):
for root, directories, filenames in os.walk(dirPath):
Expand All @@ -713,14 +717,16 @@ def textureLoad(dirPath):

ddsPath = os.path.join(root, filename + '.dds')
ftexPath = os.path.join(root, filename + extension)
if not os.path.isfile(ddsPath) and not "lut" in ddsPath and not "LUT" in ddsPath:
if not os.path.isfile(ddsPath):
# if search("lut", ddsPath.lower()):
# continue
try:
Ftex.ftexToDds(ftexPath, ddsPath)
except:
convert_ftex(ftexPath)
texconv(ddsPath, dirPath, " -y -l -f DXT5 -ft dds -srgb", True)
print('Converting {0} ==> {1}'.format(filename+'.ftex', filename+'.dds'))

return 1

def remove_dds(dirPath):
Expand Down Expand Up @@ -2698,9 +2704,10 @@ def execute(self, context):

getTextureDir = str()
if context.scene.fmdl_import_load_textures:
textureDir = f"{findDirectory(fpkdir)}sourceimages"
if os.path.exists(textureDir):
getTextureDir = getDirPath(textureDir)
textureDir = f"{findDirectory(fpkdir)}"
win11Dir = findTextureDirectory(textureDir)
if os.path.exists(win11Dir):
getTextureDir = getDirPath(win11Dir)
if os.path.exists(getTextureDir):
textureLoad(getTextureDir)
try:
Expand Down Expand Up @@ -2765,9 +2772,10 @@ def execute(self, context):

getTextureDir = str()
if context.scene.fmdl_import_load_textures:
textureDir = f"{findDirectory(fpkdir)}sourceimages"
if os.path.exists(textureDir):
getTextureDir = getDirPath(textureDir)
textureDir = f"{findDirectory(fpkdir)}"
win11Dir = findTextureDirectory(textureDir)
if os.path.exists(win11Dir):
getTextureDir = getDirPath(win11Dir)
if os.path.exists(getTextureDir):
textureLoad(getTextureDir)
try:
Expand Down Expand Up @@ -4631,14 +4639,10 @@ def execute(self, context):
mat_name = bpy.context.active_object.active_material.name
node_name = bpy.context.active_node.name
imagePath = bpy.data.materials[mat_name].node_tree.nodes[node_name].image.filepath
if os.path.isfile(imagePath):
try:
bpy.ops.image.external_edit(filepath=imagePath)
except Exception as msg:
self.report({"WARNING"}, format(msg))
return {'CANCELLED'}
else:
self.report({"WARNING"}, "File not found!!")
try:
bpy.ops.image.external_edit(filepath=imagePath)
except Exception as msg:
self.report({"WARNING"}, format(msg))
return {'CANCELLED'}
return {'FINISHED'}
pass
Expand Down

0 comments on commit 82e265c

Please sign in to comment.