134 lines
5.1 KiB
JavaScript
134 lines
5.1 KiB
JavaScript
const CollectionList = {
|
|
list_collections: [],
|
|
|
|
init: () => {
|
|
// Peuple lors du chargement du .blend
|
|
},
|
|
|
|
set_collections: (list_raw) => {
|
|
CollectionList.list_collections = [];
|
|
|
|
if (!list_raw || list_raw.length === 0) {
|
|
CollectionList.render();
|
|
let obj_badge = document.getElementById("badge_collection_count");
|
|
obj_badge.textContent = "0";
|
|
return;
|
|
}
|
|
|
|
for (let obj_raw of list_raw) {
|
|
let is_hidden = obj_raw.is_hide_render || obj_raw.is_exclude;
|
|
CollectionList.list_collections.push({
|
|
str_name: obj_raw.str_name,
|
|
nb_depth: obj_raw.nb_depth,
|
|
is_original_hide_render: is_hidden,
|
|
is_original_exclude: obj_raw.is_exclude,
|
|
is_hide_render: is_hidden,
|
|
has_override: false,
|
|
});
|
|
}
|
|
|
|
CollectionList.render();
|
|
|
|
let obj_badge = document.getElementById("badge_collection_count");
|
|
obj_badge.textContent = String(CollectionList.list_collections.length);
|
|
},
|
|
|
|
get_overrides: () => {
|
|
let list_overrides = [];
|
|
for (let obj_col of CollectionList.list_collections) {
|
|
list_overrides.push({
|
|
str_name: obj_col.str_name,
|
|
is_hide_render: obj_col.is_hide_render,
|
|
});
|
|
}
|
|
return list_overrides;
|
|
},
|
|
|
|
render: () => {
|
|
let obj_container = document.getElementById("container_collection_list");
|
|
obj_container.innerHTML = "";
|
|
|
|
if (CollectionList.list_collections.length === 0) {
|
|
obj_container.innerHTML = '<div class="text-center text-light-emphasis py-3">'
|
|
+ '<i class="mdi mdi-folder-off-outline d-block mb-2" style="font-size: 1.5rem;"></i>'
|
|
+ "Chargez un fichier .blend"
|
|
+ "</div>";
|
|
return;
|
|
}
|
|
|
|
for (let obj_col of CollectionList.list_collections) {
|
|
let obj_item = document.createElement("div");
|
|
obj_item.classList.add("list-group-item", "bg-dark", "text-light",
|
|
"border-secondary", "d-flex", "align-items-center", "gap-2", "py-1");
|
|
|
|
let nb_padding = 0.75 + obj_col.nb_depth * 1.2;
|
|
obj_item.style.paddingLeft = nb_padding + "rem";
|
|
|
|
let obj_checkbox = document.createElement("input");
|
|
obj_checkbox.type = "checkbox";
|
|
obj_checkbox.classList.add("form-check-input");
|
|
obj_checkbox.checked = !obj_col.is_hide_render;
|
|
obj_checkbox.addEventListener("change", () => {
|
|
obj_col.is_hide_render = !obj_checkbox.checked;
|
|
obj_col.has_override = (obj_col.is_hide_render !== obj_col.is_original_hide_render);
|
|
CollectionList.render();
|
|
});
|
|
|
|
let obj_icon = document.createElement("i");
|
|
obj_icon.classList.add("mdi");
|
|
if (obj_col.is_hide_render) {
|
|
obj_icon.classList.add("mdi-folder-off-outline", "text-muted");
|
|
} else {
|
|
obj_icon.classList.add("mdi-folder-outline");
|
|
}
|
|
|
|
let obj_label = document.createElement("span");
|
|
obj_label.classList.add("flex-grow-1", "collection-name");
|
|
obj_label.textContent = obj_col.str_name;
|
|
if (obj_col.is_hide_render) {
|
|
obj_label.classList.add("text-muted");
|
|
}
|
|
|
|
let obj_indicator = document.createElement("small");
|
|
obj_indicator.classList.add("collection-original-badge");
|
|
|
|
if (obj_col.has_override) {
|
|
obj_indicator.classList.add("text-warning");
|
|
obj_indicator.innerHTML = '<i class="mdi mdi-pencil-outline"></i>';
|
|
obj_indicator.title = "Modifie (original : "
|
|
+ (obj_col.is_original_hide_render ? "masque" : "visible") + ")";
|
|
} else if (obj_col.is_original_hide_render) {
|
|
obj_indicator.classList.add("text-muted");
|
|
obj_indicator.innerHTML = '<i class="mdi mdi-eye-off-outline"></i>';
|
|
obj_indicator.title = "Masque dans le .blend";
|
|
}
|
|
|
|
obj_item.appendChild(obj_checkbox);
|
|
obj_item.appendChild(obj_icon);
|
|
obj_item.appendChild(obj_label);
|
|
obj_item.appendChild(obj_indicator);
|
|
|
|
obj_container.appendChild(obj_item);
|
|
}
|
|
},
|
|
|
|
reset_to_original: () => {
|
|
for (let obj_col of CollectionList.list_collections) {
|
|
obj_col.is_hide_render = obj_col.is_original_hide_render;
|
|
obj_col.has_override = false;
|
|
}
|
|
CollectionList.render();
|
|
},
|
|
|
|
clear: () => {
|
|
CollectionList.list_collections = [];
|
|
let obj_container = document.getElementById("container_collection_list");
|
|
obj_container.innerHTML = '<div class="text-center text-light-emphasis py-3">'
|
|
+ '<i class="mdi mdi-folder-off-outline d-block mb-2" style="font-size: 1.5rem;"></i>'
|
|
+ "Chargez un fichier .blend"
|
|
+ "</div>";
|
|
let obj_badge = document.getElementById("badge_collection_count");
|
|
obj_badge.textContent = "0";
|
|
},
|
|
};
|