I wrote some stuff.

Razorfish
:)
Movable Plugin System

While working on RunStats v2 for TurboHUD, I started to play around with implementing plugins that can be moved around on the screen dynamically. After a few iterations and a game-changing tip about how to detect mouse clicks, I turned it into its own library to make it easier to write standalone plugins where you can drag, resize, and toggle the display on or off in-game and then save those modifications.

That's how I found myself working on drag and drop repositioning of menu items in RunStats v3 shortly thereafter. More on that later.

Unified Modification

Each plugin doesn't have to do it's own handling of mouse or key presses, and it doesn't have to define yet another hotkey for toggling stuff on or off, it can just focus on drawing data on the screen. A plugin that implements the IMovable interface will gain the ability to create movable areas that can be dragged around the screen and resized, and all of that code is handled behind the scenes by this library. All of the positions, dimensions, and movement delta values necessary to draw elements on the screen are provided to the Movable plugin via a PaintArea method, which works like PaintTopInGame.

Drag (or Hotkey) to Move

Press F12 to toggle Edit Mode on, which shows outlines of all the movable plugin display areas on the screen. You can drag and drop them freely while in this mode. Alternatively, because clicking around on the screen causes your character to move around or perform actions, you can press E (left) or R (right) to simulate a mouse click. To disable this or change its hotkey, change or unset SimulateLeftMouseClick and SimulateRightMouseClick properties in plugins\Razor\Click\ClickEventHandler.cs

Drag (or Hotkey) to Resize

While in Edit mode, hovering over a resizable plugin area shows little triangle corners on the bottom left and bottom right of the outline. Hovering over them will show what sort of resizing you can do. There are 4 Resize modes that plugins can specify: ResizeMode.On (free resize), ResizeMode.FixedRatio, ResizeMode.Horizontal, and ResizeMode.Vertical. Not all areas are resizable, just depends on the plugin and whether or not it does the extra size calculations.

Toggle Off or On (Hotkey)

While in Edit mode, press Ctrl + X while you have a plugin area selected or hovered over to toggle that area display on or off.

Undo (Hotkey)

While in Edit mode, press Ctrl + Z while you have a plugin area selected or hovered over to undo drag or resize actions applied to it.

Save Settings to File

Changing the position, size or on/off state of any of the movable areas will automatically generate a config file (MovablePluginConfig.txt) that you can copy from your TurboHUD\logs folder and rename and put into TurboHUD\plugins\User\MovablePluginConfig.cs. This will allow you to retain the changes you made when you load TH next time.

Note that TH version 20.7.12.0 or newer has a limitation on when log files can be written - only in menus or game difficulties below Torment 1 and not in special areas (such as rifts) - but the framework will wait until you're in a valid logging state before trying to create the config file.

As I understand it, RoS Bot's Tier 2 TH license retains this limitation, while the restriction has been lifted for Tier 3.

Hotkeys

All of these are configurable, with the variables mostly located in TurboHUD\plugins\Razor\Movable\MovableController.cs.

  • ToggleEditMode (F12) - toggle Edit Mode on or off
  • SimulateLeftMouseClick (E) - because when you click around the screen, D3 moves your character around and interacts with the game world, it's probably easier just to press a hotkey to simulate a mouse click - edit this in TurboHUD\plugins\Razor\Click\ClickEventHandler.cs
  • SimulateRightMouseClick (R) - because when you click around the screen, D3 moves your character around and interacts with the game world, it's probably easier just to press a hotkey to simulate a mouse click - edit this in TurboHUD\plugins\Razor\Click\ClickEventHandler.cs
  • ToggleEnable (Ctrl + X) - toggle display on or off
  • ToggleGrid (Ctrl + G) - toggle placement grid display on or off
  • HotkeyUndo (Ctrl + Z) - undo movement or resize
  • HotkeyUndoAll (Ctrl + 0) - undo all movements or resizes (ctrl + ZERO)
  • HotkeySave (Ctrl + S) - save config file now (this is separate from auto-save, but is still subject to the logging limitations of your TH version)
  • HotkeyCancel (Esc) - cancel your current move or resize action
  • HotkeyPickupNext (Right) - cycle forwards through all areas under your cursor and pick up the next one
  • HotkeyPickupPrev (Left) - cycle backwards through all areas under your cursor and pick up the previous one

Visibility Checking

Movable plugins are rendered during the ClipState.BeforeClip step by default, and it will properly disable rendering, click and hotkey events as necessary while obscured by (sharing the same space as) most visible game interface elements.


Custom Handlers

The Movable system has its own optional handlers for hotkeys and click events that occur while the mouse cursor is hovering over a visible MovableArea. This makes it simple to code actions like "do something when you click on this MovableArea" or "do something when you use a hotkey while hovering over this MovableArea."
  • IMovableKeyEventHandler
  • IMovableLeftClickHandler
  • IMovableRightClickHandler
  • IMovableDeleteAreaHandler - for notifications of MovableArea.DeleteOnDisable deletions
Installation

I separated the optional plugins that implement the Movable plugin system from the core download. Any plugins I write that use the Movable Plugin system will be tagged with the Movable label.

These are core files and are required for the system to work. Please put the files and folders into the following locations, as outlined in the download archive:

TurboHUD \ plugins \ Razor \ Click \ ClickEventHandler.cs
TurboHUD \ plugins \ Razor \ Click \ ILeftClickHandler.cs
TurboHUD \ plugins \ Razor \ Click \ IRightClickHandler.cs
TurboHUD \ plugins \ Razor \ Hotkey \ HotkeyEventHandler.cs
TurboHUD \ plugins \ Razor \ Hotkey \ IHotkeyEventHandler.cs
TurboHUD \ plugins \ Razor \ Log \ ITextLogger.cs
TurboHUD \ plugins \ Razor \ Log \ TextLogger.cs
TurboHUD \ plugins \ Razor \ Movable \ IMovable.cs
TurboHUD \ plugins \ Razor \ Movable \ IMovableDeleteAreaHandler.cs
TurboHUD \ plugins \ Razor \ Movable \ IMovableKeyEventHandler.cs
TurboHUD \ plugins \ Razor \ Movable \ IMovableLeftClickHandler.cs
TurboHUD \ plugins \ Razor \ Movable \ IMovableRightClickHandler.cs
TurboHUD \ plugins \ Razor \ Movable \ MovableArea.cs
TurboHUD \ plugins \ Razor \ Movable \ MovableController.cs
TurboHUD \ plugins \ Razor \ Movable \ ResizeMode.cs
TurboHUD \ plugins \ Razor \ Util \ UIOverlapHelper.cs

Movable Plugin System [Tier 2] has delayed config file writing (limitations of TH).
Movable Plugin System [Tier 3] has immediate config file writing.

Last Updated Apr 24, 2021

For Plugin Authors

If you would like to have your plugin use the Movable system, I've included a heavily commented example plugin template in the download to explain how to implement it.

MyMovablePluginTemplate.cs





Latest Movable