Merge pull request #74 from Dimava/extract/selection-world-relative

Make selection relative to world
This commit is contained in:
tobspr 2020-06-12 19:01:00 +02:00 committed by GitHub
commit cc9813bf0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -40,7 +40,7 @@ export class HUDMassSelector extends BaseHUDPart {
initialize() {
this.deletionMarker = Loader.getSprite("sprites/misc/deletion_marker.png");
this.currentSelectionStart = null;
this.currentSelectionStartWorld = null;
this.currentSelectionEnd = null;
this.selectedUids = new Set();
@ -146,7 +146,7 @@ export class HUDMassSelector extends BaseHUDPart {
this.selectedUids = new Set();
}
this.currentSelectionStart = pos.copy();
this.currentSelectionStartWorld = this.root.camera.screenToWorld(pos.copy());
this.currentSelectionEnd = pos.copy();
return STOP_PROPAGATION;
}
@ -156,14 +156,14 @@ export class HUDMassSelector extends BaseHUDPart {
* @param {Vector} pos
*/
onMouseMove(pos) {
if (this.currentSelectionStart) {
if (this.currentSelectionStartWorld) {
this.currentSelectionEnd = pos.copy();
}
}
onMouseUp() {
if (this.currentSelectionStart) {
const worldStart = this.root.camera.screenToWorld(this.currentSelectionStart);
if (this.currentSelectionStartWorld) {
const worldStart = this.currentSelectionStartWorld;
const worldEnd = this.root.camera.screenToWorld(this.currentSelectionEnd);
const tileStart = worldStart.toTileSpace();
@ -181,7 +181,7 @@ export class HUDMassSelector extends BaseHUDPart {
}
}
this.currentSelectionStart = null;
this.currentSelectionStartWorld = null;
this.currentSelectionEnd = null;
}
}
@ -197,8 +197,8 @@ export class HUDMassSelector extends BaseHUDPart {
draw(parameters) {
const boundsBorder = 2;
if (this.currentSelectionStart) {
const worldStart = this.root.camera.screenToWorld(this.currentSelectionStart);
if (this.currentSelectionStartWorld) {
const worldStart = this.currentSelectionStartWorld;
const worldEnd = this.root.camera.screenToWorld(this.currentSelectionEnd);
const realWorldStart = worldStart.min(worldEnd);