Add getPorymapVersion
This commit is contained in:
parent
af2f1b6f7d
commit
268cc9b30b
8 changed files with 42 additions and 4 deletions
|
@ -1167,6 +1167,12 @@ The following functions are related to settings.
|
||||||
|
|
||||||
:returns string: ``"pokeruby"``, ``"pokefirered"``, or ``"pokeemerald"``
|
: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()
|
.. js:function:: map.getCustomScripts()
|
||||||
|
|
||||||
Gets the list of paths to custom scripts.
|
Gets the list of paths to custom scripts.
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label_Title">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<family>Segoe UI</family>
|
<family>Segoe UI</family>
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_Version">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_Description">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<family>Segoe UI</family>
|
<family>Segoe UI</family>
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_Manual">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p>Official Documentation: <a href="https://huderlem.github.io/porymap/"><span style=" text-decoration: underline; color:#0000ff;">https://huderlem.github.io/porymap/</span></a></p></body></html></string>
|
<string><html><head/><body><p>Official Documentation: <a href="https://huderlem.github.io/porymap/"><span style=" text-decoration: underline; color:#0000ff;">https://huderlem.github.io/porymap/</span></a></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -177,6 +177,7 @@ public:
|
||||||
Q_INVOKABLE int getNumTilesInMetatile();
|
Q_INVOKABLE int getNumTilesInMetatile();
|
||||||
Q_INVOKABLE int getNumMetatileLayers();
|
Q_INVOKABLE int getNumMetatileLayers();
|
||||||
Q_INVOKABLE QString getBaseGameVersion();
|
Q_INVOKABLE QString getBaseGameVersion();
|
||||||
|
Q_INVOKABLE QJSValue getPorymapVersion();
|
||||||
Q_INVOKABLE QList<QString> getCustomScripts();
|
Q_INVOKABLE QList<QString> getCustomScripts();
|
||||||
Q_INVOKABLE int getMainTab();
|
Q_INVOKABLE int getMainTab();
|
||||||
Q_INVOKABLE void setMainTab(int index);
|
Q_INVOKABLE void setMainTab(int index);
|
||||||
|
|
|
@ -29,6 +29,7 @@ public:
|
||||||
static QJSValue fromBlock(Block block);
|
static QJSValue fromBlock(Block block);
|
||||||
static QJSValue fromTile(Tile tile);
|
static QJSValue fromTile(Tile tile);
|
||||||
static Tile toTile(QJSValue obj);
|
static Tile toTile(QJSValue obj);
|
||||||
|
static QJSValue version(QList<int> versionNums);
|
||||||
static QJSValue dimensions(int width, int height);
|
static QJSValue dimensions(int width, int height);
|
||||||
static QJSValue position(int x, int y);
|
static QJSValue position(int x, int y);
|
||||||
static QJSEngine *getEngine();
|
static QJSEngine *getEngine();
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef ABOUTPORYMAP_H
|
#ifndef ABOUTPORYMAP_H
|
||||||
#define ABOUTPORYMAP_H
|
#define ABOUTPORYMAP_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -12,6 +14,7 @@ class AboutPorymap : public QMainWindow
|
||||||
public:
|
public:
|
||||||
explicit AboutPorymap(QWidget *parent = nullptr);
|
explicit AboutPorymap(QWidget *parent = nullptr);
|
||||||
~AboutPorymap();
|
~AboutPorymap();
|
||||||
|
QList<int> getVersionNumbers();
|
||||||
private:
|
private:
|
||||||
Ui::AboutPorymap *ui;
|
Ui::AboutPorymap *ui;
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "editcommands.h"
|
#include "editcommands.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "imageproviders.h"
|
#include "imageproviders.h"
|
||||||
|
#include "aboutporymap.h"
|
||||||
|
|
||||||
QJSValue MainWindow::getBlock(int x, int y) {
|
QJSValue MainWindow::getBlock(int x, int y) {
|
||||||
if (!this->editor || !this->editor->map)
|
if (!this->editor || !this->editor->map)
|
||||||
|
@ -1051,6 +1052,13 @@ QString MainWindow::getBaseGameVersion() {
|
||||||
return projectConfig.getBaseGameVersionString();
|
return projectConfig.getBaseGameVersionString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJSValue MainWindow::getPorymapVersion() {
|
||||||
|
AboutPorymap *window = new AboutPorymap(this);
|
||||||
|
QJSValue version = Scripting::version(window->getVersionNumbers());
|
||||||
|
delete window;
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
QList<QString> MainWindow::getCustomScripts() {
|
QList<QString> MainWindow::getCustomScripts() {
|
||||||
return projectConfig.getCustomScripts();
|
return projectConfig.getCustomScripts();
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,6 +238,14 @@ QJSValue Scripting::position(int x, int y) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJSValue Scripting::version(QList<int> versionNums) {
|
||||||
|
QJSValue obj = instance->engine->newObject();
|
||||||
|
obj.setProperty("major", versionNums.at(0));
|
||||||
|
obj.setProperty("minor", versionNums.at(1));
|
||||||
|
obj.setProperty("patch", versionNums.at(2));
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
Tile Scripting::toTile(QJSValue obj) {
|
Tile Scripting::toTile(QJSValue obj) {
|
||||||
if (!obj.hasProperty("tileId")
|
if (!obj.hasProperty("tileId")
|
||||||
|| !obj.hasProperty("xflip")
|
|| !obj.hasProperty("xflip")
|
||||||
|
|
|
@ -12,3 +12,14 @@ AboutPorymap::~AboutPorymap()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the Porymap version number as a list of ints with the order {major, minor, patch}
|
||||||
|
QList<int> AboutPorymap::getVersionNumbers()
|
||||||
|
{
|
||||||
|
// Get the version string "#.#.#"
|
||||||
|
QRegularExpression regex("Version (\\d+)\\.(\\d+)\\.(\\d+)");
|
||||||
|
QRegularExpressionMatch match = regex.match(ui->label_Version->text());
|
||||||
|
if (!match.hasMatch())
|
||||||
|
return QList<int>({0, 0, 0});
|
||||||
|
return QList<int>({match.captured(1).toInt(), match.captured(2).toInt(), match.captured(3).toInt()});
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue