Merge remote-tracking branch 'diego/tabbed_events'

This commit is contained in:
Marcus Huderle 2018-12-20 17:35:59 -06:00
commit b2053e593f
5 changed files with 660 additions and 111 deletions

View file

@ -84,11 +84,40 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_name">
<property name="text">
<string>Object 1</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QSpinBox" name="spinBox_index">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>The index of the event currently being inspected.</string>
</property>
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_name">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Object 1</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">

View file

@ -1177,7 +1177,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_Objects">
<widget class="QWidget" name="tab_Events">
<property name="enabled">
<bool>true</bool>
</property>
@ -1341,86 +1341,13 @@
<number>3</number>
</property>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_selectedObjects">
<property name="title">
<string>Selected</string>
<widget class="QLabel" name="label_NoEvents">
<property name="text">
<string>There are no events on the current map.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="frame_5">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustIgnored</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>428</width>
<height>586</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
@ -1537,6 +1464,289 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QTabWidget" name="tabWidget_EventType">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_Objects">
<attribute name="title">
<string>Objects</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea_Objects">
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_Objects">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>565</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_Warps">
<attribute name="title">
<string>Warps</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea_Warps">
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_Warps">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>565</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_Triggers">
<attribute name="title">
<string>Triggers</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea_Triggers">
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_Triggers">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>565</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_BGs">
<attribute name="title">
<string>BGs</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea_BGs">
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_BGs">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>565</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_Healspots">
<attribute name="title">
<string>Healspots</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_9">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea_Healspots">
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_Healspots">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>565</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_Multiple">
<attribute name="title">
<string>Multiple</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea_Multiple">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_Multiple">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>565</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
@ -2427,6 +2637,11 @@
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>NoScrollComboBox</class>
<extends>QComboBox</extends>
<header>noscrollcombobox.h</header>
</customwidget>
<customwidget>
<class>GraphicsView</class>
<extends>QGraphicsView</extends>
@ -2437,11 +2652,6 @@
<extends>QToolButton</extends>
<header>neweventtoolbutton.h</header>
</customwidget>
<customwidget>
<class>NoScrollComboBox</class>
<extends>QComboBox</extends>
<header>noscrollcombobox.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../resources/images.qrc"/>

View file

@ -78,6 +78,7 @@ private slots:
void addNewEvent(QString);
void updateSelectedObjects();
void updateObjects();
void on_toolButton_Paint_clicked();
@ -133,6 +134,10 @@ private slots:
void on_lineEdit_filterBox_textChanged(const QString &arg1);
void eventTabChanged(int index);
void selectedEventIndexChanged(int index);
private:
Ui::MainWindow *ui;
TilesetEditor *tilesetEditor = nullptr;
@ -144,6 +149,21 @@ private:
QIcon* mapIcon;
QIcon* mapEditedIcon;
QWidget *eventTabObjectWidget;
QWidget *eventTabWarpWidget;
QWidget *eventTabTriggerWidget;
QWidget *eventTabBGWidget;
QWidget *eventTabHealspotWidget;
QWidget *eventTabMultipleWidget;
DraggablePixmapItem *selectedObject;
DraggablePixmapItem *selectedWarp;
DraggablePixmapItem *selectedTrigger;
DraggablePixmapItem *selectedBG;
DraggablePixmapItem *selectedHealspot;
bool isProgrammaticEventTabChange;
enum MapSortOrder {
Group = 0,
Name = 1,
@ -178,6 +198,7 @@ private:
void loadUserSettings();
bool openRecentProject();
void updateTilesetEditor();
QString getEventGroupFromTabWidget(QWidget *tab);
bool isProjectOpen();
};

View file

@ -1015,7 +1015,7 @@ void DraggablePixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *mouse) {
last_x = static_cast<int>(mouse->pos().x() + this->pos().x()) / 16;
last_y = static_cast<int>(mouse->pos().y() + this->pos().y()) / 16;
this->editor->selectMapEvent(this, mouse->modifiers() & Qt::ControlModifier);
this->editor->updateSelectedEvents();
//this->editor->updateSelectedEvents();
selectingEvent = true;
}

View file

