Finished binding events to splash page

Must write the log update and maybe find a way to randomize the splash images
This commit is contained in:
unsettledgames
2021-04-25 12:41:36 +02:00
parent 238eaf1783
commit 04afee2172
8 changed files with 901 additions and 29 deletions

View File

@ -75,27 +75,29 @@ on('click', 'create-button-splash', function (){
// Getting the values of the form
var width = getValue('size-width-splash');
var height = getValue('size-height-splash');
var mode = 'basic';
var mode = pixelEditorMode;
if (mode == 'Advanced')
mode = "Basic";
else
mode = "Advanced";
// Creating a new pixel with those properties
newPixel(width, height, mode);
document.getElementById('new-pixel-warning').style.display = 'block';
//get selected palette name
/*var selectedPalette = getText('palette-button');
if (selectedPalette == 'Choose a palette...') */
selectedPalette = 'none';
//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 form
//reset new pixel form
setValue('size-width-splash', 64);
setValue('size-height-splash', 64);
/*setValue("editor-mode", 'Advanced')
setValue("editor-mode", 'Advanced')
setText('editor-mode-button', 'Choose a mode...');
setText('palette-button', 'Choose a palette...');
setText('preset-button', 'Choose a preset...');*/
setText('preset-button', 'Choose a preset...');
});

View File

@ -8,12 +8,12 @@ let modes = {
}
let infoBox = document.getElementById('editor-mode-info');
let currentSplashButton;
let currentSplashButton = document.getElementById("sp-mode-palette").children[0].children[1];
function splashMode(mouseEvent, mode) {
console.log("UE");
if (currentSplashButton == undefined) {
currentSplashButton = mouseEvent.target;
return;
currentSplashButton = mouseEvent.target.parentElement;
}
if (mode !== pixelEditorMode) {
@ -21,10 +21,14 @@ function splashMode(mouseEvent, mode) {
// Remove selected class to old button
currentSplashButton.classList.remove("sp-interface-selected");
// Add selected class to new button
mouseEvent.target.classList.add("sp-interface-selected");
mouseEvent.target.parentElement.classList.add("sp-interface-selected");
// Setting the new mode
pixelEditorMode = mode;
}
currentSplashButton = mouseEvent.target;
// Setting the new selected button
currentSplashButton = mouseEvent.target.parentElement;
}
function switchMode(mustConfirm = true) {

View File

@ -196,9 +196,21 @@ function newPixel (width, height, editorMode, fileContent = null) {
// Applying the correct editor mode
if (pixelEditorMode == 'Basic') {
switchMode('Advanced', false);
switchMode(false);
}
else {
switchMode('Basic', false);
switchMode(false);
}
}
function newFromTemplate(preset, x, y) {
if (preset != '') {
setText('palette-button-splash', presets[preset].palette);
setText('palette-button', presets[preset].palette);
x = presets[preset].width;
y = presets[preset].height;
}
newPixel(x, y, pixelEditorMode == 'Advanced' ? 'Basic' : 'Advanced');
}

View File

@ -5,7 +5,7 @@ var dragging = false;
var lastMouseClickPos = [0,0];
var dialogueOpen = false;
var documentCreated = false;
var pixelEditorMode;
var pixelEditorMode = "Advanced";
//common elements
var brushPreview = document.getElementById("brush-preview");