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
- IMovableKeyEventHandler
- IMovableLeftClickHandler
- IMovableRightClickHandler
- IMovableDeleteAreaHandler - for notifications of MovableArea.DeleteOnDisable deletions