Skip to content

Implement scene saving and enhance inspector with delete confirmation#21

Merged
amasiye merged 3 commits into
mainfrom
develop
Mar 12, 2026
Merged

Implement scene saving and enhance inspector with delete confirmation#21
amasiye merged 3 commits into
mainfrom
develop

Conversation

@amasiye

@amasiye amasiye commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

This pull request introduces several enhancements and refactors to the editor and scene loading components, focusing on improved scene metadata handling, more robust serialization/deserialization, and better terminal input management. The most significant changes are grouped below.

Scene loading and metadata improvements

  • Added isolated process loading for scene metadata in SceneLoader, allowing scenes to be loaded safely and reliably even if they contain problematic code. This includes a new method for loading scene data in a separate PHP process and improved error handling. (src/Editor/SceneLoader.php, [1] [2]
  • Introduced SceneSourceParser for parsing PHP scene files to extract metadata, providing a fallback mechanism when direct loading fails. (src/Editor/SceneSourceParser.php, src/Editor/SceneSourceParser.phpR1-R276)
  • Updated SceneDTO to track additional metadata: sourcePath, rawData, and sourceData, ensuring the editor has access to both original and processed scene information. (src/Editor/DTOs/SceneDTO.php, [1] [2] [3]
  • Modified SceneLoader to populate new SceneDTO fields when loading a scene. (src/Editor/SceneLoader.php, src/Editor/SceneLoader.phpR35-R37)

Hierarchy object serialization and deserialization

  • Refactored HierarchyObjectDTO to support more flexible and robust serialization, including new fields (type, size, sprite, text, components, children), improved handling of UI elements, and normalization of vector/numeric data. (src/Editor/DTOs/HierarchyObjectDTO.php, src/Editor/DTOs/HierarchyObjectDTO.phpL5-R157)

Terminal input and key handling

  • Improved terminal input handling in InputManager by saving/restoring terminal mode snapshots, ensuring proper echo and non-blocking mode management. (src/Editor/IO/InputManager.php, [1] [2] [3]
  • Added support for CTRL_C and CTRL_S key codes in both the KeyCode enum and key detection logic, enabling new keyboard shortcuts. (src/Editor/IO/Enumerations/KeyCode.php, [1]; src/Editor/IO/InputManager.php, [2]

Documentation

  • Added an editor manual reference in the README.md to help users find the editor guide. (README.md, README.mdR14-R17)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3aeafe8d2f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +219 to +221
foreach ($tokens as $index => $token) {
if (is_array($token) && $token[0] === T_RETURN) {
return $index;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Parse the top-level scene return instead of the first return

findReturnIndex() returns the first T_RETURN token in the file, so scenes that define helpers/closures before the final return [...] are parsed against the wrong array expression. When SceneWriter::serialize() then merges data, it rewrites that earlier return block and can leave the actual scene payload untouched, producing a corrupted scene file on save for any scene source that contains a prior return statement.

Useful? React with 👍 / 👎.

Comment on lines +128 to +132
&& array_key_exists($index, $originalValue)
) {
$lines[] = $childIndent
. $this->renderMergedValue(
$currentValue[$index],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid index-based merge when list entries shift

The list merge path reuses source/original nodes by numeric index, which breaks when a loaded scene uses partial metadata (fallback load) and items are deleted or reordered. After an index shift, a remaining object is merged with the deleted object's source node ($originalValue[$index]), so preserved fields can be copied from the wrong object (or hidden fields can be dropped), leading to silent scene data corruption on save.

Useful? React with 👍 / 👎.

@amasiye amasiye merged commit fe2a497 into main Mar 12, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant