diff --git a/js/ChickenPaint.js b/js/ChickenPaint.js index 1a9fde6..ab6d866 100644 --- a/js/ChickenPaint.js +++ b/js/ChickenPaint.js @@ -228,7 +228,8 @@ function createDrawingTools() { * loadImageUrl - URL of PNG/JPEG image to load for editing (optional) * loadChibiFileUrl - URL of .chi file to load for editing (optional). Used in preference to loadImage. * loadSwatchesUrl - URL of an .aco palette to load (optional) - * + * + * allowMultipleSends - Allow the drawing to be sent to the server multiple times (saving does not immediately end drawing session). * allowDownload - Allow the drawing to be saved to the user's computer * allowFullScreen - Allow the drawing tool to enter "full screen" mode, where the rest of the page contents will be hidden * @@ -674,6 +675,13 @@ export default function ChickenPaint(options) { }, modifies: {document: true} }, + CPContinue: { + action: function() { + }, + isSupported: function() { + return !!options.allowMultipleSends; + } + }, CPExit: { action: function () { // Exit the drawing session without posting the drawing to the forum @@ -867,6 +875,10 @@ export default function ChickenPaint(options) { } function sendDrawing() { + if (!that.isActionSupported("CPContinue") && !confirm('Are you sure you want to send your drawing to the server and finish drawing now?')) { + return; + } + var saver = new CPResourceSaver({ artwork: that.getArtwork(), @@ -878,6 +890,11 @@ export default function ChickenPaint(options) { saver.on("savingComplete", function() { that.artwork.setHasUnsavedChanges(false); + + // If we're not allowed to keep editing, we can only go straight to viewing the new post + if (!that.isActionSupported("CPContinue") && that.isActionSupported("CPPost")) { + that.actionPerformed({action: "CPPost"}); + } }); // Allow the dialog to show before we begin serialization diff --git a/js/gui/CPMainMenu.js b/js/gui/CPMainMenu.js index 315f79c..04a37f6 100644 --- a/js/gui/CPMainMenu.js +++ b/js/gui/CPMainMenu.js @@ -442,6 +442,12 @@ export default function CPMainMenu(controller, mainGUI) { if (entry.action && !controller.isActionSupported(entry.action)) { return; } + + if (entry.action == "CPSend" && !controller.isActionSupported("CPContinue")) { + // User won't be able to come back after saving, so make it sound more final + entry.name = "Post Oekaki"; + entry.shortcut = "ctrl+p"; + } if (entry.children) { entryElem = $( diff --git a/js/gui/CPMiscPalette.js b/js/gui/CPMiscPalette.js index 2549f94..9f8bc9e 100644 --- a/js/gui/CPMiscPalette.js +++ b/js/gui/CPMiscPalette.js @@ -73,6 +73,11 @@ export default function CPMiscPalette(cpController) { button = buttons[i], buttonElem = document.createElement("li"); + if (button.command == 'CPSend' && !cpController.isActionSupported("CPContinue")) { + button.toolTip = "Send picture to server"; + button.className = "chickenpaint-tool-send-and-end"; + } + buttonElem.className = "chickenpaint-toolbar-button " + button.className; buttonElem.setAttribute("data-buttonIndex", i); diff --git a/js/gui/CPSendDialog.js b/js/gui/CPSendDialog.js index 6dffa14..c988579 100644 --- a/js/gui/CPSendDialog.js +++ b/js/gui/CPSendDialog.js @@ -56,7 +56,7 @@ export default function CPSendDialog(controller, parent, resourceSaver) {
@@ -72,7 +72,18 @@ export default function CPSendDialog(controller, parent, resourceSaver) { + + @@ -94,13 +105,17 @@ export default function CPSendDialog(controller, parent, resourceSaver) { .css("width", progress + "%"); }); - resourceSaver.on("savingComplete", function(progress) { + resourceSaver.on("savingComplete", function() { $(".modal-content[data-stage='saving']", dialog).hide(); - - if (controller.isActionSupported("CPExit")) { - $(".modal-content[data-stage='success-not-previously-posted']", dialog).show(); + + if (controller.isActionSupported("CPContinue")) { + if (controller.isActionSupported("CPExit")) { + $(".modal-content[data-stage='success-not-previously-posted']", dialog).show(); + } else { + $(".modal-content[data-stage='success-already-posted']", dialog).show(); + } } else { - $(".modal-content[data-stage='success-already-posted']", dialog).show(); + $(".modal-content[data-stage='success-redirect']", dialog).show(); } }); @@ -130,11 +145,13 @@ export default function CPSendDialog(controller, parent, resourceSaver) { controller.actionPerformed({action: "CPPost"}); }); - $(".chickenpaint-exit", dialog).click(function() { - alert("When you want to come back and finish your drawing, just click the 'new drawing' button again and " - + "you can choose to continue this drawing."); - controller.actionPerformed({action: "CPExit"}); - }); + $(".chickenpaint-exit", dialog) + .toggle(controller.isActionSupported("CPExit")) + .click(function() { + alert("When you want to come back and finish your drawing, just click the 'new drawing' button again and " + + "you can choose to continue this drawing."); + controller.actionPerformed({action: "CPExit"}); + }); $(".chickenpaint-send-cancel", dialog).click(function() { resourceSaver.cancel(); diff --git a/resources/css/chickenpaint.css b/resources/css/chickenpaint.css index f574074..19ae36b 100644 --- a/resources/css/chickenpaint.css +++ b/resources/css/chickenpaint.css @@ -9205,6 +9205,9 @@ body.chickenpaint-full-screen { .chickenpaint-tool-send { background-position: 0 -384px; } +.chickenpaint-tool-send-and-end { + background-position: 0 -992px; +} .chickenpaint-tool-freehand { background-position: 0 -608px; } diff --git a/resources/css/chickenpaint.less b/resources/css/chickenpaint.less index ab4188d..6487b96 100644 --- a/resources/css/chickenpaint.less +++ b/resources/css/chickenpaint.less @@ -326,6 +326,9 @@ body.chickenpaint-full-screen { .chickenpaint-tool-send { background-position:0 -384px; } +.chickenpaint-tool-send-and-end { + background-position:0 -992px; +} .chickenpaint-tool-freehand { background-position:0 -608px; diff --git a/resources/gfx/icons.png b/resources/gfx/icons.png index f696469..e10d456 100644 Binary files a/resources/gfx/icons.png and b/resources/gfx/icons.png differ diff --git a/resources/gfx/icons.psd b/resources/gfx/icons.psd index 35e2be4..7806d9a 100644 Binary files a/resources/gfx/icons.psd and b/resources/gfx/icons.psd differ diff --git a/test/index.js b/test/index.js index 8b3d705..d064f16 100644 --- a/test/index.js +++ b/test/index.js @@ -7,6 +7,7 @@ $(document).ready(function() { postUrl: "posting.php", exitUrl: "forum.php", allowSave: true, + allowMultipleSends: true, resourcesRoot: "../resources/" }); });