2022-09-05 16:53:30 +01:00
|
|
|
#pragma once
|
2022-09-05 17:17:27 +01:00
|
|
|
#ifndef SCRIPTUTILITY_H
|
|
|
|
#define SCRIPTUTILITY_H
|
2022-09-05 16:53:30 +01:00
|
|
|
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
|
|
|
class ScriptUtility : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
ScriptUtility(MainWindow *mainWindow);
|
|
|
|
void clearActions();
|
2023-02-09 18:55:25 +00:00
|
|
|
QString getActionFunctionName(int actionIndex);
|
2023-02-10 16:46:19 +00:00
|
|
|
Q_INVOKABLE bool registerAction(QString functionName, QString actionName, QString shortcut = "");
|
|
|
|
Q_INVOKABLE bool registerToggleAction(QString functionName, QString actionName, QString shortcut = "", bool checked = false);
|
2022-09-05 16:53:30 +01:00
|
|
|
Q_INVOKABLE void setTimeout(QJSValue callback, int milliseconds);
|
|
|
|
Q_INVOKABLE void log(QString message);
|
|
|
|
Q_INVOKABLE void warn(QString message);
|
|
|
|
Q_INVOKABLE void error(QString message);
|
|
|
|
Q_INVOKABLE void showMessage(QString text, QString informativeText = "", QString detailedText = "");
|
|
|
|
Q_INVOKABLE void showWarning(QString text, QString informativeText = "", QString detailedText = "");
|
|
|
|
Q_INVOKABLE void showError(QString text, QString informativeText = "", QString detailedText = "");
|
|
|
|
Q_INVOKABLE bool showQuestion(QString text, QString informativeText = "", QString detailedText = "");
|
|
|
|
Q_INVOKABLE QJSValue getInputText(QString title, QString label, QString defaultValue = "");
|
|
|
|
Q_INVOKABLE QJSValue getInputNumber(QString title, QString label, double defaultValue = 0, double min = INT_MIN, double max = INT_MAX, int decimals = 0, double step = 1);
|
|
|
|
Q_INVOKABLE QJSValue getInputItem(QString title, QString label, QStringList items, int defaultValue = 0, bool editable = false);
|
|
|
|
Q_INVOKABLE int getMainTab();
|
|
|
|
Q_INVOKABLE void setMainTab(int index);
|
|
|
|
Q_INVOKABLE int getMapViewTab();
|
|
|
|
Q_INVOKABLE void setMapViewTab(int index);
|
|
|
|
Q_INVOKABLE void setGridVisibility(bool visible);
|
|
|
|
Q_INVOKABLE bool getGridVisibility();
|
|
|
|
Q_INVOKABLE void setBorderVisibility(bool visible);
|
|
|
|
Q_INVOKABLE bool getBorderVisibility();
|
|
|
|
Q_INVOKABLE void setSmartPathsEnabled(bool visible);
|
|
|
|
Q_INVOKABLE bool getSmartPathsEnabled();
|
|
|
|
Q_INVOKABLE QList<QString> getCustomScripts();
|
|
|
|
Q_INVOKABLE QList<int> getMetatileLayerOrder();
|
|
|
|
Q_INVOKABLE void setMetatileLayerOrder(QList<int> order);
|
|
|
|
Q_INVOKABLE QList<float> getMetatileLayerOpacity();
|
|
|
|
Q_INVOKABLE void setMetatileLayerOpacity(QList<float> order);
|
2022-10-01 04:01:00 +01:00
|
|
|
Q_INVOKABLE QList<QString> getMapNames();
|
|
|
|
Q_INVOKABLE QList<QString> getTilesetNames();
|
|
|
|
Q_INVOKABLE QList<QString> getPrimaryTilesetNames();
|
|
|
|
Q_INVOKABLE QList<QString> getSecondaryTilesetNames();
|
|
|
|
Q_INVOKABLE QList<QString> getMetatileBehaviorNames();
|
|
|
|
Q_INVOKABLE QList<QString> getSongNames();
|
|
|
|
Q_INVOKABLE QList<QString> getLocationNames();
|
|
|
|
Q_INVOKABLE QList<QString> getWeatherNames();
|
|
|
|
Q_INVOKABLE QList<QString> getMapTypeNames();
|
|
|
|
Q_INVOKABLE QList<QString> getBattleSceneNames();
|
2022-09-05 16:53:30 +01:00
|
|
|
Q_INVOKABLE bool isPrimaryTileset(QString tilesetName);
|
|
|
|
Q_INVOKABLE bool isSecondaryTileset(QString tilesetName);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void callTimeoutFunction(QJSValue callback);
|
|
|
|
void runMessageBox(QString text, QString informativeText, QString detailedText, QMessageBox::Icon icon);
|
|
|
|
|
|
|
|
MainWindow *window;
|
|
|
|
QList<QAction *> registeredActions;
|
2023-02-09 18:55:25 +00:00
|
|
|
QHash<int, QString> actionMap;
|
2022-09-05 16:53:30 +01:00
|
|
|
};
|
|
|
|
|
2022-09-05 17:17:27 +01:00
|
|
|
#endif // SCRIPTUTILITY_H
|