Revolutionary-Games/Thrive — pull request #210 by HariboTer (2014-08-24 14:15:00+00:00)
Title: Implemented undo/redo-feature for MicrobeEditor

Using a closure-based action-command pattern, the MicrobeEditor now internally maintains a list of all changes that can be un- and redone if possible.

- every organelle action as well as creating a new microbe can be un- and redone

- entering the microbe editor and loading a microbe reset the action history

- Since the GUI is being overhauled atm, the implementation is purely code-based and can be used with Ctrl+U for undo and Ctrl+R for redo (because Z and Y are swapped between general European and other keyboard standards, using them has been avoided to prevent confusion until a more compatible solution is implemented)

- To perform an action with undo/redo-support, use the enqueueAction() function and provide it with a table that has an undo() and a redo() function (and optionally, a (MP) cost member).

Other notes:

- fixed a bug that would cause the organelleCount to be incremented always in addProcessOrganelle() and addAgentVacuole(), no matter the actual validity of the user action. This caused some stat calculations to become corrupt if the user had tried to place corresponding organelles on hexes that were already occupied.
- tinily improved the variable usage in main_menu_hud.lua
- removed some checks for currentMicrobe to be ~= nil in the input processing of the MicrobeEditorHUD, as I could not gather any sign for it to be relevant.