Merge branch 'master' of https://github.com/huderlem/porymap into slam

This commit is contained in:
GriffinR 2024-10-25 14:33:00 -04:00
commit 40d34b2d5b
20 changed files with 239 additions and 180 deletions

View file

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>540</width>
<width>582</width>
<height>355</height>
</rect>
</property>
@ -33,21 +33,30 @@
<item>
<widget class="QFrame" name="window">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QFrame" name="header">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="button_CreateNewScript">
<property name="toolTip">
@ -91,9 +100,9 @@
</widget>
</item>
<item>
<spacer name="horizontalSpacer_header">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -103,35 +112,33 @@
</property>
</spacer>
</item>
<item>
<spacer name="horizontalSpacer_header">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="button_Help">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<normaloff>:/icons/help.ico</normaloff>:/icons/help.ico</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="label_Manual">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://huderlem.github.io/porymap/manual/scripting-capabilities.html&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0069d9;&quot;&gt;Help&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_ListHeader">
<property name="text">
@ -142,32 +149,32 @@
<item>
<widget class="QListWidget" name="list">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
<set>QAbstractItemView::EditTrigger::NoEditTriggers</set>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragOnly</enum>
<enum>QAbstractItemView::DragDropMode::DragOnly</enum>
</property>
<property name="defaultDropAction">
<enum>Qt::IgnoreAction</enum>
<enum>Qt::DropAction::IgnoreAction</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
<enum>QAbstractItemView::SelectionMode::ExtendedSelection</enum>
</property>
<property name="textElideMode">
<enum>Qt::ElideLeft</enum>
<enum>Qt::TextElideMode::ElideLeft</enum>
</property>
<property name="movement">
<enum>QListView::Free</enum>
<enum>QListView::Movement::Free</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>

View file

@ -125,7 +125,7 @@
<item row="1" column="6">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -194,10 +194,10 @@
<item row="1" column="3">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
<enum>QSizePolicy::Policy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -276,10 +276,10 @@
<string notr="true">.QFrame { border: 1px solid red; }</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
@ -287,7 +287,6 @@
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -319,7 +318,7 @@
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -338,7 +337,7 @@
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -567,10 +566,10 @@
<string notr="true">.QFrame { border: 1px solid red; }</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_18">
<item>
@ -578,7 +577,6 @@
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -693,7 +691,7 @@
<item row="0" column="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -712,7 +710,7 @@
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -783,10 +781,10 @@
<string notr="true">.QFrame { border: 1px solid red; }</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
@ -794,7 +792,6 @@
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -839,10 +836,10 @@
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
<enum>QSizePolicy::Policy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -924,10 +921,10 @@
<item row="9" column="0">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
<enum>QSizePolicy::Policy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -975,7 +972,7 @@
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1212,7 +1209,7 @@
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
<set>Qt::TextInteractionFlag::NoTextInteraction</set>
</property>
<property name="placeholderText">
<string>Use the dropbown and buttons to add behaviors to the list...</string>
@ -1242,10 +1239,10 @@
<string notr="true">.QFrame { border: 1px solid red; }</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_15">
<item>
@ -1253,7 +1250,6 @@
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -1316,7 +1312,7 @@
<item row="0" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1335,7 +1331,7 @@
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1372,18 +1368,13 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QLabel" name="label_ProjectFilesHelp">
<widget class="QToolButton" name="button_HelpFiles">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://huderlem.github.io/porymap/manual/project-files.html#files&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0069d9;&quot;&gt;Help&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>...</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
<property name="icon">
<iconset resource="../resources/images.qrc">
<normaloff>:/icons/help.ico</normaloff>:/icons/help.ico</iconset>
</property>
</widget>
</item>
@ -1419,7 +1410,7 @@
<x>0</x>
<y>0</y>
<width>533</width>
<height>440</height>
<height>428</height>
</rect>
</property>
<layout class="QFormLayout" name="layout_ProjectPaths">
@ -1466,18 +1457,13 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_19">
<item>
<widget class="QLabel" name="label_IdentifiersHelp">
<widget class="QToolButton" name="button_HelpIdentifiers">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://huderlem.github.io/porymap/manual/project-files.html#identifiers&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0069d9;&quot;&gt;Help&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>...</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
<property name="icon">
<iconset resource="../resources/images.qrc">
<normaloff>:/icons/help.ico</normaloff>:/icons/help.ico</iconset>
</property>
</widget>
</item>
@ -1513,7 +1499,7 @@
<x>0</x>
<y>0</y>
<width>533</width>
<height>440</height>
<height>428</height>
</rect>
</property>
<layout class="QFormLayout" name="layout_Identifiers">
@ -1544,7 +1530,7 @@
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults</set>
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok|QDialogButtonBox::StandardButton::RestoreDefaults</set>
</property>
</widget>
</item>

