Populate scripts comboboxes with scripts found in map.json
This commit is contained in:
parent
e97b50a249
commit
62f73bee04
5 changed files with 86 additions and 29 deletions
|
@ -15,6 +15,9 @@
|
|||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_Themes">
|
||||
<property name="sizePolicy">
|
||||
|
@ -63,17 +66,17 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>482</width>
|
||||
<height>398</height>
|
||||
<height>392</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_TextEditorGotoLineHelp">
|
||||
<property name="text">
|
||||
<string><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></string>
|
||||
<string><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></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
|
@ -83,13 +86,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_TextEditorGotoLine">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_TextEditorGotoLine">
|
||||
<property name="text">
|
||||
<string>Goto Line Command</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_TextEditorOpenFolder">
|
||||
<property name="toolTip">
|
||||
<string>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).</string>
|
||||
<string>The shell command for your preferred text editor (possibly an absolute path if the program doesn't exist in your PATH).</string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>e.g. code --goto %F:%L</string>
|
||||
<string>e.g. code %D</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
|
@ -99,7 +109,7 @@
|
|||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_TextEditorOpenFolderHelp">
|
||||
<property name="text">
|
||||
<string><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></string>
|
||||
<string><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></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
|
@ -116,22 +126,47 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_TextEditorOpenFolder">
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_TextEditorGotoLine">
|
||||
<property name="toolTip">
|
||||
<string>The shell command for your preferred text editor (possibly an absolute path if the program doesn't exist in your PATH).</string>
|
||||
<string>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).</string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>e.g. code %D</string>
|
||||
<string>e.g. code --goto %F:%L</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_TextEditorGotoLine">
|
||||
<property name="text">
|
||||
<string>Goto Line Command</string>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>15</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<Event*> getAllEvents();
|
||||
QList<Event*> getAllEvents() const;
|
||||
QStringList eventScriptLabels(const QString &event_group_type = QString()) const;
|
||||
void removeEvent(Event*);
|
||||
void addEvent(Event*);
|
||||
QPixmap renderConnection(MapConnection, MapLayout *);
|
||||
|
|
|
@ -450,12 +450,32 @@ void Map::magicFillCollisionElevation(int initialX, int initialY, uint16_t colli
|
|||
}
|
||||
}
|
||||
|
||||
QList<Event *> Map::getAllEvents() {
|
||||
QList<Event*> all;
|
||||
for (QList<Event*> list : events.values()) {
|
||||
all += list;
|
||||
QList<Event *> Map::getAllEvents() const {
|
||||
QList<Event *> 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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue