mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-10 01:45:34 -05:00
Merge pull request #692 from GriffinRichards/utility
Add utility file, more project load speed improvements
This commit is contained in:
@@ -220,6 +220,7 @@ enum ProjectIdentifier {
|
||||
define_attribute_encounter,
|
||||
define_metatile_label_prefix,
|
||||
define_heal_locations_prefix,
|
||||
define_layout_prefix,
|
||||
define_map_prefix,
|
||||
define_map_dynamic,
|
||||
define_map_empty,
|
||||
|
||||
@@ -45,7 +45,8 @@ public:
|
||||
void setConstantName(const QString &constantName) { m_constantName = constantName; }
|
||||
QString constantName() const { return m_constantName; }
|
||||
|
||||
static QString mapConstantFromName(QString mapName, bool includePrefix = true);
|
||||
static QString mapConstantFromName(const QString &name);
|
||||
QString expectedConstantName() const { return Map::mapConstantFromName(m_name); }
|
||||
|
||||
void setLayout(Layout *layout);
|
||||
Layout* layout() const { return m_layout; }
|
||||
|
||||
@@ -20,9 +20,7 @@ public:
|
||||
Layout() {}
|
||||
Layout(const Layout &other);
|
||||
|
||||
static QString layoutConstantFromName(QString mapName);
|
||||
static QString defaultSuffix();
|
||||
|
||||
static QString layoutConstantFromName(const QString &name);
|
||||
|
||||
bool loaded = false;
|
||||
bool hasUnsavedDataChanges = false;
|
||||
|
||||
@@ -54,9 +54,9 @@ 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 QStringList ®exList, QString *error = nullptr);
|
||||
QMap<QString, int> readCDefinesByName(const QString &filename, const QStringList &names, QString *error = nullptr);
|
||||
QStringList readCDefineNames(const QString &filename, const QStringList ®exList, QString *error = nullptr);
|
||||
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);
|
||||
QStringList readCDefineNames(const QString &filename, const QSet<QString> ®exList, QString *error = nullptr);
|
||||
tsl::ordered_map<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&);
|
||||
@@ -101,10 +101,10 @@ private:
|
||||
QMap<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 QStringList &filterList, bool useRegex, QString *error);
|
||||
QMap<QString, int> evaluateCDefines(const QString &filename, const QStringList &filterList, bool useRegex, QString *error);
|
||||
bool defineNameMatchesFilter(const QString &name, const QStringList &filterList) const;
|
||||
bool defineNameMatchesFilter(const QString &name, const QList<QRegularExpression> &filterList) const;
|
||||
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);
|
||||
bool defineNameMatchesFilter(const QString &name, const QSet<QString> &filterList) const;
|
||||
bool defineNameMatchesFilter(const QString &name, const QSet<QRegularExpression> &filterList) const;
|
||||
|
||||
static const QRegularExpression re_incScriptLabel;
|
||||
static const QRegularExpression re_globalIncScriptLabel;
|
||||
|
||||
14
include/core/utility.h
Normal file
14
include/core/utility.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#ifndef UTILITY_H
|
||||
#define UTILITY_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace Util {
|
||||
void numericalModeSort(QStringList &list);
|
||||
int roundUp(int numToRound, int multiple);
|
||||
QString toDefineCase(QString input);
|
||||
QString toHexString(uint32_t value, int minLength = 0);
|
||||
}
|
||||
|
||||
#endif // UTILITY_H
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
QStringList itemNames;
|
||||
QStringList flagNames;
|
||||
QStringList varNames;
|
||||
QStringList speciesNames;
|
||||
QStringList movementTypes;
|
||||
QStringList mapTypes;
|
||||
QStringList mapBattleScenes;
|
||||
@@ -142,8 +143,8 @@ public:
|
||||
QVector<poryjson::Json::object> extraEncounterGroups;
|
||||
|
||||
bool readSpeciesIconPaths();
|
||||
QPixmap getSpeciesIcon(const QString &species) const;
|
||||
QMap<QString, QString> speciesToIconPath;
|
||||
QString getDefaultSpeciesIconPath(const QString &species);
|
||||
QPixmap getSpeciesIcon(const QString &species);
|
||||
|
||||
void addNewMapsec(const QString &idName);
|
||||
void removeMapsec(const QString &idName);
|
||||
@@ -251,12 +252,11 @@ public:
|
||||
static QString getEmptyMapsecName();
|
||||
static QString getMapGroupPrefix();
|
||||
|
||||
static void numericalModeSort(QStringList &list);
|
||||
|
||||
private:
|
||||
QMap<QString, QString> mapSectionDisplayNames;
|
||||
QMap<QString, qint64> modifiedFileTimestamps;
|
||||
QMap<QString, QString> facingDirections;
|
||||
QMap<QString, QString> speciesToIconPath;
|
||||
|
||||
struct EventGraphics
|
||||
{
|
||||
@@ -277,6 +277,8 @@ private:
|
||||
void ignoreWatchedFileTemporarily(QString filepath);
|
||||
void recordFileChange(const QString &filepath);
|
||||
|
||||
QString findSpeciesIconPath(const QStringList &names) const;
|
||||
|
||||
int maxEventsPerGroup;
|
||||
int maxObjectEvents;
|
||||
static int num_tiles_primary;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "selectablepixmapitem.h"
|
||||
#include "paletteutil.h"
|
||||
#include "imageproviders.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include <memory>
|
||||
using std::shared_ptr;
|
||||
@@ -66,7 +67,7 @@ public:
|
||||
}
|
||||
|
||||
virtual QString info() const {
|
||||
return QString("Tile: 0x") + QString("%1 ").arg(this->id(), 4, 16, QChar('0')).toUpper();
|
||||
return QString("Tile: %1 ").arg(Util::toHexString(this->id(), 4));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user