diff --git a/src/app/mods/index.ts b/src/app/mods/index.ts index 966fd47d..d3f8a4df 100644 --- a/src/app/mods/index.ts +++ b/src/app/mods/index.ts @@ -10,6 +10,7 @@ export { HealthBar } from "./health-bar/health-bar"; export { Jobsxp } from "../mods/jobsxp/jobsxp"; export { Marchand } from "../mods/marchand/marchand"; export { MonsterTooltip } from "./monsterTooltip/monsterTooltip"; +export { MoveWindows } from "./move-windows/move-windows"; export { Notifications } from "../mods/notifications/notifications"; export { PartyInfo } from "./party-info/party-info"; export { PartyMember } from "./party-info/party-member-on-map"; diff --git a/src/app/mods/move-windows/move-windows.ts b/src/app/mods/move-windows/move-windows.ts new file mode 100644 index 00000000..3666f072 --- /dev/null +++ b/src/app/mods/move-windows/move-windows.ts @@ -0,0 +1,39 @@ +import {Mod} from "../mod"; + +export class MoveWindows extends Mod { + + startMod(): void { + + this.wGame.addEventListener('storage', (e) => { + if(e.key === 'WindowMoved') { + const windowMoved = JSON.parse(localStorage.getItem('WindowMoved')); + this.moveWindow(windowMoved); + } + }); + + this.wGame.gui.windowsContainer.getChildren().forEach( + (window) => { + this.on(window, 'positioned', () => { + const windowMoved = { id: window.id, positionInfo: window.positionInfo, position: window.position, accountId: this.wGame.actorManager.userActor.data.accountId }; + localStorage.setItem("WindowMoved", JSON.stringify(windowMoved)); + }); + }); + } + + private moveWindow(window) { + if(window.accountId != this.wGame.actorManager.userActor.data.accountId) { + const movedWindow = this.wGame.gui.windowsContainer.getChildren().find(w => w.id == window.id) + if (movedWindow && movedWindow.isReadyForUserInteraction && window.positionInfo && window.position) { + movedWindow.position.x = window.position.x; + movedWindow.position.y = window.position.y; + + movedWindow.rootElement.style.transform = 'translate3d(' + window.position.x + 'px, ' + window.position.y + 'px, 0px) scale(1)'; + } + } + } + + reset() { + localStorage.removeItem("WindowMoved"); + super.reset(); + } +}