a lot of clean up

This commit is contained in:
gugus 2012-03-16 17:53:34 +01:00
parent 91801e5cab
commit 042d87f77f
4 changed files with 10 additions and 102 deletions

View file

@ -181,10 +181,6 @@ namespace MWDialogue
{ {
return true; return true;
} }
/*if(!choice && !isAChoice)
{
return false;
}*/
if(isFunction) if(isFunction)
{ {
return false; return false;
@ -202,7 +198,6 @@ namespace MWDialogue
char comp = select.selectRule[4]; char comp = select.selectRule[4];
std::string name = select.selectRule.substr (5); std::string name = select.selectRule.substr (5);
std::string function = select.selectRule.substr(1,2); std::string function = select.selectRule.substr(1,2);
//std::cout << function;
// TODO types 4, 5, 6, 7, 8, 9, A, B, C // TODO types 4, 5, 6, 7, 8, 9, A, B, C
//new TOTO: 5,6,9 //new TOTO: 5,6,9
@ -373,7 +368,6 @@ namespace MWDialogue
bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const
{ {
//bool return true;//does the actor knows the topic?
// actor id // actor id
if (!info.actor.empty()) if (!info.actor.empty())
if (toLower (info.actor)!=MWWorld::Class::get (actor).getId (actor)) if (toLower (info.actor)!=MWWorld::Class::get (actor).getId (actor))
@ -489,15 +483,13 @@ namespace MWDialogue
{ {
if(pos==0) if(pos==0)
{ {
//std::cout << "fouuuuuuuuuuund";
knownTopics[it->first] = true; knownTopics[it->first] = true;
win->addKeyword(it->first,it->second.front().response); win->addKeyword(it->first);
} }
else if(text.substr(pos -1,1) == " ") else if(text.substr(pos -1,1) == " ")
{ {
//std::cout << "fouuuuuuuuuuund";
knownTopics[it->first] = true; knownTopics[it->first] = true;
win->addKeyword(it->first,it->second.front().response); win->addKeyword(it->first);
} }
} }
} }
@ -516,6 +508,7 @@ namespace MWDialogue
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
win->startDialogue(MWWorld::Class::get (actor).getName (actor)); win->startDialogue(MWWorld::Class::get (actor).getName (actor));
//setup the list of topics known by the actor. Topics who are also on the knownTopics list will be added to the GUI
actorKnownTopics.clear(); actorKnownTopics.clear();
ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; 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++) for(ESMS::RecListT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
@ -529,16 +522,16 @@ namespace MWDialogue
if (isMatching (actor, *iter) && functionFilter(mActor,*iter,false)) if (isMatching (actor, *iter) && functionFilter(mActor,*iter,false))
{ {
actorKnownTopics[it->first].push_back(*iter); actorKnownTopics[it->first].push_back(*iter);
//does the player know the topic?
if(knownTopics.find(toLower(it->first)) != knownTopics.end()) if(knownTopics.find(toLower(it->first)) != knownTopics.end())
{ {
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
win->addKeyword(it->first,iter->response); win->addKeyword(it->first);
} }
} }
} }
} }
} }
//ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
//greeting //greeting
bool greetingFound = false; bool greetingFound = false;
@ -558,11 +551,6 @@ namespace MWDialogue
// TODO play sound // TODO play sound
} }
if (!iter->resultScript.empty())
{
//std::cout << "script: " << iter->resultScript << std::endl;
// TODO execute script
}
std::string text = iter->response; std::string text = iter->response;
parseText(text); parseText(text);
win->addText(iter->response); win->addText(iter->response);
@ -682,13 +670,11 @@ namespace MWDialogue
mChoice = mChoiceMap[answere]; mChoice = mChoiceMap[answere];
std::list<ESM::DialInfo> dials = actorKnownTopics[mLastTopic]; std::list<ESM::DialInfo> dials = actorKnownTopics[mLastTopic];
//bool passedLastDialogue = false;
std::cout << actorKnownTopics[mLastTopic].size() << mLastTopic; std::cout << actorKnownTopics[mLastTopic].size() << mLastTopic;
std::list<ESM::DialInfo>::iterator iter; std::list<ESM::DialInfo>::iterator iter;
for(iter = actorKnownTopics[mLastTopic].begin(); iter->id != mLastDialogue.id;iter++) for(iter = actorKnownTopics[mLastTopic].begin(); iter->id != mLastDialogue.id;iter++)
{ {
} }
//iter--;
for(std::list<ESM::DialInfo>::iterator it = iter; it!=actorKnownTopics[mLastTopic].begin();) for(std::list<ESM::DialInfo>::iterator it = iter; it!=actorKnownTopics[mLastTopic].begin();)
{ {
it--; it--;

View file

@ -80,25 +80,14 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender)
if(color != "#B29154") if(color != "#B29154")
{ {
UString key = history->getColorTextAt(cursorPosition); UString key = history->getColorTextAt(cursorPosition);
if(color == "#686EBA") mEnvironment.mDialogueManager->keywordSelected(lower_string(key));
//std::cout << "Clicked on key: " << key << std::endl; if(color == "#572D21") mEnvironment.mDialogueManager->questionAnswered(key);
if(color == "#686EBA")
{
//displayTopicText(lower_string(key));
mEnvironment.mDialogueManager->keywordSelected(lower_string(key));
}
if(color == "#572D21")
{
//TODO: send back the answere to the question!
mEnvironment.mDialogueManager->questionAnswered(key);
//std::cout << "and the ansere is..."<< key;
}
} }
} }
void DialogueWindow::open() void DialogueWindow::open()
{ {
//updateOptions();
topicsList->removeAllItems(); topicsList->removeAllItems();
pTopicsText.clear(); pTopicsText.clear();
history->eraseText(0,history->getTextLength()); history->eraseText(0,history->getTextLength());
@ -108,7 +97,6 @@ void DialogueWindow::open()
void DialogueWindow::onByeClicked(MyGUI::Widget* _sender) void DialogueWindow::onByeClicked(MyGUI::Widget* _sender)
{ {
//eventBye();
mEnvironment.mDialogueManager->goodbyeSelected(); mEnvironment.mDialogueManager->goodbyeSelected();
} }
@ -117,12 +105,7 @@ void DialogueWindow::onSelectTopic(MyGUI::List* _sender, size_t _index)
if (_index == MyGUI::ITEM_NONE) if (_index == MyGUI::ITEM_NONE)
return; return;
std::string topic = _sender->getItem(_index); std::string topic = _sender->getItem(_index);
//displayTopicText(topic);
mEnvironment.mDialogueManager->keywordSelected(lower_string(topic)); mEnvironment.mDialogueManager->keywordSelected(lower_string(topic));
//const std::string* theTopic = topicsList->getItemDataAt<std::string>(_index);
//std::cout << "Selected: "<< theTopic << std::endl;
//eventTopicSelected(key);
} }
void DialogueWindow::startDialogue(std::string npcName) void DialogueWindow::startDialogue(std::string npcName)
@ -130,12 +113,12 @@ void DialogueWindow::startDialogue(std::string npcName)
setText("NpcName", npcName); setText("NpcName", npcName);
} }
void DialogueWindow::addKeyword(std::string keyWord,std::string topicText) void DialogueWindow::addKeyword(std::string keyWord)
{ {
if(topicsList->findItemIndexWith(keyWord) == MyGUI::ITEM_NONE) if(topicsList->findItemIndexWith(keyWord) == MyGUI::ITEM_NONE)
{ {
topicsList->addItem(keyWord); topicsList->addItem(keyWord);
pTopicsText[keyWord] = topicText; pTopicsText[keyWord] = " ";
} }
} }
@ -170,35 +153,19 @@ void addColorInString(std::string& str, const std::string& keyword,std::string c
str.insert(pos,color2); str.insert(pos,color2);
pos+= color2.length(); pos+= color2.length();
} }
//str.replace(pos, oldStr.length(), "#686EBA"+str.get);
} }
} }
std::string DialogueWindow::parseText(std::string text) std::string DialogueWindow::parseText(std::string text)
{ {
//topicsList->geti
for(int i = 0;i<topicsList->getItemCount();i++) for(int i = 0;i<topicsList->getItemCount();i++)
{ {
std::string keyWord = topicsList->getItem(i); std::string keyWord = topicsList->getItem(i);
//std::string newKeyWord = "#686EBA"+keyWord+"#B29154";
addColorInString(text,keyWord,"#686EBA","#B29154"); addColorInString(text,keyWord,"#686EBA","#B29154");
} }
return text; return text;
} }
void DialogueWindow::displayTopicText(std::string topic)
{
if(topicsList->findItemIndexWith(topic) != MyGUI::ITEM_NONE)
{
history->addDialogHeading(topic);
history->addDialogText(parseText(pTopicsText[topic]));
}
else
{
std::cout << "topic not found!";
}
}
void DialogueWindow::addText(std::string text) void DialogueWindow::addText(std::string text)
{ {
history->addDialogText("#B29154"+parseText(text)+"#B29154"); history->addDialogText("#B29154"+parseText(text)+"#B29154");
@ -212,60 +179,18 @@ void DialogueWindow::addTitle(std::string text)
void DialogueWindow::askQuestion(std::string question) void DialogueWindow::askQuestion(std::string question)
{ {
history->addDialogText("#572D21"+question+"#B29154"+" "); history->addDialogText("#572D21"+question+"#B29154"+" ");
/*for(std::list<std::string>::iterator it = answers.begin();it!=answers.end();it++)
{
history->addDialogText("#572D21"+(*it)+"#B29154"+" ");
}*/
} }
void DialogueWindow::updateOptions() void DialogueWindow::updateOptions()
{ {
//FIXME Add this properly
/*history->addDialogText("Through the translucent surface of the orb, you see shifting images of distant locations...");
for(int z = 0; z < 10; z++)
{
history->addDialogHeading("Fort Frostmoth");
history->addDialogText("The image in the orb flickers, and you see.... The cold courtyard of #FF0000Fort Frostmoth#FFFFFF, battered bu werewolf attack, but still standing, still projecting Imperial might even to this distant and cold corner of the world.");
}*/
//Clear the list of topics //Clear the list of topics
topicsList->removeAllItems(); topicsList->removeAllItems();
pTopicsText.clear(); pTopicsText.clear();
history->eraseText(0,history->getTextLength()); history->eraseText(0,history->getTextLength());
/*addKeyword("gus","gus is working on the dialogue system");
displayTopicText("gus");*/
pDispositionBar->setProgressRange(100); pDispositionBar->setProgressRange(100);
pDispositionBar->setProgressPosition(40); pDispositionBar->setProgressPosition(40);
pDispositionText->eraseText(0,pDispositionText->getTextLength()); pDispositionText->eraseText(0,pDispositionText->getTextLength());
pDispositionText->addText("#B29154"+std::string("40/100")+"#B29154"); pDispositionText->addText("#B29154"+std::string("40/100")+"#B29154");
/*std::list<std::string> test;
test.push_back("option 1");
test.push_back("option 2");
askQuestion("is gus cooking?",test);*/
/*topicsList->addItem("Ald'ruhn", i++);
topicsList->addItem("Balmora", i++);
topicsList->addItem("Sadrith Mora", i++);
topicsList->addItem("Vivec", i++);
topicsList->addItem("Ald Velothi", i++);
topicsList->addItem("Caldera", i++);
topicsList->addItem("Dagon Fel ", i++);
topicsList->addItem("Gnaar Mok", i++);
topicsList->addItem("Gnisis", i++);
topicsList->addItem("Hla Oad", i++);
topicsList->addItem("Khuul", i++);
topicsList->addItem("Maar Gan", i++);
topicsList->addItem("Molag Mar", i++);
topicsList->addItem("Pelagiad", i++);
topicsList->addItem("Seyda Neen", i++);
topicsList->addItem("Suran", i++);
topicsList->addItem("Tel Aruhn", i++);
topicsList->addItem("Tel Branora", i++);
topicsList->addItem("Tel Fyr", i++);
topicsList->addItem("Tel Mora", i++);
topicsList->addItem("Tel Vos", i++);
topicsList->addItem("Vos", i++);*/
} }

View file

@ -42,7 +42,7 @@ namespace MWGui
void startDialogue(std::string npcName); void startDialogue(std::string npcName);
void stopDialogue(); void stopDialogue();
void addKeyword(std::string keyWord,std::string topicText); void addKeyword(std::string keyWord);
void removeKeyword(std::string keyWord); void removeKeyword(std::string keyWord);
void addText(std::string text); void addText(std::string text);
void addTitle(std::string text); void addTitle(std::string text);
@ -59,7 +59,6 @@ namespace MWGui
*Helper function that add topic keyword in blue in a text. *Helper function that add topic keyword in blue in a text.
*/ */
std::string parseText(std::string text); std::string parseText(std::string text);
void displayTopicText(std::string topic);
DialogeHistory* history; DialogeHistory* history;
MyGUI::ListPtr topicsList; MyGUI::ListPtr topicsList;

View file

@ -95,12 +95,10 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
{ {
std::cout << "CHOICE" << arg0;
arg0 = 4; arg0 = 4;
MWScript::InterpreterContext& context MWScript::InterpreterContext& context
= static_cast<MWScript::InterpreterContext&> (runtime.getContext()); = static_cast<MWScript::InterpreterContext&> (runtime.getContext());
MWDialogue::DialogueManager* dialogue = context.getEnvironment().mDialogueManager; MWDialogue::DialogueManager* dialogue = context.getEnvironment().mDialogueManager;
//int choice = 1;
while(arg0>0) while(arg0>0)
{ {
std::string question = runtime.getStringLiteral (runtime[0].mInteger); std::string question = runtime.getStringLiteral (runtime[0].mInteger);