commit
89f2779291
16 changed files with 58 additions and 30 deletions
|
@ -177,6 +177,7 @@ private:
|
||||||
DraggablePixmapItem *selectedHealspot;
|
DraggablePixmapItem *selectedHealspot;
|
||||||
|
|
||||||
bool isProgrammaticEventTabChange;
|
bool isProgrammaticEventTabChange;
|
||||||
|
bool projectHasUnsavedChanges;
|
||||||
|
|
||||||
MapSortOrder mapSortOrder;
|
MapSortOrder mapSortOrder;
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
|
|
||||||
class CityMapPixmapItem : public QObject, public QGraphicsPixmapItem {
|
class CityMapPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
using QGraphicsPixmapItem::paint;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CityMapPixmapItem(QString fname, TilemapTileSelector *tile_selector) {
|
CityMapPixmapItem(QString fname, TilemapTileSelector *tile_selector) {
|
||||||
this->file = fname;
|
this->file = fname;
|
||||||
|
|
|
@ -27,8 +27,7 @@ public:
|
||||||
height + penWidth * 2);
|
height + penWidth * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
|
||||||
QWidget *widget) override
|
|
||||||
{
|
{
|
||||||
if (!(*enabled)) return;
|
if (!(*enabled)) return;
|
||||||
int width = this->width;
|
int width = this->width;
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
|
|
||||||
class MapPixmapItem : public QObject, public QGraphicsPixmapItem {
|
class MapPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
using QGraphicsPixmapItem::paint;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MapPixmapItem(Map *map_, MetatileSelector *metatileSelector, Settings *settings) {
|
MapPixmapItem(Map *map_, MetatileSelector *metatileSelector, Settings *settings) {
|
||||||
this->map = map_;
|
this->map = map_;
|
||||||
|
|
|
@ -18,8 +18,7 @@ public:
|
||||||
20 * 8 + penWidth * 2);
|
20 * 8 + penWidth * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
|
||||||
QWidget *widget) override
|
|
||||||
{
|
{
|
||||||
painter->setPen(this->color);
|
painter->setPen(this->color);
|
||||||
painter->drawRect(-2, -2, this->width + 3, this->height + 3);
|
painter->drawRect(-2, -2, this->width + 3, this->height + 3);
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
|
|
||||||
class RegionMapPixmapItem : public QObject, public QGraphicsPixmapItem {
|
class RegionMapPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
using QGraphicsPixmapItem::paint;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RegionMapPixmapItem(RegionMap *rmap, TilemapTileSelector *tile_selector) {
|
RegionMapPixmapItem(RegionMap *rmap, TilemapTileSelector *tile_selector) {
|
||||||
this->region_map = rmap;
|
this->region_map = rmap;
|
||||||
|
|
|
@ -34,7 +34,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int numTilesWide;
|
int numTilesWide;
|
||||||
int numTiles;
|
size_t numTiles;
|
||||||
void updateSelectedTile();
|
void updateSelectedTile();
|
||||||
unsigned getTileId(int x, int y);
|
unsigned getTileId(int x, int y);
|
||||||
QPoint getTileIdCoords(unsigned);
|
QPoint getTileIdCoords(unsigned);
|
||||||
|
|
|
@ -12,7 +12,7 @@ TARGET = porymap
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
RC_ICONS = resources/icons/porymap-icon-1.ico
|
RC_ICONS = resources/icons/porymap-icon-1.ico
|
||||||
ICON = resources/icons/porymap.icns
|
ICON = resources/icons/porymap.icns
|
||||||
QMAKE_CXXFLAGS += -std=c++11
|
QMAKE_CXXFLAGS += -std=c++11 -Wall
|
||||||
|
|
||||||
SOURCES += src/core/block.cpp \
|
SOURCES += src/core/block.cpp \
|
||||||
src/core/blockdata.cpp \
|
src/core/blockdata.cpp \
|
||||||
|
|
|
@ -467,7 +467,7 @@ void Editor::onMapStartPaint(QGraphicsSceneMouseEvent *event, MapPixmapItem *ite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::onMapEndPaint(QGraphicsSceneMouseEvent *event, MapPixmapItem *item) {
|
void Editor::onMapEndPaint(QGraphicsSceneMouseEvent *, MapPixmapItem *item) {
|
||||||
if (!item->paintingEnabled) {
|
if (!item->paintingEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,8 @@ void MainWindow::setProjectSpecificUIVisibility()
|
||||||
ui->label_AllowBiking->setVisible(true);
|
ui->label_AllowBiking->setVisible(true);
|
||||||
ui->label_AllowEscapeRope->setVisible(true);
|
ui->label_AllowEscapeRope->setVisible(true);
|
||||||
break;
|
break;
|
||||||
|
case BaseGameVersion::pokefirered:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -999,6 +1001,7 @@ void MainWindow::on_mapList_activated(const QModelIndex &index)
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::drawMapListIcons(QAbstractItemModel *model) {
|
void MainWindow::drawMapListIcons(QAbstractItemModel *model) {
|
||||||
|
projectHasUnsavedChanges = false;
|
||||||
QList<QModelIndex> list;
|
QList<QModelIndex> list;
|
||||||
list.append(QModelIndex());
|
list.append(QModelIndex());
|
||||||
while (list.length()) {
|
while (list.length()) {
|
||||||
|
@ -1016,6 +1019,7 @@ void MainWindow::drawMapListIcons(QAbstractItemModel *model) {
|
||||||
map->setIcon(*mapIcon);
|
map->setIcon(*mapIcon);
|
||||||
if (editor->project->map_cache->value(map_name)->hasUnsavedChanges()) {
|
if (editor->project->map_cache->value(map_name)->hasUnsavedChanges()) {
|
||||||
map->setIcon(*mapEditedIcon);
|
map->setIcon(*mapEditedIcon);
|
||||||
|
projectHasUnsavedChanges = true;
|
||||||
}
|
}
|
||||||
if (editor->map->name == map_name) {
|
if (editor->map->name == map_name) {
|
||||||
map->setIcon(*mapOpenedIcon);
|
map->setIcon(*mapOpenedIcon);
|
||||||
|
@ -2122,7 +2126,7 @@ void MainWindow::on_pushButton_DeleteCustomHeaderField_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_tableWidget_CustomHeaderFields_cellChanged(int row, int column)
|
void MainWindow::on_tableWidget_CustomHeaderFields_cellChanged(int, int)
|
||||||
{
|
{
|
||||||
this->editor->updateCustomMapHeaderValues(this->ui->tableWidget_CustomHeaderFields);
|
this->editor->updateCustomMapHeaderValues(this->ui->tableWidget_CustomHeaderFields);
|
||||||
}
|
}
|
||||||
|
@ -2168,6 +2172,21 @@ void MainWindow::on_actionRegion_Map_Editor_triggered() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent *event) {
|
void MainWindow::closeEvent(QCloseEvent *event) {
|
||||||
|
if (projectHasUnsavedChanges || editor->map->hasUnsavedChanges()) {
|
||||||
|
QMessageBox::StandardButton result = QMessageBox::question(
|
||||||
|
this, "porymap", "The project has been modified, save changes?",
|
||||||
|
QMessageBox::No | QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes);
|
||||||
|
|
||||||
|
if (result == QMessageBox::Yes) {
|
||||||
|
editor->saveProject();
|
||||||
|
} else if (result == QMessageBox::No) {
|
||||||
|
logWarn("Closing porymap with unsaved changes.");
|
||||||
|
} else if (result == QMessageBox::Cancel) {
|
||||||
|
event->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
porymapConfig.setGeometry(
|
porymapConfig.setGeometry(
|
||||||
this->saveGeometry(),
|
this->saveGeometry(),
|
||||||
this->saveState(),
|
this->saveState(),
|
||||||
|
|
|
@ -671,7 +671,7 @@ void Project::saveTilesetTilesImage(Tileset *tileset) {
|
||||||
tileset->tilesImage.save(tileset->tilesImagePath);
|
tileset->tilesImage.save(tileset->tilesImagePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::saveTilesetPalettes(Tileset *tileset, bool primary) {
|
void Project::saveTilesetPalettes(Tileset *tileset, bool /*primary*/) {
|
||||||
PaletteUtil paletteParser;
|
PaletteUtil paletteParser;
|
||||||
for (int i = 0; i < Project::getNumPalettesTotal(); i++) {
|
for (int i = 0; i < Project::getNumPalettesTotal(); i++) {
|
||||||
QString filepath = tileset->palettePaths.at(i);
|
QString filepath = tileset->palettePaths.at(i);
|
||||||
|
|
|
@ -93,6 +93,8 @@ void NewMapPopup::setDefaultValues(int groupNum, QString mapSec) {
|
||||||
ui->label_NewMap_Allow_Biking->setVisible(true);
|
ui->label_NewMap_Allow_Biking->setVisible(true);
|
||||||
ui->label_NewMap_Allow_Escape_Rope->setVisible(true);
|
ui->label_NewMap_Allow_Escape_Rope->setVisible(true);
|
||||||
break;
|
break;
|
||||||
|
case BaseGameVersion::pokefirered:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,6 +131,7 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
|
||||||
|
|
||||||
if (this->existingLayout) {
|
if (this->existingLayout) {
|
||||||
layout = this->project->mapLayouts.value(this->layoutId);
|
layout = this->project->mapLayouts.value(this->layoutId);
|
||||||
|
newMap->needsLayoutDir = false;
|
||||||
} else {
|
} else {
|
||||||
layout = new MapLayout;
|
layout = new MapLayout;
|
||||||
layout->id = MapLayout::layoutConstantFromName(newMapName);
|
layout->id = MapLayout::layoutConstantFromName(newMapName);
|
||||||
|
@ -154,7 +157,7 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
|
||||||
group = project->groupNames->indexOf(this->ui->comboBox_NewMap_Group->currentText());
|
group = project->groupNames->indexOf(this->ui->comboBox_NewMap_Group->currentText());
|
||||||
newMap->layout = layout;
|
newMap->layout = layout;
|
||||||
newMap->layoutId = layout->id;
|
newMap->layoutId = layout->id;
|
||||||
project->loadMapLayout(newMap);
|
if (this->existingLayout) project->loadMapLayout(newMap);
|
||||||
newMap->group_num = QString::number(group);
|
newMap->group_num = QString::number(group);
|
||||||
map = newMap;
|
map = newMap;
|
||||||
emit applied();
|
emit applied();
|
||||||
|
|
|
@ -445,11 +445,6 @@ void RegionMapEditor::mouseEvent_region_map(QGraphicsSceneMouseEvent *event, Reg
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::mouseEvent_city_map(QGraphicsSceneMouseEvent *event, CityMapPixmapItem *item) {
|
void RegionMapEditor::mouseEvent_city_map(QGraphicsSceneMouseEvent *event, CityMapPixmapItem *item) {
|
||||||
QPointF pos = event->pos();
|
|
||||||
int x = static_cast<int>(pos.x()) / 8;
|
|
||||||
int y = static_cast<int>(pos.y()) / 8;
|
|
||||||
int index = this->city_map_item->getIndexAt(x, y);
|
|
||||||
|
|
||||||
if (cityMapFirstDraw) {
|
if (cityMapFirstDraw) {
|
||||||
RegionMapHistoryItem *commit = new RegionMapHistoryItem(
|
RegionMapHistoryItem *commit = new RegionMapHistoryItem(
|
||||||
RegionMapEditorBox::CityMapImage, this->city_map_item->getTiles(), this->city_map_item->file
|
RegionMapEditorBox::CityMapImage, this->city_map_item->getTiles(), this->city_map_item->file
|
||||||
|
@ -548,7 +543,7 @@ void RegionMapEditor::on_spinBox_RM_Entry_height_valueChanged(int height) {
|
||||||
this->hasUnsavedChanges = true;
|
this->hasUnsavedChanges = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_lineEdit_RM_MapName_textEdited(const QString &text) {
|
void RegionMapEditor::on_lineEdit_RM_MapName_textEdited(const QString &) {
|
||||||
this->hasUnsavedChanges = true;
|
this->hasUnsavedChanges = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ void RegionMapEntriesPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEntriesPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
void RegionMapEntriesPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *) {
|
||||||
this->draggingEntry = false;
|
this->draggingEntry = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ void RegionMapLayoutPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
mousePressEvent(event);
|
mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapLayoutPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {}
|
void RegionMapLayoutPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *) {}
|
||||||
|
|
||||||
void RegionMapLayoutPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
|
void RegionMapLayoutPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
|
||||||
QPoint pos = this->getCellPos(event->pos());
|
QPoint pos = this->getCellPos(event->pos());
|
||||||
|
@ -78,7 +78,7 @@ void RegionMapLayoutPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
emit this->hoveredTileChanged(tileId);
|
emit this->hoveredTileChanged(tileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapLayoutPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) {
|
void RegionMapLayoutPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
|
||||||
emit this->hoveredTileCleared();
|
emit this->hoveredTileCleared();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ unsigned TilemapTileSelector::getSelectedTile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned TilemapTileSelector::getTileId(int x, int y) {
|
unsigned TilemapTileSelector::getTileId(int x, int y) {
|
||||||
int index = y * this->numTilesWide + x;
|
unsigned index = y * this->numTilesWide + x;
|
||||||
return index < this->numTiles ? index : this->numTiles % index;
|
return index < this->numTiles ? index : this->numTiles % index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,6 @@ void TilemapTileSelector::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
|
||||||
emit this->hoveredTileChanged(tileId);
|
emit this->hoveredTileChanged(tileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TilemapTileSelector::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) {
|
void TilemapTileSelector::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
|
||||||
emit this->hoveredTileCleared();
|
emit this->hoveredTileCleared();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue