diff --git a/source/client/core/Config.cpp b/source/client/core/Config.cpp index b354f1d2a..81e3a39f4 100644 --- a/source/client/core/Config.cpp +++ b/source/client/core/Config.cpp @@ -65,6 +65,9 @@ u8 Config::mipmapLevels = 0; // Input u8 Config::mouseSensitivity = 8; +// Debug +bool Config::isChunkMinimapEnabled = false; + // Other std::string Config::defaultUsername = ""; std::string Config::defaultServerAddress = "localhost:4242"; @@ -106,6 +109,8 @@ void Config::loadConfigFromFile(const char *filename) { mouseSensitivity = lua["mouseSensitivity"].get_or(mouseSensitivity); + isChunkMinimapEnabled = lua["isChunkMinimapEnabled"].get_or(isChunkMinimapEnabled); + defaultUsername = lua["defaultUsername"].get_or(defaultUsername); defaultServerAddress = lua["defaultServerAddress"].get_or(defaultServerAddress); texturePack = lua["texturePack"].get_or(texturePack); @@ -144,6 +149,8 @@ void Config::saveConfigToFile(const char *filename) { file << std::endl; file << "mouseSensitivity = " << (u16)mouseSensitivity << std::endl; file << std::endl; + file << "isChunkMinimapEnabled = " << (isChunkMinimapEnabled ? "true" : "false") << std::endl; + file << std::endl; file << "defaultUsername = \"" << defaultUsername << "\"" << std::endl; file << "defaultServerAddress = \"" << defaultServerAddress << "\"" << std::endl; file << "texturePack = \"" << texturePack << "\"" << std::endl; diff --git a/source/client/core/Config.hpp b/source/client/core/Config.hpp index 9f57388e7..57ffd519d 100644 --- a/source/client/core/Config.hpp +++ b/source/client/core/Config.hpp @@ -60,6 +60,9 @@ namespace Config { // Input extern u8 mouseSensitivity; + // Debug + extern bool isChunkMinimapEnabled; + // Other extern std::string defaultUsername; extern std::string defaultServerAddress; diff --git a/source/client/hud/HUD.cpp b/source/client/hud/HUD.cpp index 738027945..d97b53f33 100644 --- a/source/client/hud/HUD.cpp +++ b/source/client/hud/HUD.cpp @@ -65,7 +65,6 @@ void HUD::setup() { m_chat.setPosition(2, Config::screenHeight / Config::guiScale - 50); m_minimap.setPosition(Config::screenWidth / Config::guiScale - Minimap::minimapSize - 15, 15); - // m_minimap.setPosition(Config::screenWidth / Config::guiScale - Minimap::minimapSize - 10 - Minimap::minimapSize / 2, 10 - Minimap::minimapSize / 2); } void HUD::onEvent(const SDL_Event &event) { @@ -104,7 +103,8 @@ void HUD::update() { m_blockInfoWidget.setCurrentBlock(m_blockCursor.currentBlock()); } - m_minimap.update(m_player, m_world); + if (Config::isChunkMinimapEnabled) + m_minimap.update(m_player, m_world); } void HUD::draw(gk::RenderTarget &target, gk::RenderStates states) const { @@ -129,7 +129,8 @@ void HUD::draw(gk::RenderTarget &target, gk::RenderStates states) const { if (Config::isFpsCounterEnabled) target.draw(m_fpsText, states); - target.draw(m_minimap, states); + if (Config::isChunkMinimapEnabled) + target.draw(m_minimap, states); target.draw(m_chat, states); diff --git a/source/client/states/SettingsMenuState.cpp b/source/client/states/SettingsMenuState.cpp index f0b4da5c2..81eca2a8c 100644 --- a/source/client/states/SettingsMenuState.cpp +++ b/source/client/states/SettingsMenuState.cpp @@ -168,6 +168,11 @@ void SettingsMenuState::addMainButtons() { addInputButtons(); }); + m_menuWidget.addButton("Debug...", [this] (TextButton &) { + m_state = MenuState::Debug; + addDebugButtons(); + }); + m_menuWidget.addButton("Texture Pack...", [this] (TextButton &) { m_stateStack->push(this); }); @@ -293,6 +298,14 @@ void SettingsMenuState::addInputButtons() { updateWidgetPosition(); } +void SettingsMenuState::addDebugButtons() { + m_menuWidget.reset(1, 8); + + addToggleButton("Show chunk minimap", Config::isChunkMinimapEnabled, false); + + updateWidgetPosition(); +} + TextButton &SettingsMenuState::addToggleButton(const std::string &text, bool &configOption, bool worldReloadRequested) { return m_menuWidget.addButton(text + ": " + (configOption ? "ON" : "OFF"), [=, &configOption] (TextButton &button) { configOption = !configOption; diff --git a/source/client/states/SettingsMenuState.hpp b/source/client/states/SettingsMenuState.hpp index 6a4d8c174..f352a0be2 100644 --- a/source/client/states/SettingsMenuState.hpp +++ b/source/client/states/SettingsMenuState.hpp @@ -56,6 +56,7 @@ class SettingsMenuState : public InterfaceState { void addInterfaceButtons(); void addGraphicsButtons(); void addInputButtons(); + void addDebugButtons(); TextButton &addToggleButton(const std::string &text, bool &configOption, bool worldReloadRequested = false); @@ -78,7 +79,8 @@ class SettingsMenuState : public InterfaceState { Main, Gameplay, Graphics, - Input + Input, + Debug }; MenuState m_state = MenuState::Main;