Merged the two create functions
This commit is contained in:
parent
eada155375
commit
4f4091ebb3
|
@ -48,7 +48,7 @@ const Dialogue = (() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
//track google event
|
//track google event
|
||||||
if (trackEvent)
|
if (trackEvent && typeof ga !== 'undefined')
|
||||||
ga('send', 'event', 'Palette Editor Dialogue', dialogueName); /*global ga*/
|
ga('send', 'event', 'Palette Editor Dialogue', dialogueName); /*global ga*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,7 @@ function create(isSplash) {
|
||||||
var width = Util.getValue('size-width' + splashPostfix);
|
var width = Util.getValue('size-width' + splashPostfix);
|
||||||
var height = Util.getValue('size-height' + splashPostfix);
|
var height = Util.getValue('size-height' + splashPostfix);
|
||||||
|
|
||||||
// If I'm creating from the splash screen, I use the splashMode variable
|
newPixel(width, height);
|
||||||
var mode = isSplash ? splashMode : pixelEditorMode;
|
|
||||||
|
|
||||||
newPixel(width, height, mode);
|
|
||||||
|
|
||||||
// If I'm not creating from the splash page, then this is not the first project I've created
|
// If I'm not creating from the splash page, then this is not the first project I've created
|
||||||
if (!isSplash)
|
if (!isSplash)
|
||||||
|
@ -23,8 +20,8 @@ function create(isSplash) {
|
||||||
selectedPalette = 'none';
|
selectedPalette = 'none';
|
||||||
|
|
||||||
//track google event
|
//track google event
|
||||||
ga('send', 'event', 'Pixel Editor New', selectedPalette, width+'/'+height); /*global ga*/
|
if (typeof ga !== 'undefined')
|
||||||
|
ga('send', 'event', 'Pixel Editor New', selectedPalette, width+'/'+height); /*global ga*/
|
||||||
|
|
||||||
//reset new form
|
//reset new form
|
||||||
Util.setValue('size-width', 64);
|
Util.setValue('size-width', 64);
|
||||||
|
@ -37,63 +34,9 @@ function create(isSplash) {
|
||||||
/** Triggered when the "Create" button in the new pixel dialogue is pressed
|
/** Triggered when the "Create" button in the new pixel dialogue is pressed
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Input.on('click', 'create-button', function (){
|
Input.on('click', 'create-button', create, false);
|
||||||
// Getting the values of the form
|
|
||||||
var width = Util.getValue('size-width');
|
|
||||||
var height = Util.getValue('size-height');
|
|
||||||
|
|
||||||
// Creating a new pixel with those properties
|
|
||||||
if(pixelEditorMode == "Basic")
|
|
||||||
newPixel(width, height, "Advanced");
|
|
||||||
else
|
|
||||||
newPixel(width, height, "Basic");
|
|
||||||
document.getElementById('new-pixel-warning').style.display = 'block';
|
|
||||||
|
|
||||||
//get selected palette name
|
|
||||||
var selectedPalette = Util.getText('palette-button');
|
|
||||||
if (selectedPalette == 'Choose a palette...')
|
|
||||||
selectedPalette = 'none';
|
|
||||||
|
|
||||||
//track google event
|
|
||||||
ga('send', 'event', 'Pixel Editor New', selectedPalette, width+'/'+height); /*global ga*/
|
|
||||||
|
|
||||||
|
|
||||||
//reset new form
|
|
||||||
Util.setValue('size-width', 64);
|
|
||||||
Util.setValue('size-height', 64);
|
|
||||||
|
|
||||||
Util.setText('palette-button', 'Choose a palette...');
|
|
||||||
Util.setText('preset-button', 'Choose a preset...');
|
|
||||||
});
|
|
||||||
|
|
||||||
/** Triggered when the "Create" button in the splash page is pressed
|
/** Triggered when the "Create" button in the splash page is pressed
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Input.on('click', 'create-button-splash', function (){
|
Input.on('click', 'create-button-splash', create, true);
|
||||||
// Getting the values of the form
|
|
||||||
var width = Util.getValue('size-width-splash');
|
|
||||||
var height = Util.getValue('size-height-splash');
|
|
||||||
var mode = pixelEditorMode;
|
|
||||||
|
|
||||||
if (mode == 'Advanced')
|
|
||||||
mode = "Basic";
|
|
||||||
else
|
|
||||||
mode = "Advanced";
|
|
||||||
|
|
||||||
// Creating a new pixel with those properties
|
|
||||||
newPixel(width, height, mode);
|
|
||||||
|
|
||||||
//track google event
|
|
||||||
ga('send', 'event', 'Pixel Editor New', selectedPalette, width+'/'+height); /*global ga*/
|
|
||||||
document.getElementById('new-pixel-warning').style.display = 'block';
|
|
||||||
|
|
||||||
// Resetting the new pixel values
|
|
||||||
selectedPalette = 'none';
|
|
||||||
|
|
||||||
//reset new pixel form
|
|
||||||
Util.setValue('size-width-splash', 64);
|
|
||||||
Util.setValue('size-height-splash', 64);
|
|
||||||
|
|
||||||
Util.setText('palette-button', 'Choose a palette...');
|
|
||||||
Util.setText('preset-button', 'Choose a preset...');
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
var pixelEditorMode = "Basic";
|
||||||
|
switchMode(pixelEditorMode);
|
||||||
|
|
||||||
let modes = {
|
let modes = {
|
||||||
'Basic' : {
|
'Basic' : {
|
||||||
description: 'Basic mode is perfect if you want to create simple sprites or try out palettes.'
|
description: 'Basic mode is perfect if you want to create simple sprites or try out palettes.'
|
||||||
|
@ -13,7 +16,7 @@ Input.on('click', 'switch-editor-mode-splash', function (e) {
|
||||||
|
|
||||||
function switchMode(newMode) {
|
function switchMode(newMode) {
|
||||||
//switch to advanced mode
|
//switch to advanced mode
|
||||||
if (newMode == 'Advanced') {
|
if (newMode == 'Advanced' && pixelEditorMode == 'Basic') {
|
||||||
// Switch to advanced ez pez lemon squez
|
// Switch to advanced ez pez lemon squez
|
||||||
document.getElementById('switch-mode-button').innerHTML = 'Switch to basic mode';
|
document.getElementById('switch-mode-button').innerHTML = 'Switch to basic mode';
|
||||||
// Show the layer menus
|
// Show the layer menus
|
||||||
|
@ -64,8 +67,6 @@ function switchMode(newMode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleMode() {
|
function toggleMode() {
|
||||||
console.log("From " + pixelEditorMode);
|
|
||||||
|
|
||||||
if (pixelEditorMode == 'Advanced')
|
if (pixelEditorMode == 'Advanced')
|
||||||
switchMode('Basic');
|
switchMode('Basic');
|
||||||
else
|
else
|
||||||
|
|
|
@ -49,7 +49,8 @@ for (var i = 1; i < mainMenuItems.length; i++) {
|
||||||
linkHolder.download = fileName;
|
linkHolder.download = fileName;
|
||||||
linkHolder.click();
|
linkHolder.click();
|
||||||
|
|
||||||
ga('send', 'event', 'Pixel Editor Save', selectedPalette, canvasSize[0]+'/'+canvasSize[1]); /*global ga*/
|
if (typeof ga !== 'undefined')
|
||||||
|
ga('send', 'event', 'Pixel Editor Save', selectedPalette, canvasSize[0]+'/'+canvasSize[1]); /*global ga*/
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'Open':
|
case 'Open':
|
||||||
|
@ -117,7 +118,8 @@ for (var i = 1; i < mainMenuItems.length; i++) {
|
||||||
exportCanvas.remove();
|
exportCanvas.remove();
|
||||||
|
|
||||||
//track google event
|
//track google event
|
||||||
ga('send', 'event', 'Pixel Editor Export', selectedPalette, canvasSize[0]+'/'+canvasSize[1]); /*global ga*/
|
if (typeof ga !== 'undefined')
|
||||||
|
ga('send', 'event', 'Pixel Editor Export', selectedPalette, canvasSize[0]+'/'+canvasSize[1]); /*global ga*/
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -38,7 +38,8 @@ document.getElementById('open-image-browse-holder').addEventListener('change', f
|
||||||
createPaletteFromLayers();
|
createPaletteFromLayers();
|
||||||
|
|
||||||
//track google event
|
//track google event
|
||||||
ga('send', 'event', 'Pixel Editor Load', colorPalette.length, this.width+'/'+this.height); /*global ga*/
|
if (typeof ga !== 'undefined')
|
||||||
|
ga('send', 'event', 'Pixel Editor Load', colorPalette.length, this.width+'/'+this.height); /*global ga*/
|
||||||
|
|
||||||
};
|
};
|
||||||
img.src = e.target.result;
|
img.src = e.target.result;
|
||||||
|
|
|
@ -4,13 +4,9 @@ let firstPixel = true;
|
||||||
*
|
*
|
||||||
* @param {*} width Start width of the canvas
|
* @param {*} width Start width of the canvas
|
||||||
* @param {*} height Start height of the canvas
|
* @param {*} height Start height of the canvas
|
||||||
* @param {*} editorMode The editor mode chosen by the user (advanced or basic)
|
|
||||||
* @param {*} fileContent If fileContent != null, then the newPixel is being called from the open menu
|
* @param {*} fileContent If fileContent != null, then the newPixel is being called from the open menu
|
||||||
*/
|
*/
|
||||||
function newPixel (width, height, editorMode, fileContent = null) {
|
function newPixel (width, height, fileContent = null) {
|
||||||
// Saving the editor mode
|
|
||||||
pixelEditorMode = editorMode;
|
|
||||||
|
|
||||||
// The palette is empty, at the beginning
|
// The palette is empty, at the beginning
|
||||||
ColorModule.currentPalette.length = 0;
|
ColorModule.currentPalette.length = 0;
|
||||||
|
|
||||||
|
@ -208,5 +204,5 @@ function newFromTemplate(preset, x, y) {
|
||||||
x = presetProperties.width;
|
x = presetProperties.width;
|
||||||
y = presetProperties.height;
|
y = presetProperties.height;
|
||||||
}
|
}
|
||||||
newPixel(x, y, pixelEditorMode == 'Advanced' ? 'Basic' : 'Advanced');
|
newPixel(x, y);
|
||||||
}
|
}
|
|
@ -4,7 +4,6 @@ var zoom = 7;
|
||||||
var dragging = false;
|
var dragging = false;
|
||||||
var lastMouseClickPos = [0,0];
|
var lastMouseClickPos = [0,0];
|
||||||
var documentCreated = false;
|
var documentCreated = false;
|
||||||
var pixelEditorMode = "Basic";
|
|
||||||
|
|
||||||
//common elements
|
//common elements
|
||||||
var brushPreview = document.getElementById("brush-preview");
|
var brushPreview = document.getElementById("brush-preview");
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/**utilities**/
|
/**utilities**/
|
||||||
//=include lib/cookies.js
|
//=include lib/cookies.js
|
||||||
|
//=include _jscolor.js
|
||||||
//=include _pixelEditorUtility.js
|
//=include _pixelEditorUtility.js
|
||||||
//=include lib/sortable.js
|
//=include lib/sortable.js
|
||||||
//=include Util.js
|
//=include Util.js
|
||||||
|
@ -14,7 +15,6 @@
|
||||||
//=include _settings.js
|
//=include _settings.js
|
||||||
|
|
||||||
/**dropdown formatting**/
|
/**dropdown formatting**/
|
||||||
//=include _editorMode.js
|
|
||||||
//=include _presets.js
|
//=include _presets.js
|
||||||
//=include _palettes.js
|
//=include _palettes.js
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@
|
||||||
//=include _colorPicker.js
|
//=include _colorPicker.js
|
||||||
//=include _paletteBlock.js
|
//=include _paletteBlock.js
|
||||||
//=include SplashPage.js
|
//=include SplashPage.js
|
||||||
|
//=include _editorMode.js
|
||||||
|
|
||||||
/**load file**/
|
/**load file**/
|
||||||
//=include _loadImage.js
|
//=include _loadImage.js
|
||||||
|
@ -60,9 +61,6 @@
|
||||||
//=include _onLoad.js
|
//=include _onLoad.js
|
||||||
//=include _onbeforeunload.js
|
//=include _onbeforeunload.js
|
||||||
|
|
||||||
/**libraries**/
|
|
||||||
//=include _jscolor.js
|
|
||||||
|
|
||||||
/**feature toggles**/
|
/**feature toggles**/
|
||||||
//=include _featureToggles.js
|
//=include _featureToggles.js
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue