mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-15 21:32:12 -05:00
Add Custom Scripts Editor window
This commit is contained in:
@@ -348,8 +348,8 @@ public:
|
||||
bool getEncounterJsonActive();
|
||||
void setProjectDir(QString projectDir);
|
||||
QString getProjectDir();
|
||||
void setCustomScripts(QList<QString> scripts);
|
||||
QList<QString> getCustomScripts();
|
||||
void setCustomScripts(QStringList scripts);
|
||||
QStringList getCustomScripts();
|
||||
protected:
|
||||
virtual QString getConfigFilepath() override;
|
||||
virtual void parseConfigKeyValue(QString key, QString value) override;
|
||||
@@ -363,7 +363,7 @@ private:
|
||||
QString projectDir;
|
||||
QString recentMap;
|
||||
bool useEncounterJson;
|
||||
QList<QString> customScripts;
|
||||
QStringList customScripts;
|
||||
QStringList readKeys;
|
||||
};
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
|
||||
void shouldReselectEvents();
|
||||
void scaleMapView(int);
|
||||
void openInTextEditor(const QString &path, int lineNum = 0) const;
|
||||
static void openInTextEditor(const QString &path, int lineNum = 0);
|
||||
bool eventLimitReached(Event::Type type);
|
||||
|
||||
public slots:
|
||||
@@ -179,9 +179,9 @@ private:
|
||||
void updateEncounterFields(EncounterFields newFields);
|
||||
QString getMovementPermissionText(uint16_t collision, uint16_t elevation);
|
||||
QString getMetatileDisplayMessage(uint16_t metatileId);
|
||||
bool startDetachedProcess(const QString &command,
|
||||
const QString &workingDirectory = QString(),
|
||||
qint64 *pid = nullptr) const;
|
||||
static bool startDetachedProcess(const QString &command,
|
||||
const QString &workingDirectory = QString(),
|
||||
qint64 *pid = nullptr);
|
||||
|
||||
private slots:
|
||||
void onMapStartPaint(QGraphicsSceneMouseEvent *event, MapPixmapItem *item);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "shortcutseditor.h"
|
||||
#include "preferenceeditor.h"
|
||||
#include "projectsettingseditor.h"
|
||||
#include "customscriptseditor.h"
|
||||
|
||||
|
||||
|
||||
@@ -286,6 +287,7 @@ private slots:
|
||||
void on_actionEdit_Preferences_triggered();
|
||||
void togglePreferenceSpecificUi();
|
||||
void on_actionEdit_Project_Settings_triggered();
|
||||
void on_actionCustom_Scripts_triggered();
|
||||
|
||||
public:
|
||||
Ui::MainWindow *ui;
|
||||
@@ -300,6 +302,7 @@ private:
|
||||
QPointer<NewMapPopup> newMapPrompt = nullptr;
|
||||
QPointer<PreferenceEditor> preferenceEditor = nullptr;
|
||||
QPointer<ProjectSettingsEditor> projectSettingsEditor = nullptr;
|
||||
QPointer<CustomScriptsEditor> customScriptsEditor = nullptr;
|
||||
FilterChildrenProxyModel *mapListProxyModel;
|
||||
QStandardItemModel *mapListModel;
|
||||
QList<QStandardItem*> *mapGroupItemsList;
|
||||
@@ -343,6 +346,7 @@ private:
|
||||
bool loadProjectCombos();
|
||||
bool populateMapList();
|
||||
void sortMapList();
|
||||
void openSubWindow(QWidget * window);
|
||||
QString getExistingDirectory(QString);
|
||||
bool openProject(QString dir);
|
||||
QString getDefaultMap();
|
||||
|
||||
60
include/ui/customscriptseditor.h
Normal file
60
include/ui/customscriptseditor.h
Normal file
@@ -0,0 +1,60 @@
|
||||
#ifndef CUSTOMSCRIPTSEDITOR_H
|
||||
#define CUSTOMSCRIPTSEDITOR_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QListWidget>
|
||||
#include <QAbstractButton>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "customscriptslistitem.h"
|
||||
|
||||
namespace Ui {
|
||||
class CustomScriptsEditor;
|
||||
}
|
||||
|
||||
|
||||
class CustomScriptsEditor : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CustomScriptsEditor(QWidget *parent = nullptr);
|
||||
~CustomScriptsEditor();
|
||||
|
||||
signals:
|
||||
void reloadScriptEngine();
|
||||
|
||||
private:
|
||||
Ui::CustomScriptsEditor *ui;
|
||||
|
||||
bool hasUnsavedChanges = false;
|
||||
QString importDir;
|
||||
const QString baseDir;
|
||||
|
||||
void displayScript(const QString &filepath);
|
||||
QString chooseScript(QString dir);
|
||||
|
||||
void removeScript(QListWidgetItem * item);
|
||||
void replaceScript(QListWidgetItem * item);
|
||||
void openScript(QListWidgetItem * item);
|
||||
|
||||
QString getListItemFilepath(QListWidgetItem * item) const;
|
||||
void setListItemFilepath(QListWidgetItem * item, QString filepath) const;
|
||||
|
||||
int prompt(const QString &text, QMessageBox::StandardButton defaultButton);
|
||||
void save();
|
||||
void closeEvent(QCloseEvent*);
|
||||
|
||||
void initShortcuts();
|
||||
QObjectList shortcutableObjects() const;
|
||||
void applyUserShortcuts();
|
||||
|
||||
private slots:
|
||||
void dialogButtonClicked(QAbstractButton *button);
|
||||
void addNewScript();
|
||||
void reloadScripts();
|
||||
void removeSelectedScripts();
|
||||
void openSelectedScripts();
|
||||
};
|
||||
|
||||
#endif // CUSTOMSCRIPTSEDITOR_H
|
||||
22
include/ui/customscriptslistitem.h
Normal file
22
include/ui/customscriptslistitem.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef CUSTOMSCRIPTSLISTITEM_H
|
||||
#define CUSTOMSCRIPTSLISTITEM_H
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
namespace Ui {
|
||||
class CustomScriptsListItem;
|
||||
}
|
||||
|
||||
class CustomScriptsListItem : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CustomScriptsListItem(QWidget *parent = nullptr);
|
||||
~CustomScriptsListItem();
|
||||
|
||||
public:
|
||||
Ui::CustomScriptsListItem *ui;
|
||||
};
|
||||
|
||||
#endif // CUSTOMSCRIPTSLISTITEM_H
|
||||
Reference in New Issue
Block a user