Skip to content

Commit

Permalink
v1.69 final
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariescyn committed Jun 5, 2023
1 parent dcb4c4b commit 548213d
Show file tree
Hide file tree
Showing 5 changed files with 329 additions and 156 deletions.
49 changes: 37 additions & 12 deletions SaveManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#Collapse all functions to navigate. In Atom editor: "Edit > Folding > Fold All"



# set always the working dir to the correct folder for unix env
if not is_windows:
os.chdir(os.path.dirname(os.path.abspath(__file__)))
Expand Down Expand Up @@ -159,7 +158,7 @@ def archive_file(file, name, metadata, names):
fho.write(fhi.read())
names = [i for i in names if not i is None]
formatted_names = ", ".join(names)
meta = f"{metadata}\nCHARACTERS: {formatted_names}"
meta = f"{metadata}\nCHARACTERS:\n {formatted_names}"

meta_ls = [i for i in meta]
try:
Expand Down Expand Up @@ -420,7 +419,7 @@ def wrapper(comm):
run_command(comm)
else:
nms = get_charnames(path)
archive_file(path, "None", "ACTION: Loaded save and overwrite current save file in EldenRing game directory", nms)
archive_file(path, "Loaded Save", "ACTION: Loaded save and overwrite current save file in EldenRing game directory", nms)
run_command(comm)

if len(lb.curselection()) < 1:
Expand All @@ -430,7 +429,6 @@ def wrapper(comm):
src_dir = "".join((savedir, name.replace(" ", "-"), "/"))



comm = lambda: copy_folder(src_dir, str(config.cfg["gamedir"]))
if not os.path.isdir(f"{savedir}{name}"):
popup(
Expand All @@ -439,9 +437,7 @@ def wrapper(comm):
lb.delete(0, END)
load_listbox(lb)
return
popup(
"Are you sure?", buttons=True, functions=(lambda: wrapper(comm), donothing)
)
popup("This will load your save into the game directory.\nWould you like to backup your current game first?\n\nClose this window to cancel load\n", buttons=True, functions=(lambda: import_save_menu(directory=src_dir + ext()), lambda:wrapper(comm)))


def run_command(subprocess_command, optional_success_out="OK"):
Expand Down Expand Up @@ -1955,11 +1951,15 @@ def do_popup(event):

def recover():
name = fetch_listbox_entry(lb1)[1].strip().replace(" ", "__").replace(":", ".")
if len(name) < 1:
popup("\nNothing selected!\n")
return
path = f"./data/archive/{name}/ER0000.xz"
folder_path = f"./data/recovered/{name}/"

try:
unarchive_file(path)
popup("Succesfully recovered save file.", functions=(lambda:open_folder_standard_exporer(folder_path), donothing), buttons=True, button_names=("Open", "Cancel"))
popup("Succesfully recovered save file.\nImport now?", functions=(lambda:import_save_menu(directory=folder_path + ext()), donothing), buttons=True, button_names=("Yes", "No"))
except FileNotFoundError as e:
popup(e)

Expand All @@ -1976,6 +1976,25 @@ def pop_up(txt, bold=True):
y = win.winfo_y()
pwin.geometry("+%d+%d" % (x + 200, y + 200))

def delete_entry(directory):

def delete(directory):
delete_folder(directory)
selected_index = lb1.curselection()
if selected_index:
lb1.delete(selected_index)
win.update()

def dont_delete():
pass

popup("Are you sure?", parent_window=win, functions=(lambda:delete(directory),dont_delete), buttons=True)

def delete_all():
folder_path = "./data/archive/"
shutil.rmtree(folder_path)
os.makedirs(folder_path)
lb1.delete(0,END)

win = Toplevel(root)
win.title("Recovery")
Expand All @@ -1995,15 +2014,16 @@ def pop_up(txt, bold=True):
helpmenu.add_command(
label="Readme",
command=lambda: pop_up(
"""\u2022 This tool recovers ruined save files in case of user error.\n
"""\u2022 This tool recovers save files in case of user error.\n
\u2022 Every time you modify/create/delete a save file, before the action is performed, a copy is created, compressed and stored in data/archive.\n
\u2022 The original file size of 28mb is compressed to 2mb. To recover a file, simply select a file and click Restore.\n
\u2022 Restored save files are in the data/recovered directory.\n
\u2022 Right-click on a save in the listbox to get additional file info.
"""
),
)
menubar.add_cascade(label="Help", menu=helpmenu)
helpmenu.add_command(label="Delete All", command=lambda:popup(text="Are you sure?", buttons=True, functions=(delete_all, donothing)))
menubar.add_cascade(label="File", menu=helpmenu)



Expand All @@ -2022,6 +2042,8 @@ def pop_up(txt, bold=True):
rt_click_menu = Menu(lb1, tearoff=0)
rt_click_menu.add_command(label="Get Info", command=lambda:grab_metadata(f"./data/archive/{fetch_listbox_entry(lb1)[1].strip()}/info.txt" ) )

rt_click_menu.add_command(label="Delete", command=lambda:delete_entry
(f"./data/archive/{fetch_listbox_entry(lb1)[1].strip().replace(' ', '__').replace(':', '.')}/"))
lb1.bind("<Button-3>", do_popup)


Expand Down Expand Up @@ -2235,12 +2257,15 @@ def validate(P):
but_cancel.grid(row=2, column=0, padx=(70, 0), pady=(0, 15))


def import_save_menu():
def import_save_menu(directory=False):
"""Opens file explorer to choose a save file to import, Then checks if the files steam ID matches users, and replaces it with users id"""

if os.path.isdir(savedir) is False:
os.makedirs(savedir)
d = fd.askopenfilename()
if directory:
d = directory
else:
d = fd.askopenfilename()

if len(d) < 1:
return
Expand Down
6 changes: 5 additions & 1 deletion data/changelog.txt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
New cheat to set amount of held runes
-- Improvements to File Recovery tool
-- various small improvements
-- Added more items to inventory editor
I have spent hundreds of hours invested in this project with over 8,000 lines of code written
If you enjoy the app and want to support future updates, PLEASE donate! Even $1 is appreciated!
Loading

0 comments on commit 548213d

Please sign in to comment.