From b6eaad7f77a3659caeb8710321cce57b6693fb80 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 30 Aug 2022 13:15:22 -0400 Subject: [PATCH] Add border API functions to manual --- docsrc/manual/scripting-capabilities.rst | 79 ++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/docsrc/manual/scripting-capabilities.rst b/docsrc/manual/scripting-capabilities.rst index d86208cc..b82bb3cd 100644 --- a/docsrc/manual/scripting-capabilities.rst +++ b/docsrc/manual/scripting-capabilities.rst @@ -118,6 +118,15 @@ Callbacks :param object prevBlock: the block's state before it was modified. The object's shape is ``{metatileId, collision, elevation, rawValue}`` :param object newBlock: the block's new state after it was modified. The object's shape is ``{metatileId, collision, elevation, rawValue}`` +.. js:function:: onBorderMetatileChanged(x, y, prevMetatileId, newMetatileId) + + Called when a border metatile is changed. + + :param number x: x coordinate of the block + :param number y: y coordinate of the block + :param number prevMetatileId: the metatile id of the border block before it was modified + :param number newMetatileId: the metatile id of the border block after it was modified + .. js:function:: onBlockHoverChanged(x, y) Called when the mouse enters a new map block. @@ -138,6 +147,15 @@ Callbacks :param number newWidth: the width of the map after the change :param number newHeight: the height of the map after the change +.. js:function:: onBorderResized(oldWidth, oldHeight, newWidth, newHeight) + + Called when the dimensions of the border are changed. + + :param number oldWidth: the width of the border before the change + :param number oldHeight: the height of the border before the change + :param number newWidth: the width of the border after the change + :param number newHeight: the height of the border after the change + .. js:function:: onMapShifted(xDelta, yDelta) Called when the map is updated by use of the Map Shift tool. @@ -165,6 +183,12 @@ Callbacks :param number oldTab: the index of the previously selected tab :param number newTab: the index of the newly selected tab +.. js:function:: onBorderVisibilityToggled(visible) + + Called when the visibility of the border and connecting maps is toggled on or off. + + :param boolean visible: whether the border is now visible + Functions ~~~~~~~~~ @@ -213,6 +237,24 @@ The following functions are related to editing the map's blocks or retrieving in :param boolean forceRedraw: Force the map view to refresh. Defaults to ``true``. Redrawing the map view is expensive, so set to ``false`` when making many consecutive map edits, and then redraw the map once using ``map.redraw()``. :param boolean commitChanges: Commit the changes to the map's edit/undo history. Defaults to ``true``. When making many related map edits, it can be useful to set this to ``false``, and then commit all of them together with ``map.commit()``. +.. js:function:: map.getBorderMetatileId(x, y) + + Gets the metatile id of a block in the border of the currently-opened map. + + :param number x: x coordinate of the block + :param number y: y coordinate of the block + :returns number: the metatile id of the block + +.. js:function:: map.setBorderMetatileId(x, y, metatileId, forceRedraw = true, commitChanges = true) + + Sets the metatile id of a block in the border of the currently-opened map. + + :param number x: x coordinate of the block + :param number y: y coordinate of the block + :param number metatileId: the metatile id of the block + :param boolean forceRedraw: Force the map view to refresh. Defaults to ``true``. Redrawing the map view is expensive, so set to ``false`` when making many consecutive map edits, and then redraw the map once using ``map.redraw()``. + :param boolean commitChanges: Commit the changes to the map's edit/undo history. Defaults to ``true``. When making many related map edits, it can be useful to set this to ``false``, and then commit all of them together with ``map.commit()``. + .. js:function:: map.getCollision(x, y) Gets the collision of a block in the currently-opened map. (``0`` = passable, ``1`` = impassable) @@ -323,6 +365,24 @@ The following functions are related to editing the map's blocks or retrieving in :returns number: the height of the map +.. js:function:: map.getBorderDimensions() + + Gets the dimensions of the border of the currently-opened map. + + :returns {width, height}: the dimensions of the border + +.. js:function:: map.getBorderWidth() + + Gets the width of the border of the currently-opened map. + + :returns number: the width of the border + +.. js:function:: map.getBorderHeight() + + Gets the height of the border of the currently-opened map. + + :returns number: the height of the border + .. js:function:: map.setDimensions(width, height) Sets the dimensions of the currently-opened map. @@ -342,6 +402,25 @@ The following functions are related to editing the map's blocks or retrieving in :param number height: height in blocks +.. js:function:: map.setBorderDimensions(width, height) + + Sets the dimensions of the border of the currently-opened map. If the config setting ``use_custom_border_size`` is set to ``0`` then this does nothing. + + :param number width: width in blocks + :param number height: height in blocks + +.. js:function:: map.setBorderWidth(width) + + Sets the width of the border of the currently-opened map. If the config setting ``use_custom_border_size`` is set to ``0`` then this does nothing. + + :param number width: width in blocks + +.. js:function:: map.setBorderHeight() + + Sets the height of the border of the currently-opened map. If the config setting ``use_custom_border_size`` is set to ``0`` then this does nothing. + + :param number height: height in blocks + .. js:function:: map.redraw() Redraws the entire map area. Useful when delaying map redraws using ``forceRedraw = false`` in certain map editing functions.