Merge branch 'master' into metatile-attr

This commit is contained in:
GriffinR 2022-11-18 18:13:21 -05:00 committed by GitHub
commit d475286249
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 148 additions and 110 deletions

View file

@ -8,7 +8,8 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
## [Unreleased]
### Added
- Added new config options for reorganizing metatile attributes.
- Add new config options for reorganizing metatile attributes.
- Add `setScale` to the scripting API.
## [5.0.0] - 2022-10-30
### Breaking Changes

View file

@ -18,7 +18,7 @@ Let's write a custom script that will randomize grass patterns when the user is
First, create a new script file called ``my_script.js``--place it in the project directory (e.g. ``pokefirered/``).
Next, open the Porymap project config file, ``porymap.project.cfg``, in the project directory. Add the script file to the ``custom_scripts`` configuration value. Multiple script files can be loaded by separating the filepaths with a comma.
Next, open the Porymap project config file, ``porymap.user.cfg``, in the project directory. Add the script file to the ``custom_scripts`` configuration value. Multiple script files can be loaded by separating the filepaths with a comma.
.. code-block::
@ -745,30 +745,6 @@ All tileset functions are callable via the global ``map`` object.
: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()
Gets the order that metatile layers are rendered.
:returns array: array of layers. The bottom layer is represented as 0.
.. js:function:: map.setMetatileLayerOrder(order)
Sets the order that metatile layers are rendered.
:param array order: array of layers. The bottom layer is represented as 0.
.. js:function:: map.getMetatileLayerOpacity()
Gets the opacities that metatile layers are rendered with.
:returns array: array of opacities for each layer. The bottom layer is the first element.
.. js:function:: map.setMetatileLayerOpacity(opacities)
Sets the opacities that metatile layers are rendered with.
:param array opacities: array of opacities for each layer. The bottom layer is the first element.
.. js:function:: map.getMetatileLabel(metatileId)
Gets the label for the specified metatile.
@ -1375,6 +1351,31 @@ All settings functions are callable via the global ``utility`` object.
:param number tab: index of the tab to select
.. js:function:: utility.getMetatileLayerOrder()
Gets the order that metatile layers are rendered.
:returns array: array of layers. The bottom layer is represented as 0.
.. js:function:: utility.setMetatileLayerOrder(order)
Sets the order that metatile layers are rendered.
:param array order: array of layers. The bottom layer is represented as 0.
.. js:function:: utility.getMetatileLayerOpacity()
Gets the opacities that metatile layers are rendered with.
:returns array: array of opacities for each layer. The bottom layer is the first element.
.. js:function:: utility.setMetatileLayerOpacity(opacities)
Sets the opacities that metatile layers are rendered with.
:param array opacities: array of opacities for each layer. The bottom layer is the first element.
Utility Functions
^^^^^^^^^^^^^^^^^

View file

