Skip to content

Commit

Permalink
Merge pull request #12 from jozz024/copy-values-button
Browse files Browse the repository at this point in the history
  • Loading branch information
jozz024 authored Jan 26, 2023
2 parents ae05e7a + 356c6f5 commit 223d329
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
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

0 comments on commit 223d329

Please sign in to comment.