1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

Revert "Add Stored in Storage Tab to Statistics"

This commit is contained in:
isaisstillalive 2020-07-01 20:52:30 +09:00
parent b9c7d167e3
commit 26f7ccbe41
5 changed files with 16 additions and 111 deletions

View File

@ -111,8 +111,7 @@
&[data-displaymode="icons"] .displayIcons, &[data-displaymode="icons"] .displayIcons,
&[data-datasource="produced"] .modeProduced, &[data-datasource="produced"] .modeProduced,
&[data-datasource="delivered"] .modeDelivered, &[data-datasource="delivered"] .modeDelivered,
&[data-datasource="stored"] .modeStored, &[data-datasource="stored"] .modeStored {
&[data-datasource="deliveredToStorage"] .modeDeliveredtostorage {
opacity: 1; opacity: 1;
} }
@ -166,28 +165,5 @@
} }
} }
} }
.shape {
position: relative;
button.moveButton {
@include S(width, 11px);
@include S(height, 11px);
background: uiResource("icons/waypoint.png") center center / 95% no-repeat;
position: absolute;
@include S(top, 29px);
@include S(right, -11px);
opacity: 0.5;
cursor: pointer;
pointer-events: all;
@include IncreasedClickArea(5px);
transition: opacity 0.12s ease-in-out;
@include DarkThemeInvert;
&:hover {
opacity: 0.6;
}
}
}
} }
} }

View File

