1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-09 08:11:51 +00:00

Some Sprite Changes

This commit is contained in:
TcePrepK 2020-10-29 21:08:29 +03:00
parent 1eb3cae5cd
commit 298a0aa20d
13 changed files with 109 additions and 61 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 364 KiB

After

Width:  |  Height:  |  Size: 291 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 364 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -123,11 +123,11 @@ export class AtlasSprite extends BaseSprite {
* @param {DrawParameters} parameters
* @param {number} x
* @param {number} y
* @param {number} size
* @param {number} size_x
* @param {boolean=} clipping
*/
drawCachedCentered(parameters, x, y, size, clipping = true) {
this.drawCached(parameters, x - size / 2, y - size / 2, size, size, clipping);
drawCachedCentered(parameters, x, y, size_x, clipping = true) {
this.drawCached(parameters, x - size_x / 2, y - size_x / 2, size_x, size_x, clipping);
}
/**

View File

@ -31,7 +31,7 @@ export class MetaWirelessDisplayBuilding extends MetaBuilding {
* @param {GameRoot} root
*/
getIsUnlocked(root) {
return true //root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_display);
return root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_display);
}
/**

View File

@ -14,6 +14,7 @@ import { KEYMAPPINGS } from "../../key_action_mapper";
import { THEME } from "../../theme";
import { enumHubGoalRewards } from "../../tutorial_goals";
import { Blueprint } from "../../blueprint";
import { drawRotatedSprite } from "../../../core/draw_utils";
const logger = createLogger("hud/mass_selector");
@ -304,16 +305,9 @@ export class HUDMassSelector extends BaseHUDPart {
renderedUids.add(uid);
const staticComp = contents.components.StaticMapEntity;
const bounds = staticComp.getTileSpaceBounds();
parameters.context.beginRoundedRect(
bounds.x * globalConfig.tileSize + boundsBorder,
bounds.y * globalConfig.tileSize + boundsBorder,
bounds.w * globalConfig.tileSize - 2 * boundsBorder,
bounds.h * globalConfig.tileSize - 2 * boundsBorder,
2
);
parameters.context.fill();
staticComp.drawSpriteOnBoundsClipped(parameters, staticComp.getBlueprintSprite(), 0);
}
parameters.context.globalAlpha = 1;
}
}
}
@ -322,15 +316,8 @@ export class HUDMassSelector extends BaseHUDPart {
this.selectedUids.forEach(uid => {
const entity = this.root.entityMgr.findByUid(uid);
const staticComp = entity.components.StaticMapEntity;
const bounds = staticComp.getTileSpaceBounds();
parameters.context.beginRoundedRect(
bounds.x * globalConfig.tileSize + boundsBorder,
bounds.y * globalConfig.tileSize + boundsBorder,
bounds.w * globalConfig.tileSize - 2 * boundsBorder,
bounds.h * globalConfig.tileSize - 2 * boundsBorder,
2
);
parameters.context.fill();
staticComp.drawSpriteOnBoundsClipped(parameters, staticComp.getBlueprintSprite(), 0);
});
}
}

View File

@ -11,6 +11,7 @@ import { MetaComparatorBuilding } from "../../buildings/comparator";
import { MetaReaderBuilding } from "../../buildings/reader";
import { MetaFilterBuilding } from "../../buildings/filter";
import { MetaDisplayBuilding } from "../../buildings/display";
import { MetaWirelessDisplayBuilding } from "../../buildings/wireless_display";
import { MetaStorageBuilding } from "../../buildings/storage";
export class HUDWiresToolbar extends HUDBaseToolbar {
@ -32,6 +33,7 @@ export class HUDWiresToolbar extends HUDBaseToolbar {
MetaLeverBuilding,
MetaFilterBuilding,
MetaDisplayBuilding,
MetaWirelessDisplayBuilding,
],
visibilityCondition: () =>
!this.root.camera.getIsMapOverlayActive() && this.root.currentLayer === "wires",

View File

@ -14,6 +14,7 @@ import { fillInLinkIntoTranslation } from "../../core/utils";
import { T } from "../../translations";
import { Entity } from "../entity";
import { WirelessCodeComponent } from "../components/wireless_code";
import { THEME} from "../theme";
export class WirelessDisplaySystem extends GameSystemWithFilter {
constructor(root) {
@ -47,6 +48,7 @@ export class WirelessDisplaySystem extends GameSystemWithFilter {
}
this.entityCount = this.allEntities.length;
}
const mousePos = this.root.app.mousePosition;
}
/**
@ -159,6 +161,48 @@ export class WirelessDisplaySystem extends GameSystemWithFilter {
}
}
/**
* Computes the color below the current tile
* @returns {number}
*/
computeColorBelowTile() {
const mousePosition = this.root.app.mousePosition;
if (!mousePosition) {
// Not on screen
return null;
}
const worldPos = this.root.camera.screenToWorld(mousePosition);
const tile = worldPos.toTileSpace();
const contents = this.root.map.getTileContent(tile, "regular");
if (contents && contents.components.WirelessDisplay) {
// We hovered a lower layer, show the color there
if (contents && contents.components.WirelessCode && contents.components.WirelessCode.wireless_code) {
return contents.components.WirelessCode.wireless_code;
}
}
return null;
}
/**
* Draws Text Storked
* @param {string} text
* @param {number} y
* @param {number} x
* @param {number=} width
*/
drawStroked(ctx, text, x, y, width = undefined) {
ctx.font = '15px Sans-serif';
ctx.strokeStyle = 'black';
ctx.lineWidth = 1;
ctx.miterLimit=2
ctx.strokeText(text, x, y, width);
ctx.fillStyle = 'white';
ctx.fillText(text, x, y, width);
}
/**
* Draws a given chunk
* @param {import("../../core/draw_utils").DrawParameters} parameters
@ -168,7 +212,21 @@ export class WirelessDisplaySystem extends GameSystemWithFilter {
const contents = chunk.containedEntitiesByLayer.regular;
for (let i = 0; i < contents.length; ++i) {
const entity_a = contents[i];
if (entity_a && !entity_a.components.WiredPins && entity_a.components.WirelessDisplay && entity_a.components.WirelessCode) {
if (entity_a && entity_a.components.WirelessDisplay) {
const below = this.computeColorBelowTile();
if (below) {
// We have something below our tile
const mousePosition = this.root.app.mousePosition;
const worldPos = this.root.camera.screenToWorld(mousePosition);
const tile = worldPos.toTileSpace().toWorldSpace();
this.drawStroked(parameters.context, below.toString(), worldPos.x + 5, worldPos.y + 5)
parameters.context.strokeStyle = THEME.map.colorBlindPickerTile;
parameters.context.beginPath();
parameters.context.rect(tile.x, tile.y, globalConfig.tileSize, globalConfig.tileSize);
parameters.context.stroke();
}
if (!entity_a.components.WiredPins) {
const entity_b = this.wirelessMachineList[entity_a.components.WirelessCode["wireless_code"]];
if (entity_b) {
if (!this.allEntities.includes(entity_b)) {
@ -211,4 +269,5 @@ export class WirelessDisplaySystem extends GameSystemWithFilter {
}
}
}
}

View File

@ -706,10 +706,10 @@ buildings:
wireless_display:
default:
name: &wireless_display Wireless Display
description: Connect a signal to show it on the display - It can be a shape, color or boolean.
description: Connect to a channel and if channel connects, it receives the signal coming from Remote Control - Signal can be a shape, color or boolean.
remote_control:
name: OR Gate
description: Emits a boolean "1" if one of the inputs is truthy. (Truthy means shape, color or boolean "1")
name: Remote Control
description: Connect to a channel and if channel connects, it emits signal to Wireless Control - Signal can be a shape, color or boolean.
reader:
default: