Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform Position Event #2249

Open
wants to merge 2 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<div>An error occurred while loading Blockbench</div>
<div id="loading_error_detail" style="color: var(--color-subtle_text);"></div>
<button onclick="isApp ? Blockbench.reload() : window.location.reload(true)" class="large" style="margin-right: auto; margin-left: auto;">Reload</button>
<button onclick="factoryResetAndReload()" class="large" style="margin-right: auto; margin-left: auto;">Factory Reset</button>
<button onclick="window.close()" class="large" style="margin-right: auto; margin-left: auto;">Quit</button>
</div>
<script>
Expand Down
7 changes: 1 addition & 6 deletions js/interface/menu_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,7 @@ const MenuBar = {
}},
'reset_layout',
{name: 'menu.help.developer.reset_storage', icon: 'fas.fa-hdd', click: () => {
if (confirm(tl('menu.help.developer.reset_storage.confirm'))) {
localStorage.clear()
Blockbench.addFlag('no_localstorage_saving')
console.log('Cleared Local Storage')
window.location.reload(true)
}
factoryResetAndReload();
}},
{name: 'menu.help.developer.unlock_projects', id: 'unlock_projects', icon: 'vpn_key', condition: () => ModelProject.all.find(project => project.locked), click() {
ModelProject.all.forEach(project => project.locked = false);
Expand Down
11 changes: 11 additions & 0 deletions js/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,17 @@ const TickUpdates = {
}
}

function factoryResetAndReload() {
let lang_key = 'menu.help.developer.reset_storage.confirm';
let result = window.confirm((window.tl && tl(lang_key) != lang_key) ? tl(lang_key) : 'Are you sure you want to reset Blockbench to factory settings? This will delete all custom settings, keybindings and installed plugins.');
if (result) {
localStorage.clear();
Blockbench.addFlag('no_localstorage_saving');
console.log('Cleared Local Storage');
window.location.reload(true);
}
}

const documentReady = new Promise((resolve, reject) => {
$(document).ready(function() {
resolve()
Expand Down
11 changes: 11 additions & 0 deletions js/modeling/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,11 @@ function moveElementsInSpace(difference, axis) {
}
if (el instanceof Cube) {
el.mapAutoUV()
// dispatches the position_changed event for plugin access.
let element = el;
let isMoveOnAxis = false;
let positionData = {element, difference, axis, isMoveOnAxis};
Blockbench.dispatchEvent('position_changed', positionData);
}
})
Canvas.updateView({
Expand Down Expand Up @@ -1000,6 +1005,12 @@ BARS.defineActions(function() {
Format.cube_size_limiter.move(obj);
}
obj.mapAutoUV()
// dispatches the position_changed event for plugin access.
let difference = val - before;
let element = obj;
let isMoveOnAxis = true;
let positionData = {element, difference, axis, isMoveOnAxis};
Blockbench.dispatchEvent('position_changed', positionData);
}
obj.preview_controller.updateTransform(obj);
if (obj.preview_controller.updateGeometry) obj.preview_controller.updateGeometry(obj);
Expand Down