diff --git a/game_core/Trunk.toml b/game_core/Trunk.toml index 017deba46e45114dc9f62b87a65ab65ef6c6b168..f9b98e0d8f68883b4623b0b6056d4d0578562bb8 100644 --- a/game_core/Trunk.toml +++ b/game_core/Trunk.toml @@ -1,2 +1,7 @@ [build] -public_url = "./" \ No newline at end of file +public_url = "/" + +[[hooks]] +stage = "post_build" +command = "sh" +command_arguments = ["-c", "flit -i $TRUNK_STAGING_DIR/index.html -f $TRUNK_SOURCE_DIR/flit.toml --inline"] \ No newline at end of file diff --git a/game_core/flit.toml b/game_core/flit.toml new file mode 100644 index 0000000000000000000000000000000000000000..69ecdeab01f076334dce91f3cc77c3098ffcd9e5 --- /dev/null +++ b/game_core/flit.toml @@ -0,0 +1,21 @@ +["script[type='module']"] +action = "wrap" +template =''' +<div id="root"> + <button id="start_game">Start Game</button> +</div> +<script> +document.addEventListener('DOMContentLoaded', () => { + document.getElementById('start_game').addEventListener('click', function() { + let element = document.createElement('{{{TAG}}}'); + let attr_string = `{{{ATTR}}}` + attr_string.split(' ').forEach(function(attr) { + let attr_array = attr.split('='); + element.setAttribute(attr_array[0], attr_array[1].slice(1, -1)); + }); + element.innerHTML = `{{{CONTENT}}}`; + document.body.appendChild(element); + + }); +}); +</script>''' \ No newline at end of file