Compare commits

..

13 Commits

Author SHA1 Message Date
6794672c97 update for new version (doesn't really matter though) 2021-11-06 15:20:27 +00:00
d2c3269eba bump wasm-bindgen 2021-07-08 18:40:55 +01:00
215af194c8 remove unnecessary comment 2021-07-08 18:38:28 +01:00
0b82495451 separate build and deploy stages 2021-07-08 11:07:24 +01:00
c1d39023f8 add itch cover 2021-07-08 11:06:33 +01:00
ecd117afea 7.5 update 2021-07-08 11:06:07 +01:00
cbe3a33311 error/success handling (user feedback) 2020-08-23 16:36:27 +01:00
3903e4e6be no favicon (avoid 404) 2020-08-23 12:36:46 +01:00
0e0c4a4a73 tidy up build script 2020-08-23 12:36:00 +01:00
eff32a6540 package info and version bump 2020-08-23 12:19:44 +01:00
1c1d183dbe woo! application state! 2020-08-23 12:19:20 +01:00
73074c8b75 newline at eof 2020-07-26 12:55:02 +01:00
13e4821fbc readme 2020-07-26 12:54:53 +01:00
9 changed files with 126 additions and 31 deletions

View File

@@ -1,8 +1,11 @@
[package]
name = "bitsy-merge"
version = "0.71.0"
name = "mixsy"
description = "combine Bitsy games"
version = "0.710.0"
authors = ["Max Bradbury <max@tinybird.info>"]
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
@@ -10,5 +13,6 @@ edition = "2018"
crate-type = ["cdylib"]
[dependencies]
"bitsy-parser" = "^0.71.1"
"wasm-bindgen" = "^0.2.64"
"bitsy-parser" = "^0.710.0"
"lazy_static" = "^1.4.0"
"wasm-bindgen" = "^0.2.78"

View File

@@ -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

View File

@@ -1,5 +1,5 @@
#!/bin/sh
#!/usr/bin/env bash
cargo build
pug index.pug
set -ex
wasm-pack build --target web

View File

@@ -1,6 +1,4 @@
#!/bin/sh
./build.sh
zip -r mixsy.zip README.md index.html merge.png pkg
butler push mixsy.zip ruin/mixsy:html

View File

@@ -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() {
await init();
document.getElementById('merge').addEventListener('click', () => {
let a = document.getElementById('a').value;
let b = document.getElementById('b').value;
document.getElementById('c').value = merge(a, b);
})
const main = document.getElementById('a');
const additional = document.getElementById('b');
const output = document.getElementById('c');
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();

View File

@@ -3,6 +3,8 @@ html(lang="en-gb")
head
meta(content="text/html;charset=utf-8" http-equiv="Content-Type")
title mixsy
//- no favicon!! taken from: https://k1ss.org/blog/20191004a
<link href=data:, rel=icon>
style
include style.css
body
@@ -13,9 +15,11 @@ html(lang="en-gb")
#main.square.left
h2 main
textarea#a(placeholder="Paste your main game data here...")
p.result
#additional.square.left
h2 additional
textarea#b(placeholder="Paste additional game data here...")
p.result
.row.middle
img.centre(src="merge.png" alt="")
button#merge.centre mix!
@@ -23,6 +27,5 @@ html(lang="en-gb")
.square.centre
h2 output
textarea#c
//- Note the usage of `type=module` here as this is an ES6 module -->
script(type="module")
include index.js

BIN
mixsy-cover.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,21 +1,55 @@
use wasm_bindgen::prelude::*;
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]
pub fn merge(a: String, b: String) -> String {
let main = Game::from(a);
let additional = Game::from(b);
pub fn load_main(game_data: String) -> String {
let result = Game::from(game_data);
if main.is_err() {
return "Couldn't parse main game.".to_string();
if result.is_ok() {
let (game, _errors) = result.unwrap();
STATE.lock().unwrap().main = Some(game);
"OK!"
} else {
"Could not parse game data"
}.to_string()
}
#[wasm_bindgen]
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()
}
#[wasm_bindgen]
pub fn merge() -> String {
let state = STATE.lock().unwrap();
if state.main.is_none() || state.additional.is_none() {
return "".to_string();
}
if additional.is_err() {
return "Couldn't parse additional game.".to_string();
}
let mut main = main.unwrap();
let additional = additional.unwrap();
let mut main = state.main.clone().unwrap();
let additional = state.additional.as_ref().unwrap();
main.merge(additional);
main.dedupe_tiles();

View File

@@ -72,6 +72,12 @@ textarea {
float: left;
}
.result {
position: relative;
background: var(--bg);
color: var(--inverse);
}
.row {
width: 100%;
height: calc(82vmin / 3);