Skip to content

Commit

Permalink
流速器国际化 & 生成物品参数
Browse files Browse the repository at this point in the history
  • Loading branch information
huww98 committed Dec 30, 2023
1 parent 25e29cc commit be0e8b5
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 60 deletions.
10 changes: 10 additions & 0 deletions src/blueprint/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,11 @@ const energyExchangerParamParser: ParamParser<EnergyExchangerParameters> = {
},
}

export enum SpawnItemOperator {
NONE = 0,
GENERATE = 1,
CONSUME = 2,
}
export interface MonitorParameters {
targetBeltId: number;
offset: number;
Expand All @@ -532,6 +537,7 @@ export interface MonitorParameters {
repeat: boolean;
length: number;
falloffRadius: [number, number];
spawnItemOperator: SpawnItemOperator;
}

const MonitorParamParser: ParamParser<MonitorParameters> = {
Expand All @@ -557,6 +563,8 @@ const MonitorParamParser: ParamParser<MonitorParameters> = {
setParam(a, 10, p.systemWarningMode);
setParam(a, 17, p.systemWarningIconId);
setParam(a, 12, p.alarmMode);

setParam(a, 20, p.spawnItemOperator);
},
decode(a) {
return {
Expand All @@ -579,6 +587,8 @@ const MonitorParamParser: ParamParser<MonitorParameters> = {
systemWarningMode: getParam(a, 10),
systemWarningIconId: getParam(a, 17),
alarmMode: getParam(a, 12),

spawnItemOperator: getParam(a, 20),
}
}
}
Expand Down
132 changes: 74 additions & 58 deletions src/components/MonitorInfo.vue
Original file line number Diff line number Diff line change
@@ -1,80 +1,83 @@
<template>
<section>
<h3>监测设置</h3>
<div class="building-params">
<div><label>监测周期</label><span class="v">{{(p.periodTicksCount / 60).toLocaleString([], { minimumFractionDigits: 2, maximumFractionDigits: 2 })}} 秒</span></div>
<div><label>目标流量</label><span class="v">{{(p.targetCargoAmount / 10).toLocaleString([], { minimumFractionDigits: 1, maximumFractionDigits: 1 })}} 个</span></div>
<div class="r">
<div class="p" style="margin-inline-end: auto;"><label>监测条件</label><span class="v">{{operator}}</span></div>
<div class="p"><span class="v"><ColorPreview :color-id="p.passColorId"/></span><label>满足</label></div>
<div class="p"><span class="v"><ColorPreview :color-id="p.failColorId"/></span><label>不满足</label></div>
</div>
<div>
<label>货物过滤</label>
<span class="v">
<BuildingIcon v-if="p.cargoFilter > 0" :icon-id="itemIconId(p.cargoFilter)" />
<span v-else>无</span>
</span>
</div>
<div class="building-params">
<h3>{{t('监测设置')}}</h3>
<div><label>{{t('监测周期')}}</label><span class="v">{{(p.periodTicksCount / 60).toLocaleString([], { minimumFractionDigits: 2, maximumFractionDigits: 2 })}}{{ t('周期秒') }}</span></div>
<div><label>{{t('目标流量')}}</label><span class="v">{{(p.targetCargoAmount / 10).toLocaleString([], { minimumFractionDigits: 1, maximumFractionDigits: 1 })}}{{ t('货物个') }}</span></div>
<div class="r">
<div class="p" style="margin-inline-end: auto;"><label>{{t('监测条件')}}</label><span class="v">{{operator}}</span></div>
<div class="p"><span class="v"><ColorPreview :color-id="p.passColorId"/></span><label>{{t('满足')}}</label></div>
<div class="p"><span class="v"><ColorPreview :color-id="p.failColorId"/></span><label>{{t('不满足')}}</label></div>
</div>
</section>
<section>
<h3>警报设置</h3>
<div class="building-params">
<div><label>系统警报</label><span class="v">{{systemWarningMode}}</span></div>
<div v-if="p.systemWarningMode > 0">
<label>警报图标</label>
<span class="v"><BuildingIcon :icon-id="p.systemWarningIconId" /></span>
</div>
<div><label>声音警报</label><span class="v">{{alarmMode}}</span></div>
<div>
<label>{{t('货物过滤')}}</label>
<span class="v">
<BuildingIcon v-if="p.cargoFilter > 0" :icon-id="itemIconId(p.cargoFilter)" />
<span v-else>无</span>
</span>
</div>
</section>
<section v-if="p.alarmMode > 0">
<div class="building-params">
<div><label>音色</label><span class="v">{{tone}}</span></div>
<div><label>范围</label><span class="v">{{p.falloffRadius[1]}} 米</span></div>
<div><label>循环</label><span class="v">{{truth(p.repeat)}}</span></div>
<div><label>音阶</label><span class="v">{{pitch}}</span></div>
<div><label>音量</label><span class="v">{{p.volume}}</span></div>
<div v-if="hasLength"><label>时长</label><span class="v">{{p.length.toLocaleString([], { minimumFractionDigits: 1, maximumFractionDigits: 1 })}} 秒</span></div>
<div>
<label>{{ t('流速器生成物品标题') }}</label>
<span class="v">{{ genDesc }}</span>
</div>
</section>
</div>
<div class="building-params">
<h3>{{t('警报设置')}}</h3>
<div><label>{{t('系统警报')}}</label><span class="v">{{systemWarningMode}}</span></div>
<div v-if="p.systemWarningMode > 0">
<label>{{t('警报图标')}}</label>
<span class="v"><BuildingIcon :icon-id="p.systemWarningIconId" /></span>
</div>
<div><label>{{t('声音警报')}}</label><span class="v">{{alarmMode}}</span></div>
</div>
<div v-if="p.alarmMode > 0" class="building-params">
<div><label>{{t('音色')}}</label><span class="v">{{tone}}</span></div>
<div><label>{{t('衰减范围')}}</label><span class="v">{{p.falloffRadius[1]}}{{t('空格米')}}</span></div>
<div><label>{{t('循环播放')}}</label><span class="v">{{truth(p.repeat)}}</span></div>
<div><label>{{t('音高')}}</label><span class="v">{{pitch}}</span></div>
<div><label>{{t('音量')}}</label><span class="v">{{p.volume}}</span></div>
<div v-if="hasLength"><label>{{t('音频长度')}}</label><span class="v">{{p.length.toLocaleString([], { minimumFractionDigits: 1, maximumFractionDigits: 1 })}}{{ t('周期秒') }}</span></div>
</div>
</template>

<script lang="ts">
const allTones = new Map<number, string>([
[20, '报警1'], [21, '报警2'], [22, '报警3'], [23, '报警4'], [24, '报警5'],
[1, '钢琴1'], [2, '钢琴2'],
[3, '贝斯1'], [4, '贝斯2'],
[5, '风琴1'], [6, '风琴2'],
[7, '铺底1'], [8, '铺底2'], [9, '铺底3'],
[10, '铜管乐'],
[11, '梦铃'],
[12, '玻璃'],
[13, '吉他'],
[14, '音乐盒'],
[15, '电子琴'],
[16, '小号'],
[17, '小提琴'],
[18, '低音贝司'],
[19, ''],
]);
const allTriggerModes = [
'', '未满足条件', '满足条件', '有货物响', '无货物响', '未满足且有货物', '未满足且无货物',
];
const allOperators = ['=', '', '', '>', '', '<'];
const allPitchs = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'];
</script>

<script lang="ts" setup>
import { computed } from 'vue';
import { BlueprintBuilding, MonitorParameters } from '@/blueprint/parser';
import { useI18n } from 'vue-i18n';
import { BlueprintBuilding, MonitorParameters, SpawnItemOperator } from '@/blueprint/parser';
import { itemIconId } from '@/data/icons';
import { midiMap } from '@/data/midi';
import { truth } from '@/utils';
import BuildingIcon from './BuildingIcon.vue';
import ColorPreview from './ColorPreview.vue';
const { t } = useI18n();
const allTones = new Map<number, string>([
[20, t('警报-1')], [21, t('警报-2')], [22, t('警报-3')], [23, t('警报-4')], [24, t('警报-5')],
[1, t('钢琴-1')], [2, t('钢琴-2')],
[3, t('贝斯-1')], [4, t('贝斯-2')],
[5, t('风琴-1')], [6, t('风琴-2')],
[7, t('铺底-1')], [8, t('铺底-2')], [9, t('铺底-3')],
[10, t('铜管乐')],
[11, t('梦铃')],
[12, t('玻璃乐器')],
[13, t('吉他')],
[14, t('音乐盒')],
[15, t('电子琴')],
[16, t('小号')],
[17, t('小提琴')],
[18, t('低音贝斯')],
[19, t('')],
]);
const allTriggerModes = [
t(''), t('未满足条件'), t('满足条件'), t('有货物响'), t('无货物响'), t('未满足且有货物'), t('未满足且无货物'),
];
const props = defineProps<{
building: BlueprintBuilding,
}>();
Expand All @@ -89,4 +92,17 @@ const pitch = computed(() => {
return allPitchs[v % 12] + Math.floor(v / 12);
});
const hasLength = computed(() => !(midiMap.get(p.value.tone)!.isInstrument) || p.value.repeat);
const genDesc = computed(() => {
switch (p.value.spawnItemOperator) {
case SpawnItemOperator.NONE:
return truth(false);
case SpawnItemOperator.GENERATE:
return t('流速器生成物品');
case SpawnItemOperator.CONSUME:
return t('流速器移除物品');
default:
return "??";
}
})
</script>
56 changes: 55 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@
"高速分拣器": "Sorter MK.II",
"高频激光塔": "Laser Turret",
"齿轮": "Gear",
"不满足": "Fail",
"不选轨道": "None",
"低音贝斯": "Sub Bass",
"储液罐关": "OFF",
"储液罐开": "ON",
"储液罐输入": "Input",
Expand All @@ -196,33 +198,71 @@
"包含设施": "Components",
"包括轨道采集器": " Orbital Collector",
"十倍射速": "10x Speed",
"吉他": "Guitar",
"周期秒": " seconds",
"图标布局": "Icon Layout",
"增产剂效果简": "Proliferator effect",
"声音警报": "Speaker alarm",
"小号": "Trumpet",
"小提琴": "Violin",
"建筑公式": "Buildings",
"当前货物数": "Current",
"待机": "Idle",
"循环播放": " Loop",
"放电": "Discharge",
"无": "None",
"无货物响": "No cargo",
"星际仓储": "Remote storage",
"星际供应": "Remote supply",
"星际需求": "Remote demand",
"曲速启用路程": "Warp distance",
"最大充能功率": "Max Charging Power",
"有货物响": "Cargo pass",
"未满足且无货物": "Fail and no cargo",
"未满足且有货物": "Fail and cargo pass",
"未满足条件": "Fail",
"本地仓储": "Local storage",
"本地供应": "Local supply",
"本地需求": "Local demand",
"梦铃": "Dream Bell",
"流速器生成物品": "Generate cargo",
"流速器生成物品标题": "Generate/Consume cargo",
"流速器移除物品": "Consume cargo",
"满足": "Pass",
"满足条件": "Pass",
"玻璃乐器": "Glass",
"电子琴": "Keyboard",
"百倍发电": "100x Gen",
"监测周期": "Cycle",
"监测条件": "Condition",
"监测设置": "Monitor Setting",
"目标流量": "Target flow",
"直接发电": "Power Generation",
"矩阵合成": "Matrix",
"科研模式": "Research",
"空栏位": "Empty slot",
"空格米": " m",
"系统警报": "Global alarm",
"组件公式": "Items",
"缩略图文字": "Thumbnail Text",
"翘曲器必要性": " Warpers required",
"自动化容量限制": "Limit for Automation Input",
"自动补充提示": "Automatically deploy transport devices",
"蓝图介绍": "Blueprint Description",
"蓝图代码": "Blueprint code",
"衰减范围": "Range",
"警报-1": "Alarm 1",
"警报-2": "Alarm 2",
"警报-3": "Alarm 3",
"警报-4": "Alarm 4",
"警报-5": "Alarm 5",
"警报图标": "Alarm Icon",
"警报设置": "Alarm settings",
"贝斯-1": "Bass 1",
"贝斯-2": "Bass 2",
"货物上限": "Limit",
"货物个": " cargos",
"货物过滤": "Item filter",
"货物集装数量": "Outgoing integration count",
"过滤器": "Filter",
"运输机最远路程": "Drone transport range",
Expand All @@ -231,6 +271,20 @@
"运输船起送量": "Min. Load of Vessels",
"选择模式": "Select Mode",
"采集速度": "Collecting Speed",
"钢琴-1": "Piano 1",
"钢琴-2": "Piano 2",
"铜管乐": "Brass",
"铺底-1": "Pad 1",
"铺底-2": "Pad 2",
"铺底-3": "Pad 3",
"集装使用科技上限": " Up to tech limit",
"额外产出": "Extra products"
"音乐盒": "Music Box",
"音色": "Tone",
"音量": "Volume",
"音频长度": "Length",
"音高": "Pitch",
"额外产出": "Extra products",
"风琴-1": "Organ 1",
"风琴-2": "Organ 2",
"鼓": "Drumpad"
}
Loading

0 comments on commit be0e8b5

Please sign in to comment.