Skip to content

Commit

Permalink
Debug option to hide player HUD (including LevelTime counter)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vankata453 committed Dec 19, 2024
1 parent 158d454 commit 0584675
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/object/level_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "editor/editor.hpp"
#include "object/player.hpp"
#include "supertux/debug.hpp"
#include "supertux/game_session.hpp"
#include "supertux/resources.hpp"
#include "supertux/sector.hpp"
Expand Down Expand Up @@ -104,8 +105,9 @@ LevelTime::update(float dt_sec)
void
LevelTime::draw(DrawingContext& context)
{
if (Editor::is_active())
if (g_debug.hide_player_hud || Editor::is_active())
return;

context.push_transform();
context.set_translation(Vector(0, 0));
context.transform().scale = 1.f;
Expand Down
1 change: 1 addition & 0 deletions src/supertux/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Debug::Debug() :
show_worldmap_path(false),
draw_redundant_frames(false),
show_toolbox_tile_ids(false),
hide_player_hud(false),
m_use_bitmap_fonts(false),
m_game_speed_multiplier(1.0f)
{
Expand Down
4 changes: 4 additions & 0 deletions src/supertux/debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ class Debug
// vaguely measure the impact of code changes which should increase the FPS
bool draw_redundant_frames;

/** Draw tile IDs in editor toolbox */
bool show_toolbox_tile_ids;

/** Do not draw PlayerStatusHUD and LevelTime */
bool hide_player_hud;

private:
/** Use old bitmap fonts instead of TTF */
bool m_use_bitmap_fonts;
Expand Down
1 change: 1 addition & 0 deletions src/supertux/menu/debug_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ DebugMenu::DebugMenu() :
[]{ return g_debug.get_use_bitmap_fonts(); },
[](bool value){ g_debug.set_use_bitmap_fonts(value); });
add_toggle(-1, _("Show Tile IDs in Editor Toolbox"), &g_debug.show_toolbox_tile_ids);
add_toggle(-1, _("Hide Player HUD"), &g_debug.hide_player_hud);

add_entry(_("Reload Resources"), &Resources::reload_all)
.set_help(_("Reloads all fonts, textures, sprites and tilesets."));
Expand Down
3 changes: 2 additions & 1 deletion src/supertux/player_status_hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <iostream>

#include "sprite/sprite_manager.hpp"
#include "supertux/debug.hpp"
#include "supertux/game_object.hpp"
#include "supertux/level.hpp"
#include "supertux/player_status.hpp"
Expand Down Expand Up @@ -60,7 +61,7 @@ PlayerStatusHUD::update(float dt_sec)
void
PlayerStatusHUD::draw(DrawingContext& context)
{
if (Editor::is_active())
if (g_debug.hide_player_hud || Editor::is_active())
return;

if ((displayed_coins == DISPLAYED_COINS_UNSET) ||
Expand Down

0 comments on commit 0584675

Please sign in to comment.