Improved artist debug mode (#4501)

* Add more functionality to the debug menu

Includes:
* Front of kart view
* Inverse side of kart view
* Change to kart #9 or #10
* Attachments for AI karts

* Fix enumeration value not handled in switch for debug camera

* More enhancements to the debug menu, part 2

Includes:
* Restore access to the anchor/anvil powerup
* Clear the current powerup or attachment
* Change to kart #11 or #12
* Flatten karts as if they were hit by a swatter
* Block most of the view with plungers

* Enable executing some keypress actions from the debug menu in a new sub-menu

Includes:
* Rescuing karts from menu
* Pausing the game from menu (but keypresses will cause the game to crash)
* Moved "To next kart" menu entry to be right below "To previous kart" for easier reach

* Change print kart positions to info level, better labeling of side kart views

* Prevent crashes when trying to use 'Behind wheel view' on a ghost kart

* Add close button to the debug slider dialog, and a function to enable/disable spinners

* Make it easier to read and select kart camera targets from the debug menu

* Add another dialog (reusing the debug slider code) to allow the user to select
from a slider the kart number to change to

* The 11th and 12th target slots have been removed to make the submenu cleaner,
but the 9th and 10th slots have been left in place

* The predefined slots (1st place to 10th place) actually use numbers

* Improve the appearance of the FPS (frames per second) counter

* Shift the position closer to the center, so that in-race kart icons are not obscured
* The box and text position adapt based on the screen resolution
* Use a thin black border for the font, and make the font white-colored
* Decrease the font scaling to 0.7, so that other UI elements can be seen more easily

* Improve debug keyboard shortcuts handling, rearrange some shortcuts

Most shortcuts are now handled by Debug instead of InputManager directly
Other changes include:
* Fix moving right in 1st-person view not working
* Change the 1st-person view shortcuts to work more like in Blender
* Add more keyboard shortcuts for quickly seeing the top and sides of a kart
* The key to show player list in soccer mode no longer needs to be held down
* Rearrange some shortcuts to flow more naturally

New list of debug keyboard shortcuts:
* F1 - Normal view
* F2 - Top view
* F3 - Right side of kart view
* F4 - Left side of kart view
* F5 - 1st-person view
* F6 - Reload SP textures
* F7 - Next kart
* F8 - Previous kart
* F9 - Show player list in soccer mode
* Q - Move 1st-person view camera down
* E - Move 1st-person view camera up
* R - Rotate 1st-person view camera right
* F - Rotate 1st-person view camera left

* Exit demo mode when there also are no dialogs active; fixes related crashes

* Improve the debug menu, various fixes to some menu items, and mouse-accessible actions

Includes:
* Debug menu opens at the cursor position, but not at off-screen places
* Ensure that the debug menu stays (almost) within the actual window
* Middle mouse button can also be used to access the debug menu
* Move all items into submenus, rearrange most submenus to keep a compact size
* Add ability to set powerup and nitro amount by debug slider dialog
* Label the some commands with the new keyboard shortcuts
* Screenshots can now be saved via the debug menu
* Texture reloading can now be done via the debug menu

* Add more debug shortcut keys, change many of the existing ones

The full shortcuts list will be explained later

Includes:
* Use Control and Shift keys to fit more shortcuts onto fewer keys
* Label the debug menu items with the keys that can be used to activate them
* Fix more debug menu items causing game crashes in certain situations
* Add help message dialog to tell users the list of static/debug shortcuts; incomplete
* Slightly alter the free margins that the debug menu can appear in
* Render target textures (RTT) can now be dumped via the debug menu
* Replace the 10th kart camera target with the last kart camera target
* Switch the shortcuts used for activating history save and manual replay saving

* Finish labelling the remaining debug actions, complete the debug keys help dialog

Unfortunately, the now unused tutorial message dialog has been repurposed for this use,
and the font sizes greater than 'Large' will cause some text to draw outside the dialog

* Document the remaining command-line parameters, clean up some of them

This adds another method that will print out the previously undocumented debug options

Rename --gamepad-visuali[s,z]ation to --gamepad-visuals

Also fix some comments related to the user config, including the game mode numbers

* The AI cannot handle the anvil powerup anymore, but it won't spam logs anymore
This commit is contained in:
Richard Qian 2021-03-07 21:23:28 -06:00 committed by GitHub
parent 142c9ccf22
commit 969de9e751
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 978 additions and 487 deletions

View File

@ -30,5 +30,9 @@
<label id="SSAO Sigma" raw_text="SSAO sigma" width="7f"/>
<gauge id="ssao_sigma" min_value="0" max_value="100" proportion="1"/>
</div>
<spacer height="1%"/>
<button id="close" text="Close" align="center"/>
</div>
</stkgui>

View File

@ -1,10 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<stkgui>
<div x="2%" y="10%" width="96%" height="80%" layout="vertical-row" >
<label id="title" width="100%" text_align="left" word_wrap="true" proportion="1" />
<div x="2%" y="10%" width="96%" height="88%" layout="vertical-row" >
<label id="title" width="100%" height="100%" text_align="left" word_wrap="true" proportion="1" />
<spacer height="2%" width="10" />
<button id="continue" I18N="Button in tutorial" text="Continue" align="right"/>
<button id="continue" I18N="Button in tutorial" text="Continue" align="center"/>
</div>
</stkgui>

View File

@ -461,7 +461,8 @@ namespace UserConfigParams
PARAM_DEFAULT( IntUserConfigParam(0, "game_mode",
&m_race_setup_group,
"Game mode. 0=standard, 1=time trial, 2=follow "
"the leader, 3=3 strikes") );
"the leader, 3=3 strikes, 4=easter egg hunt, "
"5=soccer, 6=ghost replay") );
PARAM_PREFIX StringUserConfigParam m_default_kart
PARAM_DEFAULT( StringUserConfigParam("tux", "kart",
"Kart to select by default (the last used kart)") );
@ -727,13 +728,13 @@ namespace UserConfigParams
/** If high scores will not be saved. For repeated testing on tracks. */
PARAM_PREFIX bool m_no_high_scores PARAM_DEFAULT(false);
/** If gamepad debugging is enabled. */
/** If unit testing is enabled. */
PARAM_PREFIX bool m_unit_testing PARAM_DEFAULT(false);
/** If gamepad debugging is enabled. */
PARAM_PREFIX bool m_gamepad_debug PARAM_DEFAULT( false );
/** If gamepad debugging is enabled. */
/** If keyboard debugging is enabled. */
PARAM_PREFIX bool m_keyboard_debug PARAM_DEFAULT(false);
/** Wiimote debugging. */
@ -755,7 +756,7 @@ namespace UserConfigParams
/** True if physics debugging should be enabled. */
PARAM_PREFIX bool m_physics_debug PARAM_DEFAULT( false );
/** True if fps should be printed each frame. */
/** True if FPS should be printed each frame. */
PARAM_PREFIX bool m_fps_debug PARAM_DEFAULT(false);
/** True if arena (battle/soccer) ai profiling. */

