Add documentation for prefabs

This commit is contained in:
Marcus Huderle
2022-09-10 13:08:48 -05:00
parent b14d8b8a88
commit b92fdaf94e
42 changed files with 3335 additions and 955 deletions

View File

@@ -18,6 +18,7 @@ Porymap Documentation
manual/editing-wild-encounters
manual/creating-new-maps
manual/region-map-editor
manual/tileset-editor
manual/scripting-capabilities
manual/project-files
manual/shortcuts

View File

@@ -60,7 +60,7 @@ Object events are typically used for NPCs (non-player-characters). More technic
Object Event Properties
Id
This is the local id of the object in the map. Some script values use this local id to specify object when using scripting commands such as `applymovement`.
This is the local id of the object in the map. Some script values use this local id to specify an object when using scripting commands such as `applymovement`.
Sprite
The sprite that is used by the object.
@@ -83,8 +83,27 @@ Trainer Type
Sight Radius or Berry Tree ID
If the object is a trainer, this property control how many tiles the trainer can see to spot the player for battle. If the object is a berry tree, this specifies the global id of the berry tree. Each berry tree in the game has a unique berry tree id.
In Connection
Exclusive to pokefirered. Used to replace objects that are visible in a map's connection with their corresponding object on the connecting map. When checked, these objects will make odd use of other fields; its trainer type value will be the connecting map number, its Sight Radius / Berry Tree Id will be the connecting map group, and its z coordinate will be the object's local id on the connecting map.
Clone Object Events
-------------------
Clone Object events are a special type of object that inherits its properties from another Object event. They are used in-game to load objects that are visible in the connecting area of adjacent maps. The targeted object to clone is specified by id and map name. If the targeted object does not exist, or it's also a clone, the sprite for graphics id 0 will be displayed instead. Double-clicking on a Clone Object will open the targeted map with the targeted object selected. This event type is exclusive to pokefirered projects; the code to process them does not exist in pokeemerald/pokeruby.
.. figure:: images/editing-map-events/event-clone-object.png
:alt: Clone Object Event Properties
Clone Object Event Properties
Id
This is the local id of the object in the map. Some script values use this local id to specify an object when using scripting commands such as `applymovement`.
Sprite
The sprite that is used by the object. Clone Objects inherit their sprite from the targeted object, so this cannot be edited. This field is not actually read by the game.
Target Local Id
The local id of the object to be cloned.
Target Map
The name of the map the object to be cloned is on.
.. _event-warps:

View File

@@ -167,3 +167,31 @@ Undo & Redo
-----------
When painting metatiles, you can undo and redo actions you take. This makes it very easy to fix mistakes or go back in time. Undo can be performed with ``Ctrl+Z`` or *Edit -> Undo*. Redo can be performed with ``Ctrl+Y`` or *Edit -> Redo*.
Prefabs
-------
Prefabs, or "prefabricated selections", are a way to optimize your map-editing workflow by defining pre-built metatile selections. This can be useful when larger map objects can't be selected from the main metatile selector window. For example, the Poké Mart building is only partially selectable in the metatile selector view.
.. figure:: images/editing-map-tiles/prefab-list.png
:alt: Prefab Tab
Prefab Tab
To create a new prefab, simply select a group of metatiles from the main map view. (See the `Selecting Metatiles`_. section above for how to use right-click-drag to select from the map area.) Then, click the "Create from Selection" button. This will bring up the following window where individual metatiles can be toggled on/off in the prefab. You can also give your prefab a name.
.. figure:: images/editing-map-tiles/prefab-create.png
:alt: Prefab Creation Window
Prefab Creation Window
Prefabs are designated for whichever primary and secondary tilesets were used to create them. As such, any prefabs for with tilesets that are incompatible with the currently-opened map will be hidden from the Prefab list.
To select a prefab to use for painting on the map, simply click on the prefab image in the list view.
.. figure:: images/editing-map-tiles/prefab-demo.gif
:alt: Painting with a Prefab
Painting with a Prefab
Prefab data is saved to a JSON file. It defaults to ``<project_root>/prefabs.json``. However, it can be configured in Porymap's project config file.

View File

