How do I make my own UNDO/REDO system?

2 favourites
From the Asset Store
Create complex dialogues with ease with this tool/template!
  • the layout L_Sprites does not have an eventsheet assigned to it. When I told it to use the E_Manager eventsheet it worked fine for me. (you set the eventsheet under the Layout Properties on the left)

    You also need an instance of the UNDO sprite on any layout that you want to be able to use Undo on...

  • You also need an instance of the UNDO sprite on any layout that you want to be able to use Undo on...

    Good point, I didn't think about this! Maybe you can put it on the first layout only and set it as global.

  • Thanks for founding the issue AllanR I scratched my head why it didn't work on my project!

    dop2000 the problem I need to solve is that it will be too many objects to put on the layout which I want to keep clean, this is why I made the "L_SPRITES" Layout to put all the objects I'll create there so I can see them organized and keep adding more and more.

    Is there a way I can still do that with the "L_SPRITES" maybe if I'll put the UNDO/REDO system on "L_SPRITES" event sheet (I need to create) + make the objects Global? I didn't tried it yet, but wondering if there is a solution to make it work when the objects are not actually on the "L_Workspace" layout.

    Any simple alternative solution to NOT put them on the "L_Workspace" ?

  • I don't know your layout structure. For this system to work, one instance of UNDO object should be present on all layouts where you need undo/redo.

  • I don't know your layout structure. For this system to work, one instance of UNDO object should be present on all layouts where you need undo/redo.

    My layout structure is basically: ALL layouts in the projects included on "L_Workspace" beside that, the main events is the biggest event sheet called: "E_MANAGER". I guess I have no choice but to actually put all hundreds of my objects in the "L_Workspace" with the current system, the reason it worries me is that's BEFORE the user will add hundreds of items on the same layout while creating more and more.

    But if it's the only way to make this wonderful system to work, I'll put everything on "L_Workspace" of course.

    Applying: Angle / Size

    I'm trying my luck with Rotate / Resize to work with your UNDO / REDO system, I almost made it working but it's not working exactly... I'm trying to make sure it won't save on every tiny change but only when the specific action keys released, here is the current version:

    DOWNLOAD C3 Remake TEST

    It's a mess, I know... but that's not even close to how complex my project is so I try to practice on this much more cleaner project based on your system. :)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • This is not an easy task. You need to open console (F12) in preview and check how often the game is saved for different operations.

    Here is for example how I would deal with rotation - add a new flag stepSaveRequired and set this flag while object is rotated, but don't call "SaveStep" yet. Only when keyboard button is released and the flag is set, then call the function. You will need to do something similar for other operations. (you can re-use the flag of course)

    .

  • Thanks for the example and explanation, to be honest it is scary for me how complex it will become as more as I'll use more actions (not just rotate and size) later on... so I need to think if I should use an UNDO / REDO system at all.

    The amazing thing is that I didn't even realize it is possible in C3, and to think that there are no actual limits so far (beside the fact that I'm not even close to understand how to program these yet) still very encouraging.

    I will have to see if I can.. or should actually apply this to my project because my original goal is to keep it simple, but I think some users will get upset if a basic function such as UNDO is not there.

    Once again, thank you so much dop2000 your help is always appreciated!

  • OK, I would like to begin TRYING to give an UNDO/REDO system a chance to appear in my software.

    Please forget about the earlier posts because I would like to start from zero the reason is:

    As I'm working on my software, I noticed that it became bigger and bigger as I add more features that are actually needed and not just adding for fun.

    So, if anyone can help me out work on an UNDO/REDO system with the option or "way of thinking" that will allow me to update or ADD that I will just need to tweak or edit later on in order to tell these new features events to be included in the UNDO/REDO system.

    Because there are features that need to be affected by UNDO/REDO and some that are NOT!

    for example: EXPORT PNG FILE, or click on menu buttons in general, and so on..

    The main issue is that I cannot share my software file, but I can share some project files to work on if that will help any of you guys to show me how it's done since I'm waaaay noob to understand how to program such complicated thing.

    The other issue I had was to exclude the SAVE PROJECT and LOAD PROJECT buttons also where effected by the UNDO/REDO system. it was super confusing for my level to understand and fix so I want to start from scratch of course... with YOUR help, obviously I cannot do such DYNAMIC system by myself.

    So if it's possible to make a GENERAL working system that I can always tweak to ADD or EXCLUDE what will or will not affected by UNDO / REDO it will be very useful for me to actually have it on my software.

    I'm sharing a pretty clean C3 Project that you can do your tests on it as you wish, and if possible to make all the UNDO/REDO in its dedicated Folder and PLEASE: add comments to help me understand what should I tweak or not in order to make NEW futures events later on.

    I'll probably have some questions later but for now... please have a look:

    DOWNLOAD - Experimental C3 File with some basic features

    Thanks everyone for you help, I appreciate it and I hope that I'll learn something from this.

  • So what's wrong with my Undo system that uses system Save/Load actions? I understand that you need to tweak your events in order not to call "SaveUndoStep" too often (only when any operation is finished) and it may be a difficult task. But you will have the same challenge with any other Undo system! Because if, for example, you are rotating an object and saving 100 undo steps along the way, you will need to press Ctrl-Z 100 times to undo that rotation.

    So yeah, it doesn't matter if the undo system saves information into local storage, or array, recreates objects or not, you still need to figure out how and when you are saving undo step for every operation in your app.

    .

    Here is an idea that just came to me - if everything in your app is done with mouse, use a single "On mouse button released" event to save undo steps! Set a flag UndoStepSaveRequired=true in all events when any object is changed/created/deleted, you can do this on every tick, no problem. Then in "On mouse button released" event you check for this flag and call the function to save undo step if needed.

  • Dear dop2000 actually your UNDO/REDO is the BEST I tried so far but the real problem was in my side, not yours. as I explained in my last post: I don't know how to apply NEW features, or exclude those that I don't want to apply to the UNDO/REDO system.

    Not everything on my actual project is based on MOUSE but lots of it based on HOTKEYS and actual BUTTONS (unfocus issues) as well, at least it will be added more and more, the mouse have some important part but not all of it.

    Will you PLEASE even copy/past your last UNDO/REDO and try apply it to my latest post C3 FILE that I attached but maybe if possible you can put a comment to explain what each line does or even examples of what should I do In-Code if I want to INCLUDE or EXCLUDE an event?

    I mean, if it's something that you can explain inside the code with comments I guess it will be VERY DYNAMIC Undo/Redo System! which will be very helpful for me to put on my bigger project!

    I think your undo/redo system will be perfect but last time I was confused with it and this is why I made the latest much cleaner and organized file, please have a look at it if you can.

    * Same file from my last post:

    DOWNLOAD - Experimental C3 File with some basic features

    Thanks ahead this is very helpful and encouraging!

  • You've already tried implementing my Undo system and made good progress with it. Why do you want to start from scratch and do the same job again? I'm sorry, but this is your project. I've already invested several hours into this and I can't do the whole job for you. At least not for free :)

    You've got the essentials working. All you need to do now is adding "SaveStep" function call to all features in the app where Undo is needed. With features triggered by keyboard shortcuts or on-screen buttons it should be very easy - just call "SaveStep" at the end of events. Similar with features that have any sort of "On finished" trigger (like "On drag end") - add "SaveStep" there.

    With some other operations like rotation this can be a little trickier. You need to set stepSaveRequired=true flag while the object is rotated, and call "SaveStep" function when mouse or keyboard button is released. See my screenshot in this comment.

  • Sorry for making you work too hard on this, I always say thanks and honestly I do appreciate every second of your time and anyone else who helps to noobs like myself on the community.

    I didn't mean to piss you off or anything, I apologize, I'm not as smart as you these things that may look obvious and super easy to follow are not for somebody like myself as I have no experience with programming at all and C3 basics logics are the only things I can do at this time with my low-level.

    I explained why I did it from scratch, and had no problem to Copy/Past what you did starting over on the latest file because it was more organized and clean so I could actually had a tiny chance to follow and understand using comments and groups.

    Also sorry about my bad English and about the mess I may cause, it's very hard for me to explain my issues but I still try as it's part of my learning progress.

    Please don't feel you must help me anymore if you don't feel like it, I do appreciate what you did so far and still thinks you're one of the most helpful persons around the community.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)