clean rme UI, undo / redo history, new city maps
This commit is contained in:
parent
d3a16d34df
commit
83f3cef52e
10 changed files with 1230 additions and 785 deletions
File diff suppressed because it is too large
Load diff
|
@ -12,4 +12,19 @@ public:
|
||||||
~HistoryItem();
|
~HistoryItem();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum RegionMapEditorBox {
|
||||||
|
BackgroundImage = 1,
|
||||||
|
CityMapImage = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
class RegionMapHistoryItem {
|
||||||
|
public:
|
||||||
|
int which;// region map or city map
|
||||||
|
int index;
|
||||||
|
unsigned tile;
|
||||||
|
unsigned prev;
|
||||||
|
RegionMapHistoryItem(int type, int index, unsigned prev, unsigned tile);
|
||||||
|
~RegionMapHistoryItem();
|
||||||
|
};
|
||||||
|
|
||||||
#endif // HISTORYITEM_H
|
#endif // HISTORYITEM_H
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "tilemaptileselector.h"
|
#include "tilemaptileselector.h"
|
||||||
|
#include "history.h"
|
||||||
|
#include "historyitem.h"
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
@ -73,6 +75,8 @@ public:
|
||||||
//RegionMapSquare *map_squares = nullptr;// array of RegionMapSquares
|
//RegionMapSquare *map_squares = nullptr;// array of RegionMapSquares
|
||||||
QList<RegionMapSquare> map_squares;
|
QList<RegionMapSquare> map_squares;
|
||||||
|
|
||||||
|
History<RegionMapHistoryItem*> history;
|
||||||
|
|
||||||
QString temp_path;// delete this
|
QString temp_path;// delete this
|
||||||
QString city_map_squares_path;
|
QString city_map_squares_path;
|
||||||
QString region_map_png_path;
|
QString region_map_png_path;
|
||||||
|
@ -125,6 +129,8 @@ public:
|
||||||
unsigned getTileId(int, int);
|
unsigned getTileId(int, int);
|
||||||
int getMapSquareIndex(int, int);
|
int getMapSquareIndex(int, int);
|
||||||
|
|
||||||
|
void deleteLayoutSquare(int);
|
||||||
|
|
||||||
// implement these here?
|
// implement these here?
|
||||||
void undo();
|
void undo();
|
||||||
void redo();
|
void redo();
|
||||||
|
@ -134,6 +140,7 @@ public:
|
||||||
// TODO: move read / write functions to private (and others)
|
// TODO: move read / write functions to private (and others)
|
||||||
private:
|
private:
|
||||||
//
|
//
|
||||||
|
//History<QPair<int, uint8_t>> *history;// (index, tile)
|
||||||
int layout_width_;
|
int layout_width_;
|
||||||
int layout_height_;
|
int layout_height_;
|
||||||
int img_width_;
|
int img_width_;
|
||||||
|
|
|
@ -18,6 +18,7 @@ public:
|
||||||
|
|
||||||
QString file;
|
QString file;
|
||||||
|
|
||||||
|
// TODO: make private and use access functions
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
|
||||||
|
@ -28,6 +29,11 @@ public:
|
||||||
void create(QString);
|
void create(QString);
|
||||||
virtual void paint(QGraphicsSceneMouseEvent*);
|
virtual void paint(QGraphicsSceneMouseEvent*);
|
||||||
virtual void draw();
|
virtual void draw();
|
||||||
|
int getIndexAt(int, int);
|
||||||
|
|
||||||
|
//private:
|
||||||
|
// int width;
|
||||||
|
// int height;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void mouseEvent(QGraphicsSceneMouseEvent *, CityMapPixmapItem *);
|
void mouseEvent(QGraphicsSceneMouseEvent *, CityMapPixmapItem *);
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include "citymappixmapitem.h"
|
#include "citymappixmapitem.h"
|
||||||
#include "regionmaplayoutpixmapitem.h"
|
#include "regionmaplayoutpixmapitem.h"
|
||||||
#include "regionmap.h"
|
#include "regionmap.h"
|
||||||
|
#include "history.h"
|
||||||
|
#include "historyitem.h"
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
@ -55,17 +57,45 @@ public:
|
||||||
void onRegionMapLayoutHoveredTileChanged(int);
|
void onRegionMapLayoutHoveredTileChanged(int);
|
||||||
void onRegionMapLayoutHoveredTileCleared();
|
void onRegionMapLayoutHoveredTileCleared();
|
||||||
|
|
||||||
|
void undo();
|
||||||
|
void redo();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::RegionMapEditor *ui;
|
Ui::RegionMapEditor *ui;
|
||||||
Project *project;
|
Project *project;
|
||||||
|
|
||||||
QString rmStatusbarMessage;
|
QString rmStatusbarMessage;
|
||||||
|
History<RegionMapHistoryItem*> history;
|
||||||
|
|
||||||
|
double scaleUpFactor = 2.0;
|
||||||
|
double scaleDownFactor = 1.0 / scaleUpFactor;
|
||||||
|
|
||||||
|
double scaleRegionMapTiles = 1.0;
|
||||||
|
double scaleRegionMapImage = 1.0;
|
||||||
|
double scaleCityMapTiles = 1.0;
|
||||||
|
double scaleCityMapImage = 1.0;
|
||||||
|
|
||||||
|
void scaleUp(QGraphicsView *, qreal factor, qreal width, qreal height);
|
||||||
|
|
||||||
|
bool createCityMap(QString);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_action_RegionMap_Save_triggered();
|
void on_action_RegionMap_Save_triggered();
|
||||||
|
void on_action_RegionMap_Undo_triggered();
|
||||||
|
void on_action_RegionMap_Redo_triggered();
|
||||||
void on_tabWidget_Region_Map_currentChanged(int);
|
void on_tabWidget_Region_Map_currentChanged(int);
|
||||||
void on_pushButton_RM_Options_save_clicked();
|
void on_pushButton_RM_Options_save_clicked();
|
||||||
|
void on_pushButton_RM_Options_delete_clicked();
|
||||||
void on_pushButton_CityMap_save_clicked();
|
void on_pushButton_CityMap_save_clicked();
|
||||||
|
void on_pushButton_CityMap_add_clicked();//
|
||||||
|
void on_pushButton_Zoom_In_Image_Tiles_clicked();
|
||||||
|
void on_pushButton_Zoom_Out_Image_Tiles_clicked();
|
||||||
|
void on_pushButton_Zoom_In_City_Tiles_clicked();
|
||||||
|
void on_pushButton_Zoom_Out_City_Tiles_clicked();
|
||||||
|
void on_pushButton_Zoom_In_City_Map_clicked();//
|
||||||
|
void on_pushButton_Zoom_Out_City_Map_clicked();
|
||||||
|
void on_pushButton_Zoom_In_Map_Image_clicked();
|
||||||
|
void on_pushButton_Zoom_Out_Map_Image_clicked();//
|
||||||
void on_comboBox_CityMap_picker_currentTextChanged(const QString &);
|
void on_comboBox_CityMap_picker_currentTextChanged(const QString &);
|
||||||
void onHoveredRegionMapTileChanged(int, int);
|
void onHoveredRegionMapTileChanged(int, int);
|
||||||
void onHoveredRegionMapTileCleared();
|
void onHoveredRegionMapTileCleared();
|
||||||
|
|
|
@ -9,3 +9,12 @@ HistoryItem::HistoryItem(Blockdata *metatiles, int layoutWidth, int layoutHeight
|
||||||
HistoryItem::~HistoryItem() {
|
HistoryItem::~HistoryItem() {
|
||||||
if (this->metatiles) delete this->metatiles;
|
if (this->metatiles) delete this->metatiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RegionMapHistoryItem::RegionMapHistoryItem(int which_, int index_, unsigned prev_, unsigned tile_) {
|
||||||
|
this->which = which_;
|
||||||
|
this->index = index_;
|
||||||
|
this->prev = prev_;
|
||||||
|
this->tile = tile_;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegionMapHistoryItem::~RegionMapHistoryItem() {}
|
||||||
|
|
|
@ -342,7 +342,6 @@ void Map::_floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Map::undo() {
|
void Map::undo() {
|
||||||
HistoryItem *commit = metatileHistory.back();
|
HistoryItem *commit = metatileHistory.back();
|
||||||
if (!commit)
|
if (!commit)
|
||||||
|
|
|
@ -37,7 +37,7 @@ void CityMapPixmapItem::draw() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CityMapPixmapItem::save() {
|
void CityMapPixmapItem::save() {
|
||||||
//
|
// TODO: logError / logWarn if fail
|
||||||
QFile binFile(file);
|
QFile binFile(file);
|
||||||
if (!binFile.open(QIODevice::WriteOnly)) return;
|
if (!binFile.open(QIODevice::WriteOnly)) return;
|
||||||
binFile.write(data);
|
binFile.write(data);
|
||||||
|
@ -49,7 +49,7 @@ void CityMapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
||||||
QPointF pos = event->pos();
|
QPointF pos = event->pos();
|
||||||
int x = static_cast<int>(pos.x()) / 8;
|
int x = static_cast<int>(pos.x()) / 8;
|
||||||
int y = static_cast<int>(pos.y()) / 8;
|
int y = static_cast<int>(pos.y()) / 8;
|
||||||
int index = 2 * (x + y * width);
|
int index = getIndexAt(x, y);
|
||||||
data[index] = static_cast<uint8_t>(this->tile_selector->selectedTile);
|
data[index] = static_cast<uint8_t>(this->tile_selector->selectedTile);
|
||||||
|
|
||||||
draw();
|
draw();
|
||||||
|
@ -61,3 +61,8 @@ void CityMapPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
int y = static_cast<int>(pos.y()) / 8;
|
int y = static_cast<int>(pos.y()) / 8;
|
||||||
emit mouseEvent(event, this);
|
emit mouseEvent(event, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CityMapPixmapItem::getIndexAt(int x, int y) {
|
||||||
|
//
|
||||||
|
return 2 * (x + y * width);
|
||||||
|
}
|
||||||
|
|
|
@ -2,14 +2,21 @@
|
||||||
#include "ui_regionmapeditor.h"
|
#include "ui_regionmapeditor.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QColor>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
RegionMapEditor::RegionMapEditor(QWidget *parent, Project *pro) :
|
RegionMapEditor::RegionMapEditor(QWidget *parent, Project *pro) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::RegionMapEditor)
|
ui(new Ui::RegionMapEditor)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
this->ui->setupUi(this);
|
||||||
this->project = pro;
|
this->project = pro;
|
||||||
this->region_map = new RegionMap;
|
this->region_map = new RegionMap;
|
||||||
|
this->setFixedSize(this->size());//statusbar->setSizeGripEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionMapEditor::~RegionMapEditor()
|
RegionMapEditor::~RegionMapEditor()
|
||||||
|
@ -157,7 +164,8 @@ void RegionMapEditor::displayCityMapTileSelector() {
|
||||||
|
|
||||||
this->ui->graphicsView_City_Map_Tiles->setScene(this->scene_city_map_tiles);
|
this->ui->graphicsView_City_Map_Tiles->setScene(this->scene_city_map_tiles);
|
||||||
this->ui->graphicsView_City_Map_Tiles->setFixedSize(this->city_map_selector_item->pixelWidth + 2,
|
this->ui->graphicsView_City_Map_Tiles->setFixedSize(this->city_map_selector_item->pixelWidth + 2,
|
||||||
this->city_map_selector_item->pixelHeight + 2);
|
this->city_map_selector_item->pixelHeight + 2);
|
||||||
|
//this->ui->graphicsView_City_Map_Tiles->scale(2,2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::displayCityMap(QString f) {
|
void RegionMapEditor::displayCityMap(QString f) {
|
||||||
|
@ -182,10 +190,39 @@ void RegionMapEditor::displayCityMap(QString f) {
|
||||||
scene_city_map_image->setSceneRect(this->scene_city_map_image->sceneRect());
|
scene_city_map_image->setSceneRect(this->scene_city_map_image->sceneRect());
|
||||||
|
|
||||||
this->ui->graphicsView_City_Map->setScene(scene_city_map_image);
|
this->ui->graphicsView_City_Map->setScene(scene_city_map_image);
|
||||||
this->ui->graphicsView_City_Map->setFixedSize(QSize(82,82));
|
this->ui->graphicsView_City_Map->setFixedSize(QSize(8 * city_map_item->width + 2, 8 * city_map_item->height + 2));
|
||||||
// set fixed size?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RegionMapEditor::createCityMap(QString name) {
|
||||||
|
//
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -211,7 +248,7 @@ void RegionMapEditor::onRegionMapLayoutSelectedTileChanged(int index) {
|
||||||
QString message = QString();
|
QString message = QString();
|
||||||
if (this->region_map->map_squares[index].has_map) {
|
if (this->region_map->map_squares[index].has_map) {
|
||||||
//
|
//
|
||||||
message = QString("Map: %1").arg(this->project->mapSecToMapHoverName->value(
|
message = QString("\t %1").arg(this->project->mapSecToMapHoverName->value(
|
||||||
this->region_map->map_squares[index].mapsec)).remove("{NAME_END}");//.remove("{NAME_END}")
|
this->region_map->map_squares[index].mapsec)).remove("{NAME_END}");//.remove("{NAME_END}")
|
||||||
}
|
}
|
||||||
this->ui->statusbar->showMessage(message);
|
this->ui->statusbar->showMessage(message);
|
||||||
|
@ -228,7 +265,7 @@ void RegionMapEditor::onRegionMapLayoutHoveredTileChanged(int index) {
|
||||||
message = QString("(%1, %2)").arg(x).arg(y);
|
message = QString("(%1, %2)").arg(x).arg(y);
|
||||||
if (this->region_map->map_squares[index].has_map) {
|
if (this->region_map->map_squares[index].has_map) {
|
||||||
//
|
//
|
||||||
message += QString("Map: %1").arg(this->project->mapSecToMapHoverName->value(
|
message += QString("\t %1").arg(this->project->mapSecToMapHoverName->value(
|
||||||
this->region_map->map_squares[index].mapsec)).remove("{NAME_END}");
|
this->region_map->map_squares[index].mapsec)).remove("{NAME_END}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,7 +282,7 @@ void RegionMapEditor::onRegionMapLayoutHoveredTileCleared() {
|
||||||
message = QString("(%1, %2)").arg(x).arg(y);
|
message = QString("(%1, %2)").arg(x).arg(y);
|
||||||
if (this->region_map->map_squares[index].has_map) {
|
if (this->region_map->map_squares[index].has_map) {
|
||||||
//
|
//
|
||||||
message += QString("Map: %1").arg(this->project->mapSecToMapHoverName->value(
|
message += QString("\t %1").arg(this->project->mapSecToMapHoverName->value(
|
||||||
this->region_map->map_squares[index].mapsec)).remove("{NAME_END}");
|
this->region_map->map_squares[index].mapsec)).remove("{NAME_END}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,6 +307,13 @@ void RegionMapEditor::mouseEvent_region_map(QGraphicsSceneMouseEvent *event, Reg
|
||||||
// TODO: add functionality here? replace or?
|
// TODO: add functionality here? replace or?
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
|
QPointF pos = event->pos();
|
||||||
|
int x = static_cast<int>(pos.x()) / 8;
|
||||||
|
int y = static_cast<int>(pos.y()) / 8;
|
||||||
|
int index = this->region_map->getMapSquareIndex(x, y);
|
||||||
|
RegionMapHistoryItem *commit = new RegionMapHistoryItem(RegionMapEditorBox::BackgroundImage, index,
|
||||||
|
this->region_map->map_squares[index].tile_img_id, this->mapsquare_selector_item->getSelectedTile());
|
||||||
|
history.push(commit);
|
||||||
item->paint(event);
|
item->paint(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,6 +327,13 @@ void RegionMapEditor::mouseEvent_city_map(QGraphicsSceneMouseEvent *event, CityM
|
||||||
// TODO: add functionality here? replace or?
|
// TODO: add functionality here? replace or?
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
|
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);
|
||||||
|
RegionMapHistoryItem *commit = new RegionMapHistoryItem(RegionMapEditorBox::CityMapImage, index,
|
||||||
|
this->city_map_item->data[index], this->city_map_selector_item->getSelectedTile());
|
||||||
|
history.push(commit);
|
||||||
item->paint(event);
|
item->paint(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,12 +369,154 @@ void RegionMapEditor::on_pushButton_CityMap_save_clicked() {
|
||||||
this->city_map_item->save();
|
this->city_map_item->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RegionMapEditor::on_pushButton_RM_Options_delete_clicked() {
|
||||||
|
qDebug() << "delete it fat";
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegionMapEditor::on_pushButton_CityMap_add_clicked() {
|
||||||
|
QDialog popup(this, Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
|
||||||
|
popup.setWindowTitle("New City Map");
|
||||||
|
popup.setWindowModality(Qt::NonModal);
|
||||||
|
|
||||||
|
QFormLayout form(&popup);
|
||||||
|
|
||||||
|
QLineEdit *input = new QLineEdit();
|
||||||
|
form.addRow(new QLabel("Name:"), input);
|
||||||
|
|
||||||
|
QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &popup);
|
||||||
|
|
||||||
|
QString name;
|
||||||
|
|
||||||
|
form.addRow(&buttonBox);
|
||||||
|
connect(&buttonBox, SIGNAL(rejected()), &popup, SLOT(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegionMapEditor::on_action_RegionMap_Undo_triggered() {
|
||||||
|
RegionMapHistoryItem *commit = history.current();
|
||||||
|
if (!commit) return;
|
||||||
|
|
||||||
|
uint8_t tile = static_cast<uint8_t>(commit->prev);
|
||||||
|
|
||||||
|
history.back();
|
||||||
|
|
||||||
|
switch (commit->which)
|
||||||
|
{
|
||||||
|
case RegionMapEditorBox::BackgroundImage:
|
||||||
|
history.back();// TODO: why do I need to do this?
|
||||||
|
this->region_map->map_squares[commit->index].tile_img_id = tile;
|
||||||
|
this->region_map_item->draw();
|
||||||
|
break;
|
||||||
|
case RegionMapEditorBox::CityMapImage:
|
||||||
|
this->city_map_item->data[commit->index] = tile;
|
||||||
|
this->city_map_item->draw();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegionMapEditor::on_action_RegionMap_Redo_triggered() {
|
||||||
|
RegionMapHistoryItem *commit = history.next();
|
||||||
|
if (!commit) return;
|
||||||
|
|
||||||
|
uint8_t tile = static_cast<uint8_t>(commit->tile);
|
||||||
|
|
||||||
|
switch (commit->which)
|
||||||
|
{
|
||||||
|
case RegionMapEditorBox::BackgroundImage:
|
||||||
|
history.next();// TODO: why do I need to do this?
|
||||||
|
this->region_map->map_squares[commit->index].tile_img_id = tile;
|
||||||
|
this->region_map_item->draw();
|
||||||
|
break;
|
||||||
|
case RegionMapEditorBox::CityMapImage:
|
||||||
|
this->city_map_item->data[commit->index] = tile;
|
||||||
|
this->city_map_item->draw();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_comboBox_CityMap_picker_currentTextChanged(const QString &file) {
|
void RegionMapEditor::on_comboBox_CityMap_picker_currentTextChanged(const QString &file) {
|
||||||
this->displayCityMap(file);
|
this->displayCityMap(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: prevent huge images with limits on zoom
|
||||||
|
void RegionMapEditor::on_pushButton_Zoom_In_Image_Tiles_clicked() {
|
||||||
|
//
|
||||||
|
scaleRegionMapTiles *= 2.0;
|
||||||
|
this->ui->graphicsView_RegionMap_Tiles->setFixedSize(this->mapsquare_selector_item->pixelWidth * scaleRegionMapTiles + 2,
|
||||||
|
this->mapsquare_selector_item->pixelHeight * scaleRegionMapTiles + 2);
|
||||||
|
this->ui->graphicsView_RegionMap_Tiles->scale(2.0, 2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegionMapEditor::on_pushButton_Zoom_Out_Image_Tiles_clicked() {
|
||||||
|
//
|
||||||
|
scaleRegionMapTiles /= 2.0;
|
||||||
|
this->ui->graphicsView_RegionMap_Tiles->setFixedSize(this->mapsquare_selector_item->pixelWidth * scaleRegionMapTiles + 2,
|
||||||
|
this->mapsquare_selector_item->pixelHeight * scaleRegionMapTiles + 2);
|
||||||
|
this->ui->graphicsView_RegionMap_Tiles->scale(0.5, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegionMapEditor::on_pushButton_Zoom_In_City_Tiles_clicked() {
|
||||||
|
//
|
||||||
|
scaleCityMapTiles *= 2.0;
|
||||||
|
this->ui->graphicsView_City_Map_Tiles->setFixedSize(this->city_map_selector_item->pixelWidth * scaleCityMapTiles + 2,
|
||||||
|
this->city_map_selector_item->pixelHeight * scaleCityMapTiles + 2);
|
||||||
|
this->ui->graphicsView_City_Map_Tiles->scale(2.0,2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegionMapEditor::on_pushButton_Zoom_Out_City_Tiles_clicked() {
|
||||||
|
//
|
||||||
|
scaleCityMapTiles /= 2.0;
|
||||||
|
this->ui->graphicsView_City_Map_Tiles->setFixedSize(this->city_map_selector_item->pixelWidth * scaleCityMapTiles + 2,
|
||||||
|
this->city_map_selector_item->pixelHeight * scaleCityMapTiles + 2);
|
||||||
|
this->ui->graphicsView_City_Map_Tiles->scale(0.5,0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegionMapEditor::on_pushButton_Zoom_In_City_Map_clicked() {
|
||||||
|
//
|
||||||
|
scaleCityMapImage *= 2.0;
|
||||||
|
this->ui->graphicsView_City_Map->setFixedSize(QSize(8 * city_map_item->width * scaleCityMapImage + 2, 8 * city_map_item->height * scaleCityMapImage + 2));
|
||||||
|
this->ui->graphicsView_City_Map->scale(2.0,2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegionMapEditor::on_pushButton_Zoom_Out_City_Map_clicked() {
|
||||||
|
//
|
||||||
|
scaleCityMapImage /= 2.0;
|
||||||
|
this->ui->graphicsView_City_Map->setFixedSize(QSize(8 * city_map_item->width * scaleCityMapImage + 2, 8 * city_map_item->height * scaleCityMapImage + 2));
|
||||||
|
this->ui->graphicsView_City_Map->scale(0.5,0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegionMapEditor::on_pushButton_Zoom_In_Map_Image_clicked() {
|
||||||
|
//
|
||||||
|
//qDebug() << "scale:" << scaleRegionMapImage;
|
||||||
|
scaleRegionMapImage *= 2.0;
|
||||||
|
this->ui->graphicsView_Region_Map_BkgImg->setFixedSize(this->region_map->imgSize() * scaleRegionMapImage);
|
||||||
|
this->ui->graphicsView_Region_Map_Layout->setFixedSize(this->region_map->imgSize() * scaleRegionMapImage);
|
||||||
|
this->ui->graphicsView_Region_Map_BkgImg->scale(2.0,2.0);
|
||||||
|
this->ui->graphicsView_Region_Map_Layout->scale(2.0,2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegionMapEditor::on_pushButton_Zoom_Out_Map_Image_clicked() {
|
||||||
|
//
|
||||||
|
if (scaleRegionMapImage <= 1.0) return;
|
||||||
|
scaleRegionMapImage /= 2.0;
|
||||||
|
this->ui->graphicsView_Region_Map_BkgImg->setFixedSize(this->region_map->imgSize() * scaleRegionMapImage);
|
||||||
|
this->ui->graphicsView_Region_Map_Layout->setFixedSize(this->region_map->imgSize() * scaleRegionMapImage);
|
||||||
|
this->ui->graphicsView_Region_Map_BkgImg->scale(0.5,0.5);
|
||||||
|
this->ui->graphicsView_Region_Map_Layout->scale(0.5,0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -331,16 +524,6 @@ void RegionMapEditor::on_comboBox_CityMap_picker_currentTextChanged(const QStrin
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
// the function that draws the map on the scene
|
// the function that draws the map on the scene
|
||||||
// (qnqlogous to Map::render)
|
// (qnqlogous to Map::render)
|
||||||
// TODO: figure out why this is being called twice!!
|
// TODO: figure out why this is being called twice!!
|
||||||
|
// (this also affects the history)
|
||||||
void RegionMapPixmapItem::draw() {
|
void RegionMapPixmapItem::draw() {
|
||||||
if (!region_map) return;
|
if (!region_map) return;
|
||||||
|
|
||||||
|
@ -31,7 +32,8 @@ void RegionMapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
||||||
QPointF pos = event->pos();
|
QPointF pos = event->pos();
|
||||||
int x = static_cast<int>(pos.x()) / 8;
|
int x = static_cast<int>(pos.x()) / 8;
|
||||||
int y = static_cast<int>(pos.y()) / 8;
|
int y = static_cast<int>(pos.y()) / 8;
|
||||||
this->region_map->map_squares[x + y * region_map->width()].tile_img_id = this->tile_selector->selectedTile;
|
int index = x + y * region_map->width();
|
||||||
|
this->region_map->map_squares[index].tile_img_id = this->tile_selector->selectedTile;
|
||||||
}
|
}
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue