mirror of
https://github.com/huderlem/porymap.git
synced 2026-04-20 16:47:33 -05:00
Merge pull request #673 from GriffinRichards/event-selection
Add event selection settings
This commit is contained in:
commit
d421862ced
|
|
@ -67,6 +67,35 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_EventSelectionMode">
|
||||
<property name="title">
|
||||
<string>Event Selection Mode</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_EventSelectionMode">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_OnSprite">
|
||||
<property name="toolTip">
|
||||
<string>If enabled, an event can be selected by clicking directly on the opaque pixels of its sprite. This may be preferable when events are overlapping.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select by clicking on sprite</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_WithinRect">
|
||||
<property name="toolTip">
|
||||
<string>If enabled, an event can be selected by clicking anywhere within its sprite dimensions. This may be preferable for events with small or mostly transparent sprites.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select by clicking within bounding rectangle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_Themes">
|
||||
<property name="sizePolicy">
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <QDateTime>
|
||||
#include <QUrl>
|
||||
#include <QVersionNumber>
|
||||
#include <QGraphicsPixmapItem>
|
||||
|
||||
#include "events.h"
|
||||
|
||||
|
|
@ -84,6 +85,7 @@ public:
|
|||
this->lastUpdateCheckTime = QDateTime();
|
||||
this->lastUpdateCheckVersion = porymapVersion;
|
||||
this->rateLimitTimes.clear();
|
||||
this->eventSelectionShapeMode = QGraphicsPixmapItem::MaskShape;
|
||||
}
|
||||
void addRecentProject(QString project);
|
||||
void setRecentProjects(QStringList projects);
|
||||
|
|
@ -138,6 +140,7 @@ public:
|
|||
QDateTime lastUpdateCheckTime;
|
||||
QVersionNumber lastUpdateCheckVersion;
|
||||
QMap<QUrl, QDateTime> rateLimitTimes;
|
||||
QGraphicsPixmapItem::ShapeMode eventSelectionShapeMode;
|
||||
QByteArray wildMonChartGeometry;
|
||||
QByteArray newMapDialogGeometry;
|
||||
QByteArray newLayoutDialogGeometry;
|
||||
|
|
|
|||
|
|
@ -115,6 +115,8 @@ public:
|
|||
DraggablePixmapItem *addNewEvent(Event::Type type);
|
||||
void updateSelectedEvents();
|
||||
void duplicateSelectedEvents();
|
||||
void redrawAllEvents();
|
||||
void redrawEvents(const QList<Event*> &events);
|
||||
void redrawEventPixmapItem(DraggablePixmapItem *item);
|
||||
QList<DraggablePixmapItem *> getEventPixmapItems();
|
||||
|
||||
|
|
|
|||
|
|
@ -412,6 +412,14 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
|
|||
if (match.hasMatch()) {
|
||||
this->rateLimitTimes.insert(match.captured("url"), QDateTime::fromString(value).toLocalTime());
|
||||
}
|
||||
} else if (key == "event_selection_shape_mode") {
|
||||
if (value == "mask") {
|
||||
this->eventSelectionShapeMode = QGraphicsPixmapItem::MaskShape;
|
||||
} else if (value == "bounding_rect") {
|
||||
this->eventSelectionShapeMode = QGraphicsPixmapItem::BoundingRectShape;
|
||||
} else {
|
||||
logWarn(QString("Invalid config value for %1: '%2'. Must be 'mask' or 'bounding_rect'.").arg(key).arg(value));
|
||||
}
|
||||
} else {
|
||||
logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->getConfigFilepath()).arg(key));
|
||||
}
|
||||
|
|
@ -480,6 +488,7 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
|
|||
if (!time.isNull() && time > QDateTime::currentDateTime())
|
||||
map.insert("rate_limit_time/" + i.key().toString(), time.toUTC().toString());
|
||||
}
|
||||
map.insert("event_selection_shape_mode", (this->eventSelectionShapeMode == QGraphicsPixmapItem::MaskShape) ? "mask" : "bounding_rect");
|
||||
|
||||
return map;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1985,6 +1985,16 @@ Tileset* Editor::getCurrentMapPrimaryTileset()
|
|||
return project->getTileset(tilesetLabel);
|
||||
}
|
||||
|
||||
void Editor::redrawAllEvents() {
|
||||
if (this->map) redrawEvents(this->map->getEvents());
|
||||
}
|
||||
|
||||
void Editor::redrawEvents(const QList<Event*> &events) {
|
||||
for (const auto &event : events) {
|
||||
redrawEventPixmapItem(event->getPixmapItem());
|
||||
}
|
||||
}
|
||||
|
||||
QList<DraggablePixmapItem *> Editor::getEventPixmapItems() {
|
||||
QList<DraggablePixmapItem *> list;
|
||||
for (QGraphicsItem *child : events_group->childItems()) {
|
||||
|
|
@ -1999,7 +2009,7 @@ void Editor::redrawEventPixmapItem(DraggablePixmapItem *item) {
|
|||
item->setOpacity(opacity);
|
||||
project->setEventPixmap(item->event, true);
|
||||
item->setPixmap(item->event->getPixmap());
|
||||
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
||||
item->setShapeMode(porymapConfig.eventSelectionShapeMode);
|
||||
if (selected_events && selected_events->contains(item)) {
|
||||
QImage image = item->pixmap().toImage();
|
||||
QPainter painter(&image);
|
||||
|
|
|
|||
|
|
@ -2746,6 +2746,9 @@ void MainWindow::togglePreferenceSpecificUi() {
|
|||
|
||||
if (this->updatePromoter)
|
||||
this->updatePromoter->updatePreferences();
|
||||
|
||||
// Redraw all events to use updated porymapConfig.eventSelectionShapeMode
|
||||
this->editor->redrawAllEvents();
|
||||
}
|
||||
|
||||
void MainWindow::openProjectSettingsEditor(int tab) {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ void PreferenceEditor::initFields() {
|
|||
|
||||
void PreferenceEditor::updateFields() {
|
||||
themeSelector->setCurrentText(porymapConfig.theme);
|
||||
if (porymapConfig.eventSelectionShapeMode == QGraphicsPixmapItem::MaskShape) {
|
||||
ui->radioButton_OnSprite->setChecked(true);
|
||||
} else if (porymapConfig.eventSelectionShapeMode == QGraphicsPixmapItem::BoundingRectShape) {
|
||||
ui->radioButton_WithinRect->setChecked(true);
|
||||
}
|
||||
ui->lineEdit_TextEditorOpenFolder->setText(porymapConfig.textEditorOpenFolder);
|
||||
ui->lineEdit_TextEditorGotoLine->setText(porymapConfig.textEditorGotoLine);
|
||||
ui->checkBox_MonitorProjectFiles->setChecked(porymapConfig.monitorFiles);
|
||||
|
|
@ -59,7 +64,7 @@ void PreferenceEditor::saveFields() {
|
|||
porymapConfig.theme = theme;
|
||||
emit themeChanged(theme);
|
||||
}
|
||||
|
||||
porymapConfig.eventSelectionShapeMode = ui->radioButton_OnSprite->isChecked() ? QGraphicsPixmapItem::MaskShape : QGraphicsPixmapItem::BoundingRectShape;
|
||||
porymapConfig.textEditorOpenFolder = ui->lineEdit_TextEditorOpenFolder->text();
|
||||
porymapConfig.textEditorGotoLine = ui->lineEdit_TextEditorGotoLine->text();
|
||||
porymapConfig.monitorFiles = ui->checkBox_MonitorProjectFiles->isChecked();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user