don't change palette on game data update if not necessary

This commit is contained in:
synth-ruiner 2017-12-27 20:39:35 +00:00
parent 7d31e398c6
commit fdd869653a
2 changed files with 13 additions and 7 deletions

View File

@ -97,6 +97,8 @@ $(document).ready(function() {
bitsyData.palettes = {}; bitsyData.palettes = {};
// do palettes always go 0..n?
// will this cause problems if not?
_.each(palettes, function(palette, n) { _.each(palettes, function(palette, n) {
var thisPalette = {}; var thisPalette = {};
var name = ""; var name = "";
@ -156,8 +158,16 @@ $(document).ready(function() {
bitsyData.tiles[name] = newTile; bitsyData.tiles[name] = newTile;
}); });
if (_.find(bitsyData.palettes, {'id': palette.id})) {
// user has already selected a palette, leave it be
// if we just set the palette to the newly imported palette with the same ID,
// we will lose any changes the user has made to the palettes
// is this a big issue considering that the palettes cannot be currently saved anyway?
} else {
// set palette to first imported palette and redraw // set palette to first imported palette and redraw
palette = _.first(_.sortBy(bitsyData.palettes, 'id')); palette = _.first(_.sortBy(bitsyData.palettes, 'id'));
}
renderResult(); renderResult();
@ -179,7 +189,7 @@ $(document).ready(function() {
); );
}); });
$('tr.palette input[type="radio"]').eq(0).trigger('click'); $('input[name="id"][value="' + palette.id + '"]').siblings(':radio').trigger('click');
} }
function readFile(input) { function readFile(input) {

View File

@ -40,10 +40,6 @@ croppie.js:182 (mine)
if (src.match(/^(file|https)?:\/\/|^\/\//)) { if (src.match(/^(file|https)?:\/\/|^\/\//)) {
``` ```
## known bugs
* keyup on game data input sets palette to pal 0 even if game data has not changed
## to do ## to do
* allow user to save output as image, or tweet it :) *user can currently right-click -> Save As but the 128x128 size is not great* * allow user to save output as image, or tweet it :) *user can currently right-click -> Save As but the 128x128 size is not great*