Add get/setMetatileAttributes
This commit is contained in:
parent
aad1266e91
commit
778257ccd9
4 changed files with 36 additions and 2 deletions
|
@ -12,17 +12,17 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Add Copy/Paste for metatiles in the Tileset Editor.
|
- Add Copy/Paste for metatiles in the Tileset Editor.
|
||||||
- Add new features to the scripting API, including the ability to set overlay opacity, get/set map header properties, read tile pixel data, and set blocks using a raw value.
|
- Add new features to the scripting API, including the ability to 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 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 option to not open the most recent project on launch.
|
||||||
- Add color picker to palette editor for taking colors from the screen.
|
- Add color picker to palette editor for taking colors from the screen.
|
||||||
|
|
||||||
### Changed
|
### 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.
|
- 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.
|
- 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.
|
- 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
|
- The wild encounter editor is automatically disabled if the encounter JSON data cannot be read
|
||||||
- Overhauled the region map editor, adding support for tilemaps, and significant customization. Also now supports pokefirered.
|
|
||||||
- Metatiles are always rendered accurately with 3 layers, and the unused layer is not assumed to be transparent.
|
- 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.
|
- `object_event_graphics_info.h` can now be parsed correctly if it uses structs with attributes.
|
||||||
- Palette editor ui is updated a bit to allow hex and rgb value input.
|
- Palette editor ui is updated a bit to allow hex and rgb value input.
|
||||||
|
|
|
@ -1054,6 +1054,22 @@ The following functions are related to tilesets and how they are rendered. The f
|
||||||
:param number metatileId: id of target metatile
|
:param number metatileId: id of target metatile
|
||||||
:param number behavior: the behavior
|
: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)
|
.. js:function:: map.getMetatileTile(metatileId, tileIndex)
|
||||||
|
|
||||||
Gets the tile at the specified index of the metatile.
|
Gets the tile at the specified index of the metatile.
|
||||||
|
|
|
@ -167,6 +167,8 @@ public:
|
||||||
Q_INVOKABLE void setMetatileTerrainType(int metatileId, int terrainType);
|
Q_INVOKABLE void setMetatileTerrainType(int metatileId, int terrainType);
|
||||||
Q_INVOKABLE int getMetatileBehavior(int metatileId);
|
Q_INVOKABLE int getMetatileBehavior(int metatileId);
|
||||||
Q_INVOKABLE void setMetatileBehavior(int metatileId, int behavior);
|
Q_INVOKABLE void setMetatileBehavior(int metatileId, int behavior);
|
||||||
|
Q_INVOKABLE int getMetatileAttributes(int metatileId);
|
||||||
|
Q_INVOKABLE void setMetatileAttributes(int metatileId, int attributes);
|
||||||
Q_INVOKABLE QJSValue getMetatileTile(int metatileId, int tileIndex);
|
Q_INVOKABLE QJSValue getMetatileTile(int metatileId, int tileIndex);
|
||||||
Q_INVOKABLE void setMetatileTile(int metatileId, int tileIndex, int tileId, bool xflip, bool yflip, int palette, bool forceRedraw = true);
|
Q_INVOKABLE void setMetatileTile(int metatileId, int tileIndex, int tileId, bool xflip, bool yflip, int palette, bool forceRedraw = true);
|
||||||
Q_INVOKABLE void setMetatileTile(int metatileId, int tileIndex, QJSValue tileObj, bool forceRedraw = true);
|
Q_INVOKABLE void setMetatileTile(int metatileId, int tileIndex, QJSValue tileObj, bool forceRedraw = true);
|
||||||
|
|
|
@ -961,6 +961,22 @@ void MainWindow::setMetatileBehavior(int metatileId, int behavior) {
|
||||||
this->saveMetatileAttributesByMetatileId(metatileId);
|
this->saveMetatileAttributesByMetatileId(metatileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MainWindow::getMetatileAttributes(int metatileId) {
|
||||||
|
Metatile * metatile = this->getMetatile(metatileId);
|
||||||
|
if (!metatile)
|
||||||
|
return -1;
|
||||||
|
return metatile->getAttributes(projectConfig.getBaseGameVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::setMetatileAttributes(int metatileId, int attributes) {
|
||||||
|
Metatile * metatile = this->getMetatile(metatileId);
|
||||||
|
uint32_t u_attributes = static_cast<uint32_t>(attributes);
|
||||||
|
if (!metatile)
|
||||||
|
return;
|
||||||
|
metatile->setAttributes(u_attributes, projectConfig.getBaseGameVersion());
|
||||||
|
this->saveMetatileAttributesByMetatileId(metatileId);
|
||||||
|
}
|
||||||
|
|
||||||
int MainWindow::calculateTileBounds(int * tileStart, int * tileEnd) {
|
int MainWindow::calculateTileBounds(int * tileStart, int * tileEnd) {
|
||||||
int maxNumTiles = this->getNumTilesInMetatile();
|
int maxNumTiles = this->getNumTilesInMetatile();
|
||||||
if (*tileEnd >= maxNumTiles || *tileEnd < 0)
|
if (*tileEnd >= maxNumTiles || *tileEnd < 0)
|
||||||
|
|
Loading…
Reference in a new issue