diff --git a/css/_export.scss b/css/_export.scss new file mode 100644 index 0000000..01f45a1 --- /dev/null +++ b/css/_export.scss @@ -0,0 +1,10 @@ +#export { + .export-configuration { + display: flex; + flex-direction: column; + + input { + flex: 1; + } + } +} \ No newline at end of file diff --git a/css/_popup-container.scss b/css/_popup-container.scss index 5191f9c..b81cf3e 100644 --- a/css/_popup-container.scss +++ b/css/_popup-container.scss @@ -77,6 +77,18 @@ text-align: center; } } + + div.pixel-export, div.save-project { + input { + background: $indent; + border: none; + border-radius: 4px; + color: $indenttext; + padding: 10px 20px; + margin: 0; + text-align: left; + } + } /* input { background: $indent; @@ -152,4 +164,13 @@ } } } + + .popup-actions { + display: flex; + justify-content: center; + + button { + font-size: 18px; + } + } } \ No newline at end of file diff --git a/css/_save-project.scss b/css/_save-project.scss new file mode 100644 index 0000000..16519cf --- /dev/null +++ b/css/_save-project.scss @@ -0,0 +1,10 @@ +#save-project { + .save-project-configuration { + display: flex; + flex-direction: column; + + input { + flex: 1; + } + } +} \ No newline at end of file diff --git a/css/pixel-editor.scss b/css/pixel-editor.scss index 3f87961..eb94914 100644 --- a/css/pixel-editor.scss +++ b/css/pixel-editor.scss @@ -14,4 +14,6 @@ @import 'compatibility'; @import 'resize-menus'; @import 'palette-editor'; -@import 'splash-page'; \ No newline at end of file +@import 'splash-page'; +@import "export"; +@import "save-project"; \ No newline at end of file diff --git a/js/_fileMenu.js b/js/_fileMenu.js new file mode 100644 index 0000000..5ce18ed --- /dev/null +++ b/js/_fileMenu.js @@ -0,0 +1,155 @@ +var mainMenuItems = document.getElementById('main-menu').children; + +//for each button in main menu (starting at 1 to avoid logo) +for (var i = 1; i < mainMenuItems.length; i++) { + + //get the button that's in the list item + var menuItem = mainMenuItems[i]; + var menuButton = menuItem.children[0]; + + //when you click a main menu items button + on('click', menuButton, function (e, button) { + select(button.parentElement); + }); + + var subMenu = menuItem.children[1]; + var subMenuItems = subMenu.children; + + //when you click an item within a menu button + for (var j = 0; j < subMenuItems.length; j++) { + + var subMenuItem = subMenuItems[j]; + var subMenuButton = subMenuItem.children[0]; + + subMenuButton.addEventListener('click', function (e) { + + switch(this.textContent) { + + //File Menu + case 'New': + showDialogue('new-pixel'); + break; + case 'Save project': + openSaveProjectWindow(); + break; + case 'Open': + //if a document exists + if (documentCreated) { + //check if the user wants to overwrite + if (confirm('Opening a pixel will discard your current one. Are you sure you want to do that?')) + //open file selection dialog + document.getElementById('open-image-browse-holder').click(); + } + else + //open file selection dialog + document.getElementById('open-image-browse-holder').click(); + + break; + + case 'Export': + openPixelExportWindow(); + break; + + case 'Exit': + + console.log('exit'); + //if a document exists, make sure they want to delete it + if (documentCreated) { + + //ask user if they want to leave + if (confirm('Exiting will discard your current pixel. Are you sure you want to do that?')) + //skip onbeforeunload prompt + window.onbeforeunload = null; + else + e.preventDefault(); + } + + break; + //Edit Menu + case 'Undo': + undo(); + break; + case 'Redo': + redo(); + break; + + //Palette Menu + case 'Add color': + addColor('#eeeeee'); + break; + // SELECTION MENU + case 'Paste': + pasteSelection(); + break; + case 'Copy': + copySelection(); + tool.pencil.switchTo(); + break; + case 'Cut': + cutSelectionTool(); + tool.pencil.switchTo(); + break; + case 'Cancel': + tool.pencil.switchTo(); + break; + //Help Menu + case 'Settings': + //fill form with current settings values + setValue('setting-numberOfHistoryStates', settings.numberOfHistoryStates); + + showDialogue('settings'); + break; + //Help Menu + case 'Help': + showDialogue('help'); + break; + case 'About': + showDialogue('about'); + break; + case 'Changelog': + showDialogue('changelog'); + break; + } + + closeMenu(); + }); + } +} + +function closeMenu () { + //remove .selected class from all menu buttons + for (var i = 0; i < mainMenuItems.length; i++) { + deselect(mainMenuItems[i]); + } +} + +function getProjectData() { + // use a dictionary + let dictionary = {}; + // sorting layers by increasing z-index + let layersCopy = layers.slice(); + layersCopy.sort((a, b) => (a.canvas.style.zIndex > b.canvas.style.zIndex) ? 1 : -1); + // save canvas size + dictionary['canvasWidth'] = currentLayer.canvasSize[0]; + dictionary['canvasHeight'] = currentLayer.canvasSize[1]; + // save editor mode + dictionary['editorMode'] = pixelEditorMode; + // save palette + for (let i=0; i (a.canvas.style.zIndex > b.canvas.style.zIndex) ? 1 : -1); + + // Merging every layer on the export canvas + for (let i=0; i changelog}} {{> credits}} {{> settings}} + {{> pixel-export-popup}} + {{> save-project-popup}} diff --git a/views/pixel-export-popup.hbs b/views/pixel-export-popup.hbs new file mode 100644 index 0000000..17fa4d3 --- /dev/null +++ b/views/pixel-export-popup.hbs @@ -0,0 +1,14 @@ +
+ + +

Export File

+ +
+

File Name

+ +
+ + +
\ No newline at end of file diff --git a/views/save-project-popup.hbs b/views/save-project-popup.hbs new file mode 100644 index 0000000..1b4319e --- /dev/null +++ b/views/save-project-popup.hbs @@ -0,0 +1,14 @@ +
+ + +

Save Project

+ +
+

File Name

+ +
+ + +
\ No newline at end of file