Skip to content

Test #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Test #25

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions src/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from texture import Texture
from map import Map
from decompiler import Decompiler
import subprocess

class File:
"""
Expand Down Expand Up @@ -141,14 +142,15 @@ def display_files_tree(self):
for file_name in file_list:
parent_folder_path = os.path.join(self.sdk.parent_folder, folder) # Define parentFolder

self.tree.insert(parent, "end", text=file_name, tags=(folder,))
#self.tree.insert(parent, "end", text=file_name, tags=(folder,))
"""
thumbnail = self.load_thumbnail(file_name, parent_folder_path)
if thumbnail:
self.tree.insert(parent, "end", text=file_name, image=thumbnail, tags=(folder,))
else:
self.tree.insert(parent, "end", text=file_name, tags=(folder,))
"""


# Bind double-click event to open the selected file
self.tree.bind("<Double-Button-1>", self.open_file)
Expand Down Expand Up @@ -236,7 +238,8 @@ def load_thumbnail(self, file_path, parent=""):
".wav": "audio.png",
".mp3": "audio.png",
".bik": "video.png",
".bat": "terminal.png"
".bat": "terminal.png",
".vpk": "VPKEdit.png"
}

file_name, file_extension = os.path.splitext(file_path)
Expand All @@ -260,6 +263,28 @@ def load_thumbnail(self, file_path, parent=""):
print("Error loading thumbnail:", e)
return None

'''
def load_thumbnail_folder(self):
"""
"""
try :
image = None
base_path = os.path.dirname(os.path.abspath(__file__))

image = Image.open(os.path.join(base_path, "icons", "fileexplorer.png"))

if image:
image.thumbnail((16, 16))
thumbnail = ImageTk.PhotoImage(image)
#self.thumbnails[file_path] = thumbnail
return thumbnail
else:
print('error load thumbnail')
except Exception as e:
print("Error loading thumbnail:", e)
return None
'''

def show_context_menu(self, event, file_path=None):
"""
Show the context menu on right-click.
Expand Down Expand Up @@ -289,7 +314,9 @@ def show_context_menu(self, event, file_path=None):
file_name, file_extension = os.path.splitext(file_path)

self.context_menu = tk.Menu(self.root, tearoff=0)

open = Open(self.sdk)
self.context_menu.add_command(label="open", command=lambda: open.open_file(file_path))

if file_extension == ".qc":
model = Model(self.sdk)
self.context_menu.add_command(label="Compile Model", command=lambda: model.build_model(file_path))
Expand Down Expand Up @@ -473,4 +500,3 @@ def open_directory(self):
"""
open_instance = Open(self.sdk)
open_instance.open_directory(self.current_folder)

8 changes: 6 additions & 2 deletions src/open.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def open_file(self, localpath):
command = f'"{self.sdk.bin_folder}/hlmv.exe" "{localpath}"'
subprocess.Popen(command)
elif file_extension == ".vmf":
"""
if os.path.isfile(self.sdk.bin_folder + "/hammerplusplus.exe"):
command = f'"{self.sdk.bin_folder}/hammerplusplus.exe" "{localpath}"'
print(command)
else:
"""
command = f'"{self.sdk.bin_folder}/hammer.exe" "{localpath}"'
subprocess.Popen(command)
elif file_extension == ".vcd":
Expand Down Expand Up @@ -74,8 +80,6 @@ def open_file(self, localpath):
print("Error: Failed to open file:", e)




def open_file_with_tree(self, tree):
"""
Open the selected file from the Treeview.
Expand Down
Loading