2010-11-03 20:21:08 +00:00
|
|
|
#include "dialogue_history.hpp"
|
2012-08-12 16:11:09 +00:00
|
|
|
|
|
|
|
#include "../mwbase/windowmanager.hpp"
|
|
|
|
|
2010-11-03 20:21:08 +00:00
|
|
|
#include "widgets.hpp"
|
2012-10-01 15:17:04 +00:00
|
|
|
|
|
|
|
#include "../mwworld/esmstore.hpp"
|
2010-11-03 20:21:08 +00:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <iterator>
|
|
|
|
|
|
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
|
|
|
|
|
using namespace MWGui;
|
|
|
|
using namespace Widgets;
|
|
|
|
|
2012-09-10 07:10:50 +00:00
|
|
|
MyGUI::UString DialogueHistory::getColorAtPos(size_t _pos)
|
2010-11-03 20:21:08 +00:00
|
|
|
{
|
2012-09-10 07:10:50 +00:00
|
|
|
MyGUI::UString colour = MyGUI::TextIterator::convertTagColour(getTextColour());
|
|
|
|
MyGUI::TextIterator iterator(getCaption());
|
2010-11-03 20:21:08 +00:00
|
|
|
while(iterator.moveNext())
|
|
|
|
{
|
|
|
|
size_t pos = iterator.getPosition();
|
|
|
|
iterator.getTagColour(colour);
|
|
|
|
if (pos < _pos)
|
|
|
|
continue;
|
|
|
|
else if (pos == _pos)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return colour;
|
|
|
|
}
|
|
|
|
|
2012-09-10 07:10:50 +00:00
|
|
|
MyGUI::UString DialogueHistory::getColorTextAt(size_t _pos)
|
2010-11-03 20:21:08 +00:00
|
|
|
{
|
|
|
|
bool breakOnNext = false;
|
2012-09-10 07:10:50 +00:00
|
|
|
MyGUI::UString colour = MyGUI::TextIterator::convertTagColour(getTextColour());
|
|
|
|
MyGUI::UString colour2 = colour;
|
|
|
|
MyGUI::TextIterator iterator(getCaption());
|
|
|
|
MyGUI::TextIterator col_start = iterator;
|
2010-11-03 20:21:08 +00:00
|
|
|
while(iterator.moveNext())
|
|
|
|
{
|
|
|
|
size_t pos = iterator.getPosition();
|
|
|
|
iterator.getTagColour(colour);
|
|
|
|
if(colour != colour2)
|
|
|
|
{
|
|
|
|
if(breakOnNext)
|
|
|
|
{
|
|
|
|
return getOnlyText().substr(col_start.getPosition(), iterator.getPosition()-col_start.getPosition());
|
|
|
|
}
|
|
|
|
col_start = iterator;
|
|
|
|
colour2 = colour;
|
|
|
|
}
|
|
|
|
if (pos < _pos)
|
|
|
|
continue;
|
|
|
|
else if (pos == _pos)
|
|
|
|
{
|
|
|
|
breakOnNext = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2012-09-10 07:10:50 +00:00
|
|
|
void DialogueHistory::addDialogHeading(const MyGUI::UString& parText)
|
2010-11-03 20:21:08 +00:00
|
|
|
{
|
2012-09-10 07:10:50 +00:00
|
|
|
MyGUI::UString head("\n#D8C09A");
|
2010-11-03 20:21:08 +00:00
|
|
|
head.append(parText);
|
2012-01-28 15:08:22 +00:00
|
|
|
head.append("#B29154\n");
|
2010-11-03 20:21:08 +00:00
|
|
|
addText(head);
|
|
|
|
}
|
|
|
|
|
2012-09-10 07:10:50 +00:00
|
|
|
void DialogueHistory::addDialogText(const MyGUI::UString& parText)
|
2010-11-03 20:21:08 +00:00
|
|
|
{
|
|
|
|
addText(parText);
|
|
|
|
addText("\n");
|
|
|
|
}
|