@ -456,10 +456,6 @@
<li><a href="manual/scripting-capabilities.html#map.getMetatileId">map.getMetatileId() (map method)</a>
</li>
<li><a href="manual/scripting-capabilities.html#map.getMetatileLabel">map.getMetatileLabel() (map method)</a>
</li>
<li><a href="manual/scripting-capabilities.html#map.getMetatileLayerOpacity">map.getMetatileLayerOpacity() (map method)</a>
</li>
<li><a href="manual/scripting-capabilities.html#map.getMetatileLayerOrder">map.getMetatileLayerOrder() (map method)</a>
</li>
<li><a href="manual/scripting-capabilities.html#map.getMetatileLayerType">map.getMetatileLayerType() (map method)</a>
</li>
@ -560,10 +556,6 @@
<li><a href="manual/scripting-capabilities.html#map.setMetatileId">map.setMetatileId() (map method)</a>
</li>
<li><a href="manual/scripting-capabilities.html#map.setMetatileLabel">map.setMetatileLabel() (map method)</a>
</li>
<li><a href="manual/scripting-capabilities.html#map.setMetatileLayerOpacity">map.setMetatileLayerOpacity() (map method)</a>
</li>
<li><a href="manual/scripting-capabilities.html#map.setMetatileLayerOrder">map.setMetatileLayerOrder() (map method)</a>
</li>
<li><a href="manual/scripting-capabilities.html#map.setMetatileLayerType">map.setMetatileLayerType() (map method)</a>
</li>
@ -736,6 +728,10 @@
<li><a href="manual/scripting-capabilities.html#utility.getMapViewTab">utility.getMapViewTab() (utility method)</a>
</li>
<li><a href="manual/scripting-capabilities.html#utility.getMetatileBehaviorNames">utility.getMetatileBehaviorNames() (utility method)</a>
</li>
<li><a href="manual/scripting-capabilities.html#utility.getMetatileLayerOpacity">utility.getMetatileLayerOpacity() (utility method)</a>
</li>
<li><a href="manual/scripting-capabilities.html#utility.getMetatileLayerOrder">utility.getMetatileLayerOrder() (utility method)</a>
</li>
<li><a href="manual/scripting-capabilities.html#utility.getPrimaryTilesetNames">utility.getPrimaryTilesetNames() (utility method)</a>
</li>
@ -766,6 +762,10 @@
<li><a href="manual/scripting-capabilities.html#utility.setMainTab">utility.setMainTab() (utility method)</a>
</li>
<li><a href="manual/scripting-capabilities.html#utility.setMapViewTab">utility.setMapViewTab() (utility method)</a>
</li>
<li><a href="manual/scripting-capabilities.html#utility.setMetatileLayerOpacity">utility.setMetatileLayerOpacity() (utility method)</a>
</li>
<li><a href="manual/scripting-capabilities.html#utility.setMetatileLayerOrder">utility.setMetatileLayerOrder() (utility method)</a>
</li>
<li><a href="manual/scripting-capabilities.html#utility.setSmartPathsEnabled">utility.setSmartPathsEnabled() (utility method)</a>
</li>

View file

