Monday, April 16, 2018

FMod - Clipboard API

The ability to have multiple blocks of tiles on hand would be made much easier to implement if Abiathar had a more central notion of the clipboard. The Abiathar architecture may be a bit unusual: a lot of what looks integral is actually from an (automatically loaded) extension called the Abiathar Standard Toolkit. There's not much special about the standard toolkit relative to other extensions that anyone can write, but if it wasn't loaded Abiathar wouldn't be very useful - this extension provides all the normal tools and gives the "hey, I know what that is" to the core project file section when the "claim your configuration section" event bus comes around.

Since only tools need to know about the clipboard, the idea of the clipboard only exists in the standard toolkit extension; Abiathar proper doesn't know anything about it. This makes it difficult for third-party extensions to work with the clipboard, in addition to making the multiple-clipboard feature request challenging to implement. So today I moved the clipboard into the Abiathar core and added an API for it. Whenever anything sets the clipboard, an event bus is dispatched. The standard toolkit extension responds to the notification by producing its old alert to the tools it controls.

Overall the change was straightforward. There was one snag involving the Essential Manipulator. When starting, it would initialize the clipboard, which generated a notification, which it caught and used to update the paste preview plane, and then it crashed because it hadn't finished setting up that plane. I think I've got everything worked out, since this is the only tool that both changes the clipboard and listens for changes.

While I was expanding the API, I added status properties to indicate whether there is an open project and whether there is a current level. Previously extensions had to do something gnarly like checking an internal variable belonging to the Abiathar core for null.

No comments:

Post a Comment