Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Improve error handling

See merge request minecraft/ConvertJavaTextureToBedrock!23
  • Loading branch information
ozelot379 committed Jan 2, 2020
2 parents 3da35f6 + 04465d6 commit 9db1f83
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 23 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## [3.0.3]
- Improve error handling

## [3.0.2]
- Fix title

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ozelot379/convert-minecraft-java-texture-to-bedrock",
"productName": "ConvertJavaTextureToBedrock",
"version": "3.0.2",
"version": "3.0.3",
"description": "Convert Minecraft Java texture packs to Bedrock texture packs",
"keywords": [
"Minecraft",
Expand Down
8 changes: 7 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class ConvertJavaTextureToBedrock {
* @returns {Promise<*>}
*/
async convert() {
this.log.log("Start conversion");

if (this.options.experimental) {
this.log.warn(`EXPERIMENTAL CONVERSIONS ENABLED!`)
}
Expand All @@ -68,7 +70,11 @@ class ConvertJavaTextureToBedrock {
await addAdditionalConverters(...await converter.convert());
}

return await this.output.generate();
const output = await this.output.generate();

this.log.log("Conversion finished");

return output;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/webapp/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<div>Works directly in your browser - no upload</div>
<div>More infos in the <a class="green-text"
href="https://github.com/ozelot379/ConvertJavaTextureToBedrock/blob/master/README.md"
target="_blank">readme</a></div>
target="_blank">Readme</a></div>
</div>
<div class="col l6">
<div>
Expand Down
44 changes: 24 additions & 20 deletions src/webapp/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,23 @@ document.addEventListener("DOMContentLoaded", () => {
});
document.querySelector(".swal-button--loading").disabled = true;

_log("Start conversion");

if (worker !== null) {
worker.terminate();
worker = null;
}
worker = new Worker();
worker.addEventListener("message", afterConvert);
worker.addEventListener("error", errorConvert);
worker.postMessage({
files,
options: {
experimental: experimentalSwitch.checked
try {
if (worker !== null) {
worker.terminate();
worker = null;
}
});
worker = new Worker();
worker.addEventListener("message", afterConvert);
worker.addEventListener("error", errorConvert);
worker.postMessage({
files,
options: {
experimental: experimentalSwitch.checked
}
});
} catch (err) {
errorConvert(err);
}
}

/**
Expand Down Expand Up @@ -129,7 +131,7 @@ document.addEventListener("DOMContentLoaded", () => {
buttons: "Save"
});

_log("Conversion finished");
_log();

if (await savePopup) {
if (output instanceof File) {
Expand Down Expand Up @@ -158,14 +160,16 @@ document.addEventListener("DOMContentLoaded", () => {
}

/**
* @param {string} log
* @param {string|undefined} log
*/
function _log(log) {
const li = document.createElement("li");
function _log(log = undefined) {
if (log) {
const li = document.createElement("li");

li.innerText = log;
li.innerText = log;

logs.appendChild(li);
logs.appendChild(li);
}

logs.scrollTop = logs.scrollHeight; // Scroll to bottom
}
Expand Down

0 comments on commit 9db1f83

Please sign in to comment.