mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-16 11:41:50 +00:00
Fixed Bugs with Multi Layer selecting and global alpha
This commit is contained in:
parent
a4d7284731
commit
ba7bb6cf16
@ -425,7 +425,12 @@ export class GameCore {
|
|||||||
|
|
||||||
root.camera.transform(context);
|
root.camera.transform(context);
|
||||||
|
|
||||||
assert(context.globalAlpha === 1.0, "Global alpha not 1 on frame start");
|
if (context.globalAlpha !== 1.0) {
|
||||||
|
console.warn("Global Alpha not set back to 1 on Frame Begin");
|
||||||
|
context.globalAlpha = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// assert(context.globalAlpha === 1.0, "Global alpha not 1 on frame start");
|
||||||
|
|
||||||
// Update hud
|
// Update hud
|
||||||
root.hud.update();
|
root.hud.update();
|
||||||
|
|||||||
@ -1,24 +1,17 @@
|
|||||||
import { globalConfig } from "../../../core/config";
|
import { formatBigNumberFull } from "../../../core/utils";
|
||||||
import { makeDiv, formatBigNumber, formatBigNumberFull } from "../../../core/utils";
|
|
||||||
import { DynamicDomAttach } from "../dynamic_dom_attach";
|
|
||||||
import { MapChunkView } from "../../map_chunk_view";
|
|
||||||
import { DrawParameters } from "../../../core/draw_parameters";
|
import { DrawParameters } from "../../../core/draw_parameters";
|
||||||
import { gMetaBuildingRegistry } from "../../../core/global_registries";
|
|
||||||
import { createLogger } from "../../../core/logging";
|
import { createLogger } from "../../../core/logging";
|
||||||
import { STOP_PROPAGATION } from "../../../core/signal";
|
import { STOP_PROPAGATION } from "../../../core/signal";
|
||||||
import { Vector } from "../../../core/vector";
|
import { Vector } from "../../../core/vector";
|
||||||
import { ACHIEVEMENTS } from "../../../platform/achievement_provider";
|
import { ACHIEVEMENTS } from "../../../platform/achievement_provider";
|
||||||
import { T } from "../../../translations";
|
import { T } from "../../../translations";
|
||||||
import { Blueprint } from "../../blueprint";
|
import { Blueprint } from "../../blueprint";
|
||||||
import { MetaBlockBuilding } from "../../buildings/block";
|
|
||||||
import { MetaConstantProducerBuilding } from "../../buildings/constant_producer";
|
|
||||||
import { enumMouseButton } from "../../camera";
|
import { enumMouseButton } from "../../camera";
|
||||||
import { Component } from "../../component";
|
import { Component } from "../../component";
|
||||||
import { Entity } from "../../entity";
|
import { Entity } from "../../entity";
|
||||||
import { KEYMAPPINGS } from "../../key_action_mapper";
|
import { KEYMAPPINGS } from "../../key_action_mapper";
|
||||||
import { THEME } from "../../theme";
|
import { THEME } from "../../theme";
|
||||||
import { enumHubGoalRewards } from "../../tutorial_goals";
|
import { enumHubGoalRewards } from "../../tutorial_goals";
|
||||||
import { StaticMapEntityComponent } from "../../components/static_map_entity";
|
|
||||||
import { BaseHUDPart } from "../base_hud_part";
|
import { BaseHUDPart } from "../base_hud_part";
|
||||||
|
|
||||||
const logger = createLogger("hud/mass_selector");
|
const logger = createLogger("hud/mass_selector");
|
||||||
@ -155,13 +148,12 @@ export class HUDMassSelector extends BaseHUDPart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clearBelts() {
|
clearBelts() {
|
||||||
for (const uid of this.selectedUids) {
|
for (const entity of this.selectedEntities) {
|
||||||
const entity = this.root.entityMgr.findByUid(uid);
|
|
||||||
for (const component of Object.values(entity.components)) {
|
for (const component of Object.values(entity.components)) {
|
||||||
/** @type {Component} */ (component).clear();
|
/** @type {Component} */ (component).clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.selectedUids = new Set();
|
this.selectedEntities = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
confirmCut() {
|
confirmCut() {
|
||||||
@ -363,7 +355,7 @@ export class HUDMassSelector extends BaseHUDPart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderedUids.add(uid);
|
renderedUids.add(uid);
|
||||||
this.RenderSelectonPreviewTile(parameters, entity);
|
this.renderSelectonPreviewTile(parameters, entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -373,13 +365,8 @@ export class HUDMassSelector extends BaseHUDPart {
|
|||||||
//EXTREMELY SLOW. There must be a better way. (Possibly use a Array)
|
//EXTREMELY SLOW. There must be a better way. (Possibly use a Array)
|
||||||
for (let i = 0; i < this.selectedEntities.length; ++i) {
|
for (let i = 0; i < this.selectedEntities.length; ++i) {
|
||||||
const entity = this.selectedEntities[i];
|
const entity = this.selectedEntities[i];
|
||||||
this.RenderSelectonPreviewTile(parameters, entity);
|
this.renderSelectonPreviewTile(parameters, entity);
|
||||||
}
|
}
|
||||||
// this.selectedUids.forEach(uid => {
|
|
||||||
// const entity = this.root.entityMgr.findByUid(uid);
|
|
||||||
|
|
||||||
// this.RenderSelectonPreviewTile(parameters, entity);
|
|
||||||
// });
|
|
||||||
|
|
||||||
parameters.context.globalAlpha = 1;
|
parameters.context.globalAlpha = 1;
|
||||||
}
|
}
|
||||||
@ -388,7 +375,7 @@ export class HUDMassSelector extends BaseHUDPart {
|
|||||||
* @param {DrawParameters} parameters
|
* @param {DrawParameters} parameters
|
||||||
* @param {Entity} entity
|
* @param {Entity} entity
|
||||||
*/
|
*/
|
||||||
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.globalAlpha = entity.layer == this.root.currentLayer ? 1 : 0.7;
|
||||||
|
|||||||
@ -38,7 +38,7 @@ export class HUDShapeTooltip extends BaseHUDPart {
|
|||||||
active &&
|
active &&
|
||||||
!this.isPlacingBuilding &&
|
!this.isPlacingBuilding &&
|
||||||
!hudParts.massSelector.currentSelectionStartWorld &&
|
!hudParts.massSelector.currentSelectionStartWorld &&
|
||||||
hudParts.massSelector.selectedUids.size < 1 &&
|
hudParts.massSelector.selectedEntities.length < 1 &&
|
||||||
!hudParts.blueprintPlacer.currentBlueprint.get()
|
!hudParts.blueprintPlacer.currentBlueprint.get()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,5 +118,6 @@ export class MapResourcesSystem extends GameSystem {
|
|||||||
context.fillRect(0, 0, w, 1);
|
context.fillRect(0, 0, w, 1);
|
||||||
context.fillRect(0, 1, 1, h);
|
context.fillRect(0, 1, 1, h);
|
||||||
}
|
}
|
||||||
|
context.globalAlpha = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user