From 7995ca9918cb9f9c51baed8257794122e506da00 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Thu, 13 Jun 2019 23:03:56 -0700 Subject: [PATCH] Render the DOM from the single atomic XML object --- experiments/modern/src/App.js | 59 +++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/experiments/modern/src/App.js b/experiments/modern/src/App.js index e5b1913c..c6b8ec57 100644 --- a/experiments/modern/src/App.js +++ b/experiments/modern/src/App.js @@ -14,6 +14,11 @@ const IGNORE_IDS = new Set([ "mask2", "mask3", "mask4", + "placeholder", // This looks like something related to an EQ window + "Scaler", + "toggle", + "presets", + "auto", // These need the maki script to get sized "volumethumb", "seekfull", @@ -52,16 +57,15 @@ async function getSkin() { break; } default: { - console.error(`Unknonw node ${node.name}`); + // console.error(`Unknown node ${node.name}`); } } return node; }); - const player = await Utils.readXml(zip, "xml/player-normal.xml"); // Gross hack returing a tuple here. We're just doing some crazy stuff to get // some data returned in the laziest way possible - return [player, images]; + return [skinXml, images]; } function Layout({ @@ -77,6 +81,11 @@ function Layout({ children, }) { const data = React.useContext(SkinContext); + if (background == null) { + console.warn("Got a Layouer without a background. Rendering null", id); + return null; + } + const image = data[background]; return ( <> @@ -99,7 +108,15 @@ function Layout({ function Layer({ id, image, children, x, y }) { const data = React.useContext(SkinContext); + if (image == null) { + console.warn("Got an Layer without an image. Rendering null", id); + return null; + } const img = data[image.toLowerCase()]; + if (img == null) { + console.warn("Unable to find image to render. Rendering null", image); + return null; + } return ( <> ( + + )); if (Component == null) { console.warn("Unknown node type", node.name); + if (childNodes.length) { + return <>{children}; + } return null; } - const childNodes = node.children || []; - return ( - - {childNodes.map((childNode, i) => ( - - ))} - - ); + return {children}; } function App() { @@ -191,10 +217,17 @@ function App() { if (data == null) { return

Loading...

; } - const [skin, images] = data; + const [skinXml, images] = data; return ( - + ); }