Add settings for events tab icon

This commit is contained in:
GriffinR 2025-04-30 16:58:50 -04:00
parent 311b6c8638
commit 6d3fd5bc7e
5 changed files with 186 additions and 108 deletions

View File

@ -39,7 +39,7 @@
<x>0</x>
<y>0</y>
<width>570</width>
<height>692</height>
<height>680</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
@ -94,7 +94,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<iconset>
<normaloff>:/icons/folder.ico</normaloff>:/icons/folder.ico</iconset>
</property>
</widget>
@ -164,7 +164,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<iconset>
<normaloff>:/icons/folder.ico</normaloff>:/icons/folder.ico</iconset>
</property>
</widget>
@ -248,7 +248,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<iconset>
<normaloff>:/icons/folder.ico</normaloff>:/icons/folder.ico</iconset>
</property>
</widget>
@ -1197,23 +1197,62 @@
<x>0</x>
<y>0</y>
<width>570</width>
<height>840</height>
<height>927</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QGroupBox" name="groupBox_EventsTabIcon">
<property name="title">
<string>Tab Icon</string>
</property>
<layout class="QGridLayout" name="gridLayout_12">
<item row="1" column="1">
<widget class="QToolButton" name="button_EventsTabIcon">
<property name="visible">
<bool>false</bool>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/icons/folder.ico</normaloff>:/icons/folder.ico</iconset>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="lineEdit_EventsTabIcon">
<property name="visible">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The image file path to use for the icon of the Events tab.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="NoScrollComboBox" name="comboBox_EventsTabIcon">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The icon that will be displayed for the Events tab in the editor. If 'Automatic' is chosen, the icon will be a random player character from the project's base game version. If 'Custom' is chosen an image file path may be specified.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editable">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_DefaultIcons">
<property name="title">
<string>Default Icons</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="2" column="0">
<widget class="QLabel" name="label_TriggersIcon">
<property name="text">
<string>Triggers</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_WarpsIcon">
<property name="text">
@ -1221,23 +1260,31 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_WarpsIcon">
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_BGsIcon">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The icon that will be used to represent Warp events&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The icon that will be used to represent BG events&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_HealLocationsIcon">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The icon that will be used to represent Heal Location events&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<item row="4" column="2">
<widget class="QToolButton" name="button_HealLocationsIcon">
<property name="text">
<string>...</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
<property name="icon">
<iconset>
<normaloff>:/icons/folder.ico</normaloff>:/icons/folder.ico</iconset>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_ObjectsIcon">
<property name="text">
<string>Objects</string>
</property>
</widget>
</item>
@ -1248,6 +1295,24 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_TriggersIcon">
<property name="text">
<string>Triggers</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="button_WarpsIcon">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/icons/folder.ico</normaloff>:/icons/folder.ico</iconset>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_HealLocationsIcon">
<property name="text">
@ -1265,10 +1330,56 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_ObjectsIcon">
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_WarpsIcon">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The icon that will be used to represent Warp events&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QToolButton" name="button_BGsIcon">
<property name="text">
<string>Objects</string>
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/icons/folder.ico</normaloff>:/icons/folder.ico</iconset>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_HealLocationsIcon">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The icon that will be used to represent Heal Location events&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="button_TriggersIcon">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/icons/folder.ico</normaloff>:/icons/folder.ico</iconset>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="button_ObjectsIcon">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/icons/folder.ico</normaloff>:/icons/folder.ico</iconset>
</property>
</widget>
</item>
@ -1282,71 +1393,6 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_BGsIcon">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The icon that will be used to represent BG events&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="button_ObjectsIcon">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<normaloff>:/icons/folder.ico</normaloff>:/icons/folder.ico</iconset>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="button_WarpsIcon">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<normaloff>:/icons/folder.ico</normaloff>:/icons/folder.ico</iconset>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="button_TriggersIcon">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<normaloff>:/icons/folder.ico</normaloff>:/icons/folder.ico</iconset>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QToolButton" name="button_BGsIcon">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<normaloff>:/icons/folder.ico</normaloff>:/icons/folder.ico</iconset>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QToolButton" name="button_HealLocationsIcon">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<normaloff>:/icons/folder.ico</normaloff>:/icons/folder.ico</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -1365,7 +1411,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<iconset>
<normaloff>:/icons/delete.ico</normaloff>:/icons/delete.ico</iconset>
</property>
</widget>
@ -1418,7 +1464,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<iconset>
<normaloff>:/icons/add.ico</normaloff>:/icons/add.ico</iconset>
</property>
</widget>
@ -1628,7 +1674,7 @@
<x>0</x>
<y>0</y>
<width>544</width>
<height>338</height>
<height>341</height>
</rect>
</property>
<layout class="QFormLayout" name="layout_ProjectPaths">
@ -1657,7 +1703,7 @@
<string>Add Global Constants File...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<iconset>
<normaloff>:/icons/add.ico</normaloff>:/icons/add.ico</iconset>
</property>
</widget>
@ -1668,7 +1714,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<iconset>
<normaloff>:/icons/help.ico</normaloff>:/icons/help.ico</iconset>
</property>
</widget>
@ -1708,7 +1754,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<iconset>
<normaloff>:/icons/help.ico</normaloff>:/icons/help.ico</iconset>
</property>
</widget>
@ -1745,7 +1791,7 @@
<x>0</x>
<y>0</y>
<width>544</width>
<height>421</height>
<height>425</height>
</rect>
</property>
<layout class="QFormLayout" name="layout_Identifiers">
@ -1774,7 +1820,7 @@
<string>Add Global Constant...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<iconset>
<normaloff>:/icons/add.ico</normaloff>:/icons/add.ico</iconset>
</property>
</widget>
@ -1840,8 +1886,6 @@
<header location="global">uintspinbox.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../resources/images.qrc"/>
</resources>
<resources/>
<connections/>
</ui>

