Skip to content

Commit

Permalink
QoL - Export scene option in context menu for scenes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Azmoria committed Oct 10, 2023
1 parent d9d0e9d commit 2ea6570
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ScenesPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,13 @@ function register_scene_row_context_menu() {
duplicate_scene(itemToEdit.id);
}
};
menuItems["export"] = {
name: "Export",
callback: function(itemKey, opt, originalEvent) {
let itemToEdit = find_sidebar_list_item(opt.$trigger);
export_scene_context(itemToEdit.id)
}
};
}
if (rowItem.canDelete()) {

Expand Down
30 changes: 30 additions & 0 deletions Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,36 @@ function export_current_scene(){
$(".import-loading-indicator").remove();
}

async function export_scene_context(sceneId){
build_import_loading_indicator('Preparing Export File');
let scene = await AboveApi.getScene(sceneId);
let currentSceneData = {
...scene.data
}

let DataFile = {
version: 2,
scenes: [currentSceneData],
tokencustomizations: [],
notes: {},
journalchapters: [],
soundpads: {}
};
delete DataFile.scenes[0].itemType;
for(token in scene.data.tokens){
let tokenId = scene.data.tokens[token].id;
for(noteID in window.JOURNAL.notes){
if( tokenId == noteID){
DataFile.notes[tokenId] = window.JOURNAL.notes[noteID];
}
}
}
let currentdate = new Date();
let datetime = `${currentdate.getFullYear()}-${(currentdate.getMonth()+1)}-${currentdate.getDate()}`
download(b64EncodeUnicode(JSON.stringify(DataFile,null,"\t")),`${scene.data.title}-${datetime}.abovevtt`,"text/plain");
$(".import-loading-indicator").remove();
}

function export_token_customization() {
build_import_loading_indicator('Preparing Export File');
let DataFile = {
Expand Down

0 comments on commit 2ea6570

Please sign in to comment.