Skip to content

Commit

Permalink
[Config|SettingsMenuState] Added option to disable BlockInfoWidget.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed Feb 24, 2020
1 parent 6e506d8 commit 7c9b72b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
3 changes: 3 additions & 0 deletions client/include/core/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ namespace Config {
extern bool isFlyModeEnabled;
extern bool isNoClipEnabled;

// Interface
extern bool isBlockInfoWidgetEnabled;

// Graphics
extern u16 renderDistance;
extern bool isTorchSmoothLightingEnabled;
Expand Down
1 change: 1 addition & 0 deletions client/include/states/SettingsMenuState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class SettingsMenuState : public InterfaceState {

void addMainButtons();
void addGameplayButtons();
void addInterfaceButtons();
void addGraphicsButtons();
void addInputButtons();

Expand Down
5 changes: 5 additions & 0 deletions client/source/core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
bool Config::isFlyModeEnabled = false;
bool Config::isNoClipEnabled = false;

// Interface
bool Config::isBlockInfoWidgetEnabled = true;

// Graphics
u16 Config::renderDistance = 8;
bool Config::isTorchSmoothLightingEnabled = true;
Expand Down Expand Up @@ -57,6 +60,8 @@ void Config::loadConfigFromFile(const char *file) {
isFlyModeEnabled = lua["isFlyModeEnabled"].get_or(isFlyModeEnabled);
isNoClipEnabled = lua["isNoClipEnabled"].get_or(isNoClipEnabled);

isBlockInfoWidgetEnabled = lua["isBlockInfoWidgetEnabled"].get_or(isBlockInfoWidgetEnabled);

renderDistance = lua["renderDistance"].get_or(renderDistance);
isTorchSmoothLightingEnabled = lua["isTorchSmoothLightingEnabled"].get_or(isTorchSmoothLightingEnabled);
isSunSmoothLightingEnabled = lua["isSunSmoothLightingEnabled"].get_or(isSunSmoothLightingEnabled);
Expand Down
12 changes: 8 additions & 4 deletions client/source/hud/HUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ void HUD::update() {
if (m_isDebugOverlayVisible)
m_debugOverlay.update();

m_blockInfoWidget.update();
if (Config::isBlockInfoWidgetEnabled) {
m_blockInfoWidget.update();

if (m_blockCursor.currentBlock() != m_blockInfoWidget.currentBlock())
m_blockInfoWidget.setCurrentBlock(m_blockCursor.currentBlock());
if (m_blockCursor.currentBlock() != m_blockInfoWidget.currentBlock())
m_blockInfoWidget.setCurrentBlock(m_blockCursor.currentBlock());
}
}

void HUD::draw(gk::RenderTarget &target, gk::RenderStates states) const {
Expand All @@ -97,7 +99,9 @@ void HUD::draw(gk::RenderTarget &target, gk::RenderStates states) const {
if (m_isDebugOverlayVisible)
target.draw(m_debugOverlay, states);

target.draw(m_blockInfoWidget, states);
if (Config::isBlockInfoWidgetEnabled)
target.draw(m_blockInfoWidget, states);

target.draw(m_hotbar, states);
target.draw(m_fpsText, states);
target.draw(m_chat, states);
Expand Down
11 changes: 11 additions & 0 deletions client/source/states/SettingsMenuState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ void SettingsMenuState::addMainButtons() {
addGameplayButtons();
});

m_menuWidget.addButton("Interface...", [this] (TextButton &) {
m_state = MenuState::Gameplay;
addInterfaceButtons();
});

m_menuWidget.addButton("Graphics...", [this] (TextButton &) {
m_state = MenuState::Graphics;
addGraphicsButtons();
Expand All @@ -112,6 +117,12 @@ void SettingsMenuState::addGameplayButtons() {
addToggleButton("No Clip", Config::isNoClipEnabled, false);
}

void SettingsMenuState::addInterfaceButtons() {
m_menuWidget.reset(1, 8);

addToggleButton("Show block info", Config::isBlockInfoWidgetEnabled, false);
}

void SettingsMenuState::addGraphicsButtons() {
m_menuWidget.reset(2, 8);

Expand Down

0 comments on commit 7c9b72b

Please sign in to comment.