1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2026-04-20 15:16:38 +00:00

download ROM image

This commit is contained in:
Steven Hugg
2017-02-02 14:11:52 -05:00
parent 52b58f471c
commit e68c901c3f
4 changed files with 23 additions and 2 deletions
+16 -2
View File
@@ -241,6 +241,11 @@ function _createNewFile(e) {
return true;
}
function getCurrentFilename() {
var toks = current_preset_id.split("/");
return toks[toks.length-1];
}
function _shareFile(e) {
if (current_output == null) {
alert("Please fix errors before sharing.");
@@ -249,8 +254,7 @@ function _shareFile(e) {
var github = new Octokat();
var files = {};
var text = editor.getValue();
var toks = current_preset_id.split("/");
files[toks[toks.length-1]] = {"content": text};
files[getCurrentFilename()] = {"content": text};
var gistdata = {
"description": '8bitworkshop.com {"platform":"' + platform_id + '"}',
"public": true,
@@ -275,6 +279,15 @@ function _resetPreset(e) {
return true;
}
function _downloadROMImage(e) {
if (current_output == null) {
alert("Please fix errors before downloading ROM.");
return true;
}
var blob = new Blob([current_output], {type: "application/octet-stream"});
saveAs(blob, getCurrentFilename()+".rom");
}
function populateExamples(sel) {
sel.append($("<option />").text("--------- Chapters ---------").attr('disabled',true));
for (var i=0; i<PRESETS.length; i++) {
@@ -837,6 +850,7 @@ function setupDebugControls(){
$("#item_share_file").click(_shareFile);
$("#item_reset_file").click(_resetPreset);
$("#item_debug_expr").click(_breakExpression);
$("#item_download_rom").click(_downloadROMImage);
}
function showWelcomeMessage() {