diff --git a/client/source/core/Config.cpp b/client/source/core/Config.cpp index 2a931dd9a..ba12aee7e 100644 --- a/client/source/core/Config.cpp +++ b/client/source/core/Config.cpp @@ -32,6 +32,9 @@ bool Config::isNoClipEnabled = false; // Interface bool Config::isBlockInfoWidgetEnabled = true; +bool Config::isFpsCounterEnabled = true; +bool Config::isHotbarVisible = true; +bool Config::isCrosshairVisible = true; // Graphics u16 Config::renderDistance = 8; @@ -66,6 +69,9 @@ void Config::loadConfigFromFile(const char *file) { isNoClipEnabled = lua["isNoClipEnabled"].get_or(isNoClipEnabled); isBlockInfoWidgetEnabled = lua["isBlockInfoWidgetEnabled"].get_or(isBlockInfoWidgetEnabled); + isFpsCounterEnabled = lua["isFpsCounterEnabled"].get_or(isFpsCounterEnabled); + isHotbarVisible = lua["isHotbarVisible"].get_or(isHotbarVisible); + isCrosshairVisible = lua["isCrosshairVisible"].get_or(isCrosshairVisible); renderDistance = lua["renderDistance"].get_or(renderDistance); isTorchSmoothLightingEnabled = lua["isTorchSmoothLightingEnabled"].get_or(isTorchSmoothLightingEnabled); diff --git a/client/source/core/Config.hpp b/client/source/core/Config.hpp index 4ad4922b1..875261efd 100644 --- a/client/source/core/Config.hpp +++ b/client/source/core/Config.hpp @@ -36,6 +36,9 @@ namespace Config { // Interface extern bool isBlockInfoWidgetEnabled; + extern bool isFpsCounterEnabled; + extern bool isHotbarVisible; + extern bool isCrosshairVisible; // Graphics extern u16 renderDistance; diff --git a/client/source/hud/HUD.cpp b/client/source/hud/HUD.cpp index 6aca936e3..294717f49 100644 --- a/client/source/hud/HUD.cpp +++ b/client/source/hud/HUD.cpp @@ -65,15 +65,19 @@ void HUD::onEvent(const SDL_Event &event) { if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_F3) m_isDebugOverlayVisible ^= 1; - m_hotbar.onEvent(event); + if (Config::isHotbarVisible) + m_hotbar.onEvent(event); + m_blockCursor.onEvent(event, m_hotbar); } void HUD::update() { // FIXME: Shouldn't be called every tick - m_hotbar.update(); + if (Config::isHotbarVisible) + m_hotbar.update(); - m_fpsText.setText(std::to_string(gk::GameClock::getFpsAverage()) + " FPS"); + if (Config::isFpsCounterEnabled) + m_fpsText.setText(std::to_string(gk::GameClock::getFpsAverage()) + " FPS"); m_blockCursor.update(m_hotbar); @@ -106,12 +110,17 @@ void HUD::draw(gk::RenderTarget &target, gk::RenderStates states) const { if (Config::isBlockInfoWidgetEnabled) target.draw(m_blockInfoWidget, states); - target.draw(m_hotbar, states); - target.draw(m_fpsText, states); + if (Config::isHotbarVisible) + target.draw(m_hotbar, states); + + if (Config::isFpsCounterEnabled) + target.draw(m_fpsText, states); + target.draw(m_chat, states); states.transform = gk::Transform::Identity; - target.draw(m_crosshair, states); + if (Config::isCrosshairVisible) + target.draw(m_crosshair, states); } diff --git a/client/source/states/ServerConnectState.cpp b/client/source/states/ServerConnectState.cpp index 0f4a4c6ed..beaa8aa3a 100644 --- a/client/source/states/ServerConnectState.cpp +++ b/client/source/states/ServerConnectState.cpp @@ -30,7 +30,7 @@ #include "ServerConnectState.hpp" #include "ServerLoadingState.hpp" -ServerConnectState::ServerConnectState() { +ServerConnectState::ServerConnectState(gk::ApplicationState *parent) : InterfaceState(parent) { m_textInput.setContent("localhost:4242"); m_textInput.setCharacterLimit(15 + 1 + 6); m_textInput.setSize(400, 54); @@ -86,6 +86,9 @@ void ServerConnectState::update() { } void ServerConnectState::draw(gk::RenderTarget &target, gk::RenderStates states) const { + if (m_parent) + target.draw(*m_parent, states); + prepareDraw(target, states); target.draw(m_textInput, states); diff --git a/client/source/states/ServerConnectState.hpp b/client/source/states/ServerConnectState.hpp index fcb07b3d4..8f0702f6d 100644 --- a/client/source/states/ServerConnectState.hpp +++ b/client/source/states/ServerConnectState.hpp @@ -34,7 +34,7 @@ class ServerConnectState : public InterfaceState { public: - ServerConnectState(); + ServerConnectState(gk::ApplicationState *parent = nullptr); void onEvent(const SDL_Event &event) override; diff --git a/client/source/states/SettingsMenuState.cpp b/client/source/states/SettingsMenuState.cpp index ef4017319..e68ede330 100644 --- a/client/source/states/SettingsMenuState.cpp +++ b/client/source/states/SettingsMenuState.cpp @@ -122,6 +122,9 @@ void SettingsMenuState::addInterfaceButtons() { m_menuWidget.reset(1, 8); addToggleButton("Show block info", Config::isBlockInfoWidgetEnabled, false); + addToggleButton("Show FPS counter", Config::isFpsCounterEnabled, false); + addToggleButton("Show hotbar", Config::isHotbarVisible, false); + addToggleButton("Show crosshair", Config::isCrosshairVisible, false); } void SettingsMenuState::addGraphicsButtons() { diff --git a/client/source/states/TitleScreenState.cpp b/client/source/states/TitleScreenState.cpp index 1b35f4b81..649f9a98e 100644 --- a/client/source/states/TitleScreenState.cpp +++ b/client/source/states/TitleScreenState.cpp @@ -37,7 +37,7 @@ TitleScreenState::TitleScreenState() { m_menuWidget.setScale(Config::guiScale, Config::guiScale, 1); m_menuWidget.addButton("Play", [this] (TextButton &) { - m_stateStack->push(); + m_stateStack->push(this); }); m_menuWidget.addButton("Options...", [this] (TextButton &) { @@ -59,9 +59,11 @@ void TitleScreenState::update() { } void TitleScreenState::draw(gk::RenderTarget &target, gk::RenderStates states) const { - if (&m_stateStack->top() == this) { - prepareDraw(target, states); + prepareDraw(target, states); + + target.draw(m_background, states); + if (&m_stateStack->top() == this) { target.draw(m_menuWidget, states); } } diff --git a/client/source/states/TitleScreenState.hpp b/client/source/states/TitleScreenState.hpp index 9f8fc14d2..95825be82 100644 --- a/client/source/states/TitleScreenState.hpp +++ b/client/source/states/TitleScreenState.hpp @@ -42,6 +42,8 @@ class TitleScreenState : public InterfaceState { void draw(gk::RenderTarget &target, gk::RenderStates states) const override; MenuWidget m_menuWidget{1, 3}; + + gk::Image m_background{"texture-title_screen"}; }; #endif // TITLESCREENSTATE_HPP_ diff --git a/resources/config/textures.xml b/resources/config/textures.xml index e4fd054b3..fdbd17562 100644 --- a/resources/config/textures.xml +++ b/resources/config/textures.xml @@ -5,6 +5,7 @@ + diff --git a/resources/textures/title_screen.png b/resources/textures/title_screen.png new file mode 100644 index 000000000..8610c72b7 Binary files /dev/null and b/resources/textures/title_screen.png differ