View File

@ -335,7 +335,7 @@ public:
this->filePaths.clear();
this->eventIconPaths.clear();
this->pokemonIconPaths.clear();
this->eventTabIconPath = QString();
this->eventsTabIconPath = QString();
this->collisionSheetPath = QString();
this->collisionSheetSize = QSize(2, 16);
this->playerViewDistance = QMargins(GBA_H_DIST_TO_CENTER, GBA_V_DIST_TO_CENTER, GBA_H_DIST_TO_CENTER, GBA_V_DIST_TO_CENTER);
@ -418,7 +418,7 @@ public:
uint16_t unusedTileCovered;
uint16_t unusedTileSplit;
bool mapAllowFlagsEnabled;
QString eventTabIconPath;
QString eventsTabIconPath;
QString collisionSheetPath;
QSize collisionSheetSize;
QMargins playerViewDistance;

View File

@ -894,8 +894,8 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
this->eventIconPaths[Event::Group::Heal] = value;
} else if (key.startsWith("pokemon_icon_path/")) {
this->pokemonIconPaths.insert(key.mid(QStringLiteral("pokemon_icon_path/").length()), value);
} else if (key == "event_tab_icon_path") {
this->eventTabIconPath = value;
} else if (key == "events_tab_icon_path") {
this->eventsTabIconPath = value;
} else if (key == "collision_sheet_path") {
this->collisionSheetPath = value;
} else if (key == "collision_sheet_width") {
@ -1013,7 +1013,7 @@ QMap<QString, QString> ProjectConfig::getKeyValueMap() {
for (auto it = this->identifiers.constBegin(); it != this->identifiers.constEnd(); it++) {
map.insert("ident/"+defaultIdentifiers.value(it.key()).first, it.value());
}
map.insert("event_tab_icon_path", this->eventTabIconPath);
map.insert("events_tab_icon_path", this->eventsTabIconPath);
map.insert("collision_sheet_path", this->collisionSheetPath);
map.insert("collision_sheet_width", QString::number(this->collisionSheetSize.width()));
map.insert("collision_sheet_height", QString::number(this->collisionSheetSize.height()));

View File

@ -1257,10 +1257,10 @@ bool MainWindow::setProjectUI() {
// Set a version dependent player icon (or user-chosen icon) for the Events tab.
QIcon eventTabIcon;
if (!projectConfig.eventTabIconPath.isEmpty()) {
eventTabIcon = QIcon(projectConfig.eventTabIconPath);
if (!projectConfig.eventsTabIconPath.isEmpty()) {
eventTabIcon = QIcon(project->getExistingFilepath(projectConfig.eventsTabIconPath));
if (eventTabIcon.isNull()) {
logWarn(QString("Failed to load custom Events tab icon '%1'.").arg(projectConfig.eventTabIconPath));
logWarn(QString("Failed to load custom Events tab icon '%1'.").arg(projectConfig.eventsTabIconPath));
}
}
if (eventTabIcon.isNull()) {

View File

@ -67,6 +67,7 @@ void ProjectSettingsEditor::connectSignals() {
connect(ui->button_BGsIcon, &QAbstractButton::clicked, [this](bool) { this->chooseImageFile(ui->lineEdit_BGsIcon); });
connect(ui->button_HealLocationsIcon, &QAbstractButton::clicked, [this](bool) { this->chooseImageFile(ui->lineEdit_HealLocationsIcon); });
connect(ui->button_PokemonIcon, &QAbstractButton::clicked, [this](bool) { this->chooseImageFile(ui->lineEdit_PokemonIcon); });
connect(ui->button_EventsTabIcon, &QAbstractButton::clicked, [this](bool) { this->chooseImageFile(ui->lineEdit_EventsTabIcon); });
// Display a warning if a mask value overlaps with another mask in its group.
@ -113,6 +114,20 @@ void ProjectSettingsEditor::initUi() {
ui->comboBox_BaseGameVersion->addItems(ProjectConfig::versionStrings);
ui->comboBox_AttributesSize->addItems({"1", "2", "4"});
ui->comboBox_EventsTabIcon->addItem("Automatic", "");
ui->comboBox_EventsTabIcon->addItem("Brendan (Emerald)", ProjectConfig::getPlayerIconPath(BaseGameVersion::pokeemerald, 0));
ui->comboBox_EventsTabIcon->addItem("Brendan (R/S)", ProjectConfig::getPlayerIconPath(BaseGameVersion::pokeruby, 0));
ui->comboBox_EventsTabIcon->addItem("May (Emerald)", ProjectConfig::getPlayerIconPath(BaseGameVersion::pokeemerald, 1));
ui->comboBox_EventsTabIcon->addItem("May (R/S)", ProjectConfig::getPlayerIconPath(BaseGameVersion::pokeruby, 1));
ui->comboBox_EventsTabIcon->addItem("Red", ProjectConfig::getPlayerIconPath(BaseGameVersion::pokefirered, 0));
ui->comboBox_EventsTabIcon->addItem("Green", ProjectConfig::getPlayerIconPath(BaseGameVersion::pokefirered, 1));
ui->comboBox_EventsTabIcon->addItem("Custom", "Custom");
connect(ui->comboBox_EventsTabIcon, &NoScrollComboBox::currentIndexChanged, [this](int index) {
bool usingCustom = (index == ui->comboBox_EventsTabIcon->findText("Custom"));
ui->lineEdit_EventsTabIcon->setVisible(usingCustom);
ui->button_EventsTabIcon->setVisible(usingCustom);
});
// Validate that the border metatiles text is a comma-separated list of metatile values
static const QString regex_Hex = "(0[xX])?[A-Fa-f0-9]+";
static const QRegularExpression expression_HexList(QString("^(%1,)*%1$").arg(regex_Hex)); // Comma-separated list of hex values
@ -520,6 +535,15 @@ void ProjectSettingsEditor::refresh() {
}
this->setWarpBehaviorsList(behaviorNames);
int index = ui->comboBox_EventsTabIcon->findData(projectConfig.eventsTabIconPath);
if (index < 0) {
index = ui->comboBox_EventsTabIcon->findData("Custom");
ui->lineEdit_EventsTabIcon->setText(projectConfig.eventsTabIconPath);
} else {
ui->lineEdit_EventsTabIcon->setText("");
}
ui->comboBox_EventsTabIcon->setCurrentIndex(index);
this->refreshing = false; // Allow signals
}
@ -608,6 +632,16 @@ void ProjectSettingsEditor::save() {
for (auto i = this->editedPokemonIconPaths.cbegin(), end = this->editedPokemonIconPaths.cend(); i != end; i++)
projectConfig.setPokemonIconPath(i.key(), i.value());
QString eventsTabIconPath;
QVariant data = ui->comboBox_EventsTabIcon->currentData();
if (data.isValid() && data.canConvert<QString>()) {
eventsTabIconPath = data.toString();
if (eventsTabIconPath == "Custom") {
eventsTabIconPath = ui->lineEdit_EventsTabIcon->text();
}
}
projectConfig.eventsTabIconPath = eventsTabIconPath;
projectConfig.save();
userConfig.save();
porymapConfig.save();