Started to weire the dialogue manager and the dialogue GUI

actorid
gugus 13 years ago
parent 5cbd256e1c
commit abe38e5f87

@ -16,6 +16,8 @@
#include "../mwworld/player.hpp"
#include "../mwinput/inputmanager.hpp"
#include "../mwgui/dialogue.hpp"
#include "../mwgui/window_manager.hpp"
#include <iostream>
@ -236,13 +238,13 @@ namespace MWDialogue
if (!isMatching (actor, *iter))
return false;
std::cout
/*std::cout
<< "unchecked entries:" << std::endl
<< " player faction: " << info.pcFaction << std::endl
<< " disposition: " << info.data.disposition << std::endl
<< " NPC rank: " << static_cast<int> (info.data.rank) << std::endl
<< " gender: " << static_cast<int> (info.data.gender) << std::endl
<< " PC rank: " << static_cast<int> (info.data.PCrank) << std::endl;
<< " PC rank: " << static_cast<int> (info.data.PCrank) << std::endl;*/
return true;
}
@ -254,7 +256,7 @@ namespace MWDialogue
std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl;
const ESM::Dialogue *dialogue = mEnvironment.mWorld->getStore().dialogs.find ("hello");
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter)
{
@ -277,9 +279,32 @@ namespace MWDialogue
}
mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue);
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
win->startDialogue(MWWorld::Class::get (actor).getName (actor));
win->addText(iter->response);
break;
}
}
ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
for(ESMS::RecListT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
{
ESM::Dialogue ndialogue = it->second;
if(ndialogue.type == ESM::Dialogue::Type::Topic)
{
for (std::vector<ESM::DialInfo>::const_iterator iter (it->second.mInfo.begin());
iter!=it->second.mInfo.end(); ++iter)
{
if (isMatching (actor, *iter))
{
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
win->addKeyword(it->first,iter->response);
//std::cout << "match found!!";
break;
}
}
}
}
}
}

@ -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++);

@ -57,6 +57,8 @@ namespace MWGui
DialogeHistory* history;
MyGUI::ListPtr topicsList;
MyGUI::ProgressPtr pDispositionBar;
MyGUI::EditPtr pDispositionText;
std::map<std::string,std::string> pTopicsText;// this map links keyword and "real" text.
};
}

@ -472,6 +472,7 @@ void WindowManager::updateSkillArea()
void WindowManager::removeDialog(OEngine::GUI::Layout*dialog)
{
std::cout << "dialogue a la poubelle";
assert(dialog);
if (!dialog)
return;
@ -553,7 +554,8 @@ void WindowManager::onDialogueWindowBye()
if (dialogueWindow)
{
//FIXME set some state and stuff?
removeDialog(dialogueWindow);
//removeDialog(dialogueWindow);
dialogueWindow->setVisible(false);
}
setGuiMode(GM_Game);
}

@ -207,6 +207,8 @@ namespace MWGui
updateVisible();
}
MWGui::DialogueWindow* getDialogueWindow() {return dialogueWindow;}
MyGUI::Gui* getGui() const { return gui; }
void wmUpdateFps(float fps, size_t triangleCount, size_t batchCount)

@ -54,6 +54,7 @@ configure_file("${SDIR}/openmw_chargen_class_description_layout.xml" "${DDIR}/op
configure_file("${SDIR}/openmw_chargen_birth_layout.xml" "${DDIR}/openmw_chargen_birth_layout.xml" COPYONLY)
configure_file("${SDIR}/openmw_chargen_review_layout.xml" "${DDIR}/openmw_chargen_review_layout.xml" COPYONLY)
configure_file("${SDIR}/openmw_dialogue_window_layout.xml" "${DDIR}/openmw_dialogue_window_layout.xml" COPYONLY)
configure_file("${SDIR}/openmw_dialogue_window_skin.xml" "${DDIR}/openmw_dialogue_window_skin.xml" COPYONLY)
configure_file("${SDIR}/openmw_inventory_window_layout.xml" "${DDIR}/openmw_inventory_window_layout.xml" COPYONLY)
configure_file("${SDIR}/openmw_layers.xml" "${DDIR}/openmw_layers.xml" COPYONLY)
configure_file("${SDIR}/openmw_mainmenu_layout.xml" "${DDIR}/openmw_mainmenu_layout.xml" COPYONLY)

@ -20,6 +20,7 @@
<List file="openmw_mainmenu_skin.xml" group="General"/>
<List file="openmw_console.skin.xml" group="General"/>
<List file="openmw_journal_skin.xml" group="General"/>
<List file="openmw_dialogue_window_skin.xml" group="General"/>
</MyGUI>
</MyGUI>

@ -17,8 +17,13 @@
<Property key="Edit_VisibleVScroll" value="1" />
</Widget>
<!-- The disposition bar-->
<Widget type="Progress" skin="MW_EnergyBar_Blue" position="432 39 132 18"
align="Right Top" name="Disposition">
<Widget type="Edit" skin="MW_DispositionEdit" position_real = "0.25 0 0.5 1" name = "DispositionText"/>
</Widget>
<!-- The list of topics -->
<Widget type="List" skin="MW_List" position="432 39 132 341" name="TopicsList">
<Widget type="List" skin="MW_List" position="432 62 132 318" name="TopicsList">
</Widget>
<!-- The Goodbye button -->

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Skin">
<Skin name = "MW_DispEdit" size = "10 10">
<Property key="FontName" value = "MonoFont" />
<Property key="AlignText" value = "Left Top" />
<Property key="Colour" value = "0000FF" />
<!--Property key="Pointer" value = "beam" /-->
<BasisSkin type="EditText" offset = "0 0 10 10" align = "Stretch"/>
</Skin>
<Skin name="MW_DispositionEdit" size="0 0 50 50">
<Property key="WordWrap" value = "true" />
<Child type="Widget" skin="MW_DispEdit" offset="0 0 35 10" align = "ALIGN_STRETCH" name = "Client"/>
<!--Child type="VScroll" skin="VScroll" offset = "35 0 15 50" align = "Right VStretch" name = "VScroll"/-->
</Skin>
</MyGUI>
Loading…
Cancel
Save