mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Store user selected filePath on the Piskel instance stored in pskl.app.piskelController. Getter and Setter in PublicPiskelController for filePath.
This commit is contained in:
@@ -136,6 +136,14 @@
|
||||
return this.piskelController.piskel;
|
||||
};
|
||||
|
||||
ns.PublicPiskelController.prototype.setSavePath = function (savePath) {
|
||||
this.piskelController.piskel.savePath = savePath;
|
||||
}
|
||||
|
||||
ns.PublicPiskelController.prototype.getSavePath = function () {
|
||||
return this.piskelController.piskel.savePath;
|
||||
}
|
||||
|
||||
ns.PublicPiskelController.prototype.raiseSaveStateEvent_ = function (fn, args) {
|
||||
$.publish(Events.PISKEL_SAVE_STATE, {
|
||||
type : pskl.service.HistoryService.REPLAY_NO_SNAPSHOT,
|
||||
|
||||
@@ -165,15 +165,21 @@
|
||||
ns.SaveController.prototype.saveFileDesktop_ = function () {
|
||||
this.beforeSaving_();
|
||||
var serialized = pskl.app.piskelController.serialize();
|
||||
// TODO: hold on to the full path to the file:
|
||||
var fullSavePath = null;
|
||||
// TODO: if we already have a filename (and we are sure this is the same document!!!)
|
||||
// then save over the old file without opening a save dialog (using nodejs 'fs' api)
|
||||
pskl.utils.FileUtils.desktopSaveAs(serialized, null, function (filename) {
|
||||
this.onSaveSuccess_();
|
||||
this.afterSaving_();
|
||||
fullSavePath = filename;
|
||||
}.bind(this));
|
||||
var savePath = pskl.app.piskelController.getSavePath();
|
||||
// if we already have a filename, just save the file (using nodejs 'fs' api)
|
||||
if (savePath !== null) {
|
||||
pskl.utils.FileUtils.desktopSaveToFile(serialized, savePath, function () {
|
||||
this.onSaveSuccess_();
|
||||
this.afterSaving_();
|
||||
}.bind(this));
|
||||
} else {
|
||||
// "save as" = open a save dialog, and store the returned save path
|
||||
pskl.utils.FileUtils.desktopSaveAs(serialized, null, function (selectedSavePath) {
|
||||
this.onSaveSuccess_();
|
||||
this.afterSaving_();
|
||||
pskl.app.piskelController.setSavePath(selectedSavePath);
|
||||
}.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
ns.SaveController.prototype.getName = function () {
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
this.height = height;
|
||||
|
||||
this.descriptor = descriptor;
|
||||
|
||||
/** @type {String} */
|
||||
this.savePath = null;
|
||||
|
||||
} else {
|
||||
throw 'Missing arguments in Piskel constructor : ' + Array.prototype.join.call(arguments, ",");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user