Add debug priv, and allow player to display the scene as wire-frame. (#4709)
This commit is contained in:
parent
bf315c05f1
commit
f8fd432dca
@ -58,4 +58,7 @@ core.register_privilege("zoom", {
|
|||||||
description = "Can zoom the camera",
|
description = "Can zoom the camera",
|
||||||
give_to_singleplayer = false,
|
give_to_singleplayer = false,
|
||||||
})
|
})
|
||||||
|
core.register_privilege("debug", {
|
||||||
|
description = "Allows enabling various debug options that may affect gameplay",
|
||||||
|
give_to_singleplayer = false,
|
||||||
|
})
|
||||||
|
@ -521,6 +521,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
|||||||
buf->getMaterial().setFlag(video::EMF_TRILINEAR_FILTER, m_cache_trilinear_filter);
|
buf->getMaterial().setFlag(video::EMF_TRILINEAR_FILTER, m_cache_trilinear_filter);
|
||||||
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, m_cache_bilinear_filter);
|
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, m_cache_bilinear_filter);
|
||||||
buf->getMaterial().setFlag(video::EMF_ANISOTROPIC_FILTER, m_cache_anistropic_filter);
|
buf->getMaterial().setFlag(video::EMF_ANISOTROPIC_FILTER, m_cache_anistropic_filter);
|
||||||
|
buf->getMaterial().setFlag(video::EMF_WIREFRAME, m_control.show_wireframe);
|
||||||
|
|
||||||
const video::SMaterial& material = buf->getMaterial();
|
const video::SMaterial& material = buf->getMaterial();
|
||||||
video::IMaterialRenderer* rnd =
|
video::IMaterialRenderer* rnd =
|
||||||
|
@ -32,6 +32,7 @@ struct MapDrawControl
|
|||||||
range_all(false),
|
range_all(false),
|
||||||
wanted_range(0),
|
wanted_range(0),
|
||||||
wanted_max_blocks(0),
|
wanted_max_blocks(0),
|
||||||
|
show_wireframe(false),
|
||||||
blocks_drawn(0),
|
blocks_drawn(0),
|
||||||
blocks_would_have_drawn(0),
|
blocks_would_have_drawn(0),
|
||||||
farthest_drawn(0)
|
farthest_drawn(0)
|
||||||
@ -43,6 +44,8 @@ struct MapDrawControl
|
|||||||
float wanted_range;
|
float wanted_range;
|
||||||
// Maximum number of blocks to draw
|
// Maximum number of blocks to draw
|
||||||
u32 wanted_max_blocks;
|
u32 wanted_max_blocks;
|
||||||
|
// show a wire frame for debugging
|
||||||
|
bool show_wireframe;
|
||||||
// Number of blocks rendered is written here by the renderer
|
// Number of blocks rendered is written here by the renderer
|
||||||
u32 blocks_drawn;
|
u32 blocks_drawn;
|
||||||
// Number of blocks that would have been drawn in wanted_range
|
// Number of blocks that would have been drawn in wanted_range
|
||||||
|
30
src/game.cpp
30
src/game.cpp
@ -1573,7 +1573,7 @@ protected:
|
|||||||
bool shift_pressed);
|
bool shift_pressed);
|
||||||
void toggleFog(float *statustext_time, bool *flag);
|
void toggleFog(float *statustext_time, bool *flag);
|
||||||
void toggleDebug(float *statustext_time, bool *show_debug,
|
void toggleDebug(float *statustext_time, bool *show_debug,
|
||||||
bool *show_profiler_graph);
|
bool *show_profiler_graph, bool *show_wireframe);
|
||||||
void toggleUpdateCamera(float *statustext_time, bool *flag);
|
void toggleUpdateCamera(float *statustext_time, bool *flag);
|
||||||
void toggleProfiler(float *statustext_time, u32 *profiler_current_page,
|
void toggleProfiler(float *statustext_time, u32 *profiler_current_page,
|
||||||
u32 profiler_max_page);
|
u32 profiler_max_page);
|
||||||
@ -2812,7 +2812,8 @@ void Game::processKeyInput(VolatileRunFlags *flags,
|
|||||||
} else if (wasKeyDown(KeyType::TOGGLE_UPDATE_CAMERA)) {
|
} else if (wasKeyDown(KeyType::TOGGLE_UPDATE_CAMERA)) {
|
||||||
toggleUpdateCamera(statustext_time, &flags->disable_camera_update);
|
toggleUpdateCamera(statustext_time, &flags->disable_camera_update);
|
||||||
} else if (wasKeyDown(KeyType::TOGGLE_DEBUG)) {
|
} else if (wasKeyDown(KeyType::TOGGLE_DEBUG)) {
|
||||||
toggleDebug(statustext_time, &flags->show_debug, &flags->show_profiler_graph);
|
toggleDebug(statustext_time, &flags->show_debug, &flags->show_profiler_graph,
|
||||||
|
&draw_control->show_wireframe);
|
||||||
} else if (wasKeyDown(KeyType::TOGGLE_PROFILER)) {
|
} else if (wasKeyDown(KeyType::TOGGLE_PROFILER)) {
|
||||||
toggleProfiler(statustext_time, profiler_current_page, profiler_max_page);
|
toggleProfiler(statustext_time, profiler_current_page, profiler_max_page);
|
||||||
} else if (wasKeyDown(KeyType::INCREASE_VIEWING_RANGE)) {
|
} else if (wasKeyDown(KeyType::INCREASE_VIEWING_RANGE)) {
|
||||||
@ -3119,22 +3120,33 @@ void Game::toggleFog(float *statustext_time, bool *flag)
|
|||||||
|
|
||||||
|
|
||||||
void Game::toggleDebug(float *statustext_time, bool *show_debug,
|
void Game::toggleDebug(float *statustext_time, bool *show_debug,
|
||||||
bool *show_profiler_graph)
|
bool *show_profiler_graph, bool *show_wireframe)
|
||||||
{
|
{
|
||||||
// Initial / 3x toggle: Chat only
|
// Initial / 4x toggle: Chat only
|
||||||
// 1x toggle: Debug text with chat
|
// 1x toggle: Debug text with chat
|
||||||
// 2x toggle: Debug text with profiler graph
|
// 2x toggle: Debug text with profiler graph
|
||||||
|
// 3x toggle: Debug text and wireframe
|
||||||
if (!*show_debug) {
|
if (!*show_debug) {
|
||||||
*show_debug = true;
|
*show_debug = true;
|
||||||
*show_profiler_graph = false;
|
*show_profiler_graph = false;
|
||||||
|
*show_wireframe = false;
|
||||||
statustext = L"Debug info shown";
|
statustext = L"Debug info shown";
|
||||||
} else if (*show_profiler_graph) {
|
} else if (!*show_profiler_graph) {
|
||||||
*show_debug = false;
|
|
||||||
*show_profiler_graph = false;
|
|
||||||
statustext = L"Debug info and profiler graph hidden";
|
|
||||||
} else {
|
|
||||||
*show_profiler_graph = true;
|
*show_profiler_graph = true;
|
||||||
statustext = L"Profiler graph shown";
|
statustext = L"Profiler graph shown";
|
||||||
|
} else if (!*show_wireframe && client->checkPrivilege("debug")) {
|
||||||
|
*show_profiler_graph = false;
|
||||||
|
*show_wireframe = true;
|
||||||
|
statustext = L"Wireframe shown";
|
||||||
|
} else {
|
||||||
|
*show_debug = false;
|
||||||
|
*show_profiler_graph = false;
|
||||||
|
*show_wireframe = false;
|
||||||
|
if (client->checkPrivilege("debug")) {
|
||||||
|
statustext = L"Debug info, profiler graph, and wireframe hidden";
|
||||||
|
} else {
|
||||||
|
statustext = L"Debug info and profiler graph hidden";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*statustext_time = 0;
|
*statustext_time = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user