Skip to content

Commit

Permalink
Merge pull request #50 from huderlem/layouts
Browse files Browse the repository at this point in the history
Support new map organization
  • Loading branch information
yenatch authored Jun 21, 2018
2 parents 39abd40 + 2567254 commit 9c2cf84
Show file tree
Hide file tree
Showing 7 changed files with 335 additions and 422 deletions.
14 changes: 7 additions & 7 deletions editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,14 @@ void Editor::displayMap() {
connect(map_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*,MapPixmapItem*)),
this, SLOT(mouseEvent_map(QGraphicsSceneMouseEvent*,MapPixmapItem*)));

map_item->draw();
map_item->draw(true);
scene->addItem(map_item);

collision_item = new CollisionPixmapItem(map);
connect(collision_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*,CollisionPixmapItem*)),
this, SLOT(mouseEvent_collision(QGraphicsSceneMouseEvent*,CollisionPixmapItem*)));

collision_item->draw();
collision_item->draw(true);
scene->addItem(collision_item);

events_group = new EventGroup;
Expand Down Expand Up @@ -1077,9 +1077,9 @@ void MapPixmapItem::select(QGraphicsSceneMouseEvent *event) {
}
}

void MapPixmapItem::draw() {
void MapPixmapItem::draw(bool ignoreCache) {
if (map) {
setPixmap(map->render());
setPixmap(map->render(ignoreCache));
}
}

Expand All @@ -1104,7 +1104,7 @@ void MapPixmapItem::updateCurHoveredTile(QPointF pos) {
if (x < 0 || x >= map->getWidth() || y < 0 || y >= map->getHeight()) {
map->clearHoveredTile();
} else {
int tile = map->blockdata->blocks->at(blockIndex).tile;
int tile = map->layout->blockdata->blocks->at(blockIndex).tile;
map->hoveredTileChanged(x, y, tile);
}
}
Expand Down Expand Up @@ -1141,9 +1141,9 @@ void CollisionPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
emit mouseEvent(event, this);
}

void CollisionPixmapItem::draw() {
void CollisionPixmapItem::draw(bool ignoreCache) {
if (map) {
setPixmap(map->renderCollision());
setPixmap(map->renderCollision(ignoreCache));
}
}

Expand Down
4 changes: 2 additions & 2 deletions editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class MapPixmapItem : public QObject, public QGraphicsPixmapItem {
virtual void select(QGraphicsSceneMouseEvent*);
virtual void undo();
virtual void redo();
virtual void draw();
virtual void draw(bool ignoreCache = false);

private:
void updateCurHoveredTile(QPointF pos);
Expand Down Expand Up @@ -266,7 +266,7 @@ class CollisionPixmapItem : public MapPixmapItem {
virtual void paint(QGraphicsSceneMouseEvent*);
virtual void floodFill(QGraphicsSceneMouseEvent*);
virtual void pick(QGraphicsSceneMouseEvent*);
virtual void draw();
virtual void draw(bool ignoreCache = false);

signals:
void mouseEvent(QGraphicsSceneMouseEvent *, CollisionPixmapItem *);
Expand Down
5 changes: 3 additions & 2 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ void MainWindow::on_checkBox_ShowLocation_clicked(bool checked)

void MainWindow::loadDataStructures() {
Project *project = editor->project;
project->readMapAttributesTable();
project->readAllMapAttributes();
project->readMapLayoutsTable();
project->readAllMapLayouts();
project->readItemNames();
project->readFlagNames();
project->readVarNames();
Expand Down Expand Up @@ -761,6 +761,7 @@ void MainWindow::onLoadMapRequested(QString mapName, QString fromMapName) {
}

void MainWindow::onMapChanged(Map *map) {
map->layout->has_unsaved_changes = true;
updateMapList();
}

Expand Down
Loading

0 comments on commit 9c2cf84

Please sign in to comment.