don't change current palette when editing a different palette

This commit is contained in:
synth-ruiner 2017-12-24 20:36:39 +00:00
parent b27632b6a3
commit 002863b88a
2 changed files with 6 additions and 3 deletions

View File

@ -324,14 +324,18 @@ $(document).ready(function() {
// these inputs get added and removed from the DOM so the event handler needs to be on the document // these inputs get added and removed from the DOM so the event handler needs to be on the document
$(document).on('change', '#palette input', function() { $(document).on('change', '#palette input', function() {
var id = parseInt($(this).closest('.palette').find('input[name="id"]').val());
// if this is a colour input, update the palette // if this is a colour input, update the palette
if ($(this).attr('type') === 'color') { if ($(this).attr('type') === 'color') {
if (id === palette.id) {
palette[$(this).attr('name')] = hexToColour($(this).val()); palette[$(this).attr('name')] = hexToColour($(this).val());
} }
}
// if this is a radio button, pick this palette // if this is a radio button, pick this palette
if ($(this).attr('type') === 'radio') { if ($(this).attr('type') === 'radio') {
palette.id = parseInt( $(this).closest('.palette').find('input[name="id"]' ).val()); palette.id = id;
palette.background = hexToColour($(this).closest('.palette').find('input[name="background"]').val()); palette.background = hexToColour($(this).closest('.palette').find('input[name="background"]').val());
palette.tile = hexToColour($(this).closest('.palette').find('input[name="tile"]' ).val()); palette.tile = hexToColour($(this).closest('.palette').find('input[name="tile"]' ).val());
// sprite colour is not currently used // sprite colour is not currently used

View File

@ -41,7 +41,6 @@ if (src.match(/^(file|https)?:\/\/|^\/\//)) {
## known bugs ## known bugs
* keyup on game data input sets palette to pal 0 even if game data has not changed * keyup on game data input sets palette to pal 0 even if game data has not changed
* changing the colour of a different palette will change the current palette
## to do ## to do