Skip to content

Property system#1144

Open
Lwmte wants to merge 34 commits intodevelopfrom
property_system_wpf
Open

Property system#1144
Lwmte wants to merge 34 commits intodevelopfrom
property_system_wpf

Conversation

@Lwmte
Copy link
Copy Markdown
Collaborator

@Lwmte Lwmte commented Mar 2, 2026

Implements a three-layered property system for TombEngine level target.

  • Implements a WPF-based property grid control that can be hosted within DarkUI windows and tool windows.
  • Supports data types similar to node arguments (bool, int, float, Vec2, Vec3, Rotation, Time, Color, string, enum).
  • Property metadata is managed via property catalog system, similar to node catalog system.
  • Allows global property overrides via wad2 data (there is now new property editor entry in the Tools menu in main WT window).
  • Allows instance-based property overrides in projects (property grid is accessible in realtime in main editor window).

Linked TEN PR: TombEngine/TombEngine#1903
For the details about defining properties, refer to the documentation.

Copy link
Copy Markdown
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

Implements a three-layer TombEngine Lua property system spanning data model, serialization, compilation-time Lua script generation, and editor UI integration (WadTool global overrides + TombEditor per-instance overrides) via a WPF property grid hosted inside existing DarkUI WinForms surfaces.

Changes:

  • Add Lua property core types: boxed-value parsing/validation, XML catalog loading, and script generation helpers.
  • Persist properties in assets/projects and compilation output (wad2/prj2 chunks + compiled level Lua property script blob).
  • Add WPF property grid UI and integrate it into WadTool and TombEditor (tool window + menu entries), plus refactor visual scripting argument parsing to reuse the shared parser.

Reviewed changes

