Merge pull request #2 from yenatch/master

syncing with source
This commit is contained in:
Garak 2018-07-13 21:48:50 -04:00 committed by GitHub
commit 8902102b2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 948 additions and 441 deletions

View file

@ -5,6 +5,8 @@
#include <QMouseEvent> #include <QMouseEvent>
#include <math.h> #include <math.h>
bool selectingEvent = false;
Editor::Editor(Ui::MainWindow* ui) Editor::Editor(Ui::MainWindow* ui)
{ {
this->ui = ui; this->ui = ui;
@ -27,13 +29,15 @@ void Editor::save() {
void Editor::undo() { void Editor::undo() {
if (current_view) { if (current_view) {
((MapPixmapItem*)current_view)->undo(); map->undo();
map_item->draw();
} }
} }
void Editor::redo() { void Editor::redo() {
if (current_view) { if (current_view) {
((MapPixmapItem*)current_view)->redo(); map->redo();
map_item->draw();
} }
} }
@ -59,6 +63,7 @@ void Editor::setEditingMap() {
void Editor::setEditingCollision() { void Editor::setEditingCollision() {
current_view = collision_item; current_view = collision_item;
if (collision_item) { if (collision_item) {
displayMapConnections();
collision_item->draw(); collision_item->draw();
collision_item->setVisible(true); collision_item->setVisible(true);
setConnectionsVisibility(true); setConnectionsVisibility(true);
@ -319,8 +324,8 @@ void Editor::setMap(QString map_name) {
} }
if (project) { if (project) {
map = project->loadMap(map_name); map = project->loadMap(map_name);
displayMap();
selected_events->clear(); selected_events->clear();
displayMap();
updateSelectedEvents(); updateSelectedEvents();
} }
} }
@ -467,6 +472,8 @@ void Editor::displayMapEvents() {
delete events_group; delete events_group;
} }
selected_events->clear();
events_group = new EventGroup; events_group = new EventGroup;
scene->addItem(events_group); scene->addItem(events_group);
@ -482,8 +489,7 @@ void Editor::displayMapEvents() {
} }
DraggablePixmapItem *Editor::addMapEvent(Event *event) { DraggablePixmapItem *Editor::addMapEvent(Event *event) {
DraggablePixmapItem *object = new DraggablePixmapItem(event); DraggablePixmapItem *object = new DraggablePixmapItem(event, this);
object->editor = this;
events_group->addToGroup(object); events_group->addToGroup(object);
return object; return object;
} }
@ -806,16 +812,22 @@ void Editor::updateDiveEmergeMap(QString mapName, QString direction) {
void Editor::updatePrimaryTileset(QString tilesetLabel) void Editor::updatePrimaryTileset(QString tilesetLabel)
{ {
map->layout->tileset_primary_label = tilesetLabel; if (map->layout->tileset_primary_label != tilesetLabel)
map->layout->tileset_primary = project->getTileset(tilesetLabel); {
emit tilesetChanged(map->name); map->layout->tileset_primary_label = tilesetLabel;
map->layout->tileset_primary = project->getTileset(tilesetLabel);
emit tilesetChanged(map->name);
}
} }
void Editor::updateSecondaryTileset(QString tilesetLabel) void Editor::updateSecondaryTileset(QString tilesetLabel)
{ {
map->layout->tileset_secondary_label = tilesetLabel; if (map->layout->tileset_secondary_label != tilesetLabel)
map->layout->tileset_secondary = project->getTileset(tilesetLabel); {
emit tilesetChanged(map->name); 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) {
@ -880,9 +892,6 @@ void MetatilesPixmapItem::updateSelection(QPointF pos, Qt::MouseButton button) {
map->paint_tile_index = baseTileY * 8 + baseTileX; map->paint_tile_index = baseTileY * 8 + baseTileX;
map->paint_tile_width = abs(map->paint_metatile_initial_x - x) + 1; map->paint_tile_width = abs(map->paint_metatile_initial_x - x) + 1;
map->paint_tile_height = abs(map->paint_metatile_initial_y - y) + 1; map->paint_tile_height = abs(map->paint_metatile_initial_y - y) + 1;
map->smart_paths_enabled = button == Qt::RightButton
&& map->paint_tile_width == 3
&& map->paint_tile_height == 3;
emit map->paintTileChanged(map); emit map->paintTileChanged(map);
} }
} }
@ -1030,7 +1039,7 @@ void MapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
int x = (int)(pos.x()) / 16; int x = (int)(pos.x()) / 16;
int y = (int)(pos.y()) / 16; int y = (int)(pos.y()) / 16;
if (map->smart_paths_enabled) { if (map->smart_paths_enabled && map->paint_tile_width == 3 && map->paint_tile_height == 3) {
paintSmartPath(x, y); paintSmartPath(x, y);
} else { } else {
paintNormal(x, y); paintNormal(x, y);
@ -1158,11 +1167,163 @@ void MapPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) {
QPointF pos = event->pos(); QPointF pos = event->pos();
int x = (int)(pos.x()) / 16; int x = (int)(pos.x()) / 16;
int y = (int)(pos.y()) / 16; int y = (int)(pos.y()) / 16;
map->floodFill(x, y, map->getSelectedBlockIndex(map->paint_tile_index)); Block *block = map->getBlock(x, y);
int tile = map->getSelectedBlockIndex(map->paint_tile_index);
if (block && block->tile != tile) {
if (map->smart_paths_enabled && map->paint_tile_width == 3 && map->paint_tile_height == 3)
this->_floodFillSmartPath(x, y);
else
this->_floodFill(x, y);
}
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
map->commit();
}
draw(); draw();
} }
} }
void MapPixmapItem::_floodFill(int initialX, int initialY) {
QList<QPoint> todo;
todo.append(QPoint(initialX, initialY));
while (todo.length()) {
QPoint point = todo.takeAt(0);
int x = point.x();
int y = point.y();
Block *block = map->getBlock(x, y);
if (block == NULL) {
continue;
}
int xDiff = x - initialX;
int yDiff = y - initialY;
int i = xDiff % map->paint_tile_width;
int j = yDiff % map->paint_tile_height;
if (i < 0) i = map->paint_tile_width + i;
if (j < 0) j = map->paint_tile_height + j;
int tile = map->getSelectedBlockIndex(map->paint_tile_index + i + (j * 8));
uint old_tile = block->tile;
if (old_tile == tile) {
continue;
}
block->tile = tile;
map->_setBlock(x, y, *block);
if ((block = map->getBlock(x + 1, y)) && block->tile == old_tile) {
todo.append(QPoint(x + 1, y));
}
if ((block = map->getBlock(x - 1, y)) && block->tile == old_tile) {
todo.append(QPoint(x - 1, y));
}
if ((block = map->getBlock(x, y + 1)) && block->tile == old_tile) {
todo.append(QPoint(x, y + 1));
}
if ((block = map->getBlock(x, y - 1)) && block->tile == old_tile) {
todo.append(QPoint(x, y - 1));
}
}
}
void MapPixmapItem::_floodFillSmartPath(int initialX, int initialY) {
// Smart path should never be enabled without a 3x3 block selection.
if (map->paint_tile_width != 3 || map->paint_tile_height != 3) return;
// Shift to the middle tile of the smart path selection.
int openTile = map->paint_tile_index + 8 + 1;
// Flood fill the region with the open tile.
QList<QPoint> todo;
todo.append(QPoint(initialX, initialY));
while (todo.length()) {
QPoint point = todo.takeAt(0);
int x = point.x();
int y = point.y();
Block *block = map->getBlock(x, y);
if (block == NULL) {
continue;
}
int tile = map->getSelectedBlockIndex(openTile);
uint old_tile = block->tile;
if (old_tile == tile) {
continue;
}
block->tile = tile;
map->_setBlock(x, y, *block);
if ((block = map->getBlock(x + 1, y)) && block->tile == old_tile) {
todo.append(QPoint(x + 1, y));
}
if ((block = map->getBlock(x - 1, y)) && block->tile == old_tile) {
todo.append(QPoint(x - 1, y));
}
if ((block = map->getBlock(x, y + 1)) && block->tile == old_tile) {
todo.append(QPoint(x, y + 1));
}
if ((block = map->getBlock(x, y - 1)) && block->tile == old_tile) {
todo.append(QPoint(x, y - 1));
}
}
// Go back and resolve the flood-filled edge tiles.
// Mark tiles as visited while we go.
bool visited[map->getWidth() * map->getHeight()];
for (int i = 0; i < sizeof visited; i++)
visited[i] = false;
todo.append(QPoint(initialX, initialY));
while (todo.length()) {
QPoint point = todo.takeAt(0);
int x = point.x();
int y = point.y();
visited[x + y * map->getWidth()] = true;
Block *block = map->getBlock(x, y);
if (block == NULL) {
continue;
}
int id = 0;
Block *top = map->getBlock(x, y - 1);
Block *right = map->getBlock(x + 1, y);
Block *bottom = map->getBlock(x, y + 1);
Block *left = map->getBlock(x - 1, y);
// Get marching squares value, to determine which tile to use.
if (top && IS_SMART_PATH_TILE(top))
id += 1;
if (right && IS_SMART_PATH_TILE(right))
id += 2;
if (bottom && IS_SMART_PATH_TILE(bottom))
id += 4;
if (left && IS_SMART_PATH_TILE(left))
id += 8;
block->tile = map->getSelectedBlockIndex(map->paint_tile_index + smartPathTable[id]);
map->_setBlock(x, y, *block);
// Visit neighbors if they are smart-path tiles, and don't revisit any.
if (!visited[x + 1 + y * map->getWidth()] && (block = map->getBlock(x + 1, y)) && IS_SMART_PATH_TILE(block)) {
todo.append(QPoint(x + 1, y));
visited[x + 1 + y * map->getWidth()] = true;
}
if (!visited[x - 1 + y * map->getWidth()] && (block = map->getBlock(x - 1, y)) && IS_SMART_PATH_TILE(block)) {
todo.append(QPoint(x - 1, y));
visited[x - 1 + y * map->getWidth()] = true;
}
if (!visited[x + (y + 1) * map->getWidth()] && (block = map->getBlock(x, y + 1)) && IS_SMART_PATH_TILE(block)) {
todo.append(QPoint(x, y + 1));
visited[x + (y + 1) * map->getWidth()] = true;
}
if (!visited[x + (y - 1) * map->getWidth()] && (block = map->getBlock(x, y - 1)) && IS_SMART_PATH_TILE(block)) {
todo.append(QPoint(x, y - 1));
visited[x + (y - 1) * map->getWidth()] = true;
}
}
}
void MapPixmapItem::pick(QGraphicsSceneMouseEvent *event) { void MapPixmapItem::pick(QGraphicsSceneMouseEvent *event) {
QPointF pos = event->pos(); QPointF pos = event->pos();
int x = (int)(pos.x()) / 16; int x = (int)(pos.x()) / 16;
@ -1216,20 +1377,6 @@ void MapPixmapItem::draw(bool ignoreCache) {
} }
} }
void MapPixmapItem::undo() {
if (map) {
map->undo();
draw();
}
}
void MapPixmapItem::redo() {
if (map) {
map->redo();
draw();
}
}
void MapPixmapItem::updateCurHoveredTile(QPointF pos) { void MapPixmapItem::updateCurHoveredTile(QPointF pos) {
int x = ((int)pos.x()) / 16; int x = ((int)pos.x()) / 16;
int y = ((int)pos.y()) / 16; int y = ((int)pos.y()) / 16;
@ -1334,9 +1481,11 @@ void CollisionPixmapItem::pick(QGraphicsSceneMouseEvent *event) {
void DraggablePixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *mouse) { void DraggablePixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *mouse) {
active = true; active = true;
clicking = true;
last_x = (mouse->pos().x() + this->pos().x()) / 16; last_x = (mouse->pos().x() + this->pos().x()) / 16;
last_y = (mouse->pos().y() + this->pos().y()) / 16; last_y = (mouse->pos().y() + this->pos().y()) / 16;
this->editor->selectMapEvent(this, mouse->modifiers() & Qt::ControlModifier);
this->editor->updateSelectedEvents();
selectingEvent = true;
//qDebug() << QString("(%1, %2)").arg(event->get("x")).arg(event->get("y")); //qDebug() << QString("(%1, %2)").arg(event->get("x")).arg(event->get("y"));
} }
@ -1352,7 +1501,6 @@ void DraggablePixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *mouse) {
int x = (mouse->pos().x() + this->pos().x()) / 16; int x = (mouse->pos().x() + this->pos().x()) / 16;
int y = (mouse->pos().y() + this->pos().y()) / 16; int y = (mouse->pos().y() + this->pos().y()) / 16;
if (x != last_x || y != last_y) { if (x != last_x || y != last_y) {
clicking = false;
if (editor->selected_events->contains(this)) { if (editor->selected_events->contains(this)) {
for (DraggablePixmapItem *item : *editor->selected_events) { for (DraggablePixmapItem *item : *editor->selected_events) {
item->move(x - last_x, y - last_y); item->move(x - last_x, y - last_y);
@ -1368,13 +1516,15 @@ void DraggablePixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *mouse) {
} }
void DraggablePixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouse) { void DraggablePixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouse) {
if (clicking) {
this->editor->selectMapEvent(this, mouse->modifiers() & Qt::ControlModifier);
this->editor->updateSelectedEvents();
}
active = false; active = false;
} }
void DraggablePixmapItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouse) {
if (this->event->get("event_type") == EventType::Warp) {
emit editor->warpEventDoubleClicked(this->event->get("destination_map_name"), this->event->get("destination_warp"));
}
}
QList<DraggablePixmapItem *> *Editor::getObjects() { QList<DraggablePixmapItem *> *Editor::getObjects() {
QList<DraggablePixmapItem *> *list = new QList<DraggablePixmapItem *>; QList<DraggablePixmapItem *> *list = new QList<DraggablePixmapItem *>;
for (Event *event : map->getAllEvents()) { for (Event *event : map->getAllEvents()) {
@ -1395,7 +1545,7 @@ void Editor::redrawObject(DraggablePixmapItem *item) {
if (selected_events && selected_events->contains(item)) { if (selected_events && selected_events->contains(item)) {
QImage image = item->pixmap().toImage(); QImage image = item->pixmap().toImage();
QPainter painter(&image); QPainter painter(&image);
painter.setPen(QColor(250, 100, 25)); painter.setPen(QColor(250, 0, 255));
painter.drawRect(0, 0, image.width() - 1, image.height() - 1); painter.drawRect(0, 0, image.width() - 1, image.height() - 1);
painter.end(); painter.end();
item->setPixmap(QPixmap::fromImage(image)); item->setPixmap(QPixmap::fromImage(image));
@ -1452,39 +1602,19 @@ void Editor::deleteEvent(Event *event) {
//updateSelectedObjects(); //updateSelectedObjects();
} }
// dunno how to detect bubbling. QMouseEvent::isAccepted seems to always be true // It doesn't seem to be possible to prevent the mousePress event
// check if selected_events changed instead. this has the side effect of deselecting // from triggering both event's DraggablePixmapItem and the background mousePress.
// when you click on a selected event, since selected_events doesn't change. // Since the DraggablePixmapItem's event fires first, we can set a temp
// variable "selectingEvent" so that we can detect whether or not the user
QList<DraggablePixmapItem *> selected_events_test; // is clicking on the background instead of an event.
bool clicking = false;
void Editor::objectsView_onMousePress(QMouseEvent *event) { void Editor::objectsView_onMousePress(QMouseEvent *event) {
clicking = true; bool multiSelect = event->modifiers() & Qt::ControlModifier;
selected_events_test = *selected_events; if (!selectingEvent && !multiSelect && selected_events->length() > 1) {
} DraggablePixmapItem *first = selected_events->first();
selected_events->clear();
void Editor::objectsView_onMouseMove(QMouseEvent *event) { selected_events->append(first);
clicking = false; updateSelectedEvents();
}
void Editor::objectsView_onMouseRelease(QMouseEvent *event) {
if (clicking) {
if (selected_events_test.length()) {
if (selected_events_test.length() == selected_events->length()) {
bool deselect = true;
for (int i = 0; i < selected_events_test.length(); i++) {
if (selected_events_test.at(i) != selected_events->at(i)) {
deselect = false;
break;
}
}
if (deselect) {
selected_events->clear();
updateSelectedEvents();
}
}
}
clicking = false;
} }
selectingEvent = false;
} }

View file

@ -138,6 +138,7 @@ signals:
void selectedObjectsChanged(); void selectedObjectsChanged();
void loadMapRequested(QString, QString); void loadMapRequested(QString, QString);
void tilesetChanged(QString); void tilesetChanged(QString);
void warpEventDoubleClicked(QString mapName, QString warpNum);
}; };
@ -150,13 +151,12 @@ public:
Editor *editor = NULL; Editor *editor = NULL;
Event *event = NULL; Event *event = NULL;
QGraphicsItemAnimation *pos_anim = NULL; QGraphicsItemAnimation *pos_anim = NULL;
DraggablePixmapItem(Event *event_) : QGraphicsPixmapItem(event_->pixmap) { DraggablePixmapItem(Event *event_, Editor *editor_) : QGraphicsPixmapItem(event_->pixmap) {
event = event_; event = event_;
editor = editor_;
updatePosition(); updatePosition();
} }
bool active; bool active;
bool right_click;
bool clicking;
int last_x; int last_x;
int last_y; int last_y;
void updatePosition() { void updatePosition() {
@ -229,6 +229,7 @@ protected:
void mousePressEvent(QGraphicsSceneMouseEvent*); void mousePressEvent(QGraphicsSceneMouseEvent*);
void mouseMoveEvent(QGraphicsSceneMouseEvent*); void mouseMoveEvent(QGraphicsSceneMouseEvent*);
void mouseReleaseEvent(QGraphicsSceneMouseEvent*); void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
}; };
class EventGroup : public QGraphicsItemGroup { class EventGroup : public QGraphicsItemGroup {
@ -250,10 +251,10 @@ public:
QList<QPoint> selection; QList<QPoint> selection;
virtual void paint(QGraphicsSceneMouseEvent*); virtual void paint(QGraphicsSceneMouseEvent*);
virtual void floodFill(QGraphicsSceneMouseEvent*); virtual void floodFill(QGraphicsSceneMouseEvent*);
void _floodFill(int x, int y);
void _floodFillSmartPath(int initialX, int initialY);
virtual void pick(QGraphicsSceneMouseEvent*); virtual void pick(QGraphicsSceneMouseEvent*);
virtual void select(QGraphicsSceneMouseEvent*); virtual void select(QGraphicsSceneMouseEvent*);
virtual void undo();
virtual void redo();
virtual void draw(bool ignoreCache = false); virtual void draw(bool ignoreCache = false);
private: private:

View file

@ -43,13 +43,13 @@ Event* Event::createNewObjectEvent()
event->put("event_group_type", "object_event_group"); event->put("event_group_type", "object_event_group");
event->put("event_type", EventType::Object); event->put("event_type", EventType::Object);
event->put("sprite", "EVENT_OBJ_GFX_BOY_1"); event->put("sprite", "EVENT_OBJ_GFX_BOY_1");
event->put("behavior", "1"); event->put("movement_type", "MOVEMENT_TYPE_LOOK_AROUND");
event->put("radius_x", 0); event->put("radius_x", 0);
event->put("radius_y", 0); event->put("radius_y", 0);
event->put("script_label", "NULL"); event->put("script_label", "NULL");
event->put("event_flag", "0"); event->put("event_flag", "0");
event->put("replacement", "0"); event->put("replacement", "0");
event->put("trainer_see_type", "0"); event->put("is_trainer", "FALSE");
event->put("sight_radius_tree_id", 0); event->put("sight_radius_tree_id", 0);
return event; return event;
} }
@ -89,7 +89,7 @@ Event* Event::createNewSignEvent()
Event *event = new Event; Event *event = new Event;
event->put("event_group_type", "bg_event_group"); event->put("event_group_type", "bg_event_group");
event->put("event_type", EventType::Sign); event->put("event_type", EventType::Sign);
event->put("player_facing_direction", "0"); event->put("player_facing_direction", "BG_EVENT_PLAYER_FACING_ANY");
event->put("script_label", "NULL"); event->put("script_label", "NULL");
return event; return event;
} }
@ -109,7 +109,7 @@ Event* Event::createNewSecretBaseEvent()
Event *event = new Event; Event *event = new Event;
event->put("event_group_type", "bg_event_group"); event->put("event_group_type", "bg_event_group");
event->put("event_type", EventType::SecretBase); event->put("event_type", EventType::SecretBase);
event->put("secret_base_map", "SECRET_BASE_RED_CAVE2_1"); event->put("secret_base_id", "SECRET_BASE_RED_CAVE2_1");
return event; return event;
} }
@ -127,10 +127,10 @@ QString Event::buildObjectEventMacro(int item_index)
text += QString(", %1").arg(x); text += QString(", %1").arg(x);
text += QString(", %1").arg(y); text += QString(", %1").arg(y);
text += QString(", %1").arg(this->get("elevation")); text += QString(", %1").arg(this->get("elevation"));
text += QString(", %1").arg(this->get("behavior")); text += QString(", %1").arg(this->get("movement_type"));
text += QString(", %1").arg(radius_x); text += QString(", %1").arg(radius_x);
text += QString(", %1").arg(radius_y); text += QString(", %1").arg(radius_y);
text += QString(", %1").arg(this->get("trainer_see_type")); text += QString(", %1").arg(this->get("is_trainer"));
text += QString(", %1").arg(this->get("sight_radius_tree_id")); text += QString(", %1").arg(this->get("sight_radius_tree_id"));
text += QString(", %1").arg(this->get("script_label")); text += QString(", %1").arg(this->get("script_label"));
text += QString(", %1").arg(this->get("event_flag")); text += QString(", %1").arg(this->get("event_flag"));
@ -156,10 +156,8 @@ QString Event::buildCoordScriptEventMacro()
text += QString("\tcoord_event %1").arg(this->get("x")); text += QString("\tcoord_event %1").arg(this->get("x"));
text += QString(", %1").arg(this->get("y")); text += QString(", %1").arg(this->get("y"));
text += QString(", %1").arg(this->get("elevation")); 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"));
text += QString(", %1").arg(this->get("script_var_value")); text += QString(", %1").arg(this->get("script_var_value"));
text += QString(", 0");
text += QString(", %1").arg(this->get("script_label")); text += QString(", %1").arg(this->get("script_label"));
text += "\n"; text += "\n";
return text; return text;
@ -183,7 +181,6 @@ QString Event::buildSignEventMacro()
text += QString(", %1").arg(this->get("y")); text += QString(", %1").arg(this->get("y"));
text += QString(", %1").arg(this->get("elevation")); text += QString(", %1").arg(this->get("elevation"));
text += QString(", %1").arg(this->get("player_facing_direction")); text += QString(", %1").arg(this->get("player_facing_direction"));
text += QString(", 0");
text += QString(", %1").arg(this->get("script_label")); text += QString(", %1").arg(this->get("script_label"));
text += "\n"; text += "\n";
return text; return text;
@ -207,7 +204,7 @@ QString Event::buildSecretBaseEventMacro()
text += QString("\tbg_secret_base_event %1").arg(this->get("x")); text += QString("\tbg_secret_base_event %1").arg(this->get("x"));
text += QString(", %1").arg(this->get("y")); text += QString(", %1").arg(this->get("y"));
text += QString(", %1").arg(this->get("elevation")); text += QString(", %1").arg(this->get("elevation"));
text += QString(", %1").arg(this->get("secret_base_map")); text += QString(", %1").arg(this->get("secret_base_id"));
text += "\n"; text += "\n";
return text; return text;
} }

