@@ -81,12 +81,28 @@ def open_VTF(self,file=""):
8181 command = '"' + os .getcwd () + "/VTFEdit/x64/VTFEdit.exe" + '" ' + '"' + file + '"'
8282 subprocess .Popen (command )
8383
84- def texture_to_tga (self ):
84+ def texture_to_tga (self , file = None , output = None ):
8585 """
86+ Converts a .vtf file to a .tga file using vtf2tga.exe.
87+
88+ Parameters:
89+ file (str): Path to the input .vtf file. If not provided, a file dialog will prompt the user to select a file.
90+ output (str): Directory where the output .tga file will be saved. If not provided, a directory dialog will prompt the user to select a directory.
91+
92+ Returns:
93+ None
8694 """
95+ if file == None :
96+ filenameVTF = filedialog .askopenfile (title = "Select .vtf file" , filetypes = [("VTF file" , "*.vtf" )], initialdir = self .sdk .selected_folder + "/materials" )
97+ file = filenameVTF .name
98+
99+ if output == None :
100+ outputDir = filedialog .askdirectory (title = "Select a Directory" ,initialdir = self .sdk .selected_folder + "/materialsrc" )
101+
102+ base_name = os .path .splitext (os .path .basename (file ))[0 ]
103+ output_file = os .path .join (outputDir , base_name + ".tga" )
87104
88- filenameVTF = filedialog .askopenfile (title = "Select .vtf file" , filetypes = [("VTF file" , "*.vtf" )], initialdir = self .sdk .selected_folder + "/materials" )
89- command = '"' + self .sdk .bin_folder + "/vtf2tga.exe" + '"' + " -i " + '"' + filenameVTF .name + '"'
105+ command = f'"{ self .sdk .bin_folder } /vtf2tga.exe" -i "{ file } " -o "{ output_file } "'
90106 result = subprocess .run (command , shell = True , capture_output = True , text = True )
91107 print (result )
92108
0 commit comments