refactored IDE project menu

pull/95/head
jmoenig 2020-04-30 09:07:32 +02:00
rodzic e04dedd1f5
commit 205b97895d
1 zmienionych plików z 37 dodań i 32 usunięć

Wyświetl plik

@ -3396,7 +3396,6 @@ IDE_Morph.prototype.settingsMenu = function () {
IDE_Morph.prototype.projectMenu = function () { IDE_Morph.prototype.projectMenu = function () {
var menu, var menu,
myself = this,
world = this.world(), world = this.world(),
pos = this.controlBar.projectButton.bottomLeft(), pos = this.controlBar.projectButton.bottomLeft(),
graphicsName = this.currentSprite instanceof SpriteMorph ? graphicsName = this.currentSprite instanceof SpriteMorph ?
@ -3422,14 +3421,17 @@ IDE_Morph.prototype.projectMenu = function () {
localize( localize(
'Export project...') + ' ' + localize('(in a new window)' 'Export project...') + ' ' + localize('(in a new window)'
), ),
function () { () => {
if (myself.projectName) { if (this.projectName) {
myself.exportProject(myself.projectName, shiftClicked); this.exportProject(this.projectName, shiftClicked);
} else { } else {
myself.prompt('Export Project As...', function (name) { this.prompt(
// false - override the shiftClick setting to use XML 'Export Project As...',
myself.exportProject(name, false); // false - override the shiftClick setting to use XML:
}, null, 'exportProject'); name => this.exportProject(name, false),
null,
'exportProject'
);
} }
}, },
'show project data as XML\nin a new browser window', 'show project data as XML\nin a new browser window',
@ -3439,13 +3441,16 @@ IDE_Morph.prototype.projectMenu = function () {
menu.addItem( menu.addItem(
shiftClicked ? shiftClicked ?
'Export project as plain text...' : 'Export project...', 'Export project as plain text...' : 'Export project...',
function () { () => {
if (myself.projectName) { if (this.projectName) {
myself.exportProject(myself.projectName, shiftClicked); this.exportProject(this.projectName, shiftClicked);
} else { } else {
myself.prompt('Export Project As...', function (name) { this.prompt(
myself.exportProject(name, shiftClicked); 'Export Project As...',
}, null, 'exportProject'); name => this.exportProject(name, shiftClicked),
null,
'exportProject'
);
} }
}, },
'save project data as XML\nto your downloads folder', 'save project data as XML\nto your downloads folder',
@ -3455,13 +3460,13 @@ IDE_Morph.prototype.projectMenu = function () {
if (this.stage.globalBlocks.length) { if (this.stage.globalBlocks.length) {
menu.addItem( menu.addItem(
'Export blocks...', 'Export blocks...',
function () {myself.exportGlobalBlocks(); }, () => this.exportGlobalBlocks(),
'show global custom block definitions as XML' + 'show global custom block definitions as XML' +
'\nin a new browser window' '\nin a new browser window'
); );
menu.addItem( menu.addItem(
'Unused blocks...', 'Unused blocks...',
function () {myself.removeUnusedBlocks(); }, () => this.removeUnusedBlocks(),
'find unused global custom blocks' + 'find unused global custom blocks' +
'\nand remove their definitions' '\nand remove their definitions'
); );
@ -3469,14 +3474,14 @@ IDE_Morph.prototype.projectMenu = function () {
menu.addItem( menu.addItem(
'Export summary...', 'Export summary...',
function () {myself.exportProjectSummary(); }, () => this.exportProjectSummary(),
'open a new browser browser window\n with a summary of this project' 'open a new browser browser window\n with a summary of this project'
); );
if (shiftClicked) { if (shiftClicked) {
menu.addItem( menu.addItem(
'Export summary with drop-shadows...', 'Export summary with drop-shadows...',
function () {myself.exportProjectSummary(true); }, () => this.exportProjectSummary(true),
'open a new browser browser window' + 'open a new browser browser window' +
'\nwith a summary of this project' + '\nwith a summary of this project' +
'\nwith drop-shadows on all pictures.' + '\nwith drop-shadows on all pictures.' +
@ -3485,7 +3490,7 @@ IDE_Morph.prototype.projectMenu = function () {
); );
menu.addItem( menu.addItem(
'Export all scripts as pic...', 'Export all scripts as pic...',
function () {myself.exportScriptsPicture(); }, () => this.exportScriptsPicture(),
'show a picture of all scripts\nand block definitions', 'show a picture of all scripts\nand block definitions',
new Color(100, 0, 0) new Color(100, 0, 0)
); );
@ -3494,16 +3499,16 @@ IDE_Morph.prototype.projectMenu = function () {
menu.addLine(); menu.addLine();
menu.addItem( menu.addItem(
'Libraries...', 'Libraries...',
function() { () => {
if (location.protocol === 'file:') { if (location.protocol === 'file:') {
myself.importLocalFile(); this.importLocalFile();
return; return;
} }
myself.getURL( this.getURL(
myself.resourceURL('libraries', 'LIBRARIES'), this.resourceURL('libraries', 'LIBRARIES'),
function (txt) { txt => {
var libraries = myself.parseResourceFile(txt); var libraries = this.parseResourceFile(txt);
new LibraryImportDialogMorph(myself, libraries).popUp(); new LibraryImportDialogMorph(this, libraries).popUp();
} }
); );
}, },
@ -3512,23 +3517,23 @@ IDE_Morph.prototype.projectMenu = function () {
menu.addItem( menu.addItem(
localize(graphicsName) + '...', localize(graphicsName) + '...',
function () { () => {
if (location.protocol === 'file:') { if (location.protocol === 'file:') {
myself.importLocalFile(); this.importLocalFile();
return; return;
} }
myself.importMedia(graphicsName); this.importMedia(graphicsName);
}, },
'Select a costume from the media library' 'Select a costume from the media library'
); );
menu.addItem( menu.addItem(
localize('Sounds') + '...', localize('Sounds') + '...',
function () { () => {
if (location.protocol === 'file:') { if (location.protocol === 'file:') {
myself.importLocalFile(); this.importLocalFile();
return; return;
} }
myself.importMedia('Sounds'); this.importMedia('Sounds');
}, },
'Select a sound from the media library' 'Select a sound from the media library'
); );