2017-07-13 10:26:03 +02:00
|
|
|
/*
|
|
|
|
* InfoWindows.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
|
|
|
|
*
|
|
|
|
*/
|
2014-07-15 10:14:49 +03:00
|
|
|
#include "StdInc.h"
|
|
|
|
#include "InfoWindows.h"
|
|
|
|
|
|
|
|
#include "../CGameInfo.h"
|
|
|
|
#include "../CPlayerInterface.h"
|
2024-02-26 18:53:12 +02:00
|
|
|
#include "../PlayerLocalState.h"
|
2014-07-15 10:14:49 +03:00
|
|
|
|
2024-02-26 15:48:55 +02:00
|
|
|
#include "../adventureMap/AdventureMapInterface.h"
|
|
|
|
#include "../gui/CGuiHandler.h"
|
2023-02-01 20:42:06 +02:00
|
|
|
#include "../gui/CursorHandler.h"
|
2023-04-27 19:21:06 +02:00
|
|
|
#include "../gui/Shortcut.h"
|
2024-02-26 15:48:55 +02:00
|
|
|
#include "../gui/WindowHandler.h"
|
|
|
|
#include "../widgets/Buttons.h"
|
|
|
|
#include "../widgets/CComponent.h"
|
|
|
|
#include "../widgets/Images.h"
|
|
|
|
#include "../widgets/MiscWidgets.h"
|
|
|
|
#include "../widgets/TextControls.h"
|
|
|
|
#include "../windows/CMessage.h"
|
2014-07-15 10:14:49 +03:00
|
|
|
|
|
|
|
#include "../../CCallback.h"
|
|
|
|
|
|
|
|
#include "../../lib/CConfigHandler.h"
|
2024-05-18 13:04:10 +02:00
|
|
|
#include "../ConditionalWait.h"
|
2024-02-26 18:53:12 +02:00
|
|
|
#include "../../lib/gameState/InfoAboutArmy.h"
|
2023-08-21 14:42:41 +02:00
|
|
|
#include "../../lib/mapObjects/CGCreature.h"
|
2014-07-15 10:14:49 +03:00
|
|
|
#include "../../lib/mapObjects/CGHeroInstance.h"
|
|
|
|
#include "../../lib/mapObjects/CGTownInstance.h"
|
|
|
|
#include "../../lib/mapObjects/MiscObjects.h"
|
|
|
|
|
2024-02-26 18:53:12 +02:00
|
|
|
CSelWindow::CSelWindow( const std::string & Text, PlayerColor player, int charperline, const std::vector<std::shared_ptr<CSelectableComponent>> & comps, const std::vector<std::pair<AnimationPath, CFunctionList<void()>>> & Buttons, QueryID askID)
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
2024-02-26 18:53:12 +02:00
|
|
|
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
|
2024-02-26 15:48:55 +02:00
|
|
|
|
|
|
|
backgroundTexture = std::make_shared<CFilledTexture>(ImagePath::builtin("DiBoxBck"), pos);
|
|
|
|
|
2014-07-15 10:14:49 +03:00
|
|
|
ID = askID;
|
2024-02-26 18:53:12 +02:00
|
|
|
for(int i = 0; i < Buttons.size(); i++)
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
buttons.push_back(std::make_shared<CButton>(Point(0, 0), Buttons[i].first, CButton::tooltip(), Buttons[i].second));
|
2024-02-26 18:53:12 +02:00
|
|
|
if(!i && askID.getNum() >= 0)
|
2014-09-05 21:13:58 +03:00
|
|
|
buttons.back()->addCallback(std::bind(&CSelWindow::madeChoice, this));
|
|
|
|
buttons[i]->addCallback(std::bind(&CInfoWindow::close, this)); //each button will close the window apart from call-defined actions
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 23:12:20 +02:00
|
|
|
text = std::make_shared<CTextBox>(Text, Rect(0, 0, 250, 100), 0, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE);
|
2014-07-15 10:14:49 +03:00
|
|
|
|
2024-02-26 18:53:12 +02:00
|
|
|
if(buttons.size() > 1 && askID.getNum() >= 0) //cancel button functionality
|
2024-02-27 13:47:17 +02:00
|
|
|
buttons.back()->addCallback([askID](){LOCPLINT->cb->selectionMade(0, askID);});
|
2014-07-15 10:14:49 +03:00
|
|
|
|
2023-07-22 21:29:05 +02:00
|
|
|
if(buttons.size() == 1)
|
|
|
|
buttons.front()->assignedKey = EShortcut::GLOBAL_RETURN;
|
|
|
|
|
|
|
|
if(buttons.size() == 2)
|
|
|
|
{
|
|
|
|
buttons.front()->assignedKey = EShortcut::GLOBAL_ACCEPT;
|
|
|
|
buttons.back()->assignedKey = EShortcut::GLOBAL_CANCEL;
|
|
|
|
}
|
|
|
|
|
2024-02-26 18:53:12 +02:00
|
|
|
if(!comps.empty())
|
2024-04-14 12:09:39 +02:00
|
|
|
{
|
2024-02-26 23:26:06 +02:00
|
|
|
components = std::make_shared<CComponentBox>(comps, Rect(0,0,0,0));
|
2024-04-14 12:09:39 +02:00
|
|
|
for (auto & comp : comps)
|
|
|
|
comp->onChoose = [this](){ madeChoiceAndClose(); };
|
|
|
|
}
|
2024-02-26 18:32:15 +02:00
|
|
|
|
2014-07-15 10:14:49 +03:00
|
|
|
CMessage::drawIWindow(this, Text, player);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSelWindow::madeChoice()
|
|
|
|
{
|
|
|
|
if(ID.getNum() < 0)
|
|
|
|
return;
|
|
|
|
int ret = -1;
|
2024-02-26 18:53:12 +02:00
|
|
|
if(components)
|
2024-02-26 18:32:15 +02:00
|
|
|
ret = components->selectedIndex();
|
|
|
|
|
2024-02-26 18:53:12 +02:00
|
|
|
LOCPLINT->cb->selectionMade(ret + 1, ID);
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
|
2023-09-14 12:26:11 +02:00
|
|
|
void CSelWindow::madeChoiceAndClose()
|
|
|
|
{
|
|
|
|
madeChoice();
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
2024-02-27 13:47:17 +02:00
|
|
|
CInfoWindow::CInfoWindow(const std::string & Text, PlayerColor player, const TCompsInfo & comps, const TButtonsInfo & Buttons)
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
2024-02-26 18:53:12 +02:00
|
|
|
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
|
2014-07-15 10:14:49 +03:00
|
|
|
|
2024-02-26 15:48:55 +02:00
|
|
|
backgroundTexture = std::make_shared<CFilledTexture>(ImagePath::builtin("DiBoxBck"), pos);
|
|
|
|
|
2014-07-15 10:14:49 +03:00
|
|
|
ID = QueryID(-1);
|
2024-02-27 13:47:17 +02:00
|
|
|
for(const auto & Button : Buttons)
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
2024-02-27 13:47:17 +02:00
|
|
|
auto button = std::make_shared<CButton>(Point(0, 0), Button.first, CButton::tooltip(), std::bind(&CInfoWindow::close, this));
|
2018-03-17 06:23:22 +02:00
|
|
|
button->setBorderColor(Colors::METALLIC_GOLD);
|
2014-08-03 14:16:19 +03:00
|
|
|
button->addCallback(Button.second); //each button will close the window apart from call-defined actions
|
2014-07-15 10:14:49 +03:00
|
|
|
buttons.push_back(button);
|
|
|
|
}
|
|
|
|
|
2022-11-26 23:12:20 +02:00
|
|
|
text = std::make_shared<CTextBox>(Text, Rect(0, 0, 250, 100), 0, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE);
|
2014-07-15 10:14:49 +03:00
|
|
|
if(!text->slider)
|
|
|
|
{
|
2023-11-26 18:55:50 +02:00
|
|
|
int finalWidth = std::min(250, text->label->textSize.x + 32);
|
|
|
|
int finalHeight = text->label->textSize.y;
|
|
|
|
text->resize(Point(finalWidth, finalHeight));
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
|
2023-04-28 13:22:03 +02:00
|
|
|
if(buttons.size() == 1)
|
|
|
|
buttons.front()->assignedKey = EShortcut::GLOBAL_RETURN;
|
|
|
|
|
|
|
|
if(buttons.size() == 2)
|
|
|
|
{
|
|
|
|
buttons.front()->assignedKey = EShortcut::GLOBAL_ACCEPT;
|
|
|
|
buttons.back()->assignedKey = EShortcut::GLOBAL_CANCEL;
|
|
|
|
}
|
|
|
|
|
2024-02-26 18:53:12 +02:00
|
|
|
if(!comps.empty())
|
2024-02-26 23:26:06 +02:00
|
|
|
components = std::make_shared<CComponentBox>(comps, Rect(0,0,0,0));
|
2018-04-07 13:34:11 +02:00
|
|
|
|
2024-02-26 18:53:12 +02:00
|
|
|
CMessage::drawIWindow(this, Text, player);
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
CInfoWindow::CInfoWindow()
|
|
|
|
{
|
|
|
|
ID = QueryID(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CInfoWindow::close()
|
|
|
|
{
|
2018-07-25 00:36:48 +02:00
|
|
|
WindowBase::close();
|
|
|
|
|
2014-07-15 10:14:49 +03:00
|
|
|
if(LOCPLINT)
|
2024-05-18 13:04:10 +02:00
|
|
|
LOCPLINT->showingDialog->setFree();
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
|
2023-06-02 15:42:18 +02:00
|
|
|
void CInfoWindow::showAll(Canvas & to)
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
|
|
|
CIntObject::showAll(to);
|
2024-02-26 22:04:30 +02:00
|
|
|
CMessage::drawBorder(LOCPLINT ? LOCPLINT->playerID : PlayerColor(1), to, pos.w+28, pos.h+29, pos.x-14, pos.y-15);
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
|
2024-02-26 15:48:55 +02:00
|
|
|
CInfoWindow::~CInfoWindow() = default;
|
|
|
|
|
2024-02-26 18:53:12 +02:00
|
|
|
void CInfoWindow::showInfoDialog(const std::string & text, const TCompsInfo & components, PlayerColor player)
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
2023-05-16 15:20:35 +02:00
|
|
|
GH.windows().pushWindow(CInfoWindow::create(text, player, components));
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
|
2024-02-26 18:53:12 +02:00
|
|
|
void CInfoWindow::showYesNoDialog(const std::string & text, const TCompsInfo & components, const CFunctionList<void()> & onYes, const CFunctionList<void()> & onNo, PlayerColor player)
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
2024-05-18 13:04:10 +02:00
|
|
|
assert(!LOCPLINT || LOCPLINT->showingDialog->isBusy());
|
2024-02-26 18:53:12 +02:00
|
|
|
std::vector<std::pair<AnimationPath, CFunctionList<void()>>> pom;
|
2024-02-27 13:47:17 +02:00
|
|
|
pom.emplace_back(AnimationPath::builtin("IOKAY.DEF"), nullptr);
|
|
|
|
pom.emplace_back(AnimationPath::builtin("ICANCEL.DEF"), nullptr);
|
|
|
|
auto temp = std::make_shared<CInfoWindow>(text, player, components, pom);
|
2014-11-12 22:45:48 +02:00
|
|
|
|
2024-02-26 18:53:12 +02:00
|
|
|
temp->buttons[0]->addCallback(onYes);
|
|
|
|
temp->buttons[1]->addCallback(onNo);
|
2014-07-15 10:14:49 +03:00
|
|
|
|
2023-05-16 15:20:35 +02:00
|
|
|
GH.windows().pushWindow(temp);
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
|
2024-02-26 18:53:12 +02:00
|
|
|
std::shared_ptr<CInfoWindow> CInfoWindow::create(const std::string & text, PlayerColor playerID, const TCompsInfo & components)
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
2024-02-26 18:53:12 +02:00
|
|
|
std::vector<std::pair<AnimationPath, CFunctionList<void()>>> pom;
|
2024-02-27 13:47:17 +02:00
|
|
|
pom.emplace_back(AnimationPath::builtin("IOKAY.DEF"), nullptr);
|
2018-07-25 00:36:48 +02:00
|
|
|
return std::make_shared<CInfoWindow>(text, playerID, components, pom);
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
|
2024-02-27 13:47:17 +02:00
|
|
|
std::string CInfoWindow::genText(const std::string & title, const std::string & description)
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
|
|
|
return std::string("{") + title + "}" + "\n\n" + description;
|
|
|
|
}
|
|
|
|
|
2023-06-11 19:38:42 +02:00
|
|
|
bool CRClickPopup::isPopupWindow() const
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
2023-06-11 19:38:42 +02:00
|
|
|
return true;
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CRClickPopup::close()
|
|
|
|
{
|
2018-07-25 00:36:48 +02:00
|
|
|
WindowBase::close();
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
|
2024-02-26 18:53:12 +02:00
|
|
|
void CRClickPopup::createAndPush(const std::string & txt, const CInfoWindow::TCompsInfo & comps)
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
|
|
|
PlayerColor player = LOCPLINT ? LOCPLINT->playerID : PlayerColor(1); //if no player, then use blue
|
2024-02-26 18:53:12 +02:00
|
|
|
if(settings["session"]["spectate"].Bool()) //TODO: there must be better way to implement this
|
2017-06-03 07:25:10 +02:00
|
|
|
player = PlayerColor(1);
|
2014-07-15 10:14:49 +03:00
|
|
|
|
2018-07-25 00:36:48 +02:00
|
|
|
auto temp = std::make_shared<CInfoWindow>(txt, player, comps);
|
2023-01-27 00:27:06 +02:00
|
|
|
temp->center(GH.getCursorPosition()); //center on mouse
|
2023-06-11 19:38:42 +02:00
|
|
|
#ifdef VCMI_MOBILE
|
|
|
|
temp->moveBy({0, -temp->pos.h / 2});
|
2021-03-21 12:43:01 +02:00
|
|
|
#endif
|
2014-07-15 10:14:49 +03:00
|
|
|
temp->fitToScreen(10);
|
2018-07-25 00:36:48 +02:00
|
|
|
|
2023-05-16 15:20:35 +02:00
|
|
|
GH.windows().createAndPushWindow<CRClickPopupInt>(temp);
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
|
2024-02-27 13:47:17 +02:00
|
|
|
void CRClickPopup::createAndPush(const std::string & txt, const std::shared_ptr<CComponent> & component)
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
|
|
|
CInfoWindow::TCompsInfo intComps;
|
|
|
|
intComps.push_back(component);
|
|
|
|
|
|
|
|
createAndPush(txt, intComps);
|
|
|
|
}
|
|
|
|
|
2022-11-26 23:12:20 +02:00
|
|
|
void CRClickPopup::createAndPush(const CGObjectInstance * obj, const Point & p, ETextAlignment alignment)
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
2023-08-21 14:42:41 +02:00
|
|
|
auto iWin = createCustomInfoWindow(p, obj); //try get custom infowindow for this obj
|
2014-07-15 10:14:49 +03:00
|
|
|
if(iWin)
|
2018-07-25 00:36:48 +02:00
|
|
|
{
|
2023-05-16 15:20:35 +02:00
|
|
|
GH.windows().pushWindow(iWin);
|
2018-07-25 00:36:48 +02:00
|
|
|
}
|
2014-07-15 10:14:49 +03:00
|
|
|
else
|
|
|
|
{
|
2023-10-16 22:55:37 +02:00
|
|
|
std::vector<Component> components;
|
2024-02-26 18:53:12 +02:00
|
|
|
if(settings["general"]["enableUiEnhancements"].Bool())
|
2023-10-19 12:33:49 +02:00
|
|
|
{
|
|
|
|
if(LOCPLINT->localState->getCurrentHero())
|
|
|
|
components = obj->getPopupComponents(LOCPLINT->localState->getCurrentHero());
|
|
|
|
else
|
|
|
|
components = obj->getPopupComponents(LOCPLINT->playerID);
|
|
|
|
}
|
2023-10-16 22:55:37 +02:00
|
|
|
|
|
|
|
std::vector<std::shared_ptr<CComponent>> guiComponents;
|
2024-02-26 18:53:12 +02:00
|
|
|
for(auto & component : components)
|
2023-10-16 22:55:37 +02:00
|
|
|
guiComponents.push_back(std::make_shared<CComponent>(component));
|
|
|
|
|
|
|
|
if(LOCPLINT->localState->getCurrentHero())
|
2023-10-19 13:36:11 +02:00
|
|
|
CRClickPopup::createAndPush(obj->getPopupText(LOCPLINT->localState->getCurrentHero()), guiComponents);
|
2023-10-16 22:55:37 +02:00
|
|
|
else
|
2023-10-19 13:36:11 +02:00
|
|
|
CRClickPopup::createAndPush(obj->getPopupText(LOCPLINT->playerID), guiComponents);
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-27 13:47:17 +02:00
|
|
|
CRClickPopupInt::CRClickPopupInt(const std::shared_ptr<CIntObject> & our)
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
|
|
|
CCS->curh->hide();
|
2024-07-19 21:36:05 +02:00
|
|
|
defActions = 255-DISPOSE;
|
2018-07-25 00:36:48 +02:00
|
|
|
our->recActions = defActions;
|
2014-07-15 10:14:49 +03:00
|
|
|
inner = our;
|
2018-07-25 00:36:48 +02:00
|
|
|
addChild(our.get(), false);
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
CRClickPopupInt::~CRClickPopupInt()
|
|
|
|
{
|
|
|
|
CCS->curh->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
Point CInfoBoxPopup::toScreen(Point p)
|
|
|
|
{
|
2023-02-10 23:29:13 +02:00
|
|
|
auto bounds = adventureInt->terrainAreaPixels();
|
|
|
|
|
|
|
|
vstd::abetween(p.x, bounds.top() + 100, bounds.bottom() - 100);
|
|
|
|
vstd::abetween(p.y, bounds.left() + 100, bounds.right() - 100);
|
2014-07-15 10:14:49 +03:00
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
CInfoBoxPopup::CInfoBoxPopup(Point position, const CGTownInstance * town)
|
2023-08-23 14:07:50 +02:00
|
|
|
: CWindowObject(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin("TOWNQVBK"), toScreen(position))
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
|
|
|
InfoAboutTown iah;
|
2023-04-17 12:06:58 +02:00
|
|
|
LOCPLINT->cb->getTownInfo(town, iah, LOCPLINT->localState->getCurrentTown()); //todo: should this be nearest hero?
|
2014-07-15 10:14:49 +03:00
|
|
|
|
2024-02-26 18:53:12 +02:00
|
|
|
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
|
2018-04-07 13:34:11 +02:00
|
|
|
tooltip = std::make_shared<CTownTooltip>(Point(9, 10), iah);
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
CInfoBoxPopup::CInfoBoxPopup(Point position, const CGHeroInstance * hero)
|
2023-08-23 14:07:50 +02:00
|
|
|
: CWindowObject(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin("HEROQVBK"), toScreen(position))
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
|
|
|
InfoAboutHero iah;
|
2024-02-26 18:53:12 +02:00
|
|
|
LOCPLINT->cb->getHeroInfo(hero, iah, LOCPLINT->localState->getCurrentHero()); //todo: should this be nearest hero?
|
2014-07-15 10:14:49 +03:00
|
|
|
|
2024-02-26 18:53:12 +02:00
|
|
|
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
|
2018-04-07 13:34:11 +02:00
|
|
|
tooltip = std::make_shared<CHeroTooltip>(Point(9, 10), iah);
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
CInfoBoxPopup::CInfoBoxPopup(Point position, const CGGarrison * garr)
|
2023-08-23 14:07:50 +02:00
|
|
|
: CWindowObject(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin("TOWNQVBK"), toScreen(position))
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
|
|
|
InfoAboutTown iah;
|
|
|
|
LOCPLINT->cb->getTownInfo(garr, iah);
|
|
|
|
|
2024-02-26 18:53:12 +02:00
|
|
|
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
|
2018-04-07 13:34:11 +02:00
|
|
|
tooltip = std::make_shared<CArmyTooltip>(Point(9, 10), iah);
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
|
2023-08-21 14:42:41 +02:00
|
|
|
CInfoBoxPopup::CInfoBoxPopup(Point position, const CGCreature * creature)
|
2024-02-26 18:53:12 +02:00
|
|
|
: CWindowObject(RCLICK_POPUP | BORDERED, ImagePath::builtin("DIBOXBCK"), toScreen(position))
|
2023-08-21 14:42:41 +02:00
|
|
|
{
|
2024-02-26 18:53:12 +02:00
|
|
|
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
|
2023-08-21 14:42:41 +02:00
|
|
|
tooltip = std::make_shared<CreatureTooltip>(Point(9, 10), creature);
|
|
|
|
}
|
|
|
|
|
2024-02-26 18:53:12 +02:00
|
|
|
std::shared_ptr<WindowBase>
|
|
|
|
CRClickPopup::createCustomInfoWindow(Point position, const CGObjectInstance * specific) //specific=0 => draws info about selected town/hero
|
2014-07-15 10:14:49 +03:00
|
|
|
{
|
2015-02-06 14:41:26 +02:00
|
|
|
if(nullptr == specific)
|
2023-04-17 12:06:58 +02:00
|
|
|
specific = LOCPLINT->localState->getCurrentArmy();
|
2018-04-07 13:34:11 +02:00
|
|
|
|
2015-02-06 14:41:26 +02:00
|
|
|
if(nullptr == specific)
|
|
|
|
{
|
2023-08-21 14:42:41 +02:00
|
|
|
logGlobal->error("createCustomInfoWindow: no object to describe");
|
2015-02-06 14:41:26 +02:00
|
|
|
return nullptr;
|
2018-04-07 13:34:11 +02:00
|
|
|
}
|
|
|
|
|
2014-07-15 10:14:49 +03:00
|
|
|
switch(specific->ID)
|
|
|
|
{
|
2024-02-26 18:53:12 +02:00
|
|
|
case Obj::HERO:
|
|
|
|
return std::make_shared<CInfoBoxPopup>(position, dynamic_cast<const CGHeroInstance *>(specific));
|
|
|
|
case Obj::TOWN:
|
|
|
|
return std::make_shared<CInfoBoxPopup>(position, dynamic_cast<const CGTownInstance *>(specific));
|
|
|
|
case Obj::MONSTER:
|
|
|
|
return std::make_shared<CInfoBoxPopup>(position, dynamic_cast<const CGCreature *>(specific));
|
|
|
|
case Obj::GARRISON:
|
|
|
|
case Obj::GARRISON2:
|
|
|
|
return std::make_shared<CInfoBoxPopup>(position, dynamic_cast<const CGGarrison *>(specific));
|
|
|
|
default:
|
|
|
|
return std::shared_ptr<WindowBase>();
|
2014-07-15 10:14:49 +03:00
|
|
|
}
|
|
|
|
}
|