@ -4,11 +4,7 @@ import { KeyActionMapper, KEYMAPPINGS } from "../../key_action_mapper";
import { enumAnalyticsDataSource } from "../../production_analytics"; import { enumAnalyticsDataSource } from "../../production_analytics";
import { BaseHUDPart } from "../base_hud_part"; import { BaseHUDPart } from "../base_hud_part";
import { DynamicDomAttach } from "../dynamic_dom_attach"; import { DynamicDomAttach } from "../dynamic_dom_attach";
import { import { enumDisplayMode, HUDShapeStatisticsHandle } from "./statistics_handle";
enumDisplayMode,
HUDShapeStatisticsHandle,
HUDShapeStatisticsStorageHandle,
} from "./statistics_handle";
import { T } from "../../../translations"; import { T } from "../../../translations";
export class HUDStatistics extends BaseHUDPart { export class HUDStatistics extends BaseHUDPart {
@ -31,7 +27,6 @@ export class HUDStatistics extends BaseHUDPart {
enumAnalyticsDataSource.produced, enumAnalyticsDataSource.produced,
enumAnalyticsDataSource.delivered, enumAnalyticsDataSource.delivered,
enumAnalyticsDataSource.stored, enumAnalyticsDataSource.stored,
enumAnalyticsDataSource.deliveredToStorage,
]; ];
for (let i = 0; i < dataSources.length; ++i) { for (let i = 0; i < dataSources.length; ++i) {
@ -173,8 +168,7 @@ export class HUDStatistics extends BaseHUDPart {
break; break;
} }
case enumAnalyticsDataSource.produced: case enumAnalyticsDataSource.produced:
case enumAnalyticsDataSource.delivered: case enumAnalyticsDataSource.delivered: {
case enumAnalyticsDataSource.deliveredToStorage: {
entries = Object.entries(this.root.productionAnalytics.getCurrentShapeRates(this.dataSource)); entries = Object.entries(this.root.productionAnalytics.getCurrentShapeRates(this.dataSource));
break; break;
} }
@ -190,20 +184,12 @@ export class HUDStatistics extends BaseHUDPart {
let handle = this.activeHandles[shapeKey]; let handle = this.activeHandles[shapeKey];
if (!handle) { if (!handle) {
if (this.dataSource === enumAnalyticsDataSource.deliveredToStorage) { const definition = this.root.shapeDefinitionMgr.getShapeFromShortKey(shapeKey);
const [uid, shape] = shapeKey.split(","); handle = this.activeHandles[shapeKey] = new HUDShapeStatisticsHandle(
const definition = this.root.shapeDefinitionMgr.getShapeFromShortKey(shape); this.root,
handle = new HUDShapeStatisticsStorageHandle( definition,
this.root, this.intersectionObserver
Number.parseInt(uid), );
definition,
this.intersectionObserver
);
} else {
const definition = this.root.shapeDefinitionMgr.getShapeFromShortKey(shapeKey);
handle = new HUDShapeStatisticsHandle(this.root, definition, this.intersectionObserver);
}
this.activeHandles[shapeKey] = handle;
} }
rendered.add(shapeKey); rendered.add(shapeKey);

View File

@ -5,7 +5,6 @@ import { T } from "../../../translations";
import { enumAnalyticsDataSource } from "../../production_analytics"; import { enumAnalyticsDataSource } from "../../production_analytics";
import { GameRoot } from "../../root"; import { GameRoot } from "../../root";
import { ShapeDefinition } from "../../shape_definition"; import { ShapeDefinition } from "../../shape_definition";
import { ClickDetector } from "../../../core/click_detector";
/** @enum {string} */ /** @enum {string} */
export const enumDisplayMode = { export const enumDisplayMode = {
@ -30,19 +29,13 @@ export class HUDShapeStatisticsHandle {
this.visible = false; this.visible = false;
} }
get shapeKey() {
return this.definition.getHash();
}
initElement() { initElement() {
this.element = document.createElement("div"); this.element = document.createElement("div");
this.element.setAttribute("data-shape-key", this.shapeKey); this.element.setAttribute("data-shape-key", this.definition.getHash());
this.counter = document.createElement("span"); this.counter = document.createElement("span");
this.counter.classList.add("counter"); this.counter.classList.add("counter");
this.element.appendChild(this.counter); this.element.appendChild(this.counter);
this.canvasElement = this.element;
} }
/** /**
@ -59,7 +52,7 @@ export class HUDShapeStatisticsHandle {
// Create elements // Create elements
this.shapeCanvas = this.definition.generateAsCanvas(100); this.shapeCanvas = this.definition.generateAsCanvas(100);
this.shapeCanvas.classList.add("icon"); this.shapeCanvas.classList.add("icon");
this.canvasElement.appendChild(this.shapeCanvas); this.element.appendChild(this.shapeCanvas);
} }
} else { } else {
// Drop elements // Drop elements
@ -83,12 +76,13 @@ export class HUDShapeStatisticsHandle {
switch (dataSource) { switch (dataSource) {
case enumAnalyticsDataSource.stored: { case enumAnalyticsDataSource.stored: {
this.counter.innerText = formatBigNumber(this.root.hubGoals.storedShapes[this.shapeKey] || 0); this.counter.innerText = formatBigNumber(
this.root.hubGoals.storedShapes[this.definition.getHash()] || 0
);
break; break;
} }
case enumAnalyticsDataSource.delivered: case enumAnalyticsDataSource.delivered:
case enumAnalyticsDataSource.produced: case enumAnalyticsDataSource.produced: {
case enumAnalyticsDataSource.deliveredToStorage: {
let rate = let rate =
(this.root.productionAnalytics.getCurrentShapeRate(dataSource, this.shapeKey) / (this.root.productionAnalytics.getCurrentShapeRate(dataSource, this.shapeKey) /
globalConfig.analyticsSliceDurationSeconds) * globalConfig.analyticsSliceDurationSeconds) *
@ -116,7 +110,7 @@ export class HUDShapeStatisticsHandle {
const [canvas, context] = makeOffscreenBuffer(w * graphDpi, h * graphDpi, { const [canvas, context] = makeOffscreenBuffer(w * graphDpi, h * graphDpi, {
smooth: true, smooth: true,
reusable: false, reusable: false,
label: "statgraph-" + this.shapeKey, label: "statgraph-" + this.definition.getHash(),
}); });
context.scale(graphDpi, graphDpi); context.scale(graphDpi, graphDpi);
canvas.classList.add("graph"); canvas.classList.add("graph");
@ -230,48 +224,3 @@ export class HUDShapeStatisticsHandle {
} }
} }
} }
export class HUDShapeStatisticsStorageHandle extends HUDShapeStatisticsHandle {
/**
* @param {GameRoot} root
* @param {number} uid
* @param {ShapeDefinition} definition
* @param {IntersectionObserver} intersectionObserver
*/
constructor(root, uid, definition, intersectionObserver) {
super(root, definition, intersectionObserver);
this.uid = uid;
}
get shapeKey() {
return this.uid.toString() + "," + this.definition.getHash();
}
initElement() {
super.initElement();
this.canvasElement = document.createElement("div");
this.canvasElement.classList.add("shape");
this.element.appendChild(this.canvasElement);
// Show small move icon
const moveButton = document.createElement("button");
moveButton.classList.add("moveButton");
this.canvasElement.appendChild(moveButton);
const infoDetector = new ClickDetector(moveButton, {
consumeEvents: true,
preventDefault: true,
targetOnly: true,
});
infoDetector.click.add(() => {
const entity = this.root.entityMgr.findByUid(this.uid);
const position = entity.components.StaticMapEntity.origin;
this.root.camera.setDesiredCenter(position.toWorldSpace());
this.root.camera.setDesiredZoom(
Math.max(this.root.camera.zoomLevel, globalConfig.mapChunkOverviewMinZoom + 0.05)
);
});
}
}

View File

@ -363,9 +363,6 @@ ingame:
delivered: delivered:
title: Delivered title: Delivered
description: Displaying shapes which are delivered to your central building. description: Displaying shapes which are delivered to your central building.
deliveredToStorage:
title: Storage
description: Displaying shapes which are delivered to your storages.
noShapesProduced: No shapes have been produced so far. noShapesProduced: No shapes have been produced so far.
# Displays the shapes per minute, e.g. '523 / m' # Displays the shapes per minute, e.g. '523 / m'

View File

@ -352,9 +352,6 @@ ingame:
delivered: delivered:
title: 納品済 title: 納品済
description: 中央の建造物に納品された形の総数です。 description: 中央の建造物に納品された形の総数です。
deliveredToStorage:
title: 格納庫
description: 格納庫に納品された形の総数です。
noShapesProduced: まだ形が生産されていません。 noShapesProduced: まだ形が生産されていません。
# Displays the shapes per minute, e.g. '523 / m' # Displays the shapes per minute, e.g. '523 / m'