Skip to content

New view models#231

Merged
LeftofZen merged 15 commits intomasterfrom
newViewModels
Feb 2, 2026
Merged

New view models#231
LeftofZen merged 15 commits intomasterfrom
newViewModels

Conversation

@LeftofZen
Copy link
Collaborator

No description provided.

@LeftofZen LeftofZen added the ui label Feb 2, 2026
Copilot AI review requested due to automatic review settings February 2, 2026 00:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the GUI’s view-model architecture toward a unified IViewModel + BaseViewModel<T> / BaseFileViewModel<T> setup, adds a grouped/tabbed “view model groups” UI, and updates various views and models to use the new ObjectEditorContext naming and organization.

Changes:

  • Introduces view-model grouping (ViewModelGroup, IViewModelGroupHost) and updates ObjectEditorView to render dynamic groups/tabs.
  • Adds a dedicated StringTableView and wires view templates to the new IViewModel shape.
  • Renames ObjectEditorModelObjectEditorContext and updates many view models (including moved tutorial types) accordingly.

Reviewed changes

Copilot reviewed 101 out of 102 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
Tests/LoadSaveTests.cs Minor formatting change (blank line).
Tests/IdempotenceTests.cs Disables (comments out) a view-model-related idempotence test.
GuiUpdater/Program.cs Minor formatting change (blank line).
Gui/Views/StringTableView.axaml.cs Adds new StringTableView code-behind.
Gui/Views/StringTableView.axaml Adds new string table UI (list + repeater).
Gui/Views/SCV5View.axaml Updates bindings to use Model.* instead of CurrentS5File.*.
Gui/Views/ObjectEditorView.axaml Replaces old editor layout with grouped view-model UI + group management controls.
Gui/Views/MetadataView.axaml Updates bindings to align with Model-based metadata VM.
Gui/Views/MainWindow.axaml Updates tutorial template namespace mapping.
Gui/Views/ImageTableView.axaml Updates ColorView palette usage and removes building-components panel column.
Gui/Views/BuildingComponentsView.axaml Updates VM namespace and simplifies layout.
Gui/ViewModels/ViewModelGroup.cs Adds view-model grouping container + commands (add/remove/move).
Gui/ViewModels/StringTableViewModel.cs Makes string table VM implement IViewModel.
Gui/ViewModels/ObjectMetadataViewModel.cs Refactors metadata VM to new base and Model pattern; implements IViewModel.
Gui/ViewModels/MainWindowViewModel.cs Switches from ObjectEditorModel to ObjectEditorContext; updates document creation.
Gui/ViewModels/LocoTypes/ObjectDatHeaderViewModel.cs Removes legacy DAT header VM (old location).
Gui/ViewModels/LocoTypes/LocoObjectViewModel.cs Removes legacy object VM base class.
Gui/ViewModels/LocoTypes/IObjectViewModel.cs Removes legacy object VM interface abstraction.
Gui/ViewModels/Loco/Tutorial/TutorialViewModel.cs Moves tutorial VM into Gui.ViewModels.Loco.Tutorial and new base type.
Gui/ViewModels/Loco/Tutorial/TutorialActionB.cs Splits tutorial action types into separate files.
Gui/ViewModels/Loco/Tutorial/TutorialActionA.cs Splits tutorial action types into separate files.
Gui/ViewModels/Loco/Tutorial/MouseButton.cs Splits tutorial enum into separate file.
Gui/ViewModels/Loco/Tutorial/KeyModifier.cs Splits tutorial enum into separate file.
Gui/ViewModels/Loco/Tutorial/ITutorialAction.cs Splits tutorial action interface into separate file.
Gui/ViewModels/Loco/TreeNode.cs Extracts TreeNode into its own file.
Gui/ViewModels/Loco/SoundEffectsViewModel.cs Migrates to BaseFileViewModel<T>/ObjectEditorContext usage.
Gui/ViewModels/Loco/ScoresViewModel.cs Migrates to BaseFileViewModel<T>/ObjectEditorContext usage.
Gui/ViewModels/Loco/SaveType.cs Moves save-type enum into its own file.
Gui/ViewModels/Loco/SaveParameters.cs Moves save-parameter record into its own file.
Gui/ViewModels/Loco/SCV5ViewModel.cs Migrates S5 VM to BaseFileViewModel<S5File> and uses Model.
Gui/ViewModels/Loco/Objects/WaterViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/WallViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/Vehicle/VehicleViewModel.cs Moves namespace and switches VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/TunnelViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/TreeViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/TrackViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/TrackStationViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/TrackSignalViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/TrackExtraViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/TownNamesViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/StreetLightViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/SteamViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/SoundViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/SnowViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/ScenarioTextViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/ScaffoldingViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/RoadViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/RoadStationViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/RoadExtraViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/RegionViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/LevelCrossingViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/LandViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/InterfaceSkinViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/IndustryViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/HillShapesViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/DockViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/CurrencyViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/CompetitorViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/ClimateViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/CliffEdgeViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/CargoViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/Building/DesignBuildingComponentsViewModel.cs Moves building VM namespace to new Loco.Objects.Building.
Gui/ViewModels/Loco/Objects/Building/BuildingViewModel.cs Moves namespace + switches to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/Building/BuildingVariationViewModel.cs Moves namespace for building variation VM.
Gui/ViewModels/Loco/Objects/Building/BuildingStackViewModel.cs Moves namespace for building stack VM.
Gui/ViewModels/Loco/Objects/Building/BuildingLayerViewModel.cs Moves namespace for building layer VM.
Gui/ViewModels/Loco/Objects/Building/BuildingComponentsViewModel.cs Moves namespace + implements IViewModel for building components VM.
Gui/ViewModels/Loco/Objects/BridgeViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/Objects/AirportViewModel.cs Switches object VM base to BaseViewModel<T>.
Gui/ViewModels/Loco/ObjectModelHeaderViewModel.cs Switches object header VM base to BaseViewModel<T> and customizes display name.
Gui/ViewModels/Loco/ObjectEditorViewModel.cs Major refactor to BaseFileViewModel<LocoUIObjectModel> and group-based sub-view models.
Gui/ViewModels/Loco/ObjectDatHeaderViewModel.cs Adds new DAT header VM implementing IViewModel (new location).
Gui/ViewModels/Loco/MusicViewModel.cs Migrates to BaseFileViewModel<T>/ObjectEditorContext.
Gui/ViewModels/Loco/LanguageFileViewModel.cs Renames language VM and migrates to generic base.
Gui/ViewModels/Loco/IFileViewModel.cs Introduces IFileViewModel abstraction for file-based tabs.
Gui/ViewModels/Loco/G1ViewModel.cs Migrates G1 VM to BaseFileViewModel<G1Dat> and stores in context.
Gui/ViewModels/Loco/BaseViewModelWithEditorContext.cs Adds base VM that carries ObjectEditorContext.
Gui/ViewModels/Loco/BaseViewModel.cs Adds common base VM with grouping support and tracked view models.
Gui/ViewModels/Loco/BaseFileViewModel.cs Refactors file VM base into generic BaseFileViewModel<T>.
Gui/ViewModels/IViewModelGroupHost.cs Adds host interface for view-model group operations.
Gui/ViewModels/IViewModel.cs Adds common IViewModel interface with DisplayName.
Gui/ViewModels/IExtraContentViewModel.cs Removes legacy extra-content interface (replaced by IViewModel).
Gui/ViewModels/Graphics/ImageViewModel.cs Removes unused Gui.Models reference after refactor.
Gui/ViewModels/Graphics/ImageTableViewModel.cs Switches to IViewModel, adjusts palette handling, removes building-components coupling.
Gui/ViewModels/FolderTreeViewModel.cs Migrates from ObjectEditorModel to ObjectEditorContext.
Gui/ViewModels/Filters/FilterViewModel.cs Migrates filter VM to use ObjectEditorContext.
Gui/ViewModels/AudioViewModel.cs Migrates to IViewModel (DisplayName).
Gui/Models/ObjectEditorContext.cs Renames model to ObjectEditorContext and adjusts metadata defaults.
Gui/Models/LanguageTranslation.cs Removes legacy language translation model class.
Gui/Models/LanguageFileModel.cs Adds placeholder LanguageFileModel.
Gui/Models/FileSystemItems.cs Removes inline FileLocation enum (moved out).
Gui/Models/FileLocation.cs Adds new FileLocation enum file.
Gui/Models/DummyModel.cs Adds placeholder DummyModel used by generic file VMs.
Gui/ImageConversion.cs Moves ImageConversion into Gui namespace.
Gui/Converters/LogLevelToRowBrushConverter.cs Minor formatting change (blank lines).
Gui/App.axaml.cs Minor formatting change (blank line).
Gui/App.axaml Registers StringTableViewModel template and updates type mappings to new namespaces/interfaces.
Definitions/ObjectModels/Graphics/ImageTableHelpers.cs Minor formatting change (blank line).
Definitions/ObjectModels/Graphics/ImageTable.cs Minor formatting change (blank line).
Definitions/Migrations/20251228122835_AddTblObjectMissing.cs Style refactor adding _ = discards for migration operations.
DataSanitiser/Program.cs Adds new local query routine and runs it by default.
Dat/FileParsing/SawyerStreamWriter.cs Removes unused System.Collections.Immutable import.
Comments suppressed due to low confidence (3)

Gui/ViewModels/Loco/ObjectEditorViewModel.cs:469

  • GetViewModel<IViewModel>() will throw because there are multiple view models implementing IViewModel in ViewModelGroups (SingleOrDefault on an interface is not unique). Either remove this check or query a specific concrete view model type (or change GetViewModel<T> to use OfType<T>().FirstOrDefault() when T isn’t unique).
    Gui/ViewModels/Loco/ObjectEditorViewModel.cs:527
  • JsonSerializer.Serialize(new FileStream(...)) leaves the stream undisposed, which can leak file handles and keep the output file locked. Wrap the FileStream in a using/await using (or use File.Create in a using) before calling JsonSerializer.Serialize.
    Gui/ViewModels/Loco/ObjectEditorViewModel.cs:244
  • This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.

@LeftofZen LeftofZen merged commit 1cc761e into master Feb 2, 2026
@LeftofZen LeftofZen deleted the newViewModels branch February 2, 2026 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant