From 3e5abf19653863d3b5b8f03b01c0b4a18180d850 Mon Sep 17 00:00:00 2001 From: Arnold Zhou Date: Wed, 19 Jun 2024 10:39:31 +1000 Subject: [PATCH] feat: park value record --- CHANGELOG.md | 8 +++++++- lib/exporter.d.ts | 3 ++- src/data/finance.ts | 22 +++++++++++++++++++++- src/data/main.ts | 20 +++++++++++++------- src/data/park_and_scenario.ts | 1 - src/languages/locale/en-GB.json | 3 ++- src/languages/locale/zh-CN.json | 3 ++- src/ui/main.ts | 33 ++++++++++++++++++++++----------- 8 files changed, 69 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f0328c..194d3c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,11 +25,13 @@ and this project adheres to [Semantic Versioning]. - Add advanced statistics (BETA; for guest happiness only). +- Add park value record in group Finance. + ### Changed - Reword some UI elements for better clarity. -- Adjusted colour scheme for warning prompts to match game style. +- Adjust colour scheme for warning prompts to match game style. - Move "Delete all data" button into advanced options. @@ -37,6 +39,10 @@ and this project adheres to [Semantic Versioning]. - Toolbox menu item is replaced with Advanced Options. +- Company value record is now dynamically updated and reflects the highest value achieved within the save file. + +- Move park value record to group Finance. + ### Removed ### Fixed diff --git a/lib/exporter.d.ts b/lib/exporter.d.ts index 870ce85..520825f 100644 --- a/lib/exporter.d.ts +++ b/lib/exporter.d.ts @@ -29,7 +29,6 @@ type PlayerDataType = | "action_server_chat" type ParkAndScenarioDataType = - | "park_value" | "park_size" | "park_rating" | "park_rating_ave" @@ -106,6 +105,8 @@ type FinanceDataType = | "total_expenditure" | "company_value" | "company_value_record" + | "park_value" + | "park_value_record" type FinanceBranchDataType = | "income_player_action" diff --git a/src/data/finance.ts b/src/data/finance.ts index 88726c0..6612744 100644 --- a/src/data/finance.ts +++ b/src/data/finance.ts @@ -67,8 +67,24 @@ namespace FinanceData { } function updateCompanyValueRecord(): void { + if (interval.isPaused) return baseData.local.finance.company_value_record.store.set( - scenario.companyValueRecord + Math.max( + baseData.local.finance.company_value_record.store.get(), + park.companyValue + ) + ) + } + + function updateParkValue(): void { + if (interval.isPaused) return + baseData.local.finance.park_value.store.set(park.value) + } + + function updateParkValueRecord(): void { + if (interval.isPaused) return + baseData.local.finance.park_value_record.store.set( + Math.max(baseData.local.finance.park_value_record.store.get(), park.value) ) } @@ -84,6 +100,8 @@ namespace FinanceData { updateExpenditure() updateCompanyValue() updateCompanyValueRecord() + updateParkValue() + updateParkValueRecord() } /** @@ -99,6 +117,8 @@ namespace FinanceData { tick = 0 updateCompanyValue() updateCompanyValueRecord() + updateParkValue() + updateParkValueRecord() } }) diff --git a/src/data/main.ts b/src/data/main.ts index 461cc24..eb3af0e 100644 --- a/src/data/main.ts +++ b/src/data/main.ts @@ -194,7 +194,7 @@ const branchData: BranchData = { * Accessed by the UI to display data. * @see BranchData */ -const baseData: BaseData = { +const baseData = { global: { update_frequency: new DataEntry({ key: GOBAL + ".update_frequency", @@ -325,12 +325,6 @@ const baseData: BaseData = { }) }, park_and_scenario: { - park_value: new DataEntry({ - key: LOCAL + ".park_value", - store: store( - context.getParkStorage().get(LOCAL + ".park_value", 0) - ) - }), park_size: new DataEntry({ key: LOCAL + ".park_size", store: store( @@ -616,6 +610,18 @@ const baseData: BaseData = { key: LOCAL + ".company_value_record", temporary: true, store: store(0) + }), + park_value: new DataEntry({ + key: LOCAL + ".park_value", + store: store( + context.getParkStorage().get(LOCAL + ".park_value", 0) + ) + }), + park_value_record: new DataEntry({ + key: LOCAL + ".park_value_record", + store: store( + context.getParkStorage().get(LOCAL + ".park_value_record", 0) + ) }) }, options: { diff --git a/src/data/park_and_scenario.ts b/src/data/park_and_scenario.ts index 3d6a028..790d297 100644 --- a/src/data/park_and_scenario.ts +++ b/src/data/park_and_scenario.ts @@ -119,7 +119,6 @@ namespace ParkAndScenarioData { * Updates the park data by setting the park value and park rating. */ function updateParkData(): void { - baseData.local.park_and_scenario.park_value.store.set(park.value) baseData.local.park_and_scenario.park_rating.store.set(park.rating) } diff --git a/src/languages/locale/en-GB.json b/src/languages/locale/en-GB.json index 146a081..e0c4db4 100644 --- a/src/languages/locale/en-GB.json +++ b/src/languages/locale/en-GB.json @@ -50,7 +50,6 @@ "action_server_join": "Join server: {PALESILVER}{INT32}", "action_server_chat": "Chat: {PALESILVER}{INT32}", - "park_value": "Park value: {PALESILVER}{CURRENCY2DP}", "park_size": "Park size: {PALESILVER}{COMMA32} tiles", "park_rating_current": "Current: {PALESILVER}{COMMA2DP32}", "park_rating_ave": "Average (all time): {PALESILVER}{COMMA2DP32}", @@ -114,6 +113,8 @@ "finance_total_profit": "Total Profit: {PALESILVER}{CURRENCY2DP}", "finance_company_value": "Company Value: {PALESILVER}{CURRENCY2DP}", "finance_company_value_record": "Company Value Record: {PALESILVER}{CURRENCY2DP}", + "finance_park_value": "Park Value: {PALESILVER}{CURRENCY2DP}", + "finance_park_value_record": "Park Value Record: {PALESILVER}{CURRENCY2DP}", "options_update_running": "{GREEN}Running", "options_update_manual": "{YELLOW}Manual", diff --git a/src/languages/locale/zh-CN.json b/src/languages/locale/zh-CN.json index e266a96..8e21555 100644 --- a/src/languages/locale/zh-CN.json +++ b/src/languages/locale/zh-CN.json @@ -50,7 +50,6 @@ "action_server_join": "进入服务器:{PALESILVER}{INT32}", "action_server_chat": "聊天消息:{PALESILVER}{INT32}", - "park_value": "园区价值:{PALESILVER}{CURRENCY2DP}", "park_size": "园区面积:{PALESILVER}{COMMA32} tiles", "park_rating_current": "当前:{PALESILVER}{COMMA2DP32}", "park_rating_ave": "平均值:{PALESILVER}{COMMA2DP32}", @@ -114,6 +113,8 @@ "finance_total_profit": "总利润:{PALESILVER}{CURRENCY2DP}", "finance_company_value": "公司价值:{PALESILVER}{CURRENCY2DP}", "finance_company_value_record": "公司价值最高纪录:{PALESILVER}{CURRENCY2DP}", + "finance_park_value": "园区价值:{PALESILVER}{CURRENCY2DP}", + "finance_park_value_record": "园区价值最高纪录:{PALESILVER}{CURRENCY2DP}", "options_update_running": "{GREEN}运行中", "options_update_manual": "{YELLOW}手动更新", diff --git a/src/ui/main.ts b/src/ui/main.ts index da5656e..a237fa1 100644 --- a/src/ui/main.ts +++ b/src/ui/main.ts @@ -647,17 +647,6 @@ function getWindowParams(): WindowParams { groupbox({ text: language.ui.main.groupbox.park_and_scenario.title, content: [ - // Park Value - label({ - text: compute( - baseData.local.park_and_scenario.park_value.store, - (value) => - context.formatString( - language.ui.main.label.park_value, - value - ) - ) - }), // Park Size label({ text: compute( @@ -1209,6 +1198,28 @@ function getWindowParams(): WindowParams { } ), tooltip: language.ui.main.tooltip.finance_company_value_record + }), + // Park Value + label({ + text: compute( + baseData.local.finance.park_value.store, + (value) => + context.formatString( + language.ui.main.label.finance_park_value, + value + ) + ) + }), + // Park Value Record + label({ + text: compute( + baseData.local.finance.park_value_record.store, + (value) => + context.formatString( + language.ui.main.label.finance_park_value_record, + value + ) + ) }) ] })