Use switch instead of if.
This commit is contained in:
@@ -221,186 +221,160 @@ LightNode* findNearestLight()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool handleContextMenuAction(s32 cmdID)
|
||||
bool handleContextMenuAction(s32 cmd_id)
|
||||
{
|
||||
|
||||
World *world = World::getWorld();
|
||||
Physics *physics = world ? world->getPhysics() : NULL;
|
||||
if (cmdID == DEBUG_GRAPHICS_RELOAD_SHADERS)
|
||||
{
|
||||
Log::info("Debug", "Reloading shaders...");
|
||||
ShaderBase::updateShaders();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_RESET)
|
||||
switch(cmd_id)
|
||||
{
|
||||
case DEBUG_GRAPHICS_RELOAD_SHADERS:
|
||||
Log::info("Debug", "Reloading shaders...");
|
||||
ShaderBase::updateShaders();
|
||||
break;
|
||||
case DEBUG_GRAPHICS_RESET:
|
||||
if (physics)
|
||||
physics->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_WIREFRAME)
|
||||
{
|
||||
break;
|
||||
case DEBUG_GRAPHICS_WIREFRAME:
|
||||
if (physics)
|
||||
physics->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleWireframe();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_MIPMAP_VIZ)
|
||||
{
|
||||
break;
|
||||
case DEBUG_GRAPHICS_MIPMAP_VIZ:
|
||||
if (physics)
|
||||
physics->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleMipVisualization();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_NORMALS_VIZ)
|
||||
{
|
||||
break;
|
||||
case DEBUG_GRAPHICS_NORMALS_VIZ:
|
||||
if (physics)
|
||||
physics->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleNormals();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_SSAO_VIZ)
|
||||
{
|
||||
break;
|
||||
case DEBUG_GRAPHICS_SSAO_VIZ:
|
||||
if (physics)
|
||||
physics->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleSSAOViz();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_RSM_VIZ)
|
||||
{
|
||||
break;
|
||||
case DEBUG_GRAPHICS_RSM_VIZ:
|
||||
if (physics)
|
||||
physics->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleRSM();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_RH_VIZ)
|
||||
{
|
||||
break;
|
||||
case DEBUG_GRAPHICS_RH_VIZ:
|
||||
if (physics)
|
||||
physics->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleRH();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_GI_VIZ)
|
||||
{
|
||||
break;
|
||||
case DEBUG_GRAPHICS_GI_VIZ:
|
||||
if (physics)
|
||||
physics->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleGI();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_SHADOW_VIZ)
|
||||
{
|
||||
break;
|
||||
case DEBUG_GRAPHICS_SHADOW_VIZ:
|
||||
if (physics)
|
||||
physics->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleShadowViz();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_LIGHT_VIZ)
|
||||
{
|
||||
break;
|
||||
case DEBUG_GRAPHICS_LIGHT_VIZ:
|
||||
if (physics)
|
||||
physics->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleLightViz();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_DISTORT_VIZ)
|
||||
{
|
||||
break;
|
||||
case DEBUG_GRAPHICS_DISTORT_VIZ:
|
||||
if (physics)
|
||||
physics->setDebugMode(IrrDebugDrawer::DM_NONE);
|
||||
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleDistortViz();
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_BULLET_1)
|
||||
{
|
||||
break;
|
||||
case DEBUG_GRAPHICS_BULLET_1:
|
||||
irr_driver->resetDebugModes();
|
||||
|
||||
if (!world) return false;
|
||||
physics->setDebugMode(IrrDebugDrawer::DM_KARTS_PHYSICS);
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_BULLET_2)
|
||||
break;
|
||||
case DEBUG_GRAPHICS_BULLET_2:
|
||||
{
|
||||
irr_driver->resetDebugModes();
|
||||
|
||||
if (!world) return false;
|
||||
Physics *physics = world->getPhysics();
|
||||
physics->setDebugMode(IrrDebugDrawer::DM_NO_KARTS_GRAPHICS);
|
||||
break;
|
||||
}
|
||||
else if (cmdID == DEBUG_GRAPHICS_BOUNDING_BOXES_VIZ)
|
||||
{
|
||||
case DEBUG_GRAPHICS_BOUNDING_BOXES_VIZ:
|
||||
irr_driver->resetDebugModes();
|
||||
irr_driver->toggleBoundingBoxesViz();
|
||||
}
|
||||
else if (cmdID == DEBUG_PROFILER)
|
||||
{
|
||||
break;
|
||||
case DEBUG_PROFILER:
|
||||
UserConfigParams::m_profiler_enabled =
|
||||
!UserConfigParams::m_profiler_enabled;
|
||||
}
|
||||
else if (cmdID == DEBUG_PROFILER_GENERATE_REPORT)
|
||||
{
|
||||
break;
|
||||
case DEBUG_PROFILER_GENERATE_REPORT:
|
||||
profiler.setCaptureReport(!profiler.getCaptureReport());
|
||||
}
|
||||
else if (cmdID == DEBUG_THROTTLE_FPS)
|
||||
{
|
||||
break;
|
||||
case DEBUG_THROTTLE_FPS:
|
||||
main_loop->setThrottleFPS(false);
|
||||
}
|
||||
else if (cmdID == DEBUG_FPS)
|
||||
{
|
||||
break;
|
||||
case DEBUG_FPS:
|
||||
UserConfigParams::m_display_fps =
|
||||
!UserConfigParams::m_display_fps;
|
||||
}
|
||||
else if (cmdID == DEBUG_SAVE_REPLAY)
|
||||
{
|
||||
break;
|
||||
case DEBUG_SAVE_REPLAY:
|
||||
ReplayRecorder::get()->save();
|
||||
}
|
||||
else if (cmdID == DEBUG_SAVE_HISTORY)
|
||||
{
|
||||
break;
|
||||
case DEBUG_SAVE_HISTORY:
|
||||
history->Save();
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_BOWLING)
|
||||
{
|
||||
break;
|
||||
case DEBUG_POWERUP_BOWLING:
|
||||
addPowerup(PowerupManager::POWERUP_BOWLING);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_BUBBLEGUM)
|
||||
{
|
||||
break;
|
||||
case DEBUG_POWERUP_BUBBLEGUM:
|
||||
addPowerup(PowerupManager::POWERUP_BUBBLEGUM);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_CAKE)
|
||||
{
|
||||
break;
|
||||
case DEBUG_POWERUP_CAKE:
|
||||
addPowerup(PowerupManager::POWERUP_CAKE);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_PARACHUTE)
|
||||
{
|
||||
break;
|
||||
case DEBUG_POWERUP_PARACHUTE:
|
||||
addPowerup(PowerupManager::POWERUP_PARACHUTE);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_PLUNGER)
|
||||
{
|
||||
break;
|
||||
case DEBUG_POWERUP_PLUNGER:
|
||||
addPowerup(PowerupManager::POWERUP_PLUNGER);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_RUBBERBALL)
|
||||
{
|
||||
break;
|
||||
case DEBUG_POWERUP_RUBBERBALL:
|
||||
addPowerup(PowerupManager::POWERUP_RUBBERBALL);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_SWATTER)
|
||||
{
|
||||
break;
|
||||
case DEBUG_POWERUP_SWATTER:
|
||||
addPowerup(PowerupManager::POWERUP_SWATTER);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_SWITCH)
|
||||
{
|
||||
break;
|
||||
case DEBUG_POWERUP_SWITCH:
|
||||
addPowerup(PowerupManager::POWERUP_SWITCH);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_ZIPPER)
|
||||
{
|
||||
break;
|
||||
case DEBUG_POWERUP_ZIPPER:
|
||||
addPowerup(PowerupManager::POWERUP_ZIPPER);
|
||||
}
|
||||
else if (cmdID == DEBUG_POWERUP_NITRO)
|
||||
break;
|
||||
case DEBUG_POWERUP_NITRO:
|
||||
{
|
||||
if (!world) return false;
|
||||
const unsigned int num_local_players =
|
||||
@@ -410,27 +384,25 @@ bool handleContextMenuAction(s32 cmdID)
|
||||
AbstractKart* kart = world->getLocalPlayerKart(i);
|
||||
kart->setEnergy(100.0f);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (cmdID == DEBUG_ATTACHMENT_ANVIL)
|
||||
{
|
||||
case DEBUG_ATTACHMENT_ANVIL:
|
||||
addAttachment(Attachment::ATTACH_ANVIL);
|
||||
}
|
||||
else if (cmdID == DEBUG_ATTACHMENT_BOMB)
|
||||
{
|
||||
break;
|
||||
case DEBUG_ATTACHMENT_BOMB:
|
||||
addAttachment(Attachment::ATTACH_BOMB);
|
||||
}
|
||||
else if (cmdID == DEBUG_ATTACHMENT_PARACHUTE)
|
||||
{
|
||||
break;
|
||||
case DEBUG_ATTACHMENT_PARACHUTE:
|
||||
addAttachment(Attachment::ATTACH_PARACHUTE);
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_TOGGLE)
|
||||
break;
|
||||
case DEBUG_GUI_TOGGLE:
|
||||
{
|
||||
if (!world) return false;
|
||||
RaceGUIBase* gui = world->getRaceGUI();
|
||||
if (gui != NULL) gui->m_enabled = !gui->m_enabled;
|
||||
break;
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_HIDE_KARTS)
|
||||
{
|
||||
case DEBUG_GUI_HIDE_KARTS:
|
||||
if (!world) return false;
|
||||
for (unsigned int n = 0; n<world->getNumKarts(); n++)
|
||||
{
|
||||
@@ -438,32 +410,28 @@ bool handleContextMenuAction(s32 cmdID)
|
||||
if (kart->getController()->isPlayerController())
|
||||
kart->getNode()->setVisible(false);
|
||||
}
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_CAM_TOP)
|
||||
{
|
||||
break;
|
||||
case DEBUG_GUI_CAM_TOP:
|
||||
CameraDebug::setDebugType(CameraDebug::CM_DEBUG_TOP_OF_KART);
|
||||
Camera::changeCamera(0, Camera::CM_TYPE_DEBUG);
|
||||
irr_driver->getDevice()->getCursorControl()->setVisible(true);
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_CAM_WHEEL)
|
||||
{
|
||||
break;
|
||||
case DEBUG_GUI_CAM_WHEEL:
|
||||
CameraDebug::setDebugType(CameraDebug::CM_DEBUG_GROUND);
|
||||
Camera::changeCamera(0, Camera::CM_TYPE_DEBUG);
|
||||
irr_driver->getDevice()->getCursorControl()->setVisible(true);
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_CAM_BEHIND_KART)
|
||||
{
|
||||
break;
|
||||
case DEBUG_GUI_CAM_BEHIND_KART:
|
||||
CameraDebug::setDebugType(CameraDebug::CM_DEBUG_BEHIND_KART);
|
||||
Camera::changeCamera(0, Camera::CM_TYPE_DEBUG);
|
||||
irr_driver->getDevice()->getCursorControl()->setVisible(true);
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_CAM_SIDE_OF_KART)
|
||||
{
|
||||
break;
|
||||
case DEBUG_GUI_CAM_SIDE_OF_KART:
|
||||
CameraDebug::setDebugType(CameraDebug::CM_DEBUG_SIDE_OF_KART);
|
||||
Camera::changeCamera(0, Camera::CM_TYPE_DEBUG);
|
||||
irr_driver->getDevice()->getCursorControl()->setVisible(true);
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_CAM_FREE)
|
||||
break;
|
||||
case DEBUG_GUI_CAM_FREE:
|
||||
{
|
||||
Camera *camera = Camera::getActiveCamera();
|
||||
Camera::changeCamera(camera->getIndex(), Camera::CM_TYPE_FPS);
|
||||
@@ -475,63 +443,58 @@ bool handleContextMenuAction(s32 cmdID)
|
||||
cam->setDirection(vector3df(0, 0, 1));
|
||||
cam->setUpVector(vector3df(0, 1, 0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_CAM_NORMAL)
|
||||
case DEBUG_GUI_CAM_NORMAL:
|
||||
{
|
||||
Camera *camera = Camera::getActiveCamera();
|
||||
Camera::changeCamera(camera->getIndex(), Camera::CM_TYPE_NORMAL);
|
||||
irr_driver->getDevice()->getCursorControl()->setVisible(true);
|
||||
break;
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_CAM_SMOOTH)
|
||||
case DEBUG_GUI_CAM_SMOOTH:
|
||||
{
|
||||
CameraFPS *cam = dynamic_cast<CameraFPS*>(Camera::getActiveCamera());
|
||||
if(cam)
|
||||
{
|
||||
cam->setSmoothMovement(!cam->getSmoothMovement());
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (cmdID == DEBUG_GUI_CAM_ATTACH)
|
||||
case DEBUG_GUI_CAM_ATTACH:
|
||||
{
|
||||
CameraFPS *cam = dynamic_cast<CameraFPS*>(Camera::getActiveCamera());
|
||||
if(cam)
|
||||
{
|
||||
cam->setAttachedFpsCam(!cam->getAttachedFpsCam());
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (cmdID == DEBUG_VIEW_KART_ONE)
|
||||
{
|
||||
case DEBUG_VIEW_KART_ONE:
|
||||
changeCameraTarget(1);
|
||||
}
|
||||
else if (cmdID == DEBUG_VIEW_KART_TWO)
|
||||
{
|
||||
break;
|
||||
case DEBUG_VIEW_KART_TWO:
|
||||
changeCameraTarget(2);
|
||||
}
|
||||
else if (cmdID == DEBUG_VIEW_KART_THREE)
|
||||
{
|
||||
break;
|
||||
case DEBUG_VIEW_KART_THREE:
|
||||
changeCameraTarget(3);
|
||||
}
|
||||
else if (cmdID == DEBUG_VIEW_KART_FOUR)
|
||||
{
|
||||
break;
|
||||
case DEBUG_VIEW_KART_FOUR:
|
||||
changeCameraTarget(4);
|
||||
}
|
||||
else if (cmdID == DEBUG_VIEW_KART_FIVE)
|
||||
{
|
||||
break;
|
||||
case DEBUG_VIEW_KART_FIVE:
|
||||
changeCameraTarget(5);
|
||||
}
|
||||
else if (cmdID == DEBUG_VIEW_KART_SIX)
|
||||
{
|
||||
break;
|
||||
case DEBUG_VIEW_KART_SIX:
|
||||
changeCameraTarget(6);
|
||||
}
|
||||
else if (cmdID == DEBUG_VIEW_KART_SEVEN)
|
||||
{
|
||||
break;
|
||||
case DEBUG_VIEW_KART_SEVEN:
|
||||
changeCameraTarget(7);
|
||||
}
|
||||
else if (cmdID == DEBUG_VIEW_KART_EIGHT)
|
||||
{
|
||||
break;
|
||||
case DEBUG_VIEW_KART_EIGHT:
|
||||
changeCameraTarget(8);
|
||||
}
|
||||
else if (cmdID == DEBUG_PRINT_START_POS)
|
||||
{
|
||||
break;
|
||||
case DEBUG_PRINT_START_POS:
|
||||
if (!world) return false;
|
||||
for (unsigned int i = 0; i<world->getNumKarts(); i++)
|
||||
{
|
||||
@@ -542,8 +505,8 @@ bool handleContextMenuAction(s32 cmdID)
|
||||
kart->getXYZ().getZ(), kart->getHeading()*RAD_TO_DEGREE
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (cmdID == DEBUG_VISUAL_VALUES)
|
||||
break;
|
||||
case DEBUG_VISUAL_VALUES:
|
||||
{
|
||||
#if !defined(__APPLE__)
|
||||
DebugSliderDialog *dsd = new DebugSliderDialog();
|
||||
@@ -582,7 +545,8 @@ bool handleContextMenuAction(s32 cmdID)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
else if (cmdID == DEBUG_ADJUST_LIGHTS)
|
||||
break;
|
||||
case DEBUG_ADJUST_LIGHTS:
|
||||
{
|
||||
#if !defined(__APPLE__)
|
||||
// Some sliders use multipliers because the spinner widget
|
||||
@@ -639,12 +603,12 @@ bool handleContextMenuAction(s32 cmdID)
|
||||
);
|
||||
dsd->changeLabel("SSAO Sigma", "[None]");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
else if (cmdID == DEBUG_SCRIPT_CONSOLE)
|
||||
{
|
||||
case DEBUG_SCRIPT_CONSOLE:
|
||||
ScriptingConsole* console = new ScriptingConsole();
|
||||
}
|
||||
|
||||
break;
|
||||
} // switch
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user