Fix event group tab selection
This commit is contained in:
parent
a0069b6a3f
commit
0b2a526e3d
4 changed files with 11 additions and 46 deletions
|
@ -12,6 +12,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
|
||||||
- Metatile ID strings are now padded to their current max, not the overall max.
|
- Metatile ID strings are now padded to their current max, not the overall max.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Fix the event group tabs sometimes showing an event from the wrong group
|
||||||
- Fix API error reporting
|
- Fix API error reporting
|
||||||
|
|
||||||
## [5.2.0] - 2024-01-02
|
## [5.2.0] - 2024-01-02
|
||||||
|
|
|
@ -325,12 +325,7 @@ private:
|
||||||
QWidget *eventTabBGWidget;
|
QWidget *eventTabBGWidget;
|
||||||
QWidget *eventTabHealspotWidget;
|
QWidget *eventTabHealspotWidget;
|
||||||
QWidget *eventTabMultipleWidget;
|
QWidget *eventTabMultipleWidget;
|
||||||
|
QMap<Event::Group, DraggablePixmapItem*> lastSelectedEvent;
|
||||||
DraggablePixmapItem *selectedObject;
|
|
||||||
DraggablePixmapItem *selectedWarp;
|
|
||||||
DraggablePixmapItem *selectedTrigger;
|
|
||||||
DraggablePixmapItem *selectedBG;
|
|
||||||
DraggablePixmapItem *selectedHealspot;
|
|
||||||
|
|
||||||
bool isProgrammaticEventTabChange;
|
bool isProgrammaticEventTabChange;
|
||||||
bool projectHasUnsavedChanges;
|
bool projectHasUnsavedChanges;
|
||||||
|
|
|
@ -106,7 +106,7 @@ uint32_t Metatile::getMaxAttributesMask() {
|
||||||
void Metatile::setLayout(Project * project) {
|
void Metatile::setLayout(Project * project) {
|
||||||
// Calculate the number of hex characters needed to display a metatile ID.
|
// Calculate the number of hex characters needed to display a metatile ID.
|
||||||
numMetatileIdChars = 0;
|
numMetatileIdChars = 0;
|
||||||
for (uint16_t i = Block::getMaxMetatileId(); i > 1; i /= 0xF)
|
for (uint16_t i = Block::getMaxMetatileId(); i > 0; i /= 16)
|
||||||
numMetatileIdChars++;
|
numMetatileIdChars++;
|
||||||
|
|
||||||
uint32_t behaviorMask = projectConfig.getMetatileBehaviorMask();
|
uint32_t behaviorMask = projectConfig.getMetatileBehaviorMask();
|
||||||
|
|
|
@ -49,11 +49,6 @@ using OrderedJsonDoc = poryjson::JsonDoc;
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow),
|
ui(new Ui::MainWindow),
|
||||||
selectedObject(nullptr),
|
|
||||||
selectedWarp(nullptr),
|
|
||||||
selectedTrigger(nullptr),
|
|
||||||
selectedBG(nullptr),
|
|
||||||
selectedHealspot(nullptr),
|
|
||||||
isProgrammaticEventTabChange(false)
|
isProgrammaticEventTabChange(false)
|
||||||
{
|
{
|
||||||
QCoreApplication::setOrganizationName("pret");
|
QCoreApplication::setOrganizationName("pret");
|
||||||
|
@ -694,6 +689,7 @@ bool MainWindow::setMap(QString map_name, bool scrollTreeView) {
|
||||||
ui->mapList->setExpanded(mapListProxyModel->mapFromSource(mapListIndexes.value(editor->map->name)), false);
|
ui->mapList->setExpanded(mapListProxyModel->mapFromSource(mapListIndexes.value(editor->map->name)), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->lastSelectedEvent.clear();
|
||||||
refreshMapScene();
|
refreshMapScene();
|
||||||
displayMapProperties();
|
displayMapProperties();
|
||||||
|
|
||||||
|
@ -1929,24 +1925,11 @@ void MainWindow::displayEventTabs() {
|
||||||
|
|
||||||
void MainWindow::updateObjects() {
|
void MainWindow::updateObjects() {
|
||||||
QList<DraggablePixmapItem *> all_objects = editor->getObjects();
|
QList<DraggablePixmapItem *> all_objects = editor->getObjects();
|
||||||
if (selectedObject && !all_objects.contains(selectedObject)) {
|
for (auto i = this->lastSelectedEvent.cbegin(), end = this->lastSelectedEvent.cend(); i != end; i++) {
|
||||||
selectedObject = nullptr;
|
if (i.value() && !all_objects.contains(i.value()))
|
||||||
|
this->lastSelectedEvent.insert(i.key(), nullptr);
|
||||||
}
|
}
|
||||||
if (selectedWarp && !all_objects.contains(selectedWarp)) {
|
|
||||||
selectedWarp = nullptr;
|
|
||||||
}
|
|
||||||
if (selectedTrigger && !all_objects.contains(selectedTrigger)) {
|
|
||||||
selectedTrigger = nullptr;
|
|
||||||
}
|
|
||||||
if (selectedBG && !all_objects.contains(selectedBG)) {
|
|
||||||
selectedBG = nullptr;
|
|
||||||
}
|
|
||||||
if (selectedHealspot && !all_objects.contains(selectedHealspot)) {
|
|
||||||
selectedHealspot = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
displayEventTabs();
|
displayEventTabs();
|
||||||
|
|
||||||
updateSelectedObjects();
|
updateSelectedObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1983,14 +1966,15 @@ void MainWindow::updateSelectedObjects() {
|
||||||
Event::Group eventGroup = current->getEventGroup();
|
Event::Group eventGroup = current->getEventGroup();
|
||||||
int event_offs = Event::getIndexOffset(eventGroup);
|
int event_offs = Event::getIndexOffset(eventGroup);
|
||||||
|
|
||||||
|
if (eventGroup != Event::Group::None)
|
||||||
|
this->lastSelectedEvent.insert(eventGroup, current->getPixmapItem());
|
||||||
|
|
||||||
switch (eventGroup) {
|
switch (eventGroup) {
|
||||||
case Event::Group::Object: {
|
case Event::Group::Object: {
|
||||||
scrollTarget = ui->scrollArea_Objects;
|
scrollTarget = ui->scrollArea_Objects;
|
||||||
target = ui->scrollAreaWidgetContents_Objects;
|
target = ui->scrollAreaWidgetContents_Objects;
|
||||||
ui->tabWidget_EventType->setCurrentWidget(ui->tab_Objects);
|
ui->tabWidget_EventType->setCurrentWidget(ui->tab_Objects);
|
||||||
|
|
||||||
selectedObject = current->getPixmapItem();
|
|
||||||
|
|
||||||
QSignalBlocker b(this->ui->spinner_ObjectID);
|
QSignalBlocker b(this->ui->spinner_ObjectID);
|
||||||
this->ui->spinner_ObjectID->setMinimum(event_offs);
|
this->ui->spinner_ObjectID->setMinimum(event_offs);
|
||||||
this->ui->spinner_ObjectID->setMaximum(current->getMap()->events.value(eventGroup).length() + event_offs - 1);
|
this->ui->spinner_ObjectID->setMaximum(current->getMap()->events.value(eventGroup).length() + event_offs - 1);
|
||||||
|
@ -2002,8 +1986,6 @@ void MainWindow::updateSelectedObjects() {
|
||||||
target = ui->scrollAreaWidgetContents_Warps;
|
target = ui->scrollAreaWidgetContents_Warps;
|
||||||
ui->tabWidget_EventType->setCurrentWidget(ui->tab_Warps);
|
ui->tabWidget_EventType->setCurrentWidget(ui->tab_Warps);
|
||||||
|
|
||||||
selectedWarp = current->getPixmapItem();
|
|
||||||
|
|
||||||
QSignalBlocker b(this->ui->spinner_WarpID);
|
QSignalBlocker b(this->ui->spinner_WarpID);
|
||||||
this->ui->spinner_WarpID->setMinimum(event_offs);
|
this->ui->spinner_WarpID->setMinimum(event_offs);
|
||||||
this->ui->spinner_WarpID->setMaximum(current->getMap()->events.value(eventGroup).length() + event_offs - 1);
|
this->ui->spinner_WarpID->setMaximum(current->getMap()->events.value(eventGroup).length() + event_offs - 1);
|
||||||
|
@ -2015,8 +1997,6 @@ void MainWindow::updateSelectedObjects() {
|
||||||
target = ui->scrollAreaWidgetContents_Triggers;
|
target = ui->scrollAreaWidgetContents_Triggers;
|
||||||
ui->tabWidget_EventType->setCurrentWidget(ui->tab_Triggers);
|
ui->tabWidget_EventType->setCurrentWidget(ui->tab_Triggers);
|
||||||
|
|
||||||
selectedTrigger = current->getPixmapItem();
|
|
||||||
|
|
||||||
QSignalBlocker b(this->ui->spinner_TriggerID);
|
QSignalBlocker b(this->ui->spinner_TriggerID);
|
||||||
this->ui->spinner_TriggerID->setMinimum(event_offs);
|
this->ui->spinner_TriggerID->setMinimum(event_offs);
|
||||||
this->ui->spinner_TriggerID->setMaximum(current->getMap()->events.value(eventGroup).length() + event_offs - 1);
|
this->ui->spinner_TriggerID->setMaximum(current->getMap()->events.value(eventGroup).length() + event_offs - 1);
|
||||||
|
@ -2028,8 +2008,6 @@ void MainWindow::updateSelectedObjects() {
|
||||||
target = ui->scrollAreaWidgetContents_BGs;
|
target = ui->scrollAreaWidgetContents_BGs;
|
||||||
ui->tabWidget_EventType->setCurrentWidget(ui->tab_BGs);
|
ui->tabWidget_EventType->setCurrentWidget(ui->tab_BGs);
|
||||||
|
|
||||||
selectedBG = current->getPixmapItem();
|
|
||||||
|
|
||||||
QSignalBlocker b(this->ui->spinner_BgID);
|
QSignalBlocker b(this->ui->spinner_BgID);
|
||||||
this->ui->spinner_BgID->setMinimum(event_offs);
|
this->ui->spinner_BgID->setMinimum(event_offs);
|
||||||
this->ui->spinner_BgID->setMaximum(current->getMap()->events.value(eventGroup).length() + event_offs - 1);
|
this->ui->spinner_BgID->setMaximum(current->getMap()->events.value(eventGroup).length() + event_offs - 1);
|
||||||
|
@ -2041,8 +2019,6 @@ void MainWindow::updateSelectedObjects() {
|
||||||
target = ui->scrollAreaWidgetContents_Healspots;
|
target = ui->scrollAreaWidgetContents_Healspots;
|
||||||
ui->tabWidget_EventType->setCurrentWidget(ui->tab_Healspots);
|
ui->tabWidget_EventType->setCurrentWidget(ui->tab_Healspots);
|
||||||
|
|
||||||
selectedHealspot = current->getPixmapItem();
|
|
||||||
|
|
||||||
QSignalBlocker b(this->ui->spinner_HealID);
|
QSignalBlocker b(this->ui->spinner_HealID);
|
||||||
this->ui->spinner_HealID->setMinimum(event_offs);
|
this->ui->spinner_HealID->setMinimum(event_offs);
|
||||||
this->ui->spinner_HealID->setMaximum(current->getMap()->events.value(eventGroup).length() + event_offs - 1);
|
this->ui->spinner_HealID->setMaximum(current->getMap()->events.value(eventGroup).length() + event_offs - 1);
|
||||||
|
@ -2133,28 +2109,21 @@ Event::Group MainWindow::getEventGroupFromTabWidget(QWidget *tab)
|
||||||
void MainWindow::eventTabChanged(int index) {
|
void MainWindow::eventTabChanged(int index) {
|
||||||
if (editor->map) {
|
if (editor->map) {
|
||||||
Event::Group group = getEventGroupFromTabWidget(ui->tabWidget_EventType->widget(index));
|
Event::Group group = getEventGroupFromTabWidget(ui->tabWidget_EventType->widget(index));
|
||||||
DraggablePixmapItem *selectedEvent = nullptr;
|
DraggablePixmapItem *selectedEvent = this->lastSelectedEvent.value(group, nullptr);
|
||||||
|
|
||||||
switch (group) {
|
switch (group) {
|
||||||
case Event::Group::Object:
|
case Event::Group::Object:
|
||||||
selectedEvent = selectedObject;
|
|
||||||
ui->newEventToolButton->setDefaultAction(ui->newEventToolButton->newObjectAction);
|
ui->newEventToolButton->setDefaultAction(ui->newEventToolButton->newObjectAction);
|
||||||
break;
|
break;
|
||||||
case Event::Group::Warp:
|
case Event::Group::Warp:
|
||||||
selectedEvent = selectedWarp;
|
|
||||||
ui->newEventToolButton->setDefaultAction(ui->newEventToolButton->newWarpAction);
|
ui->newEventToolButton->setDefaultAction(ui->newEventToolButton->newWarpAction);
|
||||||
break;
|
break;
|
||||||
case Event::Group::Coord:
|
case Event::Group::Coord:
|
||||||
selectedEvent = selectedTrigger;
|
|
||||||
ui->newEventToolButton->setDefaultAction(ui->newEventToolButton->newTriggerAction);
|
ui->newEventToolButton->setDefaultAction(ui->newEventToolButton->newTriggerAction);
|
||||||
break;
|
break;
|
||||||
case Event::Group::Bg:
|
case Event::Group::Bg:
|
||||||
selectedEvent = selectedBG;
|
|
||||||
ui->newEventToolButton->setDefaultAction(ui->newEventToolButton->newSignAction);
|
ui->newEventToolButton->setDefaultAction(ui->newEventToolButton->newSignAction);
|
||||||
break;
|
break;
|
||||||
case Event::Group::Heal:
|
|
||||||
selectedEvent = selectedHealspot;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue