|
|
|
@ -14,6 +14,23 @@
|
|
|
|
|
using namespace MWGui;
|
|
|
|
|
using namespace Widgets;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*Copied from the internet.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
std::string lower_string(const std::string& str)
|
|
|
|
|
{
|
|
|
|
|
std::string lower;
|
|
|
|
|
std::transform(str.begin(), str.end(), std::back_inserter(lower), std::tolower);
|
|
|
|
|
return lower;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string::size_type find_str_ci(const std::string& str, const std::string& substr,size_t pos)
|
|
|
|
|
{
|
|
|
|
|
return lower_string(str).find(lower_string(substr),pos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DialogueWindow::DialogueWindow(WindowManager& parWindowManager)
|
|
|
|
|
: WindowBase("openmw_dialogue_window_layout.xml", parWindowManager)
|
|
|
|
|
{
|
|
|
|
@ -39,7 +56,9 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager)
|
|
|
|
|
getWidget(byeButton, "ByeButton");
|
|
|
|
|
byeButton->eventMouseButtonClick = MyGUI::newDelegate(this, &DialogueWindow::onByeClicked);
|
|
|
|
|
|
|
|
|
|
//updateOptions();
|
|
|
|
|
getWidget(pDispositionBar, "Disposition");
|
|
|
|
|
getWidget(pDispositionText,"DispositionText");
|
|
|
|
|
std::cout << "creation dialogue";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender)
|
|
|
|
@ -57,7 +76,7 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender)
|
|
|
|
|
UString key = history->getColorTextAt(cursorPosition);
|
|
|
|
|
|
|
|
|
|
//std::cout << "Clicked on key: " << key << std::endl;
|
|
|
|
|
if(color == "#686EBA") displayTopicText(key);
|
|
|
|
|
if(color == "#686EBA") displayTopicText(lower_string(key));
|
|
|
|
|
if(color == "#572D21")
|
|
|
|
|
{
|
|
|
|
|
//TODO: send back the answere to the question!
|
|
|
|
@ -117,17 +136,17 @@ void DialogueWindow::removeKeyword(std::string keyWord)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*Copied from the internet.
|
|
|
|
|
*/
|
|
|
|
|
void replaceInString(std::string& str, const std::string& oldStr, const std::string& newStr)
|
|
|
|
|
void addColorInString(std::string& str, const std::string& keyword,std::string color1, std::string color2)
|
|
|
|
|
{
|
|
|
|
|
size_t pos = 0;
|
|
|
|
|
while((pos = str.find(oldStr, pos)) != std::string::npos)
|
|
|
|
|
while((pos = find_str_ci(str,keyword, pos)) != std::string::npos)
|
|
|
|
|
{
|
|
|
|
|
str.replace(pos, oldStr.length(), newStr);
|
|
|
|
|
pos += newStr.length();
|
|
|
|
|
//str.replace(pos, oldStr.length(), "#686EBA"+str.get);
|
|
|
|
|
str.insert(pos,color1);
|
|
|
|
|
pos += color1.length();
|
|
|
|
|
pos += keyword.length();
|
|
|
|
|
str.insert(pos,color2);
|
|
|
|
|
pos+= color2.length();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -137,8 +156,8 @@ std::string DialogueWindow::parseText(std::string text)
|
|
|
|
|
for(int i = 0;i<topicsList->getItemCount();i++)
|
|
|
|
|
{
|
|
|
|
|
std::string keyWord = topicsList->getItem(i);
|
|
|
|
|
std::string newKeyWord = "#686EBA"+keyWord+"#B29154";
|
|
|
|
|
replaceInString(text,keyWord,newKeyWord);
|
|
|
|
|
//std::string newKeyWord = "#686EBA"+keyWord+"#B29154";
|
|
|
|
|
addColorInString(text,keyWord,"#686EBA","#B29154");
|
|
|
|
|
}
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
@ -156,6 +175,11 @@ void DialogueWindow::displayTopicText(std::string topic)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::addText(std::string text)
|
|
|
|
|
{
|
|
|
|
|
history->addDialogText(parseText(text));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::askQuestion(std::string question,std::list<std::string> answers)
|
|
|
|
|
{
|
|
|
|
|
history->addDialogText(parseText(question));
|
|
|
|
@ -180,13 +204,18 @@ void DialogueWindow::updateOptions()
|
|
|
|
|
pTopicsText.clear();
|
|
|
|
|
history->eraseText(0,history->getTextLength());
|
|
|
|
|
|
|
|
|
|
addKeyword("gus","gus is working on the dialogue system");
|
|
|
|
|
displayTopicText("gus");
|
|
|
|
|
/*addKeyword("gus","gus is working on the dialogue system");
|
|
|
|
|
displayTopicText("gus");*/
|
|
|
|
|
|
|
|
|
|
pDispositionBar->setProgressRange(100);
|
|
|
|
|
pDispositionBar->setProgressPosition(40);
|
|
|
|
|
pDispositionText->eraseText(0,pDispositionText->getTextLength());
|
|
|
|
|
pDispositionText->addText("#B29154"+std::string("40/100")+"#B29154");
|
|
|
|
|
|
|
|
|
|
std::list<std::string> test;
|
|
|
|
|
/*std::list<std::string> test;
|
|
|
|
|
test.push_back("option 1");
|
|
|
|
|
test.push_back("option 2");
|
|
|
|
|
askQuestion("is gus cooking?",test);
|
|
|
|
|
askQuestion("is gus cooking?",test);*/
|
|
|
|
|
/*topicsList->addItem("Ald'ruhn", i++);
|
|
|
|
|
topicsList->addItem("Balmora", i++);
|
|
|
|
|
topicsList->addItem("Sadrith Mora", i++);
|
|
|
|
|