mirror of
https://github.com/huderlem/porymap.git
synced 2026-03-21 17:45:44 -05:00
New map popup/prompt to dialog
This commit is contained in:
parent
acaed90d65
commit
9d87ece663
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NewMapPopup</class>
|
||||
<widget class="QMainWindow" name="NewMapPopup">
|
||||
<class>NewMapDialog</class>
|
||||
<widget class="QDialog" name="NewMapDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
#include "mapimageexporter.h"
|
||||
#include "filterchildrenproxymodel.h"
|
||||
#include "maplistmodels.h"
|
||||
#include "newmappopup.h"
|
||||
#include "newmapdialog.h"
|
||||
#include "newtilesetdialog.h"
|
||||
#include "shortcutseditor.h"
|
||||
#include "preferenceeditor.h"
|
||||
|
|
@ -186,7 +186,7 @@ private slots:
|
|||
void onLayoutChanged(Layout *layout);
|
||||
void onOpenConnectedMap(MapConnection*);
|
||||
void onTilesetsSaved(QString, QString);
|
||||
void openNewMapPopupWindow();
|
||||
void openNewMapDialog();
|
||||
void onNewMapCreated();
|
||||
void onMapLoaded(Map *map);
|
||||
void importMapFromAdvanceMap1_92();
|
||||
|
|
@ -313,7 +313,7 @@ private:
|
|||
QPointer<RegionMapEditor> regionMapEditor = nullptr;
|
||||
QPointer<ShortcutsEditor> shortcutsEditor = nullptr;
|
||||
QPointer<MapImageExporter> mapImageExporter = nullptr;
|
||||
QPointer<NewMapPopup> newMapPrompt = nullptr;
|
||||
QPointer<NewMapDialog> newMapDialog = nullptr;
|
||||
QPointer<PreferenceEditor> preferenceEditor = nullptr;
|
||||
QPointer<ProjectSettingsEditor> projectSettingsEditor = nullptr;
|
||||
QPointer<GridSettingsDialog> gridSettingsDialog = nullptr;
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
#ifndef NEWMAPPOPUP_H
|
||||
#define NEWMAPPOPUP_H
|
||||
#ifndef NEWMAPDIALOG_H
|
||||
#define NEWMAPDIALOG_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
#include "editor.h"
|
||||
#include "project.h"
|
||||
#include "map.h"
|
||||
|
||||
namespace Ui {
|
||||
class NewMapPopup;
|
||||
class NewMapDialog;
|
||||
}
|
||||
|
||||
class NewMapPopup : public QMainWindow
|
||||
class NewMapDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NewMapPopup(QWidget *parent = nullptr, Project *project = nullptr);
|
||||
~NewMapPopup();
|
||||
explicit NewMapDialog(QWidget *parent = nullptr, Project *project = nullptr);
|
||||
~NewMapDialog();
|
||||
Map *map;
|
||||
int group;
|
||||
bool existingLayout;
|
||||
|
|
@ -32,7 +32,7 @@ signals:
|
|||
void applied();
|
||||
|
||||
private:
|
||||
Ui::NewMapPopup *ui;
|
||||
Ui::NewMapDialog *ui;
|
||||
Project *project;
|
||||
bool checkNewMapDimensions();
|
||||
bool checkNewMapGroup();
|
||||
|
|
@ -67,4 +67,4 @@ private slots:
|
|||
void on_lineEdit_NewMap_Name_textChanged(const QString &);
|
||||
};
|
||||
|
||||
#endif // NEWMAPPOPUP_H
|
||||
#endif // NEWMAPDIALOG_H
|
||||
|
|
@ -99,7 +99,7 @@ SOURCES += src/core/block.cpp \
|
|||
src/ui/tileseteditortileselector.cpp \
|
||||
src/ui/tilemaptileselector.cpp \
|
||||
src/ui/regionmapeditor.cpp \
|
||||
src/ui/newmappopup.cpp \
|
||||
src/ui/newmapdialog.cpp \
|
||||
src/ui/mapimageexporter.cpp \
|
||||
src/ui/newtilesetdialog.cpp \
|
||||
src/ui/flowlayout.cpp \
|
||||
|
|
@ -202,7 +202,7 @@ HEADERS += include/core/block.h \
|
|||
include/ui/tileseteditortileselector.h \
|
||||
include/ui/tilemaptileselector.h \
|
||||
include/ui/regionmapeditor.h \
|
||||
include/ui/newmappopup.h \
|
||||
include/ui/newmapdialog.h \
|
||||
include/ui/mapimageexporter.h \
|
||||
include/ui/newtilesetdialog.h \
|
||||
include/ui/overlay.h \
|
||||
|
|
@ -238,7 +238,7 @@ FORMS += forms/mainwindow.ui \
|
|||
forms/tileseteditor.ui \
|
||||
forms/paletteeditor.ui \
|
||||
forms/regionmapeditor.ui \
|
||||
forms/newmappopup.ui \
|
||||
forms/newmapdialog.ui \
|
||||
forms/aboutporymap.ui \
|
||||
forms/newtilesetdialog.ui \
|
||||
forms/mapimageexporter.ui \
|
||||
|
|
|
|||
|
|
@ -1363,8 +1363,8 @@ void MainWindow::onOpenMapListContextMenu(const QPoint &point) {
|
|||
|
||||
if (addToFolderAction) {
|
||||
connect(addToFolderAction, &QAction::triggered, [this, itemName] {
|
||||
openNewMapPopupWindow();
|
||||
this->newMapPrompt->init(ui->mapListContainer->currentIndex(), itemName);
|
||||
openNewMapDialog();
|
||||
this->newMapDialog->init(ui->mapListContainer->currentIndex(), itemName);
|
||||
});
|
||||
}
|
||||
if (deleteFolderAction) {
|
||||
|
|
@ -1592,11 +1592,11 @@ void MainWindow::mapListAddArea() {
|
|||
}
|
||||
|
||||
void MainWindow::onNewMapCreated() {
|
||||
QString newMapName = this->newMapPrompt->map->name();
|
||||
int newMapGroup = this->newMapPrompt->group;
|
||||
Map *newMap = this->newMapPrompt->map;
|
||||
bool existingLayout = this->newMapPrompt->existingLayout;
|
||||
bool importedMap = this->newMapPrompt->importedMap;
|
||||
QString newMapName = this->newMapDialog->map->name();
|
||||
int newMapGroup = this->newMapDialog->group;
|
||||
Map *newMap = this->newMapDialog->map;
|
||||
bool existingLayout = this->newMapDialog->existingLayout;
|
||||
bool importedMap = this->newMapDialog->importedMap;
|
||||
|
||||
newMap = editor->project->addNewMapToGroup(newMapName, newMapGroup, newMap, existingLayout, importedMap);
|
||||
|
||||
|
|
@ -1638,27 +1638,27 @@ void MainWindow::onNewMapCreated() {
|
|||
editor->save();
|
||||
}
|
||||
|
||||
disconnect(this->newMapPrompt, &NewMapPopup::applied, this, &MainWindow::onNewMapCreated);
|
||||
disconnect(this->newMapDialog, &NewMapDialog::applied, this, &MainWindow::onNewMapCreated);
|
||||
delete newMap;
|
||||
}
|
||||
|
||||
void MainWindow::openNewMapPopupWindow() {
|
||||
void MainWindow::openNewMapDialog() {
|
||||
if (!this->newMapDefaultsSet) {
|
||||
NewMapPopup::setDefaultSettings(this->editor->project);
|
||||
NewMapDialog::setDefaultSettings(this->editor->project);
|
||||
this->newMapDefaultsSet = true;
|
||||
}
|
||||
if (!this->newMapPrompt) {
|
||||
this->newMapPrompt = new NewMapPopup(this, this->editor->project);
|
||||
connect(this->newMapPrompt, &NewMapPopup::applied, this, &MainWindow::onNewMapCreated);
|
||||
if (!this->newMapDialog) {
|
||||
this->newMapDialog = new NewMapDialog(this, this->editor->project);
|
||||
connect(this->newMapDialog, &NewMapDialog::applied, this, &MainWindow::onNewMapCreated);
|
||||
}
|
||||
|
||||
openSubWindow(this->newMapPrompt);
|
||||
openSubWindow(this->newMapDialog);
|
||||
}
|
||||
|
||||
void MainWindow::on_action_NewMap_triggered() {
|
||||
openNewMapPopupWindow();
|
||||
this->newMapPrompt->initUi();
|
||||
this->newMapPrompt->init();
|
||||
openNewMapDialog();
|
||||
this->newMapDialog->initUi();
|
||||
this->newMapDialog->init();
|
||||
}
|
||||
|
||||
// Insert label for newly-created tileset into sorted list of existing labels
|
||||
|
|
@ -2864,8 +2864,8 @@ void MainWindow::importMapFromAdvanceMap1_92()
|
|||
return;
|
||||
}
|
||||
|
||||
openNewMapPopupWindow();
|
||||
this->newMapPrompt->init(mapLayout);
|
||||
openNewMapDialog();
|
||||
this->newMapDialog->init(mapLayout);
|
||||
}
|
||||
|
||||
void MainWindow::showExportMapImageWindow(ImageExporterMode mode) {
|
||||
|
|
@ -3379,9 +3379,9 @@ bool MainWindow::closeSupplementaryWindows() {
|
|||
return false;
|
||||
this->mapImageExporter = nullptr;
|
||||
|
||||
if (this->newMapPrompt && !this->newMapPrompt->close())
|
||||
if (this->newMapDialog && !this->newMapDialog->close())
|
||||
return false;
|
||||
this->newMapPrompt = nullptr;
|
||||
this->newMapDialog = nullptr;
|
||||
|
||||
if (this->shortcutsEditor && !this->shortcutsEditor->close())
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "newmappopup.h"
|
||||
#include "newmapdialog.h"
|
||||
#include "maplayout.h"
|
||||
#include "mainwindow.h"
|
||||
#include "ui_newmappopup.h"
|
||||
#include "ui_newmapdialog.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <QMap>
|
||||
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
// TODO: Convert to modal dialog (among other things, this means we wouldn't need to worry about changes to the map list while this is open)
|
||||
|
||||
struct NewMapPopup::Settings NewMapPopup::settings = {};
|
||||
struct NewMapDialog::Settings NewMapDialog::settings = {};
|
||||
|
||||
NewMapPopup::NewMapPopup(QWidget *parent, Project *project) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::NewMapPopup)
|
||||
NewMapDialog::NewMapDialog(QWidget *parent, Project *project) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::NewMapDialog)
|
||||
{
|
||||
this->setAttribute(Qt::WA_DeleteOnClose);
|
||||
ui->setupUi(this);
|
||||
|
|
@ -23,13 +23,13 @@ NewMapPopup::NewMapPopup(QWidget *parent, Project *project) :
|
|||
this->importedMap = false;
|
||||
}
|
||||
|
||||
NewMapPopup::~NewMapPopup()
|
||||
NewMapDialog::~NewMapDialog()
|
||||
{
|
||||
saveSettings();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void NewMapPopup::initUi() {
|
||||
void NewMapDialog::initUi() {
|
||||
// Populate combo boxes
|
||||
ui->comboBox_NewMap_Primary_Tileset->addItems(project->primaryTilesetLabels);
|
||||
ui->comboBox_NewMap_Secondary_Tileset->addItems(project->secondaryTilesetLabels);
|
||||
|
|
@ -76,7 +76,7 @@ void NewMapPopup::initUi() {
|
|||
this->updateGeometry();
|
||||
}
|
||||
|
||||
void NewMapPopup::init() {
|
||||
void NewMapDialog::init() {
|
||||
// Restore previous settings
|
||||
ui->lineEdit_NewMap_Name->setText(project->getNewMapName());
|
||||
ui->comboBox_NewMap_Group->setTextItem(settings.group);
|
||||
|
|
@ -104,7 +104,7 @@ void NewMapPopup::init() {
|
|||
}
|
||||
|
||||
// Creating new map by right-clicking in the map list
|
||||
void NewMapPopup::init(int tabIndex, QString fieldName) {
|
||||
void NewMapDialog::init(int tabIndex, QString fieldName) {
|
||||
initUi();
|
||||
switch (tabIndex)
|
||||
{
|
||||
|
|
@ -123,7 +123,7 @@ void NewMapPopup::init(int tabIndex, QString fieldName) {
|
|||
}
|
||||
|
||||
// Creating new map from AdvanceMap import
|
||||
void NewMapPopup::init(Layout *mapLayout) {
|
||||
void NewMapDialog::init(Layout *mapLayout) {
|
||||
initUi();
|
||||
this->importedMap = true;
|
||||
useLayoutSettings(mapLayout);
|
||||
|
|
@ -138,7 +138,7 @@ void NewMapPopup::init(Layout *mapLayout) {
|
|||
init();
|
||||
}
|
||||
|
||||
bool NewMapPopup::checkNewMapDimensions() {
|
||||
bool NewMapDialog::checkNewMapDimensions() {
|
||||
int numMetatiles = project->getMapDataSize(ui->spinBox_NewMap_Width->value(), ui->spinBox_NewMap_Height->value());
|
||||
int maxMetatiles = project->getMaxMapDataSize();
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ bool NewMapPopup::checkNewMapDimensions() {
|
|||
}
|
||||
}
|
||||
|
||||
bool NewMapPopup::checkNewMapGroup() {
|
||||
bool NewMapDialog::checkNewMapGroup() {
|
||||
group = project->groupNames.indexOf(this->ui->comboBox_NewMap_Group->currentText());
|
||||
|
||||
if (group < 0) {
|
||||
|
|
@ -179,7 +179,7 @@ bool NewMapPopup::checkNewMapGroup() {
|
|||
}
|
||||
}
|
||||
|
||||
void NewMapPopup::setDefaultSettings(Project *project) {
|
||||
void NewMapDialog::setDefaultSettings(Project *project) {
|
||||
settings.group = project->groupNames.at(0);
|
||||
settings.width = project->getDefaultMapSize();
|
||||
settings.height = project->getDefaultMapSize();
|
||||
|
|
@ -198,7 +198,7 @@ void NewMapPopup::setDefaultSettings(Project *project) {
|
|||
settings.floorNumber = 0;
|
||||
}
|
||||
|
||||
void NewMapPopup::saveSettings() {
|
||||
void NewMapDialog::saveSettings() {
|
||||
settings.group = ui->comboBox_NewMap_Group->currentText();
|
||||
settings.width = ui->spinBox_NewMap_Width->value();
|
||||
settings.height = ui->spinBox_NewMap_Height->value();
|
||||
|
|
@ -217,7 +217,7 @@ void NewMapPopup::saveSettings() {
|
|||
settings.floorNumber = ui->spinBox_NewMap_Floor_Number->value();
|
||||
}
|
||||
|
||||
void NewMapPopup::useLayoutSettings(Layout *layout) {
|
||||
void NewMapDialog::useLayoutSettings(Layout *layout) {
|
||||
if (!layout) return;
|
||||
|
||||
settings.width = layout->width;
|
||||
|
|
@ -239,7 +239,7 @@ void NewMapPopup::useLayoutSettings(Layout *layout) {
|
|||
ui->comboBox_NewMap_Secondary_Tileset->setCurrentIndex(ui->comboBox_NewMap_Secondary_Tileset->findText(layout->tileset_secondary_label));
|
||||
}
|
||||
|
||||
void NewMapPopup::useLayout(QString layoutId) {
|
||||
void NewMapDialog::useLayout(QString layoutId) {
|
||||
this->existingLayout = true;
|
||||
this->layoutId = layoutId;
|
||||
|
||||
|
|
@ -248,7 +248,7 @@ void NewMapPopup::useLayout(QString layoutId) {
|
|||
useLayoutSettings(project->mapLayouts.value(this->layoutId));
|
||||
}
|
||||
|
||||
void NewMapPopup::on_checkBox_UseExistingLayout_stateChanged(int state) {
|
||||
void NewMapDialog::on_checkBox_UseExistingLayout_stateChanged(int state) {
|
||||
bool layoutEditsEnabled = (state == Qt::Unchecked);
|
||||
|
||||
this->ui->comboBox_Layout->setEnabled(!layoutEditsEnabled);
|
||||
|
|
@ -267,13 +267,13 @@ void NewMapPopup::on_checkBox_UseExistingLayout_stateChanged(int state) {
|
|||
}
|
||||
}
|
||||
|
||||
void NewMapPopup::on_comboBox_Layout_currentTextChanged(const QString &text) {
|
||||
void NewMapDialog::on_comboBox_Layout_currentTextChanged(const QString &text) {
|
||||
if (this->project->mapLayoutsTable.contains(text)) {
|
||||
useLayout(text);
|
||||
}
|
||||
}
|
||||
|
||||
void NewMapPopup::on_lineEdit_NewMap_Name_textChanged(const QString &text) {
|
||||
void NewMapDialog::on_lineEdit_NewMap_Name_textChanged(const QString &text) {
|
||||
if (project->mapNames.contains(text)) {
|
||||
this->ui->lineEdit_NewMap_Name->setStyleSheet("QLineEdit { background-color: rgba(255, 0, 0, 25%) }");
|
||||
} else {
|
||||
|
|
@ -281,7 +281,7 @@ void NewMapPopup::on_lineEdit_NewMap_Name_textChanged(const QString &text) {
|
|||
}
|
||||
}
|
||||
|
||||
void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
|
||||
void NewMapDialog::on_pushButton_NewMap_Accept_clicked() {
|
||||
if (!checkNewMapDimensions() || !checkNewMapGroup()) {
|
||||
// ignore when map dimensions or map group are invalid
|
||||
return;
|
||||
Loading…
Reference in New Issue
Block a user