@@ -81,12 +81,28 @@ def open_VTF(self,file=""):
81
81
command = '"' + os .getcwd () + "/VTFEdit/x64/VTFEdit.exe" + '" ' + '"' + file + '"'
82
82
subprocess .Popen (command )
83
83
84
- def texture_to_tga (self ):
84
+ def texture_to_tga (self , file = None , output = None ):
85
85
"""
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
86
94
"""
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" )
87
104
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 } "'
90
106
result = subprocess .run (command , shell = True , capture_output = True , text = True )
91
107
print (result )
92
108
0 commit comments