View file

@ -18,6 +18,7 @@ public:
Tileset() = default;
Tileset(const Tileset &other);
Tileset &operator=(const Tileset &other);
~Tileset();
public:
QString name;
@ -33,7 +34,6 @@ public:
QStringList palettePaths;
QList<QImage> tiles;
QList<Metatile*> metatiles;
QHash<int, QString> metatileLabels;
QList<QList<QRgb>> palettes;
QList<QList<QRgb>> palettePreviews;
@ -59,6 +59,19 @@ public:
bool appendToHeaders(QString root, QString friendlyName, bool usingAsm);
bool appendToGraphics(QString root, QString friendlyName, bool usingAsm);
bool appendToMetatiles(QString root, QString friendlyName, bool usingAsm);
void setMetatiles(const QList<Metatile*> &metatiles);
void addMetatile(Metatile* metatile);
QList<Metatile*> metatiles() const { return m_metatiles; }
Metatile* metatileAt(unsigned int i) const { return m_metatiles.at(i); }
void clearMetatiles();
void resizeMetatiles(unsigned int newNumMetatiles);
int numMetatiles() const { return m_metatiles.length(); }
private:
QList<Metatile*> m_metatiles;
};
#endif // TILESET_H

View file

@ -167,6 +167,7 @@ public slots:
void on_mainTabBar_tabBarClicked(int index);
void on_mapViewTab_tabBarClicked(int index);
void onWarpBehaviorWarningClicked();
void clearOverlay();
private slots:
void on_action_Open_Project_triggered();

View file

@ -49,6 +49,7 @@ private:
void restoreWindowState();
void initShortcuts();
QObjectList shortcutableObjects() const;
void openManual();
private slots:
void dialogButtonClicked(QAbstractButton *button);

View file

@ -65,6 +65,8 @@ private:
void updateMaskOverlapWarning(QLabel * warning, QList<UIntSpinBox*> masks);
QStringList getWarpBehaviorsList();
void setWarpBehaviorsList(QStringList list);
void openFilesHelp();
void openIdentifiersHelp();
private slots:
void dialogButtonClicked(QAbstractButton *button);

View file

