1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-06-24 03:29:28 +00:00

create skeleton file at load time if no file found

This commit is contained in:
Steven Hugg 2019-05-14 13:56:48 -04:00
parent 89331dbcf2
commit de0ede9e81
2 changed files with 36 additions and 17 deletions

View File

@ -241,8 +241,18 @@ function refreshWindowList() {
}); });
} }
function loadMainWindow(preset_id:string) {
// we need this to build create functions for the editor
refreshWindowList();
// show main file
projectWindows.createOrShow(preset_id);
// build project
current_project.setMainFile(preset_id);
}
function loadProject(preset_id:string) { function loadProject(preset_id:string) {
// set current file ID // set current file ID
// TODO: this is done twice
current_project.mainPath = preset_id; current_project.mainPath = preset_id;
setLastPreset(preset_id); setLastPreset(preset_id);
// load files from storage or web URLs // load files from storage or web URLs
@ -250,12 +260,14 @@ function loadProject(preset_id:string) {
if (err) { if (err) {
alertError(err); alertError(err);
} else if (result && result.length) { } else if (result && result.length) {
// we need this to build create functions for the editor // file found; continue
refreshWindowList(); loadMainWindow(preset_id);
// show main file } else {
projectWindows.createOrShow(preset_id); // no file data, load skeleton file
// build project getSkeletonFile(preset_id).then((skel) => {
current_project.setMainFile(preset_id); current_project.filedata[preset_id] = skel || "\n";
loadMainWindow(preset_id);
});
} }
}); });
} }
@ -304,11 +316,7 @@ function _createNewFile(e) {
filename += platform.getDefaultExtension(); filename += platform.getDefaultExtension();
} }
var path = filename; var path = filename;
getSkeletonFile(path).then( (result) => { reloadProject(path);
return store.setItem(path, result || "\n");
}).then(() => {
reloadProject(path);
});
} }
} }
} as any); } as any);
@ -821,6 +829,15 @@ function populateFiles(sel:JQuery, category:string, prefix:string, foundFiles:{}
}); });
} }
function finishSelector(sel) {
sel.css('visibility','visible');
// create option if not selected
var main = current_project.mainPath;
if (sel.val() != main) {
sel.append($("<option />").val(main).text(main).attr('selected','selected'));
}
}
function updateSelector() { function updateSelector() {
var sel = $("#preset_select").empty(); var sel = $("#preset_select").empty();
if (!repo_id) { if (!repo_id) {
@ -828,13 +845,13 @@ function updateSelector() {
populateRepos(sel); populateRepos(sel);
var foundFiles = populateExamples(sel); var foundFiles = populateExamples(sel);
populateFiles(sel, "Local Files", "", foundFiles, () => { populateFiles(sel, "Local Files", "", foundFiles, () => {
sel.css('visibility','visible'); finishSelector(sel);
}); });
} else { } else {
sel.append($("<option />").val('/').text('Leave Repository')); sel.append($("<option />").val('/').text('Leave Repository'));
// repo: populate all files // repo: populate all files
populateFiles(sel, repo_id, "", {}, () => { populateFiles(sel, repo_id, "", {}, () => {
sel.css('visibility','visible'); finishSelector(sel);
}); });
} }
// set click handlers // set click handlers

View File

@ -796,10 +796,12 @@ function assembleDASM(step:BuildStep) {
} }
// for bataribasic (TODO) // for bataribasic (TODO)
if (step['bblines']) { if (step['bblines']) {
let lst = listings[lstpath]; let lst = listings[step.path];
lst.asmlines = lst.lines; if (lst) {
lst.text = alst; lst.asmlines = lst.lines;
lst.lines = []; lst.text = alst;
lst.lines = [];
}
} }
var segments = step.params.extra_segments; var segments = step.params.extra_segments;
return { return {