Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/huderlem/porymap into new…
Browse files Browse the repository at this point in the history
…-map-dialog
  • Loading branch information
GriffinRichards committed Dec 16, 2024
2 parents 59464aa + 8e6aa78 commit 8f16822
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 60 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions forms/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2832,6 +2832,10 @@
<property name="text">
<string>Summary Chart...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<normaloff>:/icons/chart_bar.ico</normaloff>:/icons/chart_bar.ico</iconset>
</property>
</widget>
</item>
<item>
Expand Down
5 changes: 2 additions & 3 deletions include/lib/fex/lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cstdint>
#include <string>
#include <vector>
#include <QString>

namespace fex
{
Expand Down Expand Up @@ -89,9 +90,7 @@ namespace fex
Lexer() = default;
~Lexer() = default;

std::vector<Token> LexFile(const std::string &path);
std::vector<Token> LexString(const std::string &data);
void LexFileDumpTokens(const std::string &path, const std::string &out);
std::vector<Token> LexFile(const QString &path);

private:
std::vector<Token> Lex();
Expand Down
2 changes: 1 addition & 1 deletion include/lib/fex/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace fex
std::vector<Array> ParseTopLevelArrays(std::vector<Token> tokens);
tsl::ordered_map<std::string, ArrayValue> ParseTopLevelObjects(std::vector<Token> tokens);

tsl::ordered_map<std::string, int> ReadDefines(const std::string &filename, std::vector<std::string> matching);
tsl::ordered_map<std::string, int> ReadDefines(const QString &filename, std::vector<std::string> matching);

private:
int EvaluateExpression(std::vector<Token> tokens);
Expand Down
19 changes: 0 additions & 19 deletions include/lib/fex/parser_util.h

This file was deleted.

2 changes: 0 additions & 2 deletions porymap.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
Binary file added resources/icons/chart_bar.ico
Binary file not shown.
1 change: 1 addition & 0 deletions resources/images.qrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<RCC>
<qresource prefix="/">
<file>icons/add.ico</file>
<file>icons/chart_bar.ico</file>
<file>icons/collapse_all.ico</file>
<file>icons/cursor.ico</file>
<file>icons/delete.ico</file>
Expand Down
2 changes: 1 addition & 1 deletion src/core/parseutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ bool ParseUtil::gameStringToBool(QString gameString, bool * ok) {
tsl::ordered_map<QString, QHash<QString, QString>> ParseUtil::readCStructs(const QString &filename, const QString &label, const QHash<int, QString> &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<QString, QHash<QString, QString>> structs;
for (auto it = topLevelObjects.begin(); it != topLevelObjects.end(); it++) {
Expand Down
39 changes: 9 additions & 30 deletions src/lib/fex/lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <fstream>
#include <iostream>
#include <sstream>
#include <QFile>

namespace fex
{
Expand Down Expand Up @@ -155,48 +156,26 @@ namespace fex
return Token(Token::Type::kDefine, filename_, line_number_);
}

std::vector<Token> Lexer::LexString(const std::string &data)
std::vector<Token> Lexer::LexFile(const QString &path)
{
filename_ = "string literal";
filename_ = path.toStdString();
line_number_ = 1;
index_ = 0;
data_ = data;

return Lex();
}

std::vector<Token> Lexer::LexFile(const std::string &path)
{
filename_ = path;
line_number_ = 1;
// 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::ifstream file;
file.open(path);

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<Token> Lexer::Lex()
{
std::vector<Token> tokens;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/fex/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ namespace fex
return DefineStatement(identifer, value);
}

tsl::ordered_map<std::string, int> Parser::ReadDefines(const std::string &filename, std::vector<std::string> matching)
tsl::ordered_map<std::string, int> Parser::ReadDefines(const QString &filename, std::vector<std::string> matching)
{
tsl::ordered_map<std::string, int> out;

Expand Down
4 changes: 2 additions & 2 deletions src/ui/graphicsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 5 additions & 1 deletion src/ui/uintspinbox.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "uintspinbox.h"
#include <QWheelEvent>

UIntSpinBox::UIntSpinBox(QWidget *parent)
: QAbstractSpinBox(parent)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 8f16822

Please sign in to comment.