[Minimap] Events are now only executed if minimap is enabled.

This commit is contained in:
Quentin Bazin 2020-07-30 12:27:54 +02:00
parent 4eb3b6fe5f
commit ae571dbe81
2 changed files with 12 additions and 7 deletions

1
.gitignore vendored
View File

@ -58,6 +58,7 @@ build_win32
build_win64
build_msvc
build_mingw
build_debug
deploy
openminer
openminer_server

View File

@ -86,16 +86,20 @@ void Minimap::update(const ClientPlayer &player, class ClientWorld &world) {
}
void Minimap::onChunkCreatedEvent(const ChunkCreatedEvent &event) {
auto &rect = m_chunks[event.chunkPos];
rect.setSize(chunkSize, chunkSize);
rect.setPosition(event.chunkPos.x * (chunkSize + 2), -event.chunkPos.y * (chunkSize + 2));
rect.setFillColor(event.isLoaded ? gk::Color{224, 224, 224} : gk::Color{127, 127, 127});
rect.setOutlineThickness(1);
rect.setOutlineColor(gk::Color::Transparent);
if (Config::isChunkMinimapEnabled) {
auto &rect = m_chunks[event.chunkPos];
rect.setSize(chunkSize, chunkSize);
rect.setPosition(event.chunkPos.x * (chunkSize + 2), -event.chunkPos.y * (chunkSize + 2));
rect.setFillColor(event.isLoaded ? gk::Color{224, 224, 224} : gk::Color{127, 127, 127});
rect.setOutlineThickness(1);
rect.setOutlineColor(gk::Color::Transparent);
}
}
void Minimap::onChunkRemovedEvent(const ChunkRemovedEvent &event) {
m_chunks.erase(event.chunkPos);
if (Config::isChunkMinimapEnabled) {
m_chunks.erase(event.chunkPos);
}
}
void Minimap::updatePlayerFovVertexBuffer() {