@@ -73,7 +73,8 @@ Wild Pokémon Tab
Tileset Editor
--------------
The Tileset Editor can be opened with *File -> Tileset Editor* (``Ctrl+T``). When the Tileset Editor is opened, it is opened in the context of the currently-opened map. Every map has a primary and secondary tileset, so you will work with a combination of the two whenever you use the Tileset Editor. The left-side pane shows the primary and secondary tilesets' metatiles. The right-side panes allow you to modify the currently-selected metatile.
The Tileset Editor can be opened with *File -> Tileset Editor* (``Ctrl+T``).
Check out :ref:`The Tileset Editor <tse-ref>` section for more details.
.. figure:: images/navigation/tileset-editor.png
:alt: Tileset Editor
@@ -83,11 +84,13 @@ The Tileset Editor can be opened with *File -> Tileset Editor* (``Ctrl+T``). Wh
Region Map Editor
-----------------
The Region Map Editor can be opened with *File -> Region Map Editor* (``Ctrl+M``). This window will allow you to modify the look and layout of maps on the game's region map. You can also modify the city map images using the bottom two panes. Currently the Region Map Editor is only available for pokeemerald and pokeruby projects.
The Region Map Editor can be opened with *File -> Region Map Editor* (``Ctrl+M``).
This window will allow you to modify the look and layout of maps on the game's region map.
Check out :ref:`The Region Map Editor <rme-ref>` section for more details.
.. figure:: images/navigation/region-map-editor.png
:alt: Region Map Editor
Region Map Editor
We covered all of the basic views and windows of Porymap above. Next, let's learn how to use Porymap's features to the fullest when editing map tiles.
We covered all of the basic views and windows of porymap above. Next, let's learn how to use Porymap's features to the fullest when editing map tiles.

View File

