Implement loading a palette from the menu.
This commit is contained in:
parent
c08c7f2d0b
commit
a36281935b
|
@ -388,10 +388,12 @@ const ColorModule = (() => {
|
||||||
*
|
*
|
||||||
* @param {*} paletteColors The colours of the palette
|
* @param {*} paletteColors The colours of the palette
|
||||||
*/
|
*/
|
||||||
function createColorPalette(paletteColors) {
|
function createColorPalette(paletteColors, clearCurrent=true) {
|
||||||
//remove current palette
|
//remove current palette
|
||||||
while (colorsMenu.childElementCount > 1)
|
if (clearCurrent) {
|
||||||
colorsMenu.children[0].remove();
|
while (colorsMenu.childElementCount > 1)
|
||||||
|
colorsMenu.children[0].remove();
|
||||||
|
}
|
||||||
|
|
||||||
var lightestColor = new Color("hex", '#000000');
|
var lightestColor = new Color("hex", '#000000');
|
||||||
var darkestColor = new Color("hex", '#ffffff');
|
var darkestColor = new Color("hex", '#ffffff');
|
||||||
|
@ -527,4 +529,4 @@ const ColorModule = (() => {
|
||||||
updateCurrentColor,
|
updateCurrentColor,
|
||||||
getSelectedColor,
|
getSelectedColor,
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -293,6 +293,13 @@ const FileManager = (() => {
|
||||||
return JSON.stringify(dictionary);
|
return JSON.stringify(dictionary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let fromMenu = false;
|
||||||
|
|
||||||
|
function openImportPaletteWindow() {
|
||||||
|
fromMenu = true;
|
||||||
|
document.getElementById('load-palette-browse-holder').click();
|
||||||
|
}
|
||||||
|
|
||||||
function loadPalette() {
|
function loadPalette() {
|
||||||
if (browsePaletteHolder.files && browsePaletteHolder.files[0]) {
|
if (browsePaletteHolder.files && browsePaletteHolder.files[0]) {
|
||||||
let file = browsePaletteHolder.files[0];
|
let file = browsePaletteHolder.files[0];
|
||||||
|
@ -326,12 +333,17 @@ const FileManager = (() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addPalette(colors) {
|
function addPalette(colors) {
|
||||||
//add to palettes so that it can be loaded when they click okay
|
if (fromMenu) {
|
||||||
palettes['Loaded palette'] = {};
|
ColorModule.createColorPalette(colors, clearCurrent=false);
|
||||||
palettes['Loaded palette'].colors = colors;
|
} else {
|
||||||
Util.setText('palette-button', 'Loaded palette');
|
// From splash screen
|
||||||
Util.setText('palette-button-splash', 'Loaded palette');
|
// add to palettes so that it can be loaded when they click okay
|
||||||
Util.toggle('palette-menu-splash');
|
palettes['Loaded palette'] = {};
|
||||||
|
palettes['Loaded palette'].colors = colors;
|
||||||
|
Util.setText('palette-button', 'Loaded palette');
|
||||||
|
Util.setText('palette-button-splash', 'Loaded palette');
|
||||||
|
Util.toggle('palette-menu-splash');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadPaletteFromImage(e) {
|
function loadPaletteFromImage(e) {
|
||||||
|
@ -587,6 +599,7 @@ const FileManager = (() => {
|
||||||
openPixelExportWindow,
|
openPixelExportWindow,
|
||||||
openSaveProjectWindow,
|
openSaveProjectWindow,
|
||||||
openImportImageWindow,
|
openImportImageWindow,
|
||||||
|
openImportPaletteWindow,
|
||||||
open
|
open
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,9 @@ const TopMenuModule = (() => {
|
||||||
case 'Import':
|
case 'Import':
|
||||||
Events.on('click', currSubmenuButton, FileManager.openImportImageWindow);
|
Events.on('click', currSubmenuButton, FileManager.openImportImageWindow);
|
||||||
break;
|
break;
|
||||||
|
case 'Load palette':
|
||||||
|
Events.on('click', currSubmenuButton, FileManager.openImportPaletteWindow);
|
||||||
|
break;
|
||||||
case 'Export':
|
case 'Export':
|
||||||
Events.on('click', currSubmenuButton, FileManager.openPixelExportWindow);
|
Events.on('click', currSubmenuButton, FileManager.openPixelExportWindow);
|
||||||
break;
|
break;
|
||||||
|
@ -139,4 +142,4 @@ const TopMenuModule = (() => {
|
||||||
addInfoElement,
|
addInfoElement,
|
||||||
resetInfos
|
resetInfos
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
<li><button>Save project</button></li>
|
<li><button>Save project</button></li>
|
||||||
<li><button>Open</button></li>
|
<li><button>Open</button></li>
|
||||||
<li><button>Import</button></li>
|
<li><button>Import</button></li>
|
||||||
|
<li><button>Load palette</button></li>
|
||||||
<li><button id="export-button" class="disabled">Export</button></li>
|
<li><button id="export-button" class="disabled">Export</button></li>
|
||||||
<li><a href="https://lospec.com/pixel-editor">Exit</a></li>
|
<li><a href="https://lospec.com/pixel-editor">Exit</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -74,4 +75,4 @@
|
||||||
<li>{{> checkbox}}</li>
|
<li>{{> checkbox}}</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in New Issue