diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d9fd720..2dcd180e 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,10 @@ 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. +- 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 diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 602ff620..f403f198 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -2832,6 +2832,10 @@ Summary Chart... + + + :/icons/chart_bar.ico:/icons/chart_bar.ico + 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 c79b34a2..e69b2c40 100644 --- a/include/lib/fex/parser.h +++ b/include/lib/fex/parser.h @@ -22,7 +22,7 @@ namespace fex std::vector ParseTopLevelArrays(std::vector tokens); tsl::ordered_map ParseTopLevelObjects(std::vector tokens); - tsl::ordered_map ReadDefines(const std::string &filename, std::vector matching); + tsl::ordered_map ReadDefines(const QString &filename, std::vector matching); private: int EvaluateExpression(std::vector tokens); 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 5ba1e6e0..99489758 100644 --- a/porymap.pro +++ b/porymap.pro @@ -45,7 +45,6 @@ SOURCES += src/core/advancemapparser.cpp \ src/core/editcommands.cpp \ src/lib/fex/lexer.cpp \ src/lib/fex/parser.cpp \ - src/lib/fex/parser_util.cpp \ src/lib/collapsiblesection.cpp \ src/lib/orderedjson.cpp \ src/core/regionmapeditcommands.cpp \ @@ -157,7 +156,6 @@ HEADERS += include/core/advancemapparser.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/collapsiblesection.h \ include/lib/orderedmap.h \ include/lib/orderedjson.h \ diff --git a/resources/icons/chart_bar.ico b/resources/icons/chart_bar.ico new file mode 100755 index 00000000..a66163a4 Binary files /dev/null and b/resources/icons/chart_bar.ico differ 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 diff --git a/src/core/parseutil.cpp b/src/core/parseutil.cpp index 1aff9cd5..a4a2018d 100644 --- a/src/core/parseutil.cpp +++ b/src/core/parseutil.cpp @@ -596,7 +596,7 @@ bool ParseUtil::gameStringToBool(QString gameString, bool * ok) { tsl::ordered_map> 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 topLevelObjects = cParser.ParseTopLevelObjects(tokens); tsl::ordered_map> structs; for (auto it = topLevelObjects.begin(); it != topLevelObjects.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 1c010528..ce4a9bbb 100644 --- a/src/lib/fex/parser.cpp +++ b/src/lib/fex/parser.cpp @@ -337,7 +337,7 @@ namespace fex return DefineStatement(identifer, value); } - tsl::ordered_map Parser::ReadDefines(const std::string &filename, std::vector matching) + tsl::ordered_map Parser::ReadDefines(const QString &filename, std::vector matching) { tsl::ordered_map out; 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); } 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) {