mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-09 08:11:51 +00:00
Added Rendering of Shapes and Changed Control
This commit is contained in:
parent
55f218b81f
commit
27ebf23472
@ -23,6 +23,7 @@ export class HUDMassSelector extends BaseHUDPart {
|
|||||||
createElements(parent) {}
|
createElements(parent) {}
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
|
this.multiLayerSelect = false;
|
||||||
this.currentSelectionStartWorld = null;
|
this.currentSelectionStartWorld = null;
|
||||||
this.currentSelectionEnd = null;
|
this.currentSelectionEnd = null;
|
||||||
this.selectedUids = new Set();
|
this.selectedUids = new Set();
|
||||||
@ -212,6 +213,10 @@ export class HUDMassSelector extends BaseHUDPart {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.multiLayerSelect = this.root.keyMapper.getBinding(
|
||||||
|
KEYMAPPINGS.massSelect.massSelectSelectMultiLayer
|
||||||
|
).pressed;
|
||||||
|
|
||||||
if (!this.root.keyMapper.getBinding(KEYMAPPINGS.massSelect.massSelectSelectMultiple).pressed) {
|
if (!this.root.keyMapper.getBinding(KEYMAPPINGS.massSelect.massSelectSelectMultiple).pressed) {
|
||||||
// Start new selection
|
// Start new selection
|
||||||
this.selectedUids = new Set();
|
this.selectedUids = new Set();
|
||||||
@ -246,10 +251,7 @@ export class HUDMassSelector extends BaseHUDPart {
|
|||||||
for (let x = realTileStart.x; x <= realTileEnd.x; ++x) {
|
for (let x = realTileStart.x; x <= realTileEnd.x; ++x) {
|
||||||
for (let y = realTileStart.y; y <= realTileEnd.y; ++y) {
|
for (let y = realTileStart.y; y <= realTileEnd.y; ++y) {
|
||||||
let entities = [];
|
let entities = [];
|
||||||
if (
|
if (this.multiLayerSelect) {
|
||||||
this.root.keyMapper.getBinding(KEYMAPPINGS.massSelect.massSelectSelectMultiLayer)
|
|
||||||
.pressed
|
|
||||||
) {
|
|
||||||
entities = this.root.map.getLayersContentsMultipleXY(x, y);
|
entities = this.root.map.getLayersContentsMultipleXY(x, y);
|
||||||
} else {
|
} else {
|
||||||
entities = [this.root.map.getLayerContentXY(x, y, this.root.currentLayer)];
|
entities = [this.root.map.getLayerContentXY(x, y, this.root.currentLayer)];
|
||||||
@ -273,6 +275,10 @@ export class HUDMassSelector extends BaseHUDPart {
|
|||||||
* @param {DrawParameters} parameters
|
* @param {DrawParameters} parameters
|
||||||
*/
|
*/
|
||||||
draw(parameters) {
|
draw(parameters) {
|
||||||
|
this.multiLayerSelect =
|
||||||
|
this.root.keyMapper.getBinding(KEYMAPPINGS.massSelect.massSelectSelectMultiLayer).pressed ||
|
||||||
|
this.multiLayerSelect;
|
||||||
|
|
||||||
if (this.currentSelectionStartWorld) {
|
if (this.currentSelectionStartWorld) {
|
||||||
const worldStart = this.currentSelectionStartWorld;
|
const worldStart = this.currentSelectionStartWorld;
|
||||||
const worldEnd = this.root.camera.screenToWorld(this.currentSelectionEnd);
|
const worldEnd = this.root.camera.screenToWorld(this.currentSelectionEnd);
|
||||||
@ -301,14 +307,10 @@ export class HUDMassSelector extends BaseHUDPart {
|
|||||||
|
|
||||||
const renderedUids = new Set();
|
const renderedUids = new Set();
|
||||||
|
|
||||||
const isMultiLayerPressed = this.root.keyMapper.getBinding(
|
|
||||||
KEYMAPPINGS.massSelect.massSelectSelectMultiLayer
|
|
||||||
).pressed;
|
|
||||||
|
|
||||||
for (let x = realTileStart.x; x <= realTileEnd.x; ++x) {
|
for (let x = realTileStart.x; x <= realTileEnd.x; ++x) {
|
||||||
for (let y = realTileStart.y; y <= realTileEnd.y; ++y) {
|
for (let y = realTileStart.y; y <= realTileEnd.y; ++y) {
|
||||||
let entities = [];
|
let entities = [];
|
||||||
if (isMultiLayerPressed) {
|
if (this.multiLayerSelect) {
|
||||||
entities = this.root.map.getLayersContentsMultipleXY(x, y);
|
entities = this.root.map.getLayersContentsMultipleXY(x, y);
|
||||||
} else {
|
} else {
|
||||||
entities = [this.root.map.getLayerContentXY(x, y, this.root.currentLayer)];
|
entities = [this.root.map.getLayerContentXY(x, y, this.root.currentLayer)];
|
||||||
@ -330,12 +332,15 @@ export class HUDMassSelector extends BaseHUDPart {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//EXTREMELY SLOW. There must be a better way. (Possibly use a Array)wa
|
|
||||||
|
//EXTREMELY SLOW. There must be a better way. (Possibly use a Array)
|
||||||
this.selectedUids.forEach(uid => {
|
this.selectedUids.forEach(uid => {
|
||||||
const entity = this.root.entityMgr.findByUid(uid);
|
const entity = this.root.entityMgr.findByUid(uid);
|
||||||
|
|
||||||
this.RenderSelectonPreviewTile(parameters, entity);
|
this.RenderSelectonPreviewTile(parameters, entity);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
parameters.context.globalAlpha = 1;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -345,6 +350,8 @@ export class HUDMassSelector extends BaseHUDPart {
|
|||||||
RenderSelectonPreviewTile(parameters, entity) {
|
RenderSelectonPreviewTile(parameters, entity) {
|
||||||
const staticComp = entity.components.StaticMapEntity;
|
const staticComp = entity.components.StaticMapEntity;
|
||||||
|
|
||||||
|
parameters.context.globalAlpha = entity.layer == this.root.currentLayer ? 1 : 0.7;
|
||||||
|
|
||||||
parameters.context.beginPath();
|
parameters.context.beginPath();
|
||||||
|
|
||||||
staticComp.drawSpriteOnBoundsClipped(parameters, staticComp.getBlueprintSprite(), 0);
|
staticComp.drawSpriteOnBoundsClipped(parameters, staticComp.getBlueprintSprite(), 0);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user