Add 'All' settings, avoid unnecessary work in a few places
This commit is contained in:
parent
354680d125
commit
6e79c6c4c3
3 changed files with 160 additions and 81 deletions
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>817</width>
|
<width>817</width>
|
||||||
<height>518</height>
|
<height>535</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -52,7 +52,28 @@
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_Event_Options">
|
<layout class="QGridLayout" name="gridLayout_Event_Options">
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QCheckBox" name="checkBox_Triggers">
|
||||||
|
<property name="text">
|
||||||
|
<string>Triggers</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
|
<widget class="QCheckBox" name="checkBox_Objects">
|
||||||
|
<property name="text">
|
||||||
|
<string>Objects</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QCheckBox" name="checkBox_HealLocations">
|
||||||
|
<property name="text">
|
||||||
|
<string>Heal Locations</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
<widget class="QCheckBox" name="checkBox_Warps">
|
<widget class="QCheckBox" name="checkBox_Warps">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Warps</string>
|
<string>Warps</string>
|
||||||
|
@ -60,30 +81,16 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QCheckBox" name="checkBox_Objects">
|
<widget class="QCheckBox" name="checkBox_AllEvents">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Objects</string>
|
<string>All</string>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QCheckBox" name="checkBox_BGs">
|
|
||||||
<property name="text">
|
|
||||||
<string>BGs</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QCheckBox" name="checkBox_Triggers">
|
<widget class="QCheckBox" name="checkBox_BGs">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Triggers</string>
|
<string>BGs</string>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QCheckBox" name="checkBox_HealSpots">
|
|
||||||
<property name="text">
|
|
||||||
<string>Heal Spots</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -100,34 +107,41 @@
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_Connection_Options">
|
<layout class="QGridLayout" name="gridLayout_Connection_Options">
|
||||||
<item row="0" column="0">
|
<item row="1" column="2">
|
||||||
<widget class="QCheckBox" name="checkBox_ConnectionUp">
|
|
||||||
<property name="text">
|
|
||||||
<string>Up</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QCheckBox" name="checkBox_ConnectionDown">
|
|
||||||
<property name="text">
|
|
||||||
<string>Down</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QCheckBox" name="checkBox_ConnectionLeft">
|
<widget class="QCheckBox" name="checkBox_ConnectionLeft">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Left</string>
|
<string>Left</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
<item row="1" column="0">
|
||||||
|
<widget class="QCheckBox" name="checkBox_ConnectionUp">
|
||||||
|
<property name="text">
|
||||||
|
<string>Up</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3">
|
||||||
<widget class="QCheckBox" name="checkBox_ConnectionRight">
|
<widget class="QCheckBox" name="checkBox_ConnectionRight">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Right</string>
|
<string>Right</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QCheckBox" name="checkBox_ConnectionDown">
|
||||||
|
<property name="text">
|
||||||
|
<string>Down</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QCheckBox" name="checkBox_AllConnections">
|
||||||
|
<property name="text">
|
||||||
|
<string>All</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -317,8 +331,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>500</width>
|
<width>469</width>
|
||||||
<height>439</height>
|
<height>464</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
|
|
@ -37,7 +37,7 @@ private:
|
||||||
bool showWarps = false;
|
bool showWarps = false;
|
||||||
bool showBGs = false;
|
bool showBGs = false;
|
||||||
bool showTriggers = false;
|
bool showTriggers = false;
|
||||||
bool showHealSpots = false;
|
bool showHealLocations = false;
|
||||||
bool showUpConnections = false;
|
bool showUpConnections = false;
|
||||||
bool showDownConnections = false;
|
bool showDownConnections = false;
|
||||||
bool showLeftConnections = false;
|
bool showLeftConnections = false;
|
||||||
|
@ -67,20 +67,20 @@ private slots:
|
||||||
void on_checkBox_Warps_stateChanged(int state);
|
void on_checkBox_Warps_stateChanged(int state);
|
||||||
void on_checkBox_BGs_stateChanged(int state);
|
void on_checkBox_BGs_stateChanged(int state);
|
||||||
void on_checkBox_Triggers_stateChanged(int state);
|
void on_checkBox_Triggers_stateChanged(int state);
|
||||||
void on_checkBox_HealSpots_stateChanged(int state);
|
void on_checkBox_HealLocations_stateChanged(int state);
|
||||||
|
void on_checkBox_AllEvents_stateChanged(int state);
|
||||||
|
|
||||||
void on_checkBox_ConnectionUp_stateChanged(int state);
|
void on_checkBox_ConnectionUp_stateChanged(int state);
|
||||||
void on_checkBox_ConnectionDown_stateChanged(int state);
|
void on_checkBox_ConnectionDown_stateChanged(int state);
|
||||||
void on_checkBox_ConnectionLeft_stateChanged(int state);
|
void on_checkBox_ConnectionLeft_stateChanged(int state);
|
||||||
void on_checkBox_ConnectionRight_stateChanged(int state);
|
void on_checkBox_ConnectionRight_stateChanged(int state);
|
||||||
|
void on_checkBox_AllConnections_stateChanged(int state);
|
||||||
|
|
||||||
void on_checkBox_Elevation_stateChanged(int state);
|
void on_checkBox_Elevation_stateChanged(int state);
|
||||||
void on_checkBox_Grid_stateChanged(int state);
|
void on_checkBox_Grid_stateChanged(int state);
|
||||||
void on_checkBox_Border_stateChanged(int state);
|
void on_checkBox_Border_stateChanged(int state);
|
||||||
|
|
||||||
void on_pushButton_Save_pressed();
|
|
||||||
void on_pushButton_Reset_pressed();
|
void on_pushButton_Reset_pressed();
|
||||||
void on_pushButton_Cancel_pressed();
|
|
||||||
void on_spinBox_TimelapseDelay_valueChanged(int delayMs);
|
void on_spinBox_TimelapseDelay_valueChanged(int delayMs);
|
||||||
void on_spinBox_FrameSkip_valueChanged(int skip);
|
void on_spinBox_FrameSkip_valueChanged(int skip);
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,9 @@ MapImageExporter::MapImageExporter(QWidget *parent_, Editor *editor_, ImageExpor
|
||||||
this->ui->comboBox_MapSelection->addItems(editor->project->mapNames);
|
this->ui->comboBox_MapSelection->addItems(editor->project->mapNames);
|
||||||
this->ui->comboBox_MapSelection->setCurrentText(map->name);
|
this->ui->comboBox_MapSelection->setCurrentText(map->name);
|
||||||
this->ui->comboBox_MapSelection->setEnabled(false);// TODO: allow selecting map from drop-down
|
this->ui->comboBox_MapSelection->setEnabled(false);// TODO: allow selecting map from drop-down
|
||||||
|
|
||||||
|
connect(ui->pushButton_Save, &QPushButton::pressed, this, &MapImageExporter::saveImage);
|
||||||
|
connect(ui->pushButton_Cancel, &QPushButton::pressed, this, &MapImageExporter::close);
|
||||||
}
|
}
|
||||||
|
|
||||||
MapImageExporter::~MapImageExporter() {
|
MapImageExporter::~MapImageExporter() {
|
||||||
|
@ -73,6 +76,12 @@ void MapImageExporter::resizeEvent(QResizeEvent *event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapImageExporter::saveImage() {
|
void MapImageExporter::saveImage() {
|
||||||
|
// Make sure preview is up-to-date before we save.
|
||||||
|
if (this->preview.isNull())
|
||||||
|
updatePreview();
|
||||||
|
if (this->preview.isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
QString title = getTitle(this->mode);
|
QString title = getTitle(this->mode);
|
||||||
QString defaultFilename;
|
QString defaultFilename;
|
||||||
switch (this->mode)
|
switch (this->mode)
|
||||||
|
@ -223,7 +232,7 @@ bool MapImageExporter::historyItemAppliesToFrame(const QUndoCommand *command) {
|
||||||
|| (this->showWarps && (command->id() & IDMask_EventType_Warp) != 0)
|
|| (this->showWarps && (command->id() & IDMask_EventType_Warp) != 0)
|
||||||
|| (this->showBGs && (command->id() & IDMask_EventType_BG) != 0)
|
|| (this->showBGs && (command->id() & IDMask_EventType_BG) != 0)
|
||||||
|| (this->showTriggers && (command->id() & IDMask_EventType_Trigger) != 0)
|
|| (this->showTriggers && (command->id() & IDMask_EventType_Trigger) != 0)
|
||||||
|| (this->showHealSpots && (command->id() & IDMask_EventType_Heal) != 0);
|
|| (this->showHealLocations && (command->id() & IDMask_EventType_Heal) != 0);
|
||||||
return eventTypeIsApplicable;
|
return eventTypeIsApplicable;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -435,6 +444,7 @@ QPixmap MapImageExporter::getFormattedMapPixmap(Map *map, bool ignoreBorder) {
|
||||||
if (!ignoreBorder && (this->showUpConnections || this->showDownConnections || this->showLeftConnections || this->showRightConnections)) {
|
if (!ignoreBorder && (this->showUpConnections || this->showDownConnections || this->showLeftConnections || this->showRightConnections)) {
|
||||||
// if showing connections, draw on outside of image
|
// if showing connections, draw on outside of image
|
||||||
QPainter connectionPainter(&pixmap);
|
QPainter connectionPainter(&pixmap);
|
||||||
|
// TODO: Reading the connections from the editor and not 'map' is incorrect.
|
||||||
for (auto connectionItem : editor->connection_items) {
|
for (auto connectionItem : editor->connection_items) {
|
||||||
const QString direction = connectionItem->connection->direction();
|
const QString direction = connectionItem->connection->direction();
|
||||||
if ((showUpConnections && direction == "up")
|
if ((showUpConnections && direction == "up")
|
||||||
|
@ -448,27 +458,30 @@ QPixmap MapImageExporter::getFormattedMapPixmap(Map *map, bool ignoreBorder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw events
|
// draw events
|
||||||
|
if (this->showObjects || this->showWarps || this->showBGs || this->showTriggers || this->showHealLocations) {
|
||||||
QPainter eventPainter(&pixmap);
|
QPainter eventPainter(&pixmap);
|
||||||
QList<Event *> events = map->getAllEvents();
|
|
||||||
int pixelOffset = 0;
|
int pixelOffset = 0;
|
||||||
if (!ignoreBorder && this->showBorder) {
|
if (!ignoreBorder && this->showBorder) {
|
||||||
pixelOffset = this->mode == ImageExporterMode::Normal ? BORDER_DISTANCE * 16 : STITCH_MODE_BORDER_DISTANCE * 16;
|
pixelOffset = this->mode == ImageExporterMode::Normal ? BORDER_DISTANCE * 16 : STITCH_MODE_BORDER_DISTANCE * 16;
|
||||||
}
|
}
|
||||||
for (Event *event : events) {
|
const QList<Event *> events = map->getAllEvents();
|
||||||
editor->project->setEventPixmap(event);
|
for (const auto &event : events) {
|
||||||
Event::Group group = event->getEventGroup();
|
Event::Group group = event->getEventGroup();
|
||||||
if ((showObjects && group == Event::Group::Object)
|
if ((this->showObjects && group == Event::Group::Object)
|
||||||
|| (showWarps && group == Event::Group::Warp)
|
|| (this->showWarps && group == Event::Group::Warp)
|
||||||
|| (showBGs && group == Event::Group::Bg)
|
|| (this->showBGs && group == Event::Group::Bg)
|
||||||
|| (showTriggers && group == Event::Group::Coord)
|
|| (this->showTriggers && group == Event::Group::Coord)
|
||||||
|| (showHealSpots && group == Event::Group::Heal))
|
|| (this->showHealLocations && group == Event::Group::Heal)) {
|
||||||
|
editor->project->setEventPixmap(event);
|
||||||
eventPainter.drawImage(QPoint(event->getPixelX() + pixelOffset, event->getPixelY() + pixelOffset), event->getPixmap().toImage());
|
eventPainter.drawImage(QPoint(event->getPixelX() + pixelOffset, event->getPixelY() + pixelOffset), event->getPixmap().toImage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
eventPainter.end();
|
eventPainter.end();
|
||||||
|
}
|
||||||
|
|
||||||
// draw grid directly onto the pixmap
|
// draw grid directly onto the pixmap
|
||||||
// since the last grid lines are outside of the pixmap, add a pixel to the bottom and right
|
// since the last grid lines are outside of the pixmap, add a pixel to the bottom and right
|
||||||
if (showGrid) {
|
if (this->showGrid) {
|
||||||
int addX = 1, addY = 1;
|
int addX = 1, addY = 1;
|
||||||
if (borderHeight) addY = 0;
|
if (borderHeight) addY = 0;
|
||||||
if (borderWidth) addX = 0;
|
if (borderWidth) addX = 0;
|
||||||
|
@ -491,14 +504,11 @@ QPixmap MapImageExporter::getFormattedMapPixmap(Map *map, bool ignoreBorder) {
|
||||||
|
|
||||||
void MapImageExporter::updateShowBorderState() {
|
void MapImageExporter::updateShowBorderState() {
|
||||||
// If any of the Connections settings are enabled then this setting is locked (it's implicitly enabled)
|
// If any of the Connections settings are enabled then this setting is locked (it's implicitly enabled)
|
||||||
|
bool on = (showUpConnections || showDownConnections || showLeftConnections || showRightConnections);
|
||||||
const QSignalBlocker blocker(ui->checkBox_Border);
|
const QSignalBlocker blocker(ui->checkBox_Border);
|
||||||
if (showUpConnections || showDownConnections || showLeftConnections || showRightConnections) {
|
ui->checkBox_Border->setChecked(on);
|
||||||
ui->checkBox_Border->setChecked(true);
|
ui->checkBox_Border->setDisabled(on);
|
||||||
ui->checkBox_Border->setDisabled(true);
|
showBorder = on;
|
||||||
showBorder = true;
|
|
||||||
} else {
|
|
||||||
ui->checkBox_Border->setDisabled(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapImageExporter::on_checkBox_Elevation_stateChanged(int state) {
|
void MapImageExporter::on_checkBox_Elevation_stateChanged(int state) {
|
||||||
|
@ -536,8 +546,40 @@ void MapImageExporter::on_checkBox_Triggers_stateChanged(int state) {
|
||||||
updatePreview();
|
updatePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapImageExporter::on_checkBox_HealSpots_stateChanged(int state) {
|
void MapImageExporter::on_checkBox_HealLocations_stateChanged(int state) {
|
||||||
showHealSpots = (state == Qt::Checked);
|
showHealLocations = (state == Qt::Checked);
|
||||||
|
updatePreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shortcut setting for enabling all events
|
||||||
|
void MapImageExporter::on_checkBox_AllEvents_stateChanged(int state) {
|
||||||
|
bool on = (state == Qt::Checked);
|
||||||
|
|
||||||
|
const QSignalBlocker b_Objects(ui->checkBox_Objects);
|
||||||
|
ui->checkBox_Objects->setChecked(on);
|
||||||
|
ui->checkBox_Objects->setDisabled(on);
|
||||||
|
showObjects = on;
|
||||||
|
|
||||||
|
const QSignalBlocker b_Warps(ui->checkBox_Warps);
|
||||||
|
ui->checkBox_Warps->setChecked(on);
|
||||||
|
ui->checkBox_Warps->setDisabled(on);
|
||||||
|
showWarps = on;
|
||||||
|
|
||||||
|
const QSignalBlocker b_BGs(ui->checkBox_BGs);
|
||||||
|
ui->checkBox_BGs->setChecked(on);
|
||||||
|
ui->checkBox_BGs->setDisabled(on);
|
||||||
|
showBGs = on;
|
||||||
|
|
||||||
|
const QSignalBlocker b_Triggers(ui->checkBox_Triggers);
|
||||||
|
ui->checkBox_Triggers->setChecked(on);
|
||||||
|
ui->checkBox_Triggers->setDisabled(on);
|
||||||
|
showTriggers = on;
|
||||||
|
|
||||||
|
const QSignalBlocker b_HealLocations(ui->checkBox_HealLocations);
|
||||||
|
ui->checkBox_HealLocations->setChecked(on);
|
||||||
|
ui->checkBox_HealLocations->setDisabled(on);
|
||||||
|
showHealLocations = on;
|
||||||
|
|
||||||
updatePreview();
|
updatePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,6 +607,34 @@ void MapImageExporter::on_checkBox_ConnectionRight_stateChanged(int state) {
|
||||||
updatePreview();
|
updatePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Shortcut setting for enabling all connection directions
|
||||||
|
void MapImageExporter::on_checkBox_AllConnections_stateChanged(int state) {
|
||||||
|
bool on = (state == Qt::Checked);
|
||||||
|
|
||||||
|
const QSignalBlocker b_Up(ui->checkBox_ConnectionUp);
|
||||||
|
ui->checkBox_ConnectionUp->setChecked(on);
|
||||||
|
ui->checkBox_ConnectionUp->setDisabled(on);
|
||||||
|
showUpConnections = on;
|
||||||
|
|
||||||
|
const QSignalBlocker b_Down(ui->checkBox_ConnectionDown);
|
||||||
|
ui->checkBox_ConnectionDown->setChecked(on);
|
||||||
|
ui->checkBox_ConnectionDown->setDisabled(on);
|
||||||
|
showDownConnections = on;
|
||||||
|
|
||||||
|
const QSignalBlocker b_Left(ui->checkBox_ConnectionLeft);
|
||||||
|
ui->checkBox_ConnectionLeft->setChecked(on);
|
||||||
|
ui->checkBox_ConnectionLeft->setDisabled(on);
|
||||||
|
showLeftConnections = on;
|
||||||
|
|
||||||
|
const QSignalBlocker b_Right(ui->checkBox_ConnectionRight);
|
||||||
|
ui->checkBox_ConnectionRight->setChecked(on);
|
||||||
|
ui->checkBox_ConnectionRight->setDisabled(on);
|
||||||
|
showRightConnections = on;
|
||||||
|
|
||||||
|
updateShowBorderState();
|
||||||
|
updatePreview();
|
||||||
|
}
|
||||||
|
|
||||||
void MapImageExporter::on_checkBox_ActualSize_stateChanged(int state) {
|
void MapImageExporter::on_checkBox_ActualSize_stateChanged(int state) {
|
||||||
previewActualSize = (state == Qt::Checked);
|
previewActualSize = (state == Qt::Checked);
|
||||||
if (previewActualSize) {
|
if (previewActualSize) {
|
||||||
|
@ -574,17 +644,12 @@ void MapImageExporter::on_checkBox_ActualSize_stateChanged(int state) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapImageExporter::on_pushButton_Save_pressed() {
|
|
||||||
saveImage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MapImageExporter::on_pushButton_Reset_pressed() {
|
void MapImageExporter::on_pushButton_Reset_pressed() {
|
||||||
for (auto widget : this->findChildren<QCheckBox *>())
|
for (auto widget : this->findChildren<QCheckBox *>()) {
|
||||||
|
const QSignalBlocker b(widget);
|
||||||
widget->setChecked(false);
|
widget->setChecked(false);
|
||||||
}
|
}
|
||||||
|
updatePreview();
|
||||||
void MapImageExporter::on_pushButton_Cancel_pressed() {
|
|
||||||
this->close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapImageExporter::on_spinBox_TimelapseDelay_valueChanged(int delayMs) {
|
void MapImageExporter::on_spinBox_TimelapseDelay_valueChanged(int delayMs) {
|
||||||
|
|
Loading…
Reference in a new issue