Skip to content

Commit

Permalink
Tools: Fix children element positions for visual inspector
Browse files Browse the repository at this point in the history
Caused by malformed HTML conversion. Fixes a lot of overlapping.
  • Loading branch information
lah7 committed Feb 8, 2025
1 parent e7f5b3c commit 848c67b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
17 changes: 9 additions & 8 deletions tools/inspector_data/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ window.onload = function() {
element.setAttribute("title", element.getAttribute("tiptext"));
});

// Children should be nested inside the previous LEGACY element
document.querySelectorAll(".CHILDREN").forEach((children) => {
const parent = children.previousElementSibling;
children.querySelectorAll(".LEGACY").forEach((child) => {
parent.appendChild(child);
});
children.remove();
});
// CHILDREN should be nested into the previous LEGACY element
while (document.querySelectorAll(".CHILDREN").length > 0) {
let childElement = document.querySelector(".CHILDREN");
let parent = childElement.previousElementSibling;
while (childElement.children.length > 0) {
parent.appendChild(childElement.children[0]);
}
childElement.remove();
};
};
5 changes: 4 additions & 1 deletion tools/uiscript_inspector_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ def uiscript_to_html(orig: str) -> str:
output += line + "\n"

# Replace <LEGACY> and <CHILDREN> tags with <div>
output = re.sub(r'<(\w+)', r'<div class="\1"', output)
output = output.replace("<LEGACY", "<div class=\"LEGACY\"")
output = output.replace("<CHILDREN", "<div class=\"CHILDREN\"")
output = output.replace("</LEGACY>", "</div>")
output = output.replace("</CHILDREN>", "</div>")

# <LEGACY> tags didn't have closing tags, add one if not present
output = output.replace(" >", "></div>")
Expand Down

0 comments on commit 848c67b

Please sign in to comment.