View File

@ -74,6 +74,8 @@ void CameraDebug::getCameraSettings(float *above_kart, float *cam_angle,
*distance = -m_kart->getKartModel()->getLength()-1.0f;
break;
case CM_DEBUG_SIDE_OF_KART:
case CM_DEBUG_INV_SIDE_OF_KART:
case CM_DEBUG_FRONT_OF_KART:
case CM_DEBUG_TOP_OF_KART:
*above_kart = 0.75f;
*cam_angle = UserConfigParams::m_camera_forward_up_angle * DEGREE_TO_RAD;
@ -122,6 +124,22 @@ void CameraDebug::update(float dt)
m_camera->setTarget(xyz);
m_camera->setPosition(offset.toIrrVector());
}
else if (m_default_debug_Type==CM_DEBUG_INV_SIDE_OF_KART)
{
core::vector3df xyz = m_kart->getSmoothedXYZ().toIrrVector();
Vec3 offset(-3, 0, 0);
offset = m_kart->getSmoothedTrans()(offset);
m_camera->setTarget(xyz);
m_camera->setPosition(offset.toIrrVector());
}
else if (m_default_debug_Type==CM_DEBUG_FRONT_OF_KART)
{
core::vector3df xyz = m_kart->getSmoothedXYZ().toIrrVector();
Vec3 offset(0, 1, 2);
offset = m_kart->getSmoothedTrans()(offset);
m_camera->setTarget(xyz);
m_camera->setPosition(offset.toIrrVector());
}
// If an explosion is happening, stop moving the camera,
// but keep it target on the kart.
else if (dynamic_cast<ExplosionAnimation*>(m_kart->getKartAnimation()))

View File

@ -38,6 +38,8 @@ public:
CM_DEBUG_GROUND, //!< Camera at ground level, wheel debugging
CM_DEBUG_BEHIND_KART, //!< Camera straight behind kart
CM_DEBUG_SIDE_OF_KART, //!< Camera to the right of the kart
CM_DEBUG_INV_SIDE_OF_KART, //!< Camera to the left of the kart
CM_DEBUG_FRONT_OF_KART, //!< Camera to the front of the kart
}; // CameraDebugType
private:

View File

