diff --git a/export_import.py b/Lib/export_import.py similarity index 84% rename from export_import.py rename to Lib/export_import.py index c7d6e4a..488bb49 100644 --- a/export_import.py +++ b/Lib/export_import.py @@ -2,12 +2,27 @@ import os from binary_reader import BinaryReader from cv2 import exp +from tkinter import Tk, messagebox + apti_tex_magic = bytes.fromhex('6D 32 F3 C3') DDS_Header = b'DDS |\x00\x00\x00\x07\x10\x08\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x01\x00\x00\x00GIMP-DDS\\\t\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00\x00\x00\x04\x00\x00\x00DXT5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' apti_tex_header = b'm2\xf3\xc3\xd1\x9ce\xe9\x9a\xbc\x0f\r"\xdb\xdaO\x00Q5!k\xc7\xd8\x01;\x00\x04\x007\x00\x00\x00\x04\x00\x04\x00\x0c\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x9a\xbc\x0f\r"\xdb\xdaO\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x04\x00\xc5\x04\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1d\x02\x00\x00\x00\x00\xff\x00' zeros = b'\x00'*4 +def notify(msg): + root = Tk() + root.withdraw() + messagebox.showinfo("Info", msg) + root.destroy() + +def error(msg): + root = Tk() + root.withdraw() + messagebox.showerror("Error", msg) + root.destroy() + + def export_command(file_path, dirname): try: file_name = os.path.basename(file_path) @@ -26,14 +41,16 @@ def export_command(file_path, dirname): out_file.write(DDS_Header + dosya) out_file.seek(-4, io.SEEK_END) out_file.truncate() + notify("Done!") return 'Done!' except: + error('Something went wrong.') return 'Something went wrong.' def import_command(file_path, dirname): try: file_name = os.path.basename(file_path) - outputfile = dirname + '\\' + file_name[:-4] + '.APTI_TEX' + outputfile = dirname + '\\' + file_name[:-4] + '.apti_tex_NEW' file_stats = os.stat(file_path) f = open(file_path, "rb") @@ -54,6 +71,8 @@ def import_command(file_path, dirname): size_dosya = reader_for_dds.size() out_file.write(apti_tex_header + reader_for_dds.read_bytes(size_dosya) + zeros) + notify("Done!") return 'Done!' except: - return 'Something went wrong' + error('Something went wrong.') + return 'Something went wrong.' \ No newline at end of file diff --git a/ui.py b/Lib/ui.py similarity index 96% rename from ui.py rename to Lib/ui.py index 849bda1..09796b0 100644 --- a/ui.py +++ b/Lib/ui.py @@ -1,13 +1,13 @@ import tkinter as tk import tkinter.font as tkFont from tkinter import filedialog -import export_import +from Lib import export_import class App: def __init__(self, root): #setting title - root.title("undefined") + root.title("apti_tex Tool") #setting window size width=600 height=500 @@ -49,7 +49,7 @@ def __init__(self, root): import_button["font"] = ft import_button["fg"] = "#000000" import_button["justify"] = "center" - import_button["text"] = "Import" + import_button["text"] = "Import!" import_button.place(x=380,y=160,width=160,height=53) import_button["command"] = self.import_button_command diff --git a/README.md b/README.md index 148db98..3d1093e 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,32 @@ You need to edit this DDS or at least make sure to convert it through GIMP "BC3/ Other compression support will add soon. After your editing is done, you can use the Import button to import your DDS file to the *.apti_tex file. Simple enough. + +# apti_tex Tool + +A lightweight GUI utility for exporting and importing `*.apti_tex` texture files. +The tool converts `*.apti_tex` files into `*.DDS` (BC3/DXT5) for editing in applications such as GIMP, and then repacks edited DDS files back into the apti_tex format. + +## Features +- Export `.apti_tex` files to `.DDS` +- Supports editing DDS files in BC3/DXT5 format +- Import edited `.DDS` files back into `.apti_tex` +- Simple Tkinter-based interface +- Error and status notifications via message boxes + +## How It Works +- **Export:** Reads the custom header, extracts raw texture data, and builds a valid DDS output file. +- **Import:** Validates the DDS header, rebuilds the apti_tex structure, and writes a new `.apti_tex_NEW` file. + +## Requirements +- Python 3.x +- `binary-reader` +- `tkinter` +- `opencv-python` + +## Usage +Run the main script: +**python apti_texTool.py** + + +Then use the GUI buttons to export or import textures. diff --git a/apti_texTool.py b/apti_texTool.py new file mode 100644 index 0000000..8fdb6af --- /dev/null +++ b/apti_texTool.py @@ -0,0 +1,7 @@ +from Lib import ui + +try: + if __name__ == "__main__": + ui() +except Exception as e: + pass \ No newline at end of file diff --git a/main.py b/main.py deleted file mode 100644 index 68c06ad..0000000 --- a/main.py +++ /dev/null @@ -1,4 +0,0 @@ -import ui - -if __name__ == "__main__": - ui() \ No newline at end of file