Skip to content
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

Auto fill the selected folder's name in the Name/AppID field #64

Closed
wants to merge 4 commits into from
Closed
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
8 changes: 7 additions & 1 deletion steam_auto_cracker_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import json
import os
import subprocess
import re
from sac_lib.get_file_version import GetFileVersion
import shutil
from time import sleep
Expand Down Expand Up @@ -71,6 +72,7 @@ def DoRequest(self):
def select_folder():
global folder_path
folder_path = filedialog.askdirectory()
folder_name = re.sub(r".*(\\|/)?([^\\]+)(\\|/)", "", folder_path)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using os.path.basename would probably be better

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, regex was more intuitive for me tho

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice regex though haha, I hope it was found only or ChatGPT x)
They're always so hard to make

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, i made it together with https://regex101.com

They're alright when u get used to it

if not os.path.isdir(folder_path):
update_logs("\nNo folder has been selected")
selectedFolderLabel.config(text="")
Expand All @@ -84,8 +86,12 @@ def select_folder():
selectedFolderLabel.config(text=f"Selected folder:\n{folder_path}")
selectedFolderLabel.pack()
frameGame2.pack()
gameNameEntry.delete(0, last=len(gameNameEntry.get()))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tk.END would probably fit better :)

gameNameEntry.insert(0, folder_name)
if gameSearchDone:
frameCrack2.pack()
gameNameEntry.delete(0, last=len(gameNameEntry.get()))
gameNameEntry.insert(0, folder_name)
Comment on lines +93 to +94
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate? Doesn't seem required

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you have two cases one of which when the folder already got selected. If the duplicate doesn‘t stay, it wouldn‘t auto-fill in that case

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not true? It's not an if else, just a simple if. The delete & insert functions are called BEFORE the IF, so that wouldn't matter

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh shoot true, yeah than nevermind probably

wouldn't the whole if clause be useless in this case?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IF close is meant to re-display the whole "Selected crack:" section if you decide to change the selected directory AFTER doing the App search (select a folder, search for the app, then unselect/change folder); at least from what I remember


def update_logs(log_message):
# Get current content
Expand Down Expand Up @@ -936,4 +942,4 @@ def ReloadConfig():
errorFile.write(f"SteamAutoCracker GUI v{VERSION}\n---\nA Python error occurred!\nPlease report it on GitHub or cs.rin.ru\nMake sure to blank any personal detail.\n---\n\n")
traceback.print_exc(file=errorFile)
traceback.print_exc()
print("---\nError written to error.log, please report it on GitHub or cs.rin.ru\nMake sure to blank any personal detail.")
print("---\nError written to error.log, please report it on GitHub or cs.rin.ru\nMake sure to blank any personal detail.")