@@ -1,25 +1,76 @@
.. _rme-ref:
*********************
The Region Map Editor
*********************
This is where you edit the region map for your game. To open the region map
editor, navigate to *Tools -> Region Map Editor* from porymap's main window.
This is where you edit the region maps for your game. You are able to edit the
background tilemap, the layout of map sections, and the array of map section entries
which determines the dimensions of each section.
.. note::
The region map editor is currently only available for pokeemerald and pokeruby.
To open the region map editor, navigate to *Tools -> Region Map Editor* from
porymap's main window. There is also a keyboard shortcut which is by default ``Ctrl+M``.
When you first open the region map editor, your window will look like this:
When you first open the region map editor, you will need to configure porymap to
read your region map data. There are defaults for every base game project available
which should be sufficient for most users.
.. figure:: images/region-map-editor/rme-new-window.png
:scale: 75%
.. figure:: images/region-map-editor/new-configure-window.png
:align: center
:width: 75%
:alt: RME Window
Region Maps Configurator
Porymap supports multiple region maps for any project.
By default, pokeemerald and pokefirered use this feature.
For a more custom region map, you can use the *Add Region Map...* button to
create a new region map configuration from scratch. You can also double-click on any existing
region map in the list to bring this window up to make changes.
.. figure:: images/region-map-editor/rme-config-properties.png
:align: center
:width: 50%
:alt: RME Config Prop
Region Map Properties Window
This window has many options for users to define:
.. csv-table::
:header: Field,Explanation,Restrictions
:widths: 10, 30, 20
alias,something for porymap to distinguish between your maps,unique & valid json string
**Tilemap Properties**,,
format,format of the tiles,Plain *or* 4bpp *or* 8bpp
width,width *in tiles* of the tilemap,16 *or* 32 *or* 64 *or* 128
height,height *in tiles* of the tilemap,valid corresponding height based on width
tileset path,the relative path to the tile image from project root,valid filepath string
tilemap path,the relative path to the tilemap binary from project root,valid filepath string
palette path,*optional* relative path to ``.pal`` file from project root,valid filepath string
**Layout Properties**,*can be unchecked for maps without layouts*,
format,the format to read the layout file,C array *or* binary
layout path,the relative path from project root to layout file,valid filepath string
width,the width of the layout,non-negative integer
left offset,the position on the tilemap which defines layout x=0,width + left offset < tilemap width
height,the height of the layout,non-negative integer
top offset,the position on the tilemap which defines layout y=0,height + top offset < tilemap height
When you are finished configuring your region maps, you can select *OK*. This will
display the main editor window.
.. figure:: images/region-map-editor/rme-main-window.png
:align: center
:width: 75%
:alt: RME Config Prop
Region Map Editor Window
This window is split vertically--the region map editing is done at the top,
while the zoomed-in city maps are edited at the bottom. You can use the
sliders to zoom in and out on each of the view panes. You will notice
This window has a combobox labeled "Region" which you can use to select the current
region map you want to edit.
You will notice
that there are three different tabs above the image of the region map
(:ref:`Background Image <background-image-tab>`,
:ref:`Map Layout <map-layout-tab>`,
@@ -39,24 +90,13 @@ are unhappy with what you have done, you can undo (``Ctrl+Z`` or *Edit -> Undo*)
and redo (``Ctrl+Y`` or *Edit -> Redo*) your changes. Right-clicking on the map
image will select the tile under your mouse from the tile selector.
If your tilemap format is not "Plain", then you can also select the palette,
h-flip, and v-flip of any tile you are painting with.
If you want to clear the background image, *Edit -> Clear Background Image*
will set all tiles to the first tile in the tile selector.
.. figure:: images/region-map-editor/rme-painting-image.gif
:scale: 75%
:align: center
:alt: RME Paint
Drawing on the Region Map Image
It is likely that you will want to use your own tiles for your region map. You
can import a tile image by navigating to *Tools -> Import Region Map Image Tiles*.
There are strict requirements for your region map tile image. It must (1) be
indexed with a 256 color palette\*, (2) be composed of 8x8 pixel tiles, (3) have 256
or fewer tiles.
\* While the region map tile image requires a 256-color palette, the image only
uses the 32 colors beginning at index 112 in the palette.
You can use the sliders to zoom in and out on each of the view panes.
.. _map-layout-tab:
@@ -67,9 +107,9 @@ The layout tab is where map sections are placed on the region map. When the
player looks at the region map in-game, the layout determines the map under the
cursor.
.. figure:: images/region-map-editor/rme-layout-tab.png
:scale: 75%
.. figure:: images/region-map-editor/rme-new-layout-tab.png
:align: center
:width: 75%
:alt: RME Layout
RME Layout Tab
@@ -78,29 +118,15 @@ To modify the region map layout, select a position by clicking on the map image
and higlighting a single square. The "Map Section" combobox will be populated
with all of the map sections defined in ``include/constants/region_map_sections.h``.
Select the map section you want to associate with the selected position on the
region map. To change the popup name of the map section when you enter the map,
type it into the "Map Name" box. The popup name is tied to the map section, so
each layout square with the same map section will share a name.
region map.
If you want to start from a blank layout, *Edit -> Clear Map Layout* will set
all layout squares to the value of ``MAPSEC_NONE``.
There are a couple of tools which make editing multiple layout squares simultaneously easier.
When adding new region map sections, the layout will be affected. This is
because the layout is stored as a binary file and uses the raw value of each
map section. In order to fix your layout to account for this, you can swap two
values for the entire layout with *Edit -> Swap*.
*Edit -> Clear Map Layout* will set all squares in the layout to ``MAPSEC_NONE``.
In this example, ``MAPSEC_NEW_MAPSEC`` is inserted before ``MAPSEC_NONE``, and
therefore the layout will link the original value of ``MAPSEC_NONE`` to the new
map section ``MAPSEC_NEW_MAPSEC``. Instances of ``MAPSEC_NEW_MAPSEC`` are swapped
with ``MAPSEC_NONE``.
*Edit -> Swap Layout Sections...* will exchange two layout sections with each other.
.. figure:: images/region-map-editor/rme-layout-swap.gif
:scale: 75%
:align: center
:alt: RME Swap
Swapping Map Sections
*Edit -> Replace Layout Section...* will replace all instances of one section with another.
The "Delete Square" button simply resets a single layout square to ``MAPSEC_NONE``.
@@ -111,10 +137,10 @@ Map Entries Tab
A region map entry is the area on the region map that spans an entire map section.
This determines, for example, where the player's head appears on the region map
in-game. Entries are stored at ``src/data/region_map/region_map_entries.h``.
in-game. Entries are stored in ``src/data/region_map/region_map_sections.json``.
.. figure:: images/region-map-editor/rme-entries-tab.png
:scale: 75%
.. figure:: images/region-map-editor/rme-new-entries-tab.png
:width: 75%
:align: center
:alt: RME Entries
@@ -126,29 +152,8 @@ You can also drag the entry around the map. The "x" and "y" values correspond t
the position of the entry's top-left square on the region map. The "Dimensions"
"width" and "height" spinboxes will change the size of the map entry.
City Maps
---------
In the bottom half of the region map editor window, city maps can be edited.
You paint on this the same way you paint on the region map background image.
.. figure:: images/region-map-editor/rme-painting-city.gif
:scale: 60%
:align: center
:alt: City Paint
Drawing on the City Map
To use custom tiles, there is a tile image importer under
*Tools -> Import City Map Image Tiles*. These images must (1) be indexed with a
16 color palette, (2) be made up of 8x8 pixel tiles, (3) have 256 or fewer tiles.
You can add a new city map by pressing the |new-city-map-button| button.
.. |new-city-map-button|
image:: images/region-map-editor/rme-new-city-map-button.png
Currently, it is not possible to associate a city map to a region map location,
but that functionality will be added in a future update.
To change the popup name of the map section when you enter the map, type it
into the "Map Name" box.

View File

@@ -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
~~~~~~~~~
@@ -190,11 +214,21 @@ The following functions are related to editing the map's blocks or retrieving in
: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 number collision: the collision of the block (``0`` = passable, ``1`` = impassable)
:param number collision: the collision of the block (``0`` = passable, ``1-3`` = impassable)
:param number elevation: the elevation 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.setBlock(x, y, rawValue, forceRedraw = true, commitChanges = true)
Sets a block in the currently-opened map. This is an overloaded function that takes the raw value of a block instead of each of the block's properties individually.
:param number x: x coordinate of the block
:param number y: y coordinate of the block
:param number rawValue: the 16 bit value of the block. Bits ``0-9`` will be the metatile id, bits ``10-11`` will be the collision, and bits ``12-15`` will be the elevation.
: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.getMetatileId(x, y)
Gets the metatile id of a block in the currently-opened map.
@@ -213,9 +247,27 @@ 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)
Gets the collision of a block in the currently-opened map. (``0`` = passable, ``1-3`` = impassable)
:param number x: x coordinate of the block
:param number y: y coordinate of the block
@@ -223,7 +275,7 @@ The following functions are related to editing the map's blocks or retrieving in
.. js:function:: map.setCollision(x, y, collision, forceRedraw = true, commitChanges = true)
Sets the collision of a block in the currently-opened map. (``0`` = passable, ``1`` = impassable)
Sets the collision of a block in the currently-opened map. (``0`` = passable, ``1-3`` = impassable)
:param number x: x coordinate of the block
:param number y: y coordinate of the block
@@ -323,6 +375,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 +412,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(height)
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.
@@ -350,6 +439,143 @@ The following functions are related to editing the map's blocks or retrieving in
Commits any uncommitted changes to the map's edit/undo history. Useful when delaying commits using ``commitChanges = false`` in certain map editing functions.
Map Header Editing Functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The following functions are related to reading/writing the map's header properties.
.. js:function:: map.getSong()
Gets the name of the background song for the currently-opened map.
:returns string: the name of the song
.. js:function:: map.setSong(song)
Sets the name of the background song for the currently-opened map. The song name must be one of the names in the "Song" dropdown menu on the Header tab.
:param string song: the name of the song
.. js:function:: map.getLocation()
Gets the name of the region map location for the currently-opened map.
:returns string: the name of the location
.. js:function:: map.setLocation(location)
Sets the name of the region map location for the currently-opened map. The location name must be one of the names in the "Location" dropdown menu on the Header tab.
:param string location: the name of the location
.. js:function:: map.getRequiresFlash()
Gets whether flash would be required in-game for the currently-opened map.
:returns boolean: whether flash is required
.. js:function:: map.setRequiresFlash(require)
Sets whether flash would be required in-game for the currently-opened map.
:param boolean require: whether flash should be required
.. js:function:: map.getWeather()
Gets the name of the weather for the currently-opened map.
:returns string: the name of the weather
.. js:function:: map.setWeather(weather)
Sets the name of the weather for the currently-opened map. The weather name must be one of the names in the "Weather" dropdown menu on the Header tab.
:param string weather: the name of the weather
.. js:function:: map.getType()
Gets the name of the map type for the currently-opened map.
:returns string: the name of the map type
.. js:function:: map.setType(type)
Sets the name of the map type for the currently-opened map. The map type name must be one of the names in the "Type" dropdown menu on the Header tab.
:param string type: the name of the map type
.. js:function:: map.getBattleScene()
Gets the name of the battle scene for the currently-opened map.
:returns string: the name of the battle scene
.. js:function:: map.setBattleScene(battleScene)
Sets the name of the battle scene for the currently-opened map. The battle scene name must be one of the names in the "Battle scene" dropdown menu on the Header tab.
:param string battleScene: the name of the battle scene
.. js:function:: map.getShowLocationName()
Gets whether the location name will appear in-game for the currently-opened map.
:returns boolean: whether the location name will be shown
.. js:function:: map.setShowLocationName(show)
Sets whether the location name should appear in-game for the currently-opened map.
:param boolean show: whether the location name should be shown
.. js:function:: map.getAllowRunning()
Gets whether running is allowed in-game for the currently-opened map.
:returns boolean: whether running is allowed
.. js:function:: map.setAllowRunning(allow)
Sets whether running should be allowed in-game for the currently-opened map.
:param boolean allow: whether running should be allowed
.. js:function:: map.getAllowBiking()
Gets whether biking is allowed in-game for the currently-opened map.
:returns boolean: whether biking is allowed
.. js:function:: map.setAllowBiking(allow)
Sets whether biking should be allowed in-game for the currently-opened map.
:param boolean allow: whether biking should be allowed
.. js:function:: map.getAllowEscaping()
Gets whether escaping (using Escape Rope or Dig) is allowed in-game for the currently-opened map.
:returns boolean: whether escaping is allowed
.. js:function:: map.setAllowEscaping(allow)
Sets whether escaping (using Escape Rope or Dig) should be allowed in-game for the currently-opened map.
:param boolean allow: whether escaping should be allowed
.. js:function:: map.getFloorNumber()
Gets the floor number for the currently-opened map.
:returns number: the floor number
.. js:function:: map.setFloorNumber(floorNumber)
Sets the floor number for the currently-opened map. Floor numbers can be any number between -128 and 127 inclusive.
:param number floorNumber: the floor number
Map Overlay Functions
^^^^^^^^^^^^^^^^^^^^^
@@ -405,6 +631,26 @@ The following functions are related to an overlay that is drawn on top of the ma
:param boolean visible: whether the layers should be showing
.. js:function:: map.getOverlayOpacity(layer = 0)
Gets the opacity of the specified overlay layer. Opacity ranges from 0 (invisible) to 100 (completely opaque).
:param number layer: the layer id. Defaults to ``0``
:returns number: the opacity
.. js:function:: map.setOverlayOpacity(opacity, layer = 0)
Sets the opacity of the specified overlay layer. Opacity ranges from 0 (invisible) to 100 (completely opaque).
:param number opacity: the opacity
:param number layer: the layer id. Defaults to ``0``
.. js:function:: map.setOverlaysOpacity(opacity)
Sets the opacity of all active overlay layers. Opacity ranges from 0 (invisible) to 100 (completely opaque).
:param number opacity: the opacity
.. js:function:: map.getOverlayX(layer = 0)
Gets the x position of the specified overlay layer.
@@ -525,18 +771,18 @@ The following functions are related to an overlay that is drawn on top of the ma
:param number layer: the layer id. Defaults to ``0``
:param boolean useCache: whether the image should be saved/loaded using the cache. Defaults to ``true``. Reading images from a file is slow. Setting ``useCache`` to ``true`` will save the image to memory so that the next time the filepath is encountered the image can be loaded from memory rather than the file.
.. js:function:: map.createImage(x, y, filepath, width = -1, height = -1, offset = 0, xflip = false, yflip = false, paletteId = -1, setTransparency = false, layer = 0, useCache = true)
.. js:function:: map.createImage(x, y, filepath, width = -1, height = -1, offset = 0, hScale = 1, vScale = 1, paletteId = -1, setTransparency = false, layer = 0, useCache = true)
Creates an image item on the specified overlay layer. This differs from ``map.addImage`` by allowing the new image to be a transformation of the image file.
:param number x: the x pixel coordinate of the image's top-left corner (relative to the layer's position)
:param number y: the y pixel coordinate of the image's top-left corner (relative to the layer's position)
:param string filepath: the image's filepath
:param number width: the image width. If ``-1``, use the full width of the original image. Defaults to ``-1``
:param number height: the image height. If ``-1``, use the full height of the original image. Defaults to ``-1``
:param number width: the width in pixels of the area to read in the image. If ``-1``, use the full width of the original image. Defaults to ``-1``
:param number height: the height in pixels of the area to read in the image. If ``-1``, use the full height of the original image. Defaults to ``-1``
:param number offset: the pixel offset into the original image where data should be read from. Defaults to ``0``
:param boolean xflip: whether the image should be a horizontal flip of the original image. Defaults to ``false``
:param boolean yflip: whether the image should be a vertical flip of the original image. Defaults to ``false``
:param number hScale: the horizontal scale for the image. Negative values will be a horizontal flip of the original image. Defaults to ``1``
:param number vScale: the vertical scale for the image. Negative values will be a vertical flip of the original image. Defaults to ``1``
:param number paletteId: the id of which currently loaded tileset palette to use for the image. If ``-1``, use the original image's palette. Defaults to ``-1``
:param boolean setTransparency: whether the color at index 0 should be overwritten with transparent pixels. Defaults to ``false``
:param number layer: the layer id. Defaults to ``0``
@@ -887,6 +1133,22 @@ The following functions are related to tilesets and how they are rendered. The f
:param number metatileId: id of target metatile
:param number behavior: the behavior
.. js:function:: map.getMetatileAttributes(metatileId)
Gets the raw attributes value for the specified metatile.
:param number metatileId: id of target metatile
:returns number: the raw attributes value
.. js:function:: map.setMetatileAttributes(metatileId, attributes)
Sets the raw attributes value for the specified metatile.
**Warning:** This function writes directly to the tileset. There is no undo for this. Porymap will not limit the value of existing attributes to their usual range.
:param number metatileId: id of target metatile
:param number attributes: the raw attributes value
.. js:function:: map.getMetatileTile(metatileId, tileIndex)
Gets the tile at the specified index of the metatile.
@@ -957,7 +1219,11 @@ The following functions are related to tilesets and how they are rendered. The f
:param number tileEnd: index of the last tile to set. Defaults to ``-1`` (the last tile)
: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()``.
.. js:function:: map.getTilePixels(tileId)
Gets the pixel data for the specified tile. The pixel data is an array of indexes indicating which palette color each pixel uses. Tiles are 8x8, so the pixel array will be 64 elements long.
:returns array: the pixel data
Settings Functions
^^^^^^^^^^^^^^^^^^
@@ -1006,6 +1272,12 @@ The following functions are related to settings.
:returns string: ``"pokeruby"``, ``"pokefirered"``, or ``"pokeemerald"``
.. js:function:: map.getPorymapVersion()
Gets the current version of Porymap (``MAJOR.MINOR.PATCH``).
:returns {major, minor, patch}: the version object
.. js:function:: map.getCustomScripts()
Gets the list of paths to custom scripts.
@@ -1068,9 +1340,74 @@ These are some miscellaneous functions that can be very useful when building cus
:param string message: the message to log
.. js:function:: map.error(message)
Logs a message to the Porymap log file with the prefix ``[ERROR]``.
:param string message: the message to log
.. js:function:: map.showMessage(text, informativeText, detailedText)
Displays a message box with an "Information" icon and an ``OK`` button. Execution stops while the window is open.
:param string text: the main message text
:param string informativeText: smaller text below the main message. Defaults to ``""``
:param string detailedText: text hidden behind a "Show Details" box. Defaults to ``""``
.. js:function:: map.showWarning(text, informativeText, detailedText)
Displays a message box with a "Warning" icon and an ``OK`` button. Execution stops while the window is open.
:param string text: the main message text
:param string informativeText: smaller text below the main message. Defaults to ``""``
:param string detailedText: text hidden behind a "Show Details" box. Defaults to ``""``
.. js:function:: map.showError(text, informativeText, detailedText)
Displays a message box with a "Critical" icon and an ``OK`` button. Execution stops while the window is open.
:param string text: the main message text
:param string informativeText: smaller text below the main message. Defaults to ``""``
:param string detailedText: text hidden behind a "Show Details" box. Defaults to ``""``
.. js:function:: map.showQuestion(text, informativeText, detailedText)
Displays a message box with a "Question" icon and a ``Yes`` and a ``No`` button. Execution stops while the window is open.
:param string text: the main message text
:param string informativeText: smaller text below the main message. Defaults to ``""``
:param string detailedText: text hidden behind a "Show Details" box. Defaults to ``""``
:returns boolean: ``true`` if ``Yes`` was selected, ``false`` if ``No`` was selected or if the window was closed without selection
.. js:function:: map.getInputText(title, label, default)
Displays a text input dialog with an ``OK`` and a ``Cancel`` button. Execution stops while the window is open.
:param string title: the text in the window title bar
:param string label: the text adjacent to the input entry area
:param string default: the text in the input entry area when the window is opened. Defaults to ``""``
:returns {input, ok}: ``input`` will be the input text and ``ok`` will be ``true`` if ``OK`` was selected. ``input`` will be ``""`` and ``ok`` will be ``false`` if ``Cancel`` was selected or if the window was closed without selection.
.. js:function:: map.getInputNumber(title, label, default, min, max, decimals, step)
Displays a number input dialog with an ``OK`` and a ``Cancel`` button. Execution stops while the window is open.
:param string title: the text in the window title bar
:param string label: the text adjacent to the input entry area
:param number default: the number in the input entry area when the window is opened. Defaults to ``0``
:param number min: the minimum allowable input value. Defaults to ``-2147483648``
:param number max: the maximum allowable input value. Defaults to ``2147483647``
:param number decimals: the number of decimals used for the input number. Defaults to ``0``
:param number step: the increment by which the input number will change when the spinner is used. Defaults to ``1``
:returns {input, ok}: ``input`` will be the input number and ``ok`` will be ``true`` if ``OK`` was selected. ``input`` will be ``default`` and ``ok`` will be ``false`` if ``Cancel`` was selected or if the window was closed without selection.
.. js:function:: map.getInputItem(title, label, items, default, editable)
Displays a text input dialog with an items dropdown and an ``OK`` and a ``Cancel`` button. Execution stops while the window is open.
:param string title: the text in the window title bar
:param string label: the text adjacent to the input entry area
:param array items: an array of text items that will populate the dropdown
:param number default: the index of the item to select by default. Defaults to ``0``
:param boolean editable: whether the user is allowed to enter their own text instead. Defaults to ``false``
:returns {input, ok}: ``input`` will be the input text and ``ok`` will be ``true`` if ``OK`` was selected. ``input`` will be the text of the item at ``default`` and ``ok`` will be ``false`` if ``Cancel`` was selected or if the window was closed without selection.

