Skip to content

Indicate nodes not supported by current event#1156

Open
Lwmte wants to merge 4 commits intodevelopfrom
unsupported_nodes
Open

Indicate nodes not supported by current event#1156
Lwmte wants to merge 4 commits intodevelopfrom
unsupported_nodes

Conversation

@Lwmte
Copy link
Copy Markdown
Collaborator

@Lwmte Lwmte commented Mar 15, 2026

Adds an indication that a node is not supported by the current event type:

Clipboard-2

To define whether node is supported or not supported by a particular event type, define new metadata entries:

-- !Unsupported "OnLoop" "OnLevelStart"
-- !Supported "OnVolumeEnter"

@Lwmte Lwmte added this to the Version 2.0 milestone Mar 15, 2026
@Lwmte Lwmte added enhancement A task which adds something new or improves on existing features. Tomb Editor Nodes Task specific to TEN Nodes. labels Mar 15, 2026
@Lwmte Lwmte requested review from Nickelony and TrainWrack March 17, 2026 08:01
Copy link
Copy Markdown
Collaborator

@Nickelony Nickelony left a comment

Choose a reason for hiding this comment

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

Looks good! I'll poke Copilot as well to review just in case.

@Nickelony Nickelony requested a review from Copilot March 22, 2026 21:36
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

Adds metadata-driven support/unsupported event type tagging for visual scripting nodes, and surfaces a UI warning when a node is used under an incompatible event type.

Changes:

  • Parse new !Supported / !Unsupported metadata tags into NodeFunction definitions.
  • Add support checks (IsUnsupported) to NodeFunction and propagate current event type into the node editor UI.
  • Document the new metadata tags in the TEN node catalog Readme.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
TombLib/TombLib/Utils/ScriptingUtils.cs Parses !Supported / !Unsupported tags into event type lists.
TombLib/TombLib/LevelData/VisualScripting/TriggerNodeEnumerations.cs Stores per-node supported/unsupported event lists and exposes IsUnsupported.
TombLib/TombLib/Catalogs/TEN Node Catalogs/Readme.md Documents the new metadata tag syntax and available event types.
TombLib/TombLib.Forms/Controls/VisualScripting/NodeEditor.cs Displays a warning indicator/message when a node is incompatible with the current event type.
TombEditor/Forms/FormEventSetEditor.cs Propagates event type changes into TriggerManager.
TombEditor/Controls/TriggerManager.cs Exposes EventType and forwards it to the embedded node editor.

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

Comment on lines +923 to +930
var matrix = new System.Drawing.Imaging.ColorMatrix { Matrix33 = LabelOpacity, Matrix22 = 0.0f };
var attributes = new System.Drawing.Imaging.ImageAttributes();
attributes.SetColorMatrix(matrix, System.Drawing.Imaging.ColorMatrixFlag.Default, System.Drawing.Imaging.ColorAdjustType.Bitmap);

var icon = Properties.Resources.general_Warning_16;
var iconRect = new Rectangle(rect.X, rect.Y + (rect.Height - icon.Height), icon.Width, icon.Height);
e.Graphics.DrawImage(icon, iconRect, 0, 0, icon.Width, icon.Height, GraphicsUnit.Pixel, attributes);
iconOffset = icon.Width + 2;
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

ImageAttributes is created in the paint path but never disposed, which can leak GDI resources over time (especially during frequent repaints). Also, setting Matrix22 = 0.0f zeroes the blue channel; if the intent is only to apply opacity, keep the RGB diagonal at 1.0 and only change Matrix33. Fix by disposing ImageAttributes (e.g., via a using) and correcting the color matrix so it doesn’t unintentionally alter colors.

