-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically Resize Maps - #260 #1651
Merged
Merged
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
75613d8
Store bounds of a TileLayer
ketanhwr cc61d6a
Basic support for infinite-maps
ketanhwr 7e49e26
Modify tools to support infinite-maps
ketanhwr 875f310
Modify MapRenderer to render minimap for infinite-maps
ketanhwr 11d766c
Fix review changes
ketanhwr 4136e44
Infinite->Finite conversion and vice-versa
ketanhwr 08160ef
Review Changes
ketanhwr 557275a
Fix test
ketanhwr d010cef
Minor changes
ketanhwr f75aec4
Review changes
ketanhwr a09cf51
Support for infinite isometric maps
ketanhwr c6de82b
Support for infinite hexagonal maps
ketanhwr 1f3cf8b
Review changes
ketanhwr 5d0e386
Review changes
ketanhwr 50c783b
Minor changes
ketanhwr a644f39
Bug fix
ketanhwr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,11 +38,31 @@ | |
|
||
using namespace Tiled; | ||
|
||
QSize IsometricRenderer::mapSize() const | ||
QRect IsometricRenderer::mapBoundingRect() const | ||
{ | ||
// Map width and height contribute equally in both directions | ||
const int side = map()->height() + map()->width(); | ||
return QSize(side * map()->tileWidth() / 2, | ||
if (!map()->infinite()) { | ||
const int side = map()->height() + map()->width(); | ||
return QRect(0, 0, side * map()->tileWidth() / 2, | ||
side * map()->tileHeight() / 2); | ||
} | ||
|
||
QRect mapBounds; | ||
|
||
LayerIterator iterator(map()); | ||
while (Layer *layer = iterator.next()) { | ||
if (TileLayer *tileLayer = dynamic_cast<TileLayer*>(layer)) | ||
mapBounds = mapBounds.united(tileLayer->bounds()); | ||
} | ||
|
||
if (mapBounds.size() == QSize(0, 0)) | ||
mapBounds.setSize(QSize(1, 1)); | ||
|
||
const int origin = mapBounds.x() + mapBounds.y(); | ||
const int side = mapBounds.width() + mapBounds.height(); | ||
|
||
return QRect(origin * map()->tileWidth() / 2, | ||
origin * map()->tileHeight() / 2, | ||
side * map()->tileWidth() / 2, | ||
side * map()->tileHeight() / 2); | ||
} | ||
|
||
|
@@ -157,12 +177,17 @@ void IsometricRenderer::drawGrid(QPainter *painter, const QRectF &rect, | |
r.adjust(-tileWidth / 2, -tileHeight / 2, | ||
tileWidth / 2, tileHeight / 2); | ||
|
||
const int startX = qMax(qreal(0), screenToTileCoords(r.topLeft()).x()); | ||
const int startY = qMax(qreal(0), screenToTileCoords(r.topRight()).y()); | ||
const int endX = qMin(qreal(map()->width()), | ||
screenToTileCoords(r.bottomRight()).x()); | ||
const int endY = qMin(qreal(map()->height()), | ||
screenToTileCoords(r.bottomLeft()).y()); | ||
int startX = screenToTileCoords(r.topLeft()).x(); | ||
int startY = screenToTileCoords(r.topRight()).y(); | ||
int endX = screenToTileCoords(r.bottomRight()).x(); | ||
int endY = screenToTileCoords(r.bottomLeft()).y(); | ||
|
||
if (!map()->infinite()) { | ||
startX = qMax(qreal(0), qreal(startX)); | ||
startY = qMax(qreal(0), qreal(startY)); | ||
endX = qMin(qreal(map()->width()), qreal(endX)); | ||
endY = qMin(qreal(map()->height()), qreal(endY)); | ||
} | ||
|
||
QPen gridPen = makeGridPen(painter->device(), gridColor); | ||
painter->setPen(gridPen); | ||
|
@@ -243,7 +268,7 @@ void IsometricRenderer::drawTileLayer(QPainter *painter, | |
QPoint columnItr = rowItr; | ||
|
||
for (int x = startPos.x(); x < rect.right(); x += tileWidth) { | ||
if (layer->contains(columnItr)) { | ||
if (map()->infinite() || layer->contains(columnItr)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can drop both these checks and rely only on |
||
const Cell &cell = layer->cellAt(columnItr); | ||
if (!cell.isEmpty()) { | ||
Tile *tile = cell.tile(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please still optimize this to use an
endY
that is eitherlayer->height()
orlayer->bounds()
, same for X.