@ -29,8 +29,8 @@ Tileset::Tileset(const Tileset &other)
tiles.append(tile.copy());
}
for (auto *metatile : other.metatiles) {
metatiles.append(new Metatile(*metatile));
for (auto *metatile : other.m_metatiles) {
m_metatiles.append(new Metatile(*metatile));
}
}
@ -55,14 +55,42 @@ Tileset &Tileset::operator=(const Tileset &other) {
tiles.append(tile.copy());
}
metatiles.clear();
for (auto *metatile : other.metatiles) {
metatiles.append(new Metatile(*metatile));
clearMetatiles();
for (auto *metatile : other.m_metatiles) {
m_metatiles.append(new Metatile(*metatile));
}
return *this;
}
Tileset::~Tileset() {
clearMetatiles();
}
void Tileset::clearMetatiles() {
qDeleteAll(m_metatiles);
m_metatiles.clear();
}
void Tileset::setMetatiles(const QList<Metatile*> &metatiles) {
clearMetatiles();
m_metatiles = metatiles;
}
void Tileset::addMetatile(Metatile* metatile) {
m_metatiles.append(metatile);
}
void Tileset::resizeMetatiles(unsigned int newNumMetatiles) {
while (m_metatiles.length() > newNumMetatiles) {
delete m_metatiles.takeLast();
}
const int numTiles = projectConfig.getNumTilesInMetatile();
while (m_metatiles.length() < newNumMetatiles) {
m_metatiles.append(new Metatile(numTiles));
}
}
Tileset* Tileset::getTileTileset(int tileId, Tileset *primaryTileset, Tileset *secondaryTileset) {
if (tileId < Project::getNumTilesPrimary()) {
return primaryTileset;
@ -89,7 +117,7 @@ Metatile* Tileset::getMetatile(int metatileId, Tileset *primaryTileset, Tileset
return nullptr;
}
int index = Metatile::getIndexInTileset(metatileId);
return tileset->metatiles.value(index, nullptr);
return tileset->m_metatiles.value(index, nullptr);
}
// Metatile labels are stored per-tileset. When looking for a metatile label, first search in the tileset
@ -178,10 +206,10 @@ bool Tileset::metatileIsValid(uint16_t metatileId, Tileset *primaryTileset, Tile
if (metatileId >= Project::getNumMetatilesTotal())
return false;
if (metatileId < Project::getNumMetatilesPrimary() && metatileId >= primaryTileset->metatiles.length())
if (metatileId < Project::getNumMetatilesPrimary() && metatileId >= primaryTileset->numMetatiles())
return false;
if (metatileId >= Project::getNumMetatilesPrimary() + secondaryTileset->metatiles.length())
if (metatileId >= Project::getNumMetatilesPrimary() + secondaryTileset->numMetatiles())
return false;
return true;

View file

@ -1774,7 +1774,7 @@ void MainWindow::on_actionNew_Tileset_triggered() {
}
mt->tiles.append(tile);
}
newSet.metatiles.append(mt);
newSet.addMetatile(mt);
}
for(int i = 0; i < 16; ++i) {
QList<QRgb> currentPal;
@ -3564,6 +3564,11 @@ bool MainWindow::askToFixRegionMapEditor() {
return false;
}
void MainWindow::clearOverlay() {
if (ui->graphicsView_Map)
ui->graphicsView_Map->clearOverlayMap();
}
// Attempt to close any open sub-windows of the main window, giving each a chance to abort the process.
// Each of these windows is a widget with WA_DeleteOnClose set, so manually deleting them isn't necessary.
// Because they're tracked with QPointers nullifying them shouldn't be necessary either, but it seems the

View file

@ -1117,7 +1117,7 @@ void Project::saveTilesetMetatileAttributes(Tileset *tileset) {
QFile attrs_file(tileset->metatile_attrs_path);
if (attrs_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
QByteArray data;
for (Metatile *metatile : tileset->metatiles) {
for (const auto &metatile : tileset->metatiles()) {
uint32_t attributes = metatile->getAttributes();
for (int i = 0; i < projectConfig.metatileAttributesSize; i++)
data.append(static_cast<char>(attributes >> (8 * i)));
@ -1133,7 +1133,7 @@ void Project::saveTilesetMetatiles(Tileset *tileset) {
if (metatiles_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
QByteArray data;
int numTiles = projectConfig.getNumTilesInMetatile();
for (Metatile *metatile : tileset->metatiles) {
for (const auto &metatile : tileset->metatiles()) {
for (int i = 0; i < numTiles; i++) {
uint16_t tile = metatile->tiles.at(i).rawValue();
data.append(static_cast<char>(tile));
@ -1142,7 +1142,7 @@ void Project::saveTilesetMetatiles(Tileset *tileset) {
}
metatiles_file.write(data);
} else {
tileset->metatiles.clear();
tileset->clearMetatiles();
logError(QString("Could not open tileset metatiles file '%1'").arg(tileset->metatiles_path));
}
}
@ -1635,16 +1635,16 @@ void Project::loadTilesetMetatiles(Tileset* tileset) {
}
metatiles.append(metatile);
}
tileset->metatiles = metatiles;
tileset->setMetatiles(metatiles);
} else {
tileset->metatiles.clear();
tileset->clearMetatiles();
logError(QString("Could not open tileset metatiles file '%1'").arg(tileset->metatiles_path));
}
QFile attrs_file(tileset->metatile_attrs_path);
if (attrs_file.open(QIODevice::ReadOnly)) {
QByteArray data = attrs_file.readAll();
int num_metatiles = tileset->metatiles.count();
int num_metatiles = tileset->numMetatiles();
int attrSize = projectConfig.metatileAttributesSize;
int num_metatileAttrs = data.length() / attrSize;
if (num_metatiles != num_metatileAttrs) {
@ -1657,7 +1657,7 @@ void Project::loadTilesetMetatiles(Tileset* tileset) {
uint32_t attributes = 0;
for (int j = 0; j < attrSize; j++)
attributes |= static_cast<unsigned char>(data.at(i * attrSize + j)) << (8 * j);
tileset->metatiles.at(i)->setAttributes(attributes);
tileset->metatileAt(i)->setAttributes(attributes);
}
} else {
logError(QString("Could not open tileset metatile attributes file '%1'").arg(tileset->metatile_attrs_path));

View file

@ -533,13 +533,13 @@ QJSValue MainWindow::getSecondaryTilesetPalettesPreview() {
int MainWindow::getNumPrimaryTilesetMetatiles() {
if (!this->editor || !this->editor->layout || !this->editor->layout->tileset_primary)
return 0;
return this->editor->layout->tileset_primary->metatiles.length();
return this->editor->layout->tileset_primary->numMetatiles();
}
int MainWindow::getNumSecondaryTilesetMetatiles() {
if (!this->editor || !this->editor->layout || !this->editor->layout->tileset_secondary)
return 0;
return this->editor->layout->tileset_secondary->metatiles.length();
return this->editor->layout->tileset_secondary->numMetatiles();
}
int MainWindow::getNumPrimaryTilesetTiles() {

View file

@ -29,8 +29,6 @@ void Scripting::stop() {
}
void Scripting::init(MainWindow *mainWindow) {
if (mainWindow->ui->graphicsView_Map)
mainWindow->ui->graphicsView_Map->clearOverlayMap();
Scripting::stop();
instance = new Scripting(mainWindow);
}
@ -50,6 +48,7 @@ Scripting::Scripting(MainWindow *mainWindow) {
}
Scripting::~Scripting() {
if (mainWindow) mainWindow->clearOverlay();
this->engine->setInterrupted(true);
qDeleteAll(this->imageCache);
delete this->engine;

View file

@ -23,6 +23,7 @@ CustomScriptsEditor::CustomScriptsEditor(QWidget *parent) :
for (int i = 0; i < paths.length(); i++)
this->displayScript(paths.at(i), enabled.at(i));
connect(ui->button_Help, &QAbstractButton::clicked, this, &CustomScriptsEditor::openManual);
connect(ui->button_CreateNewScript, &QAbstractButton::clicked, this, &CustomScriptsEditor::createNewScript);
connect(ui->button_LoadScript, &QAbstractButton::clicked, this, &CustomScriptsEditor::loadScript);
connect(ui->button_RefreshScripts, &QAbstractButton::clicked, this, &CustomScriptsEditor::userRefreshScripts);
@ -229,6 +230,11 @@ void CustomScriptsEditor::openSelectedScripts() {
this->openScript(item);
}
void CustomScriptsEditor::openManual() {
static const QUrl url("https://huderlem.github.io/porymap/manual/scripting-capabilities.html");
QDesktopServices::openUrl(url);
}
// When the user refreshes the scripts we show a little tooltip as feedback.
// We don't want this tooltip to display when we refresh programmatically, like when changes are saved.
void CustomScriptsEditor::userRefreshScripts() {

View file

@ -25,8 +25,9 @@ void GraphicsView::moveEvent(QMoveEvent *event) {
}
void MapView::drawForeground(QPainter *painter, const QRectF&) {
foreach (Overlay * overlay, this->overlayMap)
overlay->renderItems(painter);
for (auto i = this->overlayMap.constBegin(); i != this->overlayMap.constEnd(); i++) {
i.value()->renderItems(painter);
}
if (!editor) return;
@ -56,9 +57,8 @@ void MapView::drawForeground(QPainter *painter, const QRectF&) {
}
void MapView::clearOverlayMap() {
foreach (Overlay * overlay, this->overlayMap) {
overlay->clearItems();
delete overlay;
for (auto i = this->overlayMap.constBegin(); i != this->overlayMap.constEnd(); i++) {
delete i.value();
}
this->overlayMap.clear();
}

View file

@ -117,6 +117,7 @@ void GridSettingsDialog::init() {
connect(ui->button_LinkDimensions, &QAbstractButton::toggled, [this](bool on) { m_dimensionsLinked = on; });
connect(ui->button_LinkOffsets, &QAbstractButton::toggled, [this](bool on) { m_offsetsLinked = on; });
connect(ui->colorInput, &ColorInputWidget::colorChanged, this, &GridSettingsDialog::onColorChanged);
connect(this, &GridSettingsDialog::rejected, [this] { setSettings(m_originalSettings); });
updateInput();
}
@ -218,11 +219,10 @@ void GridSettingsDialog::dialogButtonClicked(QAbstractButton *button) {
auto role = ui->buttonBox->buttonRole(button);
if (role == QDialogButtonBox::AcceptRole) {
// "OK"
close();
accept();
} else if (role == QDialogButtonBox::RejectRole) {
// "Cancel"
setSettings(m_originalSettings);
close();
reject();
} else if (role == QDialogButtonBox::ResetRole) {
// "Restore Defaults"
setSettings(m_defaultSettings);

View file

@ -24,7 +24,7 @@ void MetatileLayersItem::draw() {
QPainter painter(&pixmap);
// Draw tile images
int numTiles = projectConfig.getNumTilesInMetatile();
int numTiles = qMin(projectConfig.getNumTilesInMetatile(), this->metatile ? this->metatile->tiles.length() : 0);
for (int i = 0; i < numTiles; i++) {
Tile tile = this->metatile->tiles.at(i);
QImage tileImage = getPalettedTileImage(tile.tileId, this->primaryTileset, this->secondaryTileset, tile.palette, true)

View file

@ -14,8 +14,8 @@ void MetatileSelector::draw() {
this->setPixmap(QPixmap());
}
int primaryLength = this->primaryTileset->metatiles.length();
int length_ = primaryLength + this->secondaryTileset->metatiles.length();
int primaryLength = this->primaryTileset->numMetatiles();
int length_ = primaryLength + this->secondaryTileset->numMetatiles();
int height_ = length_ / this->numMetatilesWide;
if (length_ % this->numMetatilesWide != 0) {
height_++;
@ -199,10 +199,10 @@ void MetatileSelector::updateExternalSelectedMetatiles() {
uint16_t MetatileSelector::getMetatileId(int x, int y) const {
int index = y * this->numMetatilesWide + x;
if (index < this->primaryTileset->metatiles.length()) {
if (index < this->primaryTileset->numMetatiles()) {
return static_cast<uint16_t>(index);
} else {
return static_cast<uint16_t>(Project::getNumMetatilesPrimary() + index - this->primaryTileset->metatiles.length());
return static_cast<uint16_t>(Project::getNumMetatilesPrimary() + index - this->primaryTileset->numMetatiles());
}
}
@ -215,7 +215,7 @@ QPoint MetatileSelector::getMetatileIdCoords(uint16_t metatileId) {
int index = metatileId < Project::getNumMetatilesPrimary()
? metatileId
: metatileId - Project::getNumMetatilesPrimary() + this->primaryTileset->metatiles.length();
: metatileId - Project::getNumMetatilesPrimary() + this->primaryTileset->numMetatiles();
return QPoint(index % this->numMetatilesWide, index / this->numMetatilesWide);
}

View file

@ -37,6 +37,8 @@ ProjectSettingsEditor::~ProjectSettingsEditor()
}
void ProjectSettingsEditor::connectSignals() {
connect(ui->button_HelpFiles, &QAbstractButton::clicked, this, &ProjectSettingsEditor::openFilesHelp);
connect(ui->button_HelpIdentifiers, &QAbstractButton::clicked, this, &ProjectSettingsEditor::openIdentifiersHelp);
connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &ProjectSettingsEditor::dialogButtonClicked);
connect(ui->button_ImportDefaultPrefabs, &QAbstractButton::clicked, this, &ProjectSettingsEditor::importDefaultPrefabsClicked);
connect(ui->comboBox_BaseGameVersion, &QComboBox::currentTextChanged, this, &ProjectSettingsEditor::promptRestoreDefaults);
@ -658,6 +660,16 @@ void ProjectSettingsEditor::dialogButtonClicked(QAbstractButton *button) {
}
}
void ProjectSettingsEditor::openFilesHelp() {
static const QUrl url("https://huderlem.github.io/porymap/manual/project-files.html#files");
QDesktopServices::openUrl(url);
}
void ProjectSettingsEditor::openIdentifiersHelp() {
static const QUrl url("https://huderlem.github.io/porymap/manual/project-files.html#identifiers");
QDesktopServices::openUrl(url);
}
// Close event triggered by a project reload. User doesn't need any prompts, just close the window.
void ProjectSettingsEditor::closeQuietly() {
// Turn off flags that trigger prompts

View file

@ -32,7 +32,6 @@ TilesetEditor::~TilesetEditor()
delete tileSelector;
delete metatileLayersItem;
delete paletteEditor;
delete metatile;
delete primaryTileset;
delete secondaryTileset;
delete metatilesScene;
@ -41,6 +40,7 @@ TilesetEditor::~TilesetEditor()
delete selectedTileScene;
delete metatileLayersScene;
delete copiedMetatile;
this->metatileHistory.clear();
}
void TilesetEditor::update(Layout *layout, QString primaryTilesetLabel, QString secondaryTilesetLabel) {
@ -781,8 +781,8 @@ void TilesetEditor::on_actionChange_Metatiles_Count_triggered()
secondarySpinBox->setMinimum(1);
primarySpinBox->setMaximum(Project::getNumMetatilesPrimary());
secondarySpinBox->setMaximum(Project::getNumMetatilesTotal() - Project::getNumMetatilesPrimary());
primarySpinBox->setValue(this->primaryTileset->metatiles.length());
secondarySpinBox->setValue(this->secondaryTileset->metatiles.length());
primarySpinBox->setValue(this->primaryTileset->numMetatiles());
secondarySpinBox->setValue(this->secondaryTileset->numMetatiles());
form.addRow(new QLabel("Primary Tileset"), primarySpinBox);
form.addRow(new QLabel("Secondary Tileset"), secondarySpinBox);
@ -792,22 +792,8 @@ void TilesetEditor::on_actionChange_Metatiles_Count_triggered()
form.addRow(&buttonBox);
if (dialog.exec() == QDialog::Accepted) {
int numPrimaryMetatiles = primarySpinBox->value();
int numSecondaryMetatiles = secondarySpinBox->value();
int numTiles = projectConfig.getNumTilesInMetatile();
while (this->primaryTileset->metatiles.length() > numPrimaryMetatiles) {
delete this->primaryTileset->metatiles.takeLast();
}
while (this->primaryTileset->metatiles.length() < numPrimaryMetatiles) {
this->primaryTileset->metatiles.append(new Metatile(numTiles));
}
while (this->secondaryTileset->metatiles.length() > numSecondaryMetatiles) {
delete this->secondaryTileset->metatiles.takeLast();
}
while (this->secondaryTileset->metatiles.length() < numSecondaryMetatiles) {
this->secondaryTileset->metatiles.append(new Metatile(numTiles));
}
this->primaryTileset->resizeMetatiles(primarySpinBox->value());
this->secondaryTileset->resizeMetatiles(secondarySpinBox->value());
this->metatileSelector->updateSelectedMetatile();
this->refresh();
this->hasUnsavedChanges = true;
@ -1008,20 +994,20 @@ void TilesetEditor::importTilesetMetatiles(Tileset *tileset, bool primary)
// Revisit this when tiles and num metatiles are added to tileset editory history.
int metatileIdBase = primary ? 0 : Project::getNumMetatilesPrimary();
for (int i = 0; i < metatiles.length(); i++) {
if (i >= tileset->metatiles.length()) {
if (i >= tileset->numMetatiles()) {
break;
}
uint16_t metatileId = static_cast<uint16_t>(metatileIdBase + i);
QString prevLabel = Tileset::getOwnedMetatileLabel(metatileId, this->primaryTileset, this->secondaryTileset);
Metatile *prevMetatile = new Metatile(*tileset->metatiles.at(i));
Metatile *prevMetatile = new Metatile(*tileset->metatileAt(i));
MetatileHistoryItem *commit = new MetatileHistoryItem(metatileId,
prevMetatile, new Metatile(*metatiles.at(i)),
prevLabel, prevLabel);
metatileHistory.push(commit);
}
tileset->metatiles = metatiles;
tileset->setMetatiles(metatiles);
this->refresh();
this->hasUnsavedChanges = true;
}
@ -1125,9 +1111,9 @@ void TilesetEditor::countTileUsage() {
// check primary tilesets that are used with this secondary tileset for
// reference to secondary tiles in primary metatiles
for (Tileset *tileset : primaryTilesets) {
for (Metatile *metatile : tileset->metatiles) {
for (Tile tile : metatile->tiles) {
for (const auto &tileset : primaryTilesets) {
for (const auto &metatile : tileset->metatiles()) {
for (const auto &tile : metatile->tiles) {
if (tile.tileId >= Project::getNumTilesPrimary())
this->tileSelector->usedTiles[tile.tileId]++;
}
@ -1136,8 +1122,8 @@ void TilesetEditor::countTileUsage() {
// do the opposite for primary tiles in secondary metatiles
for (Tileset *tileset : secondaryTilesets) {
for (Metatile *metatile : tileset->metatiles) {
for (Tile tile : metatile->tiles) {
for (const auto &metatile : tileset->metatiles()) {
for (const auto &tile : metatile->tiles) {
if (tile.tileId < Project::getNumTilesPrimary())
this->tileSelector->usedTiles[tile.tileId]++;
}
@ -1145,15 +1131,15 @@ void TilesetEditor::countTileUsage() {
}
// check this primary tileset metatiles
for (Metatile *metatile : this->primaryTileset->metatiles) {
for (Tile tile : metatile->tiles) {
for (const auto &metatile : this->primaryTileset->metatiles()) {
for (const auto &tile : metatile->tiles) {
this->tileSelector->usedTiles[tile.tileId]++;
}
}
// and the secondary metatiles
for (Metatile *metatile : this->secondaryTileset->metatiles) {
for (Tile tile : metatile->tiles) {
for (const auto &metatile : this->secondaryTileset->metatiles()) {
for (const auto &tile : metatile->tiles) {
this->tileSelector->usedTiles[tile.tileId]++;
}
}

View file

@ -22,24 +22,24 @@ int TilesetEditorMetatileSelector::numRows(int numMetatiles) {
}
int TilesetEditorMetatileSelector::numRows() {
return this->numRows(this->primaryTileset->metatiles.length() + this->secondaryTileset->metatiles.length());
return this->numRows(this->primaryTileset->numMetatiles() + this->secondaryTileset->numMetatiles());
}
QImage TilesetEditorMetatileSelector::buildAllMetatilesImage() {
return this->buildImage(0, this->primaryTileset->metatiles.length() + this->secondaryTileset->metatiles.length());
return this->buildImage(0, this->primaryTileset->numMetatiles() + this->secondaryTileset->numMetatiles());
}
QImage TilesetEditorMetatileSelector::buildPrimaryMetatilesImage() {
return this->buildImage(0, this->primaryTileset->metatiles.length());
return this->buildImage(0, this->primaryTileset->numMetatiles());
}
QImage TilesetEditorMetatileSelector::buildSecondaryMetatilesImage() {
return this->buildImage(Project::getNumMetatilesPrimary(), this->secondaryTileset->metatiles.length());
return this->buildImage(Project::getNumMetatilesPrimary(), this->secondaryTileset->numMetatiles());
}
QImage TilesetEditorMetatileSelector::buildImage(int metatileIdStart, int numMetatiles) {
int numMetatilesHigh = this->numRows(numMetatiles);
int numPrimary = this->primaryTileset->metatiles.length();
int numPrimary = this->primaryTileset->numMetatiles();
int maxPrimary = Project::getNumMetatilesPrimary();
bool includesPrimary = metatileIdStart < maxPrimary;
@ -96,7 +96,7 @@ void TilesetEditorMetatileSelector::updateSelectedMetatile() {
if (Tileset::metatileIsValid(metatileId, this->primaryTileset, this->secondaryTileset))
this->selectedMetatile = metatileId;
else
this->selectedMetatile = Project::getNumMetatilesPrimary() + this->secondaryTileset->metatiles.length() - 1;
this->selectedMetatile = Project::getNumMetatilesPrimary() + this->secondaryTileset->numMetatiles() - 1;
emit selectedMetatileChanged(this->selectedMetatile);
}
@ -106,10 +106,10 @@ uint16_t TilesetEditorMetatileSelector::getSelectedMetatileId() {
uint16_t TilesetEditorMetatileSelector::getMetatileId(int x, int y) {
int index = y * this->numMetatilesWide + x;
if (index < this->primaryTileset->metatiles.length()) {
if (index < this->primaryTileset->numMetatiles()) {
return static_cast<uint16_t>(index);
} else {
return static_cast<uint16_t>(Project::getNumMetatilesPrimary() + index - this->primaryTileset->metatiles.length());
return static_cast<uint16_t>(Project::getNumMetatilesPrimary() + index - this->primaryTileset->numMetatiles());
}
}
@ -155,7 +155,7 @@ QPoint TilesetEditorMetatileSelector::getMetatileIdCoords(uint16_t metatileId) {
}
int index = metatileId < Project::getNumMetatilesPrimary()
? metatileId
: metatileId - Project::getNumMetatilesPrimary() + this->primaryTileset->metatiles.length();
: metatileId - Project::getNumMetatilesPrimary() + this->primaryTileset->numMetatiles();
return QPoint(index % this->numMetatilesWide, index / this->numMetatilesWide);
}
@ -232,8 +232,8 @@ void TilesetEditorMetatileSelector::drawUnused() {
QPainter unusedPainter(&metatilesPixmap);
unusedPainter.setOpacity(0.5);
int primaryLength = this->primaryTileset->metatiles.length();
int length_ = primaryLength + this->secondaryTileset->metatiles.length();
int primaryLength = this->primaryTileset->numMetatiles();
int length_ = primaryLength + this->secondaryTileset->numMetatiles();
for (int i = 0; i < length_; i++) {
int tile = i;
@ -271,8 +271,8 @@ void TilesetEditorMetatileSelector::drawCounts() {
whitePen.setWidth(1);
countPainter.setPen(whitePen);
int primaryLength = this->primaryTileset->metatiles.length();
int length_ = primaryLength + this->secondaryTileset->metatiles.length();
int primaryLength = this->primaryTileset->numMetatiles();
int length_ = primaryLength + this->secondaryTileset->numMetatiles();
for (int i = 0; i < length_; i++) {
int tile = i;

View file

@ -82,6 +82,7 @@ void WildMonChart::clearTableData() {
ui->comboBox_Species->clear();
ui->comboBox_Group->clear();
ui->comboBox_Group->setEnabled(false);
ui->label_Group->setEnabled(false);
}
// Extract all the data from the table that we need for the charts
@ -152,7 +153,9 @@ void WildMonChart::readTable() {
ui->comboBox_Species->addItems(getSpeciesNamesAlphabetical());
ui->comboBox_Group->clear();
ui->comboBox_Group->addItems(this->groupNames);
ui->comboBox_Group->setEnabled(usesGroupLabels());
bool enableGroupSelection = usesGroupLabels();
ui->comboBox_Group->setEnabled(enableGroupSelection);
ui->label_Group->setEnabled(enableGroupSelection);
}
void WildMonChart::refresh() {
@ -438,23 +441,33 @@ void WildMonChart::limitChartAnimation() {
void WildMonChart::showHelpDialog() {
static const QString text = "This window provides some visualizations of the data in your current Wild Pokémon tab";
static const QString informative =
"The <b>Species Distribution</b> tab shows the cumulative encounter chance for each species "
// Describe the Species Distribution tab
static const QString speciesTabInfo =
"The <b>Species Distribution</b> tab shows the cumulative encounter chance for each species "
"in the table. In other words, it answers the question \"What is the likelihood of encountering "
"each species in a single encounter?\""
"<br><br>"
"each species in a single encounter?\"";
// Describe the Level Distribution tab
static const QString levelTabInfo =
"The <b>Level Distribution</b> tab shows the chance of encountering each species at a particular level. "
"In the top left under <b>Group</b> you can select which encounter group to show data for. "
"In the top right under <b>Species</b> you can select which species to show data for. "
"In the top right you can enable <b>Individual Mode</b>. When enabled data will be shown for only the selected species."
"<br><br>"
"<b>Individual Mode</b> on the <b>Level Distribution</b> tab toggles whether data is shown for all species in the table. "
"The percentages will update to reflect whether you're showing all species or just that individual species. "
"In other words, while <b>Individual Mode</b> is checked the chart is answering the question \"If a species x "
"is encountered, what is the likelihood that it will be level y\", and while <b>Individual Mode</b> is not checked, "
"it answers the question \"For a single encounter, what is the likelihood of encountering a species x at level y.\"";
QString informativeText;
if (ui->tabWidget->currentWidget() == ui->tabSpecies) {
informativeText = speciesTabInfo;
} else if (ui->tabWidget->currentWidget() == ui->tabLevels) {
informativeText = levelTabInfo;
}
QMessageBox msgBox(QMessageBox::Information, "porymap", text, QMessageBox::Close, this);
msgBox.setTextFormat(Qt::RichText);
msgBox.setInformativeText(informative);
msgBox.setInformativeText(informativeText);
msgBox.exec();
}