@ -1762,14 +1762,18 @@ video::SColorf IrrDriver::getAmbientLight() const
void IrrDriver::displayFPS()
{
#ifndef SERVER_ONLY
gui::IGUIFont* font = GUIEngine::getSmallFont();
gui::ScalableFont* font = GUIEngine::getSmallFont();
font->setScale(0.7f);
core::rect<s32> position;
const int fheight = font->getHeightPerLine();
const int rwidth = irr_driver->getActualScreenSize().Width / 6;
const int swidth = irr_driver->getActualScreenSize().Width / 3;
if (UserConfigParams::m_artist_debug_mode)
position = core::rect<s32>(51, 0, 30*fheight+51, 2*fheight + fheight / 3);
position = core::rect<s32>(rwidth - 20, 0, int(rwidth * 4.25), 2 * fheight + (fheight / 5));
else
position = core::rect<s32>(75, 0, 18*fheight+75 , fheight + fheight / 5);
position = core::rect<s32>(swidth, 0, swidth * 2, fheight + (fheight / 5));
GL32_draw2DRectangle(video::SColor(150, 96, 74, 196), position, NULL);
// We will let pass some time to let things settle before trusting FPS counter
// even if we also ignore fps = 1, which tends to happen in first checks
@ -1805,12 +1809,15 @@ void IrrDriver::displayFPS()
{
no_trust--;
static video::SColor fpsColor = video::SColor(255, 0, 0, 0);
static video::SColor fpsColor = video::SColor(255, 255, 255, 255);
fps_string = _("FPS: %d/%d/%d - %d KTris, Ping: %dms", "-", "-",
"-", SP::sp_solid_poly_count / 1000, ping);
font->drawQuick(fps_string,
core::rect< s32 >(100,0,400,50), fpsColor, false);
font->setBlackBorder(true);
font->setThinBorder(true);
font->drawQuick(fps_string, position, fpsColor, false);
font->setThinBorder(false);
font->setBlackBorder(false);
return;
}
@ -1828,9 +1835,8 @@ void IrrDriver::displayFPS()
if ((UserConfigParams::m_artist_debug_mode)&&(CVS->isGLSL()))
{
fps_string = StringUtils::insertValues
(L"FPS: %d/%d/%d - PolyCount: %d Solid, "
"%d Shadows - LightDist : %d\nComplexity %d, Total skinning joints: %d, "
"Ping: %dms",
(L"FPS: %d/%d/%d - PolyCount: %d Solid, %d Shadows - LightDist: %d\n"
"Complexity %d, Total skinning joints: %d, Ping: %dms",
min, fps, max, SP::sp_solid_poly_count,
SP::sp_shadow_poly_count, m_last_light_bucket_distance, irr_driver->getSceneComplexity(),
m_skinning_joint, ping);
@ -1849,9 +1855,14 @@ void IrrDriver::displayFPS()
}
}
static video::SColor fpsColor = video::SColor(255, 0, 0, 0);
static video::SColor fpsColor = video::SColor(255, 255, 255, 255);
font->setBlackBorder(true);
font->setThinBorder(true);
font->drawQuick(fps_string.c_str(), position, fpsColor, false);
font->setThinBorder(false);
font->setBlackBorder(false);
font->drawQuick( fps_string.c_str(), position, fpsColor, false );
#endif
} // updateFPS

View File

