Thursday, July 6, 2017

Abiathar API - Tools

Tools are the preferred method of providing functionality to Abiathar. Tool objects implement either IAbiatharLevelTool (for level tools) or IAbiatharTilesetTool (for tileset tools). These both inherit from IAbiatharTool, which has these members:

  • Name is the tool's name for display in the Tools menu.
  • Icon is the image to place on the Tools menu. This can be null if you do not want an icon.
  • ShortcutKey specifies the tool's keyboard shortcut. Key numbers are Windows Forms key codes. This can be null if the tool does not have a shortcut.
  • ShortcutText is the text to show on the right of the item in the Tools menu.
  • HandlesKeyPress returns whether the tool should receive key events while active.
  • KeyPress is called when a key is pressed. Return whether the press should be considered handled. This is only called if the tool handles key presses.
  • CanBeDefault returns whether it's acceptable for the user to set this tool as their default. For example, the Tile Placer can be the default level tool, but the Level Inspector cannot.
Level tools also have these members:
  • StartUse is called when the tool is switched to. It provides the current level.
  • SwitchLevel is called when the current level changes while the tool is active. It provides the new level.
  • Canceled is called when the tool is switched away from. It includes whether the cancel was initiated by the CancelTool method.
  • HandlesInLevelClick returns whether the tool should receive click events for the level.
  • InLevelClick is called when the user clicks in the level. It includes the coordinates and whether it is a right-click. This is only called if the tool handles clicks.
  • HandlesInLevelMouseMove returns whether the tool should receive mouse movement events.
  • InLevelMouseMove is called when the mouse is moved in the level. It includes the current mouse coordinates in tiles and whether the left and right buttons are being held down. This is only called if the tool handles mouse movement.
Tileset tools have these members in addition to the generic tool members, very similar to the level tool members but with tileset parameters instead of levels:
  • StartUse is like a level tool's StartUse.
  • SwitchSet is like a level tool's SwitchLevel.
  • Canceled is like a level tool's Canceled.
  • HandlesTileClick is like a level tool's HandlesInLevelClick.
  • TileClick is like a level tool's InLevelClick.
  • HandlesTileMouseMove is like a level tool's HandlesInLevelMouseMove.
  • TileMouseMove is like a level tool's InLevelMouseMove.
To register a tool, add it to the Tools list of an AbiatharRegisterToolsEvent (of IAbiatharLevelTool or IAbiatharTilesetTool, as appropriate) in the event bus.

No comments:

Post a Comment