mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-22 08:36:06 -05:00
Merge branch 'master' of https://github.com/huderlem/porymap into slam
This commit is contained in:
65
include/core/filedialog.h
Normal file
65
include/core/filedialog.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef FILEDIALOG_H
|
||||
#define FILEDIALOG_H
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
/*
|
||||
Static QFileDialog functions will (unless otherwise specified) use native file dialogs.
|
||||
In general this is good (we want our file dialogs to be visually seamless) but unfortunately
|
||||
the native file dialogs ignore the parent widget, so in some cases they'll return focus to
|
||||
the main window rather than the window that opened the file dialog.
|
||||
|
||||
To make working around this a little easier we use this class, which will use the native
|
||||
file dialog and manually return focus to the parent widget.
|
||||
|
||||
It will also save the directory of the previous file selected in a file dialog, and if
|
||||
no 'dir' argument is specified it will open new dialogs at that directory.
|
||||
|
||||
*/
|
||||
|
||||
class FileDialog : public QFileDialog
|
||||
{
|
||||
public:
|
||||
FileDialog(QWidget *parent, Qt::WindowFlags flags) : QFileDialog(parent, flags) {};
|
||||
FileDialog(QWidget *parent = nullptr,
|
||||
const QString &caption = QString(),
|
||||
const QString &directory = QString(),
|
||||
const QString &filter = QString()) : QFileDialog(parent, caption, directory, filter) {};
|
||||
|
||||
static void setDirectory(const QString &dir) { FileDialog::prevDirectory = dir; }
|
||||
static QString getDirectory() { return FileDialog::prevDirectory; }
|
||||
|
||||
static QString getOpenFileName(QWidget *parent = nullptr,
|
||||
const QString &caption = QString(),
|
||||
const QString &dir = QString(),
|
||||
const QString &filter = QString(),
|
||||
QString *selectedFilter = nullptr,
|
||||
QFileDialog::Options options = Options());
|
||||
|
||||
static QStringList getOpenFileNames(QWidget *parent = nullptr,
|
||||
const QString &caption = QString(),
|
||||
const QString &dir = QString(),
|
||||
const QString &filter = QString(),
|
||||
QString *selectedFilter = nullptr,
|
||||
QFileDialog::Options options = Options());
|
||||
|
||||
static QString getExistingDirectory(QWidget *parent = nullptr,
|
||||
const QString &caption = QString(),
|
||||
const QString &dir = QString(),
|
||||
QFileDialog::Options options = ShowDirsOnly);
|
||||
|
||||
static QString getSaveFileName(QWidget *parent = nullptr,
|
||||
const QString &caption = QString(),
|
||||
const QString &dir = QString(),
|
||||
const QString &filter = QString(),
|
||||
QString *selectedFilter = nullptr,
|
||||
QFileDialog::Options options = Options());
|
||||
|
||||
private:
|
||||
static QString prevDirectory;
|
||||
static QString getDirectoryFromInput(const QString &dir);
|
||||
static void setDirectoryFromFile(const QString &fileName);
|
||||
static void restoreFocus(QWidget *parent);
|
||||
};
|
||||
|
||||
#endif // FILEDIALOG_H
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "collisionpixmapitem.h"
|
||||
#include "layoutpixmapitem.h"
|
||||
#include "settings.h"
|
||||
#include "gridsettings.h"
|
||||
#include "movablerect.h"
|
||||
#include "cursortilerect.h"
|
||||
#include "mapruler.h"
|
||||
@@ -54,6 +55,7 @@ public:
|
||||
QUndoGroup editGroup; // Manages the undo history for each map
|
||||
|
||||
Settings *settings;
|
||||
GridSettings gridSettings;
|
||||
|
||||
void setProject(Project * project);
|
||||
void save();
|
||||
@@ -83,6 +85,7 @@ public:
|
||||
void displayMapConnections();
|
||||
void displayMapBorder();
|
||||
void displayMapGrid();
|
||||
void updateMapGrid();
|
||||
void displayWildMonTables();
|
||||
|
||||
void updateMapBorder();
|
||||
@@ -132,7 +135,7 @@ public:
|
||||
QGraphicsItemGroup *events_group = nullptr;
|
||||
|
||||
QList<QGraphicsPixmapItem*> borderItems;
|
||||
QList<QGraphicsLineItem*> gridLines;
|
||||
QGraphicsItemGroup *mapGrid = nullptr;
|
||||
MapRuler *map_ruler = nullptr;
|
||||
|
||||
MovableRect *playerViewRect = nullptr;
|
||||
@@ -197,6 +200,7 @@ public slots:
|
||||
void maskNonVisibleConnectionTiles();
|
||||
void onBorderMetatilesChanged();
|
||||
void selectedEventIndexChanged(int index, Event::Group eventGroup);
|
||||
void toggleGrid(bool);
|
||||
|
||||
private:
|
||||
const QImage defaultCollisionImgSheet = QImage(":/images/collisions.png");
|
||||
@@ -251,7 +255,6 @@ private slots:
|
||||
void onHoveredMapMovementPermissionCleared();
|
||||
void onSelectedMetatilesChanged();
|
||||
void onWheelZoom(int);
|
||||
void onToggleGridClicked(bool);
|
||||
|
||||
signals:
|
||||
void objectsChanged();
|
||||
@@ -263,6 +266,7 @@ signals:
|
||||
void currentMetatilesSelectionChanged();
|
||||
void mapRulerStatusChanged(const QString &);
|
||||
void tilesetUpdated(QString);
|
||||
void gridToggled(bool);
|
||||
};
|
||||
|
||||
#endif // EDITOR_H
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "shortcutseditor.h"
|
||||
#include "preferenceeditor.h"
|
||||
#include "projectsettingseditor.h"
|
||||
#include "gridsettings.h"
|
||||
#include "customscriptseditor.h"
|
||||
#include "wildmonchart.h"
|
||||
#include "updatepromoter.h"
|
||||
@@ -326,6 +327,8 @@ private slots:
|
||||
void on_actionProject_Settings_triggered();
|
||||
void on_actionCustom_Scripts_triggered();
|
||||
void reloadScriptEngine();
|
||||
void on_actionShow_Grid_triggered();
|
||||
void on_actionGrid_Settings_triggered();
|
||||
|
||||
public:
|
||||
Ui::MainWindow *ui;
|
||||
@@ -340,6 +343,7 @@ private:
|
||||
QPointer<NewMapPopup> newMapPrompt = nullptr;
|
||||
QPointer<PreferenceEditor> preferenceEditor = nullptr;
|
||||
QPointer<ProjectSettingsEditor> projectSettingsEditor = nullptr;
|
||||
QPointer<GridSettingsDialog> gridSettingsDialog = nullptr;
|
||||
QPointer<CustomScriptsEditor> customScriptsEditor = nullptr;
|
||||
|
||||
FilterChildrenProxyModel *groupListProxyModel;
|
||||
|
||||
@@ -77,7 +77,6 @@ public:
|
||||
QFileSystemWatcher fileWatcher;
|
||||
QMap<QString, qint64> modifiedFileTimestamps;
|
||||
bool usingAsmTilesets;
|
||||
QString importExportPath;
|
||||
QSet<QString> disabledSettingsNames;
|
||||
int pokemonMinLevel;
|
||||
int pokemonMaxLevel;
|
||||
@@ -227,7 +226,6 @@ public:
|
||||
QString buildMetatileLabelsText(const QMap<QString, uint16_t> defines);
|
||||
QString findMetatileLabelsTileset(QString label);
|
||||
|
||||
void setImportExportPath(QString filename);
|
||||
static QString getExistingFilepath(QString filepath);
|
||||
void applyParsedLimits();
|
||||
|
||||
|
||||
46
include/ui/colorinputwidget.h
Normal file
46
include/ui/colorinputwidget.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef COLORINPUTWIDGET_H
|
||||
#define COLORINPUTWIDGET_H
|
||||
|
||||
#include <QGroupBox>
|
||||
#include <QValidator>
|
||||
|
||||
namespace Ui {
|
||||
class ColorInputWidget;
|
||||
}
|
||||
|
||||
|
||||
class ColorInputWidget : public QGroupBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ColorInputWidget(QWidget *parent = nullptr);
|
||||
explicit ColorInputWidget(const QString &title, QWidget *parent = nullptr);
|
||||
~ColorInputWidget();
|
||||
|
||||
void setColor(QRgb color);
|
||||
QRgb color() const { return m_color; }
|
||||
|
||||
bool setBitDepth(int bits);
|
||||
int bitDepth() const { return m_bitDepth; }
|
||||
|
||||
signals:
|
||||
void colorChanged(QRgb color);
|
||||
void bitDepthChanged(int bits);
|
||||
void editingFinished();
|
||||
|
||||
private:
|
||||
Ui::ColorInputWidget *ui;
|
||||
|
||||
QRgb m_color = 0;
|
||||
int m_bitDepth = 0;
|
||||
|
||||
void init();
|
||||
void updateColorUi();
|
||||
void pickColor();
|
||||
void blockEditSignals(bool block);
|
||||
|
||||
void setRgbFromSliders();
|
||||
void setRgbFromSpinners();
|
||||
void setRgbFromHexString(const QString &);
|
||||
};
|
||||
|
||||
#endif // COLORINPUTWIDGET_H
|
||||
@@ -31,7 +31,6 @@ private:
|
||||
Ui::CustomScriptsEditor *ui;
|
||||
|
||||
bool hasUnsavedChanges = false;
|
||||
QString fileDialogDir;
|
||||
const QString baseDir;
|
||||
|
||||
void displayScript(const QString &filepath, bool enabled);
|
||||
|
||||
99
include/ui/gridsettings.h
Normal file
99
include/ui/gridsettings.h
Normal file
@@ -0,0 +1,99 @@
|
||||
#ifndef GRIDSETTINGS_H
|
||||
#define GRIDSETTINGS_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QAbstractButton>
|
||||
|
||||
class GridSettings {
|
||||
public:
|
||||
explicit GridSettings() {};
|
||||
~GridSettings() {};
|
||||
|
||||
enum Style {
|
||||
Solid,
|
||||
LargeDashes,
|
||||
SmallDashes,
|
||||
Crosshairs,
|
||||
Dots,
|
||||
};
|
||||
|
||||
uint width = 16;
|
||||
uint height = 16;
|
||||
int offsetX = 0;
|
||||
int offsetY = 0;
|
||||
Style style = Style::Solid;
|
||||
QColor color = Qt::black;
|
||||
QVector<qreal> getHorizontalDashPattern() const { return this->getDashPattern(this->width); }
|
||||
QVector<qreal> getVerticalDashPattern() const { return this->getDashPattern(this->height); }
|
||||
|
||||
static QString getStyleName(Style style);
|
||||
static GridSettings::Style getStyleFromName(const QString &name);
|
||||
private:
|
||||
static const QMap<Style, QString> styleToName;
|
||||
|
||||
QVector<qreal> getCenteredDashPattern(uint length, qreal dashLength, qreal gapLength) const;
|
||||
QVector<qreal> getDashPattern(uint length) const;
|
||||
};
|
||||
|
||||
inline bool operator==(const GridSettings &a, const GridSettings &b) {
|
||||
return a.width == b.width
|
||||
&& a.height == b.height
|
||||
&& a.offsetX == b.offsetX
|
||||
&& a.offsetY == b.offsetY
|
||||
&& a.style == b.style
|
||||
&& a.color == b.color;
|
||||
}
|
||||
|
||||
inline bool operator!=(const GridSettings &a, const GridSettings &b) {
|
||||
return !(operator==(a, b));
|
||||
}
|
||||
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class GridSettingsDialog;
|
||||
}
|
||||
|
||||
class GridSettingsDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GridSettingsDialog(QWidget *parent = nullptr);
|
||||
explicit GridSettingsDialog(GridSettings *settings, QWidget *parent = nullptr);
|
||||
~GridSettingsDialog();
|
||||
|
||||
void setSettings(const GridSettings &settings);
|
||||
GridSettings settings() const { return *m_settings; }
|
||||
|
||||
void setDefaultSettings(const GridSettings &settings);
|
||||
GridSettings defaultSettings() const { return m_defaultSettings; }
|
||||
|
||||
signals:
|
||||
void changedGridSettings();
|
||||
|
||||
private:
|
||||
Ui::GridSettingsDialog *ui;
|
||||
GridSettings *const m_settings;
|
||||
const GridSettings m_originalSettings;
|
||||
GridSettings m_defaultSettings;
|
||||
bool m_dimensionsLinked = true;
|
||||
bool m_offsetsLinked = true;
|
||||
bool m_ownedSettings = false;
|
||||
|
||||
void init();
|
||||
void updateInput();
|
||||
void setWidth(int value);
|
||||
void setHeight(int value);
|
||||
void setOffsetX(int value);
|
||||
void setOffsetY(int value);
|
||||
|
||||
private slots:
|
||||
void dialogButtonClicked(QAbstractButton *button);
|
||||
void on_spinBox_Width_valueChanged(int value);
|
||||
void on_spinBox_Height_valueChanged(int value);
|
||||
void on_spinBox_X_valueChanged(int value);
|
||||
void on_spinBox_Y_valueChanged(int value);
|
||||
void on_comboBox_Style_currentTextChanged(const QString &text);
|
||||
void onColorChanged(QRgb color);
|
||||
};
|
||||
|
||||
#endif // GRIDSETTINGS_H
|
||||
@@ -16,6 +16,24 @@ enum ImageExporterMode {
|
||||
Timelapse,
|
||||
};
|
||||
|
||||
struct ImageExporterSettings {
|
||||
bool showObjects = false;
|
||||
bool showWarps = false;
|
||||
bool showBGs = false;
|
||||
bool showTriggers = false;
|
||||
bool showHealLocations = false;
|
||||
bool showUpConnections = false;
|
||||
bool showDownConnections = false;
|
||||
bool showLeftConnections = false;
|
||||
bool showRightConnections = false;
|
||||
bool showGrid = false;
|
||||
bool showBorder = false;
|
||||
bool showCollision = false;
|
||||
bool previewActualSize = false;
|
||||
int timelapseSkipAmount = 1;
|
||||
int timelapseDelayMs = 200;
|
||||
};
|
||||
|
||||
class MapImageExporter : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -34,50 +52,44 @@ private:
|
||||
|
||||
QPixmap preview;
|
||||
|
||||
bool showObjects = false;
|
||||
bool showWarps = false;
|
||||
bool showBGs = false;
|
||||
bool showTriggers = false;
|
||||
bool showHealSpots = false;
|
||||
bool showUpConnections = false;
|
||||
bool showDownConnections = false;
|
||||
bool showLeftConnections = false;
|
||||
bool showRightConnections = false;
|
||||
bool showGrid = false;
|
||||
bool showBorder = false;
|
||||
bool showCollision = false;
|
||||
int timelapseSkipAmount = 1;
|
||||
int timelapseDelayMs = 200;
|
||||
ImageExporterSettings settings;
|
||||
ImageExporterMode mode = ImageExporterMode::Normal;
|
||||
|
||||
void updatePreview();
|
||||
void scalePreview();
|
||||
void updateShowBorderState();
|
||||
void saveImage();
|
||||
QPixmap getStitchedImage(QProgressDialog *progress, bool includeBorder);
|
||||
QPixmap getFormattedMapPixmap(Map *map, bool ignoreBorder = false);
|
||||
bool historyItemAppliesToFrame(const QUndoCommand *command);
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *) override;
|
||||
virtual void resizeEvent(QResizeEvent *) override;
|
||||
|
||||
private slots:
|
||||
void on_checkBox_Objects_stateChanged(int state);
|
||||
void on_checkBox_Warps_stateChanged(int state);
|
||||
void on_checkBox_BGs_stateChanged(int state);
|
||||
void on_checkBox_Triggers_stateChanged(int state);
|
||||
void on_checkBox_HealSpots_stateChanged(int state);
|
||||
void on_checkBox_HealLocations_stateChanged(int state);
|
||||
void on_checkBox_AllEvents_stateChanged(int state);
|
||||
|
||||
void on_checkBox_ConnectionUp_stateChanged(int state);
|
||||
void on_checkBox_ConnectionDown_stateChanged(int state);
|
||||
void on_checkBox_ConnectionLeft_stateChanged(int state);
|
||||
void on_checkBox_ConnectionRight_stateChanged(int state);
|
||||
void on_checkBox_AllConnections_stateChanged(int state);
|
||||
|
||||
void on_checkBox_Elevation_stateChanged(int state);
|
||||
void on_checkBox_Grid_stateChanged(int state);
|
||||
void on_checkBox_Border_stateChanged(int state);
|
||||
|
||||
void on_pushButton_Save_pressed();
|
||||
void on_pushButton_Reset_pressed();
|
||||
void on_pushButton_Cancel_pressed();
|
||||
void on_spinBox_TimelapseDelay_valueChanged(int delayMs);
|
||||
void on_spinBox_FrameSkip_valueChanged(int skip);
|
||||
|
||||
void on_checkBox_ActualSize_stateChanged(int state);
|
||||
};
|
||||
|
||||
#endif // MAPIMAGEEXPORTER_H
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
#define PALETTEEDITOR_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QValidator>
|
||||
#include <QSlider>
|
||||
#include <QFrame>
|
||||
#include <QLabel>
|
||||
|
||||
#include "colorinputwidget.h"
|
||||
#include "project.h"
|
||||
#include "history.h"
|
||||
|
||||
@@ -32,43 +30,27 @@ public:
|
||||
private:
|
||||
Ui::PaletteEditor *ui;
|
||||
Project *project = nullptr;
|
||||
|
||||
QList<QList<QSlider*>> sliders;
|
||||
QList<QList<QSpinBox *>> spinners;
|
||||
QList<QFrame*> frames;
|
||||
QList<QToolButton *> pickButtons;
|
||||
QList<QLineEdit *> hexEdits;
|
||||
QList<ColorInputWidget*> colorInputs;
|
||||
|
||||
Tileset *primaryTileset;
|
||||
Tileset *secondaryTileset;
|
||||
|
||||
QList<History<PaletteHistoryItem*>> palettesHistory;
|
||||
|
||||
void refreshColorUis();
|
||||
void updateColorUi(int index, QRgb color);
|
||||
void commitEditHistory(int paletteid);
|
||||
Tileset* getTileset(int paletteId);
|
||||
void refreshColorInputs();
|
||||
void commitEditHistory();
|
||||
void commitEditHistory(int paletteId);
|
||||
void restoreWindowState();
|
||||
void setSignalsEnabled(bool enabled);
|
||||
void setColorsFromHistory(PaletteHistoryItem*, int);
|
||||
void closeEvent(QCloseEvent*);
|
||||
void pickColor(int i);
|
||||
|
||||
void setRgb(int index, QRgb rgb);
|
||||
void setRgbFromSliders(int colorIndex);
|
||||
void setRgbFromHexEdit(int colorIndex);
|
||||
void setRgbFromSpinners(int colorIndex);
|
||||
void setPalette(int paletteId, const QList<QRgb> &palette);
|
||||
|
||||
void setBitDepth(int bits);
|
||||
int bitDepth = 24;
|
||||
|
||||
class HexCodeValidator : public QValidator {
|
||||
virtual QValidator::State validate(QString &input, int &) const override {
|
||||
input = input.toUpper();
|
||||
return QValidator::Acceptable;
|
||||
}
|
||||
};
|
||||
|
||||
HexCodeValidator *hexValidator = nullptr;
|
||||
static const int numColors = 16;
|
||||
|
||||
signals:
|
||||
void closed();
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "orderedjson.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QFileDialog>
|
||||
|
||||
class Project;
|
||||
|
||||
@@ -33,7 +32,7 @@ private:
|
||||
|
||||
void hideMessages();
|
||||
|
||||
QString browse(QString filter, QFileDialog::FileMode mode);
|
||||
QString browse(QString filter);
|
||||
|
||||
private slots:
|
||||
void on_browse_tilesetImagePath_clicked();
|
||||
|
||||
@@ -69,7 +69,7 @@ private:
|
||||
void applySpeciesColors(const QList<QBarSet*> &);
|
||||
QChart::ChartTheme currentTheme() const;
|
||||
void updateTheme();
|
||||
void limitChartAnimation(QChart*);
|
||||
void limitChartAnimation();
|
||||
|
||||
void showHelpDialog();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user