summaryrefslogtreecommitdiff
path: root/WebInterface/wasm/webhogg/update.py
diff options
context:
space:
mode:
authornatrixaeria <janng@gmx.de>2019-06-01 02:26:39 +0200
committernatrixaeria <janng@gmx.de>2019-06-01 02:26:39 +0200
commitde3d86164acaa9aeb78f28e3201ff1a40b212f04 (patch)
tree6e66e0c053e346700f3a24fc2a182d6b08329d79 /WebInterface/wasm/webhogg/update.py
parente052a0da267ac8594f3b896573a204a739340e54 (diff)
Communicate from game logic to graphics
please run the 'run'-script every time before loading the page
Diffstat (limited to 'WebInterface/wasm/webhogg/update.py')
-rw-r--r--WebInterface/wasm/webhogg/update.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/WebInterface/wasm/webhogg/update.py b/WebInterface/wasm/webhogg/update.py
new file mode 100644
index 0000000..0a0171f
--- /dev/null
+++ b/WebInterface/wasm/webhogg/update.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+ISC = '//!IMPORTANT_STUFF'
+
+def rf(fn):
+ f = open(fn)
+ c = f.read()
+ f.close()
+ return c
+
+nc = rf('pkg/webhogg.js')
+m1 = rf('loader.js')
+m2 = rf('graphics.js')
+
+nc = nc.split('function init(module) {')[0].strip('\n')
+nc = nc.replace('export function ', 'function ')
+m1 = m1.split('//!IMPORTANT_STUFF')[-1]
+m2 = m2.split('//!IMPORTANT_STUFF')[-1]
+
+nc += '\n' * 2 + ISC
+
+m1 = nc + m1
+m2 = nc + m2
+
+with open('loader.js', 'w') as f:
+ f.write(m1)
+
+with open('graphics.js', 'w') as f:
+ f.write(m2)