commit
89f2779291
16 changed files with 58 additions and 30 deletions
|
@ -177,6 +177,7 @@ private:
|
|||
DraggablePixmapItem *selectedHealspot;
|
||||
|
||||
bool isProgrammaticEventTabChange;
|
||||
bool projectHasUnsavedChanges;
|
||||
|
||||
MapSortOrder mapSortOrder;
|
||||
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
|
||||
class CityMapPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
using QGraphicsPixmapItem::paint;
|
||||
|
||||
public:
|
||||
CityMapPixmapItem(QString fname, TilemapTileSelector *tile_selector) {
|
||||
this->file = fname;
|
||||
|
@ -25,7 +29,7 @@ public:
|
|||
void init();
|
||||
void save();
|
||||
void create(QString);
|
||||
virtual void paint(QGraphicsSceneMouseEvent*);
|
||||
virtual void paint(QGraphicsSceneMouseEvent *);
|
||||
virtual void draw();
|
||||
int getIndexAt(int, int);
|
||||
int width();
|
||||
|
|
|
@ -27,8 +27,7 @@ public:
|
|||
height + penWidth * 2);
|
||||
}
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget) override
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
|
||||
{
|
||||
if (!(*enabled)) return;
|
||||
int width = this->width;
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
|
||||
class MapPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
using QGraphicsPixmapItem::paint;
|
||||
|
||||
public:
|
||||
MapPixmapItem(Map *map_, MetatileSelector *metatileSelector, Settings *settings) {
|
||||
this->map = map_;
|
||||
|
|
|
@ -18,8 +18,7 @@ public:
|
|||
20 * 8 + penWidth * 2);
|
||||
}
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget) override
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
|
||||
{
|
||||
painter->setPen(this->color);
|
||||
painter->drawRect(-2, -2, this->width + 3, this->height + 3);
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
|
||||
class RegionMapPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
using QGraphicsPixmapItem::paint;
|
||||
|
||||
public:
|
||||
RegionMapPixmapItem(RegionMap *rmap, TilemapTileSelector *tile_selector) {
|
||||
this->region_map = rmap;
|
||||
|
@ -16,8 +20,8 @@ public:
|
|||
RegionMap *region_map;
|
||||
TilemapTileSelector *tile_selector;
|
||||
|
||||
virtual void paint(QGraphicsSceneMouseEvent*);
|
||||
virtual void select(QGraphicsSceneMouseEvent*);
|
||||
virtual void paint(QGraphicsSceneMouseEvent *);
|
||||
virtual void select(QGraphicsSceneMouseEvent *);
|
||||
virtual void draw();
|
||||
|
||||
signals:
|
||||
|
@ -26,11 +30,11 @@ signals:
|
|||
void hoveredRegionMapTileCleared();
|
||||
|
||||
protected:
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent*);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent *);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
||||
};
|
||||
|
||||
#endif // REGIONMAPPIXMAPITEM_H
|
||||
|
|
|
@ -34,7 +34,7 @@ protected:
|
|||
|
||||
private:
|
||||
int numTilesWide;
|
||||
int numTiles;
|
||||
size_t numTiles;
|
||||
void updateSelectedTile();
|
||||
unsigned getTileId(int x, int y);
|
||||
QPoint getTileIdCoords(unsigned);
|
||||
|
|
|
@ -12,7 +12,7 @@ TARGET = porymap
|
|||
TEMPLATE = app
|
||||
RC_ICONS = resources/icons/porymap-icon-1.ico
|
||||
ICON = resources/icons/porymap.icns
|
||||
QMAKE_CXXFLAGS += -std=c++11
|
||||
QMAKE_CXXFLAGS += -std=c++11 -Wall
|
||||
|
||||
SOURCES += src/core/block.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) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -161,6 +161,8 @@ void MainWindow::setProjectSpecificUIVisibility()
|
|||
ui->label_AllowBiking->setVisible(true);
|
||||
ui->label_AllowEscapeRope->setVisible(true);
|
||||
break;
|
||||
case BaseGameVersion::pokefirered:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -999,6 +1001,7 @@ void MainWindow::on_mapList_activated(const QModelIndex &index)
|
|||
}
|
||||
|
||||
void MainWindow::drawMapListIcons(QAbstractItemModel *model) {
|
||||
projectHasUnsavedChanges = false;
|
||||
QList<QModelIndex> list;
|
||||
list.append(QModelIndex());
|
||||
while (list.length()) {
|
||||
|
@ -1016,6 +1019,7 @@ void MainWindow::drawMapListIcons(QAbstractItemModel *model) {
|
|||
map->setIcon(*mapIcon);
|
||||
if (editor->project->map_cache->value(map_name)->hasUnsavedChanges()) {
|
||||
map->setIcon(*mapEditedIcon);
|
||||
projectHasUnsavedChanges = true;
|
||||
}
|
||||
if (editor->map->name == map_name) {
|
||||
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);
|
||||
}
|
||||
|
@ -2168,6 +2172,21 @@ void MainWindow::on_actionRegion_Map_Editor_triggered() {
|
|||
}
|
||||
|
||||
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(
|
||||
this->saveGeometry(),
|
||||
this->saveState(),
|
||||
|
|
|
@ -671,7 +671,7 @@ void Project::saveTilesetTilesImage(Tileset *tileset) {
|
|||
tileset->tilesImage.save(tileset->tilesImagePath);
|
||||
}
|
||||
|
||||
void Project::saveTilesetPalettes(Tileset *tileset, bool primary) {
|
||||
void Project::saveTilesetPalettes(Tileset *tileset, bool /*primary*/) {
|
||||
PaletteUtil paletteParser;
|
||||
for (int i = 0; i < Project::getNumPalettesTotal(); 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_Escape_Rope->setVisible(true);
|
||||
break;
|
||||
case BaseGameVersion::pokefirered:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,6 +131,7 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
|
|||
|
||||
if (this->existingLayout) {
|
||||
layout = this->project->mapLayouts.value(this->layoutId);
|
||||
newMap->needsLayoutDir = false;
|
||||
} else {
|
||||
layout = new MapLayout;
|
||||
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());
|
||||
newMap->layout = layout;
|
||||
newMap->layoutId = layout->id;
|
||||
project->loadMapLayout(newMap);
|
||||
if (this->existingLayout) project->loadMapLayout(newMap);
|
||||
newMap->group_num = QString::number(group);
|
||||
map = newMap;
|
||||
emit applied();
|
||||
|
|
|
@ -445,11 +445,6 @@ void RegionMapEditor::mouseEvent_region_map(QGraphicsSceneMouseEvent *event, Reg
|
|||
}
|
||||
|
||||
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) {
|
||||
RegionMapHistoryItem *commit = new RegionMapHistoryItem(
|
||||
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;
|
||||
}
|
||||
|
||||
void RegionMapEditor::on_lineEdit_RM_MapName_textEdited(const QString &text) {
|
||||
void RegionMapEditor::on_lineEdit_RM_MapName_textEdited(const QString &) {
|
||||
this->hasUnsavedChanges = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ void RegionMapEntriesPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
void RegionMapEntriesPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
||||
void RegionMapEntriesPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *) {
|
||||
this->draggingEntry = false;
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ void RegionMapEntriesPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
|||
event->ignore();
|
||||
}
|
||||
|
||||
void RegionMapEntriesPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) {
|
||||
void RegionMapEntriesPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ void RegionMapLayoutPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
mousePressEvent(event);
|
||||
}
|
||||
|
||||
void RegionMapLayoutPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {}
|
||||
void RegionMapLayoutPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *) {}
|
||||
|
||||
void RegionMapLayoutPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
|
||||
QPoint pos = this->getCellPos(event->pos());
|
||||
|
@ -78,7 +78,7 @@ void RegionMapLayoutPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
|||
emit this->hoveredTileChanged(tileId);
|
||||
}
|
||||
|
||||
void RegionMapLayoutPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) {
|
||||
void RegionMapLayoutPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
|
||||
emit this->hoveredTileCleared();
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ unsigned TilemapTileSelector::getSelectedTile() {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,6 @@ void TilemapTileSelector::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
|
|||
emit this->hoveredTileChanged(tileId);
|
||||
}
|
||||
|
||||
void TilemapTileSelector::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) {
|
||||
void TilemapTileSelector::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
|
||||
emit this->hoveredTileCleared();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue