mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-29 14:51:17 +00:00
importURL parameter imports files
This commit is contained in:
parent
9fe8f5d1a0
commit
9380590ff5
@ -131,6 +131,7 @@ TODO:
|
|||||||
- vcs sound continues when paused
|
- vcs sound continues when paused
|
||||||
- upload multiple files/zip file to subdirectory
|
- upload multiple files/zip file to subdirectory
|
||||||
- allow "include graphics.asm" instead of "include project/graphics.asm"
|
- allow "include graphics.asm" instead of "include project/graphics.asm"
|
||||||
|
- chrome looks blurry on vcs
|
||||||
|
|
||||||
WEB WORKER FORMAT
|
WEB WORKER FORMAT
|
||||||
|
|
||||||
|
@ -116,8 +116,8 @@ function recordVideo(intervalMsec, maxFrames, callback) {
|
|||||||
console.log('finished encoding GIF');
|
console.log('finished encoding GIF');
|
||||||
callback(blob);
|
callback(blob);
|
||||||
});
|
});
|
||||||
intervalMsec = intervalMsec || 100;
|
intervalMsec = intervalMsec || (100 + ((Math.random()*16)&15));
|
||||||
maxFrames = maxFrames || 100;
|
maxFrames = maxFrames || (100 + ((Math.random()*16)&15));
|
||||||
var nframes = 0;
|
var nframes = 0;
|
||||||
console.log("Recording video", canvas);
|
console.log("Recording video", canvas);
|
||||||
var f = () => {
|
var f = () => {
|
||||||
|
84
src/ui.ts
84
src/ui.ts
@ -338,7 +338,7 @@ function handleFileUpload(files: File[]) {
|
|||||||
else {
|
else {
|
||||||
console.log("Uploaded " + path + " " + data.length + " bytes");
|
console.log("Uploaded " + path + " " + data.length + " bytes");
|
||||||
if (index == 1)
|
if (index == 1)
|
||||||
qs['file'] = path;
|
qs['file'] = path; // TODO?
|
||||||
uploadNextFile();
|
uploadNextFile();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -514,14 +514,15 @@ function _renameFile(e) {
|
|||||||
var fn = projectWindows.getActiveID();
|
var fn = projectWindows.getActiveID();
|
||||||
var newfn = prompt("Rename '" + fn + "' to?", fn);
|
var newfn = prompt("Rename '" + fn + "' to?", fn);
|
||||||
var data = current_project.getFile(wnd.getPath());
|
var data = current_project.getFile(wnd.getPath());
|
||||||
if (newfn && data && newfn.startsWith("local/")) {
|
if (newfn && data) {
|
||||||
if (!checkEnteredFilename(newfn)) return;
|
if (!checkEnteredFilename(newfn)) return;
|
||||||
store.removeItem(fn, () => {
|
store.removeItem(fn, () => {
|
||||||
store.setItem(newfn, data, () => {
|
store.setItem(newfn, data, () => {
|
||||||
alert("Renamed " + fn + " to " + newfn);
|
alert("Renamed " + fn + " to " + newfn);
|
||||||
updateSelector();
|
updateSelector();
|
||||||
// TODO: rebuild?
|
if (fn == main_file_id) {
|
||||||
//gotoNewLocation();
|
reloadPresetNamed(newfn);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -887,6 +888,14 @@ function updateDebugWindows() {
|
|||||||
setTimeout(updateDebugWindows, 200);
|
setTimeout(updateDebugWindows, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setWaitDialog(b : boolean) {
|
||||||
|
if (b) {
|
||||||
|
$("#pleaseWaitModal").modal('show');
|
||||||
|
} else {
|
||||||
|
$("#pleaseWaitModal").modal('hide');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function _recordVideo() {
|
function _recordVideo() {
|
||||||
loadScript("gif.js/dist/gif.js", () => {
|
loadScript("gif.js/dist/gif.js", () => {
|
||||||
var canvas = $("#emulator").find("canvas")[0] as HTMLElement;
|
var canvas = $("#emulator").find("canvas")[0] as HTMLElement;
|
||||||
@ -912,7 +921,7 @@ function _recordVideo() {
|
|||||||
//img.attr('src', 'https://articulate-heroes.s3.amazonaws.com/uploads/rte/kgrtehja_DancingBannana.gif');
|
//img.attr('src', 'https://articulate-heroes.s3.amazonaws.com/uploads/rte/kgrtehja_DancingBannana.gif');
|
||||||
gif.on('finished', function(blob) {
|
gif.on('finished', function(blob) {
|
||||||
img.attr('src', URL.createObjectURL(blob));
|
img.attr('src', URL.createObjectURL(blob));
|
||||||
$("#pleaseWaitModal").modal('hide');
|
setWaitDialog(false);
|
||||||
_resume();
|
_resume();
|
||||||
$("#videoPreviewModal").modal('show');
|
$("#videoPreviewModal").modal('show');
|
||||||
});
|
});
|
||||||
@ -923,7 +932,7 @@ function _recordVideo() {
|
|||||||
var f = function() {
|
var f = function() {
|
||||||
if (nframes++ > maxFrames) {
|
if (nframes++ > maxFrames) {
|
||||||
console.log("Rendering video");
|
console.log("Rendering video");
|
||||||
$("#pleaseWaitModal").modal('show');
|
setWaitDialog(true);
|
||||||
_pause();
|
_pause();
|
||||||
gif.render();
|
gif.render();
|
||||||
} else {
|
} else {
|
||||||
@ -1363,6 +1372,7 @@ function loadSharedGist(gistkey : string) {
|
|||||||
store.setItem('shared/'+filename, val.files[filename].content);
|
store.setItem('shared/'+filename, val.files[filename].content);
|
||||||
if (!newid) newid = 'shared/'+filename;
|
if (!newid) newid = 'shared/'+filename;
|
||||||
}
|
}
|
||||||
|
// TODO: wait for set?
|
||||||
delete qs['gistkey'];
|
delete qs['gistkey'];
|
||||||
reloadPresetNamed(newid);
|
reloadPresetNamed(newid);
|
||||||
}).fail(function(err) {
|
}).fail(function(err) {
|
||||||
@ -1404,6 +1414,36 @@ export function setupSplits() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadImportedURL(url : string) {
|
||||||
|
// TODO: zip file?
|
||||||
|
setWaitDialog(true);
|
||||||
|
getWithBinary(url, (data) => {
|
||||||
|
if (data) {
|
||||||
|
var path = 'shared/' + getFilenameForPath(url);
|
||||||
|
// TODO: progress dialog
|
||||||
|
console.log("Importing " + data.length + " bytes as " + path);
|
||||||
|
store.getItem(path, (err, olddata) => {
|
||||||
|
setWaitDialog(false);
|
||||||
|
if (!olddata || confirm("Replace existing file '" + path + "'?")) {
|
||||||
|
store.setItem(path, data, (err, result) => {
|
||||||
|
if (err)
|
||||||
|
alert(err+"");
|
||||||
|
if (result != null) {
|
||||||
|
delete qs['importURL'];
|
||||||
|
qs['file'] = path;
|
||||||
|
replaceURLState();
|
||||||
|
loadAndStartPlatform();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert("Could not load source code from URL: " + url);
|
||||||
|
setWaitDialog(false);
|
||||||
|
}
|
||||||
|
}, 'text');
|
||||||
|
}
|
||||||
|
|
||||||
// start
|
// start
|
||||||
export function startUI(loadplatform : boolean) {
|
export function startUI(loadplatform : boolean) {
|
||||||
installErrorHandler();
|
installErrorHandler();
|
||||||
@ -1415,19 +1455,29 @@ export function startUI(loadplatform : boolean) {
|
|||||||
$("#item_platform_"+platform_id).addClass("dropdown-item-checked");
|
$("#item_platform_"+platform_id).addClass("dropdown-item-checked");
|
||||||
setupSplits();
|
setupSplits();
|
||||||
// parse query string
|
// parse query string
|
||||||
// is this a share URL?
|
// is this a share URL? can't create store until we know platform_id...
|
||||||
if (qs['gistkey']) {
|
if (qs['gistkey']) {
|
||||||
loadSharedGist(qs['gistkey']);
|
loadSharedGist(qs['gistkey']);
|
||||||
} else {
|
}
|
||||||
|
// otherwise, open IDE
|
||||||
|
else {
|
||||||
|
// create store for platform
|
||||||
store = createNewPersistentStore(platform_id, null);
|
store = createNewPersistentStore(platform_id, null);
|
||||||
// reset file?
|
// is this an importURL?
|
||||||
if (qs['file'] && qs['reset']) {
|
if (qs['importURL']) {
|
||||||
store.removeItem(qs['fileview'] || qs['file']);
|
loadImportedURL(qs['importURL']);
|
||||||
qs['reset'] = '';
|
return;
|
||||||
gotoNewLocation();
|
}
|
||||||
} else {
|
|
||||||
// load and start platform object
|
// load and start platform object
|
||||||
if (loadplatform) {
|
if (loadplatform) {
|
||||||
|
loadAndStartPlatform();
|
||||||
|
} else {
|
||||||
|
startPlatform();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadAndStartPlatform() {
|
||||||
var scriptfn = 'gen/platform/' + platform_id.split(/[.-]/)[0] + '.js';
|
var scriptfn = 'gen/platform/' + platform_id.split(/[.-]/)[0] + '.js';
|
||||||
loadScript(scriptfn, () => {
|
loadScript(scriptfn, () => {
|
||||||
console.log("loaded platform", platform_id);
|
console.log("loaded platform", platform_id);
|
||||||
@ -1437,10 +1487,4 @@ export function startUI(loadplatform : boolean) {
|
|||||||
}, () => {
|
}, () => {
|
||||||
alert('Platform "' + platform_id + '" not supported.');
|
alert('Platform "' + platform_id + '" not supported.');
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
startPlatform();
|
|
||||||
showWelcomeMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user