From 26f7ccbe411339659fee2f79439027d5f812ffae Mon Sep 17 00:00:00 2001 From: isaisstillalive Date: Wed, 1 Jul 2020 20:52:30 +0900 Subject: [PATCH] Revert "Add Stored in Storage Tab to Statistics" --- src/css/ingame_hud/statistics.scss | 26 +-------- src/js/game/hud/parts/statistics.js | 30 +++------- src/js/game/hud/parts/statistics_handle.js | 65 +++------------------- translations/base-en.yaml | 3 - translations/base-ja.yaml | 3 - 5 files changed, 16 insertions(+), 111 deletions(-) diff --git a/src/css/ingame_hud/statistics.scss b/src/css/ingame_hud/statistics.scss index b84f63be..e53a80d1 100644 --- a/src/css/ingame_hud/statistics.scss +++ b/src/css/ingame_hud/statistics.scss @@ -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; - } - } - } } } diff --git a/src/js/game/hud/parts/statistics.js b/src/js/game/hud/parts/statistics.js index fce3feba..4a3b75f5 100644 --- a/src/js/game/hud/parts/statistics.js +++ b/src/js/game/hud/parts/statistics.js @@ -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); diff --git a/src/js/game/hud/parts/statistics_handle.js b/src/js/game/hud/parts/statistics_handle.js index e876b649..411814e6 100644 --- a/src/js/game/hud/parts/statistics_handle.js +++ b/src/js/game/hud/parts/statistics_handle.js @@ -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) - ); - }); - } -} diff --git a/translations/base-en.yaml b/translations/base-en.yaml index e789f692..db806a09 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -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' diff --git a/translations/base-ja.yaml b/translations/base-ja.yaml index 8bffec59..500238db 100644 --- a/translations/base-ja.yaml +++ b/translations/base-ja.yaml @@ -352,9 +352,6 @@ ingame: delivered: title: 納品済 description: 中央の建造物に納品された形の総数です。 - deliveredToStorage: - title: 格納庫 - description: 格納庫に納品された形の総数です。 noShapesProduced: まだ形が生産されていません。 # Displays the shapes per minute, e.g. '523 / m'