2023-04-23 15:10:35 +03:00
|
|
|
/*
|
|
|
|
* CArtifactsOfHeroMain.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 "CArtifactsOfHeroMain.h"
|
|
|
|
|
2024-03-30 17:18:50 +02:00
|
|
|
#include "../gui/CGuiHandler.h"
|
|
|
|
|
2023-04-23 15:10:35 +03:00
|
|
|
#include "../CPlayerInterface.h"
|
2023-10-14 22:00:39 +03:00
|
|
|
#include "../../lib/mapObjects/CGHeroInstance.h"
|
2023-04-23 15:10:35 +03:00
|
|
|
|
|
|
|
#include "../../CCallback.h"
|
2023-10-23 16:38:05 +03:00
|
|
|
#include "../../lib/networkPacks/ArtifactLocation.h"
|
2023-04-23 15:10:35 +03:00
|
|
|
|
2024-04-19 17:14:41 +03:00
|
|
|
CArtifactsOfHeroMain::CArtifactsOfHeroMain(const Point & position)
|
2023-04-23 15:10:35 +03:00
|
|
|
{
|
2024-05-20 15:31:07 +03:00
|
|
|
init(position, std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, _1));
|
|
|
|
enableGesture();
|
2023-04-23 15:10:35 +03:00
|
|
|
}
|
|
|
|
|
2024-04-16 17:45:31 +03:00
|
|
|
CArtifactsOfHeroMain::~CArtifactsOfHeroMain()
|
2023-07-06 22:14:12 +03:00
|
|
|
{
|
2024-04-16 17:45:31 +03:00
|
|
|
CArtifactsOfHeroBase::putBackPickedArtifact();
|
2023-07-06 22:14:12 +03:00
|
|
|
}
|
2024-03-30 17:18:50 +02:00
|
|
|
|
2024-04-27 02:08:47 +03:00
|
|
|
void CArtifactsOfHeroMain::keyPressed(EShortcut key)
|
|
|
|
{
|
|
|
|
if(!shortcutPressed)
|
2024-04-19 17:14:41 +03:00
|
|
|
{
|
2024-05-18 16:27:42 +00:00
|
|
|
int saveIdx = vstd::find_pos(costumeSaveShortcuts, key);
|
|
|
|
int loadIdx = vstd::find_pos(costumeLoadShortcuts, key);
|
|
|
|
|
|
|
|
if (saveIdx != -1)
|
|
|
|
{
|
|
|
|
shortcutPressed = true;
|
|
|
|
LOCPLINT->cb->manageHeroCostume(getHero()->id, saveIdx, true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (loadIdx != -1)
|
2024-04-27 02:08:47 +03:00
|
|
|
{
|
2024-05-18 16:27:42 +00:00
|
|
|
shortcutPressed = true;
|
|
|
|
LOCPLINT->cb->manageHeroCostume(getHero()->id, loadIdx, false);
|
2024-04-27 02:08:47 +03:00
|
|
|
return;
|
|
|
|
}
|
2024-04-19 17:14:41 +03:00
|
|
|
}
|
2024-03-30 17:18:50 +02:00
|
|
|
}
|
2024-04-27 02:08:47 +03:00
|
|
|
|
|
|
|
void CArtifactsOfHeroMain::keyReleased(EShortcut key)
|
|
|
|
{
|
2024-05-18 16:27:42 +00:00
|
|
|
if(vstd::contains(costumeSaveShortcuts, key) || vstd::contains(costumeLoadShortcuts, key))
|
2024-04-27 02:08:47 +03:00
|
|
|
shortcutPressed = false;
|
|
|
|
}
|