@ -253,21 +253,17 @@ void InputManager::handleStaticAction(int key, int value)
// When no players... a cutscene
if (RaceManager::get() &&
RaceManager::get()->getNumPlayers() == 0 && world != NULL && value > 0 &&
(key == IRR_KEY_SPACE || key == IRR_KEY_RETURN ||
(key == IRR_KEY_SPACE || key == IRR_KEY_RETURN ||
key == IRR_KEY_BUTTON_A))
{
world->onFirePressed(NULL);
}
if (world != NULL && UserConfigParams::m_artist_debug_mode &&
control_is_pressed && value > 0)
if (world != NULL && UserConfigParams::m_artist_debug_mode)
{
if (Debug::handleStaticAction(key))
return;
Debug::handleStaticAction(key, value, control_is_pressed, shift_is_pressed);
}
// TODO: move debug shortcuts to Debug::handleStaticAction
switch (key)
{
#ifdef DEBUG
@ -285,137 +281,31 @@ void InputManager::handleStaticAction(int key, int value)
{
if(!ProfileWorld::isProfileMode() || !world) break;
int kart_id = key - IRR_KEY_1;
if(kart_id<0 || kart_id>=(int)world->getNumKarts()) break;
if(kart_id < 0 || kart_id >= (int)world->getNumKarts()) break;
Camera::getCamera(0)->setKart(world->getKart(kart_id));
break;
}
#endif
case IRR_KEY_CONTROL:
case IRR_KEY_RCONTROL:
case IRR_KEY_LCONTROL:
case IRR_KEY_RMENU:
case IRR_KEY_LMENU:
case IRR_KEY_LWIN:
control_is_pressed = value!=0;
{
control_is_pressed = value != 0;
break;
}
case IRR_KEY_LSHIFT:
case IRR_KEY_RSHIFT:
case IRR_KEY_SHIFT:
shift_is_pressed = value!=0; break;
// Flying up and down
case IRR_KEY_I:
{
if (!world || !UserConfigParams::m_artist_debug_mode) break;
AbstractKart* kart = world->getLocalPlayerKart(0);
if (kart == NULL) break;
kart->flyUp();
shift_is_pressed = value != 0;
break;
}
case IRR_KEY_K:
{
if (!world || !UserConfigParams::m_artist_debug_mode) break;
AbstractKart* kart = world->getLocalPlayerKart(0);
if (kart == NULL) break;
kart->flyDown();
break;
}
// Moving the first person camera
case IRR_KEY_W:
{
CameraFPS *cam = dynamic_cast<CameraFPS*>(Camera::getActiveCamera());
if (world && UserConfigParams::m_artist_debug_mode && cam )
{
core::vector3df vel(cam->getLinearVelocity());
vel.Z = value ? cam->getMaximumVelocity() : 0;
cam->setLinearVelocity(vel);
}
break;
}
case IRR_KEY_S:
{
CameraFPS *cam = dynamic_cast<CameraFPS*>(Camera::getActiveCamera());
if (world && UserConfigParams::m_artist_debug_mode && cam)
{
core::vector3df vel(cam->getLinearVelocity());
vel.Z = value ? -cam->getMaximumVelocity() : 0;
cam->setLinearVelocity(vel);
}
break;
}
case IRR_KEY_D:
{
CameraFPS *cam = dynamic_cast<CameraFPS*>(Camera::getActiveCamera());
if (world && !UserConfigParams::m_artist_debug_mode && cam)
{
core::vector3df vel(cam->getLinearVelocity());
vel.X = value ? -cam->getMaximumVelocity() : 0;
cam->setLinearVelocity(vel);
}
break;
}
case IRR_KEY_A:
{
CameraFPS *cam = dynamic_cast<CameraFPS*>(Camera::getActiveCamera());
if (world && UserConfigParams::m_artist_debug_mode && cam)
{
core::vector3df vel(cam->getLinearVelocity());
vel.X = value ? cam->getMaximumVelocity() : 0;
cam->setLinearVelocity(vel);
}
break;
}
case IRR_KEY_R:
{
CameraFPS *cam = dynamic_cast<CameraFPS*>(Camera::getActiveCamera());
if (world && UserConfigParams::m_artist_debug_mode && cam)
{
core::vector3df vel(cam->getLinearVelocity());
vel.Y = value ? cam->getMaximumVelocity() : 0;
cam->setLinearVelocity(vel);
}
break;
}
case IRR_KEY_F:
{
CameraFPS *cam = dynamic_cast<CameraFPS*>(Camera::getActiveCamera());
if (world && UserConfigParams::m_artist_debug_mode && cam)
{
core::vector3df vel(cam->getLinearVelocity());
vel.Y = value ? -cam->getMaximumVelocity() : 0;
cam->setLinearVelocity(vel);
}
break;
}
// Rotating the first person camera
case IRR_KEY_Q:
{
CameraFPS *cam = dynamic_cast<CameraFPS*>(Camera::getActiveCamera());
if (world && UserConfigParams::m_artist_debug_mode && cam )
{
cam->setAngularVelocity(value ?
UserConfigParams::m_fpscam_max_angular_velocity : 0.0f);
}
break;
}
case IRR_KEY_E:
{
CameraFPS *cam = dynamic_cast<CameraFPS*>(Camera::getActiveCamera());
if (world && UserConfigParams::m_artist_debug_mode && cam)
{
cam->setAngularVelocity(value ?
-UserConfigParams::m_fpscam_max_angular_velocity : 0);
}
break;
}
case IRR_KEY_SNAPSHOT:
case IRR_KEY_PRINT:
{
// on windows we don't get a press event, only release. So
// save on release only (to avoid saving twice on other platforms)
if (value == 0)
@ -431,139 +321,56 @@ void InputManager::handleStaticAction(int key, int value)
}
}
break;
}
case IRR_KEY_F11:
if(value && shift_is_pressed)
{
#ifndef SERVER_ONLY
ShaderBasedRenderer* sbr = SP::getRenderer();
if (sbr)
sbr->dumpRTT();
#endif
}
break;
/*
else if (UserConfigParams::m_artist_debug_mode && world)
{
AbstractKart* kart = world->getLocalPlayerKart(0);
if (control_is_pressed)
kart->setPowerup(PowerupManager::POWERUP_SWATTER, 10000);
else
kart->setPowerup(PowerupManager::POWERUP_RUBBERBALL, 10000);
#ifdef FORCE_RESCUE_ON_FIRST_KART
// Can be useful for debugging places where the AI gets into
// a rescue loop: rescue, drive, crash, rescue to same place
world->getKart(0)->forceRescue();
#endif
}
break;
case IRR_KEY_F2:
if (UserConfigParams::m_artist_debug_mode && world)
{
AbstractKart* kart = world->getLocalPlayerKart(0);
kart->setPowerup(PowerupManager::POWERUP_PLUNGER, 10000);
}
break;
case IRR_KEY_F3:
if (UserConfigParams::m_artist_debug_mode && world)
{
AbstractKart* kart = world->getLocalPlayerKart(0);
kart->setPowerup(PowerupManager::POWERUP_CAKE, 10000);
}
break;
case IRR_KEY_F4:
if (UserConfigParams::m_artist_debug_mode && world)
{
AbstractKart* kart = world->getLocalPlayerKart(0);
kart->setPowerup(PowerupManager::POWERUP_SWITCH, 10000);
}
break;
case IRR_KEY_F5:
if (UserConfigParams::m_artist_debug_mode && world)
{
AbstractKart* kart = world->getLocalPlayerKart(0);
kart->setPowerup(PowerupManager::POWERUP_BOWLING, 10000);
}
break;
case IRR_KEY_F6:
if (UserConfigParams::m_artist_debug_mode && world)
{
AbstractKart* kart = world->getLocalPlayerKart(0);
kart->setPowerup(PowerupManager::POWERUP_BUBBLEGUM, 10000);
}
break;
case IRR_KEY_F7:
if (UserConfigParams::m_artist_debug_mode && world)
{
AbstractKart* kart = world->getLocalPlayerKart(0);
kart->setPowerup(PowerupManager::POWERUP_ZIPPER, 10000);
}
break;
case IRR_KEY_F8:
if (UserConfigParams::m_artist_debug_mode && value && world)
{
if (value && world)
{
if (control_is_pressed)
{
RaceGUIBase* gui = world->getRaceGUI();
if (gui != NULL) gui->m_enabled = !gui->m_enabled;
const int count = World::getWorld()->getNumKarts();
for (int n=0; n<count; n++)
{
if(World::getWorld()->getKart(n)->getController()->isPlayerController())
World::getWorld()->getKart(n)->getNode()
->setVisible(gui->m_enabled);
}
}
else
{
AbstractKart* kart = world->getLocalPlayerKart(0);
kart->setEnergy(100.0f);
}
}
break;
case IRR_KEY_F9:
if (UserConfigParams::m_artist_debug_mode && world)
{
AbstractKart* kart = world->getLocalPlayerKart(0);
if(control_is_pressed && RaceManager::get()->getMinorMode()!=
RaceManager::MINOR_MODE_3_STRIKES)
kart->setPowerup(PowerupManager::POWERUP_RUBBERBALL,
10000);
else
kart->setPowerup(PowerupManager::POWERUP_SWATTER, 10000);
}
break;
*/
case IRR_KEY_F10:
if(world && value)
{
if(control_is_pressed)
ReplayRecorder::get()->save();
else
history->Save();
}
else if (shift_is_pressed)
{
#ifndef SERVER_ONLY
ShaderBasedRenderer* sbr = SP::getRenderer();
if (sbr)
{
sbr->dumpRTT();
}
#endif
}
else
{
ReplayRecorder::get()->save();
}
}
break;
/*
case IRR_KEY_F11:
if (UserConfigParams::m_artist_debug_mode && value &&
control_is_pressed && world)
{
world->getPhysics()->nextDebugMode();
}
break;
*/
}
case IRR_KEY_F12:
if(value)
UserConfigParams::m_display_fps =
{
if (value)
{
if (control_is_pressed)
{
UserConfigParams::m_karts_powerup_gui =
!UserConfigParams::m_karts_powerup_gui;
}
else if (shift_is_pressed)
{
UserConfigParams::m_soccer_player_list =
!UserConfigParams::m_soccer_player_list;
}
else
{
UserConfigParams::m_display_fps =
!UserConfigParams::m_display_fps;
}
}
break;
default:
break;
} // switch
}
default : break;
}
} // handleStaticAction
//-----------------------------------------------------------------------------
@ -740,15 +547,15 @@ int InputManager::getPlayerKeyboardID() const
}
//-----------------------------------------------------------------------------
/** Handles the conversion from some input to a GameAction and its distribution
* to the currently active menu.
* It also handles whether the game is currently sensing input. It does so by
* suppressing the distribution of the input as a GameAction. Instead the
* input is stored in 'm_sensed_input' and GA_SENSE_COMPLETE is distributed. If
* however the input in question has resolved to GA_LEAVE this is treated as
* an attempt of the user to cancel the sensing. In that case GA_SENSE_CANCEL
* is distributed.
* to the currently active menu.
* It also handles whether the game is currently sensing input. It does so by
* suppressing the distribution of the input as a GameAction. Instead the
* input is stored in 'm_sensed_input' and GA_SENSE_COMPLETE is distributed. If
* however the input in question has resolved to GA_LEAVE this is treated as
* an attempt of the user to cancel the sensing. In that case GA_SENSE_CANCEL
* is distributed.
*
* Note: It is the obligation of the called menu to switch of the sense mode.
* Note: It is the obligation of the called menu to switch of the sense mode.
*
*/
void InputManager::dispatchInput(Input::InputType type, int deviceID,
@ -780,8 +587,10 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
return;
}
// Abort demo mode if a key is pressed during the race in demo mode
if(dynamic_cast<DemoWorld*>(World::getWorld()))
// Abort demo mode if a key is pressed during the race in demo mode,
// if a dialog is not active
if(dynamic_cast<DemoWorld*>(World::getWorld()) &&
!GUIEngine::ModalDialog::isADialogActive())
{
RaceManager::get()->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
@ -796,7 +605,7 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
&player, &action);
// in menus, some keyboard keys are standard (before each player selected
// his device). So if a key could not be mapped to any known binding,
// their device). So if a key could not be mapped to any known binding,
// fall back to check the defaults.
if (!action_found &&
StateManager::get()->getGameState() != GUIEngine::GAME &&
@ -1166,7 +975,7 @@ EventPropagation InputManager::input(const SEvent& event)
// single letter). Same for spacebar. Same for letters.
if (GUIEngine::isWithinATextBox())
{
if (key == IRR_KEY_BACK || key == IRR_KEY_SPACE ||
if (key == IRR_KEY_BACK || key == IRR_KEY_SPACE ||
key == IRR_KEY_SHIFT)
{
return EVENT_LET;
@ -1199,7 +1008,7 @@ EventPropagation InputManager::input(const SEvent& event)
// single letter). Same for spacebar. Same for letters.
if (GUIEngine::isWithinATextBox())
{
if (key == IRR_KEY_BACK || key == IRR_KEY_SPACE ||
if (key == IRR_KEY_BACK || key == IRR_KEY_SPACE ||
key == IRR_KEY_SHIFT)
{
return EVENT_LET;
@ -1322,18 +1131,18 @@ EventPropagation InputManager::input(const SEvent& event)
}
// Simulate touch events if there is no real device
if (UserConfigParams::m_multitouch_active > 1 &&
if (UserConfigParams::m_multitouch_active > 1 &&
!irr_driver->getDevice()->supportsTouchDevice())
{
MultitouchDevice* device = m_device_manager->getMultitouchDevice();
if (device != NULL && (type == EMIE_LMOUSE_PRESSED_DOWN ||
type == EMIE_LMOUSE_LEFT_UP || type == EMIE_MOUSE_MOVED))
{
device->m_events[0].id = 0;
device->m_events[0].x = event.MouseInput.X;
device->m_events[0].y = event.MouseInput.Y;
if (type == EMIE_LMOUSE_PRESSED_DOWN)
{
device->m_events[0].touched = true;
@ -1342,7 +1151,7 @@ EventPropagation InputManager::input(const SEvent& event)
{
device->m_events[0].touched = false;
}
m_device_manager->updateMultitouchDevice();
device->updateDeviceState(0);
}
@ -1368,7 +1177,7 @@ EventPropagation InputManager::input(const SEvent& event)
if (device && device->isAccelerometerActive())
{
m_device_manager->updateMultitouchDevice();
float factor = UserConfigParams::m_multitouch_tilt_factor;
factor = std::max(factor, 0.1f);
if (UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_GYROSCOPE)

View File

@ -198,6 +198,18 @@ void Powerup::set(PowerupManager::PowerupType type, int n)
} // set
//-----------------------------------------------------------------------------
/** Sets the amount of the current collected item.
* \param n Number of items.
*/
void Powerup::setNum(int n)
{
// Limit to 255 (save space in network state saving)
if(n>255) n = 255;
m_number=n;
}
//-----------------------------------------------------------------------------
/** Returns the icon for the currently collected powerup. Used in the
* race_gui to display the collected item.

View File

@ -54,7 +54,8 @@ private:
public:
Powerup (AbstractKart* kart_);
~Powerup ();
void set (PowerupManager::PowerupType _type, int n=1);
void set (PowerupManager::PowerupType _type, int n = 1);
void setNum (int n = 1);
void reset ();
Material* getIcon () const;
void adjustSound ();

View File

@ -1251,6 +1251,9 @@ void SkiddingAI::handleItems(const float dt, const Vec3 *aim_point, int last_nod
break;
}// POWERUP_PARACHUTE
case PowerupManager::POWERUP_ANVIL:
break; // POWERUP_ANVIL
case PowerupManager::POWERUP_SWATTER:
{
// if the kart has a shield, do not break it by using a swatter.

View File

@ -590,6 +590,10 @@ void cmdLineHelp()
"seconds.\n"
" --unlock-all Permanently unlock all karts and tracks for testing.\n"
" --no-unlock-all Disable unlock-all (i.e. base unlocking on player achievement).\n"
" --xmas=n Toggle Xmas/Christmas mode. n=0 Use current date, n=1, Always enable,\n"
" n=2, Always disable.\n"
" --easter=n Toggle Easter ears mode. n=0 Use current date, n=1, Always enable,\n"
" n=2, Always disable.\n"
" --no-graphics Do not display the actual race.\n"
" --sp-shader-debug Enables debug in sp shader, it will print all unavailable uniforms.\n"
" --demo-mode=t Enables demo mode after t seconds of idle time in "
@ -598,13 +602,7 @@ void cmdLineHelp()
" spaces are allowed in the track names.\n"
" --demo-laps=n Number of laps to use in a demo.\n"
" --demo-karts=n Number of karts to use in a demo.\n"
// " --history Replay history file 'history.dat'.\n"
// " --test-ai=n Use the test-ai for every n-th AI kart.\n"
// " (so n=1 means all Ais will be the test ai)\n"
// "
// " --disable-item-collection Disable item collection. Useful for\n"
// " debugging client/server item management.\n"
// " --network-item-debugging Print item handling debug information.\n"
" --history Replay history file 'history.dat'.\n"
" --server-config=file Specify the server_config.xml for server hosting, it will create\n"
" one if not found.\n"
" --network-console Enable network console.\n"
@ -646,6 +644,7 @@ void cmdLineHelp()
" --no-console-log Does not write messages in the console but to\n"
" stdout.log.\n"
" -h, --help Show this help.\n"
" --help-debug Show help for debugging options.\n"
" --log=N Set the verbosity to a value between\n"
" 0 (Debug) and 5 (Only Fatal messages)\n"
" --logbuffer=N Buffers up to N lines log lines before writing.\n"
@ -687,6 +686,9 @@ void cmdLineHelp()
" --apitrace This will disable buffer storage and\n"
" writing gpu query strings to opengl, which\n"
" can be seen later in apitrace.\n"
#ifdef ENABLE_WIIUSE
" --wii Enable usage of Wii Remotes.\n"
#endif
#if defined(__linux__) || defined(__FreeBSD__)
"\n"
"Environment variables:\n"
@ -702,6 +704,51 @@ void cmdLineHelp()
);
} // cmdLineHelp
void cmdDebugHelp()
{
fprintf(stdout,
"Usage: %s [OPTIONS]\n\n"
"Run SuperTuxKart, a go-kart racing game that features "
"Tux and friends.\n\n"
"Debug options (some work only if artist debug mode is enabled):\n"
" --debug=s s=all Log everything, s=addons Log addons management,\n"
" s=gui Log GUI events, s=flyable Log flyables,\n"
" s=memory Log memory usage, s=misc Log other events.\n"
" --gamepad-visuals Debug gamepads by visualising their values.\n"
" --no-high-scores Disable writing high scores.\n"
" --unit-testing Run unit tests and exit.\n"
" --gamepad-debug Enable verbose logging of gamepad button presses.\n"
" --keyboard-debug Enable verbose logging of keyboard key presses.\n"
" --wiimote-debug Enable verbose logging of Wii Remote button presses.\n"
" --tutorial-debug Enable verbose logging of the tutorial mode.\n"
" --track-debug Enable displaying the driveline in tracks.\n"
" --check-debug Enable displaying the checklines in tracks.\n"
" --kartsize-debug Enable verbose logging of kart dimensions\n"
" and mesh buffer counts.\n"
" --physics-debug Enable verbose logging of the physics system.\n"
" --material-debug Enable verbose logging of terrain specific slowdowns.\n"
" --ftl-debug Enable verbose logging in follow-the-leader mode.\n"
" --slipstream-debug Enable displaying of slipstreams more prominently.\n"
" --rendering-debug Enable displaying of ambient/diffuse/specularity\n"
" in RGB & all anisotropic.\n"
" --ai-debug Enable displaying of AI controllers as on-screen text.\n"
" Makes it easier to distingush between different AI controllers.\n"
" --fps-debug Enable verbose logging of the FPS counter on every frame.\n"
" --rewind Enable the rewind manager.\n"
" --battle-ai-stats Enable verbose logging of AI karts in battle modes.\n"
" --soccer-ai-stats Enable verbose logging of AI karts in soccer mode.\n"
" --test-ai=n Use the test-ai for every n-th AI kart.\n"
" (so n=1 means all Ais will be the test ai)\n"
" --disable-item-collection Disable item collection. Useful for\n"
" debugging client/server item management.\n"
" --network-item-debugging Print item handling debug information.\n"
"\n"
"You can visit SuperTuxKart's homepage at "
"https://supertuxkart.net\n\n",
CommandLine::getExecName().c_str()
);
} // cmdDebugHelp
//=============================================================================
/** For base options that modify the output (loglevel/color) or exit right
* after being processed (version/help).
@ -716,6 +763,13 @@ int handleCmdLineOutputModifier()
exit(0);
}
if (CommandLine::has("--help-debug"))
{
cmdDebugHelp();
cleanUserConfig();
exit(0);
}
if(CommandLine::has("--version") || CommandLine::has("-v"))
{
Log::info("main", "==============================");
@ -752,8 +806,7 @@ int handleCmdLineOutputModifier()
*/
int handleCmdLinePreliminary()
{
if(CommandLine::has("--gamepad-visualisation") || // only BE
CommandLine::has("--gamepad-visualization") ) // both AE and BE
if(CommandLine::has("--gamepad-visuals"))
UserConfigParams::m_gamepad_visualisation=true;
if(CommandLine::has("--debug=memory"))
UserConfigParams::m_verbosity |= UserConfigParams::LOG_MEMORY;
@ -956,10 +1009,10 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
irr::core::stringw login, password;
if (CommandLine::has("--unit-testing"))
UserConfigParams::m_unit_testing = true;
if (CommandLine::has("--no-high-scores"))
UserConfigParams::m_no_high_scores=true;
if (CommandLine::has("--unit-testing"))
UserConfigParams::m_unit_testing = true;
if (CommandLine::has("--gamepad-debug"))
UserConfigParams::m_gamepad_debug=true;
if (CommandLine::has("--keyboard-debug"))
@ -1027,21 +1080,6 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
if (UserConfigParams::m_artist_debug_mode)
{
if (CommandLine::has("--camera-wheel-debug"))
{
Camera::setDefaultCameraType(Camera::CM_TYPE_DEBUG);
CameraDebug::setDebugType(CameraDebug::CM_DEBUG_GROUND);
}
if(CommandLine::has("--camera-debug"))
{
Camera::setDefaultCameraType(Camera::CM_TYPE_DEBUG);
CameraDebug::setDebugType(CameraDebug::CM_DEBUG_TOP_OF_KART);
}
if(CommandLine::has("--camera-kart-debug"))
{
Camera::setDefaultCameraType(Camera::CM_TYPE_DEBUG);
CameraDebug::setDebugType(CameraDebug::CM_DEBUG_BEHIND_KART);
}
if(CommandLine::has("--physics-debug"))
UserConfigParams::m_physics_debug=1;
if(CommandLine::has("--check-debug"))

View File

@ -32,7 +32,7 @@ using namespace GUIEngine;
// ------------------------------------------------------------------------------------------------------
DebugSliderDialog::DebugSliderDialog() : ModalDialog(0.85f, 0.4f, MODAL_DIALOG_LOCATION_BOTTOM)
DebugSliderDialog::DebugSliderDialog() : ModalDialog(0.85f, 0.45f, MODAL_DIALOG_LOCATION_BOTTOM)
{
m_fade_background = false;
@ -56,6 +56,13 @@ void DebugSliderDialog::changeLabel(std::string id, std::string new_label)
// ------------------------------------------------------------------------------------------------------
void DebugSliderDialog::toggleSlider(std::string id, bool option)
{
getWidget<SpinnerWidget>(id.c_str())->setActive(option);
}
// ------------------------------------------------------------------------------------------------------
void DebugSliderDialog::onEnterPressedInternal()
{
}
@ -64,6 +71,12 @@ void DebugSliderDialog::onEnterPressedInternal()
GUIEngine::EventPropagation DebugSliderDialog::processEvent(const std::string& eventSource)
{
if (eventSource == "close")
{
ModalDialog::dismiss();
return GUIEngine::EVENT_BLOCK;
}
if (Setters.find(eventSource) == Setters.end())
return GUIEngine::EVENT_LET;

View File

@ -41,6 +41,7 @@ public:
~DebugSliderDialog() {};
void setSliderHook(std::string id, unsigned min, unsigned max, std::function<int()> G, std::function<void(int)> S);
void changeLabel(std::string id, std::string new_label);
void toggleSlider(std::string id, bool option);
virtual void onEnterPressedInternal() OVERRIDE;
virtual void onUpdate(float dt) OVERRIDE;

View File

@ -31,7 +31,7 @@ using namespace GUIEngine;
// ------------------------------------------------------------------------------------------------------
TutorialMessageDialog::TutorialMessageDialog(irr::core::stringw msg, bool stopGame) :
ModalDialog(0.85f, 0.25f, MODAL_DIALOG_LOCATION_BOTTOM)
ModalDialog(0.85f, 0.95f, MODAL_DIALOG_LOCATION_CENTER)
{
m_stop_game = stopGame;
@ -47,10 +47,8 @@ TutorialMessageDialog::TutorialMessageDialog(irr::core::stringw msg, bool stopGa
LabelWidget* message = getWidget<LabelWidget>("title");
message->setText( msg.c_str(), false );
ButtonWidget* cancelbtn = getWidget<ButtonWidget>("continue");
cancelbtn->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
World::getWorld()->getKart(0)->getControls().reset();
ButtonWidget* continuebtn = getWidget<ButtonWidget>("continue");
continuebtn->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
}
// ------------------------------------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,8 @@ namespace Debug
bool onEvent(const irr::SEvent &event);
bool isOpen();
void closeDebugMenu();
bool handleStaticAction(int key);
void handleStaticAction(int key, int value,
bool control_pressed, bool shift_pressed);
}