1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-05-17 22:22:59 +02:00
vcmi/client/lobby/CScenarioInfoScreen.cpp
Ivan Savenko a8a6be7ac1 Fix potential compatibility with C++20 / C++23 mode
This fixes several issues with compatibility with C++20. C++23 was also
tested, but apparently it does not have any additional breaking changes
compared to C++20 (or we don't have those).

VCMI still uses C++17 as before - goal is only to make potential
transition easier.

There were 2 cases that are deprecated in C++20 that we use:
- Floating point operations on enums are deprecated
- `this` can no longer be captured when using default capture by value
`[=]`

Both of those should now be replaced with code that works fine in both C+
+17 and in C++20 mode
2025-03-02 14:11:48 +00:00

67 lines
1.7 KiB
C++

/*
* CScenarioInfoScreen.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
#include "CScenarioInfoScreen.h"
#include "OptionsTab.h"
#include "../CPlayerInterface.h"
#include "../GameEngine.h"
#include "../GameInstance.h"
#include "../gui/Shortcut.h"
#include "../widgets/Buttons.h"
#include "../../CCallback.h"
#include "../../lib/texts/CGeneralTextHandler.h"
#include "../../lib/StartInfo.h"
#include "../../lib/mapping/CMapInfo.h"
#include "../../lib/mapping/CMapHeader.h"
#include "../../lib/GameLibrary.h"
CScenarioInfoScreen::CScenarioInfoScreen()
{
OBJECT_CONSTRUCTION;
pos.w = 800;
pos.h = 600;
pos = center();
localSi = new StartInfo(*GAME->interface()->cb->getStartInfo());
localMi = new CMapInfo();
localMi->mapHeader = std::unique_ptr<CMapHeader>(new CMapHeader(*GAME->interface()->cb->getMapHeader()));
screenType = ESelectionScreen::scenarioInfo;
card = std::make_shared<InfoCard>();
opt = std::make_shared<OptionsTab>();
opt->recActions = UPDATE | SHOWALL;
opt->recreate();
card->changeSelection();
card->iconDifficulty->setSelected(getCurrentDifficulty());
buttonBack = std::make_shared<CButton>(Point(584, 535), AnimationPath::builtin("SCNRBACK.DEF"), LIBRARY->generaltexth->zelp[105], [this](){ close();}, EShortcut::GLOBAL_CANCEL);
}
CScenarioInfoScreen::~CScenarioInfoScreen()
{
vstd::clear_pointer(localSi);
vstd::clear_pointer(localMi);
}
const CMapInfo * CScenarioInfoScreen::getMapInfo()
{
return localMi;
}
const StartInfo * CScenarioInfoScreen::getStartInfo()
{
return localSi;
}