Add optional forceRedraw argument to palette API functions
This commit is contained in:
parent
acf9673807
commit
3de8e88b8e
3 changed files with 56 additions and 32 deletions
|
@ -640,12 +640,13 @@ All tileset functions are callable via the global ``map`` object.
|
|||
:param number paletteIndex: the palette index
|
||||
:returns array: array of colors. Each color is a 3-element RGB array
|
||||
|
||||
.. js:function:: map.setPrimaryTilesetPalettePreview(paletteIndex, colors)
|
||||
.. js:function:: map.setPrimaryTilesetPalettePreview(paletteIndex, colors, forceRedraw = true)
|
||||
|
||||
Sets a palette in the primary tileset of the currently-opened map. This will NOT affect the true underlying colors--it only displays these colors in the map-editing area of Porymap.
|
||||
|
||||
:param number paletteIndex: the palette index
|
||||
:param array colors: array of colors. Each color is a 3-element RGB array
|
||||
:param boolean forceRedraw: Redraw the elements with the updated palette. Defaults to ``true``. Redrawing the elements that use palettes is expensive, so it can be useful to batch together many calls to palette functions and only set ``redraw`` to ``true`` on the final call.
|
||||
|
||||
.. js:function:: map.getPrimaryTilesetPalettesPreview()
|
||||
|
||||
|
@ -653,11 +654,12 @@ All tileset functions are callable via the global ``map`` object.
|
|||
|
||||
:returns array: array of arrays of colors. Each color is a 3-element RGB array
|
||||
|
||||
.. js:function:: map.setPrimaryTilesetPalettesPreview(palettes)
|
||||
.. js:function:: map.setPrimaryTilesetPalettesPreview(palettes, forceRedraw = true)
|
||||
|
||||
Sets all of the palettes in the primary tileset of the currently-opened map. This will NOT affect the true underlying colors--it only displays these colors in the map-editing area of Porymap.
|
||||
|
||||
:param array palettes: array of arrays of colors. Each color is a 3-element RGB array
|
||||
:param boolean forceRedraw: Redraw the elements with the updated palettes. Defaults to ``true``. Redrawing the elements that use palettes is expensive, so it can be useful to batch together many calls to palette functions and only set ``redraw`` to ``true`` on the final call.
|
||||
|
||||
.. js:function:: map.getSecondaryTilesetPalettePreview(paletteIndex)
|
||||
|
||||
|
@ -666,12 +668,13 @@ All tileset functions are callable via the global ``map`` object.
|
|||
:param number paletteIndex: the palette index
|
||||
:returns array: array of colors. Each color is a 3-element RGB array
|
||||
|
||||
.. js:function:: map.setSecondaryTilesetPalettePreview(paletteIndex, colors)
|
||||
.. js:function:: map.setSecondaryTilesetPalettePreview(paletteIndex, colors, forceRedraw = true)
|
||||
|
||||
Sets a palette in the secondary tileset of the currently-opened map. This will NOT affect the true underlying colors--it only displays these colors in the map-editing area of Porymap.
|
||||
|
||||
:param number paletteIndex: the palette index
|
||||
:param array colors: array of colors. Each color is a 3-element RGB array
|
||||
:param boolean forceRedraw: Redraw the elements with the updated palette. Defaults to ``true``. Redrawing the elements that use palettes is expensive, so it can be useful to batch together many calls to palette functions and only set ``redraw`` to ``true`` on the final call.
|
||||
|
||||
.. js:function:: map.getSecondaryTilesetPalettesPreview()
|
||||
|
||||
|
@ -679,11 +682,12 @@ All tileset functions are callable via the global ``map`` object.
|
|||
|
||||
:returns array: array of arrays of colors. Each color is a 3-element RGB array
|
||||
|
||||
.. js:function:: map.setSecondaryTilesetPalettesPreview(palettes)
|
||||
.. js:function:: map.setSecondaryTilesetPalettesPreview(palettes, forceRedraw = true)
|
||||
|
||||
Sets all of the palettes in the secondary tileset of the currently-opened map. This will NOT affect the true underlying colors--it only displays these colors in the map-editing area of Porymap.
|
||||
|
||||
:param array palettes: array of arrays of colors. Each color is a 3-element RGB array
|
||||
:param boolean forceRedraw: Redraw the elements with the updated palettes. Defaults to ``true``. Redrawing the elements that use palettes is expensive, so it can be useful to batch together many calls to palette functions and only set ``redraw`` to ``true`` on the final call.
|
||||
|
||||
.. js:function:: map.getPrimaryTilesetPalette(paletteIndex)
|
||||
|
||||
|
@ -692,12 +696,13 @@ All tileset functions are callable via the global ``map`` object.
|
|||
:param number paletteIndex: the palette index
|
||||
:returns array: array of colors. Each color is a 3-element RGB array
|
||||
|
||||
.. js:function:: map.setPrimaryTilesetPalette(paletteIndex, colors)
|
||||
.. js:function:: map.setPrimaryTilesetPalette(paletteIndex, colors, forceRedraw = true)
|
||||
|
||||
Sets a palette in the primary tileset of the currently-opened map. This will permanently affect the palette and save the palette to disk.
|
||||
|
||||
:param number paletteIndex: the palette index
|
||||
:param array colors: array of colors. Each color is a 3-element RGB array
|
||||
:param boolean forceRedraw: Redraw the elements with the updated palette. Defaults to ``true``. Redrawing the elements that use palettes is expensive, so it can be useful to batch together many calls to palette functions and only set ``redraw`` to ``true`` on the final call.
|
||||
|
||||
.. js:function:: map.getPrimaryTilesetPalettes()
|
||||
|
||||
|
@ -705,11 +710,12 @@ All tileset functions are callable via the global ``map`` object.
|
|||
|
||||
:returns array: array of arrays of colors. Each color is a 3-element RGB array
|
||||
|
||||
.. js:function:: map.setPrimaryTilesetPalettes(palettes)
|
||||
.. js:function:: map.setPrimaryTilesetPalettes(palettes, forceRedraw = true)
|
||||
|
||||
Sets all of the palettes in the primary tileset of the currently-opened map. This will permanently affect the palettes and save the palettes to disk.
|
||||
|
||||
:param array palettes: array of arrays of colors. Each color is a 3-element RGB array
|
||||
:param boolean forceRedraw: Redraw the elements with the updated palettes. Defaults to ``true``. Redrawing the elements that use palettes is expensive, so it can be useful to batch together many calls to palette functions and only set ``redraw`` to ``true`` on the final call.
|
||||
|
||||
.. js:function:: map.getSecondaryTilesetPalette(paletteIndex)
|
||||
|
||||
|
@ -718,12 +724,13 @@ All tileset functions are callable via the global ``map`` object.
|
|||
:param number paletteIndex: the palette index
|
||||
:returns array: array of colors. Each color is a 3-element RGB array
|
||||
|
||||
.. js:function:: map.setSecondaryTilesetPalette(paletteIndex, colors)
|
||||
.. js:function:: map.setSecondaryTilesetPalette(paletteIndex, colors, forceRedraw = true)
|
||||
|
||||
Sets a palette in the secondary tileset of the currently-opened map. This will permanently affect the palette and save the palette to disk.
|
||||
|
||||
:param number paletteIndex: the palette index
|
||||
:param array colors: array of colors. Each color is a 3-element RGB array
|
||||
:param boolean forceRedraw: Redraw the elements with the updated palette. Defaults to ``true``. Redrawing the elements that use palettes is expensive, so it can be useful to batch together many calls to palette functions and only set ``redraw`` to ``true`` on the final call.
|
||||
|
||||
.. js:function:: map.getSecondaryTilesetPalettes()
|
||||
|
||||
|
@ -731,11 +738,12 @@ All tileset functions are callable via the global ``map`` object.
|
|||
|
||||
:returns array: array of arrays of colors. Each color is a 3-element RGB array
|
||||
|
||||
.. js:function:: map.setSecondaryTilesetPalettes(palettes)
|
||||
.. js:function:: map.setSecondaryTilesetPalettes(palettes, forceRedraw = true)
|
||||
|
||||
Sets all of the palettes in the secondary tileset of the currently-opened map. This will permanently affect the palettes and save the palettes to disk.
|
||||
|
||||
:param array palettes: array of arrays of colors. Each color is a 3-element RGB array
|
||||
:param boolean forceRedraw: Redraw the elements with the updated palettes. Defaults to ``true``. Redrawing the elements that use palettes is expensive, so it can be useful to batch together many calls to palette functions and only set ``redraw`` to ``true`` on the final call.
|
||||
|
||||
.. js:function:: map.getMetatileLayerOrder()
|
||||
|
||||
|
|
|
@ -78,10 +78,10 @@ public:
|
|||
Q_INVOKABLE void setBorderHeight(int height);
|
||||
void refreshAfterPaletteChange(Tileset *tileset);
|
||||
void setTilesetPalette(Tileset *tileset, int paletteIndex, QList<QList<int>> colors);
|
||||
Q_INVOKABLE void setPrimaryTilesetPalette(int paletteIndex, QList<QList<int>> colors);
|
||||
Q_INVOKABLE void setPrimaryTilesetPalettes(QList<QList<QList<int>>> palettes);
|
||||
Q_INVOKABLE void setSecondaryTilesetPalette(int paletteIndex, QList<QList<int>> colors);
|
||||
Q_INVOKABLE void setSecondaryTilesetPalettes(QList<QList<QList<int>>> palettes);
|
||||
Q_INVOKABLE void setPrimaryTilesetPalette(int paletteIndex, QList<QList<int>> colors, bool forceRedraw = true);
|
||||
Q_INVOKABLE void setPrimaryTilesetPalettes(QList<QList<QList<int>>> palettes, bool forceRedraw = true);
|
||||
Q_INVOKABLE void setSecondaryTilesetPalette(int paletteIndex, QList<QList<int>> colors, bool forceRedraw = true);
|
||||
Q_INVOKABLE void setSecondaryTilesetPalettes(QList<QList<QList<int>>> palettes, bool forceRedraw = true);
|
||||
QJSValue getTilesetPalette(const QList<QList<QRgb>> &palettes, int paletteIndex);
|
||||
QJSValue getTilesetPalettes(const QList<QList<QRgb>> &palettes);
|
||||
Q_INVOKABLE QJSValue getPrimaryTilesetPalette(int paletteIndex);
|
||||
|
@ -90,10 +90,10 @@ public:
|
|||
Q_INVOKABLE QJSValue getSecondaryTilesetPalettes();
|
||||
void refreshAfterPalettePreviewChange();
|
||||
void setTilesetPalettePreview(Tileset *tileset, int paletteIndex, QList<QList<int>> colors);
|
||||
Q_INVOKABLE void setPrimaryTilesetPalettePreview(int paletteIndex, QList<QList<int>> colors);
|
||||
Q_INVOKABLE void setPrimaryTilesetPalettesPreview(QList<QList<QList<int>>> palettes);
|
||||
Q_INVOKABLE void setSecondaryTilesetPalettePreview(int paletteIndex, QList<QList<int>> colors);
|
||||
Q_INVOKABLE void setSecondaryTilesetPalettesPreview(QList<QList<QList<int>>> palettes);
|
||||
Q_INVOKABLE void setPrimaryTilesetPalettePreview(int paletteIndex, QList<QList<int>> colors, bool forceRedraw = true);
|
||||
Q_INVOKABLE void setPrimaryTilesetPalettesPreview(QList<QList<QList<int>>> palettes, bool forceRedraw = true);
|
||||
Q_INVOKABLE void setSecondaryTilesetPalettePreview(int paletteIndex, QList<QList<int>> colors, bool forceRedraw = true);
|
||||
Q_INVOKABLE void setSecondaryTilesetPalettesPreview(QList<QList<QList<int>>> palettes, bool forceRedraw = true);
|
||||
Q_INVOKABLE QJSValue getPrimaryTilesetPalettePreview(int paletteIndex);
|
||||
Q_INVOKABLE QJSValue getPrimaryTilesetPalettesPreview();
|
||||
Q_INVOKABLE QJSValue getSecondaryTilesetPalettePreview(int paletteIndex);
|
||||
|
|
|
@ -347,36 +347,44 @@ void MainWindow::setTilesetPalette(Tileset *tileset, int paletteIndex, QList<QLi
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::setPrimaryTilesetPalette(int paletteIndex, QList<QList<int>> colors) {
|
||||
void MainWindow::setPrimaryTilesetPalette(int paletteIndex, QList<QList<int>> colors, bool forceRedraw) {
|
||||
if (!this->editor || !this->editor->map || !this->editor->map->layout || !this->editor->map->layout->tileset_primary)
|
||||
return;
|
||||
this->setTilesetPalette(this->editor->map->layout->tileset_primary, paletteIndex, colors);
|
||||
this->refreshAfterPaletteChange(this->editor->map->layout->tileset_primary);
|
||||
if (forceRedraw) {
|
||||
this->refreshAfterPaletteChange(this->editor->map->layout->tileset_primary);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setPrimaryTilesetPalettes(QList<QList<QList<int>>> palettes) {
|
||||
void MainWindow::setPrimaryTilesetPalettes(QList<QList<QList<int>>> palettes, bool forceRedraw) {
|
||||
if (!this->editor || !this->editor->map || !this->editor->map->layout || !this->editor->map->layout->tileset_primary)
|
||||
return;
|
||||
for (int i = 0; i < palettes.size(); i++) {
|
||||
this->setTilesetPalette(this->editor->map->layout->tileset_primary, i, palettes[i]);
|
||||
}
|
||||
this->refreshAfterPaletteChange(this->editor->map->layout->tileset_primary);
|
||||
if (forceRedraw) {
|
||||
this->refreshAfterPaletteChange(this->editor->map->layout->tileset_primary);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setSecondaryTilesetPalette(int paletteIndex, QList<QList<int>> colors) {
|
||||
void MainWindow::setSecondaryTilesetPalette(int paletteIndex, QList<QList<int>> colors, bool forceRedraw) {
|
||||
if (!this->editor || !this->editor->map || !this->editor->map->layout || !this->editor->map->layout->tileset_secondary)
|
||||
return;
|
||||
this->setTilesetPalette(this->editor->map->layout->tileset_secondary, paletteIndex, colors);
|
||||
this->refreshAfterPaletteChange(this->editor->map->layout->tileset_secondary);
|
||||
if (forceRedraw) {
|
||||
this->refreshAfterPaletteChange(this->editor->map->layout->tileset_secondary);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setSecondaryTilesetPalettes(QList<QList<QList<int>>> palettes) {
|
||||
void MainWindow::setSecondaryTilesetPalettes(QList<QList<QList<int>>> palettes, bool forceRedraw) {
|
||||
if (!this->editor || !this->editor->map || !this->editor->map->layout || !this->editor->map->layout->tileset_secondary)
|
||||
return;
|
||||
for (int i = 0; i < palettes.size(); i++) {
|
||||
this->setTilesetPalette(this->editor->map->layout->tileset_secondary, i, palettes[i]);
|
||||
}
|
||||
this->refreshAfterPaletteChange(this->editor->map->layout->tileset_secondary);
|
||||
if (forceRedraw) {
|
||||
this->refreshAfterPaletteChange(this->editor->map->layout->tileset_secondary);
|
||||
}
|
||||
}
|
||||
|
||||
QJSValue MainWindow::getTilesetPalette(const QList<QList<QRgb>> &palettes, int paletteIndex) {
|
||||
|
@ -449,36 +457,44 @@ void MainWindow::setTilesetPalettePreview(Tileset *tileset, int paletteIndex, QL
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::setPrimaryTilesetPalettePreview(int paletteIndex, QList<QList<int>> colors) {
|
||||
void MainWindow::setPrimaryTilesetPalettePreview(int paletteIndex, QList<QList<int>> colors, bool forceRedraw) {
|
||||
if (!this->editor || !this->editor->map || !this->editor->map->layout || !this->editor->map->layout->tileset_primary)
|
||||
return;
|
||||
this->setTilesetPalettePreview(this->editor->map->layout->tileset_primary, paletteIndex, colors);
|
||||
this->refreshAfterPalettePreviewChange();
|
||||
if (forceRedraw) {
|
||||
this->refreshAfterPalettePreviewChange();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setPrimaryTilesetPalettesPreview(QList<QList<QList<int>>> palettes) {
|
||||
void MainWindow::setPrimaryTilesetPalettesPreview(QList<QList<QList<int>>> palettes, bool forceRedraw) {
|
||||
if (!this->editor || !this->editor->map || !this->editor->map->layout || !this->editor->map->layout->tileset_primary)
|
||||
return;
|
||||
for (int i = 0; i < palettes.size(); i++) {
|
||||
this->setTilesetPalettePreview(this->editor->map->layout->tileset_primary, i, palettes[i]);
|
||||
}
|
||||
this->refreshAfterPalettePreviewChange();
|
||||
if (forceRedraw) {
|
||||
this->refreshAfterPalettePreviewChange();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setSecondaryTilesetPalettePreview(int paletteIndex, QList<QList<int>> colors) {
|
||||
void MainWindow::setSecondaryTilesetPalettePreview(int paletteIndex, QList<QList<int>> colors, bool forceRedraw) {
|
||||
if (!this->editor || !this->editor->map || !this->editor->map->layout || !this->editor->map->layout->tileset_secondary)
|
||||
return;
|
||||
this->setTilesetPalettePreview(this->editor->map->layout->tileset_secondary, paletteIndex, colors);
|
||||
this->refreshAfterPalettePreviewChange();
|
||||
if (forceRedraw) {
|
||||
this->refreshAfterPalettePreviewChange();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setSecondaryTilesetPalettesPreview(QList<QList<QList<int>>> palettes) {
|
||||
void MainWindow::setSecondaryTilesetPalettesPreview(QList<QList<QList<int>>> palettes, bool forceRedraw) {
|
||||
if (!this->editor || !this->editor->map || !this->editor->map->layout || !this->editor->map->layout->tileset_secondary)
|
||||
return;
|
||||
for (int i = 0; i < palettes.size(); i++) {
|
||||
this->setTilesetPalettePreview(this->editor->map->layout->tileset_secondary, i, palettes[i]);
|
||||
}
|
||||
this->refreshAfterPalettePreviewChange();
|
||||
if (forceRedraw) {
|
||||
this->refreshAfterPalettePreviewChange();
|
||||
}
|
||||
}
|
||||
|
||||
QJSValue MainWindow::getPrimaryTilesetPalettePreview(int paletteIndex) {
|
||||
|
|
Loading…
Reference in a new issue