Skip to content

Commit

Permalink
BBS exporter: UX update and UV fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mchorse committed Jan 18, 2025
1 parent 03a8ac0 commit 2925db7
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 6 deletions.
4 changes: 2 additions & 2 deletions plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,8 @@
"title": "BBS Model Ex/importer",
"icon": "icon.png",
"author": "McHorse",
"description": "Adds actions to export/import models in BBS format, which is used by BBS machinima studio.",
"version": "1.2.4",
"description": "Adds actions to export/import models in BBS format, which is used by BBS mod.",
"version": "1.3",
"variant": "both",
"tags": ["Exporter", "Importer"],
"min_version": "4.8.0",
Expand Down
57 changes: 53 additions & 4 deletions plugins/bbs_exporter/bbs_exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@

if (texture && texture.uuid == textureUuid)
{
return [texture.width, texture.height];
return [texture.uv_width, texture.uv_height];
}
}
}
Expand Down Expand Up @@ -581,6 +581,21 @@
name: "BBS model",
extension: "json",
remember: false,
load_filter: {
type: "json",
extensions: ["json"],
condition: (file) => {
return file && file.model && file.model.groups && file.model.texture;
}
},
load(content, file) {
if (!Undo)
{
setupProject(Formats.free);
}

importBBS(content);
},
compile(options) {
return autoStringify(compile());
},
Expand Down Expand Up @@ -615,6 +630,12 @@
description: "When enabled, copies to the buffer only cubes from the first found group. This option is ignored when Copy to buffer option is disabled!",
type: "checkbox",
value: false
},
exportAsFolder: {
label: "Export to folder",
description: "When enabled, you can pick the folder where .bbs.json and the texture would be exported to.",
type: "checkbox",
value: false
}
},
onConfirm: function(formData) {
Expand All @@ -623,7 +644,35 @@
lastOptions.model = formData.exportModel;
lastOptions.animations = formData.exportAnimations;

if (formData.copyToBuffer)
if (formData.exportAsFolder)
{
var folder = Blockbench.pickDirectory({
title: "Export destination..."
});

if (folder)
{
Blockbench.writeFile(PathModule.join(folder, "model.bbs.json"), {
content: autoStringify(compile())
});

Texture.all.forEach((t) =>
{
if (t.error)
{
return;
}

var name = t.name.endsWith(".png") ? t.name : t.name + ".png";

Blockbench.writeFile(PathModule.join(folder, name), {
content: t.source,
savetype: 'image'
});
});
}
}
else if (formData.copyToBuffer)
{
var data = {};

Expand All @@ -648,9 +697,9 @@
Plugin.register("bbs_exporter", {
title: "BBS Model Ex/importer",
author: "McHorse",
description: "Adds actions to export/import models in BBS format, which is used by BBS machinima studio.",
description: "Adds actions to export/import models in BBS format, which is used by BBS mod.",
icon: "icon.png",
version: "1.2.4",
version: "1.3",
min_version: "4.8.0",
variant: "both",
has_changelog: true,
Expand Down
20 changes: 20 additions & 0 deletions plugins/bbs_exporter/changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,25 @@
]
}
]
},
"1.3": {
"title": "1.3",
"date": "2025-01-18",
"author": "McHorse",
"categories": [
{
"title": "Features",
"list": [
"Added option \"Export to folder\" to exporter to automatically export not only the .bbs.json file, but texture(s) as well!",
"Added load filter to ease importing .bbs.json models via drag-and-dropping or by opening file with Blockbench"
]
},
{
"title": "Bug fixes",
"list": [
"Fixed wrong UV size being used when a texture has different UV size"
]
}
]
}
}

0 comments on commit 2925db7

Please sign in to comment.