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-datasource="produced"] .modeProduced,
&[data-datasource="delivered"] .modeDelivered,
&[data-datasource="stored"] .modeStored,
&[data-datasource="deliveredToStorage"] .modeDeliveredtostorage {
&[data-datasource="stored"] .modeStored {
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 { BaseHUDPart } from "../base_hud_part";
import { DynamicDomAttach } from "../dynamic_dom_attach";
import {
enumDisplayMode,
HUDShapeStatisticsHandle,
HUDShapeStatisticsStorageHandle,
} from "./statistics_handle";
import { enumDisplayMode, HUDShapeStatisticsHandle } from "./statistics_handle";
import { T } from "../../../translations";
export class HUDStatistics extends BaseHUDPart {
@ -31,7 +27,6 @@ export class HUDStatistics extends BaseHUDPart {
enumAnalyticsDataSource.produced,
enumAnalyticsDataSource.delivered,
enumAnalyticsDataSource.stored,
enumAnalyticsDataSource.deliveredToStorage,
];
for (let i = 0; i < dataSources.length; ++i) {
@ -173,8 +168,7 @@ export class HUDStatistics extends BaseHUDPart {
break;
}
case enumAnalyticsDataSource.produced:
case enumAnalyticsDataSource.delivered:
case enumAnalyticsDataSource.deliveredToStorage: {
case enumAnalyticsDataSource.delivered: {
entries = Object.entries(this.root.productionAnalytics.getCurrentShapeRates(this.dataSource));
break;
}
@ -190,20 +184,12 @@ export class HUDStatistics extends BaseHUDPart {
let handle = this.activeHandles[shapeKey];
if (!handle) {
if (this.dataSource === enumAnalyticsDataSource.deliveredToStorage) {
const [uid, shape] = shapeKey.split(",");
const definition = this.root.shapeDefinitionMgr.getShapeFromShortKey(shape);
handle = new HUDShapeStatisticsStorageHandle(
this.root,
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;
const definition = this.root.shapeDefinitionMgr.getShapeFromShortKey(shapeKey);
handle = this.activeHandles[shapeKey] = new HUDShapeStatisticsHandle(
this.root,
definition,
this.intersectionObserver
);
}
rendered.add(shapeKey);

View File

@ -5,7 +5,6 @@ import { T } from "../../../translations";
import { enumAnalyticsDataSource } from "../../production_analytics";
import { GameRoot } from "../../root";
import { ShapeDefinition } from "../../shape_definition";
import { ClickDetector } from "../../../core/click_detector";
/** @enum {string} */
export const enumDisplayMode = {
@ -30,19 +29,13 @@ export class HUDShapeStatisticsHandle {
this.visible = false;
}
get shapeKey() {
return this.definition.getHash();
}
initElement() {
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.classList.add("counter");
this.element.appendChild(this.counter);
this.canvasElement = this.element;
}
/**
@ -59,7 +52,7 @@ export class HUDShapeStatisticsHandle {
// Create elements
this.shapeCanvas = this.definition.generateAsCanvas(100);
this.shapeCanvas.classList.add("icon");
this.canvasElement.appendChild(this.shapeCanvas);
this.element.appendChild(this.shapeCanvas);
}
} else {
// Drop elements
@ -83,12 +76,13 @@ export class HUDShapeStatisticsHandle {
switch (dataSource) {
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;
}
case enumAnalyticsDataSource.delivered:
case enumAnalyticsDataSource.produced:
case enumAnalyticsDataSource.deliveredToStorage: {
case enumAnalyticsDataSource.produced: {
let rate =
(this.root.productionAnalytics.getCurrentShapeRate(dataSource, this.shapeKey) /
globalConfig.analyticsSliceDurationSeconds) *
@ -116,7 +110,7 @@ export class HUDShapeStatisticsHandle {
const [canvas, context] = makeOffscreenBuffer(w * graphDpi, h * graphDpi, {
smooth: true,
reusable: false,
label: "statgraph-" + this.shapeKey,
label: "statgraph-" + this.definition.getHash(),
});
context.scale(graphDpi, graphDpi);
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:
title: Delivered
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.
# Displays the shapes per minute, e.g. '523 / m'

View File

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