@ -386,7 +386,7 @@
<h2>Writing a Custom Script<a class="headerlink" href="#writing-a-custom-script" title="Permalink to this headline"></a></h2>
<p>Lets write a custom script that will randomize grass patterns when the user is editing the map. This is useful, since its cumbersome to manually add randomness to grass patches. With the custom script, it will happen automatically. Whenever the user paints a grass tile onto the map, the script will overwrite the tile with a random grass tile instead.</p>
<p>First, create a new script file called <code class="docutils literal notranslate"><span class="pre">my_script.js</span></code>place it in the project directory (e.g. <code class="docutils literal notranslate"><span class="pre">pokefirered/</span></code>).</p>
<p>Next, open the Porymap project config file, <code class="docutils literal notranslate"><span class="pre">porymap.project.cfg</span></code>, in the project directory. Add the script file to the <code class="docutils literal notranslate"><span class="pre">custom_scripts</span></code> configuration value. Multiple script files can be loaded by separating the filepaths with a comma.</p>
<p>Next, open the Porymap project config file, <code class="docutils literal notranslate"><span class="pre">porymap.user.cfg</span></code>, in the project directory. Add the script file to the <code class="docutils literal notranslate"><span class="pre">custom_scripts</span></code> configuration value. Multiple script files can be loaded by separating the filepaths with a comma.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">custom_scripts</span><span class="o">=</span><span class="n">my_script</span><span class="o">.</span><span class="n">js</span>
</pre></div>
</div>
@ -1678,54 +1678,6 @@
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMetatileLayerOrder">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMetatileLayerOrder</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getMetatileLayerOrder" title="Permalink to this definition"></a></dt>
<dd><p>Gets the order that metatile layers are rendered.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns array</dt>
<dd class="field-odd"><p>array of layers. The bottom layer is represented as 0.</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setMetatileLayerOrder">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setMetatileLayerOrder</code><span class="sig-paren">(</span><em class="sig-param">order</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setMetatileLayerOrder" title="Permalink to this definition"></a></dt>
<dd><p>Sets the order that metatile layers are rendered.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>order</strong> (<em>array</em>) array of layers. The bottom layer is represented as 0.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMetatileLayerOpacity">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMetatileLayerOpacity</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#map.getMetatileLayerOpacity" title="Permalink to this definition"></a></dt>
<dd><p>Gets the opacities that metatile layers are rendered with.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns array</dt>
<dd class="field-odd"><p>array of opacities for each layer. The bottom layer is the first element.</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.setMetatileLayerOpacity">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">setMetatileLayerOpacity</code><span class="sig-paren">(</span><em class="sig-param">opacities</em><span class="sig-paren">)</span><a class="headerlink" href="#map.setMetatileLayerOpacity" title="Permalink to this definition"></a></dt>
<dd><p>Sets the opacities that metatile layers are rendered with.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>opacities</strong> (<em>array</em>) array of opacities for each layer. The bottom layer is the first element.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="map.getMetatileLabel">
<code class="sig-prename descclassname">map.</code><code class="sig-name descname">getMetatileLabel</code><span class="sig-paren">(</span><em class="sig-param">metatileId</em><span class="sig-paren">)</span><a class="headerlink" href="#map.getMetatileLabel" title="Permalink to this definition"></a></dt>
@ -2853,6 +2805,54 @@
</dl>
</dd></dl>
<dl class="js function">
<dt id="utility.getMetatileLayerOrder">
<code class="sig-prename descclassname">utility.</code><code class="sig-name descname">getMetatileLayerOrder</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#utility.getMetatileLayerOrder" title="Permalink to this definition"></a></dt>
<dd><p>Gets the order that metatile layers are rendered.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns array</dt>
<dd class="field-odd"><p>array of layers. The bottom layer is represented as 0.</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="utility.setMetatileLayerOrder">
<code class="sig-prename descclassname">utility.</code><code class="sig-name descname">setMetatileLayerOrder</code><span class="sig-paren">(</span><em class="sig-param">order</em><span class="sig-paren">)</span><a class="headerlink" href="#utility.setMetatileLayerOrder" title="Permalink to this definition"></a></dt>
<dd><p>Sets the order that metatile layers are rendered.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>order</strong> (<em>array</em>) array of layers. The bottom layer is represented as 0.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="utility.getMetatileLayerOpacity">
<code class="sig-prename descclassname">utility.</code><code class="sig-name descname">getMetatileLayerOpacity</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#utility.getMetatileLayerOpacity" title="Permalink to this definition"></a></dt>
<dd><p>Gets the opacities that metatile layers are rendered with.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns array</dt>
<dd class="field-odd"><p>array of opacities for each layer. The bottom layer is the first element.</p>
</dd>
</dl>
</dd></dl>
<dl class="js function">
<dt id="utility.setMetatileLayerOpacity">
<code class="sig-prename descclassname">utility.</code><code class="sig-name descname">setMetatileLayerOpacity</code><span class="sig-paren">(</span><em class="sig-param">opacities</em><span class="sig-paren">)</span><a class="headerlink" href="#utility.setMetatileLayerOpacity" title="Permalink to this definition"></a></dt>
<dd><p>Sets the opacities that metatile layers are rendered with.</p>
<dl class="field-list simple">
<dt class="field-odd">Arguments</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>opacities</strong> (<em>array</em>) array of opacities for each layer. The bottom layer is the first element.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="utility-functions">
<h4>Utility Functions<a class="headerlink" href="#utility-functions" title="Permalink to this headline"></a></h4>

Binary file not shown.

File diff suppressed because one or more lines are too long

View file