Copilot reviewed 39 out of 43 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
WadTool/WadTool.csproj Enables WPF support in WadTool to host the new WPF property grid.
WadTool/WadActions.cs Adds action entry point to open the Lua property editor form.
WadTool/Forms/FormMain.cs Adds handlers to open the property editor (focused/unfocused entry points).
WadTool/Forms/FormMain.Designer.cs Adds a “Property editor” menu entry to launch the editor.
WadTool/Forms/FormLuaProperties.resx New form resource for the global Lua property editor.
WadTool/Forms/FormLuaProperties.cs New global (wad2-level) Lua property editor hosting WPF grid in ElementHost.
WadTool/Forms/FormLuaProperties.Designer.cs New WinForms/DarkUI designer layout for the property editor form.
TombLib/TombLib/Wad/WadStatic.cs Adds global (wad2) LuaPropertyContainer storage + cloning.
TombLib/TombLib/Wad/WadMoveable.cs Adds global (wad2) LuaPropertyContainer storage + cloning.
TombLib/TombLib/Wad/Wad2Writer.cs Serializes global Lua properties into wad2 chunks.
TombLib/TombLib/Wad/Wad2Loader.cs Deserializes global Lua properties from wad2 chunks.
TombLib/TombLib/Wad/Wad2Chunks.cs Defines new wad2 chunk IDs for Lua properties.
TombLib/TombLib/Utils/ScriptingUtils.cs Extends LuaSyntax with Rotation type prefix.
TombLib/TombLib/TombLib.csproj Ships new TEN Property Catalog content files to output.
TombLib/TombLib/LuaProperties/LuaValueParser.cs Introduces shared boxing/unboxing/validation utilities for Lua value formats.
TombLib/TombLib/LuaProperties/LuaPropertyType.cs Adds enum of supported Lua property types.
TombLib/TombLib/LuaProperties/LuaPropertyScriptBuilder.cs Generates Lua API call strings for global + instance property assignment.
TombLib/TombLib/LuaProperties/LuaPropertyDefinition.cs Defines property metadata loaded from XML catalogs.
TombLib/TombLib/LuaProperties/LuaPropertyContainer.cs Adds boxed-string container for storing property overrides.
TombLib/TombLib/LuaProperties/LuaPropertyCatalog.cs Implements XML catalog loader + merging + validation for property definitions.
TombLib/TombLib/LevelData/Instances/StaticInstance.cs Adds per-instance (prj2) LuaPropertyContainer storage.
TombLib/TombLib/LevelData/Instances/MoveableInstance.cs Adds per-instance (prj2) LuaPropertyContainer storage.
TombLib/TombLib/LevelData/IO/Prj2Writer.cs Serializes per-instance Lua properties; bumps TEN object chunk versions to 3.
TombLib/TombLib/LevelData/IO/Prj2Loader.cs Deserializes per-instance Lua properties; adds support for new 3 chunk IDs.
TombLib/TombLib/LevelData/IO/Prj2Chunks.cs Defines new prj2 chunk IDs for TEN movable/static v3 objects.
TombLib/TombLib/LevelData/Compilers/TombEngine/TombEngine.cs Writes Lua property script blob into compiled level dynamic data.
TombLib/TombLib/LevelData/Compilers/TombEngine/LevelCompilerTombEngine.cs Builds the global+instance property script blob during compilation.
TombLib/TombLib.Forms/Views/LuaPropertyGridControl.xaml.cs New WPF control code-behind (color picker interop, converters, UX helpers).
TombLib/TombLib.Forms/Views/LuaPropertyGridControl.xaml New WPF property grid UI templates for all supported types.
TombLib/TombLib.Forms/Views/LuaPropertyEditorTemplateSelector.cs Selects editor templates by LuaPropertyType.
TombLib/TombLib.Forms/ViewModels/LuaPropertyRowViewModel.cs Per-property row ViewModel with typed bindable accessors and live boxing.
TombLib/TombLib.Forms/ViewModels/LuaPropertyGridViewModel.cs Grid ViewModel: load/clear/reset, live-writeback to LuaPropertyContainer.
TombLib/TombLib.Forms/Utils/WinFormsUtils.cs Extends input handling to account for WPF focus hosted in ElementHost.
TombLib/TombLib.Forms/Controls/VisualScripting/ArgumentEditor.cs Refactors argument boxing/unboxing to reuse LuaValueParser.
TombEditor/ToolWindows/ItemProperties.cs New dockable tool window for per-instance Lua properties (WPF hosted).
TombEditor/ToolWindows/ItemProperties.Designer.cs Designer metadata for the new ItemProperties tool window.
TombEditor/Forms/FormMain.cs Registers ItemProperties tool window in the default tool window list.
TombEditor/Forms/FormMain.Designer.cs Adds Window menu toggle entry for the new Item Properties window.
TombEditor/Configuration.cs Updates default docking layout to include ItemProperties.
TombEditor/Command.cs Adds command to show/hide the ItemProperties tool window.
DarkUI/DarkUI.WPF/CustomControls/NumericUpDown.cs Allows negative sign input in WPF NumericUpDown text input filter.
Files not reviewed (4)
  • TombEditor/Forms/FormMain.Designer.cs: Language not supported
  • TombEditor/ToolWindows/ItemProperties.Designer.cs: Language not supported
  • WadTool/Forms/FormLuaProperties.Designer.cs: Language not supported
  • WadTool/Forms/FormMain.Designer.cs: Language not supported
Comments suppressed due to low confidence (1)

TombLib/TombLib/LuaProperties/LuaPropertyCatalog.cs:80

  • The XML doc says this lazy initialization is thread-safe, but there is no synchronization here. Either add locking/Interlocked initialization or adjust the comment so callers don’t assume thread-safety.
        /// <summary>
        /// Gets all property definitions, loading from disk on first access.
        /// Thread-safe via lazy initialization.
        /// </summary>
        public static Dictionary<LuaPropertyObjectKey, List<LuaPropertyDefinition>> Catalog
        {
            get
            {
                if (_catalog == null)
                    _catalog = LoadCatalog(PropertyCatalogPath);
                return _catalog;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Lwmte Lwmte added the new feature This is a new feature task. label Mar 7, 2026
@Lwmte Lwmte added the work in progress The Pull Request is not finished yet or needs some extra work done to it. label Mar 7, 2026
@Lwmte Lwmte added this to the Version 2.0 milestone Mar 7, 2026
@Nickelony Nickelony added ready for review The Pull Request is finished and ready for review. and removed work in progress The Pull Request is not finished yet or needs some extra work done to it. labels Mar 16, 2026
@Nickelony Nickelony self-assigned this Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature This is a new feature task. ready for review The Pull Request is finished and ready for review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants