Skip to content

Commit

Permalink
QoL - Duplicate scene option in context menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
Azmoria committed Oct 10, 2023
1 parent 3e73a40 commit d9d0e9d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions ScenesPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,15 @@ function register_scene_row_context_menu() {
}
};
}
if(rowItem.isTypeScene()){
menuItems["duplicate"] = {
name: "Duplicate",
callback: function(itemKey, opt, originalEvent) {
let itemToEdit = find_sidebar_list_item(opt.$trigger);
duplicate_scene(itemToEdit.id);
}
};
}
if (rowItem.canDelete()) {

menuItems["border"] = "---";
Expand All @@ -2073,6 +2082,24 @@ function register_scene_row_context_menu() {
});
}

async function duplicate_scene(sceneId) {
let scene = await AboveApi.getScene(sceneId);

let aboveSceneData = {
...scene.data,
id: uuid()
}


await AboveApi.migrateScenes(window.gameId, [aboveSceneData]);

window.ScenesHandler.scenes.push(aboveSceneData);
did_update_scenes();
$(`.scene-item[data-scene-id='${aboveSceneData.id}'] .dm_scenes_button`).click();
$("#sources-import-main-container").remove();
expand_all_folders_up_to_id(aboveSceneData.id);
}

function expand_folders_to_active_scenes() {
if (!window.DM || !window.CURRENT_SCENE_DATA || !window.sceneListItems || !window.PLAYER_SCENE_ID) {
return;
Expand Down

0 comments on commit d9d0e9d

Please sign in to comment.