View file

@ -10,14 +10,8 @@ void GraphicsView::mousePressEvent(QMouseEvent *event) {
void GraphicsView::mouseMoveEvent(QMouseEvent *event) { void GraphicsView::mouseMoveEvent(QMouseEvent *event) {
QGraphicsView::mouseMoveEvent(event); QGraphicsView::mouseMoveEvent(event);
if (editor) {
editor->objectsView_onMouseMove(event);
}
} }
void GraphicsView::mouseReleaseEvent(QMouseEvent *event) { void GraphicsView::mouseReleaseEvent(QMouseEvent *event) {
QGraphicsView::mouseReleaseEvent(event); QGraphicsView::mouseReleaseEvent(event);
if (editor) {
editor->objectsView_onMouseRelease(event);
}
} }

View file

@ -15,6 +15,8 @@
#include <QSpacerItem> #include <QSpacerItem>
#include <QFont> #include <QFont>
#include <QScrollBar> #include <QScrollBar>
#include <QMessageBox>
#include <QDialogButtonBox>
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
@ -35,6 +37,7 @@ MainWindow::MainWindow(QWidget *parent) :
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))); connect(editor, SIGNAL(tilesetChanged(QString)), this, SLOT(onTilesetChanged(QString)));
connect(editor, SIGNAL(warpEventDoubleClicked(QString,QString)), this, SLOT(openWarpMap(QString,QString)));
on_toolButton_Paint_clicked(); on_toolButton_Paint_clicked();
@ -147,7 +150,22 @@ void MainWindow::setMap(QString map_name) {
return; return;
} }
editor->setMap(map_name); editor->setMap(map_name);
redrawMapScene();
displayMapProperties();
setWindowTitle(map_name + " - " + editor->project->getProjectTitle() + " - pretmap");
connect(editor->map, SIGNAL(mapChanged(Map*)), this, SLOT(onMapChanged(Map *)));
connect(editor->map, SIGNAL(mapNeedsRedrawing(Map*)), this, SLOT(onMapNeedsRedrawing(Map *)));
connect(editor->map, SIGNAL(statusBarMessage(QString)), this, SLOT(setStatusBarMessage(QString)));
setRecentMap(map_name);
updateMapList();
}
void MainWindow::redrawMapScene()
{
editor->displayMap();
on_tabWidget_currentChanged(ui->tabWidget->currentIndex()); on_tabWidget_currentChanged(ui->tabWidget->currentIndex());
ui->graphicsView_Map->setScene(editor->scene); ui->graphicsView_Map->setScene(editor->scene);
@ -177,16 +195,39 @@ void MainWindow::setMap(QString map_name) {
ui->graphicsView_Elevation->setScene(editor->scene_elevation_metatiles); ui->graphicsView_Elevation->setScene(editor->scene_elevation_metatiles);
//ui->graphicsView_Elevation->setSceneRect(editor->scene_elevation_metatiles->sceneRect()); //ui->graphicsView_Elevation->setSceneRect(editor->scene_elevation_metatiles->sceneRect());
ui->graphicsView_Elevation->setFixedSize(editor->elevation_metatiles_item->pixmap().width() + 2, editor->elevation_metatiles_item->pixmap().height() + 2); ui->graphicsView_Elevation->setFixedSize(editor->elevation_metatiles_item->pixmap().width() + 2, editor->elevation_metatiles_item->pixmap().height() + 2);
}
displayMapProperties(); void MainWindow::openWarpMap(QString map_name, QString warp_num) {
// Ensure valid destination map name.
if (!editor->project->mapNames->contains(map_name)) {
qDebug() << QString("Invalid warp destination map name '%1'").arg(map_name);
return;
}
setWindowTitle(map_name + " - " + editor->project->getProjectTitle() + " - pretmap"); // Ensure valid destination warp number.
bool ok;
int warpNum = warp_num.toInt(&ok, 0);
if (!ok) {
qDebug() << QString("Invalid warp number '%1' for destination map '%2'").arg(warp_num).arg(map_name);
return;
}
connect(editor->map, SIGNAL(mapChanged(Map*)), this, SLOT(onMapChanged(Map *))); // Open the destination map, and select the target warp event.
connect(editor->map, SIGNAL(statusBarMessage(QString)), this, SLOT(setStatusBarMessage(QString))); setMap(map_name);
QList<Event*> warp_events = editor->map->events["warp_event_group"];
if (warp_events.length() > warpNum) {
Event *warp_event = warp_events.at(warpNum);
QList<DraggablePixmapItem *> *all_events = editor->getObjects();
for (DraggablePixmapItem *item : *all_events) {
if (item->event == warp_event) {
editor->selected_events->clear();
editor->selected_events->append(item);
editor->updateSelectedEvents();
}
}
setRecentMap(map_name); delete all_events;
updateMapList(); }
} }
void MainWindow::setRecentMap(QString map_name) { void MainWindow::setRecentMap(QString map_name) {
@ -203,7 +244,7 @@ void MainWindow::setRecentMap(QString map_name) {
void MainWindow::displayMapProperties() { void MainWindow::displayMapProperties() {
ui->comboBox_Song->clear(); ui->comboBox_Song->clear();
ui->comboBox_Location->clear(); ui->comboBox_Location->clear();
ui->comboBox_Visibility->clear(); ui->checkBox_Visibility->setChecked(false);
ui->comboBox_Weather->clear(); ui->comboBox_Weather->clear();
ui->comboBox_Type->clear(); ui->comboBox_Type->clear();
ui->comboBox_BattleScene->clear(); ui->comboBox_BattleScene->clear();
@ -222,7 +263,7 @@ void MainWindow::displayMapProperties() {
ui->comboBox_Song->addItems(songs); ui->comboBox_Song->addItems(songs);
ui->comboBox_Song->setCurrentText(map->song); ui->comboBox_Song->setCurrentText(map->song);
ui->comboBox_Location->addItems(project->getLocations()); ui->comboBox_Location->addItems(*project->regionMapSections);
ui->comboBox_Location->setCurrentText(map->location); ui->comboBox_Location->setCurrentText(map->location);
QMap<QString, QStringList> tilesets = project->getTilesets(); QMap<QString, QStringList> tilesets = project->getTilesets();
@ -231,16 +272,15 @@ void MainWindow::displayMapProperties() {
ui->comboBox_SecondaryTileset->addItems(tilesets.value("secondary")); ui->comboBox_SecondaryTileset->addItems(tilesets.value("secondary"));
ui->comboBox_SecondaryTileset->setCurrentText(map->layout->tileset_secondary_label); ui->comboBox_SecondaryTileset->setCurrentText(map->layout->tileset_secondary_label);
ui->comboBox_Visibility->addItems(project->getVisibilities()); ui->checkBox_Visibility->setChecked(map->requiresFlash.toInt() > 0 || map->requiresFlash == "TRUE");
ui->comboBox_Visibility->setCurrentText(map->visibility);
ui->comboBox_Weather->addItems(project->getWeathers()); ui->comboBox_Weather->addItems(*project->weatherNames);
ui->comboBox_Weather->setCurrentText(map->weather); ui->comboBox_Weather->setCurrentText(map->weather);
ui->comboBox_Type->addItems(project->getMapTypes()); ui->comboBox_Type->addItems(*project->mapTypes);
ui->comboBox_Type->setCurrentText(map->type); ui->comboBox_Type->setCurrentText(map->type);
ui->comboBox_BattleScene->addItems(project->getBattleScenes()); ui->comboBox_BattleScene->addItems(*project->mapBattleScenes);
ui->comboBox_BattleScene->setCurrentText(map->battle_scene); ui->comboBox_BattleScene->setCurrentText(map->battle_scene);
ui->checkBox_ShowLocation->setChecked(map->show_location.toInt() > 0 || map->show_location == "TRUE"); ui->checkBox_ShowLocation->setChecked(map->show_location.toInt() > 0 || map->show_location == "TRUE");
@ -260,10 +300,10 @@ void MainWindow::on_comboBox_Location_activated(const QString &location)
} }
} }
void MainWindow::on_comboBox_Visibility_activated(const QString &visibility) void MainWindow::on_comboBox_Visibility_activated(const QString &requiresFlash)
{ {
if (editor && editor->map) { if (editor && editor->map) {
editor->map->visibility = visibility; editor->map->requiresFlash = requiresFlash;
} }
} }
@ -288,6 +328,17 @@ void MainWindow::on_comboBox_BattleScene_activated(const QString &battle_scene)
} }
} }
void MainWindow::on_checkBox_Visibility_clicked(bool checked)
{
if (editor && editor->map) {
if (checked) {
editor->map->requiresFlash = "TRUE";
} else {
editor->map->requiresFlash = "FALSE";
}
}
}
void MainWindow::on_checkBox_ShowLocation_clicked(bool checked) void MainWindow::on_checkBox_ShowLocation_clicked(bool checked)
{ {
if (editor && editor->map) { if (editor && editor->map) {
@ -303,9 +354,17 @@ void MainWindow::loadDataStructures() {
Project *project = editor->project; Project *project = editor->project;
project->readMapLayoutsTable(); project->readMapLayoutsTable();
project->readAllMapLayouts(); project->readAllMapLayouts();
project->readRegionMapSections();
project->readItemNames(); project->readItemNames();
project->readFlagNames(); project->readFlagNames();
project->readVarNames(); project->readVarNames();
project->readMovementTypes();
project->readMapTypes();
project->readMapBattleScenes();
project->readWeatherNames();
project->readCoordEventWeatherNames();
project->readSecretBaseIds();
project->readBgEventFacingDirections();
project->readMapsWithConnections(); project->readMapsWithConnections();
} }
@ -537,12 +596,19 @@ void MainWindow::addNewEvent(QString event_type)
// Should probably just pass layout and let the editor work it out // Should probably just pass layout and let the editor work it out
void MainWindow::updateSelectedObjects() { void MainWindow::updateSelectedObjects() {
QList<DraggablePixmapItem *> *all_events = editor->getObjects(); QList<DraggablePixmapItem *> *all_events = editor->getObjects();
QList<DraggablePixmapItem *> *events = all_events; QList<DraggablePixmapItem *> *events = NULL;
if (editor->selected_events && editor->selected_events->length()) { if (editor->selected_events && editor->selected_events->length()) {
events = editor->selected_events; events = editor->selected_events;
} else {
events = new QList<DraggablePixmapItem*>;
if (all_events && all_events->length()) {
DraggablePixmapItem *selectedEvent = all_events->first();
editor->selected_events->append(selectedEvent);
editor->redrawObject(selectedEvent);
events->append(selectedEvent);
}
} }
QMap<QString, int> event_obj_gfx_constants = editor->project->getEventObjGfxConstants(); QMap<QString, int> event_obj_gfx_constants = editor->project->getEventObjGfxConstants();
@ -590,11 +656,10 @@ void MainWindow::updateSelectedObjects() {
QMap<QString, QString> field_labels; QMap<QString, QString> field_labels;
field_labels["script_label"] = "Script"; field_labels["script_label"] = "Script";
field_labels["event_flag"] = "Event Flag"; field_labels["event_flag"] = "Event Flag";
field_labels["replacement"] = "Replacement"; field_labels["movement_type"] = "Movement";
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["trainer_see_type"] = "Trainer See Type"; field_labels["is_trainer"] = "Trainer";
field_labels["sight_radius_tree_id"] = "Sight Radius / Berry Tree ID"; 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";
@ -606,7 +671,7 @@ void MainWindow::updateSelectedObjects() {
field_labels["item_unknown6"] = "Unknown 6"; field_labels["item_unknown6"] = "Unknown 6";
field_labels["weather"] = "Weather"; field_labels["weather"] = "Weather";
field_labels["flag"] = "Flag"; field_labels["flag"] = "Flag";
field_labels["secret_base_map"] = "Secret Base Map"; field_labels["secret_base_id"] = "Secret Base Id";
QStringList fields; QStringList fields;
@ -627,13 +692,12 @@ void MainWindow::updateSelectedObjects() {
//connect(item, SIGNAL(scriptChanged(QString)), frame->ui->comboBox_script, SLOT(setValue(QString))); //connect(item, SIGNAL(scriptChanged(QString)), frame->ui->comboBox_script, SLOT(setValue(QString)));
*/ */
fields << "behavior"; fields << "movement_type";
fields << "radius_x"; fields << "radius_x";
fields << "radius_y"; fields << "radius_y";
fields << "script_label"; fields << "script_label";
fields << "event_flag"; fields << "event_flag";
fields << "replacement"; fields << "is_trainer";
fields << "trainer_see_type";
fields << "sight_radius_tree_id"; fields << "sight_radius_tree_id";
} }
else if (event_type == EventType::Warp) { else if (event_type == EventType::Warp) {
@ -657,37 +721,96 @@ void MainWindow::updateSelectedObjects() {
fields << "flag"; fields << "flag";
} }
else if (event_type == EventType::SecretBase) { else if (event_type == EventType::SecretBase) {
fields << "secret_base_map"; fields << "secret_base_id";
} }
for (QString key : fields) { for (QString key : fields) {
QString value = item->event->get(key);
QWidget *widget = new QWidget(frame); QWidget *widget = new QWidget(frame);
QFormLayout *fl = new QFormLayout(widget); QFormLayout *fl = new QFormLayout(widget);
fl->setContentsMargins(9, 0, 9, 0); fl->setContentsMargins(9, 0, 9, 0);
QComboBox *combo = new QComboBox(widget);
// is_trainer is the only non-combobox item.
if (key == "is_trainer") {
QCheckBox *checkbox = new QCheckBox(widget);
checkbox->setEnabled(true);
checkbox->setChecked(value.toInt() != 0 && value != "FALSE");
checkbox->setToolTip("Whether or not this object is trainer.");
fl->addRow(new QLabel(field_labels[key], widget), checkbox);
widget->setLayout(fl);
frame->layout()->addWidget(widget);
connect(checkbox, &QCheckBox::stateChanged, [=](int state) {
QString isTrainer = state == Qt::Checked ? "TRUE" : "FALSE";
item->event->put("is_trainer", isTrainer);
});
continue;
}
NoScrollComboBox *combo = new NoScrollComboBox(widget);
combo->setEditable(true); combo->setEditable(true);
QString value = item->event->get(key);
if (key == "destination_map_name") { if (key == "destination_map_name") {
if (!editor->project->mapNames->contains(value)) { if (!editor->project->mapNames->contains(value)) {
combo->addItem(value); combo->addItem(value);
} }
combo->addItems(*editor->project->mapNames); combo->addItems(*editor->project->mapNames);
combo->setToolTip("The destination map name of the warp.");
} else if (key == "destination_warp") {
combo->setToolTip("The warp id on the destination map.");
} else if (key == "item") { } else if (key == "item") {
if (!editor->project->itemNames->contains(value)) { if (!editor->project->itemNames->contains(value)) {
combo->addItem(value); combo->addItem(value);
} }
combo->addItems(*editor->project->itemNames); combo->addItems(*editor->project->itemNames);
} else if (key == "flag") { } else if (key == "flag" || key == "event_flag") {
if (!editor->project->flagNames->contains(value)) { if (!editor->project->flagNames->contains(value)) {
combo->addItem(value); combo->addItem(value);
} }
combo->addItems(*editor->project->flagNames); combo->addItems(*editor->project->flagNames);
if (key == "flag")
combo->setToolTip("The flag which is set when the hidden item is picked up.");
else if (key == "event_flag")
combo->setToolTip("The flag which hides the object when set.");
} else if (key == "script_var") { } else if (key == "script_var") {
if (!editor->project->varNames->contains(value)) { if (!editor->project->varNames->contains(value)) {
combo->addItem(value); combo->addItem(value);
} }
combo->addItems(*editor->project->varNames); combo->addItems(*editor->project->varNames);
combo->setToolTip("The variable by which the script is triggered. The script is triggered when this variable's value matches 'Var Value'.");
} else if (key == "script_var_value") {
combo->setToolTip("The variable's value which triggers the script.");
} else if (key == "movement_type") {
if (!editor->project->movementTypes->contains(value)) {
combo->addItem(value);
}
combo->addItems(*editor->project->movementTypes);
combo->setToolTip("The object's natural movement behavior when the player is not interacting with it.");
} else if (key == "weather") {
if (!editor->project->coordEventWeatherNames->contains(value)) {
combo->addItem(value);
}
combo->addItems(*editor->project->coordEventWeatherNames);
combo->setToolTip("The weather that starts when the player steps on this spot.");
} else if (key == "secret_base_id") {
if (!editor->project->secretBaseIds->contains(value)) {
combo->addItem(value);
}
combo->addItems(*editor->project->secretBaseIds);
combo->setToolTip("The secret base id which is inside this secret base entrance. Secret base ids are meant to be unique to each and every secret base entrance.");
} else if (key == "player_facing_direction") {
if (!editor->project->bgEventFacingDirections->contains(value)) {
combo->addItem(value);
}
combo->addItems(*editor->project->bgEventFacingDirections);
combo->setToolTip("The direction which the player must be facing to be able to interact with this event.");
} else if (key == "radius_x") {
combo->setToolTip("The maximum number of metatiles this object is allowed to move left or right during its normal movement behavior actions.");
} else if (key == "radius_y") {
combo->setToolTip("The maximum number of metatiles this object is allowed to move up or down during its normal movement behavior actions.");
} else if (key == "script_label") {
combo->setToolTip("The script which is executed with this event.");
} else if (key == "sight_radius_tree_id") {
combo->setToolTip("The maximum sight range of a trainer, OR the unique id of the berry tree.");
} else { } else {
combo->addItem(value); combo->addItem(value);
} }
@ -785,6 +908,10 @@ void MainWindow::onMapChanged(Map *map) {
updateMapList(); updateMapList();
} }
void MainWindow::onMapNeedsRedrawing(Map *map) {
redrawMapScene();
}
void MainWindow::on_action_Export_Map_Image_triggered() void MainWindow::on_action_Export_Map_Image_triggered()
{ {
QString defaultFilepath = QString("%1/%2.png").arg(editor->project->root).arg(editor->map->name); QString defaultFilepath = QString("%1/%2.png").arg(editor->project->root).arg(editor->map->name);
@ -838,3 +965,68 @@ void MainWindow::on_comboBox_SecondaryTileset_activated(const QString &tilesetLa
{ {
editor->updateSecondaryTileset(tilesetLabel); editor->updateSecondaryTileset(tilesetLabel);
} }
void MainWindow::on_pushButton_clicked()
{
QDialog dialog(this, Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
dialog.setWindowTitle("Change Map Dimensions");
dialog.setWindowModality(Qt::NonModal);
QFormLayout form(&dialog);
QSpinBox *widthSpinBox = new QSpinBox();
QSpinBox *heightSpinBox = new QSpinBox();
widthSpinBox->setMinimum(1);
heightSpinBox->setMinimum(1);
// See below for explanation of maximum map dimensions
widthSpinBox->setMaximum(0x1E7);
heightSpinBox->setMaximum(0x1D1);
widthSpinBox->setValue(editor->map->getWidth());
heightSpinBox->setValue(editor->map->getHeight());
form.addRow(new QLabel("Width"), widthSpinBox);
form.addRow(new QLabel("Height"), heightSpinBox);
QLabel *errorLabel = new QLabel();
QPalette errorPalette;
errorPalette.setColor(QPalette::WindowText, Qt::red);
errorLabel->setPalette(errorPalette);
errorLabel->setVisible(false);
QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog);
form.addRow(&buttonBox);
connect(&buttonBox, &QDialogButtonBox::accepted, [&dialog, &widthSpinBox, &heightSpinBox, &errorLabel](){
// Ensure width and height are an acceptable size.
// The maximum number of metatiles in a map is the following:
// max = (width + 15) * (height + 14)
// This limit can be found in fieldmap.c in pokeruby/pokeemerald.
int realWidth = widthSpinBox->value() + 15;
int realHeight = heightSpinBox->value() + 14;
int numMetatiles = realWidth * realHeight;
if (numMetatiles <= 0x2800) {
dialog.accept();
} else {
QString errorText = QString("Error: The specified width and height are too large.\n"
"The maximum width and height is the following: (width + 15) * (height + 14) <= 10240\n"
"The specified width and height was: (%1 + 15) * (%2 + 14) = %3")
.arg(widthSpinBox->value())
.arg(heightSpinBox->value())
.arg(numMetatiles);
errorLabel->setText(errorText);
errorLabel->setVisible(true);
}
});
connect(&buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject()));
form.addRow(errorLabel);
if (dialog.exec() == QDialog::Accepted) {
editor->map->setDimensions(widthSpinBox->value(), heightSpinBox->value());
editor->map->commit();
onMapNeedsRedrawing(editor->map);
}
}
void MainWindow::on_checkBox_smartPaths_stateChanged(int selected)
{
editor->map->smart_paths_enabled = selected == Qt::Checked;
}

View file

@ -32,12 +32,14 @@ private slots:
void on_action_Open_Project_triggered(); void on_action_Open_Project_triggered();
void on_mapList_activated(const QModelIndex &index); void on_mapList_activated(const QModelIndex &index);
void on_action_Save_Project_triggered(); void on_action_Save_Project_triggered();
void openWarpMap(QString map_name, QString warp_num);
void undo(); void undo();
void redo(); void redo();
void onLoadMapRequested(QString, QString); void onLoadMapRequested(QString, QString);
void onMapChanged(Map *map); void onMapChanged(Map *map);
void onMapNeedsRedrawing(Map *map);
void on_action_Save_triggered(); void on_action_Save_triggered();
void on_tabWidget_2_currentChanged(int index); void on_tabWidget_2_currentChanged(int index);
@ -93,6 +95,12 @@ private slots:
void on_comboBox_SecondaryTileset_activated(const QString &arg1); void on_comboBox_SecondaryTileset_activated(const QString &arg1);
void on_pushButton_clicked();
void on_checkBox_smartPaths_stateChanged(int selected);
void on_checkBox_Visibility_clicked(bool checked);
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
QStandardItemModel *mapListModel; QStandardItemModel *mapListModel;
@ -100,6 +108,7 @@ private:
Editor *editor = NULL; Editor *editor = NULL;
QIcon* mapIcon; QIcon* mapIcon;
void setMap(QString); void setMap(QString);
void redrawMapScene();
void loadDataStructures(); void loadDataStructures();
void populateMapList(); void populateMapList();
QString getExistingDirectory(QString); QString getExistingDirectory(QString);

View file

@ -69,6 +69,9 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<widget class="QWidget" name="tab_Map"> <widget class="QWidget" name="tab_Map">
<property name="toolTip">
<string/>
</property>
<attribute name="icon"> <attribute name="icon">
<iconset resource="resources/images.qrc"> <iconset resource="resources/images.qrc">
<normaloff>:/icons/map.ico</normaloff>:/icons/map.ico</iconset> <normaloff>:/icons/map.ico</normaloff>:/icons/map.ico</iconset>
@ -76,6 +79,9 @@
<attribute name="title"> <attribute name="title">
<string>Map</string> <string>Map</string>
</attribute> </attribute>
<attribute name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Edit the map layout.&lt;/p&gt;&lt;p&gt;Select metatiles or collision attributes from the right panel, and paint them onto the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_9"> <layout class="QGridLayout" name="gridLayout_9">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
@ -164,6 +170,9 @@
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Pencil&lt;/p&gt;&lt;p&gt;Click and drag to draw on the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Paint</string> <string>Paint</string>
</property> </property>
@ -187,6 +196,9 @@
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Pointer&lt;/p&gt;&lt;p&gt;Does nothing&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Select</string> <string>Select</string>
</property> </property>
@ -201,6 +213,9 @@
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButton_Fill"> <widget class="QToolButton" name="toolButton_Fill">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Flood Fill&lt;/p&gt;&lt;p&gt;Fills all similar tiles in a region with the selected metatiles or collision attributes&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Fill</string> <string>Fill</string>
</property> </property>
@ -215,6 +230,9 @@
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButton_Dropper"> <widget class="QToolButton" name="toolButton_Dropper">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Eye Dropper&lt;/p&gt;&lt;p&gt;Click to select a metatile or collision attribute.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Dropper</string> <string>Dropper</string>
</property> </property>
@ -228,10 +246,26 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBox_ToggleGrid"> <widget class="QCheckBox" name="checkBox_smartPaths">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Smart-path mode allows easier drawing of paths. If a 3x3 metatile block is selcted in the right panel, then smart path mode will automatically form a pathway using those selected blocks.&lt;/p&gt;&lt;p&gt;When smart-path mode is &lt;span style=&quot; font-weight:600;&quot;&gt;not&lt;/span&gt; enabled, clicking and dragging a selection will tile it in a grid.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">margin-left: 10px</string> <string notr="true">margin-left: 10px</string>
</property> </property>
<property name="text">
<string>Smart Paths</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_ToggleGrid">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Toggles a grid over the map's metatile boundaries.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text"> <property name="text">
<string>Show Grid</string> <string>Show Grid</string>
</property> </property>
@ -250,6 +284,16 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Change a map layout's width and height.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Change Dimensions</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -291,7 +335,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>436</width> <width>436</width>
<height>621</height> <height>620</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_8"> <layout class="QGridLayout" name="gridLayout_8">
@ -473,7 +517,13 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="comboBox_PrimaryTileset"> <widget class="NoScrollComboBox" name="comboBox_PrimaryTileset">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Primary Tileset&lt;/p&gt;&lt;p&gt;Defines the first 0x200 metatiles available for the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -487,7 +537,13 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QComboBox" name="comboBox_SecondaryTileset"> <widget class="NoScrollComboBox" name="comboBox_SecondaryTileset">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Secondary Tileset&lt;/p&gt;&lt;p&gt;Defines the second 0x200 metatiles available for the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -557,6 +613,9 @@
<height>48</height> <height>48</height>
</size> </size>
</property> </property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The border is a 2x2 metatile which is repeated outside of the map layout's boundary. Draw on this border area to modify it.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::StyledPanel</enum>
</property> </property>
@ -829,7 +888,10 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<attribute name="title"> <attribute name="title">
<string>Objects</string> <string>Events</string>
</attribute>
<attribute name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Edit the map's events.&lt;/p&gt;&lt;p&gt;View and modify objects, warps, signs, etc.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_10"> <layout class="QGridLayout" name="gridLayout_10">
<property name="leftMargin"> <property name="leftMargin">
@ -1090,6 +1152,9 @@
<height>32</height> <height>32</height>
</size> </size>
</property> </property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Add a new event to the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>New Object</string> <string>New Object</string>
</property> </property>
@ -1116,6 +1181,9 @@
<height>32</height> <height>32</height>
</size> </size>
</property> </property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Delete the selected event from the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Delete</string> <string>Delete</string>
</property> </property>
@ -1155,7 +1223,7 @@
</widget> </widget>
<widget class="QWidget" name="tab_Attributes"> <widget class="QWidget" name="tab_Attributes">
<attribute name="title"> <attribute name="title">
<string>Attributes</string> <string>Header</string>
</attribute> </attribute>
<widget class="QFrame" name="frame_3"> <widget class="QFrame" name="frame_3">
<property name="enabled"> <property name="enabled">
@ -1165,211 +1233,146 @@
<rect> <rect>
<x>10</x> <x>10</x>
<y>10</y> <y>10</y>
<width>301</width> <width>381</width>
<height>251</height> <height>311</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::StyledPanel</enum>
</property> </property>
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<widget class="QLabel" name="label_3"> <layout class="QFormLayout" name="formLayout_2">
<property name="geometry"> <property name="verticalSpacing">
<rect> <number>12</number>
<x>20</x>
<y>30</y>
<width>47</width>
<height>21</height>
</rect>
</property> </property>
<property name="text"> <item row="0" column="0">
<string>Song</string> <widget class="QLabel" name="label_3">
</property> <property name="text">
</widget> <string>Song</string>
<widget class="QLabel" name="label_4"> </property>
<property name="geometry"> </widget>
<rect> </item>
<x>20</x> <item row="0" column="1">
<y>60</y> <widget class="QComboBox" name="comboBox_Song">
<width>47</width> <property name="toolTip">
<height>21</height> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The default background music for this map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</rect> </property>
</property> <property name="editable">
<property name="text"> <bool>true</bool>
<string>Location</string> </property>
</property> </widget>
</widget> </item>
<widget class="QLabel" name="label_5"> <item row="1" column="0">
<property name="geometry"> <widget class="QLabel" name="label_4">
<rect> <property name="text">
<x>20</x> <string>Location</string>
<y>90</y> </property>
<width>47</width> </widget>
<height>21</height> </item>
</rect> <item row="1" column="1">
</property> <widget class="QComboBox" name="comboBox_Location">
<property name="text"> <property name="toolTip">
<string>Visibility</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The section of the region map which the map is grouped under. This also determines the name of the map that is display when the player enters it.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> <property name="editable">
<widget class="QLabel" name="label_6"> <bool>true</bool>
<property name="geometry"> </property>
<rect> </widget>
<x>20</x> </item>
<y>120</y> <item row="2" column="0">
<width>47</width> <widget class="QLabel" name="label_5">
<height>21</height> <property name="text">
</rect> <string>Requires Flash</string>
</property> </property>
<property name="text"> </widget>
<string>Weather</string> </item>
</property> <item row="3" column="0">
</widget> <widget class="QLabel" name="label_6">
<widget class="QLabel" name="label_7"> <property name="text">
<property name="geometry"> <string>Weather</string>
<rect> </property>
<x>20</x> </widget>
<y>150</y> </item>
<width>47</width> <item row="3" column="1">
<height>21</height> <widget class="QComboBox" name="comboBox_Weather">
</rect> <property name="toolTip">
</property> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The default weather for this map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<property name="text"> </property>
<string>Type</string> <property name="editable">
</property> <bool>true</bool>
</widget> </property>
<widget class="QLabel" name="label_8"> </widget>
<property name="geometry"> </item>
<rect> <item row="4" column="0">
<x>20</x> <widget class="QLabel" name="label_7">
<y>180</y> <property name="text">
<width>101</width> <string>Type</string>
<height>21</height> </property>
</rect> </widget>
</property> </item>
<property name="text"> <item row="4" column="1">
<string>Show location name</string> <widget class="QComboBox" name="comboBox_Type">
</property> <property name="toolTip">
</widget> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The map type is a general attribute, which is used for many different things. For example. it determines whether biking or running is allowed.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<widget class="QLabel" name="label_9"> </property>
<property name="geometry"> <property name="editable">
<rect> <bool>true</bool>
<x>20</x> </property>
<y>210</y> </widget>
<width>81</width> </item>
<height>21</height> <item row="5" column="0">
</rect> <widget class="QLabel" name="label_8">
</property> <property name="text">
<property name="text"> <string>Show Location Name</string>
<string>Battle scene</string> </property>
</property> </widget>
</widget> </item>
<widget class="QComboBox" name="comboBox_Location"> <item row="5" column="1">
<property name="geometry"> <widget class="QCheckBox" name="checkBox_ShowLocation">
<rect> <property name="toolTip">
<x>80</x> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Whether or not to display the location name when the player enters the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<y>60</y> </property>
<width>211</width> <property name="text">
<height>22</height> <string/>
</rect> </property>
</property> </widget>
<property name="editable"> </item>
<bool>true</bool> <item row="6" column="0">
</property> <widget class="QLabel" name="label_9">
</widget> <property name="text">
<widget class="QComboBox" name="comboBox_Visibility"> <string>Battle scene</string>
<property name="geometry"> </property>
<rect> </widget>
<x>80</x> </item>
<y>90</y> <item row="6" column="1">
<width>211</width> <widget class="QComboBox" name="comboBox_BattleScene">
<height>22</height> <property name="toolTip">
</rect> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Determines the type of battle scene graphics to use.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QComboBox" name="comboBox_Song"> </item>
<property name="geometry"> <item row="2" column="1">
<rect> <widget class="QCheckBox" name="checkBox_Visibility">
<x>80</x> <property name="toolTip">
<y>30</y> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Whether or not the map is dark and requires Flash to illuminate.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<width>211</width> </property>
<height>22</height> <property name="text">
</rect> <string/>
</property> </property>
<property name="editable"> </widget>
<bool>true</bool> </item>
</property> </layout>
</widget>
<widget class="QComboBox" name="comboBox_Weather">
<property name="geometry">
<rect>
<x>80</x>
<y>120</y>
<width>211</width>
<height>22</height>
</rect>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
<widget class="QComboBox" name="comboBox_Type">
<property name="geometry">
<rect>
<x>80</x>
<y>150</y>
<width>211</width>
<height>22</height>
</rect>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
<widget class="QComboBox" name="comboBox_BattleScene">
<property name="geometry">
<rect>
<x>90</x>
<y>210</y>
<width>201</width>
<height>22</height>
</rect>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_ShowLocation">
<property name="geometry">
<rect>
<x>130</x>
<y>180</y>
<width>161</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="label_10">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>47</width>
<height>13</height>
</rect>
</property>
<property name="text">
<string>Header</string>
</property>
</widget>
</widget> </widget>
</widget> </widget>
<widget class="QWidget" name="tab_Connections"> <widget class="QWidget" name="tab_Connections">
@ -1463,6 +1466,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Add a new connection.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -1475,6 +1481,9 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_RemoveConnection"> <widget class="QPushButton" name="pushButton_RemoveConnection">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Remove the currently-selected connection.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -1523,6 +1532,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If enabled, connections will automatically be updated on the connected map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Mirror</string> <string>Mirror</string>
</property> </property>
@ -1585,6 +1597,9 @@
</property> </property>
<item> <item>
<widget class="QComboBox" name="comboBox_ConnectionDirection"> <widget class="QComboBox" name="comboBox_ConnectionDirection">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The direction of the connection.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item> <item>
<property name="text"> <property name="text">
<string>up</string> <string>up</string>
@ -1632,6 +1647,9 @@
</item> </item>
<item> <item>
<widget class="QComboBox" name="comboBox_ConnectedMap"> <widget class="QComboBox" name="comboBox_ConnectedMap">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The destination map name of the connection.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -1646,6 +1664,9 @@
</item> </item>
<item> <item>
<widget class="QSpinBox" name="spinBox_ConnectionOffset"> <widget class="QSpinBox" name="spinBox_ConnectionOffset">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The number of metatiles to offset the connection.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="minimum"> <property name="minimum">
<number>-999</number> <number>-999</number>
</property> </property>
@ -1823,6 +1844,9 @@
</item> </item>
<item> <item>
<widget class="QComboBox" name="comboBox_DiveMap"> <widget class="QComboBox" name="comboBox_DiveMap">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Destination map name when using &lt;span style=&quot; font-weight:600;&quot;&gt;Dive&lt;/span&gt;. If empty, no such connection will exist.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -1837,6 +1861,9 @@
</item> </item>
<item> <item>
<widget class="QComboBox" name="comboBox_EmergeMap"> <widget class="QComboBox" name="comboBox_EmergeMap">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Destination map name when emerging using &lt;span style=&quot; font-weight:600;&quot;&gt;Dive&lt;/span&gt;. If empty, no such connection will exist.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -1972,6 +1999,11 @@
<extends>QToolButton</extends> <extends>QToolButton</extends>
<header>neweventtoolbutton.h</header> <header>neweventtoolbutton.h</header>
</customwidget> </customwidget>
<customwidget>
<class>NoScrollComboBox</class>
<extends>QComboBox</extends>
<header>noscrollcombobox.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="resources/images.qrc"/> <include location="resources/images.qrc"/>

113
map.cpp
View file

@ -6,6 +6,7 @@
#include <QImage> #include <QImage>
#include <QRegularExpression> #include <QRegularExpression>
Map::Map(QObject *parent) : QObject(parent) Map::Map(QObject *parent) : QObject(parent)
{ {
paint_tile_index = 1; paint_tile_index = 1;
@ -276,6 +277,7 @@ QPixmap Map::render(bool ignoreCache = false) {
cacheBlockdata(); cacheBlockdata();
pixmap = pixmap.fromImage(image); pixmap = pixmap.fromImage(image);
} }
return pixmap; return pixmap;
} }
@ -387,7 +389,7 @@ void Map::drawSelection(int i, int w, int selectionWidth, int selectionHeight, Q
int y = i / w; int y = i / w;
painter->save(); painter->save();
QColor penColor = smart_paths_enabled ? QColor(0xff, 0x0, 0xff) : QColor(0xff, 0xff, 0xff); QColor penColor = QColor(0xff, 0xff, 0xff);
painter->setPen(penColor); painter->setPen(penColor);
int rectWidth = selectionWidth * 16; int rectWidth = selectionWidth * 16;
int rectHeight = selectionHeight * 16; int rectHeight = selectionHeight * 16;
@ -427,6 +429,36 @@ QPixmap Map::renderMetatiles() {
return QPixmap::fromImage(image); return QPixmap::fromImage(image);
} }
void Map::setNewDimensionsBlockdata(int newWidth, int newHeight) {
int oldWidth = getWidth();
int oldHeight = getHeight();
Blockdata* newBlockData = new Blockdata;
for (int y = 0; y < newHeight; y++)
for (int x = 0; x < newWidth; x++) {
if (x < oldWidth && y < oldHeight) {
int index = y * oldWidth + x;
newBlockData->addBlock(layout->blockdata->blocks->value(index));
} else {
newBlockData->addBlock(0);
}
}
layout->blockdata->copyFrom(newBlockData);
}
void Map::setDimensions(int newWidth, int newHeight, bool setNewBlockdata) {
if (setNewBlockdata) {
setNewDimensionsBlockdata(newWidth, newHeight);
}
layout->width = QString::number(newWidth);
layout->height = QString::number(newHeight);
emit mapChanged(this);
}
Block* Map::getBlock(int x, int y) { Block* Map::getBlock(int x, int y) {
if (layout->blockdata && layout->blockdata->blocks) { if (layout->blockdata && layout->blockdata->blocks) {
if (x >= 0 && x < getWidth()) if (x >= 0 && x < getWidth())
@ -445,38 +477,6 @@ void Map::_setBlock(int x, int y, Block block) {
} }
} }
void Map::_floodFill(int x, int y, uint tile) {
QList<QPoint> todo;
todo.append(QPoint(x, y));
while (todo.length()) {
QPoint point = todo.takeAt(0);
x = point.x();
y = point.y();
Block *block = getBlock(x, y);
if (block == NULL) {
continue;
}
uint old_tile = block->tile;
if (old_tile == tile) {
continue;
}
block->tile = tile;
_setBlock(x, y, *block);
if ((block = getBlock(x + 1, y)) && block->tile == old_tile) {
todo.append(QPoint(x + 1, y));
}
if ((block = getBlock(x - 1, y)) && block->tile == old_tile) {
todo.append(QPoint(x - 1, y));
}
if ((block = getBlock(x, y + 1)) && block->tile == old_tile) {
todo.append(QPoint(x, y + 1));
}
if ((block = getBlock(x, y - 1)) && block->tile == old_tile) {
todo.append(QPoint(x, y - 1));
}
}
}
void Map::_floodFillCollision(int x, int y, uint collision) { void Map::_floodFillCollision(int x, int y, uint collision) {
QList<QPoint> todo; QList<QPoint> todo;
todo.append(QPoint(x, y)); todo.append(QPoint(x, y));
@ -578,29 +578,48 @@ void Map::_floodFillCollisionElevation(int x, int y, uint collision, uint elevat
void Map::undo() { void Map::undo() {
HistoryItem *commit = history.back();
if (!commit)
return;
if (layout->blockdata) { if (layout->blockdata) {
Blockdata *commit = history.back(); layout->blockdata->copyFrom(commit->metatiles);
if (commit != NULL) { if (commit->layoutWidth != this->getWidth() || commit->layoutHeight != this->getHeight())
layout->blockdata->copyFrom(commit); {
emit mapChanged(this); this->setDimensions(commit->layoutWidth, commit->layoutHeight, false);
emit mapNeedsRedrawing(this);
} }
emit mapChanged(this);
} }
} }
void Map::redo() { void Map::redo() {
HistoryItem *commit = history.next();
if (!commit)
return;
if (layout->blockdata) { if (layout->blockdata) {
Blockdata *commit = history.next(); layout->blockdata->copyFrom(commit->metatiles);
if (commit != NULL) { if (commit->layoutWidth != this->getWidth() || commit->layoutHeight != this->getHeight())
layout->blockdata->copyFrom(commit); {
emit mapChanged(this); this->setDimensions(commit->layoutWidth, commit->layoutHeight, false);
emit mapNeedsRedrawing(this);
} }
emit mapChanged(this);
} }
} }
void Map::commit() { void Map::commit() {
if (layout->blockdata) { if (layout->blockdata) {
if (!layout->blockdata->equals(history.current())) { HistoryItem *item = history.current();
Blockdata* commit = layout->blockdata->copy(); bool atCurrentHistory = item
&& layout->blockdata->equals(item->metatiles)
&& this->getWidth() == item->layoutWidth
&& this->getHeight() == item->layoutHeight;
if (!atCurrentHistory) {
HistoryItem *commit = new HistoryItem(layout->blockdata->copy(), this->getWidth(), this->getHeight());
history.push(commit); history.push(commit);
emit mapChanged(this); emit mapChanged(this);
} }
@ -615,14 +634,6 @@ void Map::setBlock(int x, int y, Block block) {
} }
} }
void Map::floodFill(int x, int y, uint tile) {
Block *block = getBlock(x, y);
if (block && block->tile != tile) {
_floodFill(x, y, tile);
commit();
}
}
void Map::floodFillCollision(int x, int y, uint collision) { void Map::floodFillCollision(int x, int y, uint collision) {
Block *block = getBlock(x, y); Block *block = getBlock(x, y);
if (block && block->collision != collision) { if (block && block->collision != collision) {

20
map.h
View file

@ -10,6 +10,17 @@
#include <QDebug> #include <QDebug>
#include <QGraphicsPixmapItem> #include <QGraphicsPixmapItem>
class HistoryItem {
public:
Blockdata *metatiles;
short layoutWidth;
short layoutHeight;
HistoryItem(Blockdata *metatiles_, short layoutWidth_, short layoutHeight_) {
this->metatiles = metatiles_;
this->layoutWidth = layoutWidth_;
this->layoutHeight = layoutHeight_;
}
};
template <typename T> template <typename T>
class History { class History {
@ -116,7 +127,7 @@ public:
QString song; QString song;
QString layout_id; QString layout_id;
QString location; QString location;
QString visibility; QString requiresFlash;
QString weather; QString weather;
QString type; QString type;
QString unknown; QString unknown;
@ -173,8 +184,6 @@ public:
void setBlock(int x, int y, Block block); void setBlock(int x, int y, Block block);
void _setBlock(int x, int y, Block block); void _setBlock(int x, int y, Block block);
void floodFill(int x, int y, uint tile);
void _floodFill(int x, int y, uint tile);
void floodFillCollision(int x, int y, uint collision); void floodFillCollision(int x, int y, uint collision);
void _floodFillCollision(int x, int y, uint collision); void _floodFillCollision(int x, int y, uint collision);
void floodFillElevation(int x, int y, uint elevation); void floodFillElevation(int x, int y, uint elevation);
@ -182,7 +191,7 @@ public:
void floodFillCollisionElevation(int x, int y, uint collision, uint elevation); void floodFillCollisionElevation(int x, int y, uint collision, uint elevation);
void _floodFillCollisionElevation(int x, int y, uint collision, uint elevation); void _floodFillCollisionElevation(int x, int y, uint collision, uint elevation);
History<Blockdata*> history; History<HistoryItem*> history;
void undo(); void undo();
void redo(); void redo();
void commit(); void commit();
@ -194,6 +203,8 @@ public:
QList<Connection*> connections; QList<Connection*> connections;
QPixmap renderConnection(Connection); QPixmap renderConnection(Connection);
void setNewDimensionsBlockdata(int newWidth, int newHeight);
void setDimensions(int newWidth, int newHeight, bool setNewBlockData = true);
QPixmap renderBorder(); QPixmap renderBorder();
void cacheBorder(); void cacheBorder();
@ -212,6 +223,7 @@ signals:
void paintTileChanged(Map *map); void paintTileChanged(Map *map);
void paintCollisionChanged(Map *map); void paintCollisionChanged(Map *map);
void mapChanged(Map *map); void mapChanged(Map *map);
void mapNeedsRedrawing(Map *map);
void statusBarMessage(QString); void statusBarMessage(QString);
public slots: public slots:

15
noscrollcombobox.cpp Normal file
View file

@ -0,0 +1,15 @@
#include "noscrollcombobox.h"
NoScrollComboBox::NoScrollComboBox(QWidget *parent)
: QComboBox(parent)
{
// Don't let scrolling hijack focus.
setFocusPolicy(Qt::StrongFocus);
}
void NoScrollComboBox::wheelEvent(QWheelEvent *event)
{
// Only allow scrolling to modify contents when it explicitly has focus.
if (hasFocus())
QComboBox::wheelEvent(event);
}

17
noscrollcombobox.h Normal file
View file

@ -0,0 +1,17 @@
#ifndef NOSCROLLCOMBOBOX_H
#define NOSCROLLCOMBOBOX_H
#include <QComboBox>
class NoScrollComboBox : public QComboBox
{
Q_OBJECT
public:
explicit NoScrollComboBox(QWidget *parent = nullptr);
void wheelEvent(QWheelEvent *event);
private:
};
#endif // NOSCROLLCOMBOBOX_H

16
noscrollspinbox.cpp Normal file
View file

@ -0,0 +1,16 @@
#include "noscrollspinbox.h"
NoScrollSpinBox::NoScrollSpinBox(QWidget *parent)
: QSpinBox(parent)
{
// Don't let scrolling hijack focus.
setFocusPolicy(Qt::StrongFocus);
}
void NoScrollSpinBox::wheelEvent(QWheelEvent *event)
{
// Only allow scrolling to modify contents when it explicitly has focus.
if (hasFocus())
QSpinBox::wheelEvent(event);
}

17
noscrollspinbox.h Normal file
View file

@ -0,0 +1,17 @@
#ifndef NOSCROLLSPINBOX_H
#define NOSCROLLSPINBOX_H
#include <QSpinBox>
class NoScrollSpinBox : public QSpinBox
{
Q_OBJECT
public:
explicit NoScrollSpinBox(QWidget *parent = nullptr);
void wheelEvent(QWheelEvent *event);
private:
};
#endif // NOSCROLLSPINBOX_H

View file

@ -105,7 +105,13 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="spinBox_x"> <widget class="NoScrollSpinBox" name="spinBox_x">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The X coordinate of this object.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="minimum"> <property name="minimum">
<number>-32768</number> <number>-32768</number>
</property> </property>
@ -129,7 +135,13 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="spinBox_y"> <widget class="NoScrollSpinBox" name="spinBox_y">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The Y coordinate of this object.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="minimum"> <property name="minimum">
<number>-32768</number> <number>-32768</number>
</property> </property>
@ -153,7 +165,13 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="spinBox_z"> <widget class="NoScrollSpinBox" name="spinBox_z">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The elevation of this object.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="maximum"> <property name="maximum">
<number>15</number> <number>15</number>
</property> </property>
@ -210,7 +228,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="comboBox_sprite"> <widget class="NoScrollComboBox" name="comboBox_sprite">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -220,6 +238,12 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The sprite graphics to use for this object.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -239,6 +263,18 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>NoScrollComboBox</class>
<extends>QComboBox</extends>
<header>noscrollcombobox.h</header>
</customwidget>
<customwidget>
<class>NoScrollSpinBox</class>
<extends>QSpinBox</extends>
<header>noscrollspinbox.h</header>
</customwidget>
</customwidgets>
<tabstops> <tabstops>
<tabstop>spinBox_x</tabstop> <tabstop>spinBox_x</tabstop>
<tabstop>spinBox_y</tabstop> <tabstop>spinBox_y</tabstop>

View file

@ -25,7 +25,9 @@ SOURCES += main.cpp\
objectpropertiesframe.cpp \ objectpropertiesframe.cpp \
graphicsview.cpp \ graphicsview.cpp \
parseutil.cpp \ parseutil.cpp \
neweventtoolbutton.cpp neweventtoolbutton.cpp \
noscrollcombobox.cpp \
noscrollspinbox.cpp
HEADERS += mainwindow.h \ HEADERS += mainwindow.h \
project.h \ project.h \
@ -39,7 +41,9 @@ HEADERS += mainwindow.h \
objectpropertiesframe.h \ objectpropertiesframe.h \
graphicsview.h \ graphicsview.h \
parseutil.h \ parseutil.h \
neweventtoolbutton.h neweventtoolbutton.h \
noscrollcombobox.h \
noscrollspinbox.h
FORMS += mainwindow.ui \ FORMS += mainwindow.ui \
objectpropertiesframe.ui objectpropertiesframe.ui

View file

@ -17,9 +17,17 @@ Project::Project()
groupNames = new QStringList; groupNames = new QStringList;
map_groups = new QMap<QString, int>; map_groups = new QMap<QString, int>;
mapNames = new QStringList; mapNames = new QStringList;
regionMapSections = new QStringList;
itemNames = new QStringList; itemNames = new QStringList;
flagNames = new QStringList; flagNames = new QStringList;
varNames = new QStringList; varNames = new QStringList;
movementTypes = new QStringList;
mapTypes = new QStringList;
mapBattleScenes = new QStringList;
weatherNames = new QStringList;
coordEventWeatherNames = new QStringList;
secretBaseIds = new QStringList;
bgEventFacingDirections = new QStringList;
map_cache = new QMap<QString, Map*>; map_cache = new QMap<QString, Map*>;
mapConstantsToMapNames = new QMap<QString, QString>; mapConstantsToMapNames = new QMap<QString, QString>;
mapNamesToMapConstants = new QMap<QString, QString>; mapNamesToMapConstants = new QMap<QString, QString>;
@ -164,7 +172,7 @@ void Project::readMapHeader(Map* map) {
map->song = header->value(4); map->song = header->value(4);
map->layout_id = header->value(5); map->layout_id = header->value(5);
map->location = header->value(6); map->location = header->value(6);
map->visibility = header->value(7); map->requiresFlash = header->value(7);
map->weather = header->value(8); map->weather = header->value(8);
map->type = header->value(9); map->type = header->value(9);
map->unknown = header->value(10); map->unknown = header->value(10);
@ -179,13 +187,13 @@ void Project::setNewMapHeader(Map* map, int mapIndex) {
map->connections_label = "0x0"; map->connections_label = "0x0";
map->song = "MUS_DAN02"; map->song = "MUS_DAN02";
map->layout_id = QString("%1").arg(mapIndex); map->layout_id = QString("%1").arg(mapIndex);
map->location = "0"; map->location = "MAPSEC_LITTLEROOT_TOWN";
map->visibility = "0"; map->requiresFlash = "FALSE";
map->weather = "2"; map->weather = "WEATHER_SUNNY";
map->type = "1"; map->type = "MAP_TYPE_TOWN";
map->unknown = "0"; map->unknown = "0";
map->show_location = "1"; map->show_location = "TRUE";
map->battle_scene = "0"; map->battle_scene = "MAP_BATTLE_SCENE_NORMAL";
} }
void Project::saveMapHeader(Map *map) { void Project::saveMapHeader(Map *map) {
@ -207,7 +215,7 @@ void Project::saveMapHeader(Map *map) {
text += QString("\t.2byte %1\n").arg(map->song); text += QString("\t.2byte %1\n").arg(map->song);
text += QString("\t.2byte %1\n").arg(map->layout_id); text += QString("\t.2byte %1\n").arg(map->layout_id);
text += QString("\t.byte %1\n").arg(map->location); text += QString("\t.byte %1\n").arg(map->location);
text += QString("\t.byte %1\n").arg(map->visibility); text += QString("\t.byte %1\n").arg(map->requiresFlash);
text += QString("\t.byte %1\n").arg(map->weather); text += QString("\t.byte %1\n").arg(map->weather);
text += QString("\t.byte %1\n").arg(map->type); text += QString("\t.byte %1\n").arg(map->type);
text += QString("\t.2byte %1\n").arg(map->unknown); text += QString("\t.2byte %1\n").arg(map->unknown);
@ -982,15 +990,6 @@ QList<QStringList>* Project::parseAsm(QString text) {
return parser->parseAsm(text); return parser->parseAsm(text);
} }
QStringList Project::getLocations() {
// TODO
QStringList names;
for (int i = 0; i < 88; i++) {
names.append(QString("%1").arg(i));
}
return names;
}
QStringList Project::getVisibilities() { QStringList Project::getVisibilities() {
// TODO // TODO
QStringList names; QStringList names;
@ -1041,31 +1040,10 @@ QMap<QString, QStringList> Project::getTilesets() {
return allTilesets; return allTilesets;
} }
QStringList Project::getWeathers() { void Project::readRegionMapSections() {
// TODO QString filepath = root + "/include/constants/region_map_sections.h";
QStringList names; QStringList prefixes = (QStringList() << "MAPSEC_");
for (int i = 0; i < 16; i++) { readCDefinesSorted(filepath, prefixes, regionMapSections);
names.append(QString("%1").arg(i));
}
return names;
}
QStringList Project::getMapTypes() {
// TODO
QStringList names;
for (int i = 0; i < 16; i++) {
names.append(QString("%1").arg(i));
}
return names;
}
QStringList Project::getBattleScenes() {
// TODO
QStringList names;
for (int i = 0; i < 16; i++) {
names.append(QString("%1").arg(i));
}
return names;
} }
void Project::readItemNames() { void Project::readItemNames() {
@ -1086,6 +1064,48 @@ void Project::readVarNames() {
readCDefinesSorted(filepath, prefixes, varNames); readCDefinesSorted(filepath, prefixes, varNames);
} }
void Project::readMovementTypes() {
QString filepath = root + "/include/constants/event_object_movement_constants.h";
QStringList prefixes = (QStringList() << "MOVEMENT_TYPE_");
readCDefinesSorted(filepath, prefixes, movementTypes);
}
void Project::readMapTypes() {
QString filepath = root + "/include/constants/map_types.h";
QStringList prefixes = (QStringList() << "MAP_TYPE_");
readCDefinesSorted(filepath, prefixes, mapTypes);
}
void Project::readMapBattleScenes() {
QString filepath = root + "/include/constants/map_types.h";
QStringList prefixes = (QStringList() << "MAP_BATTLE_SCENE_");
readCDefinesSorted(filepath, prefixes, mapBattleScenes);
}
void Project::readWeatherNames() {
QString filepath = root + "/include/constants/weather.h";
QStringList prefixes = (QStringList() << "WEATHER_");
readCDefinesSorted(filepath, prefixes, weatherNames);
}
void Project::readCoordEventWeatherNames() {
QString filepath = root + "/include/constants/weather.h";
QStringList prefixes = (QStringList() << "COORD_EVENT_WEATHER_");
readCDefinesSorted(filepath, prefixes, coordEventWeatherNames);
}
void Project::readSecretBaseIds() {
QString filepath = root + "/include/constants/secret_bases.h";
QStringList prefixes = (QStringList() << "SECRET_BASE_");
readCDefinesSorted(filepath, prefixes, secretBaseIds);
}
void Project::readBgEventFacingDirections() {
QString filepath = root + "/include/constants/bg_event_constants.h";
QStringList prefixes = (QStringList() << "BG_EVENT_PLAYER_FACING_");
readCDefinesSorted(filepath, prefixes, bgEventFacingDirections);
}
void Project::readCDefinesSorted(QString filepath, QStringList prefixes, QStringList* definesToSet) { void Project::readCDefinesSorted(QString filepath, QStringList prefixes, QStringList* definesToSet) {
QString text = readTextFile(filepath); QString text = readTextFile(filepath);
if (!text.isNull()) { if (!text.isNull()) {
@ -1098,6 +1118,8 @@ void Project::readCDefinesSorted(QString filepath, QStringList prefixes, QString
definesInverse.insert(defines[defineName], defineName); definesInverse.insert(defines[defineName], defineName);
} }
*definesToSet = definesInverse.values(); *definesToSet = definesInverse.values();
} else {
qDebug() << "Failed to read C defines file: " << filepath;
} }
} }
@ -1319,10 +1341,10 @@ void Project::readMapEvents(Map *map) {
object->put("x", command.value(i++).toInt(nullptr, 0)); object->put("x", command.value(i++).toInt(nullptr, 0));
object->put("y", command.value(i++).toInt(nullptr, 0)); object->put("y", command.value(i++).toInt(nullptr, 0));
object->put("elevation", command.value(i++)); object->put("elevation", command.value(i++));
object->put("behavior", command.value(i++)); object->put("movement_type", 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("trainer_see_type", command.value(i++)); object->put("is_trainer", command.value(i++));
object->put("sight_radius_tree_id", 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++));
@ -1363,12 +1385,6 @@ void Project::readMapEvents(Map *map) {
if (command.value(0) == "coord_event") { if (command.value(0) == "coord_event") {
Event *coord = new Event; Event *coord = new Event;
coord->put("map_name", map->name); coord->put("map_name", map->name);
bool old_macro = false;
if (command.length() >= 9) {
command.removeAt(7);
command.removeAt(4);
old_macro = true;
}
int i = 1; int i = 1;
coord->put("x", command.value(i++)); coord->put("x", command.value(i++));
coord->put("y", command.value(i++)); coord->put("y", command.value(i++));
@ -1376,9 +1392,6 @@ void Project::readMapEvents(Map *map) {
coord->put("script_var", command.value(i++)); coord->put("script_var", command.value(i++));
coord->put("script_var_value", command.value(i++)); coord->put("script_var_value", command.value(i++));
coord->put("script_label", command.value(i++)); coord->put("script_label", command.value(i++));
//coord_unknown3
//coord_unknown4
coord->put("event_group_type", "coord_event_group"); coord->put("event_group_type", "coord_event_group");
coord->put("event_type", EventType::CoordScript); coord->put("event_type", EventType::CoordScript);
map->events["coord_event_group"].append(coord); map->events["coord_event_group"].append(coord);
@ -1407,7 +1420,6 @@ 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("player_facing_direction", command.value(i++)); bg->put("player_facing_direction", command.value(i++));
i++;
bg->put("script_label", command.value(i++)); bg->put("script_label", command.value(i++));
//sign_unknown7 //sign_unknown7
bg->put("event_group_type", "bg_event_group"); bg->put("event_group_type", "bg_event_group");
@ -1432,7 +1444,7 @@ 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("secret_base_map", command.value(i++)); bg->put("secret_base_id", command.value(i++));
bg->put("event_group_type", "bg_event_group"); bg->put("event_group_type", "bg_event_group");
bg->put("event_type", EventType::SecretBase); bg->put("event_type", EventType::SecretBase);
map->events["bg_event_group"].append(bg); map->events["bg_event_group"].append(bg);

View file

@ -23,9 +23,17 @@ public:
QList<QString> mapLayoutsTableMaster; QList<QString> mapLayoutsTableMaster;
QMap<QString, MapLayout*> mapLayouts; QMap<QString, MapLayout*> mapLayouts;
QMap<QString, MapLayout*> mapLayoutsMaster; QMap<QString, MapLayout*> mapLayoutsMaster;
QStringList *regionMapSections = NULL;
QStringList *itemNames = NULL; QStringList *itemNames = NULL;
QStringList *flagNames = NULL; QStringList *flagNames = NULL;
QStringList *varNames = NULL; QStringList *varNames = NULL;
QStringList *movementTypes = NULL;
QStringList *mapTypes = NULL;
QStringList *mapBattleScenes = NULL;
QStringList *weatherNames = NULL;
QStringList *coordEventWeatherNames = NULL;
QStringList *secretBaseIds = NULL;
QStringList *bgEventFacingDirections = NULL;
QStringList mapsWithConnections; QStringList mapsWithConnections;
QMap<QString, Map*> *map_cache; QMap<QString, Map*> *map_cache;
@ -72,15 +80,19 @@ public:
QList<QStringList>* parseAsm(QString text); QList<QStringList>* parseAsm(QString text);
QStringList getSongNames(); QStringList getSongNames();
QStringList getLocations();
QStringList getVisibilities(); QStringList getVisibilities();
QMap<QString, QStringList> getTilesets(); QMap<QString, QStringList> getTilesets();
QStringList getWeathers(); void readRegionMapSections();
QStringList getMapTypes();
QStringList getBattleScenes();
void readItemNames(); void readItemNames();
void readFlagNames(); void readFlagNames();
void readVarNames(); void readVarNames();
void readMovementTypes();
void readMapTypes();
void readMapBattleScenes();
void readWeatherNames();
void readCoordEventWeatherNames();
void readSecretBaseIds();
void readBgEventFacingDirections();
void loadEventPixmaps(QList<Event*> objects); void loadEventPixmaps(QList<Event*> objects);
QMap<QString, int> getEventObjGfxConstants(); QMap<QString, int> getEventObjGfxConstants();