Skip to content

Implement UndoRedo and save prompt#10

Merged
atomic-junky merged 41 commits into
mainfrom
feature/action-history
Aug 11, 2024
Merged

Implement UndoRedo and save prompt#10
atomic-junky merged 41 commits into
mainfrom
feature/action-history

Conversation

@RailKill

@RailKill RailKill commented Aug 11, 2024

Copy link
Copy Markdown
Collaborator

Bug Fixes

  • Fix ConditionNodePanel operator not updating (similar to Fix ActionNode keep resetting to equal #9 in ActionNodePanel)
  • Fix ActionNodePanel ActionVariable value controls not updating when selecting a different variable type
  • Fix ActionNodePanel PlayAudio's pitch slider affecting volume label
  • Fix BridgeOut node being created in the center instead of next to BridgeIn when creating from picker
  • Fix off-centered position of newly created nodes ddec7fb

Features

  • Implement UndoRedo for the following operations (history is tracked in each MonologueGraphEdit, i.e. per file)

    • Adding and deleting graph nodes
    • Connecting and disconnecting graph nodes, including from picker
    • Changes to node panel data
    • Changes to option IDs and their NextID connections thereof
    • Use Ctrl + Z and Ctrl + Shift + Z
  • Add save prompt on tab close

    • Unsaved files have asterisk (*) in their name, checked with UndoRedo's built-in versioning
    • When closing individual tabs, user will be prompted to save, discard or cancel
    • When closing the entire window, the first tab will close and prompt if needed, then continue to close tabs recurringly until there are no more prompts

Developer Notes

  • RootNodePanel is now a MonologueNodePanel
  • MonologueNodePanel has a base function _on_node_property_change() that allows you to define any graph node properties to update, it has a built-in equality check to try and only register new changes, PropertyHistory will call the panel's _from_dict() on undo/redo to update the panel with the graph node's _to_dict()
  • Renamed Control.gd, GraphEdit.gd, GraphEdit.tscn to have "Monologue" prefix because the previous names were exactly the same as Godot's built-in classes, making it confusing
  • For LineEdit, TextEdit and SpinBox, the UndoRedo history is only committed on focus_exited and text_submitted, but node previews can still be updated in real-time like in SentenceNodePanel _on_sentence_text_edit_changed()

Summary by Sourcery

Implement UndoRedo functionality and add save prompt on tab close. Fix various bugs related to node updates and positioning. Refactor and enhance node panel handling and naming conventions for clarity.

New Features:

  • Implement UndoRedo functionality for adding, deleting, connecting, and disconnecting graph nodes, as well as changes to node panel data and option IDs.
  • Add save prompt on tab close, with unsaved files indicated by an asterisk (*) and prompts for saving, discarding, or canceling changes.

Bug Fixes:

  • Fix ConditionNodePanel operator not updating.
  • Fix ActionNodePanel ActionVariable value controls not updating when selecting a different variable type.
  • Fix ActionNodePanel PlayAudio's pitch slider affecting volume label.
  • Fix BridgeOut node being created in the center instead of next to BridgeIn when creating from picker.
  • Fix off-centered position of newly created nodes.

Enhancements:

  • Refactor RootNodePanel to MonologueNodePanel and introduce a base function _on_node_property_change() for updating graph node properties with built-in equality checks.
  • Rename Control.gd, GraphEdit.gd, and GraphEdit.tscn to include 'Monologue' prefix to avoid confusion with Godot's built-in classes.
  • Update LineEdit, TextEdit, and SpinBox to commit UndoRedo history on focus_exited and text_submitted events while allowing real-time node previews.

@sourcery-ai

sourcery-ai Bot commented Aug 11, 2024

Copy link
Copy Markdown

Reviewer's Guide by Sourcery

This pull request implements an UndoRedo feature and a save prompt for the MonologueGraphEdit. The changes include bug fixes, new features, and developer notes. The UndoRedo functionality tracks history for various operations, and the save prompt alerts users to save changes before closing tabs. The implementation involves significant refactoring and renaming of files to avoid conflicts with Godot's built-in classes.

File-Level Changes

Files Changes
Scripts/MonologueControl.gd
Scripts/MonologueGraphEdit.gd
Scripts/History/AddNodeHistory.gd
Scripts/History/PropertyHistory.gd
Scripts/History/DeleteNodeHistory.gd
Scripts/History/MonologueHistory.gd
Scripts/History/HistoryHandler.gd
Scripts/History/PropertyChange.gd
Implemented UndoRedo functionality and save prompt for MonologueGraphEdit, including history management for adding, deleting, and updating nodes.
Scripts/SidePanelNodes/ActionNodePanel.gd
Scripts/SidePanelNodes/ChoiceNodePanel.gd
Scripts/SidePanelNodes/ConditionNodePanel.gd
Scripts/SidePanelNodes/EndPathNodePanel.gd
Scripts/SidePanelNodes/RootNodePanel.gd
Scripts/SidePanelNodes/SentenceNodePanel.gd
Scripts/SidePanelNodes/SidePanelNodeDetails.gd
Refactored side panel nodes to handle focus_exited and text_submitted signals, and updated logic for handling node properties and connections.
Scripts/GraphNodes/ActionNode.gd
Scripts/GraphNodes/BridgeInNode.gd
Scripts/GraphNodes/BridgeOutNode.gd
Scripts/GraphNodes/ChoiceNode.gd
Scripts/GraphNodes/CommentNode.gd
Scripts/GraphNodes/ConditionNode.gd
Scripts/GraphNodes/DiceRollNodePanel.gd
Scripts/GraphNodes/EndPathNode.gd
Scripts/GraphNodes/EventNode.gd
Scripts/GraphNodes/OptionNode.gd
Scripts/GraphNodes/RootNode.gd
Refactored graph nodes to handle new UndoRedo functionality and updated logic for managing node properties and connections.
Scripts/SubComponents/Character.gd
Scripts/SubComponents/OptionReference.gd
Scripts/SubComponents/Variable.gd
Added and refactored subcomponents to handle character, option, and variable nodes, including focus_exited and text_submitted signals.
Scripts/Global/Util.gd
Scripts/Global/GlobalVariables.gd
Added utility functions and global variables for handling common operations and callbacks.
Scripts/Windows/PromptWindow.gd Added new script to handle save prompt window functionality.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

@RailKill RailKill requested a review from atomic-junky August 11, 2024 12:45

@sourcery-ai sourcery-ai 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.

Hey @RailKill - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@atomic-junky

Copy link
Copy Markdown
Collaborator

man you're crazy!

@atomic-junky atomic-junky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Amazing!

@atomic-junky atomic-junky merged commit 2f9859c into main Aug 11, 2024
@atomic-junky

Copy link
Copy Markdown
Collaborator

Thank you so much!

@RailKill RailKill deleted the feature/action-history branch August 12, 2024 00:54
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.

2 participants