Author Topic: Undo in the editor  (Read 1194 times)

0 Members and 1 Guest are viewing this topic.

Offline Simon

  • Administrator
  • Posts: 2926
    • View Profile
    • Lix
Re: Undo in the editor
« Reply #15 on: September 26, 2020, 12:39:00 pm »
I have undoable duplication of tiles (copy-paste without a copy buffer). There is a regression left behind: The newly inserted tiles aren't yet selected. The old selection remains, which is practically never what you want.

New to-do list:
  • Enrich all Undoables to suggest which tiles should be selected after apply/undo. Main reason are copy-pasting Undoables, but it will be handy for insertions and undone deletions.
  • Rotations and mirroring must become undoable.
  • Z-ordering (move to foreground/background) must become undoable.
  • Hotkeys Z and Y will bind to undo/redo by default. Both are still free in the default editor layout.
  • Resizing of the map must become undoable, or clear the undo stack if we want to rush the feature's release.
There will also be lots of lovely refactoring for cleanup, but that's not necessary to release the undo feature. Since the Undoables do the bulk of the work, I will be able to ditch the Hover class hierarchy, which is parallel to the tile hierachy and has bugged me since I made the editor.



-- Simon
« Last Edit: September 26, 2020, 05:37:18 pm by Simon »

Offline Simon

  • Administrator
  • Posts: 2926
    • View Profile
    • Lix
Re: Undo in the editor
« Reply #16 on: October 18, 2020, 08:46:02 am »
Spent all Saturday on Undo. Progress:
  • Hotkeys Z and Y are bound to undo/redo by default. You can change it in Lix's options menu.
  • All Undoables will now suggest what tiles shall be selected after apply/undo. In particular:
    When you undo a deletion, the undeleted tiles will be selected.
    When you duplicate tiles, the newly inserted tiles will be selected.
  • Lots of refactoring towards immutability of the involved classes. But the asserts in the area where I considered triple dispatch have begun to fire when I duplicate a large selection of both gadgets and terrain tiles.
New to-do list:
  • Fix above bug in the undoable copy-paste.
  • Rotations and mirroring must become undoable.
  • Z-ordering (move to foreground/background) must become undoable.
  • Resizing of the map must become undoable, or clear the undo stack if we want to rush the feature's release.
Cleanup work that isn't necessary to release undo, but that I would like to tackle:
  • Ditch the Hover class hierarchy in the editor. This is a parallel class hierarchy that wrap a selecte tile. Work more directly with the raw selection of tiles.
  • Open a pull request against Phobos, the D standard library, to allow RedBlackTrees with immutable classes as payload.
  • Open another pull request against Phobos to make SortedRange const-correct. I would have preferred SortedRange over RedBlackTree for the Lix code from the beginning, but RedBlackTree had fewer roadblock bugs. :lix-evil:
  • Attempt to fix a compiler bug: 21321: Class with unimplemented interface method compiles, links, then segfaults, if inherited through abstract base class. I ran into this yesterday. It would be the first time that I seriously look at the D compiler's source, it's a large and scary codebase.


^ Illustration of a pull request. You must be careful, watch for feedback, and don't mind the time spent. I had one pull already merged into Phobos a month ago.

In the end, running into 4 library/compiler issues within one big Lix feature shows what parts of D are rarely treaded: Heavy object-orientation, exhausting and combining the OO features of D, making stuff transitively immutable where possible, and using the more obscure areas of the standard library.

Crane would be delighted, if it weren't all so template-heavy. :lix-blush:

-- Simon
« Last Edit: October 18, 2020, 09:26:16 am by Simon »

Offline Simon

  • Administrator
  • Posts: 2926
    • View Profile
    • Lix
Re: Undo in the editor
« Reply #17 on: October 19, 2020, 09:01:16 pm »
Lots of bugfixing this evening. Copypasting does the right thing now in all cases, I don't believe I have introduced other bugs yet. This resolves the bug in yesterday's to-do list.

I've begun with the class that applies/undoes tile rotation/mirroring/darkening. This will be exactly how ccexplore suggested I should implement tile moving. The exception is that the existing TileMove objects merge with one another if they're the same tiles that get dragged further during the same mouse dragging, or if they're simultaneously selected tiles that move the same distance. Rotating/mirroring/darkening will never merge with subsequent editing; it will only form a CompoundUndoable with the simultaneously selected tiles.



Thus, very successful evening. Now time for bed.

-- Simon

Offline WillLem

  • Posts: 1142
  • Octopus 9 and the Flying Colours
    • View Profile
Re: Undo in the editor
« Reply #18 on: October 22, 2020, 06:19:47 pm »
I'm enjoying all these cute gifs :cute: :crylaugh: