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

Rearragned Seer Huts & Quests. More work on Quest Log descriptions.

This commit is contained in:
DjWarmonger
2012-07-08 06:33:41 +00:00
parent 846474af66
commit 7fbf89ffc8
6 changed files with 469 additions and 359 deletions

View File

@@ -21,6 +21,16 @@
#include "UIFramework/CGuiHandler.h"
#include "UIFramework/CIntObjectClasses.h"
/*
* CQuestLog.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
*
*/
struct QuestInfo;
class CAdvmapInterface;
@@ -30,6 +40,12 @@ void CQuestLabel::clickLeft(tribool down, bool previousState)
callback();
}
void CQuestLabel::showAll(SDL_Surface * to)
{
if (active)
CBoundedLabel::showAll (to);
}
void CQuestMinimap::clickLeft(tribool down, bool previousState)
{
if (down)
@@ -58,11 +74,11 @@ CQuestLog::CQuestLog (const std::vector<QuestInfo> & Quests) :
void CQuestLog::init()
{
minimap = new CQuestMinimap (Rect (47, 33, 144, 144));
description = new CTextBox ("", Rect(240, 33, 355, 355), 1, FONT_SMALL, TOPLEFT, Colors::Cornsilk);
description = new CTextBox ("", Rect(245, 33, 350, 355), 1, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk);
ok = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second, boost::bind(&CQuestLog::close,this), 547, 401, "IOKAY.DEF", SDLK_RETURN);
if (quests.size() > QUEST_COUNT)
slider = new CSlider(203, 199, 230, boost::bind (&CQuestLog::sliderMoved, this, _1), quests.size(), quests.size(), false, 0);
slider = new CSlider(203, 199, 230, boost::bind (&CQuestLog::sliderMoved, this, _1), QUEST_COUNT, quests.size(), false, 0);
auto map = LOCPLINT->cb->getVisibilityMap(); //TODO: another function to get all tiles?
@@ -73,26 +89,31 @@ void CQuestLog::init()
for (int i = 0; i < quests.size(); ++i)
{
CQuestLabel * label = new CQuestLabel (28, 199 + i * 24, FONT_SMALL, TOPLEFT, Colors::Cornsilk, quests[i].quest.firstVisitText);
MetaString text;
quests[i].quest.getRolloverText (text, false);
if (quests[i].obj)
text.addReplacement (quests[i].obj->getHoverText()); //get name of the object
CQuestLabel * label = new CQuestLabel (28, 199 + i * 24, FONT_SMALL, TOPLEFT, Colors::Cornsilk, text.toString());
label->callback = boost::bind(&CQuestLog::selectQuest, this, i);
label->setBounds (172, 30);
labels.push_back(label);
}
recreateQuestList (0); //truncate invisible and too wide labels
recreateQuestList (0);
showAll (screen2);
}
void CQuestLog::showAll(SDL_Surface * to)
{
CIntObject::showAll (to);
recreateQuestList (0);
BOOST_FOREACH (auto label, labels)
{
if (label->active)
label->show(to);
label->show(to); //shows only if active
}
if (labels.size())
if (labels.size() && labels[questIndex]->active)
{
CSDL_Ext::drawBorder(to, Rect::around(labels[questIndex]->pos), int3(Colors::MetallicGold.r, Colors::MetallicGold.g, Colors::MetallicGold.b));
}
description->show(to);
minimap->update();
}
@@ -101,9 +122,9 @@ void CQuestLog::recreateQuestList (int newpos)
{
for (int i = 0; i < labels.size(); ++i)
{
labels[i]->pos = Rect (pos.x + 28, pos.y + 207 + (i-newpos) * 25, 173, 23);
if (i >= newpos && i < newpos + QUEST_COUNT)
{
labels[i]->pos = Rect (pos.x + 28, pos.y + 207 + (i-newpos) * 24, 172, 30); //TODO: limit label width?
labels[i]->activate();
}
else
@@ -120,10 +141,12 @@ void CQuestLog::selectQuest (int which)
minimap->currentQuest = currentQuest;
if (currentQuest->obj)
{
//minimap->setLevel (currentQuest->obj->pos.z);
adventureInt->centerOn (currentQuest->obj->pos);
}
description->text = currentQuest->quest.firstVisitText; //TODO: use special log entry text
MetaString text;
std::vector<Component> components; //TODO: display them
currentQuest->quest.getVisitText (text, components , currentQuest->quest.isCustomFirst, true);
description->setTxt (text.toString()); //TODO: use special log entry text
redraw();
}