Skip to content
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
13 changes: 8 additions & 5 deletions Other/Citra_mods/Citra_Mod_Manager.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,19 @@ FileActions(Root, Button)
Fullpath := Zielpfad "\" button.Ziel "\" button.Name
Checkdir := Zielpfad "\" button.Ziel
Quellpfad := button.Path
vCount :=0
dirHasItems := false
Loop, Files, %Checkdir%\*, DF ;Loop through items in dir
vCount++ ;Increment vCount for each item
If !vCount ;Is vCount empty?
{
dirHasItems := true ;Mark that we found at least one item
Break ;Optimization: Break after finding the first item
}
If !dirHasItems ;Is directory empty?
{
FileCopyDir, %Quellpfad%, %Fullpath%
MsgBox % "Copied " button.Name
}
Else ;Otherwise vCount is NOT empty...
MsgBox % "Dir has " vCount " item(s). Can't copy"
Else ;Otherwise directory is NOT empty...
MsgBox % "Dir is not empty. Can't copy"
}

GuiClose:
Expand Down
43 changes: 43 additions & 0 deletions optimize_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
file_path = "Other/Citra_mods/Citra_Mod_Manager.ahk"

with open(file_path, "r") as f:
lines = f.readlines()
Comment on lines +1 to +4
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

This looks like a one-off patching script (hardcoded target path, rewrites the file in-place) and isn’t referenced by the toolkit at runtime. If it’s not intended to be a maintained repo utility, consider removing it from the PR; otherwise, make it a proper tool (accept a path argument, avoid in-place writes or create a backup, and document its usage).

Copilot uses AI. Check for mistakes.

new_lines = []
skip_next = False
for i in range(len(lines)):
if skip_next:
skip_next = False
continue

line = lines[i]

# Check for the specific Loop line
if "Loop, Files, %Checkdir%\*, DF" in line:
# We found the loop line. We keep it, then insert the block.
new_lines.append(line)
# We need to construct the block.
# Original indentation of the Loop line is 8 spaces.
# So brace should be 8 spaces? Or standard is open brace on same line or next line at same indent?
# AHK style varies. Let's use:
# Loop...
# {
# vCount++
# Break
# }
new_lines.append(" {\n")
new_lines.append(" vCount++ ;Increment vCount for each item\n")
new_lines.append(" Break ;Optimization: Break after finding the first item\n")
new_lines.append(" }\n")

# The original code had the single statement on the next line.
# We need to skip it if it is indeed the vCount++ line.
if i + 1 < len(lines) and "vCount++" in lines[i+1]:
skip_next = True
elif 'MsgBox % "Dir has " vCount " item(s). Can\'t copy"' in line:
new_lines.append(' MsgBox % "Dir is not empty. Can\'t copy"\n')
else:
new_lines.append(line)

with open(file_path, "w") as f:
f.writelines(new_lines)
Loading