Alon's Forum Posts

  • Why don't you just add and test? You could have done it in time you spent typing your comment..

    I was telling you many-many times - you need to prevent multiple saves from running at the same time! Adding this condition to the function will do exactly that.

    I just added the "isUndoSave is NOT set" to the "SaveStep" function:

    but to be honest, I got confused now... if I disable the Group: "MOUSE WHEEL - Cooldown" where the code.

    and ADD back again the "SaveStep" function to "On mouse wheel up" and "On mouse wheel down" (where the first ORIGINAL crashes used to be) still creates zillions of saves which make sense.

    But... it's NOT crashing (so it does what you're saying 1 save per time) which sounds pretty much SAFE to me.

    But there are ZILLION of undo saves since it's not saving ONLY AFTER the Wheel Scroll is finished but on every tiny scroll which is not functioning very well when I undo (too many undo's saved created to go back with no actual change between the Z-Order).

    MAYBE: the ALTERNATIVE approach should be based on the action itself and not the input?

    I don't know how to accomplish such thing (I tried), is it possible to call "SaveStep" AFTER every Z-Order change INSTEAD messing with the Scroll Wheel?

    It's probably a bad idea, but in my simple logical brain it seems like a nice alternative, I just have no clue how to do such thing in C3, I didn't find any option similar to: "On Every Z-Order change" or anything like that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Add a condition "isUndoSave is NOT set" to the "SaveStep" function. This will guarantee that another save will not start until previous save has finished. If you are saving too often, or the save size is too big, some undo steps may be skipped, but this is a minor issue comparing to all the bugs you can have from multiple simultaneously running saves.

    Wait, before I ruin anything... I don't understand what do you suggest:

    SHOULD I do what you just suggested (edit the function)? or I rather not do that? what option is LESS risky and most efficient?

    I'm asking because I really don't want to screw the way the all UNDO system currently works.

    because so far everything works GREAT... but again, tested only on my personal machine as I develop it so that's not the best indication.

  • And I think, you need to start learning something new, something useful and indeed extremely powerful... Arrays! They will improve undo/redo system so much. Just sit down and start learning. I mean really, nowadays there thousand of books/videos/tutorials on the internet, arrays is not something that is very complicated (although it might look like that at the start) compared to some other "programming stuff".

    Totally agree with this advice, I'm always RUNNING AWAY from Arrays, not because it's hard to understand.

    It's actually very logical, data based on Rows and Columns... blah blah blah, this has NEVER been the issues for me.

    The real issues was how to actually USE Arrays in C3... when it start the confusing: JSON (thinggy) AJAX (thinggy) things that doesn't make sense to me and so many properties for them that I can never GUESS because I don't know the programmers-terms, while in general it's just inserting data to the specific Array, change it, remove it, and other stuff that my non-programmer noobish brain can understand. but as always as soon as I get to C3 I'm scratching my head and don't know what or how to accomplish what's on "the paper".

    So I tried so many times to use arrays (from scratch on simple projects) in order to learn it specific in C3 since that's what I'm using... I always run away screaming and try to avoid this powerful tool (I just know how POWERFUL arrays can be) this is sad but... oh well.

    BTW - The UNDO/SYSTEM by dop2000 is based on a simple Array object. :)

    For now, I'm learning a lot (slowly, but learning a thing or two) while working on my current project with a HUGE thanks to this awesome community.

  • I wonder, are you using "No save" behavior?

    Yes, on anything that is not the instances such as GUI panels and such, anything that I don't need to save for next session.

  • And I'm saying that even 0.3s is not enough, especially if you anticipate users will be adding lots of objects. I've seen save/load actions taking more than 5 seconds.

    You need to make a proper system that doesn't allow two or more saves running at the same time.

    OH MY! That's REALLY good to know, thanks for sharing your experience! it sounds too risky if so, than maybe I should consider go back to the addition Release Key + Mouse Wheel for the extra safety? what do you think?

    My older version (before the delay) I used CTRL + Wheel Scroll UP/DOWN and once Releasing the CTRL the save undo function execute.

    The problem was that even if the user just Press and Release CTRL by itself it saves extra undos, this is why I didn't like it...

    Maybe a better solution is to combine on: Release CTRL + Wheel Scroll Finished (without delay?) for giving the OPTION for the "Scroll Finished" I didn't try it yet but I'm curious if I should.

    Unfortunately I don't see other solutions for "After Wheel Released" WITHOUT any extra Releasing key beside the current one which may cause issues on different machines now that I realize it.

  • Why did you make the delay even smaller? This means saving lots of unnecessary undo steps. Not only it can cause bugs, but also will make it more difficult for user to undo.

    Make sense, it's hard to make it work perfect for all machines but 0.3s may be too slow so I need to test it.

    Sure it works great on your PC, but on an older machine with a slow HDD saving a big project may take much longer time. 0.1s is probably good for my specific machine true I must play with it.

    The thing is that since it's ONLY be used for the Z-Order event my main goal was to immune that crash like an extra "Safety Layer" but I guess combined with the way the undo works I rather be careful and not use this cooldown for anything else so I won't cause delayed undos and a mess for the users.

    Regarding the number of steps - it depends on the average size of each save. Add some objects, open browser console, it should tell you the amount of data saved, in bytes. Multiply by the number of steps - that's how much memory the array will take.

    That sounds scary! because the user may create and tweak MANY objects over the canvas and tweak them around. From my current tests: I didn't have any issues with large amount of objects on the screen, no slowdowns no delays But once again... my computer is average+ I don't want to ruin the experience on older machines if it's an option.

    I doubt you will run out of memory even with 256 undo steps, but a very big array may be slow.

    That's encouraging! because I'm thinking about 64-128 UNDOS so I won't need to even give the user a need to change it manually.

    Thanks dop2000 that's VERY helpful!

  • Note that this method waits for a pause in scrolling, which is not an ideal solution in your case. If you keep this timeout at 0.3s, for users who scroll slowly (when they want to precisely adjust object size), undo will be saved every 0.3 seconds, which is still too frequent.

    If you set a larger timeout like 1-2 seconds, undo step will be saved with a big delay, during which user may do something else, for example delete the object. And this again can cause the situation when two undo steps are saved at the same time.

    Yes 0.3s is a bit slow (but safe) so I just did some tests and I stretched it to a faster delay such as 0.1 sec it works GREAT! even if I go like CRAZY FAST with the wheel I can easily undo back to the MAX limit on the UNDO object until it reaches the end "maxSteps" which I can easily change manually thanks to your dynamic Undo/Redo system dop2000! :)

    True that slow scroll is acting weird as you explained, but I don't see other way WITHOUT extra key to add for release to call the undo, so this is good for the Z-Order changes.

    I believe that it's very stable because it's only calling the UNDO function "SaveStep" AFTER as I wanted so it's emulating the same timing as I release a key real fast. maybe without the manual delay the scroll do multiple scrolls each time and it SUPER fast, that's the only reason I think it crashed originally.

    I WISH we had a built-in action for "AFTER WHEEL FINISHED" like this, it could be sooo useful for many things I do! I'm using the code by rokstars322 which is kind of tiny without the logs/coneole so it's still very nice!

    I'm sooo happy that it's solved and works exactly as I imagined! it is very efficient for my project :)

    UNDO / Memory Question:

    dop2000 I'm curious if you can tell me if it will be a problem if I'll push the maximum amount of undos from 30 to something like 64 or even 128 (which is too much but I'm curious)

    Memory wise... will this be an issue to old machines with 4GB RAM? consider there will be many objects on the screen that may also take memory.

    What is your suggestion about the maximum amount of UNDO'S for my software to keep it work nicely even on older machines?

    It's not that I'm making it FOR old machines, but it's always nice to have MORE machines be able to run my software.

    I still don't understand the Debugger/Profiler that should help me out with the memory and CPU (I GUESS?) so I'm asking in Theory if I should go for a HIGHER maximum UNDO limit without risk memory issues on older machines.

    I can always let the user change it with a menu I'll make but I'm talking about the defaults for now.

    Will 64 / 128 Undos be a REALLY bad idea? or not an issue at all?

  • > AFTER I scroll

    Its easy to make custom event, that will be triggered when user stop scrolling.

    A quck example: drive.google.com/file/d/1CUUe5aoDkdxJyfV1KOWbCrcDPETb6ORH/view

    YES!!! you're awesome rokstars322 THIS IS THE SOLUTION I was looking for!

    Thank you so much :)

    I wonder if someone could make this into a plugin or addon that could be used as a simple action because I could use it A LOT!

  • You do not have permission to view this post

  • If the undo needs to be saved, and it is saved, then why did you wrote that it is a problem and that it doesn't make sense? (your words, not mine) :)

    English is not my first language either, so there may be a misunderstanding on my part. Anyway, I hope you'll get everything working exactly as you want.

    That's right, I believe it's a misunderstanding (probably because I can't explain it better) your English is GREAT!

    In overall: the most important part is that the ORIGINAL bug is gone.

    What I tried to explain above is that the current "solution" is not the most efficient one, and I wish I could find a replacement for it based on the cursor wheel ALONE (without holding a button and releasing for sake of UNDO) in other words: saving the Undo only AFTER I scroll without crashing, which is impossible since it's saving to the Undo History too fast and that's what causing the original crash so I MUST use an EXTRA key to release, so it will cool-down the rate of saving undos.

    What I was looking for is a way to do the SAME (save undo) but WITHOUT any extra keys while scrolling up/down... not possible unfortunately and very incontinent for my software and the users.

    BUT! I'll just move on since the error is not there, that's the plus! :)

  • You wrote "if I just press and RELEASE CTRL by itself... it will create an UNDO"

    If you are using the flag correctly, this should not happen. When you press and release Ctrl or any other button, without actually changing any objects, undo step will not be saved. Only when anything about the object has been modified (scaled, moved on z-axis etc.), then you set the flag and undo step will be saved.

    Exactly!

    You still don't understand the issue... I NEED it to be saved why should I disable the undo?

    and it works fine but again... not as I need it to work, I described it few times above.

    I wish I could explain it better, sorry about my bad English.

  • > The problem here is if I just press and RELEASE CTRL by itself... it will create an UNDO which doesn't make any sense

    Sigh... We've been through this many times.

    You need to use a boolean flag IsUndoSaveRequired (or something like this). Set this flag to true when the object is resized. Check this flag when Ctrl is released and call SaveStep function only when the flag is true. If user just pressed and released Ctrl, the flag will false, and the undo step will not be saved.

    I don't understand what this is have to do with the issue I have mentioned with the issue at all?

    I'm afraid you didn't understand my issue with Releasing CTRL (by itself) since I must save after changing the Z-Order, so why should I not save it or using the isUndoSave boolean? it's nothing to do with the SaveStep or resizing since they work perfectly fine.

    The all point is that I have to hold another key with the middle mouse while scrolling Up or Down and I can't find another solution for this to work as scroll middle mouse (by iself) since it cause the issue, as you explained it is not a good idea to save so often or fast and it's totally make sense so I either NOT saving it to the undo history (which is not an option for me) or MUST hold a key so the SaveStep will execute ONLY once I RELEASE the CTRL (or any other key I choose) in order to slow-down the Undo/Redo so it won't cause the original issue. so yes, I do understand it you (Sensei dop2000) explained it very well from the moment you explained it saving too fast but what unfortunately I think there is no solution to scrolling middle mouse button WITHOUT releasing a key if I want a slowdown functioning Undo save.

    Just to be clear: I'm not complaining or anything, my limited English may seem like I do sometimes, it's because I'm trying my best to explain myself or the issue. but I'm always VERY thankful for any help. I must say HUGE THANKS especially to you dop2000 for your many tips, helps and solutions,  Thanks to YOU I have an AMAZING dynamic Undo/Redo system, I hope that you understand how thankful I am. :)

    Sorry for making you extremely tired from my posts, it is NOT that I do it on purpose I really try hard and if you'll read my posts and see the screenshots you will see that I'm not just asking things without trying first.

    Anyway, I'll continue to my next mission it's not that I didn't solve the current issue, it's just that it's not a very efficient solution to my use as I explained earlier why, once again: it works! (but it's a waste a really good use of the mouse wheel scroll by itself without extra keys because I have no other choice if I want the undo to work while not crashing or saving randomly.

    In Overall: it works (but not the way I want it to work, it's a "walk around") so I'll just move on for my next mission. :)

  • Thanks rokstars322 you sure gave some good advice, I'll explore a bit more what I can do or improve.

    At this point I'm using the CTRL + Scroll so the Undo/Redo save to slot once I release the CTRL.

    The problem here is if I just press and RELEASE CTRL by itself... it will create an UNDO which doesn't make any sense, and I tried other combinations such as SHIFT or other letters on the keyboard, even Spacebar... nothing make sense in the specific workflow of my software only CTRL or NONE, but Scrolling without any EXTRA key to release will make the UNDO go nuts...

    As I said, if I had some action for something like "When Scroll UP (or Down) finished" I could use it not only to FIX this annoying issue, but also for many other features! but once again... there is no such action so it doesn't matter.

    Thanks for sharing your advice and experience, I appreciate it! :)

  • You can change the controls you use to scale objects. Make it Ctrl+Wheel for example, and save undo step on Ctrl released.

    Yeah, I it's the only temporary fix I had in mind and it's a waste of use for the wheel alone, but I'll just have to hold a key and use the wheel for something that doesn't need an undo.

    Also, it will create an Undo if I'll just release the CTRL by itself which is not ideal.

    I wish we had an extra addon or plugin or a feature for extra action such as: "on Finish Wheel Scroll UP" (or Down) I could use that for so many other things on my software not even related to this specific issue that's for sure but oh well... WE DON'T have such feature! lol :)

  • The correct solution is to not save a new undo step until previous save has completed.

    From my tries, it didn't work with the "Wait for previous actions to complete" so what's the alternative way to do it?

    Of course other software are using different methods for undo, you are welcome to try some other system if this doesn't work for you.

    Unfortunately, I don't even know what are the alternative systems to emulate a safer or more efficient undo/redo system so I don't think it's an option I can go for.

    Beside that, I must be honest: not only that I LOVE the current UNDO/REDO system thanks to you of course (I appreciate it A LOT!) so far EVERYTHING I tested works GREAT! but ONLY THIS specific annoying fast-wheel issue which make things go nuts... users will have so many crashes and random SAVE appears from nowhere.

    Also, save only one undo step after user finished resizing the object. Saving dozens of steps for one resizing operation is a bad idea anyway

    This is how most of my other actions works, on release key it calls: "SaveStep" function so it's very safe.

    But the Mouse Wheel actions have no "on release" or something close because it's not a keyboard of course.. I wish it has after or per one-sliding or something... that could solve the issue EASY! (I can only dream for such features hehe)

    The only Temporary Fix which is not an actual solution is to hold a key while scrolling so it will call the "SaveStep" function only when releasing it. the reason it's the ideal a solution is because I need to add another key instead of just using the scroll freely without holding any any extra key (waste of use).

    Isn't there a other way to somehow LIMIT or Slowing-Down the current code on the wheel up/down over instances?

    Thanks ahead! any help is more than welcome and very appreciated! :)