From 1a1d86c784931d80da85290e03b6517ac531bc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Sun, 31 Dec 2023 01:15:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=82=A8=E7=89=A9=E4=BB=93=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E5=99=A8=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/blueprint/parser.ts | 54 +++++++++++++++++------ src/components/BuildingIcon.vue | 3 +- src/components/BuildingInfoPanel.vue | 14 ++---- src/components/StorageInfo.vue | 64 ++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 26 deletions(-) create mode 100644 src/components/StorageInfo.vue diff --git a/src/blueprint/parser.ts b/src/blueprint/parser.ts index 23f7d35..e9daa62 100644 --- a/src/blueprint/parser.ts +++ b/src/blueprint/parser.ts @@ -425,20 +425,48 @@ const tankParamParser: ParamParser = { }, } +export enum StorageType { + DEFAULT = 0, + FILTERED = 9, +} +export interface StorageGrid { + filter: number; +} export interface StorageParameters { - automationLimit: number + automationLimit: number; + type: StorageType; + grids: StorageGrid[]; } -const storageParamParser: ParamParser = { - encodedSize() { return 1; }, - encode(p, a) { - setParam(a, 0, p.automationLimit); - }, - decode(a) { - return { - automationLimit: getParam(a, 0), - }; - }, +function storageParamParser(size: number): ParamParser{ + return { + encodedSize() { + const s = 10 + size; + if (s < 110) + return 110; + return s; + }, + encode(p, a) { + setParam(a, 0, p.automationLimit); + setParam(a, 1, p.type); + for (let i = 0; i < size; i++) { + setParam(a, 10 + i, p.grids[i].filter); + } + }, + decode(a) { + const grids: StorageGrid[] = []; + for (let i = 0; i < size; i++) { + grids.push({ + filter: getParam(a, 10 + i, 0), + }); + } + return { + automationLimit: getParam(a, 0), + type: getParam(a, 1, StorageType.DEFAULT), + grids, + }; + }, + } } export interface EjectorParameters { @@ -631,8 +659,8 @@ const parameterParsers = new Map>([ [2011, inserterParamParser], [2012, inserterParamParser], [2013, inserterParamParser], - [2101, storageParamParser], - [2102, storageParamParser], + [2101, storageParamParser(30)], + [2102, storageParamParser(60)], [2106, tankParamParser], [2311, ejectorParamParser], [2208, powerGeneratorParamParser], diff --git a/src/components/BuildingIcon.vue b/src/components/BuildingIcon.vue index 39a026a..fdfbf0b 100644 --- a/src/components/BuildingIcon.vue +++ b/src/components/BuildingIcon.vue @@ -26,7 +26,6 @@ watchEffect(async () => { .icon { display: inline-block; position: relative; - height: 2.5rem; width: 2.5rem; &.has-count { @@ -34,8 +33,8 @@ watchEffect(async () => { } img { - height: 100%; width: 100%; + display: block; } .count { diff --git a/src/components/BuildingInfoPanel.vue b/src/components/BuildingInfoPanel.vue index 0f7669c..1e8d917 100644 --- a/src/components/BuildingInfoPanel.vue +++ b/src/components/BuildingInfoPanel.vue @@ -5,6 +5,7 @@ +
@@ -22,10 +23,6 @@ {{ (bParams as InserterParameters).length }}
-
- - {{ capacityForAutomation }} -