Compare commits
3 Commits
game-data-
...
b157007ff3
| Author | SHA1 | Date | |
|---|---|---|---|
| b157007ff3 | |||
| 704f710047 | |||
| 5c4259d222 |
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "pixsy"
|
name = "pixsy"
|
||||||
version = "0.72.8"
|
version = "0.72.7"
|
||||||
description = "convert images to Bitsy rooms"
|
description = "convert images to Bitsy rooms"
|
||||||
authors = ["Max Bradbury <max@tinybird.info>"]
|
authors = ["Max Bradbury <max@tinybird.info>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
@page-background: #968eb5;
|
@page-background: #968eb5;
|
||||||
@accent: #ec6d7d;
|
@accent: #ec6d7d;
|
||||||
@text: #464256;
|
@text: #464256;
|
||||||
@ok: #caec6d;
|
|
||||||
|
|
||||||
* {
|
* {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@@ -132,13 +131,3 @@ textarea {
|
|||||||
image-rendering: pixelated;
|
image-rendering: pixelated;
|
||||||
image-rendering: crisp-edges;
|
image-rendering: crisp-edges;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message {
|
|
||||||
background-color: @ok;
|
|
||||||
padding: 1em;
|
|
||||||
text-align: left;
|
|
||||||
|
|
||||||
&#game-data-errors {
|
|
||||||
background-color: @accent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
25
index.pug
25
index.pug
@@ -12,7 +12,7 @@ html(lang="en-gb")
|
|||||||
| pixsy
|
| pixsy
|
||||||
//img(alt="pixsy" src="includes/pixsy.png")
|
//img(alt="pixsy" src="includes/pixsy.png")
|
||||||
p.
|
p.
|
||||||
convert images to Bitsy rooms
|
version 0.72.7
|
||||||
|
|
|
|
||||||
#[a(href="http://tinybird.info/image-to-bitsy/old/" target="_blank") old version]
|
#[a(href="http://tinybird.info/image-to-bitsy/old/" target="_blank") old version]
|
||||||
|
|
|
|
||||||
@@ -21,12 +21,30 @@ html(lang="en-gb")
|
|||||||
#[a(href="https://twitter.com/synth_ruiner") twitter]
|
#[a(href="https://twitter.com/synth_ruiner") twitter]
|
||||||
.pages
|
.pages
|
||||||
.page#start
|
.page#start
|
||||||
|
p.
|
||||||
|
#[b pixsy] is a tool for #[a(href="http://bitsy.org/") Bitsy Game Maker]
|
||||||
|
that allows you to generate a room from an image and add it to your game.
|
||||||
|
p this version is compatible with Bitsy version 7.2 and earlier.
|
||||||
|
p.
|
||||||
|
#[b pixsy] does not currently work via the Itch desktop program.
|
||||||
|
some users are also currently reporting problems.
|
||||||
|
if pixsy does not work for you, please try the
|
||||||
|
#[a(href="http://tinybird.info/image-to-bitsy/old/") old version] instead.
|
||||||
|
p.
|
||||||
|
instructions can be found on the
|
||||||
|
#[a(href="https://ruin.itch.io/pixsy/") itch.io page] -
|
||||||
|
scroll down to "how to use".
|
||||||
|
|
||||||
button.normal.pagination.next#new create a new bitsy game
|
button.normal.pagination.next#new create a new bitsy game
|
||||||
button.normal.pagination.next#load load an existing bitsy game
|
button.normal.pagination.next#load load an existing bitsy game
|
||||||
.page.game-data
|
.page.game-data
|
||||||
h2 game data
|
h2 game data
|
||||||
|
|
||||||
input#game(type="file" autocomplete="off")
|
p.
|
||||||
|
your game data is available from the #[i game data] window in bitsy,
|
||||||
|
under the #[i tools] dropdown.
|
||||||
|
|
||||||
|
input#game(type="file" accept=".bitsy,.txt" autocomplete="off")
|
||||||
br
|
br
|
||||||
|
|
||||||
textarea#game-data(
|
textarea#game-data(
|
||||||
@@ -34,9 +52,6 @@ html(lang="en-gb")
|
|||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
)
|
)
|
||||||
|
|
||||||
p#game-data-result.message(style="display: none;")
|
|
||||||
p#game-data-errors.message(style="display: none;")
|
|
||||||
|
|
||||||
button.pagination.prev previous
|
button.pagination.prev previous
|
||||||
button.pagination.next#game-data-next(disabled=true) next
|
button.pagination.next#game-data-next(disabled=true) next
|
||||||
.page.image#page-image
|
.page.image#page-image
|
||||||
|
|||||||
34
script.js
34
script.js
@@ -78,8 +78,6 @@ async function run() {
|
|||||||
const inputColourBackground = el("colour-background");
|
const inputColourBackground = el("colour-background");
|
||||||
const inputColourForeground = el("colour-foreground");
|
const inputColourForeground = el("colour-foreground");
|
||||||
const inputRoomName = el("room-name");
|
const inputRoomName = el("room-name");
|
||||||
const paragraphGameResult = el("game-data-result");
|
|
||||||
const paragraphGameErrors = el("game-data-errors");
|
|
||||||
const selectPalette = el("palette");
|
const selectPalette = el("palette");
|
||||||
const textareaGameDataInput = el("game-data");
|
const textareaGameDataInput = el("game-data");
|
||||||
const textareaGameDataOutput = el("output");
|
const textareaGameDataOutput = el("output");
|
||||||
@@ -128,6 +126,7 @@ async function run() {
|
|||||||
el("game").addEventListener("change", function() {
|
el("game").addEventListener("change", function() {
|
||||||
readFile(this, function (e) {
|
readFile(this, function (e) {
|
||||||
textareaGameDataInput.value = e.target.result;
|
textareaGameDataInput.value = e.target.result;
|
||||||
|
console.log(load_game(e.target.result));
|
||||||
checkGameData();
|
checkGameData();
|
||||||
}, "text");
|
}, "text");
|
||||||
});
|
});
|
||||||
@@ -154,39 +153,16 @@ async function run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function checkGameData() {
|
function checkGameData() {
|
||||||
paragraphGameResult.style.display = "none";
|
if (textareaGameDataInput.value.length > 0) {
|
||||||
paragraphGameErrors.style.display = "none";
|
|
||||||
|
|
||||||
let game_data = textareaGameDataInput.value;
|
|
||||||
|
|
||||||
if (game_data.length === 0) {
|
|
||||||
buttonGameDataProceed.setAttribute("disabled", "disabled");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = load_game(game_data);
|
|
||||||
console.debug(result);
|
|
||||||
let parts = result.split(". Errors: ");
|
|
||||||
result = parts[0];
|
|
||||||
let errors = parts[1];
|
|
||||||
|
|
||||||
paragraphGameResult.innerText = result;
|
|
||||||
paragraphGameResult.style.display = "block";
|
|
||||||
|
|
||||||
if (errors) {
|
|
||||||
paragraphGameErrors.innerText = errors;
|
|
||||||
paragraphGameErrors.style.display = "block";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.startsWith("Error")) {
|
|
||||||
buttonGameDataProceed.setAttribute("disabled", "disabled");
|
|
||||||
} else {
|
|
||||||
buttonGameDataProceed.removeAttribute("disabled");
|
buttonGameDataProceed.removeAttribute("disabled");
|
||||||
setPaletteDropdown();
|
setPaletteDropdown();
|
||||||
|
} else {
|
||||||
|
buttonGameDataProceed.setAttribute("disabled", "disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
textareaGameDataInput.addEventListener("change", checkGameData);
|
textareaGameDataInput.addEventListener("change", checkGameData);
|
||||||
|
textareaGameDataInput.addEventListener("keyup", checkGameData);
|
||||||
checkGameData();
|
checkGameData();
|
||||||
|
|
||||||
el('image').addEventListener('change', function () {
|
el('image').addEventListener('change', function () {
|
||||||
|
|||||||
45
src/lib.rs
45
src/lib.rs
@@ -76,21 +76,16 @@ pub fn load_game(game_data: String) -> String {
|
|||||||
let result = Game::from(game_data);
|
let result = Game::from(game_data);
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok((game, errors)) => {
|
Ok((game, _errs)) => {
|
||||||
let palette_id = game.palette_ids()[0].clone();
|
let palette_id = game.palette_ids()[0].clone();
|
||||||
let game_name = game.name.clone();
|
|
||||||
let errors: Vec<String> = errors.iter().map(|err| format!("{}", err)).collect();
|
|
||||||
|
|
||||||
state.game = Some(game);
|
state.game = Some(game);
|
||||||
state.palette = SelectedPalette::Existing { id: palette_id };
|
state.palette = SelectedPalette::Existing { id: palette_id };
|
||||||
|
format!("Loaded game")
|
||||||
format!("Loaded game: {}. Errors: {}", game_name, errors.join(", "))
|
},
|
||||||
}
|
|
||||||
_ => {
|
_ => {
|
||||||
state.game = None;
|
state.game = None;
|
||||||
state.palette = SelectedPalette::None;
|
state.palette = SelectedPalette::None;
|
||||||
|
format!("{}", result.err().unwrap())
|
||||||
format!("Error: {}", result.err().unwrap())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,20 +167,18 @@ pub fn get_palettes() -> String {
|
|||||||
|
|
||||||
let mut palette_objects = json::JsonValue::new_array();
|
let mut palette_objects = json::JsonValue::new_array();
|
||||||
|
|
||||||
if state.game.is_some() {
|
for palette in &state.game.as_ref().unwrap().palettes {
|
||||||
for palette in &state.game.as_ref().unwrap().palettes {
|
let mut object = json::JsonValue::new_object();
|
||||||
let mut object = json::JsonValue::new_object();
|
|
||||||
|
|
||||||
object.insert("id", palette.id.clone()).unwrap();
|
object.insert("id", palette.id.clone()).unwrap();
|
||||||
|
|
||||||
object.insert(
|
object.insert(
|
||||||
"name",
|
"name",
|
||||||
palette.name.clone().unwrap_or(
|
palette.name.clone().unwrap_or(
|
||||||
format!("Palette {}", palette.id))
|
format!("Palette {}", palette.id))
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
palette_objects.push(object).unwrap();
|
palette_objects.push(object).unwrap();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
json::stringify(palette_objects)
|
json::stringify(palette_objects)
|
||||||
@@ -399,16 +392,4 @@ mod test {
|
|||||||
// todo what? why are extraneous pixels appearing in the output tiles?
|
// todo what? why are extraneous pixels appearing in the output tiles?
|
||||||
assert_eq!(output(), include_str!("test-resources/expected.bitsy"));
|
assert_eq!(output(), include_str!("test-resources/expected.bitsy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn palettes() {
|
|
||||||
load_default_game();
|
|
||||||
|
|
||||||
assert_eq!(crate::get_palettes(), "[{\"id\":\"0\",\"name\":\"blueprint\"}]");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn no_palettes() {
|
|
||||||
assert_eq!(crate::get_palettes(), "[]");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user