kopia lustrzana https://github.com/backface/turtlestitch
remove costumes and sounds from menu
rodzic
186261bd07
commit
b7a44b44f8
|
@ -686,4 +686,204 @@ IDE_Morph.prototype.createCategories = function () {
|
|||
this.add(this.categories);
|
||||
};
|
||||
|
||||
|
||||
IDE_Morph.prototype.projectMenu = function () {
|
||||
var menu,
|
||||
myself = this,
|
||||
world = this.world(),
|
||||
pos = this.controlBar.projectButton.bottomLeft(),
|
||||
graphicsName = this.currentSprite instanceof SpriteMorph ?
|
||||
'Costumes' : 'Backgrounds',
|
||||
shiftClicked = (world.currentKey === 16);
|
||||
|
||||
menu = new MenuMorph(this);
|
||||
menu.addItem('Project notes...', 'editProjectNotes');
|
||||
menu.addLine();
|
||||
menu.addItem('New', 'createNewProject');
|
||||
menu.addItem('Open...', 'openProjectsBrowser');
|
||||
menu.addItem('Save', "save");
|
||||
if (shiftClicked) {
|
||||
menu.addItem(
|
||||
'Save to disk',
|
||||
'saveProjectToDisk',
|
||||
'experimental - store this project\nin your downloads folder',
|
||||
new Color(100, 0, 0)
|
||||
);
|
||||
}
|
||||
menu.addItem('Save As...', 'saveProjectsBrowser');
|
||||
menu.addLine();
|
||||
menu.addItem(
|
||||
'Import...',
|
||||
function () {
|
||||
var inp = document.createElement('input');
|
||||
if (myself.filePicker) {
|
||||
document.body.removeChild(myself.filePicker);
|
||||
myself.filePicker = null;
|
||||
}
|
||||
inp.type = 'file';
|
||||
inp.style.color = "transparent";
|
||||
inp.style.backgroundColor = "transparent";
|
||||
inp.style.border = "none";
|
||||
inp.style.outline = "none";
|
||||
inp.style.position = "absolute";
|
||||
inp.style.top = "0px";
|
||||
inp.style.left = "0px";
|
||||
inp.style.width = "0px";
|
||||
inp.style.height = "0px";
|
||||
inp.addEventListener(
|
||||
"change",
|
||||
function () {
|
||||
document.body.removeChild(inp);
|
||||
myself.filePicker = null;
|
||||
world.hand.processDrop(inp.files);
|
||||
},
|
||||
false
|
||||
);
|
||||
document.body.appendChild(inp);
|
||||
myself.filePicker = inp;
|
||||
inp.click();
|
||||
},
|
||||
'file menu import hint' // looks up the actual text in the translator
|
||||
);
|
||||
|
||||
menu.addItem(
|
||||
shiftClicked ?
|
||||
'Export project as plain text...' : 'Export project...',
|
||||
function () {
|
||||
if (myself.projectName) {
|
||||
myself.exportProject(myself.projectName, shiftClicked);
|
||||
} else {
|
||||
myself.prompt('Export Project As...', function (name) {
|
||||
myself.exportProject(name);
|
||||
}, null, 'exportProject');
|
||||
}
|
||||
},
|
||||
'show project data as XML\nin a new browser window',
|
||||
shiftClicked ? new Color(100, 0, 0) : null
|
||||
);
|
||||
|
||||
menu.addItem(
|
||||
'Export blocks...',
|
||||
function () {myself.exportGlobalBlocks(); },
|
||||
'show global custom block definitions as XML\nin a new browser window'
|
||||
);
|
||||
|
||||
if (shiftClicked) {
|
||||
menu.addItem(
|
||||
'Export all scripts as pic...',
|
||||
function () {myself.exportScriptsPicture(); },
|
||||
'show a picture of all scripts\nand block definitions',
|
||||
new Color(100, 0, 0)
|
||||
);
|
||||
}
|
||||
|
||||
menu.addLine();
|
||||
menu.addItem(
|
||||
'Import tools',
|
||||
function () {
|
||||
myself.droppedText(
|
||||
myself.getURLsbeOrRelative(
|
||||
'tools.xml'
|
||||
),
|
||||
'tools'
|
||||
);
|
||||
},
|
||||
'load the official library of\npowerful blocks'
|
||||
);
|
||||
menu.addItem(
|
||||
'Libraries...',
|
||||
function () {
|
||||
// read a list of libraries from an external file,
|
||||
var libMenu = new MenuMorph(this, 'Import library'),
|
||||
libUrl = 'http://snap.berkeley.edu/snapsource/libraries/' +
|
||||
'LIBRARIES';
|
||||
|
||||
function loadLib(name) {
|
||||
var url = 'http://snap.berkeley.edu/snapsource/libraries/'
|
||||
+ name
|
||||
+ '.xml';
|
||||
myself.droppedText(myself.getURL(url), name);
|
||||
}
|
||||
|
||||
myself.getURL(libUrl).split('\n').forEach(function (line) {
|
||||
if (line.length > 0) {
|
||||
libMenu.addItem(
|
||||
line.substring(line.indexOf('\t') + 1),
|
||||
function () {
|
||||
loadLib(
|
||||
line.substring(0, line.indexOf('\t'))
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
libMenu.popup(world, pos);
|
||||
},
|
||||
'Select categories of additional blocks to add to this project.'
|
||||
);
|
||||
|
||||
/*
|
||||
menu.addItem(
|
||||
localize(graphicsName) + '...',
|
||||
function () {
|
||||
var dir = graphicsName,
|
||||
names = myself.getCostumesList(dir),
|
||||
libMenu = new MenuMorph(
|
||||
myself,
|
||||
localize('Import') + ' ' + localize(dir)
|
||||
);
|
||||
|
||||
function loadCostume(name) {
|
||||
var url = dir + '/' + name,
|
||||
img = new Image();
|
||||
img.onload = function () {
|
||||
var canvas = newCanvas(new Point(img.width, img.height));
|
||||
canvas.getContext('2d').drawImage(img, 0, 0);
|
||||
myself.droppedImage(canvas, name);
|
||||
};
|
||||
img.src = url;
|
||||
}
|
||||
|
||||
names.forEach(function (line) {
|
||||
if (line.length > 0) {
|
||||
libMenu.addItem(
|
||||
line,
|
||||
function () {loadCostume(line); }
|
||||
);
|
||||
}
|
||||
});
|
||||
libMenu.popup(world, pos);
|
||||
},
|
||||
'Select a costume from the media library'
|
||||
);
|
||||
menu.addItem(
|
||||
localize('Sounds') + '...',
|
||||
function () {
|
||||
var names = this.getCostumesList('Sounds'),
|
||||
libMenu = new MenuMorph(this, 'Import sound');
|
||||
|
||||
function loadSound(name) {
|
||||
var url = 'Sounds/' + name,
|
||||
audio = new Audio();
|
||||
audio.src = url;
|
||||
audio.load();
|
||||
myself.droppedAudio(audio, name);
|
||||
}
|
||||
|
||||
names.forEach(function (line) {
|
||||
if (line.length > 0) {
|
||||
libMenu.addItem(
|
||||
line,
|
||||
function () {loadSound(line); }
|
||||
);
|
||||
}
|
||||
});
|
||||
libMenu.popup(world, pos);
|
||||
},
|
||||
'Select a sound from the media library'
|
||||
);
|
||||
*/
|
||||
|
||||
menu.popup(world, pos);
|
||||
};
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue