diff options
author | Mattes D <github@xoft.cz> | 2014-10-03 19:41:42 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-10-03 19:41:42 +0200 |
commit | 0aa1b5667e0ba97101f60343323c595cc7866c6d (patch) | |
tree | 5d39793f4b9e6662a7e53f8cdb4c375bdc7f23ff /Tools/QtBiomeVisualiser/BiomeView.cpp | |
parent | QtBiomeVisualiser: Zoom is now limited and aligned to steps. (diff) | |
download | cuberite-0aa1b5667e0ba97101f60343323c595cc7866c6d.tar cuberite-0aa1b5667e0ba97101f60343323c595cc7866c6d.tar.gz cuberite-0aa1b5667e0ba97101f60343323c595cc7866c6d.tar.bz2 cuberite-0aa1b5667e0ba97101f60343323c595cc7866c6d.tar.lz cuberite-0aa1b5667e0ba97101f60343323c595cc7866c6d.tar.xz cuberite-0aa1b5667e0ba97101f60343323c595cc7866c6d.tar.zst cuberite-0aa1b5667e0ba97101f60343323c595cc7866c6d.zip |
Diffstat (limited to 'Tools/QtBiomeVisualiser/BiomeView.cpp')
-rw-r--r-- | Tools/QtBiomeVisualiser/BiomeView.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Tools/QtBiomeVisualiser/BiomeView.cpp b/Tools/QtBiomeVisualiser/BiomeView.cpp index 8d53c8626..b44b935d7 100644 --- a/Tools/QtBiomeVisualiser/BiomeView.cpp +++ b/Tools/QtBiomeVisualiser/BiomeView.cpp @@ -42,8 +42,9 @@ BiomeView::BiomeView(QWidget * parent) : // Add a chunk-update callback mechanism: connect(&m_Cache, SIGNAL(chunkAvailable(int, int)), this, SLOT(chunkAvailable(int, int))); - // Allow keyboard interaction: + // Allow mouse and keyboard interaction: setFocusPolicy(Qt::StrongFocus); + setMouseTracking(true); } @@ -296,6 +297,12 @@ void BiomeView::mousePressEvent(QMouseEvent * a_Event) void BiomeView::mouseMoveEvent(QMouseEvent * a_Event) { + // If there's no data displayed, bail out: + if (!hasData()) + { + return; + } + if (m_IsMouseDragging) { // The user is dragging the mouse, move the view around: @@ -307,7 +314,15 @@ void BiomeView::mouseMoveEvent(QMouseEvent * a_Event) return; } - // TODO: Update the status bar info for the biome currently pointed at + // Update the status bar info text: + int blockX = floor((a_Event->x() - width() / 2) / m_Zoom + m_X); + int blockZ = floor((a_Event->y() - height() / 2) / m_Zoom + m_Z); + int chunkX, chunkZ; + int relX = blockX, relY, relZ = blockZ; + cChunkDef::AbsoluteToRelative(relX, relY, relZ, chunkX, chunkZ); + auto chunk = m_Cache.fetch(chunkX, chunkZ); + int biome = (chunk.get() != nullptr) ? chunk->getBiome(relX, relZ) : biInvalidBiome; + emit hoverChanged(blockX, blockZ, biome); } |