code cleanup: finish rme update core
This commit is contained in:
parent
aeb56e579c
commit
c76f6a8049
6 changed files with 66 additions and 300 deletions
|
@ -62,8 +62,6 @@ public:
|
||||||
void save();
|
void save();
|
||||||
void saveTilemap();
|
void saveTilemap();
|
||||||
void saveLayout();
|
void saveLayout();
|
||||||
void saveConfig();// ? or do this in the editor only?
|
|
||||||
void saveOptions(int id, QString sec, QString name, int x, int y);
|
|
||||||
|
|
||||||
void resizeTilemap(int width, int height, bool update = true);
|
void resizeTilemap(int width, int height, bool update = true);
|
||||||
void resetSquare(int index);
|
void resetSquare(int index);
|
||||||
|
@ -93,12 +91,8 @@ public:
|
||||||
|
|
||||||
QString palPath();
|
QString palPath();
|
||||||
QString pngPath();
|
QString pngPath();
|
||||||
QString cityTilesPath();
|
|
||||||
QString entriesPath() { return this->entries_path; }
|
QString entriesPath() { return this->entries_path; }
|
||||||
|
|
||||||
QVector<uint8_t> getTiles();
|
|
||||||
void setTiles(QVector<uint8_t> tileIds);
|
|
||||||
|
|
||||||
QByteArray getTilemap();
|
QByteArray getTilemap();
|
||||||
void setTilemap(QByteArray newTilemap);
|
void setTilemap(QByteArray newTilemap);
|
||||||
|
|
||||||
|
@ -181,7 +175,6 @@ private:
|
||||||
bool layout_uses_layers = false;
|
bool layout_uses_layers = false;
|
||||||
QStringList layout_constants;
|
QStringList layout_constants;
|
||||||
QString layout_qualifiers;
|
QString layout_qualifiers;
|
||||||
QString layout_type;
|
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
QVector<shared_ptr<TilemapTile>> tilemap;
|
QVector<shared_ptr<TilemapTile>> tilemap;
|
||||||
|
|
|
@ -345,7 +345,7 @@ private:
|
||||||
QPointer<RegionMapEditor> regionMapEditor = nullptr;
|
QPointer<RegionMapEditor> regionMapEditor = nullptr;
|
||||||
QPointer<ShortcutsEditor> shortcutsEditor = nullptr;
|
QPointer<ShortcutsEditor> shortcutsEditor = nullptr;
|
||||||
QPointer<MapImageExporter> mapImageExporter = nullptr;
|
QPointer<MapImageExporter> mapImageExporter = nullptr;
|
||||||
QPointer<NewMapPopup> newmapprompt = nullptr;
|
QPointer<NewMapPopup> newMapPrompt = nullptr;
|
||||||
QPointer<PreferenceEditor> preferenceEditor = nullptr;
|
QPointer<PreferenceEditor> preferenceEditor = nullptr;
|
||||||
FilterChildrenProxyModel *mapListProxyModel;
|
FilterChildrenProxyModel *mapListProxyModel;
|
||||||
QStandardItemModel *mapListModel;
|
QStandardItemModel *mapListModel;
|
||||||
|
|
|
@ -30,10 +30,8 @@ public:
|
||||||
tsl::ordered_map<QString, RegionMap *> region_maps;
|
tsl::ordered_map<QString, RegionMap *> region_maps;
|
||||||
|
|
||||||
bool load();
|
bool load();
|
||||||
bool loadCityMaps();
|
|
||||||
|
|
||||||
void onRegionMapTileSelectorSelectedTileChanged(unsigned id);
|
void onRegionMapTileSelectorSelectedTileChanged(unsigned id);
|
||||||
void onCityMapTileSelectorSelectedTileChanged(unsigned id);
|
|
||||||
void onRegionMapTileSelectorHoveredTileChanged(unsigned id);
|
void onRegionMapTileSelectorHoveredTileChanged(unsigned id);
|
||||||
void onRegionMapTileSelectorHoveredTileCleared();
|
void onRegionMapTileSelectorHoveredTileCleared();
|
||||||
|
|
||||||
|
@ -64,7 +62,6 @@ private:
|
||||||
unsigned selectedImageTile;
|
unsigned selectedImageTile;
|
||||||
QString activeEntry;
|
QString activeEntry;
|
||||||
|
|
||||||
bool hasUnsavedChanges = false;
|
|
||||||
bool cityMapFirstDraw = true;
|
bool cityMapFirstDraw = true;
|
||||||
bool regionMapFirstDraw = true;
|
bool regionMapFirstDraw = true;
|
||||||
bool entriesFirstDraw = true;
|
bool entriesFirstDraw = true;
|
||||||
|
@ -95,7 +92,6 @@ private:
|
||||||
|
|
||||||
bool buildConfigDialog();
|
bool buildConfigDialog();
|
||||||
poryjson::Json configRegionMapDialog();
|
poryjson::Json configRegionMapDialog();
|
||||||
void buildUpdateConfigDialog();
|
|
||||||
poryjson::Json buildDefaultJson();
|
poryjson::Json buildDefaultJson();
|
||||||
bool verifyConfig(poryjson::Json cfg);
|
bool verifyConfig(poryjson::Json cfg);
|
||||||
|
|
||||||
|
@ -110,14 +106,10 @@ private:
|
||||||
void updateRegionMapLayoutOptions(int index);
|
void updateRegionMapLayoutOptions(int index);
|
||||||
void displayRegionMapTileSelector();
|
void displayRegionMapTileSelector();
|
||||||
void updateLayerDisplayed();
|
void updateLayerDisplayed();
|
||||||
void displayCityMapTileSelector();
|
|
||||||
void displayCityMap(QString name);
|
|
||||||
void displayRegionMapEntryOptions();
|
void displayRegionMapEntryOptions();
|
||||||
void updateRegionMapEntryOptions(QString);
|
void updateRegionMapEntryOptions(QString);
|
||||||
void setRegionMap(RegionMap *map);
|
void setRegionMap(RegionMap *map);
|
||||||
|
|
||||||
bool createCityMap(QString name);
|
|
||||||
|
|
||||||
void restoreWindowState();
|
void restoreWindowState();
|
||||||
void closeEvent(QCloseEvent* event);
|
void closeEvent(QCloseEvent* event);
|
||||||
|
|
||||||
|
@ -144,15 +136,12 @@ private slots:
|
||||||
void on_spinBox_tilePalette_valueChanged(int);
|
void on_spinBox_tilePalette_valueChanged(int);
|
||||||
void on_checkBox_tileHFlip_stateChanged(int);
|
void on_checkBox_tileHFlip_stateChanged(int);
|
||||||
void on_checkBox_tileVFlip_stateChanged(int);
|
void on_checkBox_tileVFlip_stateChanged(int);
|
||||||
void on_pushButton_CityMap_add_clicked();
|
|
||||||
void on_verticalSlider_Zoom_Map_Image_valueChanged(int);
|
void on_verticalSlider_Zoom_Map_Image_valueChanged(int);
|
||||||
void on_verticalSlider_Zoom_Image_Tiles_valueChanged(int);
|
void on_verticalSlider_Zoom_Image_Tiles_valueChanged(int);
|
||||||
void on_comboBox_CityMap_picker_currentTextChanged(const QString &);
|
|
||||||
void on_lineEdit_RM_MapName_textEdited(const QString &);
|
void on_lineEdit_RM_MapName_textEdited(const QString &);
|
||||||
void onHoveredRegionMapTileChanged(int x, int y);
|
void onHoveredRegionMapTileChanged(int x, int y);
|
||||||
void onHoveredRegionMapTileCleared();
|
void onHoveredRegionMapTileCleared();
|
||||||
void mouseEvent_region_map(QGraphicsSceneMouseEvent *event, RegionMapPixmapItem *item);
|
void mouseEvent_region_map(QGraphicsSceneMouseEvent *event, RegionMapPixmapItem *item);
|
||||||
void mouseEvent_city_map(QGraphicsSceneMouseEvent *event, CityMapPixmapItem *item);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // REGIONMAPEDITOR_H
|
#endif // REGIONMAPEDITOR_H
|
||||||
|
|
|
@ -100,7 +100,6 @@ bool RegionMap::loadLayout(poryjson::Json layoutJson) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: reset other values here
|
|
||||||
this->layout_constants.clear();
|
this->layout_constants.clear();
|
||||||
|
|
||||||
poryjson::Json::object layoutObject = layoutJson.object_items();
|
poryjson::Json::object layoutObject = layoutJson.object_items();
|
||||||
|
@ -121,7 +120,7 @@ bool RegionMap::loadLayout(poryjson::Json layoutJson) {
|
||||||
switch (this->layout_format) {
|
switch (this->layout_format) {
|
||||||
case LayoutFormat::Binary:
|
case LayoutFormat::Binary:
|
||||||
{
|
{
|
||||||
// TODO: only one layer supported for binary layouts (change or no?)
|
// only one layer supported for binary layouts
|
||||||
QFile binFile(fullPath(this->layout_path));
|
QFile binFile(fullPath(this->layout_path));
|
||||||
if (!binFile.open(QIODevice::ReadOnly)) {
|
if (!binFile.open(QIODevice::ReadOnly)) {
|
||||||
logError(QString("Failed to read region map layout binary file %1").arg(this->layout_path));
|
logError(QString("Failed to read region map layout binary file %1").arg(this->layout_path));
|
||||||
|
@ -168,7 +167,6 @@ bool RegionMap::loadLayout(poryjson::Json layoutJson) {
|
||||||
// check for layers, extract info
|
// check for layers, extract info
|
||||||
QRegularExpressionMatch match = re.match(text);
|
QRegularExpressionMatch match = re.match(text);
|
||||||
if (match.hasMatch()) {
|
if (match.hasMatch()) {
|
||||||
// TODO: keep track of labels and consts
|
|
||||||
QString qualifiers = match.captured("qual_1") + " " + match.captured("qual_2");
|
QString qualifiers = match.captured("qual_1") + " " + match.captured("qual_2");
|
||||||
QString type = match.captured("type");
|
QString type = match.captured("type");
|
||||||
QString label = match.captured("label");
|
QString label = match.captured("label");
|
||||||
|
@ -203,7 +201,6 @@ bool RegionMap::loadLayout(poryjson::Json layoutJson) {
|
||||||
int x = 0;
|
int x = 0;
|
||||||
for (QString section : rowSections) {
|
for (QString section : rowSections) {
|
||||||
QString square_section_name = section.trimmed();
|
QString square_section_name = section.trimmed();
|
||||||
int square_index = get_tilemap_index(x, y);
|
|
||||||
|
|
||||||
LayoutSquare square;
|
LayoutSquare square;
|
||||||
square.map_section = square_section_name;
|
square.map_section = square_section_name;
|
||||||
|
@ -223,14 +220,12 @@ bool RegionMap::loadLayout(poryjson::Json layoutJson) {
|
||||||
QRegularExpression reAlt("(?<qual_1>static)?\\s?(?<qual_2>const)?\\s?(?<type>[A-Za-z0-9_]+)?\\s+(?<label>[A-Za-z0-9_]+)\\[\\]");
|
QRegularExpression reAlt("(?<qual_1>static)?\\s?(?<qual_2>const)?\\s?(?<type>[A-Za-z0-9_]+)?\\s+(?<label>[A-Za-z0-9_]+)\\[\\]");
|
||||||
QRegularExpressionMatch matchAlt = reAlt.match(text);
|
QRegularExpressionMatch matchAlt = reAlt.match(text);
|
||||||
if (matchAlt.hasMatch()) {
|
if (matchAlt.hasMatch()) {
|
||||||
// TODO: save type info
|
|
||||||
QString qualifiers = matchAlt.captured("qual_1") + " " + matchAlt.captured("qual_2");
|
QString qualifiers = matchAlt.captured("qual_1") + " " + matchAlt.captured("qual_2");
|
||||||
QString type = matchAlt.captured("type");
|
QString type = matchAlt.captured("type");
|
||||||
QString label = matchAlt.captured("label");
|
QString label = matchAlt.captured("label");
|
||||||
this->layout_constants.append("");
|
this->layout_constants.append("");
|
||||||
this->layout_qualifiers = qualifiers + " " + type;
|
this->layout_qualifiers = qualifiers + " " + type;
|
||||||
this->layout_array_label = label;
|
this->layout_array_label = label;
|
||||||
this->layout_type = type;
|
|
||||||
|
|
||||||
QRegularExpression reSec("(?<sec>MAPSEC_[A-Za-z0-9_]+)");
|
QRegularExpression reSec("(?<sec>MAPSEC_[A-Za-z0-9_]+)");
|
||||||
QRegularExpressionMatchIterator k = reSec.globalMatch(text);
|
QRegularExpressionMatchIterator k = reSec.globalMatch(text);
|
||||||
|
@ -262,6 +257,9 @@ bool RegionMap::loadLayout(poryjson::Json layoutJson) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case LayoutFormat::None:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
this->current_layer = this->layout_layers.first();
|
this->current_layer = this->layout_layers.first();
|
||||||
|
|
||||||
|
@ -273,12 +271,10 @@ void RegionMap::commit(QUndoCommand *command) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMap::undo() {
|
void RegionMap::undo() {
|
||||||
//
|
|
||||||
editHistory.undo();
|
editHistory.undo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMap::redo() {
|
void RegionMap::redo() {
|
||||||
//
|
|
||||||
editHistory.redo();
|
editHistory.redo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,14 +384,12 @@ void RegionMap::saveLayout() {
|
||||||
this->project->saveTextFile(fullPath(this->layout_path), text);
|
this->project->saveTextFile(fullPath(this->layout_path), text);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case LayoutFormat::None:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMap::saveOptions(int id, QString sec, QString name, int x, int y) {
|
|
||||||
// TODO
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegionMap::resetSquare(int index) {
|
void RegionMap::resetSquare(int index) {
|
||||||
this->layouts[this->current_layer][index].map_section = "MAPSEC_NONE";
|
this->layouts[this->current_layer][index].map_section = "MAPSEC_NONE";
|
||||||
this->layouts[this->current_layer][index].has_map = false;
|
this->layouts[this->current_layer][index].has_map = false;
|
||||||
|
@ -546,16 +540,14 @@ void RegionMap::setAllLayouts(QMap<QString, QList<LayoutSquare>> newLayouts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMap::setLayoutDimensions(int width, int height, bool update) {
|
void RegionMap::setLayoutDimensions(int width, int height, bool update) {
|
||||||
// for each layer!
|
// for each layer
|
||||||
if (update) {
|
if (update) {
|
||||||
for (QString layer : this->layout_layers) {
|
for (QString layer : this->layout_layers) {
|
||||||
//
|
|
||||||
QList<LayoutSquare> oldLayout = this->getLayout(layer);
|
QList<LayoutSquare> oldLayout = this->getLayout(layer);
|
||||||
QList<LayoutSquare> newLayout;
|
QList<LayoutSquare> newLayout;
|
||||||
|
|
||||||
for (int y = 0; y < height; y++)
|
for (int y = 0; y < height; y++)
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
//
|
|
||||||
LayoutSquare newSquare;
|
LayoutSquare newSquare;
|
||||||
if (x < this->layout_width && y < this->layout_height) {
|
if (x < this->layout_width && y < this->layout_height) {
|
||||||
// within old layout
|
// within old layout
|
||||||
|
@ -570,21 +562,6 @@ void RegionMap::setLayoutDimensions(int width, int height, bool update) {
|
||||||
|
|
||||||
this->layout_width = width;
|
this->layout_width = width;
|
||||||
this->layout_height = height;
|
this->layout_height = height;
|
||||||
|
|
||||||
// TODO: commit
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<uint8_t> RegionMap::getTiles() {
|
|
||||||
QVector<uint8_t> tileIds;
|
|
||||||
// unused? remove when redo history is fully transitioned
|
|
||||||
// TODO: change this to use TilemapTile instead of uint8_t
|
|
||||||
|
|
||||||
return tileIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegionMap::setTiles(QVector<uint8_t> tileIds) {
|
|
||||||
// TODO
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Layout coords to image index.
|
// Layout coords to image index.
|
||||||
|
@ -712,12 +689,6 @@ QString RegionMap::pngPath() {
|
||||||
return this->project->root + "/" + this->tileset_path;
|
return this->project->root + "/" + this->tileset_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RegionMap::cityTilesPath() {
|
|
||||||
// TODO
|
|
||||||
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// From x, y of image.
|
// From x, y of image.
|
||||||
int RegionMap::getMapSquareIndex(int x, int y) {
|
int RegionMap::getMapSquareIndex(int x, int y) {
|
||||||
int index = (x + y * this->tilemap_width);
|
int index = (x + y * this->tilemap_width);
|
||||||
|
|
|
@ -1166,11 +1166,11 @@ void MainWindow::onAddNewMapToLayoutClick(QAction* triggeredAction)
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onNewMapCreated() {
|
void MainWindow::onNewMapCreated() {
|
||||||
QString newMapName = this->newmapprompt->map->name;
|
QString newMapName = this->newMapPrompt->map->name;
|
||||||
int newMapGroup = this->newmapprompt->group;
|
int newMapGroup = this->newMapPrompt->group;
|
||||||
Map *newMap = this->newmapprompt->map;
|
Map *newMap = this->newMapPrompt->map;
|
||||||
bool existingLayout = this->newmapprompt->existingLayout;
|
bool existingLayout = this->newMapPrompt->existingLayout;
|
||||||
bool importedMap = this->newmapprompt->importedMap;
|
bool importedMap = this->newMapPrompt->importedMap;
|
||||||
|
|
||||||
newMap = editor->project->addNewMapToGroup(newMapName, newMapGroup, newMap, existingLayout, importedMap);
|
newMap = editor->project->addNewMapToGroup(newMapName, newMapGroup, newMap, existingLayout, importedMap);
|
||||||
|
|
||||||
|
@ -1195,52 +1195,52 @@ void MainWindow::onNewMapCreated() {
|
||||||
editor->save();// required
|
editor->save();// required
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect(this->newmapprompt, &NewMapPopup::applied, this, &MainWindow::onNewMapCreated);
|
disconnect(this->newMapPrompt, &NewMapPopup::applied, this, &MainWindow::onNewMapCreated);
|
||||||
delete newMap;
|
delete newMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::openNewMapPopupWindow(int type, QVariant data) {
|
void MainWindow::openNewMapPopupWindow(int type, QVariant data) {
|
||||||
if (!this->newmapprompt) {
|
if (!this->newMapPrompt) {
|
||||||
this->newmapprompt = new NewMapPopup(this, this->editor->project);
|
this->newMapPrompt = new NewMapPopup(this, this->editor->project);
|
||||||
}
|
}
|
||||||
if (!this->newmapprompt->isVisible()) {
|
if (!this->newMapPrompt->isVisible()) {
|
||||||
this->newmapprompt->show();
|
this->newMapPrompt->show();
|
||||||
} else {
|
} else {
|
||||||
this->newmapprompt->raise();
|
this->newMapPrompt->raise();
|
||||||
this->newmapprompt->activateWindow();
|
this->newMapPrompt->activateWindow();
|
||||||
}
|
}
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case MapSortOrder::Group:
|
case MapSortOrder::Group:
|
||||||
this->newmapprompt->init(type, data.toInt(), QString(), QString());
|
this->newMapPrompt->init(type, data.toInt(), QString(), QString());
|
||||||
break;
|
break;
|
||||||
case MapSortOrder::Area:
|
case MapSortOrder::Area:
|
||||||
this->newmapprompt->init(type, 0, data.toString(), QString());
|
this->newMapPrompt->init(type, 0, data.toString(), QString());
|
||||||
break;
|
break;
|
||||||
case MapSortOrder::Layout:
|
case MapSortOrder::Layout:
|
||||||
this->newmapprompt->init(type, 0, QString(), data.toString());
|
this->newMapPrompt->init(type, 0, QString(), data.toString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
connect(this->newmapprompt, &NewMapPopup::applied, this, &MainWindow::onNewMapCreated);
|
connect(this->newMapPrompt, &NewMapPopup::applied, this, &MainWindow::onNewMapCreated);
|
||||||
this->newmapprompt->setAttribute(Qt::WA_DeleteOnClose);
|
this->newMapPrompt->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::openNewMapPopupWindowImportMap(MapLayout *mapLayout) {
|
void MainWindow::openNewMapPopupWindowImportMap(MapLayout *mapLayout) {
|
||||||
if (!this->newmapprompt) {
|
if (!this->newMapPrompt) {
|
||||||
this->newmapprompt = new NewMapPopup(this, this->editor->project);
|
this->newMapPrompt = new NewMapPopup(this, this->editor->project);
|
||||||
}
|
}
|
||||||
if (!this->newmapprompt->isVisible()) {
|
if (!this->newMapPrompt->isVisible()) {
|
||||||
this->newmapprompt->show();
|
this->newMapPrompt->show();
|
||||||
} else {
|
} else {
|
||||||
this->newmapprompt->raise();
|
this->newMapPrompt->raise();
|
||||||
this->newmapprompt->activateWindow();
|
this->newMapPrompt->activateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->newmapprompt->initImportMap(mapLayout);
|
this->newMapPrompt->initImportMap(mapLayout);
|
||||||
|
|
||||||
connect(this->newmapprompt, SIGNAL(applied()), this, SLOT(onNewMapCreated()));
|
connect(this->newMapPrompt, SIGNAL(applied()), this, SLOT(onNewMapCreated()));
|
||||||
connect(this->newmapprompt, &QObject::destroyed, [=](QObject *) { this->newmapprompt = nullptr; });
|
connect(this->newMapPrompt, &QObject::destroyed, [=](QObject *) { this->newMapPrompt = nullptr; });
|
||||||
this->newmapprompt->setAttribute(Qt::WA_DeleteOnClose);
|
this->newMapPrompt->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_action_NewMap_triggered() {
|
void MainWindow::on_action_NewMap_triggered() {
|
||||||
|
@ -3164,16 +3164,26 @@ bool MainWindow::initRegionMapEditor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::closeSupplementaryWindows() {
|
void MainWindow::closeSupplementaryWindows() {
|
||||||
if (this->tilesetEditor)
|
if (this->tilesetEditor) {
|
||||||
delete this->tilesetEditor;
|
delete this->tilesetEditor;
|
||||||
if (this->regionMapEditor)
|
this->tilesetEditor = nullptr;
|
||||||
|
}
|
||||||
|
if (this->regionMapEditor) {
|
||||||
delete this->regionMapEditor;
|
delete this->regionMapEditor;
|
||||||
if (this->mapImageExporter)
|
this->regionMapEditor = nullptr;
|
||||||
|
}
|
||||||
|
if (this->mapImageExporter) {
|
||||||
delete this->mapImageExporter;
|
delete this->mapImageExporter;
|
||||||
if (this->newmapprompt)
|
this->mapImageExporter = nullptr;
|
||||||
delete this->newmapprompt;
|
}
|
||||||
if (this->shortcutsEditor)
|
if (this->newMapPrompt) {
|
||||||
|
delete this->newMapPrompt;
|
||||||
|
this->newMapPrompt = nullptr;
|
||||||
|
}
|
||||||
|
if (this->shortcutsEditor) {
|
||||||
delete this->shortcutsEditor;
|
delete this->shortcutsEditor;
|
||||||
|
this->shortcutsEditor = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent *event) {
|
void MainWindow::closeEvent(QCloseEvent *event) {
|
||||||
|
|
|
@ -135,6 +135,8 @@ bool RegionMapEditor::loadRegionMapEntries() {
|
||||||
entry.valid = true;
|
entry.valid = true;
|
||||||
this->region_map_entries[entryMapSection] = entry;
|
this->region_map_entries[entryMapSection] = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RegionMapEditor::saveRegionMapEntries() {
|
bool RegionMapEditor::saveRegionMapEntries() {
|
||||||
|
@ -236,7 +238,7 @@ bool RegionMapEditor::buildConfigDialog() {
|
||||||
|
|
||||||
// lambda to update the current map list displayed in the config window with a
|
// lambda to update the current map list displayed in the config window with a
|
||||||
// widget item that contains that region map's json data
|
// widget item that contains that region map's json data
|
||||||
auto updateMapList = [this, regionMapList, &rmConfigJsonUpdate]() {
|
auto updateMapList = [regionMapList, &rmConfigJsonUpdate]() {
|
||||||
regionMapList->clear();
|
regionMapList->clear();
|
||||||
poryjson::Json::object mapsObject = rmConfigJsonUpdate.object_items();
|
poryjson::Json::object mapsObject = rmConfigJsonUpdate.object_items();
|
||||||
for (auto o : mapsObject["region_maps"].array_items()) {
|
for (auto o : mapsObject["region_maps"].array_items()) {
|
||||||
|
@ -276,8 +278,6 @@ bool RegionMapEditor::buildConfigDialog() {
|
||||||
rmConfigJsonUpdate = poryjson::Json(previousObj);
|
rmConfigJsonUpdate = poryjson::Json(previousObj);
|
||||||
|
|
||||||
updateMapList();
|
updateMapList();
|
||||||
} else {
|
|
||||||
// TODO: anything?
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -289,8 +289,6 @@ bool RegionMapEditor::buildConfigDialog() {
|
||||||
poryjson::Json resultJson = configRegionMapDialog();
|
poryjson::Json resultJson = configRegionMapDialog();
|
||||||
poryjson::Json::object resultObj = resultJson.object_items();
|
poryjson::Json::object resultObj = resultJson.object_items();
|
||||||
|
|
||||||
// TODO: check duplicate alias? other error-checking
|
|
||||||
|
|
||||||
QString resultStr;
|
QString resultStr;
|
||||||
int tab = 0;
|
int tab = 0;
|
||||||
resultJson.dump(resultStr, &tab);
|
resultJson.dump(resultStr, &tab);
|
||||||
|
@ -372,11 +370,6 @@ poryjson::Json RegionMapEditor::configRegionMapDialog() {
|
||||||
return poryjson::Json();
|
return poryjson::Json();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::buildUpdateConfigDialog() {
|
|
||||||
// unused
|
|
||||||
// TODO: get rid of this function
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RegionMapEditor::verifyConfig(poryjson::Json cfg) {
|
bool RegionMapEditor::verifyConfig(poryjson::Json cfg) {
|
||||||
OrderedJson::object obj = cfg.object_items();
|
OrderedJson::object obj = cfg.object_items();
|
||||||
|
|
||||||
|
@ -479,7 +472,6 @@ bool RegionMapEditor::load() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::setRegionMap(RegionMap *map) {
|
void RegionMapEditor::setRegionMap(RegionMap *map) {
|
||||||
//
|
|
||||||
this->region_map = map;
|
this->region_map = map;
|
||||||
this->currIndex = this->region_map->firstLayoutIndex();
|
this->currIndex = this->region_map->firstLayoutIndex();
|
||||||
this->region_map->editHistory.setActive();
|
this->region_map->editHistory.setActive();
|
||||||
|
@ -497,13 +489,6 @@ void RegionMapEditor::setRegionMap(RegionMap *map) {
|
||||||
displayRegionMap();
|
displayRegionMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RegionMapEditor::loadCityMaps() {
|
|
||||||
// unused
|
|
||||||
// TODO
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RegionMapEditor::saveRegionMap(RegionMap *map) {
|
bool RegionMapEditor::saveRegionMap(RegionMap *map) {
|
||||||
if (!map) return false;
|
if (!map) return false;
|
||||||
|
|
||||||
|
@ -542,8 +527,6 @@ void RegionMapEditor::on_action_RegionMap_Save_triggered() {
|
||||||
|
|
||||||
// save config
|
// save config
|
||||||
saveConfig();
|
saveConfig();
|
||||||
|
|
||||||
this->hasUnsavedChanges = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_actionSave_All_triggered() {
|
void RegionMapEditor::on_actionSave_All_triggered() {
|
||||||
|
@ -552,14 +535,10 @@ void RegionMapEditor::on_actionSave_All_triggered() {
|
||||||
}
|
}
|
||||||
saveRegionMapEntries();
|
saveRegionMapEntries();
|
||||||
saveConfig();
|
saveConfig();
|
||||||
|
|
||||||
this->hasUnsavedChanges = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::displayRegionMap() {
|
void RegionMapEditor::displayRegionMap() {
|
||||||
displayRegionMapTileSelector();
|
displayRegionMapTileSelector();
|
||||||
//< displayCityMapTileSelector();
|
|
||||||
|
|
||||||
displayRegionMapImage();
|
displayRegionMapImage();
|
||||||
displayRegionMapLayout();
|
displayRegionMapLayout();
|
||||||
displayRegionMapLayoutOptions();
|
displayRegionMapLayoutOptions();
|
||||||
|
@ -567,8 +546,6 @@ void RegionMapEditor::displayRegionMap() {
|
||||||
displayRegionMapEntryOptions();
|
displayRegionMapEntryOptions();
|
||||||
|
|
||||||
updateLayerDisplayed();
|
updateLayerDisplayed();
|
||||||
|
|
||||||
this->hasUnsavedChanges = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::updateLayerDisplayed() {
|
void RegionMapEditor::updateLayerDisplayed() {
|
||||||
|
@ -640,8 +617,10 @@ void RegionMapEditor::displayRegionMapLayout() {
|
||||||
void RegionMapEditor::displayRegionMapLayoutOptions() {
|
void RegionMapEditor::displayRegionMapLayoutOptions() {
|
||||||
if (!this->region_map->layoutEnabled()) return;
|
if (!this->region_map->layoutEnabled()) return;
|
||||||
|
|
||||||
|
this->ui->comboBox_RM_ConnectedMap->blockSignals(true);
|
||||||
this->ui->comboBox_RM_ConnectedMap->clear();
|
this->ui->comboBox_RM_ConnectedMap->clear();
|
||||||
this->ui->comboBox_RM_ConnectedMap->addItems(this->project->mapSectionValueToName.values());
|
this->ui->comboBox_RM_ConnectedMap->addItems(this->project->mapSectionValueToName.values());
|
||||||
|
this->ui->comboBox_RM_ConnectedMap->blockSignals(false);
|
||||||
|
|
||||||
this->ui->frame_RM_Options->setEnabled(true);
|
this->ui->frame_RM_Options->setEnabled(true);
|
||||||
|
|
||||||
|
@ -811,101 +790,10 @@ void RegionMapEditor::displayRegionMapTileSelector() {
|
||||||
this->mapsquare_selector_item->select(this->selectedImageTile);
|
this->mapsquare_selector_item->select(this->selectedImageTile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::displayCityMapTileSelector() {
|
|
||||||
return;
|
|
||||||
/*
|
|
||||||
if (!scene_city_map_tiles) {
|
|
||||||
this->scene_city_map_tiles = new QGraphicsScene;
|
|
||||||
}
|
|
||||||
if (city_map_selector_item && scene_city_map_tiles) {
|
|
||||||
scene_city_map_tiles->removeItem(city_map_selector_item);
|
|
||||||
delete city_map_selector_item;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->city_map_selector_item = new TilemapTileSelector(QPixmap(this->region_map->cityTilesPath()));
|
|
||||||
this->city_map_selector_item->draw();
|
|
||||||
|
|
||||||
this->scene_city_map_tiles->addItem(this->city_map_selector_item);
|
|
||||||
|
|
||||||
connect(this->city_map_selector_item, &TilemapTileSelector::selectedTileChanged,
|
|
||||||
this, &RegionMapEditor::onCityMapTileSelectorSelectedTileChanged);
|
|
||||||
|
|
||||||
this->ui->graphicsView_City_Map_Tiles->setScene(this->scene_city_map_tiles);
|
|
||||||
on_verticalSlider_Zoom_City_Tiles_valueChanged(this->ui->verticalSlider_Zoom_City_Tiles->value());
|
|
||||||
|
|
||||||
this->city_map_selector_item->select(this->selectedCityTile);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegionMapEditor::displayCityMap(QString f) {
|
|
||||||
return;
|
|
||||||
/*
|
|
||||||
QString file = this->project->root + "/graphics/pokenav/city_maps/" + f + ".bin";
|
|
||||||
|
|
||||||
if (!scene_city_map_image) {
|
|
||||||
scene_city_map_image = new QGraphicsScene;
|
|
||||||
}
|
|
||||||
if (city_map_item && scene_city_map_image) {
|
|
||||||
scene_city_map_image->removeItem(city_map_item);
|
|
||||||
delete city_map_item;
|
|
||||||
}
|
|
||||||
|
|
||||||
city_map_item = new CityMapPixmapItem(file, this->city_map_selector_item);
|
|
||||||
city_map_item->draw();
|
|
||||||
|
|
||||||
connect(this->city_map_item, &CityMapPixmapItem::mouseEvent,
|
|
||||||
this, &RegionMapEditor::mouseEvent_city_map);
|
|
||||||
|
|
||||||
scene_city_map_image->addItem(city_map_item);
|
|
||||||
scene_city_map_image->setSceneRect(this->scene_city_map_image->sceneRect());
|
|
||||||
|
|
||||||
this->ui->graphicsView_City_Map->setScene(scene_city_map_image);
|
|
||||||
on_verticalSlider_Zoom_City_Map_valueChanged(this->ui->verticalSlider_Zoom_City_Map->value());
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RegionMapEditor::createCityMap(QString name) {
|
|
||||||
return false;
|
|
||||||
/*
|
|
||||||
bool errored = false;
|
|
||||||
|
|
||||||
QString file = this->project->root + "/graphics/pokenav/city_maps/" + name + ".bin";
|
|
||||||
|
|
||||||
uint8_t filler = 0x30;
|
|
||||||
uint8_t border = 0x7;
|
|
||||||
uint8_t blank = 0x1;
|
|
||||||
QByteArray new_data(400, filler);
|
|
||||||
for (int i = 0; i < new_data.size(); i++) {
|
|
||||||
if (i % 2) continue;
|
|
||||||
int x = i % 20;
|
|
||||||
int y = i / 20;
|
|
||||||
if (y <= 1 || y >= 8 || x <= 3 || x >= 16)
|
|
||||||
new_data[i] = border;
|
|
||||||
else
|
|
||||||
new_data[i] = blank;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFile binFile(file);
|
|
||||||
if (!binFile.open(QIODevice::WriteOnly)) errored = true;
|
|
||||||
binFile.write(new_data);
|
|
||||||
binFile.close();
|
|
||||||
|
|
||||||
loadCityMaps();
|
|
||||||
this->ui->comboBox_CityMap_picker->setCurrentText(name);
|
|
||||||
|
|
||||||
return !errored;
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegionMapEditor::onRegionMapTileSelectorSelectedTileChanged(unsigned id) {
|
void RegionMapEditor::onRegionMapTileSelectorSelectedTileChanged(unsigned id) {
|
||||||
this->selectedImageTile = id;
|
this->selectedImageTile = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::onCityMapTileSelectorSelectedTileChanged(unsigned id) {
|
|
||||||
// TODO
|
|
||||||
//< this->selectedCityTile = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegionMapEditor::onRegionMapTileSelectorHoveredTileChanged(unsigned tileId) {
|
void RegionMapEditor::onRegionMapTileSelectorHoveredTileChanged(unsigned tileId) {
|
||||||
QString message = QString("Tile: 0x") + QString("%1").arg(tileId, 4, 16, QChar('0')).toUpper();
|
QString message = QString("Tile: 0x") + QString("%1").arg(tileId, 4, 16, QChar('0')).toUpper();
|
||||||
this->ui->statusbar->showMessage(message);
|
this->ui->statusbar->showMessage(message);
|
||||||
|
@ -985,43 +873,10 @@ void RegionMapEditor::mouseEvent_region_map(QGraphicsSceneMouseEvent *event, Reg
|
||||||
EditTilemap *command = new EditTilemap(this->region_map, oldTilemap, newTilemap, actionId_);
|
EditTilemap *command = new EditTilemap(this->region_map, oldTilemap, newTilemap, actionId_);
|
||||||
this->region_map->commit(command);
|
this->region_map->commit(command);
|
||||||
//this->region_map_layout_item->draw();
|
//this->region_map_layout_item->draw();
|
||||||
this->hasUnsavedChanges = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::mouseEvent_city_map(QGraphicsSceneMouseEvent *event, CityMapPixmapItem *item) {
|
|
||||||
return;
|
|
||||||
//< TODO: city maps
|
|
||||||
/*
|
|
||||||
if (cityMapFirstDraw) {
|
|
||||||
RegionMapHistoryItem *commit = new RegionMapHistoryItem(
|
|
||||||
RegionMapEditorBox::CityMapImage, this->city_map_item->getTiles(), this->city_map_item->file
|
|
||||||
);
|
|
||||||
history.push(commit);
|
|
||||||
cityMapFirstDraw = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event->buttons() & Qt::RightButton) {// TODO
|
|
||||||
//} else if (event->buttons() & Qt::MiddleButton) {// TODO
|
|
||||||
} else {
|
|
||||||
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
|
||||||
RegionMapHistoryItem *current = history.current();
|
|
||||||
bool addToHistory = !(current && current->tiles == this->city_map_item->getTiles());
|
|
||||||
if (addToHistory) {
|
|
||||||
RegionMapHistoryItem *commit = new RegionMapHistoryItem(
|
|
||||||
RegionMapEditorBox::CityMapImage, this->city_map_item->getTiles(), this->city_map_item->file
|
|
||||||
);
|
|
||||||
history.push(commit);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
item->paint(event);
|
|
||||||
this->hasUnsavedChanges = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegionMapEditor::on_tabWidget_Region_Map_currentChanged(int index) {
|
void RegionMapEditor::on_tabWidget_Region_Map_currentChanged(int index) {
|
||||||
this->ui->stackedWidget_RM_Options->setCurrentIndex(index);
|
this->ui->stackedWidget_RM_Options->setCurrentIndex(index);
|
||||||
if (!this->region_map) return;
|
if (!this->region_map) return;
|
||||||
|
@ -1048,12 +903,7 @@ void RegionMapEditor::on_tabWidget_Region_Map_currentChanged(int index) {
|
||||||
|
|
||||||
void RegionMapEditor::on_comboBox_RM_ConnectedMap_textActivated(const QString &mapsec) {
|
void RegionMapEditor::on_comboBox_RM_ConnectedMap_textActivated(const QString &mapsec) {
|
||||||
QString layer = this->region_map->getLayer();
|
QString layer = this->region_map->getLayer();
|
||||||
QList<LayoutSquare> oldLayout = this->region_map->getLayout(layer);
|
|
||||||
this->region_map->setSquareMapSection(this->currIndex, mapsec);
|
this->region_map->setSquareMapSection(this->currIndex, mapsec);
|
||||||
QList<LayoutSquare> newLayout = this->region_map->getLayout(layer);
|
|
||||||
|
|
||||||
EditLayout *command = new EditLayout(this->region_map, layer, this->currIndex, oldLayout, newLayout);
|
|
||||||
this->region_map->commit(command);
|
|
||||||
|
|
||||||
onRegionMapLayoutSelectedTileChanged(this->currIndex);// re-draw layout image
|
onRegionMapLayoutSelectedTileChanged(this->currIndex);// re-draw layout image
|
||||||
}
|
}
|
||||||
|
@ -1093,7 +943,6 @@ void RegionMapEditor::on_spinBox_RM_Entry_x_valueChanged(int x) {
|
||||||
this->region_map_entries_item->select(idx);
|
this->region_map_entries_item->select(idx);
|
||||||
this->region_map_entries_item->draw();
|
this->region_map_entries_item->draw();
|
||||||
this->ui->spinBox_RM_Entry_width->setMaximum(this->region_map->tilemapWidth() - this->region_map->padLeft() - this->region_map->padRight() - x);
|
this->ui->spinBox_RM_Entry_width->setMaximum(this->region_map->tilemapWidth() - this->region_map->padLeft() - this->region_map->padRight() - x);
|
||||||
this->hasUnsavedChanges = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_spinBox_RM_Entry_y_valueChanged(int y) {
|
void RegionMapEditor::on_spinBox_RM_Entry_y_valueChanged(int y) {
|
||||||
|
@ -1108,7 +957,6 @@ void RegionMapEditor::on_spinBox_RM_Entry_y_valueChanged(int y) {
|
||||||
this->region_map_entries_item->select(idx);
|
this->region_map_entries_item->select(idx);
|
||||||
this->region_map_entries_item->draw();
|
this->region_map_entries_item->draw();
|
||||||
this->ui->spinBox_RM_Entry_height->setMaximum(this->region_map->tilemapHeight() - this->region_map->padTop() - this->region_map->padBottom() - y);
|
this->ui->spinBox_RM_Entry_height->setMaximum(this->region_map->tilemapHeight() - this->region_map->padTop() - this->region_map->padBottom() - y);
|
||||||
this->hasUnsavedChanges = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_spinBox_RM_Entry_width_valueChanged(int width) {
|
void RegionMapEditor::on_spinBox_RM_Entry_width_valueChanged(int width) {
|
||||||
|
@ -1119,7 +967,6 @@ void RegionMapEditor::on_spinBox_RM_Entry_width_valueChanged(int width) {
|
||||||
EditEntry *commit = new EditEntry(this->region_map, activeEntry, oldEntry, newEntry);
|
EditEntry *commit = new EditEntry(this->region_map, activeEntry, oldEntry, newEntry);
|
||||||
this->region_map->editHistory.push(commit);
|
this->region_map->editHistory.push(commit);
|
||||||
this->region_map_entries_item->draw();
|
this->region_map_entries_item->draw();
|
||||||
this->hasUnsavedChanges = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_spinBox_RM_Entry_height_valueChanged(int height) {
|
void RegionMapEditor::on_spinBox_RM_Entry_height_valueChanged(int height) {
|
||||||
|
@ -1130,7 +977,6 @@ void RegionMapEditor::on_spinBox_RM_Entry_height_valueChanged(int height) {
|
||||||
EditEntry *commit = new EditEntry(this->region_map, activeEntry, oldEntry, newEntry);
|
EditEntry *commit = new EditEntry(this->region_map, activeEntry, oldEntry, newEntry);
|
||||||
this->region_map->editHistory.push(commit);
|
this->region_map->editHistory.push(commit);
|
||||||
this->region_map_entries_item->draw();
|
this->region_map_entries_item->draw();
|
||||||
this->hasUnsavedChanges = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_spinBox_RM_LayoutWidth_valueChanged(int value) {
|
void RegionMapEditor::on_spinBox_RM_LayoutWidth_valueChanged(int value) {
|
||||||
|
@ -1139,7 +985,7 @@ void RegionMapEditor::on_spinBox_RM_LayoutWidth_valueChanged(int value) {
|
||||||
int oldHeight = this->region_map->layoutHeight();
|
int oldHeight = this->region_map->layoutHeight();
|
||||||
QMap<QString, QList<LayoutSquare>> oldLayouts = this->region_map->getAllLayouts();
|
QMap<QString, QList<LayoutSquare>> oldLayouts = this->region_map->getAllLayouts();
|
||||||
|
|
||||||
this->region_map->setLayoutDimensions(this->ui->spinBox_RM_LayoutWidth->value(), this->ui->spinBox_RM_LayoutHeight->value());
|
this->region_map->setLayoutDimensions(value, this->ui->spinBox_RM_LayoutHeight->value());
|
||||||
|
|
||||||
int newWidth = this->region_map->layoutWidth();
|
int newWidth = this->region_map->layoutWidth();
|
||||||
int newHeight = this->region_map->layoutHeight();
|
int newHeight = this->region_map->layoutHeight();
|
||||||
|
@ -1151,13 +997,12 @@ void RegionMapEditor::on_spinBox_RM_LayoutWidth_valueChanged(int value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_spinBox_RM_LayoutHeight_valueChanged(int value) {
|
void RegionMapEditor::on_spinBox_RM_LayoutHeight_valueChanged(int value) {
|
||||||
//
|
|
||||||
if (this->region_map) {
|
if (this->region_map) {
|
||||||
int oldWidth = this->region_map->layoutWidth();
|
int oldWidth = this->region_map->layoutWidth();
|
||||||
int oldHeight = this->region_map->layoutHeight();
|
int oldHeight = this->region_map->layoutHeight();
|
||||||
QMap<QString, QList<LayoutSquare>> oldLayouts = this->region_map->getAllLayouts();
|
QMap<QString, QList<LayoutSquare>> oldLayouts = this->region_map->getAllLayouts();
|
||||||
|
|
||||||
this->region_map->setLayoutDimensions(this->ui->spinBox_RM_LayoutWidth->value(), this->ui->spinBox_RM_LayoutHeight->value());
|
this->region_map->setLayoutDimensions(this->ui->spinBox_RM_LayoutWidth->value(), value);
|
||||||
|
|
||||||
int newWidth = this->region_map->layoutWidth();
|
int newWidth = this->region_map->layoutWidth();
|
||||||
int newHeight = this->region_map->layoutHeight();
|
int newHeight = this->region_map->layoutHeight();
|
||||||
|
@ -1170,8 +1015,11 @@ void RegionMapEditor::on_spinBox_RM_LayoutHeight_valueChanged(int value) {
|
||||||
|
|
||||||
void RegionMapEditor::on_lineEdit_RM_MapName_textEdited(const QString &text) {
|
void RegionMapEditor::on_lineEdit_RM_MapName_textEdited(const QString &text) {
|
||||||
if (!this->region_map_entries.contains(activeEntry)) return;
|
if (!this->region_map_entries.contains(activeEntry)) return;
|
||||||
this->region_map_entries[this->ui->comboBox_RM_Entry_MapSection->currentText()].name = text;
|
MapSectionEntry oldEntry = this->region_map_entries[activeEntry];
|
||||||
this->hasUnsavedChanges = true;
|
this->region_map_entries[activeEntry].name = text;
|
||||||
|
MapSectionEntry newEntry = this->region_map_entries[activeEntry];
|
||||||
|
EditEntry *commit = new EditEntry(this->region_map, activeEntry, oldEntry, newEntry);
|
||||||
|
this->region_map->editHistory.push(commit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_pushButton_RM_Options_delete_clicked() {
|
void RegionMapEditor::on_pushButton_RM_Options_delete_clicked() {
|
||||||
|
@ -1188,7 +1036,6 @@ void RegionMapEditor::on_pushButton_RM_Options_delete_clicked() {
|
||||||
// ^ this line necessary?
|
// ^ this line necessary?
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: check value bounds for current palette?
|
|
||||||
void RegionMapEditor::on_spinBox_tilePalette_valueChanged(int value) {
|
void RegionMapEditor::on_spinBox_tilePalette_valueChanged(int value) {
|
||||||
this->mapsquare_selector_item->selectPalette(value);
|
this->mapsquare_selector_item->selectPalette(value);
|
||||||
}
|
}
|
||||||
|
@ -1201,40 +1048,6 @@ void RegionMapEditor::on_checkBox_tileVFlip_stateChanged(int state) {
|
||||||
this->mapsquare_selector_item->selectVFlip(state == Qt::Checked);
|
this->mapsquare_selector_item->selectVFlip(state == Qt::Checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_pushButton_CityMap_add_clicked() {
|
|
||||||
return;
|
|
||||||
//< TODO: city maps
|
|
||||||
/*
|
|
||||||
QDialog popup(this, Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
|
|
||||||
popup.setWindowTitle("New City Map");
|
|
||||||
popup.setWindowModality(Qt::NonModal);
|
|
||||||
|
|
||||||
QFormLayout form(&popup);
|
|
||||||
|
|
||||||
QLineEdit *input = new QLineEdit();
|
|
||||||
input->setClearButtonEnabled(true);
|
|
||||||
form.addRow(new QLabel("Name:"), input);
|
|
||||||
|
|
||||||
QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &popup);
|
|
||||||
|
|
||||||
QString name;
|
|
||||||
|
|
||||||
form.addRow(&buttonBox);
|
|
||||||
connect(&buttonBox, &QDialogButtonBox::rejected, &popup, &QDialog::reject);
|
|
||||||
connect(&buttonBox, &QDialogButtonBox::accepted, [&popup, &input, &name](){
|
|
||||||
name = input->text().remove(QRegularExpression("[^a-zA-Z0-9_]+"));
|
|
||||||
if (!name.isEmpty())
|
|
||||||
popup.accept();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (popup.exec() == QDialog::Accepted) {
|
|
||||||
createCityMap(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->hasUnsavedChanges = true;
|
|
||||||
//*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegionMapEditor::on_action_RegionMap_Resize_triggered() {
|
void RegionMapEditor::on_action_RegionMap_Resize_triggered() {
|
||||||
QDialog popup(this, Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
|
QDialog popup(this, Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
|
||||||
popup.setWindowTitle("New Tilemap Dimensions");
|
popup.setWindowTitle("New Tilemap Dimensions");
|
||||||
|
@ -1277,9 +1090,6 @@ void RegionMapEditor::resizeTilemap(int width, int height) {
|
||||||
ResizeTilemap *commit = new ResizeTilemap(this->region_map, oldTilemap, newTilemap, oldWidth, oldHeight, newWidth, newHeight);
|
ResizeTilemap *commit = new ResizeTilemap(this->region_map, oldTilemap, newTilemap, oldWidth, oldHeight, newWidth, newHeight);
|
||||||
this->region_map->editHistory.push(commit);
|
this->region_map->editHistory.push(commit);
|
||||||
this->currIndex = this->region_map->padLeft() * width + this->region_map->padTop();
|
this->currIndex = this->region_map->padLeft() * width + this->region_map->padTop();
|
||||||
//displayRegionMapImage();
|
|
||||||
//displayRegionMapLayout();
|
|
||||||
//displayRegionMapLayoutOptions();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_action_Swap_triggered() {
|
void RegionMapEditor::on_action_Swap_triggered() {
|
||||||
|
@ -1301,7 +1111,7 @@ void RegionMapEditor::on_action_Swap_triggered() {
|
||||||
|
|
||||||
QString beforeSection, afterSection;
|
QString beforeSection, afterSection;
|
||||||
connect(&buttonBox, &QDialogButtonBox::rejected, &popup, &QDialog::reject);
|
connect(&buttonBox, &QDialogButtonBox::rejected, &popup, &QDialog::reject);
|
||||||
connect(&buttonBox, &QDialogButtonBox::accepted, [this, &popup, &oldSecBox, &newSecBox, &beforeSection, &afterSection](){
|
connect(&buttonBox, &QDialogButtonBox::accepted, [&popup, &oldSecBox, &newSecBox, &beforeSection, &afterSection](){
|
||||||
beforeSection = oldSecBox->currentText();
|
beforeSection = oldSecBox->currentText();
|
||||||
afterSection = newSecBox->currentText();
|
afterSection = newSecBox->currentText();
|
||||||
if (!beforeSection.isEmpty() && !afterSection.isEmpty()) {
|
if (!beforeSection.isEmpty() && !afterSection.isEmpty()) {
|
||||||
|
@ -1318,7 +1128,6 @@ void RegionMapEditor::on_action_Swap_triggered() {
|
||||||
this->region_map->editHistory.push(commit);
|
this->region_map->editHistory.push(commit);
|
||||||
displayRegionMapLayout();
|
displayRegionMapLayout();
|
||||||
this->region_map_layout_item->select(this->region_map_layout_item->selectedTile);
|
this->region_map_layout_item->select(this->region_map_layout_item->selectedTile);
|
||||||
this->hasUnsavedChanges = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1357,14 +1166,8 @@ void RegionMapEditor::on_action_RegionMap_ClearLayout_triggered() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_comboBox_CityMap_picker_currentTextChanged(const QString &file) {
|
|
||||||
//< TODO: city maps
|
|
||||||
//< this->displayCityMap(file);
|
|
||||||
//< this->cityMapFirstDraw = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RegionMapEditor::modified() {
|
bool RegionMapEditor::modified() {
|
||||||
return this->hasUnsavedChanges || !this->history.isClean();
|
return !this->history.isClean();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::closeEvent(QCloseEvent *event)
|
void RegionMapEditor::closeEvent(QCloseEvent *event)
|
||||||
|
|
Loading…
Reference in a new issue