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

This commit is contained in:
GriffinR
2024-10-16 22:29:03 -04:00
39 changed files with 2206 additions and 5929 deletions

View 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

View File

@@ -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
View 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

View File

@@ -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

View File

@@ -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();

View File

@@ -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();

View File

@@ -69,7 +69,7 @@ private:
void applySpeciesColors(const QList<QBarSet*> &);
QChart::ChartTheme currentTheme() const;
void updateTheme();
void limitChartAnimation(QChart*);
void limitChartAnimation();
void showHelpDialog();
};