@ -28,7 +28,13 @@
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
ui(new Ui::MainWindow),
selectedObject(nullptr),
selectedWarp(nullptr),
selectedTrigger(nullptr),
selectedBG(nullptr),
selectedHealspot(nullptr),
isProgrammaticEventTabChange(false)
{
QCoreApplication::setOrganizationName("pret");
QCoreApplication::setApplicationName("porymap");
@ -74,11 +80,12 @@ void MainWindow::initCustomUI() {
void MainWindow::initExtraSignals() {
connect(ui->newEventToolButton, SIGNAL(newEventAdded(QString)), this, SLOT(addNewEvent(QString)));
connect(ui->tabWidget_EventType, &QTabWidget::currentChanged, this, &MainWindow::eventTabChanged);
}
void MainWindow::initEditor() {
this->editor = new Editor(ui);
connect(this->editor, SIGNAL(objectsChanged()), this, SLOT(updateSelectedObjects()));
connect(this->editor, SIGNAL(objectsChanged()), this, SLOT(updateObjects()));
connect(this->editor, SIGNAL(selectedObjectsChanged()), this, SLOT(updateSelectedObjects()));
connect(this->editor, SIGNAL(loadMapRequested(QString, QString)), this, SLOT(onLoadMapRequested(QString, QString)));
connect(this->editor, SIGNAL(tilesetChanged(QString)), this, SLOT(onTilesetChanged(QString)));
@ -104,6 +111,14 @@ void MainWindow::initMiscHeapObjects() {
mapListProxyModel->setSourceModel(mapListModel);
ui->mapList->setModel(mapListProxyModel);
eventTabObjectWidget = ui->tab_Objects;
eventTabWarpWidget = ui->tab_Warps;
eventTabTriggerWidget = ui->tab_Triggers;
eventTabBGWidget = ui->tab_BGs;
eventTabHealspotWidget = ui->tab_Healspots;
eventTabMultipleWidget = ui->tab_Multiple;
ui->tabWidget_EventType->clear();
}
void MainWindow::initMapSortOrder() {
@ -900,10 +915,73 @@ void MainWindow::addNewEvent(QString event_type)
if (object) {
editor->selectMapEvent(object, false);
}
updateSelectedObjects();
updateObjects();
}
}
void MainWindow::updateObjects() {
selectedObject = nullptr;
selectedWarp = nullptr;
selectedTrigger = nullptr;
selectedBG = nullptr;
selectedHealspot = nullptr;
ui->tabWidget_EventType->clear();
bool hasObjects = false;
bool hasWarps = false;
bool hasTriggers = false;
bool hasBGs = false;
bool hasHealspots = false;
for (DraggablePixmapItem *item : *editor->getObjects())
{
QString event_type = item->event->get("event_type");
if (event_type == EventType::Object) {
hasObjects = true;
}
else if (event_type == EventType::Warp) {
hasWarps = true;
}
else if (event_type == EventType::CoordScript || event_type == EventType::CoordWeather) {
hasTriggers = true;
}
else if (event_type == EventType::Sign || event_type == EventType::HiddenItem || event_type == EventType::SecretBase) {
hasBGs = true;
}
else if (event_type == EventType::HealLocation) {
hasHealspots = true;
}
}
if (hasObjects)
{
ui->tabWidget_EventType->addTab(eventTabObjectWidget, "Objects");
}
if (hasWarps)
{
ui->tabWidget_EventType->addTab(eventTabWarpWidget, "Warps");
}
if (hasTriggers)
{
ui->tabWidget_EventType->addTab(eventTabTriggerWidget, "Triggers");
}
if (hasBGs)
{
ui->tabWidget_EventType->addTab(eventTabBGWidget, "BGs");
}
if (hasHealspots)
{
ui->tabWidget_EventType->addTab(eventTabHealspotWidget, "Healspots");
}
updateSelectedObjects();
}
// Should probably just pass layout and let the editor work it out
void MainWindow::updateSelectedObjects() {
QList<DraggablePixmapItem *> *all_events = editor->getObjects();
@ -955,12 +1033,23 @@ void MainWindow::updateSelectedObjects() {
if (event_type == "event_warp") { event_offs = 0; }
else { event_offs = 1; }
frame->ui->label_name->setText(
QString("%1: %2 %3")
.arg(editor->project->getMap(map_name)->events.value(event_group_type).indexOf(item->event) + event_offs)
QString("%1 %2")
.arg(map_name)
.arg(event_type)
);
if (events->count() == 1)
{
frame->ui->spinBox_index->setValue(editor->project->getMap(map_name)->events.value(event_group_type).indexOf(item->event) + event_offs);
frame->ui->spinBox_index->setMinimum(event_offs);
frame->ui->spinBox_index->setMaximum(editor->project->getMap(map_name)->events.value(event_group_type).length() + event_offs - 1);
connect(frame->ui->spinBox_index, QOverload<int>::of(&QSpinBox::valueChanged), this, &MainWindow::selectedEventIndexChanged);
}
else
{
frame->ui->spinBox_index->setVisible(false);
}
frame->ui->label_spritePixmap->setPixmap(item->event->pixmap);
connect(item, SIGNAL(spriteChanged(QPixmap)), frame->ui->label_spritePixmap, SLOT(setPixmap(QPixmap)));
@ -1142,26 +1231,226 @@ void MainWindow::updateSelectedObjects() {
//int scroll = ui->scrollArea_4->verticalScrollBar()->value();
QWidget *target = ui->scrollAreaWidgetContents;
QScrollArea *scrollTarget = ui->scrollArea_Multiple;
QWidget *target = ui->scrollAreaWidgetContents_Multiple;
if (target->children().length()) {
qDeleteAll(target->children());
isProgrammaticEventTabChange = true;
if (events->length() == 1)
{
QString event_group_type = (*events)[0]->event->get("event_group_type");
if (event_group_type == "object_event_group") {
scrollTarget = ui->scrollArea_Objects;
target = ui->scrollAreaWidgetContents_Objects;
ui->tabWidget_EventType->setCurrentWidget(ui->tab_Objects);
}
else if (event_group_type == "warp_event_group") {
scrollTarget = ui->scrollArea_Warps;
target = ui->scrollAreaWidgetContents_Warps;
ui->tabWidget_EventType->setCurrentWidget(ui->tab_Warps);
}
else if (event_group_type == "coord_event_group") {
scrollTarget = ui->scrollArea_Triggers;
target = ui->scrollAreaWidgetContents_Triggers;
ui->tabWidget_EventType->setCurrentWidget(ui->tab_Triggers);
}
else if (event_group_type == "bg_event_group") {
scrollTarget = ui->scrollArea_BGs;
target = ui->scrollAreaWidgetContents_BGs;
ui->tabWidget_EventType->setCurrentWidget(ui->tab_BGs);
}
else if (event_group_type == "heal_event_group") {
scrollTarget = ui->scrollArea_Healspots;
target = ui->scrollAreaWidgetContents_Healspots;
ui->tabWidget_EventType->setCurrentWidget(ui->tab_Healspots);
}
ui->tabWidget_EventType->removeTab(ui->tabWidget_EventType->indexOf(ui->tab_Multiple));
}
else if (events->length() > 1)
{
ui->tabWidget_EventType->addTab(ui->tab_Multiple, "Multiple");
ui->tabWidget_EventType->setCurrentWidget(ui->tab_Multiple);
}
QVBoxLayout *layout = new QVBoxLayout(target);
target->setLayout(layout);
ui->scrollArea_4->setWidgetResizable(true);
ui->scrollArea_4->setWidget(target);
isProgrammaticEventTabChange = false;
for (EventPropertiesFrame *frame : frames) {
layout->addWidget(frame);
if (events->length() != 0)
{
if (target->children().length())
{
for (QObject *obj : target->children())
{
obj->deleteLater();
}
delete target->layout();
}
QVBoxLayout *layout = new QVBoxLayout(target);
target->setLayout(layout);
scrollTarget->setWidgetResizable(true);
scrollTarget->setWidget(target);
for (EventPropertiesFrame *frame : frames) {
layout->addWidget(frame);
}
layout->addStretch(1);
// doesn't work
//QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
//ui->scrollArea_4->ensureVisible(0, scroll);
ui->label_NoEvents->hide();
ui->tabWidget_EventType->show();
}
else
{
ui->tabWidget_EventType->hide();
ui->label_NoEvents->show();
}
}
QString MainWindow::getEventGroupFromTabWidget(QWidget *tab)
{
QString ret = "";
if (tab == eventTabObjectWidget)
{
ret = "object_event_group";
}
else if (tab == eventTabWarpWidget)
{
ret = "warp_event_group";
}
else if (tab == eventTabTriggerWidget)
{
ret = "coord_event_group";
}
else if (tab == eventTabBGWidget)
{
ret = "bg_event_group";
}
else if (tab == eventTabHealspotWidget)
{
ret = "heal_event_group";
}
return ret;
}
void MainWindow::eventTabChanged(int index)
{
if (!isProgrammaticEventTabChange && editor->map != nullptr)
{
QString group = getEventGroupFromTabWidget(ui->tabWidget_EventType->widget(index));
DraggablePixmapItem *selectedEvent = nullptr;
if (group == "object_event_group")
{
if (selectedObject == nullptr && editor->map->events.value(group).count())
{
Event *event = editor->map->events.value(group).at(0);
for (QGraphicsItem *child : editor->events_group->childItems()) {
DraggablePixmapItem *item = static_cast<DraggablePixmapItem *>(child);
if (item->event == event) {
selectedObject = item;
break;
}
}
}
selectedEvent = selectedObject;
}
else if (group == "warp_event_group")
{
if (selectedWarp == nullptr && editor->map->events.value(group).count())
{
Event *event = editor->map->events.value(group).at(0);
for (QGraphicsItem *child : editor->events_group->childItems()) {
DraggablePixmapItem *item = static_cast<DraggablePixmapItem *>(child);
if (item->event == event) {
selectedWarp = item;
break;
}
}
}
selectedEvent = selectedWarp;
}
else if (group == "coord_event_group")
{
if (selectedTrigger == nullptr && editor->map->events.value(group).count())
{
Event *event = editor->map->events.value(group).at(0);
for (QGraphicsItem *child : editor->events_group->childItems()) {
DraggablePixmapItem *item = static_cast<DraggablePixmapItem *>(child);
if (item->event == event) {
selectedTrigger = item;
break;
}
}
}
selectedEvent = selectedTrigger;
}
else if (group == "bg_event_group")
{
if (selectedBG == nullptr && editor->map->events.value(group).count())
{
Event *event = editor->map->events.value(group).at(0);
for (QGraphicsItem *child : editor->events_group->childItems()) {
DraggablePixmapItem *item = static_cast<DraggablePixmapItem *>(child);
if (item->event == event) {
selectedBG = item;
break;
}
}
}
selectedEvent = selectedBG;
}
else if (group == "heal_event_group")
{
if (selectedHealspot == nullptr && editor->map->events.value(group).count())
{
Event *event = editor->map->events.value(group).at(0);
for (QGraphicsItem *child : editor->events_group->childItems()) {
DraggablePixmapItem *item = static_cast<DraggablePixmapItem *>(child);
if (item->event == event) {
selectedHealspot = item;
break;
}
}
}
selectedEvent = selectedHealspot;
}
if (selectedEvent != nullptr)
editor->selectMapEvent(selectedEvent);
}
layout->addStretch(1);
isProgrammaticEventTabChange = false;
}
// doesn't work
//QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
//ui->scrollArea_4->ensureVisible(0, scroll);
void MainWindow::selectedEventIndexChanged(int index)
{
QString group = getEventGroupFromTabWidget(ui->tabWidget_EventType->currentWidget());
int event_offs;
if (group == "warp_event_group") { event_offs = 0; }
else { event_offs = 1; }
Event *event = editor->map->events.value(group).at(index - event_offs);
DraggablePixmapItem *selectedEvent = nullptr;
for (QGraphicsItem *child : editor->events_group->childItems()) {
DraggablePixmapItem *item = static_cast<DraggablePixmapItem *>(child);
if (item->event == event) {
selectedEvent = item;
break;
}
}
if (selectedEvent != nullptr)
editor->selectMapEvent(selectedEvent);
}
void MainWindow::on_toolButton_deleteObject_clicked()
@ -1169,7 +1458,7 @@ void MainWindow::on_toolButton_deleteObject_clicked()
if (editor && editor->selected_events) {
if (editor->selected_events->length()) {
for (DraggablePixmapItem *item : *editor->selected_events) {
if (item->event->get("event_type") != EventType::HealLocation) {
if (item->event->get("event_group_type") != "heal_event_group") {
editor->deleteEvent(item->event);
if (editor->scene->items().contains(item)) {
editor->scene->removeItem(item);
@ -1180,7 +1469,7 @@ void MainWindow::on_toolButton_deleteObject_clicked()
logWarn(QString("Cannot delete event of type '%1'").arg(item->event->get("event_type")));
}
}
updateSelectedObjects();
updateObjects();
}
}
}