Wednesday, March 25, 2015

FMod - Refactored Drag

Yesterday and today, I worked on moving the click-and-drag functionality (which is kind of a kludge) out of all the tools and into the Abiathar core. Previously, each tool had to have its own code to identify a click-and-drag because Abiathar only delivered click and mouse-move notifications. My goal is to have all tools support click-and-drag for region selection in addition to click-one-corner-then-the-other and for this behavior to be configurable with a single Boolean option.

This effort resulted in the creation of the SetClickDragTranslationMode API method, which only has an effect if the UseDrag config file option is set. Depending on the active tool's translation mode, Abiathar will deliver a click message at the beginning and end of a drag, or at each tile dragged across. Tools still receive the InLevelMouseMove notifications, but I'm destroying the unwieldy drag detection code from those methods, leaving undo action accumulation. (I might refactor that up into AbiatharStandardLevelTool so I don't have to repeat myself.)

The Freeform Tile Placer was the first to take advantage of the API; it uses click-at-each-step translation. Coding the use of this feature is really nice - it's just a one-line SetClickDragTranslationMode call, then process each "click" as normal. Since the FFTP is now able to be either a one-tile-at-a-time tweaker or a pencil, the Tile Tweaker is redundant and is now gone. (That was kind of a symbolic experience for me - the Tile Tweaker was the first tool written for Abiathar. It's like I'm completely reforming the system!)

The Linker was the first test of the click-at-drag-endpoints mode. There were some bugs with that mode, but they were fixed fairly easily after stepping through what was going on. A single API call added drag functionality to an existing tool; the Linker didn't have it before!

The Paster has been reworked to use click-at-each-step translation, but there is a rather serious problem with my undo action accumulation, which I will investigate tomorrow.

No comments:

Post a Comment