Add Project::getMapScriptsFilePath() and rename text editor config members
This commit is contained in:
parent
662fb2a367
commit
3478846b60
5 changed files with 26 additions and 15 deletions
|
@ -61,7 +61,7 @@ public:
|
|||
void setMonitorFiles(bool monitor);
|
||||
void setRegionMapDimensions(int width, int height);
|
||||
void setTheme(QString theme);
|
||||
void setTextEditorCommand(const QString &command);
|
||||
void setTextEditorCommandTemplate(const QString &commandTemplate);
|
||||
QString getRecentProject();
|
||||
QString getRecentMap();
|
||||
MapSortOrder getMapSortOrder();
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
bool getMonitorFiles();
|
||||
QSize getRegionMapDimensions();
|
||||
QString getTheme();
|
||||
QString getTextEditorCommand();
|
||||
QString getTextEditorCommandTemplate();
|
||||
protected:
|
||||
virtual QString getConfigFilepath() override;
|
||||
virtual void parseConfigKeyValue(QString key, QString value) override;
|
||||
|
@ -109,7 +109,7 @@ private:
|
|||
bool monitorFiles;
|
||||
QSize regionMapDimensions;
|
||||
QString theme;
|
||||
QString textEditorCommand;
|
||||
QString textEditorCommandTemplate;
|
||||
};
|
||||
|
||||
extern PorymapConfig porymapConfig;
|
||||
|
|
|
@ -172,8 +172,9 @@ public:
|
|||
QString fixPalettePath(QString path);
|
||||
QString fixGraphicPath(QString path);
|
||||
|
||||
QString getScriptFileExtension(bool usePoryScript);
|
||||
QString getScriptDefaultString(bool usePoryScript, QString mapName);
|
||||
QString getScriptFileExtension(bool usePoryScript) const;
|
||||
QString getScriptDefaultString(bool usePoryScript, QString mapName) const;
|
||||
QString getMapScriptsFilePath(const QString &mapName) const;
|
||||
|
||||
bool loadMapBorder(Map *map);
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue