mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-17 06:08:07 -05:00
Merge branch 'dev' into update-scripts
This commit is contained in:
@@ -345,6 +345,8 @@ public:
|
||||
this->unusedTileCovered = 0x0000;
|
||||
this->unusedTileSplit = 0x0000;
|
||||
this->maxEventsPerGroup = 255;
|
||||
this->globalConstantsFilepaths.clear();
|
||||
this->globalConstants.clear();
|
||||
this->identifiers.clear();
|
||||
this->readKeys.clear();
|
||||
}
|
||||
@@ -417,6 +419,8 @@ public:
|
||||
QMargins playerViewDistance;
|
||||
QList<uint32_t> warpBehaviors;
|
||||
int maxEventsPerGroup;
|
||||
QStringList globalConstantsFilepaths;
|
||||
QMap<QString,QString> globalConstants;
|
||||
|
||||
protected:
|
||||
virtual QString getConfigFilepath() override;
|
||||
|
||||
@@ -107,8 +107,8 @@ public:
|
||||
void setBlock(int x, int y, Block block, bool enableScriptCallback = false);
|
||||
void setBlockdata(Blockdata blockdata, bool enableScriptCallback = false);
|
||||
|
||||
void adjustDimensions(QMargins margins, bool setNewBlockdata = true);
|
||||
void setDimensions(int newWidth, int newHeight, bool setNewBlockdata = true, bool enableScriptCallback = false);
|
||||
void adjustDimensions(const QMargins &margins, bool setNewBlockdata = true);
|
||||
void setDimensions(int newWidth, int newHeight, bool setNewBlockdata = true);
|
||||
void setBorderDimensions(int newWidth, int newHeight, bool setNewBlockdata = true, bool enableScriptCallback = false);
|
||||
|
||||
void cacheBlockdata();
|
||||
|
||||
@@ -43,8 +43,13 @@ class ParseUtil
|
||||
{
|
||||
public:
|
||||
ParseUtil();
|
||||
void set_root(const QString &dir);
|
||||
|
||||
void setRoot(const QString &dir) { this->root = dir; }
|
||||
void setUpdatesSplashScreen(bool updates) { this->updatesSplashScreen = updates; }
|
||||
|
||||
static QString readTextFile(const QString &path, QString *error = nullptr);
|
||||
QString loadTextFile(const QString &path, QString *error = nullptr);
|
||||
|
||||
bool cacheFile(const QString &path, QString *error = nullptr);
|
||||
void clearFileCache() { this->fileCache.clear(); }
|
||||
static int textFileLineCount(const QString &path);
|
||||
@@ -55,9 +60,13 @@ public:
|
||||
QString readCIncbin(const QString &text, const QString &label);
|
||||
QMap<QString, QString> readCIncbinMulti(const QString &filepath);
|
||||
QStringList readCIncbinArray(const QString &filename, const QString &label);
|
||||
QMap<QString, int> readCDefinesByRegex(const QString &filename, const QSet<QString> ®exList, QString *error = nullptr);
|
||||
QMap<QString, int> readCDefinesByName(const QString &filename, const QSet<QString> &names, QString *error = nullptr);
|
||||
QHash<QString, int> readCDefinesByRegex(const QString &filename, const QSet<QString> ®exList, QString *error = nullptr);
|
||||
QHash<QString, int> readCDefinesByName(const QString &filename, const QSet<QString> &names, QString *error = nullptr);
|
||||
QStringList readCDefineNames(const QString &filename, const QSet<QString> ®exList, QString *error = nullptr);
|
||||
void loadGlobalCDefinesFromFile(const QString &filename, QString *error = nullptr);
|
||||
void loadGlobalCDefines(const QMap<QString,QString> &defines);
|
||||
void loadGlobalCDefines(const QHash<QString,QString> &defines);
|
||||
void resetCDefines();
|
||||
OrderedMap<QString, QHash<QString, QString>> readCStructs(const QString &, const QString & = "", const QHash<int, QString>& = {});
|
||||
QList<QStringList> getLabelMacros(const QList<QStringList>&, const QString&);
|
||||
QStringList getLabelValues(const QList<QStringList>&, const QString&);
|
||||
@@ -90,24 +99,38 @@ private:
|
||||
QString curDefine;
|
||||
QHash<QString, QString> fileCache;
|
||||
QHash<QString, QStringList> errorMap;
|
||||
int evaluateDefine(const QString&, const QString &, QMap<QString, int>*, QMap<QString, QString>*);
|
||||
QList<Token> tokenizeExpression(QString, QMap<QString, int>*, QMap<QString, QString>*);
|
||||
|
||||
// The maps of define names to values/expressions that are available while parsing C defines.
|
||||
// As the parser reads and evaluates more defines it will update these maps accordingly.
|
||||
QHash<QString, int> knownDefineValues;
|
||||
QHash<QString, QString> knownDefineExpressions;
|
||||
|
||||
// Maps of special define names to values/expressions that take precedence over defines encountered while parsing.
|
||||
// Some (like 'TRUE'/'FALSE') are always present in these maps, others may be specified by the user with 'loadGlobalCDefines' / 'loadGlobalCDefinesFromFile'.
|
||||
QHash<QString, int> globalDefineValues;
|
||||
QHash<QString, QString> globalDefineExpressions;
|
||||
|
||||
bool updatesSplashScreen = false;
|
||||
|
||||
int evaluateDefine(const QString &identifier, bool *ok = nullptr);
|
||||
int evaluateExpression(const QString &expression);
|
||||
QList<Token> tokenizeExpression(QString expression);
|
||||
QList<Token> generatePostfix(const QList<Token> &tokens);
|
||||
int evaluatePostfix(const QList<Token> &postfix);
|
||||
void recordError(const QString &message);
|
||||
void recordErrors(const QStringList &errors);
|
||||
void logRecordedErrors();
|
||||
QString createErrorMessage(const QString &message, const QString &expression);
|
||||
void updateSplashScreen(QString path);
|
||||
|
||||
struct ParsedDefines {
|
||||
QMap<QString,QString> expressions; // Map of all define names encountered to their expressions
|
||||
QHash<QString,QString> expressions; // Map of all define names encountered to their expressions
|
||||
QStringList filteredNames; // List of define names that matched the search text, in the order that they were encountered
|
||||
};
|
||||
ParsedDefines readCDefines(const QString &filename, const QSet<QString> &filterList, bool useRegex, QString *error);
|
||||
QMap<QString, int> evaluateCDefines(const QString &filename, const QSet<QString> &filterList, bool useRegex, QString *error);
|
||||
QHash<QString, int> evaluateCDefines(const QString &filename, const QSet<QString> &filterList, bool useRegex, QString *error);
|
||||
bool defineNameMatchesFilter(const QString &name, const QSet<QString> &filterList) const;
|
||||
bool defineNameMatchesFilter(const QString &name, const QSet<QRegularExpression> &filterList) const;
|
||||
QString loadTextFile(const QString &path, QString *error = nullptr);
|
||||
QString pathWithRoot(const QString &path);
|
||||
|
||||
static const QRegularExpression re_incScriptLabel;
|
||||
|
||||
@@ -67,9 +67,9 @@ public:
|
||||
bool saveTilesImage();
|
||||
bool savePalettes();
|
||||
|
||||
bool appendToHeaders(QString root, QString friendlyName, bool usingAsm);
|
||||
bool appendToGraphics(QString root, QString friendlyName, bool usingAsm);
|
||||
bool appendToMetatiles(QString root, QString friendlyName, bool usingAsm);
|
||||
bool appendToHeaders(const QString &filepath, const QString &friendlyName, bool usingAsm);
|
||||
bool appendToGraphics(const QString &filepath, const QString &friendlyName, bool usingAsm);
|
||||
bool appendToMetatiles(const QString &filepath, const QString &friendlyName, bool usingAsm);
|
||||
|
||||
void setTilesImage(const QImage &image);
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ public:
|
||||
MainWindow(const MainWindow &) = delete;
|
||||
MainWindow & operator = (const MainWindow &) = delete;
|
||||
|
||||
void initialize();
|
||||
|
||||
// Scripting API
|
||||
Q_INVOKABLE QJSValue getBlock(int x, int y);
|
||||
void tryRedrawMapArea(bool forceRedraw);
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
int maxEncounterRate;
|
||||
bool wildEncountersLoaded;
|
||||
|
||||
void set_root(QString);
|
||||
void setRoot(const QString&);
|
||||
|
||||
void clearMaps();
|
||||
void clearTilesetCache();
|
||||
@@ -203,6 +203,7 @@ public:
|
||||
bool readEventGraphics();
|
||||
bool readFieldmapProperties();
|
||||
bool readFieldmapMasks();
|
||||
bool readGlobalConstants();
|
||||
QMap<QString, QMap<QString, QString>> readObjEventGfxInfo();
|
||||
|
||||
QPixmap getEventPixmap(const QString &gfxName, const QString &movementName);
|
||||
@@ -307,7 +308,10 @@ private:
|
||||
void setNewLayoutBlockdata(Layout *layout);
|
||||
void setNewLayoutBorder(Layout *layout);
|
||||
|
||||
void ignoreWatchedFileTemporarily(QString filepath);
|
||||
void watchFile(const QString &filename);
|
||||
void watchFiles(const QStringList &filenames);
|
||||
void ignoreWatchedFileTemporarily(const QString &filepath);
|
||||
void ignoreWatchedFilesTemporarily(const QStringList &filepaths);
|
||||
void recordFileChange(const QString &filepath);
|
||||
void resetFileCache();
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
static void populateGlobalObject(MainWindow *mainWindow);
|
||||
static QJSEngine *getEngine();
|
||||
static void invokeAction(int actionIndex);
|
||||
|
||||
static void cb_ProjectOpened(QString projectPath);
|
||||
static void cb_ProjectClosed(QString projectPath);
|
||||
static void cb_MetatileChanged(int x, int y, Block prevBlock, Block newBlock);
|
||||
@@ -47,18 +48,20 @@ public:
|
||||
static void cb_BlockHoverCleared();
|
||||
static void cb_MapOpened(QString mapName);
|
||||
static void cb_LayoutOpened(QString layoutName);
|
||||
static void cb_MapResized(int oldWidth, int oldHeight, int newWidth, int newHeight);
|
||||
static void cb_MapResized(int oldWidth, int oldHeight, const QMargins &delta);
|
||||
static void cb_BorderResized(int oldWidth, int oldHeight, int newWidth, int newHeight);
|
||||
static void cb_MapShifted(int xDelta, int yDelta);
|
||||
static void cb_TilesetUpdated(QString tilesetName);
|
||||
static void cb_MainTabChanged(int oldTab, int newTab);
|
||||
static void cb_MapViewTabChanged(int oldTab, int newTab);
|
||||
static void cb_BorderVisibilityToggled(bool visible);
|
||||
|
||||
static bool tryErrorJS(QJSValue js);
|
||||
static QJSValue fromBlock(Block block);
|
||||
static QJSValue fromTile(Tile tile);
|
||||
static Tile toTile(QJSValue obj);
|
||||
static QJSValue dimensions(int width, int height);
|
||||
static QJSValue margins(const QMargins &margins);
|
||||
static QJSValue position(int x, int y);
|
||||
static const QImage * getImage(const QString &filepath, bool useCache);
|
||||
static QJSValue dialogInput(QJSValue input, bool selectedOk);
|
||||
|
||||
@@ -13,6 +13,8 @@ class AboutPorymap : public QDialog
|
||||
public:
|
||||
explicit AboutPorymap(QWidget *parent = nullptr);
|
||||
~AboutPorymap();
|
||||
|
||||
static QString getVersionString();
|
||||
private:
|
||||
Ui::AboutPorymap *ui;
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define DIVINGMAPPIXMAPITEM_H
|
||||
|
||||
#include "mapconnection.h"
|
||||
#include "noscrollcombobox.h"
|
||||
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QPointer>
|
||||
@@ -10,7 +11,7 @@
|
||||
class DivingMapPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DivingMapPixmapItem(MapConnection *connection, QComboBox *combo);
|
||||
DivingMapPixmapItem(MapConnection *connection, NoScrollComboBox *combo);
|
||||
~DivingMapPixmapItem();
|
||||
|
||||
MapConnection* connection() const { return m_connection; }
|
||||
@@ -18,7 +19,7 @@ public:
|
||||
|
||||
private:
|
||||
QPointer<MapConnection> m_connection;
|
||||
QPointer<QComboBox> m_combo;
|
||||
QPointer<NoScrollComboBox> m_combo;
|
||||
|
||||
void setComboText(const QString &text);
|
||||
static QPixmap getBasePixmap(MapConnection* connection);
|
||||
|
||||
43
include/ui/loadingscreen.h
Normal file
43
include/ui/loadingscreen.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "qgifimage.h"
|
||||
|
||||
#include <QSplashScreen>
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class LoadingScreen;
|
||||
}
|
||||
|
||||
class PorymapLoadingScreen : public QWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PorymapLoadingScreen(QWidget *parent = nullptr);
|
||||
~PorymapLoadingScreen();
|
||||
|
||||
void setPixmap(const QPixmap &pixmap);
|
||||
void showMessage(const QString &text);
|
||||
void showMessage(const QString &prefix, const QString &text);
|
||||
void showLoadingMessage(const QString &text);
|
||||
|
||||
void start();
|
||||
void stop ();
|
||||
|
||||
private:
|
||||
void setupUi();
|
||||
|
||||
public slots:
|
||||
void updateFrame();
|
||||
|
||||
private:
|
||||
Ui::LoadingScreen *ui;
|
||||
|
||||
QGifImage splashImage;
|
||||
int frame = 0;
|
||||
QTimer timer;
|
||||
};
|
||||
|
||||
extern PorymapLoadingScreen *porysplash;
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "mapheader.h"
|
||||
#include "project.h"
|
||||
#include "noscrollcombobox.h"
|
||||
|
||||
namespace Ui {
|
||||
class MapHeaderForm;
|
||||
@@ -64,7 +65,7 @@ private:
|
||||
QPointer<Project> m_project = nullptr;
|
||||
bool m_allowProjectChanges = true;
|
||||
|
||||
void setText(QComboBox *combo, const QString &text) const;
|
||||
void setText(NoScrollComboBox *combo, const QString &text) const;
|
||||
void setText(QLineEdit *lineEdit, const QString &text) const;
|
||||
void setLocations(const QStringList &locations);
|
||||
void updateLocationName();
|
||||
|
||||
@@ -24,21 +24,21 @@ public:
|
||||
class ErrorMessage : public Message {
|
||||
public:
|
||||
ErrorMessage(const QString &message, QWidget *parent);
|
||||
static int show(const QString &message, QWidget *parent);
|
||||
static void show(const QString &message, QWidget *parent);
|
||||
};
|
||||
|
||||
// Basic warning message with an 'Ok' button.
|
||||
class WarningMessage : public Message {
|
||||
public:
|
||||
WarningMessage(const QString &message, QWidget *parent);
|
||||
static int show(const QString &message, QWidget *parent);
|
||||
static void show(const QString &message, QWidget *parent);
|
||||
};
|
||||
|
||||
// Basic informational message with a 'Close' button.
|
||||
class InfoMessage : public Message {
|
||||
public:
|
||||
InfoMessage(const QString &message, QWidget *parent);
|
||||
static int show(const QString &message, QWidget *parent);
|
||||
static void show(const QString &message, QWidget *parent);
|
||||
};
|
||||
|
||||
// Basic question message with a 'Yes' and 'No' button.
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
class RecentErrorMessage : public ErrorMessage {
|
||||
public:
|
||||
RecentErrorMessage(const QString &message, QWidget *parent);
|
||||
static int show(const QString &message, QWidget *parent);
|
||||
static void show(const QString &message, QWidget *parent);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
}
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override {
|
||||
if (!(*enabled)) return;
|
||||
if (!isVisible()) return;
|
||||
painter->setPen(this->color);
|
||||
painter->drawRect(this->rect() + QMargins(1,1,1,1)); // Fill
|
||||
painter->setPen(Qt::black);
|
||||
@@ -28,11 +28,17 @@ public:
|
||||
painter->drawRect(this->rect()); // Inner border
|
||||
}
|
||||
void updateLocation(int x, int y);
|
||||
bool *enabled;
|
||||
|
||||
void setActive(bool active);
|
||||
bool getActive() const { return this->active; }
|
||||
|
||||
protected:
|
||||
bool *enabled = nullptr;
|
||||
bool active = true;
|
||||
QRectF baseRect;
|
||||
QRgb color;
|
||||
|
||||
void updateVisibility();
|
||||
};
|
||||
|
||||
|
||||
|
||||
32
include/ui/newdefinedialog.h
Normal file
32
include/ui/newdefinedialog.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef NEWDEFINEDIALOG_H
|
||||
#define NEWDEFINEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QAbstractButton>
|
||||
|
||||
namespace Ui {
|
||||
class NewDefineDialog;
|
||||
}
|
||||
|
||||
class NewDefineDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NewDefineDialog(QWidget *parent = nullptr);
|
||||
~NewDefineDialog();
|
||||
|
||||
virtual void accept() override;
|
||||
|
||||
signals:
|
||||
void createdDefine(const QString &name, const QString &expression);
|
||||
|
||||
private:
|
||||
Ui::NewDefineDialog *ui;
|
||||
|
||||
bool validateName(bool allowEmpty = false);
|
||||
void onNameChanged(const QString &name);
|
||||
void dialogButtonClicked(QAbstractButton *button);
|
||||
};
|
||||
|
||||
#endif // NEWDEFINEDIALOG_H
|
||||
@@ -67,6 +67,12 @@ private:
|
||||
void setWarpBehaviorsList(QStringList list);
|
||||
void openFilesHelp();
|
||||
void openIdentifiersHelp();
|
||||
void addNewGlobalConstantsFilepath();
|
||||
void addGlobalConstantsFilepath(const QString &filepath);
|
||||
QStringList getGlobalConstantsFilepaths();
|
||||
void addNewGlobalConstant();
|
||||
void addGlobalConstant(const QString &name, const QString &expression);
|
||||
QMap<QString,QString> getGlobalConstants();
|
||||
|
||||
private slots:
|
||||
void dialogButtonClicked(QAbstractButton *button);
|
||||
|
||||
Reference in New Issue
Block a user