Extend funto's debug menu
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14676 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
31c29c7a92
commit
55018ee089
@ -374,6 +374,17 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
inline bool isGLSL() const { return m_glsl; }
|
||||
// ------------------------------------------------------------------------
|
||||
void resetDebugModes()
|
||||
{
|
||||
m_wireframe = false;
|
||||
m_mipviz = false;
|
||||
m_normals = false;
|
||||
m_ssaoviz = false;
|
||||
m_shadowviz = false;
|
||||
m_lightviz = false;
|
||||
m_distortviz = false;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
void toggleWireframe() { m_wireframe = !m_wireframe; }
|
||||
// ------------------------------------------------------------------------
|
||||
void toggleMipVisualization() { m_mipviz = !m_mipviz; }
|
||||
|
@ -2194,6 +2194,8 @@ core::recti Skin::draw3DWindowBackground(IGUIElement *element,
|
||||
void Skin::draw3DMenuPane (IGUIElement *element, const core::recti &rect,
|
||||
const core::recti *clip)
|
||||
{
|
||||
SColor color = SColor(150, 255, 255, 255);
|
||||
GUIEngine::getDriver()->draw2DRectangle(color, rect);
|
||||
} // draw3DMenuPane
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -161,7 +161,7 @@ void InputManager::handleStaticAction(int key, int value)
|
||||
if (value ==0 )
|
||||
irr_driver->requestScreenshot();
|
||||
break;
|
||||
|
||||
/*
|
||||
case KEY_F1:
|
||||
if (UserConfigParams::m_artist_debug_mode && world)
|
||||
{
|
||||
@ -222,7 +222,7 @@ void InputManager::handleStaticAction(int key, int value)
|
||||
kart->setPowerup(PowerupManager::POWERUP_ZIPPER, 10000);
|
||||
}
|
||||
break;
|
||||
|
||||
*/
|
||||
case KEY_F8:
|
||||
if (UserConfigParams::m_artist_debug_mode && value && world)
|
||||
{
|
||||
@ -283,60 +283,6 @@ void InputManager::handleStaticAction(int key, int value)
|
||||
UserConfigParams::m_display_fps =
|
||||
!UserConfigParams::m_display_fps;
|
||||
break;
|
||||
|
||||
case KEY_KEY_P:
|
||||
if (UserConfigParams::m_artist_debug_mode && value &&
|
||||
control_is_pressed)
|
||||
UserConfigParams::m_profiler_enabled =
|
||||
!UserConfigParams::m_profiler_enabled;
|
||||
break;
|
||||
|
||||
// Debug views
|
||||
// These should be available in normal (non-artist) mode
|
||||
// to enable easier bug reports (go there, press this key, screenshot)
|
||||
// without requiring editing the UTF-32 config files (which is inconvenient).
|
||||
case KEY_HOME:
|
||||
if (value)
|
||||
{
|
||||
irr_driver->toggleWireframe();
|
||||
}
|
||||
break;
|
||||
case KEY_END:
|
||||
if (value)
|
||||
{
|
||||
irr_driver->toggleMipVisualization();
|
||||
}
|
||||
break;
|
||||
case KEY_DELETE:
|
||||
if (value)
|
||||
{
|
||||
irr_driver->toggleNormals();
|
||||
}
|
||||
break;
|
||||
case KEY_NEXT: // pgdown
|
||||
if (value)
|
||||
{
|
||||
irr_driver->toggleSSAOViz();
|
||||
}
|
||||
break;
|
||||
case KEY_PRIOR: // pgup
|
||||
if (value)
|
||||
{
|
||||
irr_driver->toggleLightViz();
|
||||
}
|
||||
break;
|
||||
case KEY_INSERT:
|
||||
if (value)
|
||||
{
|
||||
irr_driver->toggleShadowViz();
|
||||
}
|
||||
break;
|
||||
case KEY_SCROLL:
|
||||
if (value)
|
||||
{
|
||||
irr_driver->toggleDistortViz();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} // switch
|
||||
|
@ -35,7 +35,13 @@ IrrDebugDrawer::IrrDebugDrawer()
|
||||
void IrrDebugDrawer::nextDebugMode()
|
||||
{
|
||||
// Go to next debug mode. Note that debug mode 3 (
|
||||
m_debug_mode = (DebugModeType) ((m_debug_mode+1) % 3);
|
||||
setDebugMode((DebugModeType) ((m_debug_mode+1) % 3));
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void IrrDebugDrawer::setDebugMode(DebugModeType mode)
|
||||
{
|
||||
m_debug_mode = mode;
|
||||
World *world = World::getWorld();
|
||||
unsigned int num_karts = world->getNumKarts();
|
||||
for(unsigned int i=0; i<num_karts; i++)
|
||||
|
@ -28,6 +28,7 @@
|
||||
*/
|
||||
class IrrDebugDrawer : public btIDebugDraw
|
||||
{
|
||||
public:
|
||||
/** The drawing mode to use:
|
||||
* If bit 0 is set, draw the bullet collision shape of karts
|
||||
* If bit 1 is set, don't draw the kart graphics
|
||||
@ -63,6 +64,7 @@ public:
|
||||
/** Returns true if debug mode is enabled. */
|
||||
bool debugEnabled() const {return m_debug_mode!=0;}
|
||||
void nextDebugMode();
|
||||
void setDebugMode(DebugModeType mode);
|
||||
}; // IrrDebugDrawer
|
||||
|
||||
#endif
|
||||
|
@ -162,6 +162,7 @@ public:
|
||||
/** Activates the next debug mode (or switches it off again).
|
||||
*/
|
||||
void nextDebugMode () {m_debug_drawer->nextDebugMode(); }
|
||||
void setDebugMode(IrrDebugDrawer::DebugModeType mode) { m_debug_drawer->setDebugMode(mode); }
|
||||
/** Returns true if the debug drawer is enabled. */
|
||||
bool isDebug() const {return m_debug_drawer->debugEnabled(); }
|
||||
virtual btScalar solveGroup(btCollisionObject** bodies, int numBodies,
|
||||
|
@ -17,8 +17,15 @@
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "debug.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "items/powerup_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "physics/irr_debug_drawer.hpp"
|
||||
#include "physics/physics.hpp"
|
||||
#include "race/history.hpp"
|
||||
#include "replay/replay_recorder.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include <IGUIEnvironment.h>
|
||||
#include <IGUIContextMenu.h>
|
||||
@ -39,6 +46,29 @@ enum DebugMenuCommand
|
||||
{
|
||||
//! graphics commands
|
||||
DEBUG_GRAPHICS_RELOAD_SHADERS,
|
||||
DEBUG_GRAPHICS_RESET,
|
||||
DEBUG_GRAPHICS_WIREFRAME,
|
||||
DEBUG_GRAPHICS_MIPMAP_VIZ,
|
||||
DEBUG_GRAPHICS_NORMALS_VIZ,
|
||||
DEBUG_GRAPHICS_SSAO_VIZ,
|
||||
DEBUG_GRAPHICS_SHADOW_VIZ,
|
||||
DEBUG_GRAPHICS_LIGHT_VIZ,
|
||||
DEBUG_GRAPHICS_DISTORT_VIZ,
|
||||
DEBUG_GRAPHICS_BULLET_1,
|
||||
DEBUG_GRAPHICS_BULLET_2,
|
||||
DEBUG_PROFILER,
|
||||
DEBUG_FPS,
|
||||
DEBUG_SAVE_REPLAY,
|
||||
DEBUG_SAVE_HISTORY,
|
||||
DEBUG_POWERUP_BOWLING,
|
||||
DEBUG_POWERUP_BUBBLEGUM,
|
||||
DEBUG_POWERUP_CAKE,
|
||||
DEBUG_POWERUP_PLUNGER,
|
||||
DEBUG_POWERUP_RUBBERBALL,
|
||||
DEBUG_POWERUP_SWATTER,
|
||||
DEBUG_POWERUP_SWITCH,
|
||||
DEBUG_POWERUP_ZIPPER,
|
||||
DEBUG_POWERUP_NITRO
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -55,15 +85,45 @@ bool onEvent(const SEvent &event)
|
||||
if(event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN && !g_debug_menu_visible)
|
||||
{
|
||||
// root menu
|
||||
gui::IGUIEnvironment* guienv = irr_driver->getGUI();
|
||||
gui::IGUIEnvironment* guienv = irr_driver->getGUI();
|
||||
IGUIContextMenu* mnu = guienv->addContextMenu(
|
||||
core::rect<s32>(event.MouseInput.X, event.MouseInput.Y, event.MouseInput.Y+100, event.MouseInput.Y+100),NULL);
|
||||
mnu->addItem(L"Graphics >",-1,true,true);
|
||||
int graphicsMenuIndex = mnu->addItem(L"Graphics >",-1,true,true);
|
||||
|
||||
// graphics menu
|
||||
IGUIContextMenu* sub = mnu->getSubMenu(0);
|
||||
IGUIContextMenu* sub = mnu->getSubMenu(graphicsMenuIndex);
|
||||
|
||||
sub->addItem(L"Reload shaders", DEBUG_GRAPHICS_RELOAD_SHADERS );
|
||||
sub->addItem(L"Reset debug views", DEBUG_GRAPHICS_RESET );
|
||||
sub->addItem(L"Wireframe", DEBUG_GRAPHICS_WIREFRAME );
|
||||
sub->addItem(L"Mipmap viz", DEBUG_GRAPHICS_MIPMAP_VIZ );
|
||||
sub->addItem(L"Normals viz", DEBUG_GRAPHICS_NORMALS_VIZ );
|
||||
sub->addItem(L"SSAO viz", DEBUG_GRAPHICS_SSAO_VIZ );
|
||||
sub->addItem(L"Shadow viz", DEBUG_GRAPHICS_SHADOW_VIZ );
|
||||
sub->addItem(L"Light viz", DEBUG_GRAPHICS_LIGHT_VIZ );
|
||||
sub->addItem(L"Distort viz", DEBUG_GRAPHICS_DISTORT_VIZ );
|
||||
sub->addItem(L"Physics debug", DEBUG_GRAPHICS_BULLET_1);
|
||||
sub->addItem(L"Physics debug (no kart)", DEBUG_GRAPHICS_BULLET_2);
|
||||
|
||||
int itemsMenuIndex = mnu->addItem(L"Items >",-1,true,true);
|
||||
sub = mnu->getSubMenu(1);
|
||||
sub->addItem(L"Basketball", DEBUG_POWERUP_RUBBERBALL );
|
||||
sub->addItem(L"Bowling", DEBUG_POWERUP_BOWLING );
|
||||
sub->addItem(L"Bubblegum", DEBUG_POWERUP_BUBBLEGUM );
|
||||
sub->addItem(L"Cake", DEBUG_POWERUP_CAKE );
|
||||
sub->addItem(L"Plunger", DEBUG_POWERUP_PLUNGER );
|
||||
sub->addItem(L"Swatter", DEBUG_POWERUP_SWATTER );
|
||||
sub->addItem(L"Switch", DEBUG_POWERUP_SWITCH );
|
||||
sub->addItem(L"Zipper", DEBUG_POWERUP_ZIPPER );
|
||||
sub->addItem(L"Nitro", DEBUG_POWERUP_NITRO );
|
||||
|
||||
mnu->addItem(L"Profiler",DEBUG_PROFILER);
|
||||
mnu->addItem(L"FPS",DEBUG_FPS);
|
||||
mnu->addItem(L"Save replay", DEBUG_SAVE_REPLAY);
|
||||
mnu->addItem(L"Save history", DEBUG_SAVE_HISTORY);
|
||||
|
||||
|
||||
|
||||
g_debug_menu_visible = true;
|
||||
|
||||
g_was_pointer_shown = irr_driver->isPointerShown();
|
||||
@ -77,29 +137,190 @@ bool onEvent(const SEvent &event)
|
||||
|
||||
if (event.EventType == EET_GUI_EVENT)
|
||||
{
|
||||
if (event.GUIEvent.Caller != NULL)
|
||||
if (event.GUIEvent.Caller != NULL && event.GUIEvent.Caller->getType() == EGUIET_CONTEXT_MENU )
|
||||
{
|
||||
if(event.GUIEvent.Caller->getType() == EGUIET_CONTEXT_MENU)
|
||||
IGUIContextMenu *menu = (IGUIContextMenu*)event.GUIEvent.Caller;
|
||||
s32 cmdID = menu->getItemCommandId(menu->getSelectedItem());
|
||||
|
||||
if(event.GUIEvent.EventType == EGET_ELEMENT_CLOSED)
|
||||
{
|
||||
IGUIContextMenu *menu = (IGUIContextMenu*)event.GUIEvent.Caller;
|
||||
s32 cmdID = menu->getItemCommandId(menu->getSelectedItem());
|
||||
|
||||
if(event.GUIEvent.EventType == EGET_ELEMENT_CLOSED)
|
||||
{
|
||||
g_debug_menu_visible = false;
|
||||
if(g_was_pointer_shown)
|
||||
irr_driver->showPointer();
|
||||
else
|
||||
irr_driver->hidePointer();
|
||||
}
|
||||
g_debug_menu_visible = false;
|
||||
if(g_was_pointer_shown)
|
||||
irr_driver->showPointer();
|
||||
else
|
||||
irr_driver->hidePointer();
|
||||
}
|
||||
|
||||
if (event.GUIEvent.EventType == gui::EGET_MENU_ITEM_SELECTED)
|
||||
{
|
||||
if(cmdID == DEBUG_GRAPHICS_RELOAD_SHADERS)
|
||||
{
|
||||
Log::info("Debug", "Reloading shaders...\n");
|
||||
irr_driver->updateShaders();
|
||||
}
|
||||
return false; // event has been treated
|
||||
else if (cmdID == DEBUG_GRAPHICS_RESET)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_WIREFRAME)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleWireframe();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_MIPMAP_VIZ)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleMipVisualization();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_NORMALS_VIZ)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleNormals();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_SSAO_VIZ)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleSSAOViz();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_SHADOW_VIZ)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleShadowViz();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_LIGHT_VIZ)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleLightViz();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_DISTORT_VIZ)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleDistortViz();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_BULLET_1)
|
||||
{
|
||||
irr_driver->resetDebugModes();
|
||||
|
||||
World* world = World::getWorld();
|
||||
if (world == NULL) return false;
|
||||
world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_KARTS_PHYSICS);
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_BULLET_2)
|
||||
{
|
||||
irr_driver->resetDebugModes();
|
||||
|
||||
World* world = World::getWorld();
|
||||
if (world == NULL) return false;
|
||||
world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NO_KARTS_GRAPHICS);
|
||||
}
|
||||
else if (cmdID == DEBUG_PROFILER)
|
||||
{
|
||||
UserConfigParams::m_profiler_enabled =
|
||||
!UserConfigParams::m_profiler_enabled;
|
||||
}
|
||||
else if (cmdID == DEBUG_FPS)
|
||||
{
|
||||
UserConfigParams::m_display_fps =
|
||||
!UserConfigParams::m_display_fps;
|
||||
}
|
||||
else if (cmdID == DEBUG_SAVE_REPLAY)
|
||||
{
|
||||
ReplayRecorder::get()->Save();
|
||||
}
|
||||
else if (cmdID == DEBUG_SAVE_HISTORY)
|
||||
{
|
||||
history->Save();
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_BOWLING)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world == NULL) return false;
|
||||
AbstractKart* kart = world->getLocalPlayerKart(0);
|
||||
kart->setPowerup(PowerupManager::POWERUP_BOWLING, 10000);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_BUBBLEGUM)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world == NULL) return false;
|
||||
AbstractKart* kart = world->getLocalPlayerKart(0);
|
||||
kart->setPowerup(PowerupManager::POWERUP_BUBBLEGUM, 10000);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_CAKE)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world == NULL) return false;
|
||||
AbstractKart* kart = world->getLocalPlayerKart(0);
|
||||
kart->setPowerup(PowerupManager::POWERUP_CAKE, 10000);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_PLUNGER)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world == NULL) return false;
|
||||
AbstractKart* kart = world->getLocalPlayerKart(0);
|
||||
kart->setPowerup(PowerupManager::POWERUP_PLUNGER, 10000);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_RUBBERBALL)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world == NULL) return false;
|
||||
AbstractKart* kart = world->getLocalPlayerKart(0);
|
||||
kart->setPowerup(PowerupManager::POWERUP_RUBBERBALL, 10000);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_SWATTER)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world == NULL) return false;
|
||||
AbstractKart* kart = world->getLocalPlayerKart(0);
|
||||
kart->setPowerup(PowerupManager::POWERUP_SWATTER, 10000);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_SWITCH)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world == NULL) return false;
|
||||
AbstractKart* kart = world->getLocalPlayerKart(0);
|
||||
kart->setPowerup(PowerupManager::POWERUP_SWITCH, 10000);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_ZIPPER)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world == NULL) return false;
|
||||
AbstractKart* kart = world->getLocalPlayerKart(0);
|
||||
kart->setPowerup(PowerupManager::POWERUP_ZIPPER, 10000);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_NITRO)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world == NULL) return false;
|
||||
AbstractKart* kart = world->getLocalPlayerKart(0);
|
||||
kart->setEnergy(100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
return false; // event has been handled
|
||||
}
|
||||
}
|
||||
return true; // continue event handling
|
||||
|
Loading…
Reference in New Issue
Block a user