Add ability to export map stitch images.

This commit is contained in:
Marcus Huderle
2020-04-18 13:07:41 -05:00
committed by huderlem
parent 800d584eb5
commit bb6dbedabf
11 changed files with 275 additions and 57 deletions

View File

@@ -131,6 +131,8 @@ public:
void objectsView_onMouseMove(QMouseEvent *event);
void objectsView_onMouseRelease(QMouseEvent *event);
int getBorderDrawDistance(int dimension);
private:
void setConnectionItemsVisible(bool);
void setBorderItemsVisible(bool, qreal = 1);
@@ -147,7 +149,6 @@ private:
void updateMirroredConnectionMap(MapConnection*, QString);
void updateMirroredConnection(MapConnection*, QString, QString, bool isDelete = false);
void updateEncounterFields(EncounterFields newFields);
int getBorderDrawDistance(int dimension);
Event* createNewObjectEvent();
Event* createNewWarpEvent();
Event* createNewHealLocationEvent();

View File

@@ -62,6 +62,10 @@
#include <memory>
#include <initializer_list>
#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 1)
#include "qstringhash.h"
#endif
#include "orderedmap.h"
#ifdef _MSC_VER

View File

@@ -1640,7 +1640,7 @@ private:
* the erased element and all the ones after the erased element (including end()).
* Otherwise all the iterators are invalidated if an erase occurs.
*/
template<class Key,
template<class Key,
class T,
class Hash = std::hash<Key>,
class KeyEqual = std::equal_to<Key>,
@@ -2031,7 +2031,7 @@ public:
T& operator[](const Key& key) { return m_ht[key]; }
T& operator[](const Key& key) { return m_ht[key]; }
T& operator[](Key&& key) { return m_ht[std::move(key)]; }
@@ -2042,7 +2042,7 @@ public:
* Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same
* as hash_function()(key). Usefull to speed-up the lookup if you already have the hash.
*/
size_type count(const Key& key, std::size_t precalculated_hash) const {
size_type count(const Key& key, std::size_t precalculated_hash) const {
return m_ht.count(key, precalculated_hash);
}
@@ -2079,7 +2079,7 @@ public:
/**
* @copydoc find(const Key& key, std::size_t precalculated_hash)
*/
const_iterator find(const Key& key, std::size_t precalculated_hash) const {
const_iterator find(const Key& key, std::size_t precalculated_hash) const {
return m_ht.find(key, precalculated_hash);
}
@@ -2124,7 +2124,7 @@ public:
* Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same
* as hash_function()(key). Usefull to speed-up the lookup if you already have the hash.
*/
std::pair<iterator, iterator> equal_range(const Key& key, std::size_t precalculated_hash) {
std::pair<iterator, iterator> equal_range(const Key& key, std::size_t precalculated_hash) {
return m_ht.equal_range(key, precalculated_hash);
}
@@ -2133,7 +2133,7 @@ public:
/**
* @copydoc equal_range(const Key& key, std::size_t precalculated_hash)
*/
std::pair<const_iterator, const_iterator> equal_range(const Key& key, std::size_t precalculated_hash) const {
std::pair<const_iterator, const_iterator> equal_range(const Key& key, std::size_t precalculated_hash) const {
return m_ht.equal_range(key, precalculated_hash);
}

19
include/lib/qstringhash.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef QSTRINGHASH_H
#define QSTRINGHASH_H
#include <QHash>
#include <QString>
#include <functional>
// This is a custom hash function for QString so it can be used as
// a key in a std::hash structure. Qt 5.14 added this function, so
// this file should only be included in earlier versions.
namespace std {
template<> struct hash<QString> {
std::size_t operator()(const QString& s) const noexcept {
return static_cast<size_t>(qHash(s));
}
};
}
#endif // QSTRINGHASH_H

View File

@@ -109,6 +109,7 @@ private slots:
void currentMetatilesSelectionChanged();
void on_action_Export_Map_Image_triggered();
void on_actionExport_Stitched_Map_Image_triggered();
void on_comboBox_ConnectionDirection_currentIndexChanged(const QString &arg1);
void on_spinBox_ConnectionOffset_valueChanged(int offset);
@@ -219,6 +220,7 @@ private:
void closeSupplementaryWindows();
bool isProjectOpen();
void showExportMapImageWindow(bool stitchMode);
};
enum MapListUserRoles {

View File

@@ -15,7 +15,7 @@ class MapImageExporter : public QDialog
Q_OBJECT
public:
explicit MapImageExporter(QWidget *parent, Editor *editor);
explicit MapImageExporter(QWidget *parent, Editor *editor, bool stitchMode);
~MapImageExporter();
private:
@@ -39,9 +39,12 @@ private:
bool showGrid = false;
bool showBorder = false;
bool showCollision = false;
bool stitchMode = false;
void updatePreview();
void saveImage();
QPixmap getStitchedImage(QProgressDialog *progress, bool includeBorder);
QPixmap getFormattedMapPixmap(Map *map, bool ignoreBorder);
private slots:
void on_checkBox_Objects_stateChanged(int state);