mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 01:53:45 +01:00
Readd basic_debug as a HUD flag (#12020)
This commit is contained in:
parent
44fc888bd6
commit
b9e886726c
@ -6772,17 +6772,18 @@ object you are working with still exists.
|
|||||||
* `hud_get(id)`: gets the HUD element definition structure of the specified ID
|
* `hud_get(id)`: gets the HUD element definition structure of the specified ID
|
||||||
* `hud_set_flags(flags)`: sets specified HUD flags of player.
|
* `hud_set_flags(flags)`: sets specified HUD flags of player.
|
||||||
* `flags`: A table with the following fields set to boolean values
|
* `flags`: A table with the following fields set to boolean values
|
||||||
* hotbar
|
* `hotbar`
|
||||||
* healthbar
|
* `healthbar`
|
||||||
* crosshair
|
* `crosshair`
|
||||||
* wielditem
|
* `wielditem`
|
||||||
* breathbar
|
* `breathbar`
|
||||||
* minimap
|
* `minimap`: Modifies the client's permission to view the minimap.
|
||||||
* minimap_radar
|
The client may locally elect to not view the minimap.
|
||||||
|
* `minimap_radar`: is only usable when `minimap` is true
|
||||||
|
* `basic_debug`: Allow showing basic debug info that might give a gameplay advantage.
|
||||||
|
This includes map seed, player position, look direction, the pointed node and block bounds.
|
||||||
|
Does not affect players with the `debug` privilege.
|
||||||
* If a flag equals `nil`, the flag is not modified
|
* If a flag equals `nil`, the flag is not modified
|
||||||
* `minimap`: Modifies the client's permission to view the minimap.
|
|
||||||
The client may locally elect to not view the minimap.
|
|
||||||
* `minimap_radar` is only usable when `minimap` is true
|
|
||||||
* `hud_get_flags()`: returns a table of player HUD flags with boolean values.
|
* `hud_get_flags()`: returns a table of player HUD flags with boolean values.
|
||||||
* See `hud_set_flags` for a list of flags that can be toggled.
|
* See `hud_set_flags` for a list of flags that can be toggled.
|
||||||
* `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
|
* `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
|
||||||
|
@ -723,7 +723,7 @@ protected:
|
|||||||
void processClientEvents(CameraOrientation *cam);
|
void processClientEvents(CameraOrientation *cam);
|
||||||
void updateCamera(f32 dtime);
|
void updateCamera(f32 dtime);
|
||||||
void updateSound(f32 dtime);
|
void updateSound(f32 dtime);
|
||||||
void processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug);
|
void processPlayerInteraction(f32 dtime, bool show_hud);
|
||||||
/*!
|
/*!
|
||||||
* Returns the object or node the player is pointing at.
|
* Returns the object or node the player is pointing at.
|
||||||
* Also updates the selected thing in the Hud.
|
* Also updates the selected thing in the Hud.
|
||||||
@ -1134,8 +1134,7 @@ void Game::run()
|
|||||||
updateDebugState();
|
updateDebugState();
|
||||||
updateCamera(dtime);
|
updateCamera(dtime);
|
||||||
updateSound(dtime);
|
updateSound(dtime);
|
||||||
processPlayerInteraction(dtime, m_game_ui->m_flags.show_hud,
|
processPlayerInteraction(dtime, m_game_ui->m_flags.show_hud);
|
||||||
m_game_ui->m_flags.show_basic_debug);
|
|
||||||
updateFrame(&graph, &stats, dtime, cam_view);
|
updateFrame(&graph, &stats, dtime, cam_view);
|
||||||
updateProfilerGraphs(&graph);
|
updateProfilerGraphs(&graph);
|
||||||
|
|
||||||
@ -1740,17 +1739,16 @@ void Game::processQueues()
|
|||||||
|
|
||||||
void Game::updateDebugState()
|
void Game::updateDebugState()
|
||||||
{
|
{
|
||||||
const bool has_basic_debug = true;
|
LocalPlayer *player = client->getEnv().getLocalPlayer();
|
||||||
bool has_debug = client->checkPrivilege("debug");
|
bool has_debug = client->checkPrivilege("debug");
|
||||||
|
bool has_basic_debug = has_debug || (player->hud_flags & HUD_FLAG_BASIC_DEBUG);
|
||||||
|
|
||||||
if (m_game_ui->m_flags.show_basic_debug) {
|
if (m_game_ui->m_flags.show_basic_debug) {
|
||||||
if (!has_basic_debug) {
|
if (!has_basic_debug)
|
||||||
m_game_ui->m_flags.show_basic_debug = false;
|
m_game_ui->m_flags.show_basic_debug = false;
|
||||||
}
|
|
||||||
} else if (m_game_ui->m_flags.show_minimal_debug) {
|
} else if (m_game_ui->m_flags.show_minimal_debug) {
|
||||||
if (has_basic_debug) {
|
if (has_basic_debug)
|
||||||
m_game_ui->m_flags.show_basic_debug = true;
|
m_game_ui->m_flags.show_basic_debug = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!has_basic_debug)
|
if (!has_basic_debug)
|
||||||
hud->disableBlockBounds();
|
hud->disableBlockBounds();
|
||||||
@ -2211,27 +2209,27 @@ void Game::toggleCinematic()
|
|||||||
|
|
||||||
void Game::toggleBlockBounds()
|
void Game::toggleBlockBounds()
|
||||||
{
|
{
|
||||||
if (true /* basic_debug */) {
|
LocalPlayer *player = client->getEnv().getLocalPlayer();
|
||||||
enum Hud::BlockBoundsMode newmode = hud->toggleBlockBounds();
|
if (!(client->checkPrivilege("debug") || (player->hud_flags & HUD_FLAG_BASIC_DEBUG))) {
|
||||||
switch (newmode) {
|
m_game_ui->showTranslatedStatusText("Can't show block bounds (disabled by mod or game)");
|
||||||
case Hud::BLOCK_BOUNDS_OFF:
|
return;
|
||||||
m_game_ui->showTranslatedStatusText("Block bounds hidden");
|
}
|
||||||
break;
|
enum Hud::BlockBoundsMode newmode = hud->toggleBlockBounds();
|
||||||
case Hud::BLOCK_BOUNDS_CURRENT:
|
switch (newmode) {
|
||||||
m_game_ui->showTranslatedStatusText("Block bounds shown for current block");
|
case Hud::BLOCK_BOUNDS_OFF:
|
||||||
break;
|
m_game_ui->showTranslatedStatusText("Block bounds hidden");
|
||||||
case Hud::BLOCK_BOUNDS_NEAR:
|
break;
|
||||||
m_game_ui->showTranslatedStatusText("Block bounds shown for nearby blocks");
|
case Hud::BLOCK_BOUNDS_CURRENT:
|
||||||
break;
|
m_game_ui->showTranslatedStatusText("Block bounds shown for current block");
|
||||||
case Hud::BLOCK_BOUNDS_MAX:
|
break;
|
||||||
m_game_ui->showTranslatedStatusText("Block bounds shown for all blocks");
|
case Hud::BLOCK_BOUNDS_NEAR:
|
||||||
break;
|
m_game_ui->showTranslatedStatusText("Block bounds shown for nearby blocks");
|
||||||
default:
|
break;
|
||||||
break;
|
case Hud::BLOCK_BOUNDS_MAX:
|
||||||
}
|
m_game_ui->showTranslatedStatusText("Block bounds shown for all blocks");
|
||||||
|
break;
|
||||||
} else {
|
default:
|
||||||
m_game_ui->showTranslatedStatusText("Can't show block bounds (need 'basic_debug' privilege)");
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2298,6 +2296,9 @@ void Game::toggleFog()
|
|||||||
|
|
||||||
void Game::toggleDebug()
|
void Game::toggleDebug()
|
||||||
{
|
{
|
||||||
|
LocalPlayer *player = client->getEnv().getLocalPlayer();
|
||||||
|
bool has_debug = client->checkPrivilege("debug");
|
||||||
|
bool has_basic_debug = has_debug || (player->hud_flags & HUD_FLAG_BASIC_DEBUG);
|
||||||
// Initial: No debug info
|
// Initial: No debug info
|
||||||
// 1x toggle: Debug text
|
// 1x toggle: Debug text
|
||||||
// 2x toggle: Debug text with profiler graph
|
// 2x toggle: Debug text with profiler graph
|
||||||
@ -2307,9 +2308,8 @@ void Game::toggleDebug()
|
|||||||
// The debug text can be in 2 modes: minimal and basic.
|
// The debug text can be in 2 modes: minimal and basic.
|
||||||
// * Minimal: Only technical client info that not gameplay-relevant
|
// * Minimal: Only technical client info that not gameplay-relevant
|
||||||
// * Basic: Info that might give gameplay advantage, e.g. pos, angle
|
// * Basic: Info that might give gameplay advantage, e.g. pos, angle
|
||||||
// Basic mode is always used.
|
// Basic mode is used when player has the debug HUD flag set,
|
||||||
|
// otherwise the Minimal mode is used.
|
||||||
const bool has_basic_debug = true;
|
|
||||||
if (!m_game_ui->m_flags.show_minimal_debug) {
|
if (!m_game_ui->m_flags.show_minimal_debug) {
|
||||||
m_game_ui->m_flags.show_minimal_debug = true;
|
m_game_ui->m_flags.show_minimal_debug = true;
|
||||||
if (has_basic_debug)
|
if (has_basic_debug)
|
||||||
@ -2333,7 +2333,7 @@ void Game::toggleDebug()
|
|||||||
m_game_ui->m_flags.show_basic_debug = false;
|
m_game_ui->m_flags.show_basic_debug = false;
|
||||||
m_game_ui->m_flags.show_profiler_graph = false;
|
m_game_ui->m_flags.show_profiler_graph = false;
|
||||||
draw_control->show_wireframe = false;
|
draw_control->show_wireframe = false;
|
||||||
if (client->checkPrivilege("debug")) {
|
if (has_debug) {
|
||||||
m_game_ui->showTranslatedStatusText("Debug info, profiler graph, and wireframe hidden");
|
m_game_ui->showTranslatedStatusText("Debug info, profiler graph, and wireframe hidden");
|
||||||
} else {
|
} else {
|
||||||
m_game_ui->showTranslatedStatusText("Debug info and profiler graph hidden");
|
m_game_ui->showTranslatedStatusText("Debug info and profiler graph hidden");
|
||||||
@ -3039,7 +3039,7 @@ void Game::updateSound(f32 dtime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
|
void Game::processPlayerInteraction(f32 dtime, bool show_hud)
|
||||||
{
|
{
|
||||||
LocalPlayer *player = client->getEnv().getLocalPlayer();
|
LocalPlayer *player = client->getEnv().getLocalPlayer();
|
||||||
|
|
||||||
@ -3157,7 +3157,8 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
|
|||||||
handlePointingAtNode(pointed, selected_item, hand_item, dtime);
|
handlePointingAtNode(pointed, selected_item, hand_item, dtime);
|
||||||
} else if (pointed.type == POINTEDTHING_OBJECT) {
|
} else if (pointed.type == POINTEDTHING_OBJECT) {
|
||||||
v3f player_position = player->getPosition();
|
v3f player_position = player->getPosition();
|
||||||
handlePointingAtObject(pointed, tool_item, player_position, show_debug);
|
handlePointingAtObject(pointed, tool_item, player_position,
|
||||||
|
client->checkPrivilege("debug") || (player->hud_flags & HUD_FLAG_BASIC_DEBUG));
|
||||||
} else if (isKeyDown(KeyType::DIG)) {
|
} else if (isKeyDown(KeyType::DIG)) {
|
||||||
// When button is held down in air, show continuous animation
|
// When button is held down in air, show continuous animation
|
||||||
runData.punching = true;
|
runData.punching = true;
|
||||||
|
@ -63,5 +63,6 @@ const struct EnumString es_HudBuiltinElement[] =
|
|||||||
{HUD_FLAG_BREATHBAR_VISIBLE, "breathbar"},
|
{HUD_FLAG_BREATHBAR_VISIBLE, "breathbar"},
|
||||||
{HUD_FLAG_MINIMAP_VISIBLE, "minimap"},
|
{HUD_FLAG_MINIMAP_VISIBLE, "minimap"},
|
||||||
{HUD_FLAG_MINIMAP_RADAR_VISIBLE, "minimap_radar"},
|
{HUD_FLAG_MINIMAP_RADAR_VISIBLE, "minimap_radar"},
|
||||||
|
{HUD_FLAG_BASIC_DEBUG, "basic_debug"},
|
||||||
{0, NULL},
|
{0, NULL},
|
||||||
};
|
};
|
||||||
|
@ -47,6 +47,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#define HUD_FLAG_BREATHBAR_VISIBLE (1 << 4)
|
#define HUD_FLAG_BREATHBAR_VISIBLE (1 << 4)
|
||||||
#define HUD_FLAG_MINIMAP_VISIBLE (1 << 5)
|
#define HUD_FLAG_MINIMAP_VISIBLE (1 << 5)
|
||||||
#define HUD_FLAG_MINIMAP_RADAR_VISIBLE (1 << 6)
|
#define HUD_FLAG_MINIMAP_RADAR_VISIBLE (1 << 6)
|
||||||
|
#define HUD_FLAG_BASIC_DEBUG (1 << 7)
|
||||||
|
|
||||||
#define HUD_PARAM_HOTBAR_ITEMCOUNT 1
|
#define HUD_PARAM_HOTBAR_ITEMCOUNT 1
|
||||||
#define HUD_PARAM_HOTBAR_IMAGE 2
|
#define HUD_PARAM_HOTBAR_IMAGE 2
|
||||||
|
@ -71,7 +71,7 @@ Player::Player(const char *name, IItemDefManager *idef):
|
|||||||
HUD_FLAG_HOTBAR_VISIBLE | HUD_FLAG_HEALTHBAR_VISIBLE |
|
HUD_FLAG_HOTBAR_VISIBLE | HUD_FLAG_HEALTHBAR_VISIBLE |
|
||||||
HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE |
|
HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE |
|
||||||
HUD_FLAG_BREATHBAR_VISIBLE | HUD_FLAG_MINIMAP_VISIBLE |
|
HUD_FLAG_BREATHBAR_VISIBLE | HUD_FLAG_MINIMAP_VISIBLE |
|
||||||
HUD_FLAG_MINIMAP_RADAR_VISIBLE;
|
HUD_FLAG_MINIMAP_RADAR_VISIBLE | HUD_FLAG_BASIC_DEBUG;
|
||||||
|
|
||||||
hud_hotbar_itemcount = HUD_HOTBAR_ITEMCOUNT_DEFAULT;
|
hud_hotbar_itemcount = HUD_HOTBAR_ITEMCOUNT_DEFAULT;
|
||||||
|
|
||||||
|
@ -1617,20 +1617,11 @@ int ObjectRef::l_hud_get_flags(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
lua_pushboolean(L, player->hud_flags & HUD_FLAG_HOTBAR_VISIBLE);
|
const EnumString *esp = es_HudBuiltinElement;
|
||||||
lua_setfield(L, -2, "hotbar");
|
for (int i = 0; esp[i].str; i++) {
|
||||||
lua_pushboolean(L, player->hud_flags & HUD_FLAG_HEALTHBAR_VISIBLE);
|
lua_pushboolean(L, (player->hud_flags & esp[i].num) != 0);
|
||||||
lua_setfield(L, -2, "healthbar");
|
lua_setfield(L, -2, esp[i].str);
|
||||||
lua_pushboolean(L, player->hud_flags & HUD_FLAG_CROSSHAIR_VISIBLE);
|
}
|
||||||
lua_setfield(L, -2, "crosshair");
|
|
||||||
lua_pushboolean(L, player->hud_flags & HUD_FLAG_WIELDITEM_VISIBLE);
|
|
||||||
lua_setfield(L, -2, "wielditem");
|
|
||||||
lua_pushboolean(L, player->hud_flags & HUD_FLAG_BREATHBAR_VISIBLE);
|
|
||||||
lua_setfield(L, -2, "breathbar");
|
|
||||||
lua_pushboolean(L, player->hud_flags & HUD_FLAG_MINIMAP_VISIBLE);
|
|
||||||
lua_setfield(L, -2, "minimap");
|
|
||||||
lua_pushboolean(L, player->hud_flags & HUD_FLAG_MINIMAP_RADAR_VISIBLE);
|
|
||||||
lua_setfield(L, -2, "minimap_radar");
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user