Overlay

Methods
39
Fields
5

Getting one

Overlay.new(…)

Methods

MethodReturnsDescription
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()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)…
setPosition(OverlayPosition)()Sets where the overlay goes; DYNAMIC and TOOLTIP make it neither movable nor snappable, DETACHED movable only, the rest both.
getPosition()OverlayPositionThe 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()OverlayLayerThe layer.
setPriority(number)()(Overlay, number) -> (): Sets the priority (Overlay.PRIORITY_*): dynamic overlays with a higher one draw later, others earlier.
setPriority(OverlayPriority)()
getPriority()numberThe 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()RectangleWhere it was last drawn: location and the size render answered. A copy.
setMovable(boolean)()Whether Alt-drag may move it.
isMovable()booleanWhether Alt-drag may move it.
setSnappable(boolean)()Whether it may be dropped on a snap corner.
isSnappable()booleanWhether it may be dropped on a snap corner.
setResizable(boolean)()Whether Alt-drag on an edge resizes it.
isResizable()booleanWhether Alt-drag on an edge resizes it.
setResettable(boolean)()Whether Alt-right-click resets it.
isResettable()booleanWhether Alt-right-click resets it.
setDragTargetable(boolean)()Whether other overlays may be dragged onto it (its onDrag decides).
isDragTargetable()booleanWhether other overlays may be dragged onto it.
setMinimumSize(number)()The smallest a resize may make it (default 32).
getMinimumSize()numberThe 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)booleanCalled 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 `…

Fields

FieldTypeDescription
PRIORITY_LOWnumberOverlay.PRIORITY_LOW: 0.0.
PRIORITY_DEFAULTnumberOverlay.PRIORITY_DEFAULT: 0.25.
PRIORITY_MEDnumberOverlay.PRIORITY_MED: 0.5.
PRIORITY_HIGHnumberOverlay.PRIORITY_HIGH: 0.75.
PRIORITY_HIGHESTnumberOverlay.PRIORITY_HIGHEST: 1.0.

Returned by

MethodReturnsDescription
OverlayClass.newOverlay() -> Overlay: Overlay is abstract, so build your own subclass (class(Overlay), whose new runs this constructor first). Called on `…
OverlayMenuClicked.getOverlayOverlay?The overlay the entry is on, in the overlay's own plugin; nil in another plugin (no object crosses between plugins).

Method details

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.

render

render: (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.

getName

getName: (Overlay) -> 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). Override it to choose another.

setPosition

setPosition: (Overlay, OverlayPosition) -> ()

Sets where the overlay goes; DYNAMIC and TOOLTIP make it neither movable nor snappable, DETACHED movable only, the rest both.

setLayer

setLayer: (Overlay, OverlayLayer) -> ()

Sets the layer it draws in (default UNDER_WIDGETS). Takes effect when the manager next rebuilds its layers (add, remove, save).

setPriority

setPriority: ((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.

getPreferredLocation

getPreferredLocation: (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.

getPreferredSize

getPreferredSize: (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.

setDragTargetable

setDragTargetable: (Overlay, boolean) -> ()

Whether other overlays may be dragged onto it (its onDrag decides).

drawAfterInterface

drawAfterInterface: (Overlay, number) -> ()

Also draw after interface interfaceId (usually with layer MANUAL).

drawAfterLayer

drawAfterLayer: ((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).

addMenuEntry

addMenuEntry: (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.

onMouseOver

onMouseOver: (Overlay) -> ()

Called after a render in which the pointer was over it (and no menu was open). Does nothing; override it.

onDrag

onDrag: (Overlay, Overlay) -> boolean

Called when other is dropped on this drag-targetable overlay: true consumes the drop. False; override it.

revalidate

revalidate: (Overlay) -> ()

Called when its placement was reset. Does nothing; override it.

new

new: (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).