mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-26 18:06:32 -05:00
Add getPorymapVersion
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "editcommands.h"
|
||||
#include "config.h"
|
||||
#include "imageproviders.h"
|
||||
#include "aboutporymap.h"
|
||||
|
||||
QJSValue MainWindow::getBlock(int x, int y) {
|
||||
if (!this->editor || !this->editor->map)
|
||||
@@ -1051,6 +1052,13 @@ QString MainWindow::getBaseGameVersion() {
|
||||
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() {
|
||||
return projectConfig.getCustomScripts();
|
||||
}
|
||||
|
||||
@@ -238,6 +238,14 @@ QJSValue Scripting::position(int x, int y) {
|
||||
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) {
|
||||
if (!obj.hasProperty("tileId")
|
||||
|| !obj.hasProperty("xflip")
|
||||
|
||||
@@ -12,3 +12,14 @@ AboutPorymap::~AboutPorymap()
|
||||
{
|
||||
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()});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user