@ -18,7 +18,7 @@ Let's write a custom script that will randomize grass patterns when the user is
First, create a new script file called ``my_script.js``--place it in the project directory (e.g. ``pokefirered/``).
Next, open the Porymap project config file, ``porymap.project.cfg``, in the project directory. Add the script file to the ``custom_scripts`` configuration value. Multiple script files can be loaded by separating the filepaths with a comma.
Next, open the Porymap project config file, ``porymap.user.cfg``, in the project directory. Add the script file to the ``custom_scripts`` configuration value. Multiple script files can be loaded by separating the filepaths with a comma.
.. code-block::
@ -745,30 +745,6 @@ All tileset functions are callable via the global ``map`` object.
: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()
Gets the order that metatile layers are rendered.
:returns array: array of layers. The bottom layer is represented as 0.
.. js:function:: map.setMetatileLayerOrder(order)
Sets the order that metatile layers are rendered.
:param array order: array of layers. The bottom layer is represented as 0.
.. js:function:: map.getMetatileLayerOpacity()
Gets the opacities that metatile layers are rendered with.
:returns array: array of opacities for each layer. The bottom layer is the first element.
.. js:function:: map.setMetatileLayerOpacity(opacities)
Sets the opacities that metatile layers are rendered with.
:param array opacities: array of opacities for each layer. The bottom layer is the first element.
.. js:function:: map.getMetatileLabel(metatileId)
Gets the label for the specified metatile.
@ -1058,6 +1034,21 @@ All overlay functions are callable via the global ``overlay`` object.
:param number scale: the scale to set
.. js:function:: overlay.setScale(hScale, vScale, layer)
Sets the horizontal and vertical scale of the specified overlay layer. ``1.0`` is normal size.
:param number hScale: the horizontal scale to set
:param number vScale: the vertical scale to set
:param number layer: the layer id
.. js:function:: overlay.setScale(hScale, vScale)
This is an overloaded function. Sets the horizontal and vertical scale of all active overlay layers. Layers that have not been used yet will not have their scale changed. ``1.0`` is normal size.
:param number hScale: the horizontal scale to set
:param number vScale: the vertical scale to set
.. js:function:: overlay.getRotation(layer = 0)
Gets the angle the specified overlay layer is rotated to.
@ -1375,6 +1366,31 @@ All settings functions are callable via the global ``utility`` object.
:param number tab: index of the tab to select
.. js:function:: utility.getMetatileLayerOrder()
Gets the order that metatile layers are rendered.
:returns array: array of layers. The bottom layer is represented as 0.
.. js:function:: utility.setMetatileLayerOrder(order)
Sets the order that metatile layers are rendered.
:param array order: array of layers. The bottom layer is represented as 0.
.. js:function:: utility.getMetatileLayerOpacity()
Gets the opacities that metatile layers are rendered with.
:returns array: array of opacities for each layer. The bottom layer is the first element.
.. js:function:: utility.setMetatileLayerOpacity(opacities)
Sets the opacities that metatile layers are rendered with.
:param array opacities: array of opacities for each layer. The bottom layer is the first element.
Utility Functions
^^^^^^^^^^^^^^^^^

View file

@ -50,6 +50,8 @@ public:
Q_INVOKABLE void setHorizontalScale(qreal scale);
Q_INVOKABLE void setVerticalScale(qreal scale, int layer);
Q_INVOKABLE void setVerticalScale(qreal scale);
Q_INVOKABLE void setScale(qreal hScale, qreal vScale, int layer);
Q_INVOKABLE void setScale(qreal hScale, qreal vScale);
Q_INVOKABLE int getRotation(int layer = 0);
Q_INVOKABLE void setRotation(int angle, int layer);
Q_INVOKABLE void setRotation(int angle);

View file

@ -93,6 +93,7 @@ public:
qreal getVScale();
void setHScale(qreal scale);
void setVScale(qreal scale);
void setScale(qreal hScale, qreal vScale);
int getRotation();
void setRotation(int angle);
void rotate(int degrees);

View file

@ -1367,7 +1367,7 @@ void Project::loadTilesetAssets(Tileset* tileset) {
this->readTilesetPaths(tileset);
QImage image;
if (QFile::exists(tileset->tilesImagePath)) {
image = QImage(tileset->tilesImagePath);
image = QImage(tileset->tilesImagePath).convertToFormat(QImage::Format_Indexed8, Qt::ThresholdDither);
} else {
image = QImage(8, 8, QImage::Format_Indexed8);
}

View file

@ -179,6 +179,18 @@ void MapView::setVerticalScale(qreal scale) {
this->scene()->update();
}
void MapView::setScale(qreal hScale, qreal vScale, int layer) {
this->getOverlay(layer)->setScale(hScale, vScale);
this->scene()->update();
}
// Overload. No layer provided, set scale of all layers
void MapView::setScale(qreal hScale, qreal vScale) {
foreach (Overlay * layer, this->overlayMap)
layer->setScale(hScale, vScale);
this->scene()->update();
}
int MapView::getRotation(int layer) {
return this->getOverlay(layer)->getRotation();
}

View file

@ -106,6 +106,11 @@ void Overlay::setVScale(qreal scale) {
this->vScale = scale;
}
void Overlay::setScale(qreal hScale, qreal vScale) {
this->hScale = hScale;
this->vScale = vScale;
}
int Overlay::getRotation() {
return this->angle;
}