1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 12:42:11 +00:00
OpenMW/apps/openmw/mwgui/dialogue_history.cpp

76 lines
1.8 KiB
C++
Raw Normal View History

2010-11-03 20:21:08 +00:00
#include "dialogue_history.hpp"
#include "window_manager.hpp"
#include "widgets.hpp"
#include "components/esm_store/store.hpp"
#include <assert.h>
#include <iostream>
#include <iterator>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
using namespace MWGui;
using namespace Widgets;
2012-03-22 14:10:29 +00:00
UString DialogueHistory::getColorAtPos(size_t _pos)
2010-11-03 20:21:08 +00:00
{
2012-03-20 19:24:36 +00:00
UString colour = TextIterator::convertTagColour(getTextColour());
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-03-22 14:10:29 +00:00
UString DialogueHistory::getColorTextAt(size_t _pos)
2010-11-03 20:21:08 +00:00
{
bool breakOnNext = false;
2012-03-20 19:24:36 +00:00
UString colour = TextIterator::convertTagColour(getTextColour());
2010-11-03 20:21:08 +00:00
UString colour2 = colour;
2012-03-20 19:24:36 +00:00
TextIterator iterator(getCaption());
2010-11-03 20:21:08 +00:00
TextIterator col_start = iterator;
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-03-22 14:10:29 +00:00
void DialogueHistory::addDialogHeading(const UString& parText)
2010-11-03 20:21:08 +00:00
{
UString head("\n#D8C09A");
2010-11-03 20:21:08 +00:00
head.append(parText);
head.append("#B29154\n");
2010-11-03 20:21:08 +00:00
addText(head);
}
2012-03-22 14:10:29 +00:00
void DialogueHistory::addDialogText(const UString& parText)
2010-11-03 20:21:08 +00:00
{
addText(parText);
addText("\n");
}