View File

@@ -17,6 +17,7 @@ determined by this file.
:widths: 10, 3, 5, 5, 20
``recent_project``, , global, yes, The project that will be opened on launch
``reopen_on_launch``, 1, global, yes, Whether the most recent project should be opened on launch
``recent_map``, , global, yes, The map that will be opened on launch
``pretty_cursors``, 1, global, yes, Whether to use custom crosshair cursors
``map_sort_order``, group, global, yes, The order map list is sorted in
@@ -39,13 +40,14 @@ determined by this file.
``use_custom_border_size``, 0, project, yes, Whether to allow variable border sizes
``enable_event_weather_trigger``, 1 if not ``pokefirered``, project, yes, Allows adding Weather Trigger events
``enable_event_secret_base``, 1 if not ``pokefirered``, project, yes, Allows adding Secret Base events
``enable_event_clone_object``, 1 if ``pokefirered``, project, yes, Allows adding Clone Object events
``enable_hidden_item_quantity``, 1 if ``pokefirered``, project, yes, Adds ``Quantity`` to Hidden Item events
``enable_hidden_item_requires_itemfinder``, 1 if ``pokefirered``, project, yes, Adds ``Requires Itemfinder`` to Hidden Item events
``enable_heal_location_respawn_data``, 1 if ``pokefirered``, project, yes, Adds ``Respawn Map`` and ``Respawn NPC`` to Heal Location events
``enable_object_event_in_connection``, 1 if ``pokefirered``, project, yes, Adds ``In Connection`` to Object events
``enable_floor_number``, 1 if ``pokefirered``, project, yes, Adds ``Floor Number`` to map headers
``create_map_text_file``, 1 if not ``pokeemerald``, project, yes, A ``text.inc`` or ``text.pory`` file will be created for any new map
``enable_triple_layer_metatiles``, 0, project, yes, Enables triple-layer metatiles (See https://github.com/pret/pokeemerald/wiki/Triple-layer-metatiles)
``custom_scripts``, , project, yes, A list of script files to load into the scripting engine
``prefabs_filepath``, ``<project_root>/prefabs.json``, project, yes, The filepath containing prefab JSON data
Some of these settings can be toggled manually in porymap via the *Options* menu.

View File

@@ -0,0 +1,163 @@
.. _tse-ref:
*********************
The Tileset Editor
*********************
Here, you can edit individual tilesets.
When the Tileset Editor is opened, it is opened in the context of the
currently-opened map. Every map has a primary and secondary tileset, so you
will work with a combination of the two whenever you use the Tileset Editor.
The left-side pane shows the primary and secondary tilesets' metatiles.
The right-side panes allow you to modify the currently-selected metatile.
.. figure:: images/tileset-editor/tse-open-window.png
:align: center
:width: 75%
:alt: TSE Window
Tileset Editor Window
Metatile Properties
===================
.. figure:: images/tileset-editor/tse-metatile-properties.png
:align: center
:width: 30%
:alt: MP Frame
Metatile Properties Panel
Layer Type
----------
Defines the background layers the metatiles will use for drawing.
The options are:
**Normal** --- Metatile uses middle and top bg layers
**Covered** --- Metatile uses bottom and middle bg layers
**Split** --- Metatile uses bottom and top bg layers
Metatile Behavior
-----------------
Defines the metatile behavior associated with this metatile. This can be used
for a variety of different reasons. For example, warps, ice, and tall grass effects
are all determined by a metatile's behavior.
This dropdown is populated with constants found in ``include/constants/metatile_behaviors.h``.
Encounter Type
--------------
*pokefirered exclusive*
Used to determine which category of wild encounter to attempt.
Terrain Type
------------
*pokefirered exclusive*
Used to determine certain attributes of metatiles. Can be useful in certain scenarios.
For example, to determine if the player is facing water or standing in grass.
Metatile Label
--------------
*optional*
A name can be given to metatiles so that they may be referenced in source code.
These are defined in ``include/constants/metatile_labels.h`` and can be used in
together with the ``METATILE_ID`` macro.
For example, the metatile pictured above can be accessed like
``METATILE_ID(General, Plain_Grass)``.
Tools Menu
==========
The tileset editor provides users with several useful tools for making edits
easier and more convenient.
Import Tiles Image...
---------------------
Tool to automatically import a new tile image for a tileset.
The tile image is an indexed png of 8x8 pixel tiles, which are used to form
metatiles in the tileset editor.
Import Metatiles from Advance Map 1.92...
-----------------------------------------
Helpful for users converting projects from binary hacks.
Metatile data exported from Advance Map 1.92 in a ``.bvd``` file can be imported
into porymap's tileset editor.
This saves a lot of time since metatiles will not have to be defined from scratch.
Change Number of Metatiles
--------------------------
The number of metatiles in both the current primary and current secondary tileset
can be adjusted within the limits.
.. note::
You may need to change the Makefile rules for the number of tiles allowed
for the tileset in the file ``graphics_file_rules.mk``. You can simply
remove the ``-num_tiles=`` argument altogether.
Other Tools
-----------
.. figure:: images/tileset-editor/tse-display-tool.png
:align: center
:width: 60%
:alt: TSE Unused
Displaying Unused Tiles
There are also tools to count the number of metatile and tile usages across the
entire project, which can be useful, for example, in determining whether a
metatile can be deleted. The output of these operations is pictured above.
Palette Editor
==============
The palette editor is where the ``.pal`` files are modified for each tileset.
.. figure:: images/tileset-editor/pe-open-window.png
:align: center
:width: 75%
:alt: PE
Palette Editor
The current palette is indicated by the spinner at the top left. To switch
between palettes, just change the spinner value.
At the top right is a setting for the bit depth at which colors are displayed.
The colors in a palette file are displayed as 24 bit numbers, but the GBA
hardware only allows 15 bit colors, so displaying in 15 bits can be more realistic.
Each individual color can be adjusted with either the sliders or the spinners,
in addition to the hex value box. Each color also has an eyedropper toolbutton
which allows users to pick any color from the screen and add it to the palette.
Entire palettes can also be imported from a variety of formats,
including JASC, Adobe Color Table, Tile Layer Pro, and Advance PE.
Each imported palette must contain 16 colors.

View File

@@ -7,7 +7,37 @@ and this project somewhat adheres to [Semantic Versioning](https://semver.org/sp
The **"Breaking Changes"** listed below are changes that have been made in the decompilation projects (e.g. pokeemerald), which porymap requires in order to work properly. If porymap is used on a project that is not up-to-date with the breaking changes, then porymap will likely break or behave improperly.
## [Unreleased]
Nothing, yet.
### Breaking Changes
- Proper support for pokefirered's clone objects was added, which requires the changes made in [pokefirered/#484](https://github.com/pret/pokefirered/pull/484).
### Added
- Add Copy/Paste for metatiles in the Tileset Editor.
- Add new features to the scripting API, including the ability to display message boxes and user input windows, set overlay opacity, get/set map header properties, read tile pixel data, and set blocks or metatile attributes using a raw value.
- Add button to copy the full metatile label to the clipboard in the Tileset Editor.
- Add option to not open the most recent project on launch.
- Add color picker to palette editor for taking colors from the screen.
### Changed
- Overhauled the region map editor, adding support for tilemaps, and significant customization. Also now supports pokefirered.
- If an object event is inanimate, it will always render using its first frame.
- Only log "Unknown custom script function" when a registered script function is not present in any script.
- Unused metatile attribute bits that are set are preserved instead of being cleared.
- The wild encounter editor is automatically disabled if the encounter JSON data cannot be read
- Metatiles are always rendered accurately with 3 layers, and the unused layer is not assumed to be transparent.
- `object_event_graphics_info.h` can now be parsed correctly if it uses structs with attributes.
- The selection is no longer reset when pasting events. The newly pasted events are selected instead.
- Palette editor ui is updated a bit to allow hex and rgb value input.
### Fixed
- Fix cursor tile outline not updating at the end of a dragged selection.
- Fix cursor tile and player view outlines exiting map bounds while painting.
- Fix cursor tile and player view outlines not updating immediately when toggled in Collision view.
- Fix selected space not updating while painting in Collision view.
- Fix collision values of 2 or 3 not rendering properly.
- Fix the map music dropdown being empty when importing a map from Advance Map.
- Fix object events added by pasting ignoring the map event limit.
- Fixed a bug where saving the tileset editor would reselect the main editor's first selected metatile.
- Fix crashes / unexpected behavior if certain scripting API functions are given invalid palette or tile numbers.
## [4.5.0] - 2021-12-26
### Added
@@ -287,7 +317,7 @@ Nothing, yet.
This was the initial release.
[Unreleased]: https://github.com/huderlem/porymap/compare/4.5.0...HEAD
[4.5.0]: https://github.com/huderlem/porymap/compare/4.4.0...4.4.0
[4.5.0]: https://github.com/huderlem/porymap/compare/4.4.0...4.5.0
[4.4.0]: https://github.com/huderlem/porymap/compare/4.3.1...4.4.0
[4.3.1]: https://github.com/huderlem/porymap/compare/4.3.0...4.3.1
[4.3.0]: https://github.com/huderlem/porymap/compare/4.2.0...4.3.0