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

add the ability to copy the values of the current amiibo #12

Merged
merged 1 commit into from
Jan 26, 2023
Merged
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
38 changes: 35 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def get_menu_def(update_available: bool, amiibo_loaded: bool, ryujinx: bool = Fa
:return: tuple of menu
"""
if amiibo_loaded:
file_tab = ['&File', ['&Open (CTRL+O)', '&Save', 'Save &As (CTRL+S)', '---', '&View Hex']]
file_tab = ['&File', ['&Open (CTRL+O)', '&Save', 'Save &As (CTRL+S)', 'Copy &Values', '---', '&View Hex']]
if ryujinx:
file_tab = ['&File', ['&Open (CTRL+O)', '&Save', 'Save &As (CTRL+S)', '---', '!&View Hex']]
file_tab = ['&File', ['&Open (CTRL+O)', '&Save', 'Save &As (CTRL+S)', 'Copy &Values', '---', '!&View Hex']]
else:
file_tab = ['&File', ['&Open (CTRL+O)', '!&Save', '!Save &As (CTRL+S)', '---', '!&View Hex']]
file_tab = ['&File', ['&Open (CTRL+O)', '!&Save', '!Save &As (CTRL+S)', '!Copy &Values', '---', '!&View Hex']]
template_tab = ['&Template', ['&Create', '&Edit', '&Load (CTRL+L)']]

if update_available:
Expand Down Expand Up @@ -265,6 +265,38 @@ def main():
amiibo.save_bin(path)
else:
sg.popup("An amiibo has to be loaded before it can be saved.", title="Error")
elif event == "Copy Values":
output = ""
# Current index in the `values` dict, we use number keys for everything besides implicit sum.
idx = 1
# Iterate through the sections
for section in sections:
# Check if the section has the type of `ImplicitSum`
if type(section) == parse.ImplicitSum:
# If it does, we have to get the value by name
current_val = values[section.name]
# Add the section and current value to the output
output += f"{section}: {current_val}\n"
# Continue to the next section
continue

# Get the current value from the value
current_val = values[str(idx)]
# The `values` dict keeps copies of some float values in both str and float form, so we just use str
# Loop to check if the current value is a str
while type(current_val) != str:
# If it isn't, keep looking until you find one that is.
current_val = values[str(idx)]
idx +=1

# Add to the output.
output += f"{section}: {current_val}\n"
# Increment index
idx +=1

# Set the user's clipboard to the output after the loop finishes
sg.clipboard_set(output)

elif event == 'Select Regions':
# write regions path to file and reinstate window
regions = filedialog.askopenfilename(filetypes=(('Any Region', '*.json;*.txt'),))
Expand Down
3 changes: 3 additions & 0 deletions utils/region_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,9 @@ def __init__(self, name, description, counterparts):
self.primary_input_key = name
self.counterparts = counterparts

def __str__(self):
return self.name

def get_counterpart_signatures(self):
"""
gets all counterpart signatures to sum
Expand Down