Compare commits
13 Commits
b68cc873d5
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 6794672c97 | |||
| d2c3269eba | |||
| 215af194c8 | |||
| 0b82495451 | |||
| c1d39023f8 | |||
| ecd117afea | |||
| cbe3a33311 | |||
| 3903e4e6be | |||
| 0e0c4a4a73 | |||
| eff32a6540 | |||
| 1c1d183dbe | |||
| 73074c8b75 | |||
| 13e4821fbc |
12
Cargo.toml
12
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,5 +13,6 @@ edition = "2018"
|
|||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
"bitsy-parser" = "^0.71.1"
|
"bitsy-parser" = "^0.710.0"
|
||||||
"wasm-bindgen" = "^0.2.64"
|
"lazy_static" = "^1.4.0"
|
||||||
|
"wasm-bindgen" = "^0.2.78"
|
||||||
|
|||||||
28
README.md
28
README.md
@@ -1,3 +1,27 @@
|
|||||||
# mixsy
|
# Mixsy
|
||||||
|
|
||||||
blah blah blah
|
A tool for combining Bitsy games.
|
||||||
|
|
||||||
|
Paste your game data into the main and additional inputs, and click _mix_!
|
||||||
|
|
||||||
|
All palettes, rooms, tiles, sprites, items, exits, endings, variables and dialogue
|
||||||
|
will be copied from the additional game to the main game.
|
||||||
|
Tiles will also be deduplicated, to avoid unnecessary extra tiles in your merged game.
|
||||||
|
The resulting merged game will appear in the output box.
|
||||||
|
You can copy and paste this back into Bitsy.
|
||||||
|
|
||||||
|
I'm fairly confident that Mixsy won't mangle your game data,
|
||||||
|
but I still recommend taking backups of your games periodically.
|
||||||
|
|
||||||
|
Mixsy requires WebAssembly, so if it doesn't work on your web browser
|
||||||
|
I suggest using [bitsy merge](https://seansleblanc.itch.io/bitsy-merge) instead.
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
|
||||||
|
A tool by Max Bradbury
|
||||||
|
|
||||||
|
Thanks to Adam Le Doux for Bitsy
|
||||||
|
|
||||||
|
Thanks to Freya for the colour palette (I love that watermelon and mint-choc-chip kinda thing)
|
||||||
|
|
||||||
|
Thanks to Candle, Sean and everyone in the Bitsy community
|
||||||
|
|||||||
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
|
||||||
|
|||||||
38
index.js
38
index.js
@@ -1,13 +1,39 @@
|
|||||||
import init, {merge} from './pkg/bitsy_merge.js';
|
import init, {load_main, load_additional, merge} from './pkg/mixsy.js';
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
await init();
|
await init();
|
||||||
|
|
||||||
document.getElementById('merge').addEventListener('click', () => {
|
const main = document.getElementById('a');
|
||||||
let a = document.getElementById('a').value;
|
const additional = document.getElementById('b');
|
||||||
let b = document.getElementById('b').value;
|
const output = document.getElementById('c');
|
||||||
document.getElementById('c').value = merge(a, b);
|
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', () => {
|
||||||
|
if (main.value) {
|
||||||
|
handleResult(main, load_main(main.value));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
additional.addEventListener('change', () => {
|
||||||
|
if (additional.value) {
|
||||||
|
handleResult(additional, load_additional(additional.value));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function mix() {
|
||||||
|
output.value = merge();
|
||||||
|
}
|
||||||
|
|
||||||
|
merge_button.addEventListener('click', mix);
|
||||||
|
merge_button.addEventListener('touchend', mix);
|
||||||
}
|
}
|
||||||
|
|
||||||
run();
|
run();
|
||||||
|
|||||||
@@ -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 |
54
src/lib.rs
54
src/lib.rs
@@ -1,21 +1,55 @@
|
|||||||
use wasm_bindgen::prelude::*;
|
|
||||||
use bitsy_parser::game::Game;
|
use bitsy_parser::game::Game;
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
use std::sync::Mutex;
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
|
struct State {
|
||||||
|
main: Option<Game>,
|
||||||
|
additional: Option<Game>,
|
||||||
|
}
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref STATE: Mutex<State> = Mutex::new(State { main: None, additional: None});
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO DEDUPE
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn merge(a: String, b: String) -> String {
|
pub fn load_main(game_data: String) -> String {
|
||||||
let main = Game::from(a);
|
let result = Game::from(game_data);
|
||||||
let additional = Game::from(b);
|
|
||||||
|
|
||||||
if main.is_err() {
|
if result.is_ok() {
|
||||||
return "Couldn't parse main game.".to_string();
|
let (game, _errors) = result.unwrap();
|
||||||
|
STATE.lock().unwrap().main = Some(game);
|
||||||
|
"OK!"
|
||||||
|
} else {
|
||||||
|
"Could not parse game data"
|
||||||
|
}.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
if additional.is_err() {
|
#[wasm_bindgen]
|
||||||
return "Couldn't parse additional game.".to_string();
|
pub fn load_additional(game_data: String) -> String {
|
||||||
|
let result = Game::from(game_data);
|
||||||
|
|
||||||
|
if result.is_ok() {
|
||||||
|
let (game, _errors) = result.unwrap();
|
||||||
|
STATE.lock().unwrap().additional = Some(game);
|
||||||
|
"OK!"
|
||||||
|
} else {
|
||||||
|
"Could not parse game data"
|
||||||
|
}.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut main = main.unwrap();
|
#[wasm_bindgen]
|
||||||
let additional = additional.unwrap();
|
pub fn merge() -> String {
|
||||||
|
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 additional = state.additional.as_ref().unwrap();
|
||||||
|
|
||||||
main.merge(additional);
|
main.merge(additional);
|
||||||
main.dedupe_tiles();
|
main.dedupe_tiles();
|
||||||
|
|||||||
Reference in New Issue
Block a user