diff --git a/forms/preferenceeditor.ui b/forms/preferenceeditor.ui index eafffcbf..b082ec1d 100644 --- a/forms/preferenceeditor.ui +++ b/forms/preferenceeditor.ui @@ -15,6 +15,9 @@ + + 9 + @@ -63,17 +66,17 @@ 0 0 482 - 398 + 392 QLayout::SetMinimumSize - + - <html><head/><body><p>The command that will be executed when clicking the <span style=" font-weight:600;">Open Map Scripts</span> button<span style=" font-weight:600;">. %F</span> will be substituted with the scripts file path and <span style=" font-weight:600;">%L</span> will be substituted with the line number of the event that is currently selected. <span style=" font-weight:600;">%F </span><span style=" font-style:italic;">must</span> be specified if <span style=" font-weight:600;">%L</span> is specified. If <span style=" font-weight:600;">%F</span> is <span style=" font-style:italic;">not</span> specified then the scripts file path will be appended to the end of the command.</p></body></html> + <html><head/><body><p>This is the command that will be executed when clicking the <span style=" font-weight:600;">Open Map Scripts</span> button<span style=" font-weight:600;">. %F</span> will be substituted with the scripts file path and <span style=" font-weight:600;">%L</span> will be substituted with the line number of the script for the currently selected event. <span style=" font-weight:600;">%F </span><span style=" font-style:italic;">must</span> be specified if <span style=" font-weight:600;">%L</span> is specified. If <span style=" font-weight:600;">%F</span> is <span style=" font-style:italic;">not</span> specified then the scripts file path will be appended to the end of the command.</p></body></html> Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -83,13 +86,20 @@ - - + + + + Goto Line Command + + + + + - The shell command for your preferred text editor to open a file to a specific line number (possibly an absolute path if the program doesn't exist in your PATH). + The shell command for your preferred text editor (possibly an absolute path if the program doesn't exist in your PATH). - e.g. code --goto %F:%L + e.g. code %D true @@ -99,7 +109,7 @@ - <html><head/><body><p>The command that will be executed when clicking <span style=" font-weight:600;">Open Project in Text Editor</span> in the <span style=" font-weight:600;">Tools</span> menu. <span style=" font-weight:600;">%D</span> will be substituted with the current project's root directory. If <span style=" font-weight:600;">%D</span> is <span style=" font-style:italic;">not</span> specified then the project directory will be appended to the end of the command.</p></body></html> + <html><head/><body><p>This is the command that will be executed when clicking <span style=" font-weight:600;">Open Project in Text Editor</span> in the <span style=" font-weight:600;">Tools</span> menu. <span style=" font-weight:600;">%D</span> will be substituted with the current project's root directory. If <span style=" font-weight:600;">%D</span> is <span style=" font-style:italic;">not</span> specified then the project directory will be appended to the end of the command.</p></body></html> Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -116,22 +126,47 @@ - - + + - The shell command for your preferred text editor (possibly an absolute path if the program doesn't exist in your PATH). + The shell command for your preferred text editor to open a file to a specific line number (possibly an absolute path if the program doesn't exist in your PATH). - e.g. code %D + e.g. code --goto %F:%L + + + true - - - - Goto Line Command + + + + Qt::Vertical - + + QSizePolicy::Fixed + + + + 20 + 15 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + diff --git a/include/core/event.h b/include/core/event.h index 48d13253..b6e0d175 100644 --- a/include/core/event.h +++ b/include/core/event.h @@ -31,10 +31,10 @@ public: Event(const Event&); Event(QJsonObject, QString); public: - int x() { + int x() const { return getInt("x"); } - int y() { + int y() const { return getInt("y"); } int elevation() { @@ -46,16 +46,16 @@ public: void setY(int y) { put("y", y); } - QString get(QString key) { + QString get(const QString &key) const { return values.value(key); } - int getInt(QString key) { + int getInt(const QString &key) const { return values.value(key).toInt(nullptr, 0); } - uint16_t getU16(QString key) { + uint16_t getU16(const QString &key) const { return values.value(key).toUShort(nullptr, 0); } - int16_t getS16(QString key) { + int16_t getS16(const QString &key) const { return values.value(key).toShort(nullptr, 0); } void put(QString key, int value) { diff --git a/include/core/map.h b/include/core/map.h index 4d34a071..a2a51551 100644 --- a/include/core/map.h +++ b/include/core/map.h @@ -83,7 +83,8 @@ public: void floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation); void _floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation); void magicFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation); - QList getAllEvents(); + QList getAllEvents() const; + QStringList eventScriptLabels(const QString &event_group_type = QString()) const; void removeEvent(Event*); void addEvent(Event*); QPixmap renderConnection(MapConnection, MapLayout *); diff --git a/src/core/map.cpp b/src/core/map.cpp index 02cd15f8..14da4650 100644 --- a/src/core/map.cpp +++ b/src/core/map.cpp @@ -450,12 +450,32 @@ void Map::magicFillCollisionElevation(int initialX, int initialY, uint16_t colli } } -QList Map::getAllEvents() { - QList all; - for (QList list : events.values()) { - all += list; +QList Map::getAllEvents() const { + QList all_events; + for (const auto &event_list : events) { + all_events << event_list; } - return all; + return all_events; +} + +QStringList Map::eventScriptLabels(const QString &event_group_type) const { + QStringList scriptLabels; + if (event_group_type.isEmpty()) { + for (const auto *event : getAllEvents()) + scriptLabels << event->get("script_label"); + } else { + for (const auto *event : events.value(event_group_type)) + scriptLabels << event->get("script_label"); + } + + scriptLabels.removeDuplicates(); + scriptLabels.removeAll(QString()); + if (scriptLabels.contains("0x0")) + scriptLabels.move(scriptLabels.indexOf("0x0"), scriptLabels.count() - 1); + if (scriptLabels.contains("NULL")) + scriptLabels.move(scriptLabels.indexOf("NULL"), scriptLabels.count() - 1); + + return scriptLabels; } void Map::removeEvent(Event *event) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 60d6018b..fe104371 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1789,6 +1789,7 @@ void MainWindow::updateSelectedObjects() { "normal movement behavior actions."); combo->setMinimumContentsLength(4); } else if (key == "script_label") { + combo->addItems(editor->map->eventScriptLabels()); combo->setToolTip("The script which is executed with this event."); } else if (key == "trainer_type") { combo->addItems(*editor->project->trainerTypes);