commit
43119f2b43
18 changed files with 1114 additions and 363 deletions
184
editor.cpp
184
editor.cpp
|
@ -1,4 +1,5 @@
|
||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
|
#include "event.h"
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
@ -301,8 +302,12 @@ void Editor::onConnectionDirectionChanged(QString newDirection) {
|
||||||
ui->comboBox_ConnectionDirection->blockSignals(false);
|
ui->comboBox_ConnectionDirection->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Editor::onBorderMetatilesChanged() {
|
||||||
|
displayMapBorder();
|
||||||
|
}
|
||||||
|
|
||||||
void Editor::setConnectionsVisibility(bool visible) {
|
void Editor::setConnectionsVisibility(bool visible) {
|
||||||
for (QGraphicsPixmapItem* item : map->connection_items) {
|
for (QGraphicsPixmapItem* item : connection_items) {
|
||||||
item->setVisible(visible);
|
item->setVisible(visible);
|
||||||
item->setActive(visible);
|
item->setActive(visible);
|
||||||
}
|
}
|
||||||
|
@ -344,8 +349,13 @@ void Editor::mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixm
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::displayMap() {
|
void Editor::displayMap() {
|
||||||
scene = new QGraphicsScene;
|
if (!scene)
|
||||||
|
scene = new QGraphicsScene;
|
||||||
|
|
||||||
|
if (map_item && scene) {
|
||||||
|
scene->removeItem(map_item);
|
||||||
|
delete map_item;
|
||||||
|
}
|
||||||
map_item = new MapPixmapItem(map);
|
map_item = new MapPixmapItem(map);
|
||||||
connect(map_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*,MapPixmapItem*)),
|
connect(map_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*,MapPixmapItem*)),
|
||||||
this, SLOT(mouseEvent_map(QGraphicsSceneMouseEvent*,MapPixmapItem*)));
|
this, SLOT(mouseEvent_map(QGraphicsSceneMouseEvent*,MapPixmapItem*)));
|
||||||
|
@ -353,6 +363,10 @@ void Editor::displayMap() {
|
||||||
map_item->draw(true);
|
map_item->draw(true);
|
||||||
scene->addItem(map_item);
|
scene->addItem(map_item);
|
||||||
|
|
||||||
|
if (collision_item && scene) {
|
||||||
|
scene->removeItem(collision_item);
|
||||||
|
delete collision_item;
|
||||||
|
}
|
||||||
collision_item = new CollisionPixmapItem(map);
|
collision_item = new CollisionPixmapItem(map);
|
||||||
connect(collision_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*,CollisionPixmapItem*)),
|
connect(collision_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*,CollisionPixmapItem*)),
|
||||||
this, SLOT(mouseEvent_collision(QGraphicsSceneMouseEvent*,CollisionPixmapItem*)));
|
this, SLOT(mouseEvent_collision(QGraphicsSceneMouseEvent*,CollisionPixmapItem*)));
|
||||||
|
@ -360,19 +374,6 @@ void Editor::displayMap() {
|
||||||
collision_item->draw(true);
|
collision_item->draw(true);
|
||||||
scene->addItem(collision_item);
|
scene->addItem(collision_item);
|
||||||
|
|
||||||
events_group = new EventGroup;
|
|
||||||
scene->addItem(events_group);
|
|
||||||
|
|
||||||
if (map_item) {
|
|
||||||
map_item->setVisible(false);
|
|
||||||
}
|
|
||||||
if (collision_item) {
|
|
||||||
collision_item->setVisible(false);
|
|
||||||
}
|
|
||||||
if (events_group) {
|
|
||||||
events_group->setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
int tw = 16;
|
int tw = 16;
|
||||||
int th = 16;
|
int th = 16;
|
||||||
scene->setSceneRect(
|
scene->setSceneRect(
|
||||||
|
@ -383,22 +384,57 @@ void Editor::displayMap() {
|
||||||
);
|
);
|
||||||
|
|
||||||
displayMetatiles();
|
displayMetatiles();
|
||||||
|
displayBorderMetatiles();
|
||||||
displayCollisionMetatiles();
|
displayCollisionMetatiles();
|
||||||
displayElevationMetatiles();
|
displayElevationMetatiles();
|
||||||
displayMapEvents();
|
displayMapEvents();
|
||||||
displayMapConnections();
|
displayMapConnections();
|
||||||
displayMapBorder();
|
displayMapBorder();
|
||||||
displayMapGrid();
|
displayMapGrid();
|
||||||
|
|
||||||
|
if (map_item) {
|
||||||
|
map_item->setVisible(false);
|
||||||
|
}
|
||||||
|
if (collision_item) {
|
||||||
|
collision_item->setVisible(false);
|
||||||
|
}
|
||||||
|
if (events_group) {
|
||||||
|
events_group->setVisible(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::displayMetatiles() {
|
void Editor::displayMetatiles() {
|
||||||
|
if (metatiles_item && metatiles_item->scene()) {
|
||||||
|
metatiles_item->scene()->removeItem(metatiles_item);
|
||||||
|
delete metatiles_item;
|
||||||
|
}
|
||||||
|
|
||||||
scene_metatiles = new QGraphicsScene;
|
scene_metatiles = new QGraphicsScene;
|
||||||
metatiles_item = new MetatilesPixmapItem(map);
|
metatiles_item = new MetatilesPixmapItem(map);
|
||||||
metatiles_item->draw();
|
metatiles_item->draw();
|
||||||
scene_metatiles->addItem(metatiles_item);
|
scene_metatiles->addItem(metatiles_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Editor::displayBorderMetatiles() {
|
||||||
|
if (selected_border_metatiles_item && selected_border_metatiles_item->scene()) {
|
||||||
|
selected_border_metatiles_item->scene()->removeItem(selected_border_metatiles_item);
|
||||||
|
delete selected_border_metatiles_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
scene_selected_border_metatiles = new QGraphicsScene;
|
||||||
|
selected_border_metatiles_item = new BorderMetatilesPixmapItem(map);
|
||||||
|
selected_border_metatiles_item->draw();
|
||||||
|
scene_selected_border_metatiles->addItem(selected_border_metatiles_item);
|
||||||
|
|
||||||
|
connect(selected_border_metatiles_item, SIGNAL(borderMetatilesChanged()), this, SLOT(onBorderMetatilesChanged()));
|
||||||
|
}
|
||||||
|
|
||||||
void Editor::displayCollisionMetatiles() {
|
void Editor::displayCollisionMetatiles() {
|
||||||
|
if (collision_metatiles_item && collision_metatiles_item->scene()) {
|
||||||
|
collision_metatiles_item->scene()->removeItem(collision_metatiles_item);
|
||||||
|
delete collision_metatiles_item;
|
||||||
|
}
|
||||||
|
|
||||||
scene_collision_metatiles = new QGraphicsScene;
|
scene_collision_metatiles = new QGraphicsScene;
|
||||||
collision_metatiles_item = new CollisionMetatilesPixmapItem(map);
|
collision_metatiles_item = new CollisionMetatilesPixmapItem(map);
|
||||||
collision_metatiles_item->draw();
|
collision_metatiles_item->draw();
|
||||||
|
@ -406,6 +442,11 @@ void Editor::displayCollisionMetatiles() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::displayElevationMetatiles() {
|
void Editor::displayElevationMetatiles() {
|
||||||
|
if (elevation_metatiles_item && elevation_metatiles_item->scene()) {
|
||||||
|
elevation_metatiles_item->scene()->removeItem(elevation_metatiles_item);
|
||||||
|
delete elevation_metatiles_item;
|
||||||
|
}
|
||||||
|
|
||||||
scene_elevation_metatiles = new QGraphicsScene;
|
scene_elevation_metatiles = new QGraphicsScene;
|
||||||
elevation_metatiles_item = new ElevationMetatilesPixmapItem(map);
|
elevation_metatiles_item = new ElevationMetatilesPixmapItem(map);
|
||||||
elevation_metatiles_item->draw();
|
elevation_metatiles_item->draw();
|
||||||
|
@ -413,10 +454,22 @@ void Editor::displayElevationMetatiles() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::displayMapEvents() {
|
void Editor::displayMapEvents() {
|
||||||
for (QGraphicsItem *child : events_group->childItems()) {
|
if (events_group) {
|
||||||
events_group->removeFromGroup(child);
|
for (QGraphicsItem *child : events_group->childItems()) {
|
||||||
|
events_group->removeFromGroup(child);
|
||||||
|
delete child;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (events_group->scene()) {
|
||||||
|
events_group->scene()->removeItem(events_group);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete events_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
events_group = new EventGroup;
|
||||||
|
scene->addItem(events_group);
|
||||||
|
|
||||||
QList<Event *> events = map->getAllEvents();
|
QList<Event *> events = map->getAllEvents();
|
||||||
project->loadEventPixmaps(events);
|
project->loadEventPixmaps(events);
|
||||||
for (Event *event : events) {
|
for (Event *event : events) {
|
||||||
|
@ -436,12 +489,18 @@ DraggablePixmapItem *Editor::addMapEvent(Event *event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::displayMapConnections() {
|
void Editor::displayMapConnections() {
|
||||||
for (QGraphicsPixmapItem* item : map->connection_items) {
|
for (QGraphicsPixmapItem* item : connection_items) {
|
||||||
|
if (item->scene()) {
|
||||||
|
item->scene()->removeItem(item);
|
||||||
|
}
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
map->connection_items.clear();
|
connection_items.clear();
|
||||||
|
|
||||||
for (ConnectionPixmapItem* item : connection_edit_items) {
|
for (ConnectionPixmapItem* item : connection_edit_items) {
|
||||||
|
if (item->scene()) {
|
||||||
|
item->scene()->removeItem(item);
|
||||||
|
}
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
selected_connection_item = NULL;
|
selected_connection_item = NULL;
|
||||||
|
@ -483,7 +542,7 @@ void Editor::createConnectionItem(Connection* connection, bool hide) {
|
||||||
item->setX(x);
|
item->setX(x);
|
||||||
item->setY(y);
|
item->setY(y);
|
||||||
scene->addItem(item);
|
scene->addItem(item);
|
||||||
map->connection_items.append(item);
|
connection_items.append(item);
|
||||||
item->setVisible(!hide);
|
item->setVisible(!hide);
|
||||||
|
|
||||||
ConnectionPixmapItem *connection_edit_item = new ConnectionPixmapItem(pixmap, connection, x, y, map->getWidth(), map->getHeight());
|
ConnectionPixmapItem *connection_edit_item = new ConnectionPixmapItem(pixmap, connection, x, y, map->getWidth(), map->getHeight());
|
||||||
|
@ -498,6 +557,14 @@ void Editor::createConnectionItem(Connection* connection, bool hide) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::displayMapBorder() {
|
void Editor::displayMapBorder() {
|
||||||
|
for (QGraphicsPixmapItem* item : borderItems) {
|
||||||
|
if (item->scene()) {
|
||||||
|
item->scene()->removeItem(item);
|
||||||
|
}
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
borderItems.clear();
|
||||||
|
|
||||||
QPixmap pixmap = map->renderBorder();
|
QPixmap pixmap = map->renderBorder();
|
||||||
for (int y = -6; y < map->getHeight() + 6; y += 2)
|
for (int y = -6; y < map->getHeight() + 6; y += 2)
|
||||||
for (int x = -6; x < map->getWidth() + 6; x += 2) {
|
for (int x = -6; x < map->getWidth() + 6; x += 2) {
|
||||||
|
@ -511,18 +578,29 @@ void Editor::displayMapBorder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::displayMapGrid() {
|
void Editor::displayMapGrid() {
|
||||||
|
for (QGraphicsLineItem* item : gridLines) {
|
||||||
|
if (item && item->scene()) {
|
||||||
|
item->scene()->removeItem(item);
|
||||||
|
}
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
gridLines.clear();
|
||||||
|
ui->checkBox_ToggleGrid->disconnect();
|
||||||
|
|
||||||
int pixelWidth = map->getWidth() * 16;
|
int pixelWidth = map->getWidth() * 16;
|
||||||
int pixelHeight = map->getHeight() * 16;
|
int pixelHeight = map->getHeight() * 16;
|
||||||
for (int i = 0; i <= map->getWidth(); i++) {
|
for (int i = 0; i <= map->getWidth(); i++) {
|
||||||
int x = i * 16;
|
int x = i * 16;
|
||||||
QGraphicsLineItem *line = scene->addLine(x, 0, x, pixelHeight);
|
QGraphicsLineItem *line = scene->addLine(x, 0, x, pixelHeight);
|
||||||
line->setVisible(ui->checkBox_ToggleGrid->isChecked());
|
line->setVisible(ui->checkBox_ToggleGrid->isChecked());
|
||||||
|
gridLines.append(line);
|
||||||
connect(ui->checkBox_ToggleGrid, &QCheckBox::toggled, [=](bool checked){line->setVisible(checked);});
|
connect(ui->checkBox_ToggleGrid, &QCheckBox::toggled, [=](bool checked){line->setVisible(checked);});
|
||||||
}
|
}
|
||||||
for (int j = 0; j <= map->getHeight(); j++) {
|
for (int j = 0; j <= map->getHeight(); j++) {
|
||||||
int y = j * 16;
|
int y = j * 16;
|
||||||
QGraphicsLineItem *line = scene->addLine(0, y, pixelWidth, y);
|
QGraphicsLineItem *line = scene->addLine(0, y, pixelWidth, y);
|
||||||
line->setVisible(ui->checkBox_ToggleGrid->isChecked());
|
line->setVisible(ui->checkBox_ToggleGrid->isChecked());
|
||||||
|
gridLines.append(line);
|
||||||
connect(ui->checkBox_ToggleGrid, &QCheckBox::toggled, [=](bool checked){line->setVisible(checked);});
|
connect(ui->checkBox_ToggleGrid, &QCheckBox::toggled, [=](bool checked){line->setVisible(checked);});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -665,8 +743,11 @@ void Editor::removeCurrentConnection() {
|
||||||
connection_edit_items.removeOne(selected_connection_item);
|
connection_edit_items.removeOne(selected_connection_item);
|
||||||
removeMirroredConnection(selected_connection_item->connection);
|
removeMirroredConnection(selected_connection_item->connection);
|
||||||
|
|
||||||
scene->removeItem(selected_connection_item);
|
if (selected_connection_item && selected_connection_item->scene()) {
|
||||||
delete selected_connection_item;
|
selected_connection_item->scene()->removeItem(selected_connection_item);
|
||||||
|
delete selected_connection_item;
|
||||||
|
}
|
||||||
|
|
||||||
selected_connection_item = NULL;
|
selected_connection_item = NULL;
|
||||||
setConnectionEditControlsEnabled(false);
|
setConnectionEditControlsEnabled(false);
|
||||||
ui->spinBox_ConnectionOffset->setValue(0);
|
ui->spinBox_ConnectionOffset->setValue(0);
|
||||||
|
@ -723,6 +804,20 @@ void Editor::updateDiveEmergeMap(QString mapName, QString direction) {
|
||||||
ui->label_NumConnections->setText(QString::number(map->connections.length()));
|
ui->label_NumConnections->setText(QString::number(map->connections.length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Editor::updatePrimaryTileset(QString tilesetLabel)
|
||||||
|
{
|
||||||
|
map->layout->tileset_primary_label = tilesetLabel;
|
||||||
|
map->layout->tileset_primary = project->getTileset(tilesetLabel);
|
||||||
|
emit tilesetChanged(map->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Editor::updateSecondaryTileset(QString tilesetLabel)
|
||||||
|
{
|
||||||
|
map->layout->tileset_secondary_label = tilesetLabel;
|
||||||
|
map->layout->tileset_secondary = project->getTileset(tilesetLabel);
|
||||||
|
emit tilesetChanged(map->name);
|
||||||
|
}
|
||||||
|
|
||||||
void MetatilesPixmapItem::paintTileChanged(Map *map) {
|
void MetatilesPixmapItem::paintTileChanged(Map *map) {
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
@ -792,6 +887,43 @@ void MetatilesPixmapItem::updateSelection(QPointF pos, Qt::MouseButton button) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BorderMetatilesPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
|
QPointF pos = event->pos();
|
||||||
|
int x = ((int)pos.x()) / 16;
|
||||||
|
int y = ((int)pos.y()) / 16;
|
||||||
|
|
||||||
|
for (int i = 0; i < map->paint_tile_width && (i + x) < 2; i++) {
|
||||||
|
for (int j = 0; j < map->paint_tile_height && (j + y) < 2; j++) {
|
||||||
|
int blockIndex = (j + y) * 2 + (i + x);
|
||||||
|
int tile = map->getSelectedBlockIndex(map->paint_tile_index + i + (j * 8));
|
||||||
|
(*map->layout->border->blocks)[blockIndex].tile = tile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
draw();
|
||||||
|
emit borderMetatilesChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BorderMetatilesPixmapItem::draw() {
|
||||||
|
QImage image(32, 32, QImage::Format_RGBA8888);
|
||||||
|
QPainter painter(&image);
|
||||||
|
QList<Block> *blocks = map->layout->border->blocks;
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
for (int j = 0; j < 2; j++)
|
||||||
|
{
|
||||||
|
int x = i * 16;
|
||||||
|
int y = j * 16;
|
||||||
|
int index = j * 2 + i;
|
||||||
|
QImage metatile_image = Metatile::getMetatileImage(blocks->value(index).tile, map->layout->tileset_primary, map->layout->tileset_secondary);
|
||||||
|
QPoint metatile_origin = QPoint(x, y);
|
||||||
|
painter.drawImage(metatile_origin, metatile_image);
|
||||||
|
}
|
||||||
|
|
||||||
|
painter.end();
|
||||||
|
setPixmap(QPixmap::fromImage(image));
|
||||||
|
}
|
||||||
|
|
||||||
void MovementPermissionsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent* event) {
|
void MovementPermissionsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent* event) {
|
||||||
QPointF pos = event->pos();
|
QPointF pos = event->pos();
|
||||||
int x = ((int)pos.x()) / 16;
|
int x = ((int)pos.x()) / 16;
|
||||||
|
@ -1298,15 +1430,10 @@ void Editor::selectMapEvent(DraggablePixmapItem *object, bool toggle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DraggablePixmapItem* Editor::addNewEvent() {
|
|
||||||
return addNewEvent("object");
|
|
||||||
}
|
|
||||||
|
|
||||||
DraggablePixmapItem* Editor::addNewEvent(QString event_type) {
|
DraggablePixmapItem* Editor::addNewEvent(QString event_type) {
|
||||||
if (project && map) {
|
if (project && map) {
|
||||||
Event *event = new Event;
|
Event *event = Event::createNewEvent(event_type, map->name);
|
||||||
event->put("map_name", map->name);
|
event->put("map_name", map->name);
|
||||||
event->put("event_type", event_type);
|
|
||||||
map->addEvent(event);
|
map->addEvent(event);
|
||||||
project->loadEventPixmaps(map->getAllEvents());
|
project->loadEventPixmaps(map->getAllEvents());
|
||||||
DraggablePixmapItem *object = addMapEvent(event);
|
DraggablePixmapItem *object = addMapEvent(event);
|
||||||
|
@ -1325,7 +1452,6 @@ void Editor::deleteEvent(Event *event) {
|
||||||
//updateSelectedObjects();
|
//updateSelectedObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// dunno how to detect bubbling. QMouseEvent::isAccepted seems to always be true
|
// dunno how to detect bubbling. QMouseEvent::isAccepted seems to always be true
|
||||||
// check if selected_events changed instead. this has the side effect of deselecting
|
// check if selected_events changed instead. this has the side effect of deselecting
|
||||||
// when you click on a selected event, since selected_events doesn't change.
|
// when you click on a selected event, since selected_events doesn't change.
|
||||||
|
|
36
editor.h
36
editor.h
|
@ -16,6 +16,7 @@ class MapPixmapItem;
|
||||||
class CollisionPixmapItem;
|
class CollisionPixmapItem;
|
||||||
class ConnectionPixmapItem;
|
class ConnectionPixmapItem;
|
||||||
class MetatilesPixmapItem;
|
class MetatilesPixmapItem;
|
||||||
|
class BorderMetatilesPixmapItem;
|
||||||
class CollisionMetatilesPixmapItem;
|
class CollisionMetatilesPixmapItem;
|
||||||
class ElevationMetatilesPixmapItem;
|
class ElevationMetatilesPixmapItem;
|
||||||
|
|
||||||
|
@ -36,6 +37,7 @@ public:
|
||||||
void setMap(QString map_name);
|
void setMap(QString map_name);
|
||||||
void displayMap();
|
void displayMap();
|
||||||
void displayMetatiles();
|
void displayMetatiles();
|
||||||
|
void displayBorderMetatiles();
|
||||||
void displayCollisionMetatiles();
|
void displayCollisionMetatiles();
|
||||||
void displayElevationMetatiles();
|
void displayElevationMetatiles();
|
||||||
void displayMapEvents();
|
void displayMapEvents();
|
||||||
|
@ -57,12 +59,14 @@ public:
|
||||||
void updateDiveMap(QString mapName);
|
void updateDiveMap(QString mapName);
|
||||||
void updateEmergeMap(QString mapName);
|
void updateEmergeMap(QString mapName);
|
||||||
void setSelectedConnectionFromMap(QString mapName);
|
void setSelectedConnectionFromMap(QString mapName);
|
||||||
|
void updatePrimaryTileset(QString tilesetLabel);
|
||||||
|
void updateSecondaryTileset(QString tilesetLabel);
|
||||||
|
|
||||||
DraggablePixmapItem *addMapEvent(Event *event);
|
DraggablePixmapItem *addMapEvent(Event *event);
|
||||||
void selectMapEvent(DraggablePixmapItem *object);
|
void selectMapEvent(DraggablePixmapItem *object);
|
||||||
void selectMapEvent(DraggablePixmapItem *object, bool toggle);
|
void selectMapEvent(DraggablePixmapItem *object, bool toggle);
|
||||||
DraggablePixmapItem *addNewEvent();
|
|
||||||
DraggablePixmapItem *addNewEvent(QString event_type);
|
DraggablePixmapItem *addNewEvent(QString event_type);
|
||||||
|
Event* createNewEvent(QString event_type);
|
||||||
void deleteEvent(Event *);
|
void deleteEvent(Event *);
|
||||||
void updateSelectedEvents();
|
void updateSelectedEvents();
|
||||||
void redrawObject(DraggablePixmapItem *item);
|
void redrawObject(DraggablePixmapItem *item);
|
||||||
|
@ -72,15 +76,19 @@ public:
|
||||||
QGraphicsPixmapItem *current_view = NULL;
|
QGraphicsPixmapItem *current_view = NULL;
|
||||||
MapPixmapItem *map_item = NULL;
|
MapPixmapItem *map_item = NULL;
|
||||||
ConnectionPixmapItem* selected_connection_item = NULL;
|
ConnectionPixmapItem* selected_connection_item = NULL;
|
||||||
|
QList<QGraphicsPixmapItem*> connection_items;
|
||||||
QList<ConnectionPixmapItem*> connection_edit_items;
|
QList<ConnectionPixmapItem*> connection_edit_items;
|
||||||
CollisionPixmapItem *collision_item = NULL;
|
CollisionPixmapItem *collision_item = NULL;
|
||||||
QGraphicsItemGroup *events_group = NULL;
|
QGraphicsItemGroup *events_group = NULL;
|
||||||
QList<QGraphicsPixmapItem*> borderItems;
|
QList<QGraphicsPixmapItem*> borderItems;
|
||||||
|
QList<QGraphicsLineItem*> gridLines;
|
||||||
|
|
||||||
QGraphicsScene *scene_metatiles = NULL;
|
QGraphicsScene *scene_metatiles = NULL;
|
||||||
|
QGraphicsScene *scene_selected_border_metatiles = NULL;
|
||||||
QGraphicsScene *scene_collision_metatiles = NULL;
|
QGraphicsScene *scene_collision_metatiles = NULL;
|
||||||
QGraphicsScene *scene_elevation_metatiles = NULL;
|
QGraphicsScene *scene_elevation_metatiles = NULL;
|
||||||
MetatilesPixmapItem *metatiles_item = NULL;
|
MetatilesPixmapItem *metatiles_item = NULL;
|
||||||
|
BorderMetatilesPixmapItem *selected_border_metatiles_item = NULL;
|
||||||
CollisionMetatilesPixmapItem *collision_metatiles_item = NULL;
|
CollisionMetatilesPixmapItem *collision_metatiles_item = NULL;
|
||||||
ElevationMetatilesPixmapItem *elevation_metatiles_item = NULL;
|
ElevationMetatilesPixmapItem *elevation_metatiles_item = NULL;
|
||||||
|
|
||||||
|
@ -108,6 +116,13 @@ private:
|
||||||
void updateMirroredConnectionDirection(Connection*, QString);
|
void updateMirroredConnectionDirection(Connection*, QString);
|
||||||
void updateMirroredConnectionMap(Connection*, QString);
|
void updateMirroredConnectionMap(Connection*, QString);
|
||||||
void updateMirroredConnection(Connection*, QString, QString, bool isDelete = false);
|
void updateMirroredConnection(Connection*, QString, QString, bool isDelete = false);
|
||||||
|
Event* createNewObjectEvent();
|
||||||
|
Event* createNewWarpEvent();
|
||||||
|
Event* createNewCoordScriptEvent();
|
||||||
|
Event* createNewCoordWeatherEvent();
|
||||||
|
Event* createNewSignEvent();
|
||||||
|
Event* createNewHiddenItemEvent();
|
||||||
|
Event* createNewSecretBaseEvent();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item);
|
void mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item);
|
||||||
|
@ -116,11 +131,13 @@ private slots:
|
||||||
void onConnectionItemSelected(ConnectionPixmapItem* connectionItem);
|
void onConnectionItemSelected(ConnectionPixmapItem* connectionItem);
|
||||||
void onConnectionItemDoubleClicked(ConnectionPixmapItem* connectionItem);
|
void onConnectionItemDoubleClicked(ConnectionPixmapItem* connectionItem);
|
||||||
void onConnectionDirectionChanged(QString newDirection);
|
void onConnectionDirectionChanged(QString newDirection);
|
||||||
|
void onBorderMetatilesChanged();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void objectsChanged();
|
void objectsChanged();
|
||||||
void selectedObjectsChanged();
|
void selectedObjectsChanged();
|
||||||
void loadMapRequested(QString, QString);
|
void loadMapRequested(QString, QString);
|
||||||
|
void tilesetChanged(QString);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,7 +183,7 @@ public:
|
||||||
emit spriteChanged(event->pixmap);
|
emit spriteChanged(event->pixmap);
|
||||||
}
|
}
|
||||||
void bind(QComboBox *combo, QString key) {
|
void bind(QComboBox *combo, QString key) {
|
||||||
connect(combo, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::activated),
|
connect(combo, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
||||||
this, [this, key](QString value){
|
this, [this, key](QString value){
|
||||||
this->event->put(key, value);
|
this->event->put(key, value);
|
||||||
});
|
});
|
||||||
|
@ -344,6 +361,21 @@ protected:
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class BorderMetatilesPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
BorderMetatilesPixmapItem(Map *map_) {
|
||||||
|
map = map_;
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
|
}
|
||||||
|
Map* map = NULL;
|
||||||
|
virtual void draw();
|
||||||
|
signals:
|
||||||
|
void borderMetatilesChanged();
|
||||||
|
protected:
|
||||||
|
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||||
|
};
|
||||||
|
|
||||||
class MovementPermissionsPixmapItem : public MetatilesPixmapItem {
|
class MovementPermissionsPixmapItem : public MetatilesPixmapItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
208
event.cpp
208
event.cpp
|
@ -1,5 +1,213 @@
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
|
|
||||||
|
QString EventType::Object = "event_object";
|
||||||
|
QString EventType::Warp = "event_warp";
|
||||||
|
QString EventType::CoordScript = "event_trap";
|
||||||
|
QString EventType::CoordWeather = "event_trap_weather";
|
||||||
|
QString EventType::Sign = "event_sign";
|
||||||
|
QString EventType::HiddenItem = "event_hidden_item";
|
||||||
|
QString EventType::SecretBase = "event_secret_base";
|
||||||
|
|
||||||
Event::Event()
|
Event::Event()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Event* Event::createNewEvent(QString event_type, QString map_name)
|
||||||
|
{
|
||||||
|
Event *event;
|
||||||
|
if (event_type == EventType::Object) {
|
||||||
|
event = createNewObjectEvent();
|
||||||
|
} else if (event_type == EventType::Warp) {
|
||||||
|
event = createNewWarpEvent(map_name);
|
||||||
|
} else if (event_type == EventType::CoordScript) {
|
||||||
|
event = createNewCoordScriptEvent();
|
||||||
|
} else if (event_type == EventType::CoordWeather) {
|
||||||
|
event = createNewCoordWeatherEvent();
|
||||||
|
} else if (event_type == EventType::Sign) {
|
||||||
|
event = createNewSignEvent();
|
||||||
|
} else if (event_type == EventType::HiddenItem) {
|
||||||
|
event = createNewHiddenItemEvent();
|
||||||
|
} else if (event_type == EventType::SecretBase) {
|
||||||
|
event = createNewSecretBaseEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
event->setX(0);
|
||||||
|
event->setY(0);
|
||||||
|
event->put("elevation", 3);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
Event* Event::createNewObjectEvent()
|
||||||
|
{
|
||||||
|
Event *event = new Event;
|
||||||
|
event->put("event_group_type", "object_event_group");
|
||||||
|
event->put("event_type", EventType::Object);
|
||||||
|
event->put("sprite", "EVENT_OBJ_GFX_BOY_1");
|
||||||
|
event->put("behavior", "1");
|
||||||
|
event->put("radius_x", 0);
|
||||||
|
event->put("radius_y", 0);
|
||||||
|
event->put("script_label", "NULL");
|
||||||
|
event->put("event_flag", "0");
|
||||||
|
event->put("replacement", "0");
|
||||||
|
event->put("trainer_see_type", "0");
|
||||||
|
event->put("sight_radius_tree_id", 0);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
Event* Event::createNewWarpEvent(QString map_name)
|
||||||
|
{
|
||||||
|
Event *event = new Event;
|
||||||
|
event->put("event_group_type", "warp_event_group");
|
||||||
|
event->put("event_type", EventType::Warp);
|
||||||
|
event->put("destination_warp", 0);
|
||||||
|
event->put("destination_map_name", map_name);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
Event* Event::createNewCoordScriptEvent()
|
||||||
|
{
|
||||||
|
Event *event = new Event;
|
||||||
|
event->put("event_group_type", "coord_event_group");
|
||||||
|
event->put("event_type", EventType::CoordScript);
|
||||||
|
event->put("script_label", "NULL");
|
||||||
|
event->put("script_var", "VAR_TEMP_0");
|
||||||
|
event->put("script_var_value", "0");
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
Event* Event::createNewCoordWeatherEvent()
|
||||||
|
{
|
||||||
|
Event *event = new Event;
|
||||||
|
event->put("event_group_type", "coord_event_group");
|
||||||
|
event->put("event_type", EventType::CoordWeather);
|
||||||
|
event->put("weather", "COORD_EVENT_WEATHER_SUNNY");
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
Event* Event::createNewSignEvent()
|
||||||
|
{
|
||||||
|
Event *event = new Event;
|
||||||
|
event->put("event_group_type", "bg_event_group");
|
||||||
|
event->put("event_type", EventType::Sign);
|
||||||
|
event->put("player_facing_direction", "0");
|
||||||
|
event->put("script_label", "NULL");
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
Event* Event::createNewHiddenItemEvent()
|
||||||
|
{
|
||||||
|
Event *event = new Event;
|
||||||
|
event->put("event_group_type", "bg_event_group");
|
||||||
|
event->put("event_type", EventType::HiddenItem);
|
||||||
|
event->put("item", "ITEM_POTION");
|
||||||
|
event->put("flag", "FLAG_HIDDEN_ITEM_0");
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
Event* Event::createNewSecretBaseEvent()
|
||||||
|
{
|
||||||
|
Event *event = new Event;
|
||||||
|
event->put("event_group_type", "bg_event_group");
|
||||||
|
event->put("event_type", EventType::SecretBase);
|
||||||
|
event->put("secret_base_map", "SECRET_BASE_RED_CAVE2_1");
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Event::buildObjectEventMacro(int item_index)
|
||||||
|
{
|
||||||
|
int radius_x = this->getInt("radius_x");
|
||||||
|
int radius_y = this->getInt("radius_y");
|
||||||
|
uint16_t x = this->getInt("x");
|
||||||
|
uint16_t y = this->getInt("y");
|
||||||
|
|
||||||
|
QString text = "";
|
||||||
|
text += QString("\tobject_event %1").arg(item_index + 1);
|
||||||
|
text += QString(", %1").arg(this->get("sprite"));
|
||||||
|
text += QString(", %1").arg(this->get("replacement"));
|
||||||
|
text += QString(", %1").arg(x);
|
||||||
|
text += QString(", %1").arg(y);
|
||||||
|
text += QString(", %1").arg(this->get("elevation"));
|
||||||
|
text += QString(", %1").arg(this->get("behavior"));
|
||||||
|
text += QString(", %1").arg(radius_x);
|
||||||
|
text += QString(", %1").arg(radius_y);
|
||||||
|
text += QString(", %1").arg(this->get("trainer_see_type"));
|
||||||
|
text += QString(", %1").arg(this->get("sight_radius_tree_id"));
|
||||||
|
text += QString(", %1").arg(this->get("script_label"));
|
||||||
|
text += QString(", %1").arg(this->get("event_flag"));
|
||||||
|
text += "\n";
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Event::buildWarpEventMacro(QMap<QString, QString> *mapNamesToMapConstants)
|
||||||
|
{
|
||||||
|
QString text = "";
|
||||||
|
text += QString("\twarp_def %1").arg(this->get("x"));
|
||||||
|
text += QString(", %1").arg(this->get("y"));
|
||||||
|
text += QString(", %1").arg(this->get("elevation"));
|
||||||
|
text += QString(", %1").arg(this->get("destination_warp"));
|
||||||
|
text += QString(", %1").arg(mapNamesToMapConstants->value(this->get("destination_map_name")));
|
||||||
|
text += "\n";
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Event::buildCoordScriptEventMacro()
|
||||||
|
{
|
||||||
|
QString text = "";
|
||||||
|
text += QString("\tcoord_event %1").arg(this->get("x"));
|
||||||
|
text += QString(", %1").arg(this->get("y"));
|
||||||
|
text += QString(", %1").arg(this->get("elevation"));
|
||||||
|
text += QString(", 0");
|
||||||
|
text += QString(", %1").arg(this->get("script_var"));
|
||||||
|
text += QString(", %1").arg(this->get("script_var_value"));
|
||||||
|
text += QString(", 0");
|
||||||
|
text += QString(", %1").arg(this->get("script_label"));
|
||||||
|
text += "\n";
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Event::buildCoordWeatherEventMacro()
|
||||||
|
{
|
||||||
|
QString text = "";
|
||||||
|
text += QString("\tcoord_weather_event %1").arg(this->get("x"));
|
||||||
|
text += QString(", %1").arg(this->get("y"));
|
||||||
|
text += QString(", %1").arg(this->get("elevation"));
|
||||||
|
text += QString(", %1").arg(this->get("weather"));
|
||||||
|
text += "\n";
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Event::buildSignEventMacro()
|
||||||
|
{
|
||||||
|
QString text = "";
|
||||||
|
text += QString("\tbg_event %1").arg(this->get("x"));
|
||||||
|
text += QString(", %1").arg(this->get("y"));
|
||||||
|
text += QString(", %1").arg(this->get("elevation"));
|
||||||
|
text += QString(", %1").arg(this->get("player_facing_direction"));
|
||||||
|
text += QString(", 0");
|
||||||
|
text += QString(", %1").arg(this->get("script_label"));
|
||||||
|
text += "\n";
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Event::buildHiddenItemEventMacro()
|
||||||
|
{
|
||||||
|
QString text = "";
|
||||||
|
text += QString("\tbg_hidden_item_event %1").arg(this->get("x"));
|
||||||
|
text += QString(", %1").arg(this->get("y"));
|
||||||
|
text += QString(", %1").arg(this->get("elevation"));
|
||||||
|
text += QString(", %1").arg(this->get("item"));
|
||||||
|
text += QString(", %1").arg(this->get("flag"));
|
||||||
|
text += "\n";
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Event::buildSecretBaseEventMacro()
|
||||||
|
{
|
||||||
|
QString text = "";
|
||||||
|
text += QString("\tbg_secret_base_event %1").arg(this->get("x"));
|
||||||
|
text += QString(", %1").arg(this->get("y"));
|
||||||
|
text += QString(", %1").arg(this->get("elevation"));
|
||||||
|
text += QString(", %1").arg(this->get("secret_base_map"));
|
||||||
|
text += "\n";
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
31
event.h
31
event.h
|
@ -4,12 +4,24 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
class EventType
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static QString Object;
|
||||||
|
static QString Warp;
|
||||||
|
static QString CoordScript;
|
||||||
|
static QString CoordWeather;
|
||||||
|
static QString Sign;
|
||||||
|
static QString HiddenItem;
|
||||||
|
static QString SecretBase;
|
||||||
|
};
|
||||||
|
|
||||||
class Event
|
class Event
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Event();
|
Event();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int x() {
|
int x() {
|
||||||
return getInt("x");
|
return getInt("x");
|
||||||
|
@ -39,6 +51,23 @@ public:
|
||||||
values.insert(key, value);
|
values.insert(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Event* createNewEvent(QString, QString);
|
||||||
|
static Event* createNewObjectEvent();
|
||||||
|
static Event* createNewWarpEvent(QString);
|
||||||
|
static Event* createNewCoordScriptEvent();
|
||||||
|
static Event* createNewCoordWeatherEvent();
|
||||||
|
static Event* createNewSignEvent();
|
||||||
|
static Event* createNewHiddenItemEvent();
|
||||||
|
static Event* createNewSecretBaseEvent();
|
||||||
|
|
||||||
|
QString buildObjectEventMacro(int);
|
||||||
|
QString buildWarpEventMacro(QMap<QString, QString>*);
|
||||||
|
QString buildCoordScriptEventMacro();
|
||||||
|
QString buildCoordWeatherEventMacro();
|
||||||
|
QString buildSignEventMacro();
|
||||||
|
QString buildHiddenItemEventMacro();
|
||||||
|
QString buildSecretBaseEventMacro();
|
||||||
|
|
||||||
QMap<QString, QString> values;
|
QMap<QString, QString> values;
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,12 +24,17 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
QCoreApplication::setApplicationName("pretmap");
|
QCoreApplication::setApplicationName("pretmap");
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
ui->newEventToolButton->initButton();
|
||||||
|
connect(ui->newEventToolButton, SIGNAL(newEventAdded(QString)), this, SLOT(addNewEvent(QString)));
|
||||||
|
|
||||||
new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z), this, SLOT(redo()));
|
new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z), this, SLOT(redo()));
|
||||||
|
|
||||||
editor = new Editor(ui);
|
editor = new Editor(ui);
|
||||||
connect(editor, SIGNAL(objectsChanged()), this, SLOT(updateSelectedObjects()));
|
connect(editor, SIGNAL(objectsChanged()), this, SLOT(updateSelectedObjects()));
|
||||||
connect(editor, SIGNAL(selectedObjectsChanged()), this, SLOT(updateSelectedObjects()));
|
connect(editor, SIGNAL(selectedObjectsChanged()), this, SLOT(updateSelectedObjects()));
|
||||||
connect(editor, SIGNAL(loadMapRequested(QString, QString)), this, SLOT(onLoadMapRequested(QString, QString)));
|
connect(editor, SIGNAL(loadMapRequested(QString, QString)), this, SLOT(onLoadMapRequested(QString, QString)));
|
||||||
|
connect(editor, SIGNAL(tilesetChanged(QString)), this, SLOT(onTilesetChanged(QString)));
|
||||||
|
|
||||||
on_toolButton_Paint_clicked();
|
on_toolButton_Paint_clicked();
|
||||||
|
|
||||||
|
@ -162,6 +167,9 @@ void MainWindow::setMap(QString map_name) {
|
||||||
//ui->graphicsView_Metatiles->setSceneRect(editor->scene_metatiles->sceneRect());
|
//ui->graphicsView_Metatiles->setSceneRect(editor->scene_metatiles->sceneRect());
|
||||||
ui->graphicsView_Metatiles->setFixedSize(editor->metatiles_item->pixmap().width() + 2, editor->metatiles_item->pixmap().height() + 2);
|
ui->graphicsView_Metatiles->setFixedSize(editor->metatiles_item->pixmap().width() + 2, editor->metatiles_item->pixmap().height() + 2);
|
||||||
|
|
||||||
|
ui->graphicsView_BorderMetatile->setScene(editor->scene_selected_border_metatiles);
|
||||||
|
ui->graphicsView_BorderMetatile->setFixedSize(editor->selected_border_metatiles_item->pixmap().width() + 2, editor->selected_border_metatiles_item->pixmap().height() + 2);
|
||||||
|
|
||||||
ui->graphicsView_Collision->setScene(editor->scene_collision_metatiles);
|
ui->graphicsView_Collision->setScene(editor->scene_collision_metatiles);
|
||||||
//ui->graphicsView_Collision->setSceneRect(editor->scene_collision_metatiles->sceneRect());
|
//ui->graphicsView_Collision->setSceneRect(editor->scene_collision_metatiles->sceneRect());
|
||||||
ui->graphicsView_Collision->setFixedSize(editor->collision_metatiles_item->pixmap().width() + 2, editor->collision_metatiles_item->pixmap().height() + 2);
|
ui->graphicsView_Collision->setFixedSize(editor->collision_metatiles_item->pixmap().width() + 2, editor->collision_metatiles_item->pixmap().height() + 2);
|
||||||
|
@ -199,6 +207,8 @@ void MainWindow::displayMapProperties() {
|
||||||
ui->comboBox_Weather->clear();
|
ui->comboBox_Weather->clear();
|
||||||
ui->comboBox_Type->clear();
|
ui->comboBox_Type->clear();
|
||||||
ui->comboBox_BattleScene->clear();
|
ui->comboBox_BattleScene->clear();
|
||||||
|
ui->comboBox_PrimaryTileset->clear();
|
||||||
|
ui->comboBox_SecondaryTileset->clear();
|
||||||
ui->checkBox_ShowLocation->setChecked(false);
|
ui->checkBox_ShowLocation->setChecked(false);
|
||||||
if (!editor || !editor->map || !editor->project) {
|
if (!editor || !editor->map || !editor->project) {
|
||||||
ui->frame_3->setEnabled(false);
|
ui->frame_3->setEnabled(false);
|
||||||
|
@ -215,6 +225,12 @@ void MainWindow::displayMapProperties() {
|
||||||
ui->comboBox_Location->addItems(project->getLocations());
|
ui->comboBox_Location->addItems(project->getLocations());
|
||||||
ui->comboBox_Location->setCurrentText(map->location);
|
ui->comboBox_Location->setCurrentText(map->location);
|
||||||
|
|
||||||
|
QMap<QString, QStringList> tilesets = project->getTilesets();
|
||||||
|
ui->comboBox_PrimaryTileset->addItems(tilesets.value("primary"));
|
||||||
|
ui->comboBox_PrimaryTileset->setCurrentText(map->layout->tileset_primary_label);
|
||||||
|
ui->comboBox_SecondaryTileset->addItems(tilesets.value("secondary"));
|
||||||
|
ui->comboBox_SecondaryTileset->setCurrentText(map->layout->tileset_secondary_label);
|
||||||
|
|
||||||
ui->comboBox_Visibility->addItems(project->getVisibilities());
|
ui->comboBox_Visibility->addItems(project->getVisibilities());
|
||||||
ui->comboBox_Visibility->setCurrentText(map->visibility);
|
ui->comboBox_Visibility->setCurrentText(map->visibility);
|
||||||
|
|
||||||
|
@ -405,6 +421,11 @@ void MainWindow::onAddNewMapToGroupClick(QAction* triggeredAction)
|
||||||
setMap(newMapName);
|
setMap(newMapName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onTilesetChanged(QString mapName)
|
||||||
|
{
|
||||||
|
setMap(mapName);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_mapList_activated(const QModelIndex &index)
|
void MainWindow::on_mapList_activated(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
QVariant data = index.data(Qt::UserRole);
|
QVariant data = index.data(Qt::UserRole);
|
||||||
|
@ -503,14 +524,12 @@ void MainWindow::on_actionRedo_triggered()
|
||||||
redo();
|
redo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_toolButton_newObject_clicked()
|
void MainWindow::addNewEvent(QString event_type)
|
||||||
{
|
{
|
||||||
if (editor) {
|
if (editor) {
|
||||||
DraggablePixmapItem *object = editor->addNewEvent();
|
DraggablePixmapItem *object = editor->addNewEvent(event_type);
|
||||||
if (object) {
|
if (object) {
|
||||||
//if (editor->selected_events->length()) {
|
editor->selectMapEvent(object, false);
|
||||||
editor->selectMapEvent(object, true);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
updateSelectedObjects();
|
updateSelectedObjects();
|
||||||
}
|
}
|
||||||
|
@ -554,12 +573,13 @@ void MainWindow::updateSelectedObjects() {
|
||||||
font.setCapitalization(QFont::Capitalize);
|
font.setCapitalization(QFont::Capitalize);
|
||||||
frame->ui->label_name->setFont(font);
|
frame->ui->label_name->setFont(font);
|
||||||
QString event_type = item->event->get("event_type");
|
QString event_type = item->event->get("event_type");
|
||||||
|
QString event_group_type = item->event->get("event_group_type");
|
||||||
QString map_name = item->event->get("map_name");
|
QString map_name = item->event->get("map_name");
|
||||||
frame->ui->label_name->setText(
|
frame->ui->label_name->setText(
|
||||||
QString("%1 %2 %3")
|
QString("%1: %2 %3")
|
||||||
|
.arg(editor->project->getMap(map_name)->events.value(event_group_type).indexOf(item->event) + 1)
|
||||||
.arg(map_name)
|
.arg(map_name)
|
||||||
.arg(event_type)
|
.arg(event_type)
|
||||||
.arg(editor->project->getMap(map_name)->events.value(event_type).indexOf(item->event) + 1)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
frame->ui->label_spritePixmap->setPixmap(item->event->pixmap);
|
frame->ui->label_spritePixmap->setPixmap(item->event->pixmap);
|
||||||
|
@ -574,13 +594,13 @@ void MainWindow::updateSelectedObjects() {
|
||||||
field_labels["behavior"] = "Behavior";
|
field_labels["behavior"] = "Behavior";
|
||||||
field_labels["radius_x"] = "Movement Radius X";
|
field_labels["radius_x"] = "Movement Radius X";
|
||||||
field_labels["radius_y"] = "Movement Radius Y";
|
field_labels["radius_y"] = "Movement Radius Y";
|
||||||
field_labels["property"] = "Property";
|
field_labels["trainer_see_type"] = "Trainer See Type";
|
||||||
field_labels["sight_radius"] = "Sight Radius";
|
field_labels["sight_radius_tree_id"] = "Sight Radius / Berry Tree ID";
|
||||||
field_labels["destination_warp"] = "Destination Warp";
|
field_labels["destination_warp"] = "Destination Warp";
|
||||||
field_labels["destination_map_name"] = "Destination Map";
|
field_labels["destination_map_name"] = "Destination Map";
|
||||||
field_labels["script_var"] = "Var";
|
field_labels["script_var"] = "Var";
|
||||||
field_labels["script_var_value"] = "Var Value";
|
field_labels["script_var_value"] = "Var Value";
|
||||||
field_labels["type"] = "Type";
|
field_labels["player_facing_direction"] = "Player Facing Direction";
|
||||||
field_labels["item"] = "Item";
|
field_labels["item"] = "Item";
|
||||||
field_labels["item_unknown5"] = "Unknown 5";
|
field_labels["item_unknown5"] = "Unknown 5";
|
||||||
field_labels["item_unknown6"] = "Unknown 6";
|
field_labels["item_unknown6"] = "Unknown 6";
|
||||||
|
@ -590,7 +610,7 @@ void MainWindow::updateSelectedObjects() {
|
||||||
|
|
||||||
QStringList fields;
|
QStringList fields;
|
||||||
|
|
||||||
if (event_type == "object") {
|
if (event_type == EventType::Object) {
|
||||||
|
|
||||||
frame->ui->sprite->setVisible(true);
|
frame->ui->sprite->setVisible(true);
|
||||||
frame->ui->comboBox_sprite->addItems(event_obj_gfx_constants.keys());
|
frame->ui->comboBox_sprite->addItems(event_obj_gfx_constants.keys());
|
||||||
|
@ -613,30 +633,30 @@ void MainWindow::updateSelectedObjects() {
|
||||||
fields << "script_label";
|
fields << "script_label";
|
||||||
fields << "event_flag";
|
fields << "event_flag";
|
||||||
fields << "replacement";
|
fields << "replacement";
|
||||||
fields << "property";
|
fields << "trainer_see_type";
|
||||||
fields << "sight_radius";
|
fields << "sight_radius_tree_id";
|
||||||
}
|
}
|
||||||
else if (event_type == "warp") {
|
else if (event_type == EventType::Warp) {
|
||||||
fields << "destination_warp";
|
fields << "destination_warp";
|
||||||
fields << "destination_map_name";
|
fields << "destination_map_name";
|
||||||
}
|
}
|
||||||
else if (event_type == "trap") {
|
else if (event_type == EventType::CoordScript) {
|
||||||
fields << "script_label";
|
fields << "script_label";
|
||||||
fields << "script_var";
|
fields << "script_var";
|
||||||
fields << "script_var_value";
|
fields << "script_var_value";
|
||||||
}
|
}
|
||||||
else if (event_type == "trap_weather") {
|
else if (event_type == EventType::CoordWeather) {
|
||||||
fields << "weather";
|
fields << "weather";
|
||||||
}
|
}
|
||||||
else if (event_type == "sign") {
|
else if (event_type == EventType::Sign) {
|
||||||
fields << "type";
|
fields << "player_facing_direction";
|
||||||
fields << "script_label";
|
fields << "script_label";
|
||||||
}
|
}
|
||||||
else if (event_type == "event_hidden_item") {
|
else if (event_type == EventType::HiddenItem) {
|
||||||
fields << "item";
|
fields << "item";
|
||||||
fields << "flag";
|
fields << "flag";
|
||||||
}
|
}
|
||||||
else if (event_type == "event_secret_base") {
|
else if (event_type == EventType::SecretBase) {
|
||||||
fields << "secret_base_map";
|
fields << "secret_base_map";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -808,3 +828,13 @@ void MainWindow::on_comboBox_EmergeMap_currentTextChanged(const QString &mapName
|
||||||
{
|
{
|
||||||
editor->updateEmergeMap(mapName);
|
editor->updateEmergeMap(mapName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_comboBox_PrimaryTileset_activated(const QString &tilesetLabel)
|
||||||
|
{
|
||||||
|
editor->updatePrimaryTileset(tilesetLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_comboBox_SecondaryTileset_activated(const QString &tilesetLabel)
|
||||||
|
{
|
||||||
|
editor->updateSecondaryTileset(tilesetLabel);
|
||||||
|
}
|
||||||
|
|
|
@ -56,10 +56,9 @@ private slots:
|
||||||
|
|
||||||
void on_actionRedo_triggered();
|
void on_actionRedo_triggered();
|
||||||
|
|
||||||
void on_toolButton_newObject_clicked();
|
|
||||||
|
|
||||||
void on_toolButton_deleteObject_clicked();
|
void on_toolButton_deleteObject_clicked();
|
||||||
|
|
||||||
|
void addNewEvent(QString);
|
||||||
void updateSelectedObjects();
|
void updateSelectedObjects();
|
||||||
|
|
||||||
void on_toolButton_Paint_clicked();
|
void on_toolButton_Paint_clicked();
|
||||||
|
@ -72,6 +71,7 @@ private slots:
|
||||||
|
|
||||||
void onOpenMapListContextMenu(const QPoint &point);
|
void onOpenMapListContextMenu(const QPoint &point);
|
||||||
void onAddNewMapToGroupClick(QAction* triggeredAction);
|
void onAddNewMapToGroupClick(QAction* triggeredAction);
|
||||||
|
void onTilesetChanged(QString);
|
||||||
|
|
||||||
void on_action_Export_Map_Image_triggered();
|
void on_action_Export_Map_Image_triggered();
|
||||||
|
|
||||||
|
@ -89,6 +89,10 @@ private slots:
|
||||||
|
|
||||||
void on_comboBox_EmergeMap_currentTextChanged(const QString &mapName);
|
void on_comboBox_EmergeMap_currentTextChanged(const QString &mapName);
|
||||||
|
|
||||||
|
void on_comboBox_PrimaryTileset_activated(const QString &arg1);
|
||||||
|
|
||||||
|
void on_comboBox_SecondaryTileset_activated(const QString &arg1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
QStandardItemModel *mapListModel;
|
QStandardItemModel *mapListModel;
|
||||||
|
|
214
mainwindow.ui
214
mainwindow.ui
|
@ -290,7 +290,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>614</width>
|
<width>436</width>
|
||||||
<height>621</height>
|
<height>621</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -451,9 +451,146 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
<widget class="QFrame" name="frame_Tilesets">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_PrimaryTileset">
|
||||||
|
<property name="text">
|
||||||
|
<string>Primary Tileset</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="comboBox_PrimaryTileset">
|
||||||
|
<property name="editable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_SecondaryTileset">
|
||||||
|
<property name="text">
|
||||||
|
<string>Secondary Tileset</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QComboBox" name="comboBox_SecondaryTileset">
|
||||||
|
<property name="editable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QFrame" name="frame_10">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetDefaultConstraint</enum>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_13">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_16">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Border</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGraphicsView" name="graphicsView_BorderMetatile">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>48</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Sunken</enum>
|
||||||
|
</property>
|
||||||
|
<property name="verticalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_12">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
<widget class="QScrollArea" name="scrollArea_2">
|
<widget class="QScrollArea" name="scrollArea_2">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
|
@ -470,6 +607,9 @@
|
||||||
<property name="widgetResizable">
|
<property name="widgetResizable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
<widget class="QWidget" name="scrollAreaWidgetContents_2">
|
<widget class="QWidget" name="scrollAreaWidgetContents_2">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -478,8 +618,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>180</width>
|
<width>358</width>
|
||||||
<height>629</height>
|
<height>497</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -488,7 +628,10 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_5" rowstretch="0" columnstretch="0">
|
<layout class="QGridLayout" name="gridLayout_5">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetDefaultConstraint</enum>
|
||||||
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -501,16 +644,26 @@
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="spacing">
|
<item row="1" column="1">
|
||||||
<number>0</number>
|
<spacer name="verticalSpacer_5">
|
||||||
</property>
|
<property name="orientation">
|
||||||
<item row="0" column="0">
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
<widget class="QGraphicsView" name="graphicsView_Metatiles">
|
<widget class="QGraphicsView" name="graphicsView_Metatiles">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
|
@ -526,6 +679,32 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<spacer name="horizontalSpacer_14">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<spacer name="horizontalSpacer_15">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -904,13 +1083,7 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="toolButton_newObject">
|
<widget class="NewEventToolButton" name="newEventToolButton">
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>40</width>
|
||||||
|
@ -918,7 +1091,7 @@
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>New</string>
|
<string>New Object</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="resources/images.qrc">
|
<iconset resource="resources/images.qrc">
|
||||||
|
@ -1794,6 +1967,11 @@
|
||||||
<extends>QGraphicsView</extends>
|
<extends>QGraphicsView</extends>
|
||||||
<header>graphicsview.h</header>
|
<header>graphicsview.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>NewEventToolButton</class>
|
||||||
|
<extends>QToolButton</extends>
|
||||||
|
<header>neweventtoolbutton.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="resources/images.qrc"/>
|
<include location="resources/images.qrc"/>
|
||||||
|
|
134
map.cpp
134
map.cpp
|
@ -31,6 +31,26 @@ QString Map::mapConstantFromName(QString mapName) {
|
||||||
return constantName;
|
return constantName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Map::objectEventsLabelFromName(QString mapName)
|
||||||
|
{
|
||||||
|
return QString("%1_EventObjects").arg(mapName);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Map::warpEventsLabelFromName(QString mapName)
|
||||||
|
{
|
||||||
|
return QString("%1_MapWarps").arg(mapName);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Map::coordEventsLabelFromName(QString mapName)
|
||||||
|
{
|
||||||
|
return QString("%1_MapCoordEvents").arg(mapName);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Map::bgEventsLabelFromName(QString mapName)
|
||||||
|
{
|
||||||
|
return QString("%1_MapBGEvents").arg(mapName);
|
||||||
|
}
|
||||||
|
|
||||||
int Map::getWidth() {
|
int Map::getWidth() {
|
||||||
return layout->width.toInt(nullptr, 0);
|
return layout->width.toInt(nullptr, 0);
|
||||||
}
|
}
|
||||||
|
@ -39,35 +59,6 @@ int Map::getHeight() {
|
||||||
return layout->height.toInt(nullptr, 0);
|
return layout->height.toInt(nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Tileset* Map::getBlockTileset(int metatile_index) {
|
|
||||||
int primary_size = 0x200;
|
|
||||||
if (metatile_index < primary_size) {
|
|
||||||
return layout->tileset_primary;
|
|
||||||
} else {
|
|
||||||
return layout->tileset_secondary;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QList<QRgb>> Map::getBlockPalettes(int metatile_index) {
|
|
||||||
QList<QList<QRgb>> palettes;
|
|
||||||
for (int i = 0; i < 6; i++) {
|
|
||||||
palettes.append(layout->tileset_primary->palettes->at(i));
|
|
||||||
}
|
|
||||||
for (int i = 6; i < layout->tileset_secondary->palettes->length(); i++) {
|
|
||||||
palettes.append(layout->tileset_secondary->palettes->at(i));
|
|
||||||
}
|
|
||||||
return palettes;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Map::getBlockIndex(int index) {
|
|
||||||
int primary_size = 0x200;
|
|
||||||
if (index < primary_size) {
|
|
||||||
return index;
|
|
||||||
} else {
|
|
||||||
return index - primary_size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int Map::getSelectedBlockIndex(int index) {
|
int Map::getSelectedBlockIndex(int index) {
|
||||||
if (index < layout->tileset_primary->metatiles->length()) {
|
if (index < layout->tileset_primary->metatiles->length()) {
|
||||||
return index;
|
return index;
|
||||||
|
@ -84,25 +75,6 @@ int Map::getDisplayedBlockIndex(int index) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage Map::getMetatileTile(int tile) {
|
|
||||||
Tileset *tileset = getBlockTileset(tile);
|
|
||||||
int local_index = getBlockIndex(tile);
|
|
||||||
if (!tileset || !tileset->tiles) {
|
|
||||||
return QImage();
|
|
||||||
}
|
|
||||||
return tileset->tiles->value(local_index, QImage());
|
|
||||||
}
|
|
||||||
|
|
||||||
Metatile* Map::getMetatile(int index) {
|
|
||||||
Tileset *tileset = getBlockTileset(index);
|
|
||||||
int local_index = getBlockIndex(index);
|
|
||||||
if (!tileset || !tileset->metatiles) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
Metatile *metatile = tileset->metatiles->value(local_index, NULL);
|
|
||||||
return metatile;
|
|
||||||
}
|
|
||||||
|
|
||||||
QImage Map::getCollisionMetatileImage(Block block) {
|
QImage Map::getCollisionMetatileImage(Block block) {
|
||||||
return getCollisionMetatileImage(block.collision);
|
return getCollisionMetatileImage(block.collision);
|
||||||
}
|
}
|
||||||
|
@ -146,57 +118,6 @@ QImage Map::getElevationMetatileImage(int elevation) {
|
||||||
return metatile_image;
|
return metatile_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage Map::getMetatileImage(int tile) {
|
|
||||||
|
|
||||||
QImage metatile_image(16, 16, QImage::Format_RGBA8888);
|
|
||||||
|
|
||||||
Metatile* metatile = getMetatile(tile);
|
|
||||||
if (!metatile || !metatile->tiles) {
|
|
||||||
metatile_image.fill(0xffffffff);
|
|
||||||
return metatile_image;
|
|
||||||
}
|
|
||||||
|
|
||||||
Tileset* blockTileset = getBlockTileset(tile);
|
|
||||||
if (!blockTileset) {
|
|
||||||
metatile_image.fill(0xffffffff);
|
|
||||||
return metatile_image;
|
|
||||||
}
|
|
||||||
QList<QList<QRgb>> palettes = getBlockPalettes(tile);
|
|
||||||
|
|
||||||
QPainter metatile_painter(&metatile_image);
|
|
||||||
for (int layer = 0; layer < 2; layer++)
|
|
||||||
for (int y = 0; y < 2; y++)
|
|
||||||
for (int x = 0; x < 2; x++) {
|
|
||||||
Tile tile_ = metatile->tiles->value((y * 2) + x + (layer * 4));
|
|
||||||
QImage tile_image = getMetatileTile(tile_.tile);
|
|
||||||
if (tile_image.isNull()) {
|
|
||||||
// Some metatiles specify tiles that are outside the valid range.
|
|
||||||
// These are treated as completely transparent, so they can be skipped without
|
|
||||||
// being drawn.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Colorize the metatile tiles with its palette.
|
|
||||||
QList<QRgb> palette = palettes.value(tile_.palette);
|
|
||||||
for (int j = 0; j < palette.length(); j++) {
|
|
||||||
tile_image.setColor(j, palette.value(j));
|
|
||||||
}
|
|
||||||
|
|
||||||
// The top layer of the metatile has its last color displayed at transparent.
|
|
||||||
if (layer > 0) {
|
|
||||||
QColor color(tile_image.color(15));
|
|
||||||
color.setAlpha(0);
|
|
||||||
tile_image.setColor(15, color.rgba());
|
|
||||||
}
|
|
||||||
|
|
||||||
QPoint origin = QPoint(x*8, y*8);
|
|
||||||
metatile_painter.drawImage(origin, tile_image.mirrored(tile_.xflip == 1, tile_.yflip == 1));
|
|
||||||
}
|
|
||||||
metatile_painter.end();
|
|
||||||
|
|
||||||
return metatile_image;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Map::blockChanged(int i, Blockdata *cache) {
|
bool Map::blockChanged(int i, Blockdata *cache) {
|
||||||
if (cache == NULL || cache == nullptr) {
|
if (cache == NULL || cache == nullptr) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -275,7 +196,7 @@ QPixmap Map::renderCollision(bool ignoreCache) {
|
||||||
}
|
}
|
||||||
changed_any = true;
|
changed_any = true;
|
||||||
Block block = layout->blockdata->blocks->value(i);
|
Block block = layout->blockdata->blocks->value(i);
|
||||||
QImage metatile_image = getMetatileImage(block.tile);
|
QImage metatile_image = Metatile::getMetatileImage(block.tile, layout->tileset_primary, layout->tileset_secondary);
|
||||||
QImage collision_metatile_image = getCollisionMetatileImage(block);
|
QImage collision_metatile_image = getCollisionMetatileImage(block);
|
||||||
QImage elevation_metatile_image = getElevationMetatileImage(block);
|
QImage elevation_metatile_image = getElevationMetatileImage(block);
|
||||||
int map_y = width_ ? i / width_ : 0;
|
int map_y = width_ ? i / width_ : 0;
|
||||||
|
@ -344,7 +265,7 @@ QPixmap Map::render(bool ignoreCache = false) {
|
||||||
}
|
}
|
||||||
changed_any = true;
|
changed_any = true;
|
||||||
Block block = layout->blockdata->blocks->value(i);
|
Block block = layout->blockdata->blocks->value(i);
|
||||||
QImage metatile_image = getMetatileImage(block.tile);
|
QImage metatile_image = Metatile::getMetatileImage(block.tile, layout->tileset_primary, layout->tileset_secondary);
|
||||||
int map_y = width_ ? i / width_ : 0;
|
int map_y = width_ ? i / width_ : 0;
|
||||||
int map_x = width_ ? i % width_ : 0;
|
int map_x = width_ ? i % width_ : 0;
|
||||||
QPoint metatile_origin = QPoint(map_x * 16, map_y * 16);
|
QPoint metatile_origin = QPoint(map_x * 16, map_y * 16);
|
||||||
|
@ -377,7 +298,7 @@ QPixmap Map::renderBorder() {
|
||||||
}
|
}
|
||||||
changed_any = true;
|
changed_any = true;
|
||||||
Block block = layout->border->blocks->value(i);
|
Block block = layout->border->blocks->value(i);
|
||||||
QImage metatile_image = getMetatileImage(block.tile);
|
QImage metatile_image = Metatile::getMetatileImage(block.tile, layout->tileset_primary, layout->tileset_secondary);
|
||||||
int map_y = i / width_;
|
int map_y = i / width_;
|
||||||
int map_x = i % width_;
|
int map_x = i % width_;
|
||||||
painter.drawImage(QPoint(map_x * 16, map_y * 16), metatile_image);
|
painter.drawImage(QPoint(map_x * 16, map_y * 16), metatile_image);
|
||||||
|
@ -493,7 +414,7 @@ QPixmap Map::renderMetatiles() {
|
||||||
if (i >= primary_length) {
|
if (i >= primary_length) {
|
||||||
tile += 0x200 - primary_length;
|
tile += 0x200 - primary_length;
|
||||||
}
|
}
|
||||||
QImage metatile_image = getMetatileImage(tile);
|
QImage metatile_image = Metatile::getMetatileImage(tile, layout->tileset_primary, layout->tileset_secondary);
|
||||||
int map_y = i / width_;
|
int map_y = i / width_;
|
||||||
int map_x = i % width_;
|
int map_x = i % width_;
|
||||||
QPoint metatile_origin = QPoint(map_x * 16, map_y * 16);
|
QPoint metatile_origin = QPoint(map_x * 16, map_y * 16);
|
||||||
|
@ -733,11 +654,6 @@ QList<Event *> Map::getAllEvents() {
|
||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Event *> Map::getEventsByType(QString type)
|
|
||||||
{
|
|
||||||
return events.value(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::removeEvent(Event *event) {
|
void Map::removeEvent(Event *event) {
|
||||||
for (QString key : events.keys()) {
|
for (QString key : events.keys()) {
|
||||||
events[key].removeAll(event);
|
events[key].removeAll(event);
|
||||||
|
@ -745,7 +661,7 @@ void Map::removeEvent(Event *event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Map::addEvent(Event *event) {
|
void Map::addEvent(Event *event) {
|
||||||
events[event->get("event_type")].append(event);
|
events[event->get("event_group_type")].append(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Map::hasUnsavedChanges() {
|
bool Map::hasUnsavedChanges() {
|
||||||
|
|
22
map.h
22
map.h
|
@ -129,15 +129,14 @@ public:
|
||||||
public:
|
public:
|
||||||
void setName(QString mapName);
|
void setName(QString mapName);
|
||||||
static QString mapConstantFromName(QString mapName);
|
static QString mapConstantFromName(QString mapName);
|
||||||
|
static QString objectEventsLabelFromName(QString mapName);
|
||||||
|
static QString warpEventsLabelFromName(QString mapName);
|
||||||
|
static QString coordEventsLabelFromName(QString mapName);
|
||||||
|
static QString bgEventsLabelFromName(QString mapName);
|
||||||
int getWidth();
|
int getWidth();
|
||||||
int getHeight();
|
int getHeight();
|
||||||
Tileset* getBlockTileset(int);
|
int getSelectedBlockIndex(int);
|
||||||
int getBlockIndex(int layout_id);
|
int getDisplayedBlockIndex(int);
|
||||||
int getSelectedBlockIndex(int layout_id);
|
|
||||||
int getDisplayedBlockIndex(int layout_id);
|
|
||||||
Metatile* getMetatile(int);
|
|
||||||
QImage getMetatileImage(int);
|
|
||||||
QImage getMetatileTile(int);
|
|
||||||
QPixmap render(bool ignoreCache);
|
QPixmap render(bool ignoreCache);
|
||||||
QPixmap renderMetatiles();
|
QPixmap renderMetatiles();
|
||||||
|
|
||||||
|
@ -188,19 +187,12 @@ public:
|
||||||
void redo();
|
void redo();
|
||||||
void commit();
|
void commit();
|
||||||
|
|
||||||
QString object_events_label;
|
|
||||||
QString warps_label;
|
|
||||||
QString coord_events_label;
|
|
||||||
QString bg_events_label;
|
|
||||||
|
|
||||||
QList<Event*> getAllEvents();
|
QList<Event*> getAllEvents();
|
||||||
QList<Event*> getEventsByType(QString type);
|
|
||||||
void removeEvent(Event *event);
|
void removeEvent(Event *event);
|
||||||
void addEvent(Event *event);
|
void addEvent(Event *event);
|
||||||
QMap<QString, QList<Event*>> events;
|
QMap<QString, QList<Event*>> events;
|
||||||
|
|
||||||
QList<Connection*> connections;
|
QList<Connection*> connections;
|
||||||
QList<QGraphicsPixmapItem*> connection_items;
|
|
||||||
QPixmap renderConnection(Connection);
|
QPixmap renderConnection(Connection);
|
||||||
|
|
||||||
QPixmap renderBorder();
|
QPixmap renderBorder();
|
||||||
|
@ -216,8 +208,6 @@ public:
|
||||||
void hoveredElevationTileChanged(int elevation);
|
void hoveredElevationTileChanged(int elevation);
|
||||||
void clearHoveredElevationTile();
|
void clearHoveredElevationTile();
|
||||||
|
|
||||||
QList<QList<QRgb> > getBlockPalettes(int metatile_index);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void paintTileChanged(Map *map);
|
void paintTileChanged(Map *map);
|
||||||
void paintCollisionChanged(Map *map);
|
void paintCollisionChanged(Map *map);
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
#include "metatile.h"
|
|
||||||
|
|
||||||
Metatile::Metatile()
|
|
||||||
{
|
|
||||||
tiles = new QList<Tile>;
|
|
||||||
}
|
|
16
metatile.h
16
metatile.h
|
@ -1,16 +0,0 @@
|
||||||
#ifndef METATILE_H
|
|
||||||
#define METATILE_H
|
|
||||||
|
|
||||||
#include "tile.h"
|
|
||||||
#include <QList>
|
|
||||||
|
|
||||||
class Metatile
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Metatile();
|
|
||||||
public:
|
|
||||||
QList<Tile> *tiles = NULL;
|
|
||||||
int attr;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // METATILE_H
|
|
103
neweventtoolbutton.cpp
Normal file
103
neweventtoolbutton.cpp
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
#include "neweventtoolbutton.h"
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
// Custom QToolButton which has a context menu that expands to allow
|
||||||
|
// selection of different types of map events.
|
||||||
|
NewEventToolButton::NewEventToolButton(QWidget *parent) :
|
||||||
|
QToolButton(parent)
|
||||||
|
{
|
||||||
|
setPopupMode(QToolButton::MenuButtonPopup);
|
||||||
|
QObject::connect(this, SIGNAL(triggered(QAction*)),
|
||||||
|
this, SLOT(setDefaultAction(QAction*)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewEventToolButton::initButton()
|
||||||
|
{
|
||||||
|
// Add a context menu to select different types of map events.
|
||||||
|
this->newObjectAction = new QAction("New Object", this);
|
||||||
|
this->newObjectAction->setIcon(QIcon(":/icons/add.ico"));
|
||||||
|
connect(this->newObjectAction, SIGNAL(triggered(bool)), this, SLOT(newObject()));
|
||||||
|
|
||||||
|
this->newWarpAction = new QAction("New Warp", this);
|
||||||
|
this->newWarpAction->setIcon(QIcon(":/icons/add.ico"));
|
||||||
|
connect(this->newWarpAction, SIGNAL(triggered(bool)), this, SLOT(newWarp()));
|
||||||
|
|
||||||
|
this->newCoordScriptAction = new QAction("New Coord Script", this);
|
||||||
|
this->newCoordScriptAction->setIcon(QIcon(":/icons/add.ico"));
|
||||||
|
connect(this->newCoordScriptAction, SIGNAL(triggered(bool)), this, SLOT(newCoordScript()));
|
||||||
|
|
||||||
|
this->newCoordWeatherAction = new QAction("New Coord Weather", this);
|
||||||
|
this->newCoordWeatherAction->setIcon(QIcon(":/icons/add.ico"));
|
||||||
|
connect(this->newCoordWeatherAction, SIGNAL(triggered(bool)), this, SLOT(newCoordWeather()));
|
||||||
|
|
||||||
|
this->newSignAction = new QAction("New Sign", this);
|
||||||
|
this->newSignAction->setIcon(QIcon(":/icons/add.ico"));
|
||||||
|
connect(this->newSignAction, SIGNAL(triggered(bool)), this, SLOT(newSign()));
|
||||||
|
|
||||||
|
this->newHiddenItemAction = new QAction("New Hidden Item", this);
|
||||||
|
this->newHiddenItemAction->setIcon(QIcon(":/icons/add.ico"));
|
||||||
|
connect(this->newHiddenItemAction, SIGNAL(triggered(bool)), this, SLOT(newHiddenItem()));
|
||||||
|
|
||||||
|
this->newSecretBaseAction = new QAction("New Secret Base", this);
|
||||||
|
this->newSecretBaseAction->setIcon(QIcon(":/icons/add.ico"));
|
||||||
|
connect(this->newSecretBaseAction, SIGNAL(triggered(bool)), this, SLOT(newSecretBase()));
|
||||||
|
|
||||||
|
QMenu *alignMenu = new QMenu();
|
||||||
|
alignMenu->addAction(this->newObjectAction);
|
||||||
|
alignMenu->addAction(this->newWarpAction);
|
||||||
|
alignMenu->addAction(this->newCoordScriptAction);
|
||||||
|
alignMenu->addAction(this->newCoordWeatherAction);
|
||||||
|
alignMenu->addAction(this->newSignAction);
|
||||||
|
alignMenu->addAction(this->newHiddenItemAction);
|
||||||
|
alignMenu->addAction(this->newSecretBaseAction);
|
||||||
|
this->setMenu(alignMenu);
|
||||||
|
this->setDefaultAction(this->newObjectAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NewEventToolButton::getSelectedEventType()
|
||||||
|
{
|
||||||
|
return this->selectedEventType;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewEventToolButton::newObject()
|
||||||
|
{
|
||||||
|
this->selectedEventType = EventType::Object;
|
||||||
|
emit newEventAdded(this->selectedEventType);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewEventToolButton::newWarp()
|
||||||
|
{
|
||||||
|
this->selectedEventType = EventType::Warp;
|
||||||
|
emit newEventAdded(this->selectedEventType);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewEventToolButton::newCoordScript()
|
||||||
|
{
|
||||||
|
this->selectedEventType = EventType::CoordScript;
|
||||||
|
emit newEventAdded(this->selectedEventType);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewEventToolButton::newCoordWeather()
|
||||||
|
{
|
||||||
|
this->selectedEventType = EventType::CoordWeather;
|
||||||
|
emit newEventAdded(this->selectedEventType);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewEventToolButton::newSign()
|
||||||
|
{
|
||||||
|
this->selectedEventType = EventType::Sign;
|
||||||
|
emit newEventAdded(this->selectedEventType);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewEventToolButton::newHiddenItem()
|
||||||
|
{
|
||||||
|
this->selectedEventType = EventType::HiddenItem;
|
||||||
|
emit newEventAdded(this->selectedEventType);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewEventToolButton::newSecretBase()
|
||||||
|
{
|
||||||
|
this->selectedEventType = EventType::SecretBase;
|
||||||
|
emit newEventAdded(this->selectedEventType);
|
||||||
|
}
|
35
neweventtoolbutton.h
Normal file
35
neweventtoolbutton.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef NEWEVENTTOOLBUTTON_H
|
||||||
|
#define NEWEVENTTOOLBUTTON_H
|
||||||
|
|
||||||
|
#include "event.h"
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
|
class NewEventToolButton : public QToolButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit NewEventToolButton(QWidget *parent = 0);
|
||||||
|
void initButton();
|
||||||
|
QString getSelectedEventType();
|
||||||
|
public slots:
|
||||||
|
void newObject();
|
||||||
|
void newWarp();
|
||||||
|
void newCoordScript();
|
||||||
|
void newCoordWeather();
|
||||||
|
void newSign();
|
||||||
|
void newHiddenItem();
|
||||||
|
void newSecretBase();
|
||||||
|
signals:
|
||||||
|
void newEventAdded(QString);
|
||||||
|
private:
|
||||||
|
QString selectedEventType;
|
||||||
|
QAction *newObjectAction;
|
||||||
|
QAction *newWarpAction;
|
||||||
|
QAction *newCoordScriptAction;
|
||||||
|
QAction *newCoordWeatherAction;
|
||||||
|
QAction *newSignAction;
|
||||||
|
QAction *newHiddenItemAction;
|
||||||
|
QAction *newSecretBaseAction;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NEWEVENTTOOLBUTTON_H
|
|
@ -19,13 +19,13 @@ SOURCES += main.cpp\
|
||||||
blockdata.cpp \
|
blockdata.cpp \
|
||||||
block.cpp \
|
block.cpp \
|
||||||
tileset.cpp \
|
tileset.cpp \
|
||||||
metatile.cpp \
|
|
||||||
tile.cpp \
|
tile.cpp \
|
||||||
event.cpp \
|
event.cpp \
|
||||||
editor.cpp \
|
editor.cpp \
|
||||||
objectpropertiesframe.cpp \
|
objectpropertiesframe.cpp \
|
||||||
graphicsview.cpp \
|
graphicsview.cpp \
|
||||||
parseutil.cpp
|
parseutil.cpp \
|
||||||
|
neweventtoolbutton.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
project.h \
|
project.h \
|
||||||
|
@ -33,13 +33,13 @@ HEADERS += mainwindow.h \
|
||||||
blockdata.h \
|
blockdata.h \
|
||||||
block.h \
|
block.h \
|
||||||
tileset.h \
|
tileset.h \
|
||||||
metatile.h \
|
|
||||||
tile.h \
|
tile.h \
|
||||||
event.h \
|
event.h \
|
||||||
editor.h \
|
editor.h \
|
||||||
objectpropertiesframe.h \
|
objectpropertiesframe.h \
|
||||||
graphicsview.h \
|
graphicsview.h \
|
||||||
parseutil.h
|
parseutil.h \
|
||||||
|
neweventtoolbutton.h
|
||||||
|
|
||||||
FORMS += mainwindow.ui \
|
FORMS += mainwindow.ui \
|
||||||
objectpropertiesframe.ui
|
objectpropertiesframe.ui
|
||||||
|
|
268
project.cpp
268
project.cpp
|
@ -2,7 +2,6 @@
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
#include "tileset.h"
|
#include "tileset.h"
|
||||||
#include "metatile.h"
|
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -65,7 +64,6 @@ void Project::loadMapConnections(Map *map) {
|
||||||
}
|
}
|
||||||
|
|
||||||
map->connections.clear();
|
map->connections.clear();
|
||||||
map->connection_items.clear();
|
|
||||||
if (!map->connections_label.isNull()) {
|
if (!map->connections_label.isNull()) {
|
||||||
QString path = root + QString("/data/maps/%1/connections.inc").arg(map->name);
|
QString path = root + QString("/data/maps/%1/connections.inc").arg(map->name);
|
||||||
QString text = readTextFile(path);
|
QString text = readTextFile(path);
|
||||||
|
@ -355,7 +353,7 @@ void Project::readMapLayout(Map* map) {
|
||||||
map->layout = mapLayouts[map->layout_label];
|
map->layout = mapLayouts[map->layout_label];
|
||||||
}
|
}
|
||||||
|
|
||||||
getTilesets(map);
|
loadMapTilesets(map);
|
||||||
loadBlockdata(map);
|
loadBlockdata(map);
|
||||||
loadMapBorder(map);
|
loadMapBorder(map);
|
||||||
}
|
}
|
||||||
|
@ -495,7 +493,7 @@ void Project::saveMapConstantsHeader() {
|
||||||
saveTextFile(root + "/include/constants/maps.h", text);
|
saveTextFile(root + "/include/constants/maps.h", text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::getTilesets(Map* map) {
|
void Project::loadMapTilesets(Map* map) {
|
||||||
if (map->layout->has_unsaved_changes) {
|
if (map->layout->has_unsaved_changes) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -956,7 +954,7 @@ Map* Project::addNewMapToGroup(QString mapName, int groupNum) {
|
||||||
mapNamesToMapConstants->insert(map->name, map->constantName);
|
mapNamesToMapConstants->insert(map->name, map->constantName);
|
||||||
setNewMapHeader(map, mapLayoutsTable.size() + 1);
|
setNewMapHeader(map, mapLayoutsTable.size() + 1);
|
||||||
setNewMapLayout(map);
|
setNewMapLayout(map);
|
||||||
getTilesets(map);
|
loadMapTilesets(map);
|
||||||
setNewMapBlockdata(map);
|
setNewMapBlockdata(map);
|
||||||
setNewMapBorder(map);
|
setNewMapBorder(map);
|
||||||
setNewMapEvents(map);
|
setNewMapEvents(map);
|
||||||
|
@ -1002,6 +1000,47 @@ QStringList Project::getVisibilities() {
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMap<QString, QStringList> Project::getTilesets() {
|
||||||
|
QMap<QString, QStringList> allTilesets;
|
||||||
|
QStringList primaryTilesets;
|
||||||
|
QStringList secondaryTilesets;
|
||||||
|
allTilesets.insert("primary", primaryTilesets);
|
||||||
|
allTilesets.insert("secondary", secondaryTilesets);
|
||||||
|
QString headers_text = readTextFile(root + "/data/tilesets/headers.inc");
|
||||||
|
QList<QStringList>* commands = parseAsm(headers_text);
|
||||||
|
int i = 0;
|
||||||
|
while (i < commands->length()) {
|
||||||
|
if (commands->at(i).length() != 2)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (commands->at(i).at(0) == ".label") {
|
||||||
|
QString tilesetLabel = commands->at(i).at(1);
|
||||||
|
// Advance to command specifying whether or not it is a secondary tileset
|
||||||
|
i += 2;
|
||||||
|
if (commands->at(i).at(0) != ".byte") {
|
||||||
|
qDebug() << "Unexpected command found for secondary tileset flag. Expected '.byte', but found: " << commands->at(i).at(0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString secondaryTilesetValue = commands->at(i).at(1);
|
||||||
|
if (secondaryTilesetValue != "TRUE" && secondaryTilesetValue != "FALSE" && secondaryTilesetValue != "0" && secondaryTilesetValue != "1") {
|
||||||
|
qDebug() << "Unexpected secondary tileset flag found. Expected \"TRUE\", \"FALSE\", \"0\", or \"1\", but found: " << secondaryTilesetValue;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isSecondaryTileset = (secondaryTilesetValue == "TRUE" || secondaryTilesetValue == "1");
|
||||||
|
if (isSecondaryTileset)
|
||||||
|
allTilesets["secondary"].append(tilesetLabel);
|
||||||
|
else
|
||||||
|
allTilesets["primary"].append(tilesetLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return allTilesets;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList Project::getWeathers() {
|
QStringList Project::getWeathers() {
|
||||||
// TODO
|
// TODO
|
||||||
QStringList names;
|
QStringList names;
|
||||||
|
@ -1152,17 +1191,17 @@ void Project::loadEventPixmaps(QList<Event*> objects) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QString event_type = object->get("event_type");
|
QString event_type = object->get("event_type");
|
||||||
if (event_type == "object") {
|
if (event_type == EventType::Object) {
|
||||||
object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(0, 0, 16, 16);
|
object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(0, 0, 16, 16);
|
||||||
} else if (event_type == "warp") {
|
} else if (event_type == EventType::Warp) {
|
||||||
object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(16, 0, 16, 16);
|
object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(16, 0, 16, 16);
|
||||||
} else if (event_type == "trap" || event_type == "trap_weather") {
|
} else if (event_type == EventType::CoordScript || event_type == EventType::CoordWeather) {
|
||||||
object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(32, 0, 16, 16);
|
object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(32, 0, 16, 16);
|
||||||
} else if (event_type == "sign" || event_type == "event_hidden_item" || event_type == "event_secret_base") {
|
} else if (event_type == EventType::Sign || event_type == EventType::HiddenItem || event_type == EventType::SecretBase) {
|
||||||
object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(48, 0, 16, 16);
|
object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(48, 0, 16, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event_type == "object") {
|
if (event_type == EventType::Object) {
|
||||||
int sprite_id = constants.value(object->get("sprite"));
|
int sprite_id = constants.value(object->get("sprite"));
|
||||||
|
|
||||||
QString info_label = pointers.value(sprite_id).replace("&", "");
|
QString info_label = pointers.value(sprite_id).replace("&", "");
|
||||||
|
@ -1178,117 +1217,74 @@ void Project::loadEventPixmaps(QList<Event*> objects) {
|
||||||
object->pixmap = pixmap;
|
object->pixmap = pixmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::saveMapEvents(Map *map) {
|
void Project::saveMapEvents(Map *map) {
|
||||||
QString path = root + QString("/data/maps/%1/events.inc").arg(map->name);
|
QString path = root + QString("/data/maps/%1/events.inc").arg(map->name);
|
||||||
QString text = "";
|
QString text = "";
|
||||||
|
QString objectEventsLabel = "0x0";
|
||||||
|
QString warpEventsLabel = "0x0";
|
||||||
|
QString coordEventsLabel = "0x0";
|
||||||
|
QString bgEventsLabel = "0x0";
|
||||||
|
|
||||||
if (map->events["object"].length() > 0) {
|
if (map->events["object_event_group"].length() > 0) {
|
||||||
text += QString("%1::\n").arg(map->object_events_label);
|
objectEventsLabel = Map::objectEventsLabelFromName(map->name);
|
||||||
for (int i = 0; i < map->events["object"].length(); i++) {
|
text += QString("%1::\n").arg(objectEventsLabel);
|
||||||
Event *object_event = map->events["object"].value(i);
|
for (int i = 0; i < map->events["object_event_group"].length(); i++) {
|
||||||
int radius_x = object_event->getInt("radius_x");
|
Event *object_event = map->events["object_event_group"].value(i);
|
||||||
int radius_y = object_event->getInt("radius_y");
|
text += object_event->buildObjectEventMacro(i);
|
||||||
uint16_t x = object_event->getInt("x");
|
|
||||||
uint16_t y = object_event->getInt("y");
|
|
||||||
|
|
||||||
text += QString("\tobject_event %1").arg(i + 1);
|
|
||||||
text += QString(", %1").arg(object_event->get("sprite"));
|
|
||||||
text += QString(", %1").arg(object_event->get("replacement"));
|
|
||||||
text += QString(", %1").arg(x);
|
|
||||||
text += QString(", %1").arg(y);
|
|
||||||
text += QString(", %1").arg(object_event->get("elevation"));
|
|
||||||
text += QString(", %1").arg(object_event->get("behavior"));
|
|
||||||
text += QString(", %1").arg(radius_x);
|
|
||||||
text += QString(", %1").arg(radius_y);
|
|
||||||
text += QString(", %1").arg(object_event->get("property"));
|
|
||||||
text += QString(", %1").arg(object_event->get("sight_radius"));
|
|
||||||
text += QString(", %1").arg(object_event->get("script_label"));
|
|
||||||
text += QString(", %1").arg(object_event->get("event_flag"));
|
|
||||||
text += "\n";
|
|
||||||
}
|
}
|
||||||
text += "\n";
|
text += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map->events["warp"].length() > 0) {
|
if (map->events["warp_event_group"].length() > 0) {
|
||||||
text += QString("%1::\n").arg(map->warps_label);
|
warpEventsLabel = Map::warpEventsLabelFromName(map->name);
|
||||||
for (Event *warp : map->events["warp"]) {
|
text += QString("%1::\n").arg(warpEventsLabel);
|
||||||
text += QString("\twarp_def %1").arg(warp->get("x"));
|
for (Event *warp : map->events["warp_event_group"]) {
|
||||||
text += QString(", %1").arg(warp->get("y"));
|
text += warp->buildWarpEventMacro(mapNamesToMapConstants);
|
||||||
text += QString(", %1").arg(warp->get("elevation"));
|
|
||||||
text += QString(", %1").arg(warp->get("destination_warp"));
|
|
||||||
text += QString(", %1").arg(mapNamesToMapConstants->value(warp->get("destination_map_name")));
|
|
||||||
text += "\n";
|
|
||||||
}
|
}
|
||||||
text += "\n";
|
text += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map->events["trap"].length() + map->events["trap_weather"].length() > 0) {
|
if (map->events["coord_event_group"].length() > 0) {
|
||||||
text += QString("%1::\n").arg(map->coord_events_label);
|
coordEventsLabel = Map::coordEventsLabelFromName(map->name);
|
||||||
for (Event *coords : map->events["trap"]) {
|
text += QString("%1::\n").arg(coordEventsLabel);
|
||||||
text += QString("\tcoord_event %1").arg(coords->get("x"));
|
for (Event *event : map->events["coord_event_group"]) {
|
||||||
text += QString(", %1").arg(coords->get("y"));
|
QString event_type = event->get("event_type");
|
||||||
text += QString(", %1").arg(coords->get("elevation"));
|
if (event_type == EventType::CoordScript) {
|
||||||
text += QString(", 0");
|
text += event->buildCoordScriptEventMacro();
|
||||||
text += QString(", %1").arg(coords->get("script_var"));
|
} else if (event_type == EventType::CoordWeather) {
|
||||||
text += QString(", %1").arg(coords->get("script_var_value"));
|
text += event->buildCoordWeatherEventMacro();
|
||||||
text += QString(", 0");
|
}
|
||||||
text += QString(", %1").arg(coords->get("script_label"));
|
|
||||||
text += "\n";
|
|
||||||
}
|
|
||||||
for (Event *coords : map->events["trap_weather"]) {
|
|
||||||
text += QString("\tcoord_weather_event %1").arg(coords->get("x"));
|
|
||||||
text += QString(", %1").arg(coords->get("y"));
|
|
||||||
text += QString(", %1").arg(coords->get("elevation"));
|
|
||||||
text += QString(", %1").arg(coords->get("weather"));
|
|
||||||
text += "\n";
|
|
||||||
}
|
}
|
||||||
text += "\n";
|
text += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map->events["sign"].length() +
|
if (map->events["bg_event_group"].length() > 0)
|
||||||
map->events["event_hidden_item"].length() +
|
|
||||||
map->events["event_secret_base"].length() > 0)
|
|
||||||
{
|
{
|
||||||
text += QString("%1::\n").arg(map->bg_events_label);
|
bgEventsLabel = Map::bgEventsLabelFromName(map->name);
|
||||||
for (Event *sign : map->events["sign"]) {
|
text += QString("%1::\n").arg(bgEventsLabel);
|
||||||
text += QString("\tbg_event %1").arg(sign->get("x"));
|
for (Event *event : map->events["bg_event_group"]) {
|
||||||
text += QString(", %1").arg(sign->get("y"));
|
QString event_type = event->get("event_type");
|
||||||
text += QString(", %1").arg(sign->get("elevation"));
|
if (event_type == EventType::Sign) {
|
||||||
text += QString(", %1").arg(sign->get("type"));
|
text += event->buildSignEventMacro();
|
||||||
text += QString(", 0");
|
} else if (event_type == EventType::HiddenItem) {
|
||||||
text += QString(", %1").arg(sign->get("script_label"));
|
text += event->buildHiddenItemEventMacro();
|
||||||
text += "\n";
|
} else if (event_type == EventType::SecretBase) {
|
||||||
}
|
text += event->buildSecretBaseEventMacro();
|
||||||
for (Event *item : map->events["event_hidden_item"]) {
|
}
|
||||||
text += QString("\tbg_hidden_item_event %1").arg(item->get("x"));
|
|
||||||
text += QString(", %1").arg(item->get("y"));
|
|
||||||
text += QString(", %1").arg(item->get("elevation"));
|
|
||||||
text += QString(", %1").arg(item->get("item"));
|
|
||||||
text += QString(", %1").arg(item->get("flag"));
|
|
||||||
text += "\n";
|
|
||||||
}
|
|
||||||
for (Event *item : map->events["event_secret_base"]) {
|
|
||||||
text += QString("\tbg_secret_base_event %1").arg(item->get("x"));
|
|
||||||
text += QString(", %1").arg(item->get("y"));
|
|
||||||
text += QString(", %1").arg(item->get("elevation"));
|
|
||||||
text += QString(", %1").arg(item->get("secret_base_map"));
|
|
||||||
text += "\n";
|
|
||||||
}
|
}
|
||||||
text += "\n";
|
text += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
text += QString("%1::\n").arg(map->events_label);
|
text += QString("%1::\n").arg(map->events_label);
|
||||||
text += QString("\tmap_events %1, %2, %3, %4\n")
|
text += QString("\tmap_events %1, %2, %3, %4\n")
|
||||||
.arg(map->object_events_label)
|
.arg(objectEventsLabel)
|
||||||
.arg(map->warps_label)
|
.arg(warpEventsLabel)
|
||||||
.arg(map->coord_events_label)
|
.arg(coordEventsLabel)
|
||||||
.arg(map->bg_events_label);
|
.arg(bgEventsLabel);
|
||||||
|
|
||||||
saveTextFile(path, text);
|
saveTextFile(path, text);
|
||||||
}
|
}
|
||||||
|
@ -1306,13 +1302,13 @@ void Project::readMapEvents(Map *map) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList *labels = getLabelValues(parseAsm(text), map->events_label);
|
QStringList *labels = getLabelValues(parseAsm(text), map->events_label);
|
||||||
map->object_events_label = labels->value(0);
|
QString objectEventsLabel = labels->value(0);
|
||||||
map->warps_label = labels->value(1);
|
QString warpEventsLabel = labels->value(1);
|
||||||
map->coord_events_label = labels->value(2);
|
QString coordEventsLabel = labels->value(2);
|
||||||
map->bg_events_label = labels->value(3);
|
QString bgEventsLabel = labels->value(3);
|
||||||
|
|
||||||
QList<QStringList> *object_events = getLabelMacros(parseAsm(text), map->object_events_label);
|
QList<QStringList> *object_events = getLabelMacros(parseAsm(text), objectEventsLabel);
|
||||||
map->events["object"].clear();
|
map->events["object_event_group"].clear();
|
||||||
for (QStringList command : *object_events) {
|
for (QStringList command : *object_events) {
|
||||||
if (command.value(0) == "object_event") {
|
if (command.value(0) == "object_event") {
|
||||||
Event *object = new Event;
|
Event *object = new Event;
|
||||||
|
@ -1326,18 +1322,18 @@ void Project::readMapEvents(Map *map) {
|
||||||
object->put("behavior", command.value(i++));
|
object->put("behavior", command.value(i++));
|
||||||
object->put("radius_x", command.value(i++).toInt(nullptr, 0));
|
object->put("radius_x", command.value(i++).toInt(nullptr, 0));
|
||||||
object->put("radius_y", command.value(i++).toInt(nullptr, 0));
|
object->put("radius_y", command.value(i++).toInt(nullptr, 0));
|
||||||
object->put("property", command.value(i++));
|
object->put("trainer_see_type", command.value(i++));
|
||||||
object->put("sight_radius", command.value(i++));
|
object->put("sight_radius_tree_id", command.value(i++));
|
||||||
object->put("script_label", command.value(i++));
|
object->put("script_label", command.value(i++));
|
||||||
object->put("event_flag", command.value(i++));
|
object->put("event_flag", command.value(i++));
|
||||||
|
object->put("event_group_type", "object_event_group");
|
||||||
object->put("event_type", "object");
|
object->put("event_type", EventType::Object);
|
||||||
map->events["object"].append(object);
|
map->events["object_event_group"].append(object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QStringList> *warps = getLabelMacros(parseAsm(text), map->warps_label);
|
QList<QStringList> *warps = getLabelMacros(parseAsm(text), warpEventsLabel);
|
||||||
map->events["warp"].clear();
|
map->events["warp_event_group"].clear();
|
||||||
for (QStringList command : *warps) {
|
for (QStringList command : *warps) {
|
||||||
if (command.value(0) == "warp_def") {
|
if (command.value(0) == "warp_def") {
|
||||||
Event *warp = new Event;
|
Event *warp = new Event;
|
||||||
|
@ -1352,17 +1348,17 @@ void Project::readMapEvents(Map *map) {
|
||||||
QString mapConstant = command.value(i++);
|
QString mapConstant = command.value(i++);
|
||||||
if (mapConstantsToMapNames->contains(mapConstant)) {
|
if (mapConstantsToMapNames->contains(mapConstant)) {
|
||||||
warp->put("destination_map_name", mapConstantsToMapNames->value(mapConstant));
|
warp->put("destination_map_name", mapConstantsToMapNames->value(mapConstant));
|
||||||
warp->put("event_type", "warp");
|
warp->put("event_group_type", "warp_event_group");
|
||||||
map->events["warp"].append(warp);
|
warp->put("event_type", EventType::Warp);
|
||||||
|
map->events["warp_event_group"].append(warp);
|
||||||
} else {
|
} else {
|
||||||
qDebug() << QString("Destination map constant '%1' is invalid for warp").arg(mapConstant);
|
qDebug() << QString("Destination map constant '%1' is invalid for warp").arg(mapConstant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QStringList> *coords = getLabelMacros(parseAsm(text), map->coord_events_label);
|
QList<QStringList> *coords = getLabelMacros(parseAsm(text), coordEventsLabel);
|
||||||
map->events["trap"].clear();
|
map->events["coord_event_group"].clear();
|
||||||
map->events["trap_weather"].clear();
|
|
||||||
for (QStringList command : *coords) {
|
for (QStringList command : *coords) {
|
||||||
if (command.value(0) == "coord_event") {
|
if (command.value(0) == "coord_event") {
|
||||||
Event *coord = new Event;
|
Event *coord = new Event;
|
||||||
|
@ -1383,8 +1379,9 @@ void Project::readMapEvents(Map *map) {
|
||||||
//coord_unknown3
|
//coord_unknown3
|
||||||
//coord_unknown4
|
//coord_unknown4
|
||||||
|
|
||||||
coord->put("event_type", "trap");
|
coord->put("event_group_type", "coord_event_group");
|
||||||
map->events["trap"].append(coord);
|
coord->put("event_type", EventType::CoordScript);
|
||||||
|
map->events["coord_event_group"].append(coord);
|
||||||
} else if (command.value(0) == "coord_weather_event") {
|
} else if (command.value(0) == "coord_weather_event") {
|
||||||
Event *coord = new Event;
|
Event *coord = new Event;
|
||||||
coord->put("map_name", map->name);
|
coord->put("map_name", map->name);
|
||||||
|
@ -1393,15 +1390,14 @@ void Project::readMapEvents(Map *map) {
|
||||||
coord->put("y", command.value(i++));
|
coord->put("y", command.value(i++));
|
||||||
coord->put("elevation", command.value(i++));
|
coord->put("elevation", command.value(i++));
|
||||||
coord->put("weather", command.value(i++));
|
coord->put("weather", command.value(i++));
|
||||||
coord->put("event_type", "trap_weather");
|
coord->put("event_group_type", "coord_event_group");
|
||||||
map->events["trap_weather"].append(coord);
|
coord->put("event_type", EventType::CoordWeather);
|
||||||
|
map->events["coord_event_group"].append(coord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QStringList> *bgs = getLabelMacros(parseAsm(text), map->bg_events_label);
|
QList<QStringList> *bgs = getLabelMacros(parseAsm(text), bgEventsLabel);
|
||||||
map->events["sign"].clear();
|
map->events["bg_event_group"].clear();
|
||||||
map->events["event_hidden_item"].clear();
|
|
||||||
map->events["event_secret_base"].clear();
|
|
||||||
for (QStringList command : *bgs) {
|
for (QStringList command : *bgs) {
|
||||||
if (command.value(0) == "bg_event") {
|
if (command.value(0) == "bg_event") {
|
||||||
Event *bg = new Event;
|
Event *bg = new Event;
|
||||||
|
@ -1410,12 +1406,13 @@ void Project::readMapEvents(Map *map) {
|
||||||
bg->put("x", command.value(i++));
|
bg->put("x", command.value(i++));
|
||||||
bg->put("y", command.value(i++));
|
bg->put("y", command.value(i++));
|
||||||
bg->put("elevation", command.value(i++));
|
bg->put("elevation", command.value(i++));
|
||||||
bg->put("type", command.value(i++));
|
bg->put("player_facing_direction", command.value(i++));
|
||||||
i++;
|
i++;
|
||||||
bg->put("script_label", command.value(i++));
|
bg->put("script_label", command.value(i++));
|
||||||
//sign_unknown7
|
//sign_unknown7
|
||||||
bg->put("event_type", "sign");
|
bg->put("event_group_type", "bg_event_group");
|
||||||
map->events["sign"].append(bg);
|
bg->put("event_type", EventType::Sign);
|
||||||
|
map->events["bg_event_group"].append(bg);
|
||||||
} else if (command.value(0) == "bg_hidden_item_event") {
|
} else if (command.value(0) == "bg_hidden_item_event") {
|
||||||
Event *bg = new Event;
|
Event *bg = new Event;
|
||||||
bg->put("map_name", map->name);
|
bg->put("map_name", map->name);
|
||||||
|
@ -1425,8 +1422,9 @@ void Project::readMapEvents(Map *map) {
|
||||||
bg->put("elevation", command.value(i++));
|
bg->put("elevation", command.value(i++));
|
||||||
bg->put("item", command.value(i++));
|
bg->put("item", command.value(i++));
|
||||||
bg->put("flag", command.value(i++));
|
bg->put("flag", command.value(i++));
|
||||||
bg->put("event_type", "event_hidden_item");
|
bg->put("event_group_type", "bg_event_group");
|
||||||
map->events["event_hidden_item"].append(bg);
|
bg->put("event_type", EventType::HiddenItem);
|
||||||
|
map->events["bg_event_group"].append(bg);
|
||||||
} else if (command.value(0) == "bg_secret_base_event") {
|
} else if (command.value(0) == "bg_secret_base_event") {
|
||||||
Event *bg = new Event;
|
Event *bg = new Event;
|
||||||
bg->put("map_name", map->name);
|
bg->put("map_name", map->name);
|
||||||
|
@ -1435,24 +1433,18 @@ void Project::readMapEvents(Map *map) {
|
||||||
bg->put("y", command.value(i++));
|
bg->put("y", command.value(i++));
|
||||||
bg->put("elevation", command.value(i++));
|
bg->put("elevation", command.value(i++));
|
||||||
bg->put("secret_base_map", command.value(i++));
|
bg->put("secret_base_map", command.value(i++));
|
||||||
bg->put("event_type", "event_secret_base");
|
bg->put("event_group_type", "bg_event_group");
|
||||||
map->events["event_secret_base"].append(bg);
|
bg->put("event_type", EventType::SecretBase);
|
||||||
|
map->events["bg_event_group"].append(bg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::setNewMapEvents(Map *map) {
|
void Project::setNewMapEvents(Map *map) {
|
||||||
map->object_events_label = "0x0";
|
map->events["object_event_group"].clear();
|
||||||
map->warps_label = "0x0";
|
map->events["warp_event_group"].clear();
|
||||||
map->coord_events_label = "0x0";
|
map->events["coord_event_group"].clear();
|
||||||
map->bg_events_label = "0x0";
|
map->events["bg_event_group"].clear();
|
||||||
map->events["object"].clear();
|
|
||||||
map->events["warp"].clear();
|
|
||||||
map->events["trap"].clear();
|
|
||||||
map->events["trap_weather"].clear();
|
|
||||||
map->events["sign"].clear();
|
|
||||||
map->events["event_hidden_item"].clear();
|
|
||||||
map->events["event_secret_base"].clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Project::readCArray(QString text, QString label) {
|
QStringList Project::readCArray(QString text, QString label) {
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
QStringList* readLayoutValues(QString layoutName);
|
QStringList* readLayoutValues(QString layoutName);
|
||||||
void readMapLayout(Map*);
|
void readMapLayout(Map*);
|
||||||
void readMapsWithConnections();
|
void readMapsWithConnections();
|
||||||
void getTilesets(Map*);
|
void loadMapTilesets(Map*);
|
||||||
void loadTilesetAssets(Tileset*);
|
void loadTilesetAssets(Tileset*);
|
||||||
|
|
||||||
void saveBlockdata(Map*);
|
void saveBlockdata(Map*);
|
||||||
|
@ -74,6 +74,7 @@ public:
|
||||||
QStringList getSongNames();
|
QStringList getSongNames();
|
||||||
QStringList getLocations();
|
QStringList getLocations();
|
||||||
QStringList getVisibilities();
|
QStringList getVisibilities();
|
||||||
|
QMap<QString, QStringList> getTilesets();
|
||||||
QStringList getWeathers();
|
QStringList getWeathers();
|
||||||
QStringList getMapTypes();
|
QStringList getMapTypes();
|
||||||
QStringList getBattleScenes();
|
QStringList getBattleScenes();
|
||||||
|
|
111
tileset.cpp
111
tileset.cpp
|
@ -1,6 +1,117 @@
|
||||||
#include "tileset.h"
|
#include "tileset.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QImage>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
Tileset::Tileset()
|
Tileset::Tileset()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Metatile::Metatile()
|
||||||
|
{
|
||||||
|
tiles = new QList<Tile>;
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage Metatile::getMetatileImage(int tile, Tileset *primaryTileset, Tileset *secondaryTileset) {
|
||||||
|
QImage metatile_image(16, 16, QImage::Format_RGBA8888);
|
||||||
|
|
||||||
|
Metatile* metatile = Metatile::getMetatile(tile, primaryTileset, secondaryTileset);
|
||||||
|
if (!metatile || !metatile->tiles) {
|
||||||
|
metatile_image.fill(0xffffffff);
|
||||||
|
return metatile_image;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tileset* blockTileset = Metatile::getBlockTileset(tile, primaryTileset, secondaryTileset);
|
||||||
|
if (!blockTileset) {
|
||||||
|
metatile_image.fill(0xffffffff);
|
||||||
|
return metatile_image;
|
||||||
|
}
|
||||||
|
QList<QList<QRgb>> palettes = Metatile::getBlockPalettes(primaryTileset, secondaryTileset);
|
||||||
|
|
||||||
|
QPainter metatile_painter(&metatile_image);
|
||||||
|
for (int layer = 0; layer < 2; layer++)
|
||||||
|
for (int y = 0; y < 2; y++)
|
||||||
|
for (int x = 0; x < 2; x++) {
|
||||||
|
Tile tile_ = metatile->tiles->value((y * 2) + x + (layer * 4));
|
||||||
|
QImage tile_image = Metatile::getMetatileTile(tile_.tile, primaryTileset, secondaryTileset);
|
||||||
|
if (tile_image.isNull()) {
|
||||||
|
// Some metatiles specify tiles that are outside the valid range.
|
||||||
|
// These are treated as completely transparent, so they can be skipped without
|
||||||
|
// being drawn.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Colorize the metatile tiles with its palette.
|
||||||
|
if (tile_.palette < palettes.length()) {
|
||||||
|
QList<QRgb> palette = palettes.value(tile_.palette);
|
||||||
|
for (int j = 0; j < palette.length(); j++) {
|
||||||
|
tile_image.setColor(j, palette.value(j));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qDebug() << "Tile is referring to invalid palette number: " << tile_.palette;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The top layer of the metatile has its last color displayed at transparent.
|
||||||
|
if (layer > 0) {
|
||||||
|
QColor color(tile_image.color(15));
|
||||||
|
color.setAlpha(0);
|
||||||
|
tile_image.setColor(15, color.rgba());
|
||||||
|
}
|
||||||
|
|
||||||
|
QPoint origin = QPoint(x*8, y*8);
|
||||||
|
metatile_painter.drawImage(origin, tile_image.mirrored(tile_.xflip == 1, tile_.yflip == 1));
|
||||||
|
}
|
||||||
|
metatile_painter.end();
|
||||||
|
|
||||||
|
return metatile_image;
|
||||||
|
}
|
||||||
|
|
||||||
|
Metatile* Metatile::getMetatile(int index, Tileset *primaryTileset, Tileset *secondaryTileset) {
|
||||||
|
Tileset *tileset = Metatile::getBlockTileset(index, primaryTileset, secondaryTileset);
|
||||||
|
int local_index = Metatile::getBlockIndex(index);
|
||||||
|
if (!tileset || !tileset->metatiles) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
Metatile *metatile = tileset->metatiles->value(local_index, NULL);
|
||||||
|
return metatile;
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage Metatile::getMetatileTile(int tile, Tileset *primaryTileset, Tileset *secondaryTileset) {
|
||||||
|
Tileset *tileset = Metatile::getBlockTileset(tile, primaryTileset, secondaryTileset);
|
||||||
|
int local_index = Metatile::getBlockIndex(tile);
|
||||||
|
if (!tileset || !tileset->tiles) {
|
||||||
|
return QImage();
|
||||||
|
}
|
||||||
|
return tileset->tiles->value(local_index, QImage());
|
||||||
|
}
|
||||||
|
|
||||||
|
Tileset* Metatile::getBlockTileset(int metatile_index, Tileset *primaryTileset, Tileset *secondaryTileset) {
|
||||||
|
int primary_size = 0x200;
|
||||||
|
if (metatile_index < primary_size) {
|
||||||
|
return primaryTileset;
|
||||||
|
} else {
|
||||||
|
return secondaryTileset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int Metatile::getBlockIndex(int index) {
|
||||||
|
int primary_size = 0x200;
|
||||||
|
if (index < primary_size) {
|
||||||
|
return index;
|
||||||
|
} else {
|
||||||
|
return index - primary_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QList<QRgb>> Metatile::getBlockPalettes(Tileset *primaryTileset, Tileset *secondaryTileset) {
|
||||||
|
QList<QList<QRgb>> palettes;
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
palettes.append(primaryTileset->palettes->at(i));
|
||||||
|
}
|
||||||
|
for (int i = 6; i < 12; i++) {
|
||||||
|
palettes.append(secondaryTileset->palettes->at(i));
|
||||||
|
}
|
||||||
|
return palettes;
|
||||||
|
}
|
||||||
|
|
20
tileset.h
20
tileset.h
|
@ -1,9 +1,11 @@
|
||||||
#ifndef TILESET_H
|
#ifndef TILESET_H
|
||||||
#define TILESET_H
|
#define TILESET_H
|
||||||
|
|
||||||
#include "metatile.h"
|
#include "tile.h"
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
|
||||||
|
class Metatile;
|
||||||
|
|
||||||
class Tileset
|
class Tileset
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -24,4 +26,20 @@ public:
|
||||||
QList<QList<QRgb>> *palettes = NULL;
|
QList<QList<QRgb>> *palettes = NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Metatile
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Metatile();
|
||||||
|
public:
|
||||||
|
QList<Tile> *tiles = NULL;
|
||||||
|
int attr;
|
||||||
|
|
||||||
|
static QImage getMetatileImage(int, Tileset*, Tileset*);
|
||||||
|
static Metatile* getMetatile(int, Tileset*, Tileset*);
|
||||||
|
static QImage getMetatileTile(int, Tileset*, Tileset*);
|
||||||
|
static Tileset* getBlockTileset(int, Tileset*, Tileset*);
|
||||||
|
static int getBlockIndex(int);
|
||||||
|
static QList<QList<QRgb>> getBlockPalettes(Tileset*, Tileset*);
|
||||||
|
};
|
||||||
|
|
||||||
#endif // TILESET_H
|
#endif // TILESET_H
|
||||||
|
|
Loading…
Reference in a new issue