1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Quest Log: display components under quest description

This commit add CComponentBox under text. If quest have components description height will be changed to avoid conflicts.
Though it's would be much better if VCMI had something like QScrollArea in Qt so both text and components was using shared slider.
This commit is contained in:
ArseniyShestakov 2015-02-14 04:21:31 +03:00
parent c978bc862d
commit d06bba422a
2 changed files with 61 additions and 3 deletions

View File

@ -11,6 +11,7 @@
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../gui/SDL_Extensions.h" #include "../gui/SDL_Extensions.h"
#include "../widgets/CComponent.h"
#include "../../CCallback.h" #include "../../CCallback.h"
#include "../../lib/CArtHandler.h" #include "../../lib/CArtHandler.h"
@ -123,6 +124,7 @@ CQuestLog::CQuestLog (const std::vector<QuestInfo> & Quests) :
CWindowObject(PLAYER_COLORED | BORDERED, "questDialog.pcx"), CWindowObject(PLAYER_COLORED | BORDERED, "questDialog.pcx"),
questIndex(0), questIndex(0),
currentQuest(nullptr), currentQuest(nullptr),
componentsBox(nullptr),
quests (Quests), quests (Quests),
slider(nullptr) slider(nullptr)
{ {
@ -207,11 +209,66 @@ void CQuestLog::selectQuest (int which, int labelId)
minimap->currentQuest = currentQuest; minimap->currentQuest = currentQuest;
MetaString text; MetaString text;
std::vector<Component> components; //TODO: display them std::vector<Component> components;
currentQuest->quest->getVisitText (text, components, currentQuest->quest->isCustomFirst, true); currentQuest->quest->getVisitText (text, components, currentQuest->quest->isCustomFirst, true);
if (description->slider) if (description->slider)
description->slider->moveToMin(); // scroll text to start position description->slider->moveToMin(); // scroll text to start position
description->setText (text.toString()); //TODO: use special log entry text description->setText (text.toString()); //TODO: use special log entry text
vstd::clear_pointer(componentsBox);
int componentsSize = components.size();
int descriptionHeight = DESCRIPTION_HEIGHT_MAX;
if (componentsSize)
{
descriptionHeight -= 15;
CComponent::ESize imageSize = CComponent::large;
switch (currentQuest->quest->missionType)
{
case CQuest::MISSION_ARMY:
{
if (componentsSize > 4)
descriptionHeight -= 195;
else
descriptionHeight -= 100;
break;
}
case CQuest::MISSION_ART:
{
if (componentsSize > 4)
descriptionHeight -= 190;
else
descriptionHeight -= 90;
break;
}
case CQuest::MISSION_PRIMARY_STAT:
case CQuest::MISSION_RESOURCES:
{
if (componentsSize > 4)
{
imageSize = CComponent::small; // Only small icons can be used for resources as 4+ icons take too much space
descriptionHeight -= 140;
}
else
descriptionHeight -= 125;
break;
}
default:
descriptionHeight -= 115;
break;
}
OBJ_CONSTRUCTION_CAPTURING_ALL;
std::vector<CComponent *> comps;
for (auto & component : components)
comps.push_back(new CComponent(component, imageSize));
componentsBox = new CComponentBox(comps, Rect(202, 20+descriptionHeight+15, 391, DESCRIPTION_HEIGHT_MAX-(20+descriptionHeight)));
}
description->resize(Point(385, descriptionHeight));
minimap->update(); minimap->update();
redraw(); redraw();
} }

View File

@ -20,7 +20,7 @@ class CCreature;
class CStackInstance; class CStackInstance;
class CButton; class CButton;
class CGHeroInstance; class CGHeroInstance;
class CComponent; class CComponentBox;
class LRClickableAreaWText; class LRClickableAreaWText;
class CButton; class CButton;
class CPicture; class CPicture;
@ -79,6 +79,7 @@ class CQuestLog : public CWindowObject
{ {
int questIndex; int questIndex;
const QuestInfo * currentQuest; const QuestInfo * currentQuest;
CComponentBox * componentsBox;
const std::vector<QuestInfo> quests; const std::vector<QuestInfo> quests;
std::vector<CQuestLabel *> labels; std::vector<CQuestLabel *> labels;