mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-12 20:05:55 -05:00
Merge branch 'master' of https://github.com/huderlem/porymap into slam
This commit is contained in:
@@ -27,6 +27,7 @@ Map::~Map() {
|
||||
void Map::setName(QString mapName) {
|
||||
name = mapName;
|
||||
constantName = mapConstantFromName(mapName);
|
||||
scriptsFileLabels = ParseUtil::getGlobalScriptLabels(this->getScriptsFilePath());
|
||||
}
|
||||
|
||||
void Map::setLayout(Layout *layout) {
|
||||
@@ -36,11 +37,12 @@ void Map::setLayout(Layout *layout) {
|
||||
}
|
||||
}
|
||||
|
||||
QString Map::mapConstantFromName(QString mapName) {
|
||||
QString Map::mapConstantFromName(QString mapName, bool includePrefix) {
|
||||
// Transform map names of the form 'GraniteCave_B1F` into map constants like 'MAP_GRANITE_CAVE_B1F'.
|
||||
static const QRegularExpression caseChange("([a-z])([A-Z])");
|
||||
QString nameWithUnderscores = mapName.replace(caseChange, "\\1_\\2");
|
||||
QString withMapAndUppercase = "MAP_" + nameWithUnderscores.toUpper();
|
||||
const QString prefix = includePrefix ? projectConfig.getIdentifier(ProjectIdentifier::define_map_prefix) : "";
|
||||
QString withMapAndUppercase = prefix + nameWithUnderscores.toUpper();
|
||||
static const QRegularExpression underscores("_+");
|
||||
QString constantName = withMapAndUppercase.replace(underscores, "_");
|
||||
|
||||
@@ -67,7 +69,7 @@ int Map::getBorderHeight() {
|
||||
return layout->getBorderHeight();
|
||||
}
|
||||
|
||||
QPixmap Map::renderConnection(MapConnection connection, Layout *fromLayout) {
|
||||
QPixmap Map::renderConnection(MapConnection connection, Layout * fromLayout) {
|
||||
int x, y, w, h;
|
||||
if (connection.direction == "up") {
|
||||
x = 0;
|
||||
@@ -115,9 +117,10 @@ QList<Event *> Map::getAllEvents() const {
|
||||
return all_events;
|
||||
}
|
||||
|
||||
QStringList Map::eventScriptLabels(Event::Group group) const {
|
||||
QStringList Map::getScriptLabels(Event::Group group) const {
|
||||
QStringList scriptLabels;
|
||||
|
||||
// Get script labels currently in-use by the map's events
|
||||
if (group == Event::Group::None) {
|
||||
ScriptTracker scriptTracker;
|
||||
for (Event *event : this->getAllEvents()) {
|
||||
@@ -132,14 +135,30 @@ QStringList Map::eventScriptLabels(Event::Group group) const {
|
||||
scriptLabels = scriptTracker.getScripts();
|
||||
}
|
||||
|
||||
scriptLabels.removeAll("");
|
||||
// Add scripts from map's scripts file, and empty names.
|
||||
scriptLabels.append(scriptsFileLabels);
|
||||
scriptLabels.prepend("0x0");
|
||||
scriptLabels.prepend("NULL");
|
||||
|
||||
scriptLabels.removeAll("");
|
||||
scriptLabels.removeDuplicates();
|
||||
|
||||
return scriptLabels;
|
||||
}
|
||||
|
||||
QString Map::getScriptsFilePath() const {
|
||||
const bool usePoryscript = projectConfig.getUsePoryScript();
|
||||
auto path = QDir::cleanPath(QString("%1/%2/%3/scripts")
|
||||
.arg(projectConfig.getProjectDir())
|
||||
.arg(projectConfig.getFilePath(ProjectFilePath::data_map_folders))
|
||||
.arg(this->name));
|
||||
auto extension = Project::getScriptFileExtension(usePoryscript);
|
||||
if (usePoryscript && !QFile::exists(path + extension))
|
||||
extension = Project::getScriptFileExtension(false);
|
||||
path += extension;
|
||||
return path;
|
||||
}
|
||||
|
||||
void Map::removeEvent(Event *event) {
|
||||
for (Event::Group key : events.keys()) {
|
||||
events[key].removeAll(event);
|
||||
|
||||
Reference in New Issue
Block a user