Add inline inflation-adjusted cost editor for objects#223
Conversation
Co-authored-by: LeftofZen <7483209+LeftofZen@users.noreply.github.com>
…ridge objects Co-authored-by: LeftofZen <7483209+LeftofZen@users.noreply.github.com>
Co-authored-by: LeftofZen <7483209+LeftofZen@users.noreply.github.com>
Co-authored-by: LeftofZen <7483209+LeftofZen@users.noreply.github.com>
|
@copilot this method for displaying the values in the UI does work, but since it is displayed in the UI in a PropertyGrid (from bodong.PropertyGrid repo) I would prefer if I could mark specific 'currency' properties with an attribute and then properties with that attribute use a custom cell editor and factory, which displays the underlying value as well as the inflation-adjusted value, as well as a stepper containing a year value that the user can edit. |
…h inline inflation adjustment - Created CurrencyAttribute to mark cost factor properties - Created CurrencyEditorViewModel and CurrencyView for inline editing - Created CurrencyCellEditFactory in ExtendedPropertyGrid - Updated all 13 object ViewModels to use Currency attribute - Removed separate read-only effective cost properties - Cost properties now show: Factor input, Year stepper, and calculated effective cost inline Co-authored-by: LeftofZen <7483209+LeftofZen@users.noreply.github.com>
I've implemented the custom PropertyGrid cell editor approach you requested. Changes in commit b9f4c65: Implementation:
Applied to all 13 object types: Track, Road, Bridge, Airport, Dock, Stations (Track/Road), Extras (Track/Road), Tree, Signal, Industry, Vehicle The year stepper updates the global inflation year setting, so changing it in one editor affects all currency displays. The UI is much more compact than the previous approach with separate read-only properties. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
0f9e9bf to
5cec6f0
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds an inline inflation-adjusted cost editor for objects in the ObjectEditor GUI, displaying real in-game costs based on specified year and inflation calculations derived from OpenLoco's economy system.
Key Changes:
- Implemented core inflation calculation engine matching OpenLoco's formula (1900-2030 year range)
- Created custom PropertyGrid cell editor with inline cost factor input, year stepper, and calculated effective cost display
- Applied
[InflatableCurrency]attribute to cost factor properties across 13 object ViewModel types
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| Definitions/Economy.cs | Core inflation calculation engine with year-based currency multiplication factors |
| Tests/EconomyTests.cs | Test suite validating inflation calculations and edge cases |
| Gui/Views/InflatableCurrencyView.axaml | XAML layout for inline cost editor with factor input, year stepper, and result display |
| Gui/Views/InflatableCurrencyView.cs | TemplatedControl backing class for currency view |
| Gui/ViewModels/InflatableCurrencyViewModel.cs | ReactiveUI ViewModel managing cost calculations and property change notifications |
| Gui/Attributes/InflatableCurrencyAttribute.cs | Custom attribute marking properties for inflation-adjusted editing |
| Gui/Views/ExtendedPropertyGrid.cs | Factory implementation integrating custom currency editor into PropertyGrid |
| Gui/ViewModels/LocoTypes/Objects/*.cs | Applied InflatableCurrency attributes and CostIndex property change notifications across 13 object types |
| Gui/Gui.csproj | Added build configuration for CurrencyView component |
| Gui/App.axaml | Registered InflatableCurrencyView style resources |
| Gui/Views/Pos3View.axaml | Minor cleanup: removed ReSharper comments, improved comment formatting |
| Gui/ViewModels/EditorSettingsWindowViewModel.cs | Added InflationYear setting property |
9717520 to
698d236
Compare
The editor now displays real in-game costs for objects accounting for inflation at a specified year, using a custom PropertyGrid cell editor that shows both the raw cost factor and calculated effective cost inline with an adjustable year stepper.
Changes
Core Economy Implementation
Common/Economy.cs: Inflation calculation engineCalculateCurrencyMultiplicationFactors(year): Computes inflation factors for 32 cost indices using OpenLoco's inflation tableGetInflationAdjustedCost(costFactor, costIndex, year, divisor): Applies formula(costFactor * inflationFactor) / (1 << divisor)Settings
EditorSettings: AddedInflationYearproperty (default: 1950)GlobalSettings: Static accessor for ViewModels to read current settingsCustom PropertyGrid Cell Editor
CurrencyAttribute: Custom attribute to mark cost factor properties for custom editingCurrencyEditorViewModel: ViewModel managing cost factor, year, and calculated effective costCurrencyView: Avalonia UI control displaying in a single row:CurrencyCellEditFactory: Factory integrated intoExtendedPropertyGridthat creates custom editors for[Currency]-marked propertiesViewModel Updates
Applied
[Currency]attribute to all cost factor properties across 13 object types:BuildCostFactor,SellCostFactor,TunnelCostFactorBaseCostFactor,HeightCostFactorClearCostFactorCostFactor,RunCostFactorExample from
TrackViewModel:Tests
EconomyTests: 9 tests validating inflation calculation mechanicsUsage
When editing objects in the PropertyGrid, cost factor properties display an inline editor showing:
This provides immediate visual feedback of how cost factors translate to in-game costs at different time periods, all within a single compact row per cost property.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.