mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Optimize mass selector drawing
This commit is contained in:
parent
34ea3c85c9
commit
2f8ac548ad
@ -16,10 +16,13 @@ import { enumHubGoalRewards } from "../../tutorial_goals";
|
|||||||
import { Blueprint } from "../../blueprint";
|
import { Blueprint } from "../../blueprint";
|
||||||
|
|
||||||
const logger = createLogger("hud/mass_selector");
|
const logger = createLogger("hud/mass_selector");
|
||||||
|
var globalTileSizeAdjusted = 0;
|
||||||
|
|
||||||
export class HUDMassSelector extends BaseHUDPart {
|
export class HUDMassSelector extends BaseHUDPart {
|
||||||
|
|
||||||
createElements(parent) {}
|
createElements(parent) {}
|
||||||
|
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
this.currentSelectionStartWorld = null;
|
this.currentSelectionStartWorld = null;
|
||||||
this.currentSelectionEnd = null;
|
this.currentSelectionEnd = null;
|
||||||
@ -41,6 +44,7 @@ export class HUDMassSelector extends BaseHUDPart {
|
|||||||
|
|
||||||
this.root.hud.signals.selectedPlacementBuildingChanged.add(this.clearSelection, this);
|
this.root.hud.signals.selectedPlacementBuildingChanged.add(this.clearSelection, this);
|
||||||
this.root.signals.editModeChanged.add(this.clearSelection, this);
|
this.root.signals.editModeChanged.add(this.clearSelection, this);
|
||||||
|
globalTileSizeAdjusted = globalConfig.tileSize - 2 * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -315,18 +319,20 @@ export class HUDMassSelector extends BaseHUDPart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parameters.context.fillStyle = THEME.map.selectionOverlay;
|
parameters.context.fillStyle = THEME.map.selectionOverlay;
|
||||||
|
parameters.context.beginPath();
|
||||||
this.selectedUids.forEach(uid => {
|
this.selectedUids.forEach(uid => {
|
||||||
const entity = this.root.entityMgr.findByUid(uid);
|
const entity = this.root.entityMgr.findByUid(uid);
|
||||||
const staticComp = entity.components.StaticMapEntity;
|
const staticComp = entity.components.StaticMapEntity;
|
||||||
const bounds = staticComp.getTileSpaceBounds();
|
const bounds = staticComp.getTileSpaceBounds();
|
||||||
parameters.context.beginRoundedRect(
|
// tried writing this in one line: it worked but it was very slow... WHY?
|
||||||
|
parameters.context.fillRect(
|
||||||
bounds.x * globalConfig.tileSize + boundsBorder,
|
bounds.x * globalConfig.tileSize + boundsBorder,
|
||||||
bounds.y * globalConfig.tileSize + boundsBorder,
|
bounds.y * globalConfig.tileSize + boundsBorder,
|
||||||
bounds.w * globalConfig.tileSize - 2 * boundsBorder,
|
bounds.w * globalTileSizeAdjusted,
|
||||||
bounds.h * globalConfig.tileSize - 2 * boundsBorder,
|
bounds.h * globalTileSizeAdjusted, // This seems like microoptimization but on a huuuge scale it makes a difference
|
||||||
2
|
|
||||||
);
|
);
|
||||||
parameters.context.fill();
|
|
||||||
});
|
});
|
||||||
|
parameters.context.closePath(); // +1 fps for some reason
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user