-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add Jump to Tile Coordinates feature #4215
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
base: master
Are you sure you want to change the base?
Add Jump to Tile Coordinates feature #4215
Conversation
- Implement TileLocatorSource for parsing tile coordinates - Add 'Jump to Tile' action with Ctrl+Shift+G shortcut - Support multiple coordinate formats: x,y, x:10 y:20, 10 20, etc. - Update keyboard shortcuts documentation - Fixes issue mapeditor#1367
08afd98
to
3e6b93e
Compare
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.
Pull Request Overview
This PR adds a "Jump to Tile Coordinates" feature that allows users to navigate directly to specific tile locations using keyboard input. The implementation provides a locator widget that accepts multiple coordinate formats and integrates with the existing locator system.
Key changes:
- Implements TileLocatorSource for parsing and handling tile coordinate input
- Adds jump to tile action with Ctrl+Shift+G keyboard shortcut
- Supports multiple coordinate formats (x,y / x:10 y:20 / 10 20 / single numbers)
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/tiled/tilelocator.h | New header defining TileLocatorSource class and Match structure |
src/tiled/tilelocator.cpp | Implementation of coordinate parsing, UI delegate, and navigation logic |
src/tiled/mainwindow.ui | Added Jump to Tile action and menu item with Ctrl+Shift+G shortcut |
src/tiled/mainwindow.h | Added jumpToTile method declaration |
src/tiled/mainwindow.cpp | Connected action to jumpToTile method implementation |
src/tiled/libtilededitor.qbs | Added new source files to build system |
docs/manual/keyboard-shortcuts.rst | Updated documentation with new keyboard shortcut |
return true; | ||
} | ||
|
||
// Format 2: "x:10 y:20" or "x:10, y:20" |
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.
The regular expression pattern is complex and hard to understand. Consider breaking it into smaller, more readable patterns or adding a comment explaining the expected format.
// Format 2: "x:10 y:20" or "x:10, y:20" | |
// Format 2: "x:10 y:20" or "x:10, y:20" | |
// Matches formats like "x:10 y:20" or "x:10, y:20". | |
// - "x:10" captures the x-coordinate. | |
// - "y:20" (optional) captures the y-coordinate, separated by a comma or whitespace. |
Copilot uses AI. Check for mistakes.
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.
@bjorn this is not a regular expression, it is a comment
QString remaining = text.mid(match.capturedEnd()); | ||
QRegularExpression yPattern(QStringLiteral(R"(y\s*:\s*(\d+))")); | ||
auto yMatch = yPattern.match(remaining); | ||
if (yMatch.hasMatch()) { | ||
tilePos.setY(yMatch.captured(1).toInt()); |
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.
[nitpick] The nested logic for handling partial x:y coordinate matches is complex and could be simplified. Consider extracting this into a separate helper method.
QString remaining = text.mid(match.capturedEnd()); | |
QRegularExpression yPattern(QStringLiteral(R"(y\s*:\s*(\d+))")); | |
auto yMatch = yPattern.match(remaining); | |
if (yMatch.hasMatch()) { | |
tilePos.setY(yMatch.captured(1).toInt()); | |
if (parseYCoordinateFromRemainingText(text.mid(match.capturedEnd()), tilePos)) { |
Copilot uses AI. Check for mistakes.
// Try to find any open map document | ||
const auto documents = documentManager->documents(); | ||
for (auto document : documents) { | ||
if (auto mapDoc = qobject_cast<MapDocument*>(document.data())) { | ||
mapDocument = mapDoc; | ||
break; | ||
} | ||
} |
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.
[nitpick] The fallback logic for finding a map document when no current document exists could be extracted into a helper method to improve readability.
// Try to find any open map document | |
const auto documents = documentManager->documents(); | |
for (auto document : documents) { | |
if (auto mapDoc = qobject_cast<MapDocument*>(document.data())) { | |
mapDocument = mapDoc; | |
break; | |
} | |
} | |
mapDocument = findFallbackMapDocument(documentManager); |
Copilot uses AI. Check for mistakes.
This PR implements the "Jump to location by tile coordinates" feature requested in issue #1367.
Changes:
Testing:
Files Changed:
src/tiled/tilelocator.h
- New header filesrc/tiled/tilelocator.cpp
- New implementationsrc/tiled/mainwindow.ui
- Added action and menu itemsrc/tiled/mainwindow.h
- Added method declarationsrc/tiled/mainwindow.cpp
- Added method implementationsrc/tiled/libtilededitor.qbs
- Added to build systemdocs/manual/keyboard-shortcuts.rst
- Updated documentationFixes #1367