#pragma once #ifndef SCRIPTUTILITY_H #define SCRIPTUTILITY_H #include "mainwindow.h" class ScriptUtility : public QObject { Q_OBJECT public: ScriptUtility(MainWindow *mainWindow); void clearActions(); QString getActionFunctionName(QString actionName); Q_INVOKABLE void registerAction(QString functionName, QString actionName, QString shortcut = ""); 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 getCustomScripts(); Q_INVOKABLE QList getMetatileLayerOrder(); Q_INVOKABLE void setMetatileLayerOrder(QList order); Q_INVOKABLE QList getMetatileLayerOpacity(); Q_INVOKABLE void setMetatileLayerOpacity(QList order); Q_INVOKABLE QList getMapNames(); Q_INVOKABLE QList getTilesetNames(); Q_INVOKABLE QList getPrimaryTilesetNames(); Q_INVOKABLE QList getSecondaryTilesetNames(); Q_INVOKABLE QList getMetatileBehaviorNames(); Q_INVOKABLE QList getSongNames(); Q_INVOKABLE QList getLocationNames(); Q_INVOKABLE QList getWeatherNames(); Q_INVOKABLE QList getMapTypeNames(); Q_INVOKABLE QList getBattleSceneNames(); 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 registeredActions; QMap actionMap; }; #endif // SCRIPTUTILITY_H