Minor fixes
- The code starting a tutorial race was duplicated in three places. Consolidate it in one place. - When launching the tutorial from the overworld, use the last used input device instead of the keyboard - Restore the old cmake policy. The new way to replace that code suggested by the cmake manual fails CI, and debugging MSVC fantasies without a local install is a nightmare. - Restrict this policy setting to MSVC as that's the only compile path that needs it, avoiding the warning for non-MSVC builds. - Add missing define guards - Remove some extraneous includes
This commit is contained in:
parent
e165a5680b
commit
2923a86cd6
@ -9,6 +9,10 @@ add_definitions( -DSUPERTUXKART_VERSION="${PROJECT_VERSION}" )
|
|||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
|
||||||
include(CMakeDependentOption)
|
include(CMakeDependentOption)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
cmake_policy(SET CMP0043 OLD)
|
||||||
|
endif()
|
||||||
|
|
||||||
include(BuildTypeSTKRelease)
|
include(BuildTypeSTKRelease)
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
message(STATUS "No build type selected, default to STKRelease")
|
message(STATUS "No build type selected, default to STKRelease")
|
||||||
|
@ -160,7 +160,9 @@ public:
|
|||||||
/** Returns the name of this player. */
|
/** Returns the name of this player. */
|
||||||
const core::stringw& getName() const
|
const core::stringw& getName() const
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
assert(m_magic_number == 0xABCD1234);
|
assert(m_magic_number == 0xABCD1234);
|
||||||
|
#endif
|
||||||
return m_local_name;
|
return m_local_name;
|
||||||
} // getName
|
} // getName
|
||||||
|
|
||||||
|
62
src/modes/tutorial_utils.cpp
Normal file
62
src/modes/tutorial_utils.cpp
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// SuperTuxKart - a fun racing game with go-kart
|
||||||
|
//
|
||||||
|
// Copyright (C) 2024 Alayan
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU General Public License
|
||||||
|
// as published by the Free Software Foundation; either version 3
|
||||||
|
// of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
#include "modes/tutorial_utils.hpp"
|
||||||
|
|
||||||
|
#include "config/player_manager.hpp"
|
||||||
|
#include "config/user_config.hpp"
|
||||||
|
#include "karts/kart_properties_manager.hpp"
|
||||||
|
#include "input/device_manager.hpp"
|
||||||
|
#include "input/input_manager.hpp"
|
||||||
|
#include "race/race_manager.hpp"
|
||||||
|
|
||||||
|
namespace TutorialUtils
|
||||||
|
{
|
||||||
|
void startTutorial(bool from_overworld)
|
||||||
|
{
|
||||||
|
RaceManager::get()->setNumPlayers(1);
|
||||||
|
RaceManager::get()->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
||||||
|
RaceManager::get()->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
|
||||||
|
RaceManager::get()->setNumKarts( 1 );
|
||||||
|
RaceManager::get()->setTrack( "tutorial" );
|
||||||
|
RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_EASY);
|
||||||
|
RaceManager::get()->setReverseTrack(false);
|
||||||
|
|
||||||
|
// Use the last used device
|
||||||
|
InputDevice* device = input_manager->getDeviceManager()->getLatestUsedDevice();
|
||||||
|
|
||||||
|
// Create player and associate player with device
|
||||||
|
StateManager::get()->createActivePlayer(PlayerManager::getCurrentPlayer(), device);
|
||||||
|
|
||||||
|
if (kart_properties_manager->getKart(UserConfigParams::m_default_kart) == NULL)
|
||||||
|
{
|
||||||
|
Log::warn("HelpScreen1", "Cannot find kart '%s', will revert to default",
|
||||||
|
UserConfigParams::m_default_kart.c_str());
|
||||||
|
UserConfigParams::m_default_kart.revertToDefaults();
|
||||||
|
}
|
||||||
|
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart);
|
||||||
|
|
||||||
|
// ASSIGN should make sure that only input from assigned devices is read.
|
||||||
|
input_manager->getDeviceManager()->setAssignMode(ASSIGN);
|
||||||
|
input_manager->getDeviceManager()->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
|
||||||
|
|
||||||
|
StateManager::get()->enterGameState();
|
||||||
|
RaceManager::get()->setupPlayerKartInfo();
|
||||||
|
RaceManager::get()->startNew(from_overworld);
|
||||||
|
}
|
||||||
|
}
|
27
src/modes/tutorial_utils.hpp
Normal file
27
src/modes/tutorial_utils.hpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// SuperTuxKart - a fun racing game with go-kart
|
||||||
|
//
|
||||||
|
// Copyright (C) 2024 Alayan
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU General Public License
|
||||||
|
// as published by the Free Software Foundation; either version 3
|
||||||
|
// of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
#ifndef __HEADER_TUTORIAL_UTILS_HPP__
|
||||||
|
#define __HEADER_TUTORIAL_UTILS_HPP__
|
||||||
|
|
||||||
|
namespace TutorialUtils
|
||||||
|
{
|
||||||
|
void startTutorial(bool from_overworld = false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -52,6 +52,7 @@
|
|||||||
#include "karts/kart_rewinder.hpp"
|
#include "karts/kart_rewinder.hpp"
|
||||||
#include "main_loop.hpp"
|
#include "main_loop.hpp"
|
||||||
#include "modes/overworld.hpp"
|
#include "modes/overworld.hpp"
|
||||||
|
#include "modes/tutorial_utils.hpp"
|
||||||
#include "network/child_loop.hpp"
|
#include "network/child_loop.hpp"
|
||||||
#include "network/protocols/client_lobby.hpp"
|
#include "network/protocols/client_lobby.hpp"
|
||||||
#include "network/network_config.hpp"
|
#include "network/network_config.hpp"
|
||||||
@ -82,12 +83,6 @@
|
|||||||
#include "utils/translation.hpp"
|
#include "utils/translation.hpp"
|
||||||
#include "utils/string_utils.hpp"
|
#include "utils/string_utils.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <ctime>
|
|
||||||
#include <sstream>
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
#include <IrrlichtDevice.h>
|
#include <IrrlichtDevice.h>
|
||||||
#include <ISceneManager.h>
|
#include <ISceneManager.h>
|
||||||
|
|
||||||
@ -1016,7 +1011,6 @@ void World::updateWorld(int ticks)
|
|||||||
assert(m_magic_number == 0xB01D6543);
|
assert(m_magic_number == 0xB01D6543);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (m_schedule_pause)
|
if (m_schedule_pause)
|
||||||
{
|
{
|
||||||
pause(m_scheduled_pause_phase);
|
pause(m_scheduled_pause_phase);
|
||||||
@ -1067,41 +1061,8 @@ void World::updateWorld(int ticks)
|
|||||||
if (m_schedule_tutorial)
|
if (m_schedule_tutorial)
|
||||||
{
|
{
|
||||||
m_schedule_tutorial = false;
|
m_schedule_tutorial = false;
|
||||||
RaceManager::get()->setNumPlayers(1);
|
|
||||||
RaceManager::get()->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
|
||||||
RaceManager::get()->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
|
|
||||||
RaceManager::get()->setNumKarts( 1 );
|
|
||||||
RaceManager::get()->setTrack( "tutorial" );
|
|
||||||
RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_EASY);
|
|
||||||
RaceManager::get()->setReverseTrack(false);
|
|
||||||
|
|
||||||
// Use keyboard 0 by default (FIXME: let player choose?)
|
|
||||||
InputDevice* device = input_manager->getDeviceManager()->getKeyboard(0);
|
|
||||||
|
|
||||||
// Create player and associate player with keyboard
|
|
||||||
StateManager::get()->createActivePlayer(PlayerManager::getCurrentPlayer(),
|
|
||||||
device);
|
|
||||||
|
|
||||||
if (!kart_properties_manager->getKart(UserConfigParams::m_default_kart))
|
|
||||||
{
|
|
||||||
Log::warn("[World]",
|
|
||||||
"Cannot find kart '%s', will revert to default.",
|
|
||||||
UserConfigParams::m_default_kart.c_str());
|
|
||||||
UserConfigParams::m_default_kart.revertToDefaults();
|
|
||||||
}
|
|
||||||
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart);
|
|
||||||
|
|
||||||
// ASSIGN should make sure that only input from assigned devices
|
|
||||||
// is read.
|
|
||||||
input_manager->getDeviceManager()->setAssignMode(ASSIGN);
|
|
||||||
input_manager->getDeviceManager()
|
|
||||||
->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
|
|
||||||
|
|
||||||
delete this;
|
delete this;
|
||||||
|
TutorialUtils::startTutorial(true /*from overworld*/);
|
||||||
StateManager::get()->enterGameState();
|
|
||||||
RaceManager::get()->setupPlayerKartInfo();
|
|
||||||
RaceManager::get()->startNew(true);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1123,6 +1084,7 @@ void World::updateWorld(int ticks)
|
|||||||
|
|
||||||
void World::scheduleTutorial()
|
void World::scheduleTutorial()
|
||||||
{
|
{
|
||||||
|
printf("Tutorial scheduled\n");
|
||||||
m_schedule_exit_race = true;
|
m_schedule_exit_race = true;
|
||||||
m_schedule_tutorial = true;
|
m_schedule_tutorial = true;
|
||||||
} // scheduleTutorial
|
} // scheduleTutorial
|
||||||
|
@ -18,13 +18,8 @@
|
|||||||
// Manages includes common to all help screens
|
// Manages includes common to all help screens
|
||||||
#include "states_screens/help/help_common.hpp"
|
#include "states_screens/help/help_common.hpp"
|
||||||
|
|
||||||
#include "config/player_manager.hpp"
|
|
||||||
#include "config/user_config.hpp"
|
|
||||||
#include "guiengine/widgets/button_widget.hpp"
|
#include "guiengine/widgets/button_widget.hpp"
|
||||||
#include "input/device_manager.hpp"
|
#include "modes/tutorial_utils.hpp"
|
||||||
#include "input/input_manager.hpp"
|
|
||||||
#include "karts/kart_properties_manager.hpp"
|
|
||||||
#include "race/race_manager.hpp"
|
|
||||||
|
|
||||||
using namespace GUIEngine;
|
using namespace GUIEngine;
|
||||||
|
|
||||||
@ -46,38 +41,7 @@ void HelpScreen1::eventCallback(Widget* widget, const std::string& name, const i
|
|||||||
{
|
{
|
||||||
if (name == "startTutorial")
|
if (name == "startTutorial")
|
||||||
{
|
{
|
||||||
RaceManager::get()->setNumPlayers(1);
|
TutorialUtils::startTutorial();
|
||||||
RaceManager::get()->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
|
||||||
RaceManager::get()->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
|
|
||||||
RaceManager::get()->setNumKarts( 1 );
|
|
||||||
RaceManager::get()->setTrack( "tutorial" );
|
|
||||||
RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_EASY);
|
|
||||||
RaceManager::get()->setReverseTrack(false);
|
|
||||||
|
|
||||||
// Use the last used device
|
|
||||||
InputDevice* device = input_manager->getDeviceManager()->getLatestUsedDevice();
|
|
||||||
|
|
||||||
// Create player and associate player with keyboard
|
|
||||||
StateManager::get()->createActivePlayer(PlayerManager::getCurrentPlayer(),
|
|
||||||
device);
|
|
||||||
|
|
||||||
if (kart_properties_manager->getKart(UserConfigParams::m_default_kart) == NULL)
|
|
||||||
{
|
|
||||||
Log::warn("HelpScreen1", "Cannot find kart '%s', will revert to default",
|
|
||||||
UserConfigParams::m_default_kart.c_str());
|
|
||||||
UserConfigParams::m_default_kart.revertToDefaults();
|
|
||||||
}
|
|
||||||
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart);
|
|
||||||
|
|
||||||
// ASSIGN should make sure that only input from assigned devices
|
|
||||||
// is read.
|
|
||||||
input_manager->getDeviceManager()->setAssignMode(ASSIGN);
|
|
||||||
input_manager->getDeviceManager()
|
|
||||||
->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
|
|
||||||
|
|
||||||
StateManager::get()->enterGameState();
|
|
||||||
RaceManager::get()->setupPlayerKartInfo();
|
|
||||||
RaceManager::get()->startNew(false);
|
|
||||||
}
|
}
|
||||||
else if (name == "category")
|
else if (name == "category")
|
||||||
{
|
{
|
||||||
|
@ -38,8 +38,9 @@
|
|||||||
#include "karts/kart_properties_manager.hpp"
|
#include "karts/kart_properties_manager.hpp"
|
||||||
#include "main_loop.hpp"
|
#include "main_loop.hpp"
|
||||||
#include "modes/cutscene_world.hpp"
|
#include "modes/cutscene_world.hpp"
|
||||||
#include "modes/overworld.hpp"
|
|
||||||
#include "modes/demo_world.hpp"
|
#include "modes/demo_world.hpp"
|
||||||
|
#include "modes/overworld.hpp"
|
||||||
|
#include "modes/tutorial_utils.hpp"
|
||||||
#include "network/network_config.hpp"
|
#include "network/network_config.hpp"
|
||||||
#include "online/request_manager.hpp"
|
#include "online/request_manager.hpp"
|
||||||
#include "states_screens/addons_screen.hpp"
|
#include "states_screens/addons_screen.hpp"
|
||||||
@ -258,7 +259,7 @@ void MainMenuScreen::onUpdate(float delta)
|
|||||||
virtual void onConfirm()
|
virtual void onConfirm()
|
||||||
{
|
{
|
||||||
GUIEngine::ModalDialog::dismiss();
|
GUIEngine::ModalDialog::dismiss();
|
||||||
MainMenuScreen::getInstance()->startTutorial();
|
TutorialUtils::startTutorial();
|
||||||
} // onConfirm
|
} // onConfirm
|
||||||
}; // PlayTutorial
|
}; // PlayTutorial
|
||||||
|
|
||||||
@ -271,41 +272,6 @@ void MainMenuScreen::onUpdate(float delta)
|
|||||||
#endif
|
#endif
|
||||||
} // onUpdate
|
} // onUpdate
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
void MainMenuScreen::startTutorial()
|
|
||||||
{
|
|
||||||
RaceManager::get()->setNumPlayers(1);
|
|
||||||
RaceManager::get()->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
|
||||||
RaceManager::get()->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
|
|
||||||
RaceManager::get()->setNumKarts( 1 );
|
|
||||||
RaceManager::get()->setTrack("tutorial");
|
|
||||||
RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_EASY);
|
|
||||||
RaceManager::get()->setReverseTrack(false);
|
|
||||||
|
|
||||||
// Use the last used device
|
|
||||||
InputDevice* device = input_manager->getDeviceManager()->getLatestUsedDevice();
|
|
||||||
|
|
||||||
// Create player and associate player with device
|
|
||||||
StateManager::get()->createActivePlayer(PlayerManager::getCurrentPlayer(), device);
|
|
||||||
|
|
||||||
if (kart_properties_manager->getKart(UserConfigParams::m_default_kart) == NULL)
|
|
||||||
{
|
|
||||||
Log::warn("MainMenuScreen", "Cannot find kart '%s', will revert to default",
|
|
||||||
UserConfigParams::m_default_kart.c_str());
|
|
||||||
UserConfigParams::m_default_kart.revertToDefaults();
|
|
||||||
}
|
|
||||||
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart);
|
|
||||||
|
|
||||||
// ASSIGN should make sure that only input from assigned devices is read
|
|
||||||
input_manager->getDeviceManager()->setAssignMode(ASSIGN);
|
|
||||||
input_manager->getDeviceManager()
|
|
||||||
->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
|
|
||||||
|
|
||||||
StateManager::get()->enterGameState();
|
|
||||||
RaceManager::get()->setupPlayerKartInfo();
|
|
||||||
RaceManager::get()->startNew(false);
|
|
||||||
} // startTutorial
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
||||||
@ -509,7 +475,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
|||||||
}
|
}
|
||||||
else if (selection == "startTutorial")
|
else if (selection == "startTutorial")
|
||||||
{
|
{
|
||||||
startTutorial();
|
TutorialUtils::startTutorial();
|
||||||
}
|
}
|
||||||
else if (selection == "story")
|
else if (selection == "story")
|
||||||
{
|
{
|
||||||
|
@ -38,8 +38,6 @@ private:
|
|||||||
core::stringw m_news_text;
|
core::stringw m_news_text;
|
||||||
|
|
||||||
MainMenuScreen();
|
MainMenuScreen();
|
||||||
|
|
||||||
void startTutorial();
|
|
||||||
public:
|
public:
|
||||||
virtual void onUpdate(float delta) OVERRIDE;
|
virtual void onUpdate(float delta) OVERRIDE;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user