init
init: (Overlay, any?) -> ()X.super.init(self, plugin) in a subclass's init does nothing: X.new(...) has run Overlay's constructor before X:init(...). Keep the call or drop it.
Overlay.new(…)| Method | Returns | Description |
|---|---|---|
init(any?) | () | X.super.init(self, plugin) in a subclass's init does nothing: X.new(...) has run Overlay's constructor before X:init(...). Keep t… |
render(Graphics2D) | Dimension? | Draws the overlay with graphics (translated to the overlay's location, in the font its position calls for) and answers its size, or nil.… |
getName() | string | The overlay's name, the key its saved position is stored under: the class's __name, else a stable per-plugin fallback (see the class doc)… |
setPosition(OverlayPosition) | () | Sets where the overlay goes; DYNAMIC and TOOLTIP make it neither movable nor snappable, DETACHED movable only, the rest both. |
getPosition() | OverlayPosition | The position. |
setLayer(OverlayLayer) | () | Sets the layer it draws in (default UNDER_WIDGETS). Takes effect when the manager next rebuilds its layers (add, remove, save). |
getLayer() | OverlayLayer | The layer. |
setPriority(number) | () | (Overlay, number) -> (): Sets the priority (Overlay.PRIORITY_*): dynamic overlays with a higher one draw later, others earlier. |
setPriority(OverlayPriority) | () | |
getPriority() | number | The priority. |
setPreferredLocation(Point?) | () | Sets the location the user dragged it to (relative to its origin), or nil. |
getPreferredLocation() | Point? | The preferred location, or nil: the very Point given to setPreferredLocation, until the user drags or resets the overlay; then the one… |
setPreferredSize(Dimension?) | () | Sets the preferred size, or nil. |
getPreferredSize() | Dimension? | The preferred size, or nil: the very Dimension given to setPreferredSize, until the user resizes or resets the overlay; then the one th… |
setPreferredPosition(OverlayPosition?) | () | Sets the snap corner the user dropped it on, or nil. |
getPreferredPosition() | OverlayPosition? | The preferred position, or nil. |
getBounds() | Rectangle | Where it was last drawn: location and the size render answered. A copy. |
setMovable(boolean) | () | Whether Alt-drag may move it. |
isMovable() | boolean | Whether Alt-drag may move it. |
setSnappable(boolean) | () | Whether it may be dropped on a snap corner. |
isSnappable() | boolean | Whether it may be dropped on a snap corner. |
setResizable(boolean) | () | Whether Alt-drag on an edge resizes it. |
isResizable() | boolean | Whether Alt-drag on an edge resizes it. |
setResettable(boolean) | () | Whether Alt-right-click resets it. |
isResettable() | boolean | Whether Alt-right-click resets it. |
setDragTargetable(boolean) | () | Whether other overlays may be dragged onto it (its onDrag decides). |
isDragTargetable() | boolean | Whether other overlays may be dragged onto it. |
setMinimumSize(number) | () | The smallest a resize may make it (default 32). |
getMinimumSize() | number | The smallest a resize may make it. |
drawAfterInterface(number) | () | Also draw after interface interfaceId (usually with layer MANUAL). |
drawAfterLayer(number, number) | () | (Overlay, number, number) -> (): Also draw after layer widget (groupId, childId). Raises outside 0..65535. |
drawAfterLayer(number) | () | |
getDrawHooks() | {number} | The draw hooks (a copy). |
addMenuEntry(MenuAction, string, string, ((any) -> ())?) | OverlayMenuEntry | (Overlay, MenuAction, string, string) -> OverlayMenuEntry: Adds a shift-right-click entry; picking it posts OverlayMenuClicked. |
removeMenuEntry(MenuAction, string, string) | () | Removes the first equal entry. |
getMenuEntries() | {OverlayMenuEntry} | The live list of entries: table.insert adds. |
onMouseOver() | () | Called after a render in which the pointer was over it (and no menu was open). Does nothing; override it. |
onDrag(Overlay) | boolean | Called when other is dropped on this drag-targetable overlay: true consumes the drop. False; override it. |
getParentBounds() | Rectangle? | The area dragging keeps it inside, or nil for the canvas. Nil; override it. |
revalidate() | () | Called when its placement was reset. Does nothing; override it. |
new(any?) | Overlay | () -> Overlay: Overlay is abstract, so build your own subclass (class(Overlay), whose new runs this constructor first). Called on `… |
| Field | Type | Description |
|---|---|---|
PRIORITY_LOW | number | Overlay.PRIORITY_LOW: 0.0. |
PRIORITY_DEFAULT | number | Overlay.PRIORITY_DEFAULT: 0.25. |
PRIORITY_MED | number | Overlay.PRIORITY_MED: 0.5. |
PRIORITY_HIGH | number | Overlay.PRIORITY_HIGH: 0.75. |
PRIORITY_HIGHEST | number | Overlay.PRIORITY_HIGHEST: 1.0. |
| Method | Returns | Description |
|---|---|---|
OverlayClass.new | Overlay | () -> Overlay: Overlay is abstract, so build your own subclass (class(Overlay), whose new runs this constructor first). Called on `… |
OverlayMenuClicked.getOverlay | Overlay? | The overlay the entry is on, in the overlay's own plugin; nil in another plugin (no object crosses between plugins). |
initinit: (Overlay, any?) -> ()X.super.init(self, plugin) in a subclass's init does nothing: X.new(...) has run Overlay's constructor before X:init(...). Keep the call or drop it.
renderrender: (Overlay, Graphics2D) -> Dimension?Draws the overlay with graphics (translated to the overlay's location, in the font its position calls for) and answers its size, or nil. Abstract: a subclass defines it.
getNamegetName: (Overlay) -> stringThe overlay's name, the key its saved position is stored under: the class's __name, else a stable per-plugin fallback (see the class doc). Override it to choose another.
setPositionsetPosition: (Overlay, OverlayPosition) -> ()Sets where the overlay goes; DYNAMIC and TOOLTIP make it neither movable nor snappable, DETACHED movable only, the rest both.
getPositiongetPosition: (Overlay) -> OverlayPositionThe position.
setLayersetLayer: (Overlay, OverlayLayer) -> ()Sets the layer it draws in (default UNDER_WIDGETS). Takes effect when the manager next rebuilds its layers (add, remove, save).
getLayergetLayer: (Overlay) -> OverlayLayerThe layer.
setPrioritysetPriority: ((Overlay, number) -> ()) & ((Overlay, OverlayPriority) -> ())(Overlay, number) -> (): Sets the priority (Overlay.PRIORITY_*): dynamic overlays with a higher one draw later, others earlier.
(Overlay, OverlayPriority) -> (): The deprecated form: LOW, NONE, MED, HIGH, HIGHEST map to PRIORITY_LOW ... PRIORITY_HIGHEST.
getPrioritygetPriority: (Overlay) -> numberThe priority.
setPreferredLocationsetPreferredLocation: (Overlay, Point?) -> ()Sets the location the user dragged it to (relative to its origin), or nil.
getPreferredLocationgetPreferredLocation: (Overlay) -> Point?The preferred location, or nil: the very Point given to setPreferredLocation, until the user drags or resets the overlay; then the one the renderer set.
setPreferredSizesetPreferredSize: (Overlay, Dimension?) -> ()Sets the preferred size, or nil.
getPreferredSizegetPreferredSize: (Overlay) -> Dimension?The preferred size, or nil: the very Dimension given to setPreferredSize, until the user resizes or resets the overlay; then the one the renderer set.
setPreferredPositionsetPreferredPosition: (Overlay, OverlayPosition?) -> ()Sets the snap corner the user dropped it on, or nil.
getPreferredPositiongetPreferredPosition: (Overlay) -> OverlayPosition?The preferred position, or nil.
getBoundsgetBounds: (Overlay) -> RectangleWhere it was last drawn: location and the size render answered. A copy.
setMovablesetMovable: (Overlay, boolean) -> ()Whether Alt-drag may move it.
isMovableisMovable: (Overlay) -> booleanWhether Alt-drag may move it.
setSnappablesetSnappable: (Overlay, boolean) -> ()Whether it may be dropped on a snap corner.
isSnappableisSnappable: (Overlay) -> booleanWhether it may be dropped on a snap corner.
setResizablesetResizable: (Overlay, boolean) -> ()Whether Alt-drag on an edge resizes it.
isResizableisResizable: (Overlay) -> booleanWhether Alt-drag on an edge resizes it.
setResettablesetResettable: (Overlay, boolean) -> ()Whether Alt-right-click resets it.
isResettableisResettable: (Overlay) -> booleanWhether Alt-right-click resets it.
setDragTargetablesetDragTargetable: (Overlay, boolean) -> ()Whether other overlays may be dragged onto it (its onDrag decides).
isDragTargetableisDragTargetable: (Overlay) -> booleanWhether other overlays may be dragged onto it.
setMinimumSizesetMinimumSize: (Overlay, number) -> ()The smallest a resize may make it (default 32).
getMinimumSizegetMinimumSize: (Overlay) -> numberThe smallest a resize may make it.
drawAfterInterfacedrawAfterInterface: (Overlay, number) -> ()Also draw after interface interfaceId (usually with layer MANUAL).
drawAfterLayerdrawAfterLayer: ((Overlay, number, number) -> ()) & ((Overlay, number) -> ())(Overlay, number, number) -> (): Also draw after layer widget (groupId, childId). Raises outside 0..65535.
(Overlay, number) -> (): Also draw after the layer component (a packed id).
getDrawHooksgetDrawHooks: (Overlay) -> {number}The draw hooks (a copy).
addMenuEntryaddMenuEntry: (Overlay, MenuAction, string, string, ((any) -> ())?) -> OverlayMenuEntry(Overlay, MenuAction, string, string) -> OverlayMenuEntry: Adds a shift-right-click entry; picking it posts OverlayMenuClicked.
(Overlay, MenuAction, string, string, ((any) -> ())?) -> OverlayMenuEntry: Adds a shift-right-click entry that calls callback with the game's MenuEntry when it is picked.
removeMenuEntryremoveMenuEntry: (Overlay, MenuAction, string, string) -> ()Removes the first equal entry.
getMenuEntriesgetMenuEntries: (Overlay) -> {OverlayMenuEntry}The live list of entries: table.insert adds.
onMouseOveronMouseOver: (Overlay) -> ()Called after a render in which the pointer was over it (and no menu was open). Does nothing; override it.
onDragonDrag: (Overlay, Overlay) -> booleanCalled when other is dropped on this drag-targetable overlay: true consumes the drop. False; override it.
getParentBoundsgetParentBounds: (Overlay) -> Rectangle?The area dragging keeps it inside, or nil for the canvas. Nil; override it.
revalidaterevalidate: (Overlay) -> ()Called when its placement was reset. Does nothing; override it.
newnew: (any?) -> Overlay() -> Overlay: Overlay is abstract, so build your own subclass (class(Overlay), whose new runs this constructor first). Called on Overlay itself it makes a bare overlay with no render.
(any?) -> Overlay: As new(); the plugin is the caller's to keep (self.plugin = plugin).