Add Project::getMapScriptsFilePath() and rename text editor config members

This commit is contained in:
BigBahss
2020-11-21 17:33:16 -05:00
parent 662fb2a367
commit 3478846b60
5 changed files with 26 additions and 15 deletions

View File

@@ -188,7 +188,7 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
} else if (key == "theme") {
this->theme = value;
} else if (key == "text_editor") {
this->textEditorCommand = value;
this->textEditorCommandTemplate = value;
} else {
logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->getConfigFilepath()).arg(key));
}
@@ -218,7 +218,7 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
map.insert("region_map_dimensions", QString("%1x%2").arg(this->regionMapDimensions.width())
.arg(this->regionMapDimensions.height()));
map.insert("theme", this->theme);
map.insert("text_editor", this->textEditorCommand);
map.insert("text_editor", this->textEditorCommandTemplate);
return map;
}
@@ -319,8 +319,8 @@ void PorymapConfig::setTheme(QString theme) {
this->theme = theme;
}
void PorymapConfig::setTextEditorCommand(const QString &command) {
this->textEditorCommand = command;
void PorymapConfig::setTextEditorCommandTemplate(const QString &commandTemplate) {
this->textEditorCommandTemplate = commandTemplate;
this->save();
}
@@ -406,8 +406,8 @@ QString PorymapConfig::getTheme() {
return this->theme;
}
QString PorymapConfig::getTextEditorCommand() {
return this->textEditorCommand;
QString PorymapConfig::getTextEditorCommandTemplate() {
return this->textEditorCommandTemplate;
}
const QMap<BaseGameVersion, QString> baseGameVersionMap = {

View File

@@ -2410,7 +2410,7 @@ QString Project::fixGraphicPath(QString path) {
return path;
}
QString Project::getScriptFileExtension(bool usePoryScript) {
QString Project::getScriptFileExtension(bool usePoryScript) const {
if(usePoryScript) {
return ".pory";
} else {
@@ -2418,13 +2418,23 @@ QString Project::getScriptFileExtension(bool usePoryScript) {
}
}
QString Project::getScriptDefaultString(bool usePoryScript, QString mapName) {
QString Project::getScriptDefaultString(bool usePoryScript, QString mapName) const {
if(usePoryScript)
return QString("mapscripts %1_MapScripts {}").arg(mapName);
else
return QString("%1_MapScripts::\n\t.byte 0\n").arg(mapName);
}
QString Project::getMapScriptsFilePath(const QString &mapName) const {
const bool usePoryscript = projectConfig.getUsePoryScript();
auto path = QDir::cleanPath(root + "/data/maps/" + mapName + "/scripts");
auto extension = getScriptFileExtension(usePoryscript);
if (usePoryscript && !QFile::exists(path + extension))
extension = getScriptFileExtension(false);
path += extension;
return path;
}
void Project::loadEventPixmaps(QList<Event*> objects) {
bool needs_update = false;
for (Event *object : objects) {

View File

@@ -30,7 +30,7 @@ PreferenceEditor::~PreferenceEditor()
}
void PreferenceEditor::populateFields() {
ui->lineEdit_TextEditor->setText(porymapConfig.getTextEditorCommand());
ui->lineEdit_TextEditor->setText(porymapConfig.getTextEditorCommandTemplate());
QStringList themes = { "default" };
QRegularExpression re(":/themes/([A-z0-9_-]+).qss");
@@ -44,7 +44,7 @@ void PreferenceEditor::populateFields() {
}
void PreferenceEditor::saveFields() {
porymapConfig.setTextEditorCommand(ui->lineEdit_TextEditor->text());
porymapConfig.setTextEditorCommandTemplate(ui->lineEdit_TextEditor->text());
if (themeSelector->currentText() != porymapConfig.getTheme()) {
const auto theme = themeSelector->currentText();