Suggested change
var matrix = new System.Drawing.Imaging.ColorMatrix { Matrix33 = LabelOpacity, Matrix22 = 0.0f };
var attributes = new System.Drawing.Imaging.ImageAttributes();
attributes.SetColorMatrix(matrix, System.Drawing.Imaging.ColorMatrixFlag.Default, System.Drawing.Imaging.ColorAdjustType.Bitmap);
var icon = Properties.Resources.general_Warning_16;
var iconRect = new Rectangle(rect.X, rect.Y + (rect.Height - icon.Height), icon.Width, icon.Height);
e.Graphics.DrawImage(icon, iconRect, 0, 0, icon.Width, icon.Height, GraphicsUnit.Pixel, attributes);
iconOffset = icon.Width + 2;
var matrix = new System.Drawing.Imaging.ColorMatrix
{
Matrix00 = 1.0f,
Matrix11 = 1.0f,
Matrix22 = 1.0f,
Matrix33 = LabelOpacity,
Matrix44 = 1.0f
};
using (var attributes = new System.Drawing.Imaging.ImageAttributes())
{
attributes.SetColorMatrix(matrix, System.Drawing.Imaging.ColorMatrixFlag.Default, System.Drawing.Imaging.ColorAdjustType.Bitmap);
var icon = Properties.Resources.general_Warning_16;
var iconRect = new Rectangle(rect.X, rect.Y + (rect.Height - icon.Height), icon.Width, icon.Height);
e.Graphics.DrawImage(icon, iconRect, 0, 0, icon.Width, icon.Height, GraphicsUnit.Pixel, attributes);
iconOffset = icon.Width + 2;
}

Copilot uses AI. Check for mistakes.
var values = TextExtensions.ExtractValues(comment.Substring(tagId.Length, comment.Length - tagId.Length));
foreach (var v in values)
{
if (Enum.TryParse(v.Trim(), out EventType eventType))
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

Enum.TryParse here is case-sensitive, while the metadata tag match uses case-insensitive comparison. This can cause valid values (e.g., different casing in scripts) to be silently ignored. Use the Enum.TryParse(string, bool ignoreCase, out TEnum) overload with ignoreCase: true, and consider avoiding duplicates when adding to targetList to prevent repeated entries if multiple tags are present.

Suggested change
if (Enum.TryParse(v.Trim(), out EventType eventType))
if (Enum.TryParse(v.Trim(), true, out EventType eventType) && !targetList.Contains(eventType))

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +49
- **!Supported "TYPE" "TYPE" "..." - defines supported event types for a given node. Each event type should be
enclosed in quotes. If event is not supported by a node, it will display a warning message when misplaced.
Possible event types are: **OnVolumeEnter, OnVolumeInside, OnVolumeLeave, OnLoop, OnLoadGame, OnSaveGame,
OnLevelStart, OnLevelEnd, OnUseItem, OnFreeze**.

- **!Unsupported "TYPE" "TYPE" "..." - defines unsupported event types for a given node. Acts in an opposite way
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

The markdown bold markup is unbalanced for the !Supported / !Unsupported entries (missing closing ** after the tag pattern), which will render the rest of the section incorrectly. Close the bold around just the tag syntax (e.g., **!Supported "TYPE" ...**) and consider the small grammar fix “If an event is not supported…” for clarity.

Suggested change
- **!Supported "TYPE" "TYPE" "..." - defines supported event types for a given node. Each event type should be
enclosed in quotes. If event is not supported by a node, it will display a warning message when misplaced.
Possible event types are: **OnVolumeEnter, OnVolumeInside, OnVolumeLeave, OnLoop, OnLoadGame, OnSaveGame,
OnLevelStart, OnLevelEnd, OnUseItem, OnFreeze**.
- **!Unsupported "TYPE" "TYPE" "..." - defines unsupported event types for a given node. Acts in an opposite way
- **!Supported "TYPE" "TYPE" "..."** - defines supported event types for a given node. Each event type should be
enclosed in quotes. If an event is not supported by a node, it will display a warning message when misplaced.
Possible event types are: **OnVolumeEnter, OnVolumeInside, OnVolumeLeave, OnLoop, OnLoadGame, OnSaveGame,
OnLevelStart, OnLevelEnd, OnUseItem, OnFreeze**.
- **!Unsupported "TYPE" "TYPE" "..."** - defines unsupported event types for a given node. Acts in an opposite way

Copilot uses AI. Check for mistakes.

private static void ParseEventTypeList(string comment, string tagId, List<EventType> targetList)
{
var values = TextExtensions.ExtractValues(comment.Substring(tagId.Length, comment.Length - tagId.Length));
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

comment.Substring(tagId.Length, comment.Length - tagId.Length) is equivalent to comment.Substring(tagId.Length) and is harder to read than necessary. Simplifying this reduces cognitive overhead and removes an easy place for accidental off-by-one edits later.

Suggested change
var values = TextExtensions.ExtractValues(comment.Substring(tagId.Length, comment.Length - tagId.Length));
var values = TextExtensions.ExtractValues(comment.Substring(tagId.Length));

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement A task which adds something new or improves on existing features. Tomb Editor Nodes Task specific to TEN Nodes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants