Compare commits
10 Commits
1c1d183dbe
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 6794672c97 | |||
| d2c3269eba | |||
| 215af194c8 | |||
| 0b82495451 | |||
| c1d39023f8 | |||
| ecd117afea | |||
| cbe3a33311 | |||
| 3903e4e6be | |||
| 0e0c4a4a73 | |||
| eff32a6540 |
11
Cargo.toml
11
Cargo.toml
@@ -1,8 +1,11 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "bitsy-merge"
|
name = "mixsy"
|
||||||
version = "0.71.0"
|
description = "combine Bitsy games"
|
||||||
|
version = "0.710.0"
|
||||||
authors = ["Max Bradbury <max@tinybird.info>"]
|
authors = ["Max Bradbury <max@tinybird.info>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
license = "MIT"
|
||||||
|
repository = "https://tinybird.dev/max/mixsy"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
@@ -10,6 +13,6 @@ edition = "2018"
|
|||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
"bitsy-parser" = "^0.72.0"
|
"bitsy-parser" = "^0.710.0"
|
||||||
"lazy_static" = "^1.4.0"
|
"lazy_static" = "^1.4.0"
|
||||||
"wasm-bindgen" = "^0.2.64"
|
"wasm-bindgen" = "^0.2.78"
|
||||||
|
|||||||
4
build.sh
4
build.sh
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
cargo build
|
||||||
pug index.pug
|
pug index.pug
|
||||||
set -ex
|
|
||||||
wasm-pack build --target web
|
wasm-pack build --target web
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
./build.sh
|
|
||||||
|
|
||||||
zip -r mixsy.zip README.md index.html merge.png pkg
|
zip -r mixsy.zip README.md index.html merge.png pkg
|
||||||
butler push mixsy.zip ruin/mixsy:html
|
butler push mixsy.zip ruin/mixsy:html
|
||||||
|
|||||||
16
index.js
16
index.js
@@ -8,12 +8,24 @@ async function run() {
|
|||||||
const output = document.getElementById('c');
|
const output = document.getElementById('c');
|
||||||
const merge_button = document.getElementById('merge');
|
const merge_button = document.getElementById('merge');
|
||||||
|
|
||||||
|
function handleResult(inputElement, message) {
|
||||||
|
console.log(message);
|
||||||
|
let messageBox = inputElement.nextSibling;
|
||||||
|
messageBox.innerText = message;
|
||||||
|
messageBox.style.display = "block"
|
||||||
|
setTimeout(() => {messageBox.style.display = "none"}, 4000);
|
||||||
|
}
|
||||||
|
|
||||||
main.addEventListener('change', () => {
|
main.addEventListener('change', () => {
|
||||||
console.debug(load_main(main.value));
|
if (main.value) {
|
||||||
|
handleResult(main, load_main(main.value));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
additional.addEventListener('change', () => {
|
additional.addEventListener('change', () => {
|
||||||
console.debug(load_additional(additional.value));
|
if (additional.value) {
|
||||||
|
handleResult(additional, load_additional(additional.value));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function mix() {
|
function mix() {
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ html(lang="en-gb")
|
|||||||
head
|
head
|
||||||
meta(content="text/html;charset=utf-8" http-equiv="Content-Type")
|
meta(content="text/html;charset=utf-8" http-equiv="Content-Type")
|
||||||
title mixsy
|
title mixsy
|
||||||
|
//- no favicon!! taken from: https://k1ss.org/blog/20191004a
|
||||||
|
<link href=data:, rel=icon>
|
||||||
style
|
style
|
||||||
include style.css
|
include style.css
|
||||||
body
|
body
|
||||||
@@ -13,9 +15,11 @@ html(lang="en-gb")
|
|||||||
#main.square.left
|
#main.square.left
|
||||||
h2 main
|
h2 main
|
||||||
textarea#a(placeholder="Paste your main game data here...")
|
textarea#a(placeholder="Paste your main game data here...")
|
||||||
|
p.result
|
||||||
#additional.square.left
|
#additional.square.left
|
||||||
h2 additional
|
h2 additional
|
||||||
textarea#b(placeholder="Paste additional game data here...")
|
textarea#b(placeholder="Paste additional game data here...")
|
||||||
|
p.result
|
||||||
.row.middle
|
.row.middle
|
||||||
img.centre(src="merge.png" alt="")
|
img.centre(src="merge.png" alt="")
|
||||||
button#merge.centre mix!
|
button#merge.centre mix!
|
||||||
@@ -23,6 +27,5 @@ html(lang="en-gb")
|
|||||||
.square.centre
|
.square.centre
|
||||||
h2 output
|
h2 output
|
||||||
textarea#c
|
textarea#c
|
||||||
//- Note the usage of `type=module` here as this is an ES6 module -->
|
|
||||||
script(type="module")
|
script(type="module")
|
||||||
include index.js
|
include index.js
|
||||||
|
|||||||
BIN
mixsy-cover.png
Normal file
BIN
mixsy-cover.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
22
src/lib.rs
22
src/lib.rs
@@ -16,10 +16,11 @@ lazy_static! {
|
|||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn load_main(game_data: String) -> String {
|
pub fn load_main(game_data: String) -> String {
|
||||||
let game = Game::from(game_data);
|
let result = Game::from(game_data);
|
||||||
|
|
||||||
if game.is_ok() {
|
if result.is_ok() {
|
||||||
STATE.lock().unwrap().main = Some(game.unwrap());
|
let (game, _errors) = result.unwrap();
|
||||||
|
STATE.lock().unwrap().main = Some(game);
|
||||||
"OK!"
|
"OK!"
|
||||||
} else {
|
} else {
|
||||||
"Could not parse game data"
|
"Could not parse game data"
|
||||||
@@ -28,10 +29,11 @@ pub fn load_main(game_data: String) -> String {
|
|||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn load_additional(game_data: String) -> String {
|
pub fn load_additional(game_data: String) -> String {
|
||||||
let game = Game::from(game_data);
|
let result = Game::from(game_data);
|
||||||
|
|
||||||
if game.is_ok() {
|
if result.is_ok() {
|
||||||
STATE.lock().unwrap().additional = Some(game.unwrap());
|
let (game, _errors) = result.unwrap();
|
||||||
|
STATE.lock().unwrap().additional = Some(game);
|
||||||
"OK!"
|
"OK!"
|
||||||
} else {
|
} else {
|
||||||
"Could not parse game data"
|
"Could not parse game data"
|
||||||
@@ -41,8 +43,14 @@ pub fn load_additional(game_data: String) -> String {
|
|||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn merge() -> String {
|
pub fn merge() -> String {
|
||||||
let state = STATE.lock().unwrap();
|
let state = STATE.lock().unwrap();
|
||||||
|
|
||||||
|
if state.main.is_none() || state.additional.is_none() {
|
||||||
|
return "".to_string();
|
||||||
|
}
|
||||||
|
|
||||||
let mut main = state.main.clone().unwrap();
|
let mut main = state.main.clone().unwrap();
|
||||||
let additional = state.additional.clone().unwrap();
|
let additional = state.additional.as_ref().unwrap();
|
||||||
|
|
||||||
main.merge(additional);
|
main.merge(additional);
|
||||||
main.dedupe_tiles();
|
main.dedupe_tiles();
|
||||||
main.to_string()
|
main.to_string()
|
||||||
|
|||||||
@@ -72,6 +72,12 @@ textarea {
|
|||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.result {
|
||||||
|
position: relative;
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--inverse);
|
||||||
|
}
|
||||||
|
|
||||||
.row {
|
.row {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: calc(82vmin / 3);
|
height: calc(82vmin / 3);
|
||||||
@@ -81,4 +87,4 @@ textarea {
|
|||||||
width: 50vmin;
|
width: 50vmin;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user