Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The UndoRedo class has been extended to make it more useful for its own use in addition to internal use by the engine itself. #41193

Closed

Conversation

TypeOverride2
Copy link

@TypeOverride2 TypeOverride2 commented Aug 11, 2020

int get_action_count() const;

Gets the amount of actions.

int get_current_action() const;

Gets the index of the current action.

void set_max_actions(int p_max_actions);

Sets the max amount of actions. If max_actions is -1, there is no limit of actions.

int get_max_actions() const;

Returns the max amount of actions. Returns -1, when there is no limit of actions.

…wn use in addition to internal use by the engine itself.
Copy link
Contributor

@bojidar-bg bojidar-bg left a comment

Choose a reason for hiding this comment

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

set_max_actions/get_max_actions should become a property, using the ADD_PROPERTY macro; you can check how it is used in other classes such as Node.
get_current_action could also be a property (without a setter), though get_action_count should likely not be one.

<return type="int">
</return>
<description>
Gets the ammount of actions.
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: "amount"

Might be nice to clarify what this means exactly, i.e. that it represents the amount of actions currently stored in the undo/redo.

<argument index="0" name="max_actions" type="int">
</argument>
<description>
Sets the max ammount of actions. If [code]max_actions[/code] is [code]-1[/code], there is no limit of actions.
Copy link
Contributor

Choose a reason for hiding this comment

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

As above, "amount"

There should be an explanation of what happens after the limit is reached, likely that the oldest action (index 0) is forgotten by the UndoRedo. Also, would be ideal if what happens to action indices after the limit is reached is also clarified.

@@ -256,6 +256,13 @@ void UndoRedo::commit_action() {
committing++;
redo(); // perform action
committing--;

if (max_actions > 0 && actions.size() > max_actions) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking:
Shouldn't this occur in create_action instead? Note that this is where _discard_redo() is used currently, and that it is where the action itself is created.

Also, note that the if does not need to check for actions.size() > max_actions as it is going to be checked by the while anyway.

<return type="int">
</return>
<description>
Gets the index of the current action.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a link between the "current action" and the amount of undo steps available? If so, the current documentation does not mention it.

@bojidar-bg
Copy link
Contributor

Also, note that there is no proposal backing this feature-adding PR. As there has not been discussion about it before, it is possible that it does not get merged with the current API (even after the changes I suggested). I would suggest opening one, for the sake of completeness.

@TypeOverride2
Copy link
Author

TypeOverride2 commented Aug 22, 2020

Also, note that there is no proposal backing this feature-adding PR. As there has not been discussion about it before, it is possible that it does not get merged with the current API (even after the changes I suggested). I would suggest opening one, for the sake of completeness.

ok. Its more important that you get the idea.

(i see the problems with it. It was for sure only a dirty hack to make it possible. It would need to make more coding around it, so it is not become inconstancy - on changing the max_actions value it has to delete elements from the stack as well, off course. And other stuff)

@Calinou Calinou added this to the 4.0 milestone Jan 5, 2021
@Calinou
Copy link
Member

Calinou commented Mar 20, 2021

This PR likely conflicts with #43872, and may be closed in favor of #43872 as it has gathered more support.

@YuriSizov YuriSizov removed this from the 4.0 milestone Feb 9, 2023
@YuriSizov
Copy link
Contributor

This PR needs to be redone if there is any interest in it. UndoRedo has changed a lot since this was last worked on.

@YuriSizov YuriSizov closed this Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants