diff --git a/include/ui/eventpropertiesframe.h b/include/ui/eventpropertiesframe.h index 49add45b..7e526ab7 100644 --- a/include/ui/eventpropertiesframe.h +++ b/include/ui/eventpropertiesframe.h @@ -1,6 +1,8 @@ #ifndef EVENTPROPERTIESFRAME_H #define EVENTPROPERTIESFRAME_H +#include "event.h" + #include namespace Ui { @@ -12,11 +14,16 @@ class EventPropertiesFrame : public QFrame Q_OBJECT public: - explicit EventPropertiesFrame(QWidget *parent = nullptr); + explicit EventPropertiesFrame(Event *event, QWidget *parent = nullptr); ~EventPropertiesFrame(); + void paintEvent(QPaintEvent*); public: Ui::EventPropertiesFrame *ui; + +private: + Event *event; + bool firstShow = true; }; #endif // EVENTPROPERTIESFRAME_H diff --git a/include/ui/mappixmapitem.h b/include/ui/mappixmapitem.h index 1443785d..e0111eb0 100644 --- a/include/ui/mappixmapitem.h +++ b/include/ui/mappixmapitem.h @@ -51,8 +51,6 @@ private: void paintSmartPath(int x, int y); static QList smartPathTable; - void paint_object(QGraphicsSceneMouseEvent*);// ? - signals: void startPaint(QGraphicsSceneMouseEvent *, MapPixmapItem *); void endPaint(QGraphicsSceneMouseEvent *, MapPixmapItem *); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1cdc8df0..5408452a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -8,7 +8,6 @@ #include "ui_eventpropertiesframe.h" #include "bordermetatilespixmapitem.h" #include "currentselectedmetatilespixmapitem.h" -#include "customattributestable.h" #include #include @@ -80,12 +79,12 @@ void MainWindow::initExtraShortcuts() { void MainWindow::initCustomUI() { // Set up the tab bar - ui->mainTabBar->addTab("Map"); // add the icon + ui->mainTabBar->addTab("Map"); ui->mainTabBar->setTabIcon(0, QIcon(QStringLiteral(":/icons/map.ico"))); ui->mainTabBar->addTab("Events"); ui->mainTabBar->addTab("Header"); ui->mainTabBar->addTab("Connections"); - ui->mainTabBar->addTab("Wild Pokemon"); // add the icon + ui->mainTabBar->addTab("Wild Pokemon"); ui->mainTabBar->setTabIcon(4, QIcon(QStringLiteral(":/icons/tall_grass.ico"))); // Right-clicking on items in the map list tree view brings up a context menu. @@ -455,7 +454,7 @@ void MainWindow::redrawMapScene() if (!editor->displayMap()) return; - on_mainTabBar_tabBarClicked(ui->mainStackedWidget->currentIndex()); + on_mainTabBar_tabBarClicked(ui->mainTabBar->currentIndex()); double base = editor->scale_base; double exp = editor->scale_exp; @@ -1440,7 +1439,7 @@ void MainWindow::updateSelectedObjects() { bool pokefirered = projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered; for (DraggablePixmapItem *item : *events) { - EventPropertiesFrame *frame = new EventPropertiesFrame; + EventPropertiesFrame *frame = new EventPropertiesFrame(item->event); // frame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); QSpinBox *x = frame->ui->spinBox_x; @@ -1746,13 +1745,6 @@ void MainWindow::updateSelectedObjects() { item->bind(combo, key); } } - - // Custom fields table. - if (event_type != EventType::HealLocation) { - CustomAttributesTable *customAttributes = new CustomAttributesTable(item->event, frame); - frame->layout()->addWidget(customAttributes); - } - frames.append(frame); } @@ -2054,7 +2046,7 @@ void MainWindow::on_toolButton_Paint_clicked() void MainWindow::on_toolButton_Select_clicked() { editor->map_edit_mode = "select"; - editor->settings->mapCursor = QCursor();//QPixmap(":/icons/cursor.ico"), 0, 0); + editor->settings->mapCursor = QCursor(); editor->cursorMapTileRect->setSingleTileMode(); ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); diff --git a/src/ui/eventpropertiesframe.cpp b/src/ui/eventpropertiesframe.cpp index f340be50..d4ea2ac8 100644 --- a/src/ui/eventpropertiesframe.cpp +++ b/src/ui/eventpropertiesframe.cpp @@ -1,14 +1,28 @@ #include "eventpropertiesframe.h" +#include "customattributestable.h" + #include "ui_eventpropertiesframe.h" -EventPropertiesFrame::EventPropertiesFrame(QWidget *parent) : +EventPropertiesFrame::EventPropertiesFrame(Event *event, QWidget *parent) : QFrame(parent), ui(new Ui::EventPropertiesFrame) { ui->setupUi(this); + this->event = event; + this->firstShow = true; } EventPropertiesFrame::~EventPropertiesFrame() { delete ui; } + +void EventPropertiesFrame::paintEvent(QPaintEvent *painter) { + // Custom fields table. + if (firstShow && event->get("event_type") != EventType::HealLocation) { + CustomAttributesTable *customAttributes = new CustomAttributesTable(event, this); + this->layout()->addWidget(customAttributes); + } + QFrame::paintEvent(painter); + firstShow = false; +}