From 0a87f7b9451b257d3d918616320fd1732facb8fe Mon Sep 17 00:00:00 2001 From: garak Date: Tue, 12 Nov 2024 13:08:46 -0500 Subject: [PATCH 1/8] update changelog after #515 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d9fd720..f92f02b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,11 +9,14 @@ The **"Breaking Changes"** listed below are changes that have been made in the d ## [Unreleased] ### Added - Redesigned the Connections tab, adding a number of new features including the option to open or display diving maps and a list UI for easier edit access. +- Add the ability to edit layouts with no corresponding map. - Add a `Close Project` option - Add charts to the `Wild Pokémon` tab that show species and level distributions. - Add options for customizing the map grid under `View -> Grid Settings`. - An alert will be displayed when attempting to open a seemingly invalid project. - Add support for defining project values with `enum` where `#define` was expected. +- Add button to enable editing map groups including renaming groups and rearranging the maps within them. +- Add buttons to hide and show empty folders in each map tree view. ### Changed - Edits to map connections now have Undo/Redo and can be viewed in exported timelapses. @@ -24,6 +27,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - It's now possible to cancel quitting if there are unsaved changes in sub-windows. - The triple-layer metatiles setting can now be set automatically using a project constant. - `Export Map Stitch Image` now shows a preview of the full image, not just the current map. +- Maps and layouts were internally separated. ### Fixed - Fix `Add Region Map...` not updating the region map settings file. @@ -52,6 +56,8 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Stop sliders in the Palette Editor from creating a bunch of edit history when used. - Fix scrolling on some containers locking up when the mouse stops over a spin box or combo box. - Fix some file dialogs returning to an incorrect window when closed. +- Fix bug where reloading a layout would overwrite all unsaved changes. +- Fix bug where layout json and blockdata could be saved separately leading to inconsistent data. ## [5.4.1] - 2024-03-21 ### Fixed From d3a34cf5fc448eab23a13b5268eb88db276bf4a5 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 19 Nov 2024 21:18:55 -0500 Subject: [PATCH 2/8] Fix scrolling over UIntSpinBox --- src/ui/uintspinbox.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ui/uintspinbox.cpp b/src/ui/uintspinbox.cpp index 789a1662..53f6df78 100644 --- a/src/ui/uintspinbox.cpp +++ b/src/ui/uintspinbox.cpp @@ -1,4 +1,5 @@ #include "uintspinbox.h" +#include UIntSpinBox::UIntSpinBox(QWidget *parent) : QAbstractSpinBox(parent) @@ -178,8 +179,11 @@ QAbstractSpinBox::StepEnabled UIntSpinBox::stepEnabled() const { void UIntSpinBox::wheelEvent(QWheelEvent *event) { // Only allow scrolling to modify contents when it explicitly has focus. - if (hasFocus()) + if (hasFocus()) { QAbstractSpinBox::wheelEvent(event); + } else { + event->ignore(); + } } void UIntSpinBox::focusOutEvent(QFocusEvent *event) { From 7eafae8cf7123fe6ee759bdf76a83d56eb11f931 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 22 Nov 2024 23:13:26 -0500 Subject: [PATCH 3/8] Fix map grid not clipping in layout-only mode --- src/ui/graphicsview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/graphicsview.cpp b/src/ui/graphicsview.cpp index a9761139..73827211 100644 --- a/src/ui/graphicsview.cpp +++ b/src/ui/graphicsview.cpp @@ -46,9 +46,9 @@ void MapView::drawForeground(QPainter *painter, const QRectF&) { // Draw map grid if (editor->mapGrid && editor->mapGrid->isVisible()) { painter->save(); - if (editor->map) { + if (editor->layout) { // We're clipping here to hide parts of the grid that are outside the map. - const QRectF mapRect(-0.5, -0.5, editor->map->getWidth() * 16 + 1.5, editor->map->getHeight() * 16 + 1.5); + const QRectF mapRect(-0.5, -0.5, editor->layout->getWidth() * 16 + 1.5, editor->layout->getHeight() * 16 + 1.5); painter->setClipping(true); painter->setClipRect(mapRect); } From 59c525e9fe511936e06cb7d6361e4db69e8a4203 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 23 Nov 2024 14:39:01 -0500 Subject: [PATCH 4/8] Add icon for Summary Chart button --- forms/mainwindow.ui | 4 ++++ resources/icons/chart_bar.ico | Bin 0 -> 1049 bytes resources/images.qrc | 1 + 3 files changed, 5 insertions(+) create mode 100755 resources/icons/chart_bar.ico diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 44d69d30..6a373edc 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -3028,6 +3028,10 @@ Summary Chart... + + + :/icons/chart_bar.ico:/icons/chart_bar.ico + diff --git a/resources/icons/chart_bar.ico b/resources/icons/chart_bar.ico new file mode 100755 index 0000000000000000000000000000000000000000..a66163a4381f1330ea1c0a01f37073b85cf53076 GIT binary patch literal 1049 zcmV+!1m^pRP)?9f9=W?@Hkof`zWHVmw!X}plSf`^>lVp%Z$JfLwOT&??&CSWEw=R082~JZ z^JAATZn|mZ$LvhiWhQ1^vjIR!gJZv{WE|E?!1rR?dhGw20mm6o z>|Cj42IQV?ifFz7&w#e491Vv$G*Aj$wn-;POGbO4ZlNe7!Rb*%&u0AvnST_72V0XS?AYSR?i z9E4x3iDpV0K-C2%0H_0X6L;Kvkgzl-%_4zQrL7ZyJhqs3H>M7@Sc;=cReTh=%{bpC z&OosBXF$@dy8(DxS&(uVp=#-T{r}WwfMON*JgB!~1AxUpzTT}fkST3?5^VLPfDI zLX!Zdk*UxHx&uIO21*X(n{XhX6rdLXVbBTi8HfRRaH1id08pab0O=iy+DD#=jkV1` zP+G;@pJpd0UdC#v;-Mmk5uT#9R_7@IalEj`b%R#ggoKo?@d;udc)iuS_rQ=z3-Y8N z4|n?`S`#8OU?G8#+0|&@^v1PYxlF-=2ZD3hj!q7|#)6d#t)B^<=LLSn@L?n=a!_^* zNbU2S5L5|?RRZ@PKFY+)kgr309S|_EGfPC}D_^S^oDRz(?C2Wv^$Y&@`YXTyvmIbY TYF0c_00000NkvXXu0mjfiDAtd literal 0 HcmV?d00001 diff --git a/resources/images.qrc b/resources/images.qrc index a89535a9..888c5d9d 100644 --- a/resources/images.qrc +++ b/resources/images.qrc @@ -1,6 +1,7 @@ icons/add.ico + icons/chart_bar.ico icons/collapse_all.ico icons/cursor.ico icons/delete.ico From c2cf3cc9c781faae1ba0851ddc28a35c7946ba79 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 4 Dec 2024 15:41:29 -0500 Subject: [PATCH 5/8] Fix tileset palette saving crash --- CHANGELOG.md | 1 + src/project.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f92f02b4..11e4696d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Fix some file dialogs returning to an incorrect window when closed. - Fix bug where reloading a layout would overwrite all unsaved changes. - Fix bug where layout json and blockdata could be saved separately leading to inconsistent data. +- Fix crash when saving tilesets with fewer palettes than the maximum. ## [5.4.1] - 2024-03-21 ### Fixed diff --git a/src/project.cpp b/src/project.cpp index 88e3d9d1..43b62ecf 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -1130,7 +1130,8 @@ void Project::saveTilesetTilesImage(Tileset *tileset) { } void Project::saveTilesetPalettes(Tileset *tileset) { - for (int i = 0; i < Project::getNumPalettesTotal(); i++) { + int numPalettes = qMin(tileset->palettePaths.length(), tileset->palettes.length()); + for (int i = 0; i < numPalettes; i++) { QString filepath = tileset->palettePaths.at(i); PaletteUtil::writeJASC(filepath, tileset->palettes.at(i).toVector(), 0, 16); } From 11dd7306d32fb897a108c34c41c1860044b94c26 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 11 Dec 2024 01:01:00 -0500 Subject: [PATCH 6/8] Remove unused parser_util --- include/lib/fex/parser_util.h | 19 ------------- porymap.pro | 2 -- src/lib/fex/parser_util.cpp | 50 ----------------------------------- 3 files changed, 71 deletions(-) delete mode 100644 include/lib/fex/parser_util.h delete mode 100644 src/lib/fex/parser_util.cpp diff --git a/include/lib/fex/parser_util.h b/include/lib/fex/parser_util.h deleted file mode 100644 index 58ff89fc..00000000 --- a/include/lib/fex/parser_util.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef PARSER_UTIL_H -#define PARSER_UTIL_H - -#include -#include - -class ParserUtil -{ -public: - ParserUtil(QString root); - QStringList ReadDefines(QString filename, QString prefix); - QStringList ReadDefinesValueSort(QString filename, QString prefix); - -private: - QString root_; -}; - - -#endif // PARSER_UTIL_H diff --git a/porymap.pro b/porymap.pro index 1b1c693e..5734fd73 100644 --- a/porymap.pro +++ b/porymap.pro @@ -44,7 +44,6 @@ SOURCES += src/core/block.cpp \ src/core/editcommands.cpp \ src/lib/fex/lexer.cpp \ src/lib/fex/parser.cpp \ - src/lib/fex/parser_util.cpp \ src/lib/orderedjson.cpp \ src/core/regionmapeditcommands.cpp \ src/scriptapi/apimap.cpp \ @@ -150,7 +149,6 @@ HEADERS += include/core/block.h \ include/lib/fex/define_statement.h \ include/lib/fex/lexer.h \ include/lib/fex/parser.h \ - include/lib/fex/parser_util.h \ include/lib/orderedmap.h \ include/lib/orderedjson.h \ include/ui/aboutporymap.h \ diff --git a/src/lib/fex/parser_util.cpp b/src/lib/fex/parser_util.cpp deleted file mode 100644 index 0f375b81..00000000 --- a/src/lib/fex/parser_util.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "lib/fex/parser_util.h" - -#include - -#include "lib/fex/parser.h" - -ParserUtil::ParserUtil(QString root): root_(root) {} - -QStringList ParserUtil::ReadDefines(QString filename, QString prefix) -{ - if (filename.isEmpty()) { - return QStringList(); - } - - QString filepath = root_ + "/" + filename; - - fex::Parser parser; - - std::vector match_list = { prefix.toStdString() + ".*" }; - std::map defines = parser.ReadDefines(filepath.toStdString(), match_list); - - QStringList out; - for(auto const& define : defines) { - out.append(QString::fromStdString(define.first)); - } - - return out; -} - -QStringList ParserUtil::ReadDefinesValueSort(QString filename, QString prefix) -{ - - if (filename.isEmpty()) { - return QStringList(); - } - - QString filepath = root_ + "/" + filename; - - fex::Parser parser; - - std::vector match_list = { prefix.toStdString() + ".*" }; - std::map defines = parser.ReadDefines(filepath.toStdString(), match_list); - - QMultiMap defines_keyed_by_value; - for (const auto& pair : defines) { - defines_keyed_by_value.insert(pair.second, QString::fromStdString(pair.first)); - } - - return defines_keyed_by_value.values(); -} From 6b70abaaf0c74a46a8e92fbf32be09fe92cd4f2d Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 11 Dec 2024 09:00:51 -0500 Subject: [PATCH 7/8] Use QFile/QString for C parser files and paths --- include/lib/fex/lexer.h | 5 ++--- include/lib/fex/parser.h | 2 +- src/core/parseutil.cpp | 2 +- src/lib/fex/lexer.cpp | 39 +++++++++------------------------------ src/lib/fex/parser.cpp | 2 +- 5 files changed, 14 insertions(+), 36 deletions(-) diff --git a/include/lib/fex/lexer.h b/include/lib/fex/lexer.h index 9b22976d..d4d65271 100644 --- a/include/lib/fex/lexer.h +++ b/include/lib/fex/lexer.h @@ -4,6 +4,7 @@ #include #include #include +#include namespace fex { @@ -89,9 +90,7 @@ namespace fex Lexer() = default; ~Lexer() = default; - std::vector LexFile(const std::string &path); - std::vector LexString(const std::string &data); - void LexFileDumpTokens(const std::string &path, const std::string &out); + std::vector LexFile(const QString &path); private: std::vector Lex(); diff --git a/include/lib/fex/parser.h b/include/lib/fex/parser.h index 6a6b9e43..b73dd81e 100644 --- a/include/lib/fex/parser.h +++ b/include/lib/fex/parser.h @@ -21,7 +21,7 @@ namespace fex std::vector ParseTopLevelArrays(std::vector tokens); std::map ParseTopLevelObjects(std::vector tokens); - std::map ReadDefines(const std::string &filename, std::vector matching); + std::map ReadDefines(const QString &filename, std::vector matching); private: int EvaluateExpression(std::vector tokens); diff --git a/src/core/parseutil.cpp b/src/core/parseutil.cpp index 9664fdc7..2c357776 100644 --- a/src/core/parseutil.cpp +++ b/src/core/parseutil.cpp @@ -596,7 +596,7 @@ bool ParseUtil::gameStringToBool(QString gameString, bool * ok) { QMap> ParseUtil::readCStructs(const QString &filename, const QString &label, const QHash memberMap) { QString filePath = this->root + "/" + filename; auto cParser = fex::Parser(); - auto tokens = fex::Lexer().LexFile(filePath.toStdString()); + auto tokens = fex::Lexer().LexFile(filePath); auto structs = cParser.ParseTopLevelObjects(tokens); QMap> structMaps; for (auto it = structs.begin(); it != structs.end(); it++) { diff --git a/src/lib/fex/lexer.cpp b/src/lib/fex/lexer.cpp index 2dd4b249..e8545f2e 100644 --- a/src/lib/fex/lexer.cpp +++ b/src/lib/fex/lexer.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace fex { @@ -155,48 +156,26 @@ namespace fex return Token(Token::Type::kDefine, filename_, line_number_); } - std::vector Lexer::LexString(const std::string &data) + std::vector Lexer::LexFile(const QString &path) { - filename_ = "string literal"; - line_number_ = 1; - index_ = 0; - data_ = data; - - return Lex(); - } - - std::vector Lexer::LexFile(const std::string &path) - { - filename_ = path; + filename_ = path.toStdString(); line_number_ = 1; - std::ifstream file; - file.open(path); + // Note: Using QFile instead of ifstream to handle encoding differences between platforms + // (specifically to handle accented characters on Windows) + QFile file(path); + file.open(QIODevice::ReadOnly); - std::stringstream stream; - stream << file.rdbuf(); + const QByteArray data = file.readAll(); index_ = 0; - data_ = stream.str(); + data_ = data.toStdString(); file.close(); return Lex(); } - void Lexer::LexFileDumpTokens(const std::string &path, const std::string &out) - { - std::ofstream file; - file.open(out); - - for (Token token : LexFile(path)) - { - file << token.ToString() << std::endl; - } - - file.close(); - } - std::vector Lexer::Lex() { std::vector tokens; diff --git a/src/lib/fex/parser.cpp b/src/lib/fex/parser.cpp index bb5c90a8..2e2a6f3e 100644 --- a/src/lib/fex/parser.cpp +++ b/src/lib/fex/parser.cpp @@ -337,7 +337,7 @@ namespace fex return DefineStatement(identifer, value); } - std::map Parser::ReadDefines(const std::string &filename, std::vector matching) + std::map Parser::ReadDefines(const QString &filename, std::vector matching) { std::map out; From 8e6aa7888486d501f5dd29b0c4e441a6e6f8e90c Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 11 Dec 2024 23:24:52 -0500 Subject: [PATCH 8/8] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11e4696d..2dcd180e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Fix bug where reloading a layout would overwrite all unsaved changes. - Fix bug where layout json and blockdata could be saved separately leading to inconsistent data. - Fix crash when saving tilesets with fewer palettes than the maximum. +- Fix projects not opening on Windows if the project filepath contains certain characters. ## [5.4.1] - 2024-03-21 ### Fixed