From f7cf5f9bef4746efaddf7b2ed8ea81c8d6c83cfa Mon Sep 17 00:00:00 2001 From: gugus Date: Fri, 27 Jan 2012 14:50:13 +0100 Subject: [PATCH 01/77] improved the dialogue GUI. Questions are still missing. --- apps/openmw/mwgui/dialogue.cpp | 105 ++++++++++++++++++++++++++++----- apps/openmw/mwgui/dialogue.hpp | 13 ++++ 2 files changed, 102 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index e48c142aaf..39d5419153 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -15,31 +15,31 @@ using namespace MWGui; using namespace Widgets; DialogueWindow::DialogueWindow(WindowManager& parWindowManager) - : WindowBase("openmw_dialogue_window_layout.xml", parWindowManager) + : WindowBase("openmw_dialogue_window_layout.xml", parWindowManager) { // Centre dialog center(); //WindowManager *wm = environment.mWindowManager; setText("NpcName", "Name of character"); - + //History view getWidget(history, "History"); history->setOverflowToTheLeft(true); history->getClient()->eventMouseButtonClick = MyGUI::newDelegate(this, &DialogueWindow::onHistoryClicked); - + //Topics list getWidget(topicsList, "TopicsList"); topicsList->setScrollVisible(true); - topicsList->eventListSelectAccept = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); + //topicsList->eventListSelectAccept = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); topicsList->eventListMouseItemActivate = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); - topicsList->eventListChangePosition = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); + //topicsList->eventListChangePosition = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); MyGUI::ButtonPtr byeButton; getWidget(byeButton, "ByeButton"); byeButton->eventMouseButtonClick = MyGUI::newDelegate(this, &DialogueWindow::onByeClicked); - updateOptions(); + //updateOptions(); } void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) @@ -54,14 +54,18 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) if(history->getColorAtPos(cursorPosition) != "#FFFFFF") { UString key = history->getColorTextAt(cursorPosition); - std::cout << "Clicked on key: " << key << std::endl; - //eventTopicSelected(key); + //std::cout << "Clicked on key: " << key << std::endl; + displayTopicText(key); } } void DialogueWindow::open() { - updateOptions(); + //updateOptions(); + topicsList->removeAllItems(); + pTopicsText.clear(); + history->eraseText(0,history->getTextLength()); + setVisible(true); } @@ -74,27 +78,96 @@ void DialogueWindow::onSelectTopic(MyGUI::List* _sender, size_t _index) { if (_index == MyGUI::ITEM_NONE) return; + std::string topic = _sender->getItem(_index); + displayTopicText(topic); //const std::string* theTopic = topicsList->getItemDataAt(_index); //std::cout << "Selected: "<< theTopic << std::endl; //eventTopicSelected(key); } +void DialogueWindow::startDialogue(std::string npcName) +{ + setText("NpcName", npcName); +} + +void DialogueWindow::addKeyword(std::string keyWord,std::string topicText) +{ + if(topicsList->findItemIndexWith(keyWord) == MyGUI::ITEM_NONE) + { + topicsList->addItem(keyWord); + pTopicsText[keyWord] = topicText; + } +} + +void DialogueWindow::removeKeyword(std::string keyWord) +{ + if(topicsList->findItemIndexWith(keyWord) != MyGUI::ITEM_NONE) + { + std::cout << topicsList->findItem(keyWord); + topicsList->removeItemAt(topicsList->findItem(keyWord)); + pTopicsText.erase(keyWord); + } +} + + +/** +*Copied from the internet. +*/ +void replaceInString(std::string& str, const std::string& oldStr, const std::string& newStr) +{ + size_t pos = 0; + while((pos = str.find(oldStr, pos)) != std::string::npos) + { + str.replace(pos, oldStr.length(), newStr); + pos += newStr.length(); + } +} + +std::string DialogueWindow::parseText(std::string text) +{ + //topicsList->geti + for(int i = 0;igetItemCount();i++) + { + std::string keyWord = topicsList->getItem(i); + std::string newKeyWord = "#FF0000"+keyWord+"#FFFFFF"; + replaceInString(text,keyWord,newKeyWord); + } + 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::updateOptions() { //FIXME Add this properly - history->addDialogText("Through the translucent surface of the orb, you see shifting images of distant locations..."); + /*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."); - } + 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 topicsList->removeAllItems(); - int i = 0; - topicsList->addItem("Ald'ruhn", i++); + pTopicsText.clear(); + history->eraseText(0,history->getTextLength()); + + addKeyword("gus","gus is working on the dialogue system"); + + displayTopicText("gus"); + /*topicsList->addItem("Ald'ruhn", i++); topicsList->addItem("Balmora", i++); topicsList->addItem("Sadrith Mora", i++); topicsList->addItem("Vivec", i++); @@ -115,6 +188,6 @@ void DialogueWindow::updateOptions() topicsList->addItem("Tel Fyr", i++); topicsList->addItem("Tel Mora", i++); topicsList->addItem("Tel Vos", i++); - topicsList->addItem("Vos", i++); + topicsList->addItem("Vos", i++);*/ } diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index ddb6f8a4c8..efedf07487 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -35,6 +35,13 @@ namespace MWGui */ EventHandle_Void eventBye; + void startDialogue(std::string npcName); + void stopDialogue(); + void addKeyword(std::string keyWord,std::string topicText); + void removeKeyword(std::string keyWord); + void addText(std::string text); + void askQuestion(); + protected: void onSelectTopic(MyGUI::List* _sender, size_t _index); void onByeClicked(MyGUI::Widget* _sender); @@ -42,9 +49,15 @@ namespace MWGui private: void updateOptions(); + /** + *Helper function that add topic keyword in blue in a text. + */ + std::string parseText(std::string text); + void displayTopicText(std::string topic); DialogeHistory* history; MyGUI::ListPtr topicsList; + std::map pTopicsText;// this map links keyword and "real" text. }; } #endif From debec44b511f7143542504761c1d5083f8aecbcf Mon Sep 17 00:00:00 2001 From: gugus Date: Sat, 28 Jan 2012 16:08:22 +0100 Subject: [PATCH 02/77] better colors (not perfect yet), and some basic question support (not finished yet). --- apps/openmw/mwgui/dialogue.cpp | 21 +++++++++++++++++---- apps/openmw/mwgui/dialogue.hpp | 2 +- apps/openmw/mwgui/dialogue_history.cpp | 4 ++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 39d5419153..b94858a7b2 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -51,7 +51,7 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) const IntPoint& lastPressed = InputManager::getInstance().getLastLeftPressed(); size_t cursorPosition = t->getCursorPosition(lastPressed); - if(history->getColorAtPos(cursorPosition) != "#FFFFFF") + if(history->getColorAtPos(cursorPosition) != "#B29154") { UString key = history->getColorTextAt(cursorPosition); //std::cout << "Clicked on key: " << key << std::endl; @@ -65,7 +65,7 @@ void DialogueWindow::open() topicsList->removeAllItems(); pTopicsText.clear(); history->eraseText(0,history->getTextLength()); - + updateOptions(); setVisible(true); } @@ -130,7 +130,7 @@ std::string DialogueWindow::parseText(std::string text) for(int i = 0;igetItemCount();i++) { std::string keyWord = topicsList->getItem(i); - std::string newKeyWord = "#FF0000"+keyWord+"#FFFFFF"; + std::string newKeyWord = "#686EBA"+keyWord+"#B29154"; replaceInString(text,keyWord,newKeyWord); } return text; @@ -149,6 +149,15 @@ void DialogueWindow::displayTopicText(std::string topic) } } +void DialogueWindow::askQuestion(std::string question,std::list answers) +{ + history->addDialogText(parseText(question)); + for(std::list::iterator it = answers.begin();it!=answers.end();it++) + { + history->addDialogText("#572D21"+(*it)+"#B29154"); + } +} + void DialogueWindow::updateOptions() { //FIXME Add this properly @@ -165,8 +174,12 @@ void DialogueWindow::updateOptions() history->eraseText(0,history->getTextLength()); addKeyword("gus","gus is working on the dialogue system"); - displayTopicText("gus"); + + std::list 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++); diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index efedf07487..a83334e395 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -40,7 +40,7 @@ namespace MWGui void addKeyword(std::string keyWord,std::string topicText); void removeKeyword(std::string keyWord); void addText(std::string text); - void askQuestion(); + void askQuestion(std::string question,std::list answers); protected: void onSelectTopic(MyGUI::List* _sender, size_t _index); diff --git a/apps/openmw/mwgui/dialogue_history.cpp b/apps/openmw/mwgui/dialogue_history.cpp index aaa559d243..ceb9045281 100644 --- a/apps/openmw/mwgui/dialogue_history.cpp +++ b/apps/openmw/mwgui/dialogue_history.cpp @@ -61,9 +61,9 @@ UString DialogeHistory::getColorTextAt(size_t _pos) void DialogeHistory::addDialogHeading(const UString& parText) { - UString head("\n#00FF00"); + UString head("\n#D8C09A"); head.append(parText); - head.append("#FFFFFF\n"); + head.append("#B29154\n"); addText(head); } From 5cbd256e1c9633bee716c7b03156f446e5240110 Mon Sep 17 00:00:00 2001 From: gugus Date: Sat, 28 Jan 2012 16:16:49 +0100 Subject: [PATCH 03/77] "full" question support. Now needs to be linked with the dialogue Manager. --- apps/openmw/mwgui/dialogue.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index b94858a7b2..87eb3e9cf3 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -51,11 +51,18 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) const IntPoint& lastPressed = InputManager::getInstance().getLastLeftPressed(); size_t cursorPosition = t->getCursorPosition(lastPressed); - if(history->getColorAtPos(cursorPosition) != "#B29154") + MyGUI::UString color = history->getColorAtPos(cursorPosition); + if(color != "#B29154") { UString key = history->getColorTextAt(cursorPosition); + //std::cout << "Clicked on key: " << key << std::endl; - displayTopicText(key); + if(color == "#686EBA") displayTopicText(key); + if(color == "#572D21") + { + //TODO: send back the answere to the question! + std::cout << "and the ansere is..."<< key; + } } } @@ -154,7 +161,7 @@ void DialogueWindow::askQuestion(std::string question,std::list ans history->addDialogText(parseText(question)); for(std::list::iterator it = answers.begin();it!=answers.end();it++) { - history->addDialogText("#572D21"+(*it)+"#B29154"); + history->addDialogText("#572D21"+(*it)+"#B29154"+" "); } } From abe38e5f879e22e9bd451d2da50a51fba6cdf8ae Mon Sep 17 00:00:00 2001 From: gugus Date: Sun, 5 Feb 2012 10:54:56 +0100 Subject: [PATCH 04/77] Started to weire the dialogue manager and the dialogue GUI --- apps/openmw/mwdialogue/dialoguemanager.cpp | 31 +++++++++- apps/openmw/mwgui/dialogue.cpp | 61 ++++++++++++++----- apps/openmw/mwgui/dialogue.hpp | 2 + apps/openmw/mwgui/window_manager.cpp | 4 +- apps/openmw/mwgui/window_manager.hpp | 2 + extern/mygui_3.0.1/CMakeLists.txt | 1 + extern/mygui_3.0.1/openmw_resources/core.xml | 1 + .../openmw_dialogue_window_layout.xml | 7 ++- .../openmw_dialogue_window_skin.xml | 18 ++++++ 9 files changed, 106 insertions(+), 21 deletions(-) create mode 100644 extern/mygui_3.0.1/openmw_resources/openmw_dialogue_window_skin.xml diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index f78160cd78..6665c30aa4 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -16,6 +16,8 @@ #include "../mwworld/player.hpp" #include "../mwinput/inputmanager.hpp" +#include "../mwgui/dialogue.hpp" +#include "../mwgui/window_manager.hpp" #include @@ -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 (info.data.rank) << std::endl << " gender: " << static_cast (info.data.gender) << std::endl - << " PC rank: " << static_cast (info.data.PCrank) << std::endl; + << " PC rank: " << static_cast (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::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::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + { + ESM::Dialogue ndialogue = it->second; + if(ndialogue.type == ESM::Dialogue::Type::Topic) + { + for (std::vector::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; + } + } + } + } } } diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 87eb3e9cf3..acb04e53c7 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -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;igetItemCount();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 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 test; + /*std::list 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++); diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index a83334e395..9518edcde4 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -57,6 +57,8 @@ namespace MWGui DialogeHistory* history; MyGUI::ListPtr topicsList; + MyGUI::ProgressPtr pDispositionBar; + MyGUI::EditPtr pDispositionText; std::map pTopicsText;// this map links keyword and "real" text. }; } diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index d16611794d..f1db1654ee 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -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); } diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index a47e53fed8..9dbe72eabc 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -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) diff --git a/extern/mygui_3.0.1/CMakeLists.txt b/extern/mygui_3.0.1/CMakeLists.txt index 2cbe8aabe6..6a96bd3674 100644 --- a/extern/mygui_3.0.1/CMakeLists.txt +++ b/extern/mygui_3.0.1/CMakeLists.txt @@ -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) diff --git a/extern/mygui_3.0.1/openmw_resources/core.xml b/extern/mygui_3.0.1/openmw_resources/core.xml index 31d409a35a..e98b20d3ad 100644 --- a/extern/mygui_3.0.1/openmw_resources/core.xml +++ b/extern/mygui_3.0.1/openmw_resources/core.xml @@ -20,6 +20,7 @@ + diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_dialogue_window_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_dialogue_window_layout.xml index 2987e82be0..44642167b2 100644 --- a/extern/mygui_3.0.1/openmw_resources/openmw_dialogue_window_layout.xml +++ b/extern/mygui_3.0.1/openmw_resources/openmw_dialogue_window_layout.xml @@ -17,8 +17,13 @@ + + + + - + diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_dialogue_window_skin.xml b/extern/mygui_3.0.1/openmw_resources/openmw_dialogue_window_skin.xml new file mode 100644 index 0000000000..25e0b86592 --- /dev/null +++ b/extern/mygui_3.0.1/openmw_resources/openmw_dialogue_window_skin.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file From c65c160e7b2eebed85a45bb5732f4b2c1aca60ab Mon Sep 17 00:00:00 2001 From: gugus Date: Sun, 5 Feb 2012 12:25:23 +0100 Subject: [PATCH 05/77] finished connecting the dialogue GUI and the dialogue manager --- apps/openmw/mwdialogue/dialoguemanager.cpp | 15 +++++++++++++++ apps/openmw/mwdialogue/dialoguemanager.hpp | 5 +++++ apps/openmw/mwgui/dialogue.cpp | 20 +++++++++++++++----- apps/openmw/mwgui/dialogue.hpp | 9 ++++++++- apps/openmw/mwgui/window_manager.cpp | 7 ++----- 5 files changed, 45 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 6665c30aa4..7ffb7f29b2 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -307,4 +307,19 @@ namespace MWDialogue } } + void DialogueManager::keywordSelected(std::string keyword) + { + std::cout << "keyword" << keyword; + } + + void DialogueManager::goodbyeSelected() + { + mEnvironment.mInputManager->setGuiMode(MWGui::GM_Game); + } + + void DialogueManager::questionAnswered(std::string answere) + { + std::cout << "and the ansere is..."<< answere; + } + } diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index 5b6b262404..0e06838e6c 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -26,6 +26,11 @@ namespace MWDialogue void startDialogue (const MWWorld::Ptr& actor); + //calbacks for the GUI + void keywordSelected(std::string keyword); + void goodbyeSelected(); + void questionAnswered(std::string answere); + }; } diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index acb04e53c7..c4cebaa671 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -3,6 +3,8 @@ #include "window_manager.hpp" #include "widgets.hpp" #include "components/esm_store/store.hpp" +#include "../mwworld/environment.hpp" +#include "../mwdialogue/dialoguemanager.hpp" #include #include @@ -31,8 +33,9 @@ std::string::size_type find_str_ci(const std::string& str, const std::string& su } -DialogueWindow::DialogueWindow(WindowManager& parWindowManager) - : WindowBase("openmw_dialogue_window_layout.xml", parWindowManager) +DialogueWindow::DialogueWindow(WindowManager& parWindowManager,MWWorld::Environment& environment) + : WindowBase("openmw_dialogue_window_layout.xml", parWindowManager), + mEnvironment(environment) { // Centre dialog center(); @@ -76,11 +79,16 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) UString key = history->getColorTextAt(cursorPosition); //std::cout << "Clicked on key: " << key << std::endl; - if(color == "#686EBA") displayTopicText(lower_string(key)); + if(color == "#686EBA") + { + mEnvironment.mDialogueManager->keywordSelected(lower_string(key)); + displayTopicText(lower_string(key)); + } if(color == "#572D21") { //TODO: send back the answere to the question! - std::cout << "and the ansere is..."<< key; + mEnvironment.mDialogueManager->questionAnswered(key); + //std::cout << "and the ansere is..."<< key; } } } @@ -97,7 +105,8 @@ void DialogueWindow::open() void DialogueWindow::onByeClicked(MyGUI::Widget* _sender) { - eventBye(); + //eventBye(); + mEnvironment.mDialogueManager->goodbyeSelected(); } void DialogueWindow::onSelectTopic(MyGUI::List* _sender, size_t _index) @@ -105,6 +114,7 @@ void DialogueWindow::onSelectTopic(MyGUI::List* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; std::string topic = _sender->getItem(_index); + mEnvironment.mDialogueManager->keywordSelected(lower_string(topic)); displayTopicText(topic); //const std::string* theTopic = topicsList->getItemDataAt(_index); diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 9518edcde4..232721f0aa 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -9,6 +9,11 @@ namespace MWGui class WindowManager; } +namespace MWWorld +{ + class Environment; +} + /* This file contains the dialouge window Layout is defined by resources/mygui/openmw_dialogue_window_layout.xml. @@ -23,7 +28,7 @@ namespace MWGui class DialogueWindow: public WindowBase { public: - DialogueWindow(WindowManager& parWindowManager); + DialogueWindow(WindowManager& parWindowManager,MWWorld::Environment& environment); void open(); @@ -60,6 +65,8 @@ namespace MWGui MyGUI::ProgressPtr pDispositionBar; MyGUI::EditPtr pDispositionText; std::map pTopicsText;// this map links keyword and "real" text. + + MWWorld::Environment& mEnvironment; }; } #endif diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index f1db1654ee..5302489f1a 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -64,6 +64,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment console = new Console(w,h, environment, extensions); mJournal = new JournalWindow(*this); mMessageBoxManager = new MessageBoxManager(this); + dialogueWindow = new DialogueWindow(*this,environment); // The HUD is always on hud->setVisible(true); @@ -173,6 +174,7 @@ void WindowManager::updateVisible() #endif console->disable(); mJournal->setVisible(false); + dialogueWindow->setVisible(false); // Mouse is visible whenever we're not in game mode gui->setVisiblePointer(isGuiMode()); @@ -338,11 +340,6 @@ void WindowManager::updateVisible() if (mode == GM_Dialogue) { - if (!dialogueWindow) - { - dialogueWindow = new DialogueWindow(*this); - dialogueWindow->eventBye = MyGUI::newDelegate(this, &WindowManager::onDialogueWindowBye); - } dialogueWindow->open(); return; } From f76e0e19411be73ea12df2c0c8f652729bdb04ef Mon Sep 17 00:00:00 2001 From: gugus Date: Wed, 8 Feb 2012 00:32:22 +0100 Subject: [PATCH 06/77] corrected the light problem --- apps/openmw/mwrender/renderingmanager.cpp | 13 +++++++++---- apps/openmw/mwrender/renderingmanager.hpp | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 6215c1913f..adc0b23f99 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -54,10 +54,12 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const cameraPitchNode->attachObject(mRendering.getCamera()); mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode); + mSun = 0; } RenderingManager::~RenderingManager () { + //TODO: destroy mSun? delete mPlayer; delete mSkyManager; } @@ -204,12 +206,15 @@ void RenderingManager::configureAmbient(ESMS::CellStore &mCell // Create a "sun" that shines light downwards. It doesn't look // completely right, but leave it for now. - Ogre::Light *light = mRendering.getScene()->createLight(); + if(!mSun) + { + mSun = mRendering.getScene()->createLight(); + } Ogre::ColourValue colour; colour.setAsABGR (mCell.cell->ambi.sunlight); - light->setDiffuseColour (colour); - light->setType(Ogre::Light::LT_DIRECTIONAL); - light->setDirection(0,-1,0); + mSun->setDiffuseColour (colour); + mSun->setType(Ogre::Light::LT_DIRECTIONAL); + mSun->setDirection(0,-1,0); } // Switch through lighting modes. diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 747a3e0eea..f25dbfb540 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -120,6 +120,7 @@ class RenderingManager: private RenderingInterface { int mAmbientMode; Ogre::ColourValue mAmbientColor; + Ogre::Light* mSun; /// Root node for all objects added to the scene. This is rotated so /// that the OGRE coordinate system matches that used internally in From e7ef39cabc08a2b573687e3bab4df69062e6e43d Mon Sep 17 00:00:00 2001 From: gugus Date: Thu, 9 Feb 2012 19:27:15 +0100 Subject: [PATCH 07/77] more improvements to dialogue filters. Some of them are still missing. --- apps/openmw/mwdialogue/dialoguemanager.cpp | 153 ++++++++++++++++++++- apps/openmw/mwdialogue/dialoguemanager.hpp | 3 + 2 files changed, 151 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 7ffb7f29b2..d98b295f36 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -9,6 +9,7 @@ #include + #include "../mwworld/class.hpp" #include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" @@ -19,6 +20,8 @@ #include "../mwgui/dialogue.hpp" #include "../mwgui/window_manager.hpp" +#include "journal.hpp" + #include namespace @@ -128,7 +131,7 @@ namespace MWDialogue std::string name = select.selectRule.substr (5); // TODO types 4, 5, 6, 7, 8, 9, A, B, C - + //new TOTO: 5,6,9 switch (type) { case '1': // function @@ -169,12 +172,122 @@ namespace MWDialogue mEnvironment.mWorld->getStore())) return false; } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + + return true; + + case '4'://journal + if(select.type==ESM::VT_Int) + { + //std::cout << "vtint: " << select.i << std::endl; + bool isInJournal; + if(mEnvironment.mJournal->begin()!=mEnvironment.mJournal->end()) + { + for(std::deque::const_iterator it = mEnvironment.mJournal->begin();it!=mEnvironment.mJournal->end();it++) + { + + if(it->mTopic == name) isInJournal = true; + } + } + else + isInJournal = false; + if(!selectCompare(comp,int(isInJournal),select.i)) return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + + return true; + + case '7':// not ID + if(select.type==ESM::VT_String ||select.type==ESM::VT_Int)//bug in morrowind here? it's not a short, it's a string + { + int isID = int(toLower(name)==toLower(MWWorld::Class::get (actor).getId (actor))); + if (selectCompare(comp,!isID,select.i)) return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + + return true; + + case '8':// not faction + if(select.type==ESM::VT_Int) + { + ESMS::LiveCellRef* npc = actor.get(); + int isFaction = int(toLower(npc->base->faction) == toLower(name)); + if(selectCompare(comp,!isFaction,select.i)) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + + return true; + + case '9':// not class + if(select.type==ESM::VT_Int) + { + ESMS::LiveCellRef* npc = actor.get(); + int isClass = int(toLower(npc->base->cls) == toLower(name)); + if(selectCompare(comp,!isClass,select.i)) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + + return true; + + case 'A'://not Race + if(select.type==ESM::VT_Int) + { + ESMS::LiveCellRef* npc = actor.get(); + int isRace = int(toLower(npc->base->race) == toLower(name)); + //std::cout << "isRace"<(comp,!isRace,select.i)) + return false; + } else throw std::runtime_error ( "unsupported variable type in dialogue info select"); return true; + case 'B'://not Cell + if(select.type==ESM::VT_Int) + { + int isCell = int(toLower(actor.getCell()->cell->name) == toLower(name)); + if(selectCompare(comp,!isCell,select.i)) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + return true; + + case 'C'://not local + if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || + select.type==ESM::VT_Long) + { + if (checkLocal (comp, toLower (name), select.i, actor, + mEnvironment.mWorld->getStore())) + return false; + } + else if (select.type==ESM::VT_Float) + { + if (checkLocal (comp, toLower (name), select.f, actor, + mEnvironment.mWorld->getStore())) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + return true; + + default: std::cout << "unchecked select: " << type << " " << comp << " " << name << std::endl; @@ -186,11 +299,13 @@ namespace MWDialogue bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const { + //bool return true;//does the actor knows the topic? // actor id if (!info.actor.empty()) if (toLower (info.actor)!=MWWorld::Class::get (actor).getId (actor)) return false; + //NPC race if (!info.race.empty()) { ESMS::LiveCellRef *cellRef = actor.get(); @@ -202,6 +317,7 @@ namespace MWDialogue return false; } + //NPC class if (!info.clas.empty()) { ESMS::LiveCellRef *cellRef = actor.get(); @@ -213,6 +329,7 @@ namespace MWDialogue return false; } + //NPC faction if (!info.npcFaction.empty()) { ESMS::LiveCellRef *cellRef = actor.get(); @@ -222,10 +339,32 @@ namespace MWDialogue if (toLower (info.npcFaction)!=toLower (cellRef->base->faction)) return false; + + //check NPC rank + if(cellRef->base->npdt52.gold != -10) + { + if(cellRef->base->npdt52.rank < info.data.rank) return false; + } + else + { + if(cellRef->base->npdt12.rank < info.data.rank) return false; + } } // TODO check player faction + //check gender + ESMS::LiveCellRef* npc = actor.get(); + if(npc->base->flags&npc->base->Female) + { + if(static_cast (info.data.gender)==0) return false; + } + else + { + if(static_cast (info.data.gender)==1) return false; + } + + // check cell if (!info.cell.empty()) if (mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell->name != info.cell) @@ -297,10 +436,14 @@ namespace MWDialogue { if (isMatching (actor, *iter)) { - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); - win->addKeyword(it->first,iter->response); - //std::cout << "match found!!"; - break; + if(knownTopics.find(toLower(it->first)) != knownTopics.end()) + { + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + win->addKeyword(it->first,iter->response); + //std::cout << it->first; + //std::cout << "match found!!"; + break; + } } } } diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index 0e06838e6c..7579ce7e4e 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -4,6 +4,7 @@ #include #include "../mwworld/ptr.hpp" +#include namespace MWWorld { @@ -20,6 +21,8 @@ namespace MWDialogue bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const; + std::map knownTopics;// Those are the topics the player knows. + public: DialogueManager (MWWorld::Environment& environment); From ea8335a393c4fb1223d25fae1dec5b8f3e4b4b61 Mon Sep 17 00:00:00 2001 From: gugus Date: Fri, 10 Feb 2012 16:09:43 +0100 Subject: [PATCH 08/77] addTopic function --- apps/openmw/mwdialogue/dialoguemanager.cpp | 5 +++++ apps/openmw/mwdialogue/dialoguemanager.hpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index d98b295f36..053e3987bf 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -390,6 +390,11 @@ namespace MWDialogue DialogueManager::DialogueManager (MWWorld::Environment& environment) : mEnvironment (environment) {} + void DialogueManager::addTopic(std::string topic) + { + knownTopics[toLower(topic)] = true; + } + void DialogueManager::startDialogue (const MWWorld::Ptr& actor) { std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl; diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index 7579ce7e4e..cafad7c6ec 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -29,6 +29,8 @@ namespace MWDialogue void startDialogue (const MWWorld::Ptr& actor); + void addTopic(std::string topic); + //calbacks for the GUI void keywordSelected(std::string keyword); void goodbyeSelected(); From 94ab65f8bb7d4bd00e7a9919cedb77feb6cc6be9 Mon Sep 17 00:00:00 2001 From: gugus Date: Fri, 10 Feb 2012 16:21:04 +0100 Subject: [PATCH 09/77] fixe a compiling error? --- apps/openmw/mwgui/dialogue.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index c4cebaa671..ddd76bbeee 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -22,9 +22,12 @@ using namespace Widgets; 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 lowerCase; + + std::transform (str.begin(), str.end(), std::back_inserter (lowerCase), + (int(*)(int)) std::tolower); + + return lowerCase; } std::string::size_type find_str_ci(const std::string& str, const std::string& substr,size_t pos) From 554bf8e58601483b3fc4b520972e4b2137cc6fda Mon Sep 17 00:00:00 2001 From: gugus Date: Fri, 10 Feb 2012 22:01:31 +0100 Subject: [PATCH 10/77] Improvement in the dialogue manager --- apps/openmw/mwdialogue/dialoguemanager.cpp | 78 ++++++++++++++-------- apps/openmw/mwdialogue/dialoguemanager.hpp | 1 + 2 files changed, 50 insertions(+), 29 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 053e3987bf..8e70778700 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -36,6 +36,7 @@ namespace return lowerCase; } + template bool selectCompare (char comp, T1 value1, T2 value2) { @@ -399,8 +400,39 @@ namespace MWDialogue { std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl; + //initialise the GUI + mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue); + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + win->startDialogue(MWWorld::Class::get (actor).getName (actor)); + + actorKnownTopics.clear(); + ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + { + ESM::Dialogue ndialogue = it->second; + if(ndialogue.type == ESM::Dialogue::Type::Topic) + { + for (std::vector::const_iterator iter (it->second.mInfo.begin()); + iter!=it->second.mInfo.end(); ++iter) + { + if (isMatching (actor, *iter)) + { + actorKnownTopics[it->first] = iter->response; + if(knownTopics.find(toLower(it->first)) != knownTopics.end()) + { + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + win->addKeyword(it->first,iter->response); + //std::cout << it->first; + //std::cout << "match found!!"; + break; + } + } + } + } + } + const ESM::Dialogue *dialogue = mEnvironment.mWorld->getStore().dialogs.find ("hello"); - + for (std::vector::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) { @@ -421,43 +453,31 @@ namespace MWDialogue std::cout << "script: " << iter->resultScript << std::endl; // TODO execute script } - - 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::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) - { - ESM::Dialogue ndialogue = it->second; - if(ndialogue.type == ESM::Dialogue::Type::Topic) - { - for (std::vector::const_iterator iter (it->second.mInfo.begin()); - iter!=it->second.mInfo.end(); ++iter) - { - if (isMatching (actor, *iter)) - { - if(knownTopics.find(toLower(it->first)) != knownTopics.end()) - { - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); - win->addKeyword(it->first,iter->response); - //std::cout << it->first; - //std::cout << "match found!!"; - break; - } - } - } - } - } + //helper function + std::string::size_type find_str_ci(const std::string& str, const std::string& substr,size_t pos) + { + return toLower(str).find(toLower(substr),pos); } void DialogueManager::keywordSelected(std::string keyword) { - std::cout << "keyword" << keyword; + std::string text = actorKnownTopics[keyword]; + std::map::iterator it; + for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) + { + if(find_str_ci(text,it->second,0) !=std::string::npos) + { + knownTopics[it->first] = true; + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + win->addKeyword(it->first,it->second); + } + } } void DialogueManager::goodbyeSelected() diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index cafad7c6ec..88ae9e35c7 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -22,6 +22,7 @@ namespace MWDialogue bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const; std::map knownTopics;// Those are the topics the player knows. + std::map actorKnownTopics; public: From f1dc36072026e9943c5a858b9e0a6688fdaa02bc Mon Sep 17 00:00:00 2001 From: gugus Date: Fri, 10 Feb 2012 22:02:24 +0100 Subject: [PATCH 11/77] added the script instruction addTopic --- apps/openmw/mwscript/dialogueextensions.cpp | 20 ++++++++++++++++++++ apps/openmw/mwscript/docs/vmformat.txt | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index c2ff9ed8bd..26fb6d9bed 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -8,6 +8,7 @@ #include #include "../mwdialogue/journal.hpp" +#include "../mwdialogue/dialoguemanager.hpp" #include "interpretercontext.hpp" @@ -72,15 +73,33 @@ namespace MWScript } }; + class OpAddTopic : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWScript::InterpreterContext& context + = static_cast (runtime.getContext()); + + std::string topic = runtime.getStringLiteral (runtime[0].mInteger); + runtime.pop(); + + context.getEnvironment().mDialogueManager->addTopic(topic); + } + }; + const int opcodeJournal = 0x2000133; const int opcodeSetJournalIndex = 0x2000134; const int opcodeGetJournalIndex = 0x2000135; + const int opcodeAddTopic = 0x200013a; void registerExtensions (Compiler::Extensions& extensions) { extensions.registerInstruction ("journal", "cl", opcodeJournal); extensions.registerInstruction ("setjournalindex", "cl", opcodeSetJournalIndex); extensions.registerFunction ("getjournalindex", 'l', "c", opcodeGetJournalIndex); + extensions.registerInstruction ("addtopic", "S" , opcodeAddTopic); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -88,6 +107,7 @@ namespace MWScript interpreter.installSegment5 (opcodeJournal, new OpJournal); interpreter.installSegment5 (opcodeSetJournalIndex, new OpSetJournalIndex); interpreter.installSegment5 (opcodeGetJournalIndex, new OpGetJournalIndex); + interpreter.installSegment5 (opcodeAddTopic, new OpAddTopic); } } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 1836053286..1f033c8db8 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -115,4 +115,5 @@ op 0x2000136: GetPCCell op 0x2000137: GetButtonPressed op 0x2000138: SkipAnim op 0x2000139: SkipAnim, expplicit reference -opcodes 0x200013a-0x3ffffff unused +op 0x200013a: AddTopic +opcodes 0x200013b-0x3ffffff unused From eee5d20809a3d538c5f03d6650dfbd6f7d28dd3f Mon Sep 17 00:00:00 2001 From: gugus Date: Fri, 10 Feb 2012 22:54:17 +0100 Subject: [PATCH 12/77] a little fix --- apps/openmw/mwdialogue/dialoguemanager.cpp | 36 +++++++++++++++------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 8e70778700..df85430327 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -121,6 +121,14 @@ namespace namespace MWDialogue { + + //helper function + std::string::size_type find_str_ci(const std::string& str, const std::string& substr,size_t pos) + { + return toLower(str).find(toLower(substr),pos); + } + + bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo::SelectStruct& select) const { @@ -439,9 +447,9 @@ namespace MWDialogue if (isMatching (actor, *iter)) { // start dialogue - std::cout << "found matching info record" << std::endl; + //std::cout << "found matching info record" << std::endl; - std::cout << "response: " << iter->response << std::endl; + //std::cout << "response: " << iter->response << std::endl; if (!iter->sound.empty()) { @@ -450,28 +458,34 @@ namespace MWDialogue if (!iter->resultScript.empty()) { - std::cout << "script: " << iter->resultScript << std::endl; + //std::cout << "script: " << iter->resultScript << std::endl; // TODO execute script } + std::string text = iter->response; + std::map::iterator it; + for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) + { + if(find_str_ci(text,it->first,0) !=std::string::npos) + { + std::cout << "fouuuuuuuuuuund"; + knownTopics[it->first] = true; + MWGui::DialogueWindow* win2 = mEnvironment.mWindowManager->getDialogueWindow(); + win2->addKeyword(it->first,it->second); + } + } win->addText(iter->response); - break; + //break; } } } - //helper function - std::string::size_type find_str_ci(const std::string& str, const std::string& substr,size_t pos) - { - return toLower(str).find(toLower(substr),pos); - } - void DialogueManager::keywordSelected(std::string keyword) { std::string text = actorKnownTopics[keyword]; std::map::iterator it; for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) { - if(find_str_ci(text,it->second,0) !=std::string::npos) + if(find_str_ci(text,it->first,0) !=std::string::npos) { knownTopics[it->first] = true; MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); From 4658ec276f87f63024daace58759b98821bcc622 Mon Sep 17 00:00:00 2001 From: gugus Date: Sat, 11 Feb 2012 12:18:47 +0100 Subject: [PATCH 13/77] increased the max size of the text of the dialogue --- apps/openmw/mwgui/dialogue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index ddd76bbeee..5754d1d7e6 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -50,7 +50,7 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager,MWWorld::Environm getWidget(history, "History"); history->setOverflowToTheLeft(true); history->getClient()->eventMouseButtonClick = MyGUI::newDelegate(this, &DialogueWindow::onHistoryClicked); - + history->setMaxTextLength(1000000); //Topics list getWidget(topicsList, "TopicsList"); topicsList->setScrollVisible(true); From 4d4ae41a4a2a2af504e1e69e6dd8b933d3ce9b41 Mon Sep 17 00:00:00 2001 From: gugus Date: Sat, 11 Feb 2012 12:19:02 +0100 Subject: [PATCH 14/77] greetings are working now --- apps/openmw/mwdialogue/dialoguemanager.cpp | 64 ++++++++++++---------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index df85430327..d4b2234d65 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -438,43 +438,47 @@ namespace MWDialogue } } } + //ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - const ESM::Dialogue *dialogue = mEnvironment.mWorld->getStore().dialogs.find ("hello"); - - for (std::vector::const_iterator iter (dialogue->mInfo.begin()); - iter!=dialogue->mInfo.end(); ++iter) + bool greetingFound = false; + for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { - if (isMatching (actor, *iter)) + ESM::Dialogue ndialogue = it->second; + if(ndialogue.type == ESM::Dialogue::Type::Greeting) { - // start dialogue - //std::cout << "found matching info record" << std::endl; - - //std::cout << "response: " << iter->response << std::endl; - - if (!iter->sound.empty()) - { - // TODO play sound - } - - if (!iter->resultScript.empty()) - { - //std::cout << "script: " << iter->resultScript << std::endl; - // TODO execute script - } - std::string text = iter->response; - std::map::iterator it; - for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) + if (greetingFound) break; + for (std::vector::const_iterator iter (it->second.mInfo.begin()); + iter!=it->second.mInfo.end(); ++iter) { - if(find_str_ci(text,it->first,0) !=std::string::npos) + if (isMatching (actor, *iter)) { - std::cout << "fouuuuuuuuuuund"; - knownTopics[it->first] = true; - MWGui::DialogueWindow* win2 = mEnvironment.mWindowManager->getDialogueWindow(); - win2->addKeyword(it->first,it->second); + if (!iter->sound.empty()) + { + // TODO play sound + } + + if (!iter->resultScript.empty()) + { + //std::cout << "script: " << iter->resultScript << std::endl; + // TODO execute script + } + std::string text = iter->response; + std::map::iterator it; + for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) + { + if(find_str_ci(text,it->first,0) !=std::string::npos) + { + //std::cout << "fouuuuuuuuuuund"; + knownTopics[it->first] = true; + MWGui::DialogueWindow* win2 = mEnvironment.mWindowManager->getDialogueWindow(); + win2->addKeyword(it->first,it->second); + } + } + win->addText(iter->response); + greetingFound = true; + break; } } - win->addText(iter->response); - //break; } } } From d66b6743f4dab4cfc0698c0dd501f35d0a9bb282 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 12 Feb 2012 13:58:02 +0100 Subject: [PATCH 15/77] minor fix --- apps/openmw/mwdialogue/dialoguemanager.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index d4b2234d65..339755c358 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -197,7 +197,7 @@ namespace MWDialogue for(std::deque::const_iterator it = mEnvironment.mJournal->begin();it!=mEnvironment.mJournal->end();it++) { - if(it->mTopic == name) isInJournal = true; + if(it->mTopic == name) isInJournal = true; } } else @@ -227,7 +227,7 @@ namespace MWDialogue { ESMS::LiveCellRef* npc = actor.get(); int isFaction = int(toLower(npc->base->faction) == toLower(name)); - if(selectCompare(comp,!isFaction,select.i)) + if(selectCompare(comp,!isFaction,select.i)) return false; } else @@ -241,7 +241,7 @@ namespace MWDialogue { ESMS::LiveCellRef* npc = actor.get(); int isClass = int(toLower(npc->base->cls) == toLower(name)); - if(selectCompare(comp,!isClass,select.i)) + if(selectCompare(comp,!isClass,select.i)) return false; } else @@ -256,7 +256,7 @@ namespace MWDialogue ESMS::LiveCellRef* npc = actor.get(); int isRace = int(toLower(npc->base->race) == toLower(name)); //std::cout << "isRace"<(comp,!isRace,select.i)) + if(selectCompare(comp,!isRace,select.i)) return false; } else @@ -418,7 +418,7 @@ namespace MWDialogue for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { ESM::Dialogue ndialogue = it->second; - if(ndialogue.type == ESM::Dialogue::Type::Topic) + if(ndialogue.type == ESM::Dialogue::Topic) { for (std::vector::const_iterator iter (it->second.mInfo.begin()); iter!=it->second.mInfo.end(); ++iter) @@ -444,7 +444,7 @@ namespace MWDialogue for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { ESM::Dialogue ndialogue = it->second; - if(ndialogue.type == ESM::Dialogue::Type::Greeting) + if(ndialogue.type == ESM::Dialogue::Greeting) { if (greetingFound) break; for (std::vector::const_iterator iter (it->second.mInfo.begin()); From bc72b2d535b784eef9d474baba5d09b8beec4f1b Mon Sep 17 00:00:00 2001 From: gugus Date: Sun, 12 Feb 2012 22:24:23 +0100 Subject: [PATCH 16/77] fixed text color --- apps/openmw/mwgui/dialogue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 5754d1d7e6..055b0a75f9 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -190,7 +190,7 @@ void DialogueWindow::displayTopicText(std::string topic) void DialogueWindow::addText(std::string text) { - history->addDialogText(parseText(text)); + history->addDialogText("#B29154"+parseText(text)+"#B29154"); } void DialogueWindow::askQuestion(std::string question,std::list answers) From 232e478768a488e341a3255c71bab4e770db73d1 Mon Sep 17 00:00:00 2001 From: gugus Date: Wed, 15 Feb 2012 13:23:59 +0100 Subject: [PATCH 17/77] Fix for prefix/suffix stuff --- apps/openmw/mwdialogue/dialoguemanager.cpp | 50 +++++++++++++--------- apps/openmw/mwdialogue/dialoguemanager.hpp | 2 + apps/openmw/mwgui/dialogue.cpp | 21 ++++++--- 3 files changed, 47 insertions(+), 26 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index d4b2234d65..b2915b10af 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -404,6 +404,32 @@ namespace MWDialogue knownTopics[toLower(topic)] = true; } + void DialogueManager::parseText(std::string text) + { + std::map::iterator it; + for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) + { + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + size_t pos = find_str_ci(text,it->first,0); + if(pos !=std::string::npos) + { + if(pos==0) + { + //std::cout << "fouuuuuuuuuuund"; + knownTopics[it->first] = true; + win->addKeyword(it->first,it->second); + } + else if(text.substr(pos -1,1) == " ") + { + //std::cout << "fouuuuuuuuuuund"; + knownTopics[it->first] = true; + win->addKeyword(it->first,it->second); + } + } + + } + } + void DialogueManager::startDialogue (const MWWorld::Ptr& actor) { std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl; @@ -463,18 +489,9 @@ namespace MWDialogue // TODO execute script } std::string text = iter->response; - std::map::iterator it; - for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) - { - if(find_str_ci(text,it->first,0) !=std::string::npos) - { - //std::cout << "fouuuuuuuuuuund"; - knownTopics[it->first] = true; - MWGui::DialogueWindow* win2 = mEnvironment.mWindowManager->getDialogueWindow(); - win2->addKeyword(it->first,it->second); - } - } + parseText(text); win->addText(iter->response); + greetingFound = true; break; } @@ -486,16 +503,7 @@ namespace MWDialogue void DialogueManager::keywordSelected(std::string keyword) { std::string text = actorKnownTopics[keyword]; - std::map::iterator it; - for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) - { - if(find_str_ci(text,it->first,0) !=std::string::npos) - { - knownTopics[it->first] = true; - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); - win->addKeyword(it->first,it->second); - } - } + parseText(text); } void DialogueManager::goodbyeSelected() diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index 88ae9e35c7..4d16abf6d5 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -21,6 +21,8 @@ namespace MWDialogue bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const; + void parseText(std::string text); + std::map knownTopics;// Those are the topics the player knows. std::map actorKnownTopics; diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 055b0a75f9..f336d8a38d 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -154,12 +154,23 @@ void addColorInString(std::string& str, const std::string& keyword,std::string c size_t pos = 0; while((pos = find_str_ci(str,keyword, pos)) != std::string::npos) { + if(pos==0) + { + str.insert(pos,color1); + pos += color1.length(); + pos += keyword.length(); + str.insert(pos,color2); + pos+= color2.length(); + } + else if(str.substr(pos -1,1) == " ") + { + str.insert(pos,color1); + pos += color1.length(); + pos += keyword.length(); + str.insert(pos,color2); + pos+= color2.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(); } } From c0bd86ce4446a4ac340b5f6947de616aac28db0a Mon Sep 17 00:00:00 2001 From: gugus Date: Fri, 17 Feb 2012 20:20:23 +0100 Subject: [PATCH 18/77] scripts. Not tested --- apps/openmw/mwdialogue/dialoguemanager.cpp | 91 ++++++++++++++++++++-- apps/openmw/mwdialogue/dialoguemanager.hpp | 23 +++++- 2 files changed, 105 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index b2915b10af..5830832dbc 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -24,6 +24,19 @@ #include +#include "../mwscript/extensions.hpp" +#include +#include +#include +#include +#include +#include +#include + +#include "../mwscript/compilercontext.hpp" +#include "../mwscript/interpretercontext.hpp" +#include + namespace { std::string toLower (const std::string& name) @@ -397,7 +410,10 @@ namespace MWDialogue return true; } - DialogueManager::DialogueManager (MWWorld::Environment& environment) : mEnvironment (environment) {} + DialogueManager::DialogueManager (MWWorld::Environment& environment) : + mEnvironment (environment),mCompilerContext (MWScript::CompilerContext::Type_Dialgoue, environment) + { + } void DialogueManager::addTopic(std::string topic) { @@ -406,7 +422,7 @@ namespace MWDialogue void DialogueManager::parseText(std::string text) { - std::map::iterator it; + std::map::iterator it; for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) { MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); @@ -417,13 +433,13 @@ namespace MWDialogue { //std::cout << "fouuuuuuuuuuund"; knownTopics[it->first] = true; - win->addKeyword(it->first,it->second); + win->addKeyword(it->first,it->second.response); } else if(text.substr(pos -1,1) == " ") { //std::cout << "fouuuuuuuuuuund"; knownTopics[it->first] = true; - win->addKeyword(it->first,it->second); + win->addKeyword(it->first,it->second.response); } } @@ -434,6 +450,8 @@ namespace MWDialogue { std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl; + mActor = actor; + //initialise the GUI mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue); MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); @@ -451,7 +469,7 @@ namespace MWDialogue { if (isMatching (actor, *iter)) { - actorKnownTopics[it->first] = iter->response; + actorKnownTopics[it->first] = *iter; if(knownTopics.find(toLower(it->first)) != knownTopics.end()) { MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); @@ -491,7 +509,7 @@ namespace MWDialogue std::string text = iter->response; parseText(text); win->addText(iter->response); - + executeScript(iter->resultScript); greetingFound = true; break; } @@ -500,10 +518,63 @@ namespace MWDialogue } } + bool DialogueManager::compile (const std::string& cmd, Compiler::Output& output) + { + try + { + ErrorHandler::reset(); + + std::istringstream input (cmd + '\n'); + + Compiler::Scanner scanner (*this, input, mCompilerContext.getExtensions()); + + Compiler::FileParser parser(*this,mCompilerContext); + + scanner.scan (parser); + + return isGood(); + } + catch (const Compiler::SourceException& error) + { + // error has already been reported via error handler + } + catch (const std::exception& error) + { + printError (std::string ("An exception has been thrown: ") + error.what()); + } + + return false; + } + + void DialogueManager::executeScript(std::string script) + { + Compiler::Locals locals; + Compiler::Output output (locals); + + if(compile(script,output)) + { + try + { + MWScript::InterpreterContext interpreterContext(mEnvironment,&mActor.getRefData().getLocals(),mActor); + Interpreter::Interpreter interpreter; + MWScript::installOpcodes (interpreter); + std::vector code; + output.getCode (code); + interpreter.run (&code[0], code.size(), interpreterContext); + } + catch (const std::exception& error) + { + printError (std::string ("An exception has been thrown: ") + error.what()); + } + } + } + void DialogueManager::keywordSelected(std::string keyword) { - std::string text = actorKnownTopics[keyword]; + std::string text = actorKnownTopics[keyword].response; + std::string script = actorKnownTopics[keyword].resultScript; parseText(text); + executeScript(script); } void DialogueManager::goodbyeSelected() @@ -516,4 +587,10 @@ namespace MWDialogue std::cout << "and the ansere is..."<< answere; } + void DialogueManager::printError(std::string error) + { + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + win->addText(error); + } + } diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index 4d16abf6d5..4226a447cd 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -3,6 +3,11 @@ #include +#include +#include "../mwscript/compilercontext.hpp" +#include "../mwscript/interpretercontext.hpp" +#include + #include "../mwworld/ptr.hpp" #include @@ -13,7 +18,7 @@ namespace MWWorld namespace MWDialogue { - class DialogueManager + class DialogueManager: private Compiler::ErrorHandler { MWWorld::Environment& mEnvironment; @@ -24,7 +29,21 @@ namespace MWDialogue void parseText(std::string text); std::map knownTopics;// Those are the topics the player knows. - std::map actorKnownTopics; + std::map actorKnownTopics; + + MWScript::CompilerContext mCompilerContext; + + /// Report error to the user. + virtual void report (const std::string& message, const Compiler::TokenLoc& loc, Type type){}; + + /// Report a file related error + virtual void report (const std::string& message, Type type){}; + + bool compile (const std::string& cmd, Compiler::Output& output); + void executeScript(std::string script); + MWWorld::Ptr mActor; + + void printError(std::string error); public: From 9716199d187d21be6d4793e35a442f64b2747192 Mon Sep 17 00:00:00 2001 From: gugus Date: Sat, 18 Feb 2012 12:19:42 +0100 Subject: [PATCH 19/77] script "fix". I'm waiting for you Zini^^ --- apps/openmw/mwdialogue/dialoguemanager.cpp | 31 +++++++++++----------- apps/openmw/mwdialogue/dialoguemanager.hpp | 15 +++++------ 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 5830832dbc..2aea3fcc38 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -27,7 +27,6 @@ #include "../mwscript/extensions.hpp" #include #include -#include #include #include #include @@ -35,7 +34,7 @@ #include "../mwscript/compilercontext.hpp" #include "../mwscript/interpretercontext.hpp" -#include +#include namespace { @@ -411,7 +410,8 @@ namespace MWDialogue } DialogueManager::DialogueManager (MWWorld::Environment& environment) : - mEnvironment (environment),mCompilerContext (MWScript::CompilerContext::Type_Dialgoue, environment) + mEnvironment (environment),mCompilerContext (MWScript::CompilerContext::Type_Dialgoue, environment), + mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream) { } @@ -518,21 +518,26 @@ namespace MWDialogue } } - bool DialogueManager::compile (const std::string& cmd, Compiler::Output& output) + bool DialogueManager::compile (const std::string& cmd,std::vector& code) { try { - ErrorHandler::reset(); + mErrorHandler.reset(); - std::istringstream input (cmd + '\n'); + std::istringstream input (cmd); - Compiler::Scanner scanner (*this, input, mCompilerContext.getExtensions()); + Compiler::Scanner scanner (mErrorHandler, input, mCompilerContext.getExtensions()); - Compiler::FileParser parser(*this,mCompilerContext); + Compiler::ScriptParser parser(mErrorHandler,mCompilerContext,Compiler::Locals());//??????&mActor.getRefData().getLocals()); scanner.scan (parser); - return isGood(); + if(mErrorHandler.isGood()) + { + parser.getCode(code); + return true; + } + return false; } catch (const Compiler::SourceException& error) { @@ -548,18 +553,14 @@ namespace MWDialogue void DialogueManager::executeScript(std::string script) { - Compiler::Locals locals; - Compiler::Output output (locals); - - if(compile(script,output)) + std::vector code; + if(compile(script,code)) { try { MWScript::InterpreterContext interpreterContext(mEnvironment,&mActor.getRefData().getLocals(),mActor); Interpreter::Interpreter interpreter; MWScript::installOpcodes (interpreter); - std::vector code; - output.getCode (code); interpreter.run (&code[0], code.size(), interpreterContext); } catch (const std::exception& error) diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index 4226a447cd..600171d331 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -3,7 +3,7 @@ #include -#include +#include #include "../mwscript/compilercontext.hpp" #include "../mwscript/interpretercontext.hpp" #include @@ -18,7 +18,7 @@ namespace MWWorld namespace MWDialogue { - class DialogueManager: private Compiler::ErrorHandler + class DialogueManager { MWWorld::Environment& mEnvironment; @@ -32,14 +32,11 @@ namespace MWDialogue std::map actorKnownTopics; MWScript::CompilerContext mCompilerContext; + std::ostream mErrorStream; + Compiler::StreamErrorHandler mErrorHandler; + - /// Report error to the user. - virtual void report (const std::string& message, const Compiler::TokenLoc& loc, Type type){}; - - /// Report a file related error - virtual void report (const std::string& message, Type type){}; - - bool compile (const std::string& cmd, Compiler::Output& output); + bool compile (const std::string& cmd,std::vector& code); void executeScript(std::string script); MWWorld::Ptr mActor; From 69f0ec99f10f9fa8ed905ba9fee83ab8f0c99d4b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 5 Mar 2012 16:56:14 +0100 Subject: [PATCH 20/77] implemented dialogue scripts --- apps/openmw/engine.cpp | 15 +++++----- apps/openmw/engine.hpp | 3 +- apps/openmw/mwdialogue/dialoguemanager.cpp | 18 ++++++++++-- apps/openmw/mwscript/scriptmanager.cpp | 33 +++++++++++++++++----- apps/openmw/mwscript/scriptmanager.hpp | 9 +++++- apps/openmw/mwworld/environment.hpp | 4 ++- 6 files changed, 60 insertions(+), 22 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 4765ceadc5..bff952ab8c 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -60,7 +60,7 @@ void OMW::Engine::executeLocalScripts() MWScript::InterpreterContext interpreterContext (mEnvironment, &script.second.getRefData().getLocals(), script.second); - mScriptManager->run (script.first, interpreterContext); + mEnvironment.mScriptManager->run (script.first, interpreterContext); if (mEnvironment.mWorld->hasCellChanged()) break; @@ -183,7 +183,6 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) , mCompileAll (false) , mReportFocus (false) , mFocusTDiff (0) - , mScriptManager (0) , mScriptContext (0) , mFSStrict (false) , mCfgMgr(configurationManager) @@ -200,7 +199,7 @@ OMW::Engine::~Engine() delete mEnvironment.mMechanicsManager; delete mEnvironment.mDialogueManager; delete mEnvironment.mJournal; - delete mScriptManager; + delete mEnvironment.mScriptManager; delete mScriptContext; delete mOgre; } @@ -350,11 +349,11 @@ void OMW::Engine::go() mEnvironment); mScriptContext->setExtensions (&mExtensions); - mScriptManager = new MWScript::ScriptManager (mEnvironment.mWorld->getStore(), mVerboseScripts, - *mScriptContext); + mEnvironment.mScriptManager = new MWScript::ScriptManager (mEnvironment.mWorld->getStore(), + mVerboseScripts, *mScriptContext); mEnvironment.mGlobalScripts = new MWScript::GlobalScripts (mEnvironment.mWorld->getStore(), - *mScriptManager); + *mEnvironment.mScriptManager); // Create game mechanics system mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager (mEnvironment); @@ -395,7 +394,7 @@ void OMW::Engine::go() // scripts if (mCompileAll) { - std::pair result = mScriptManager->compileAll(); + std::pair result = mEnvironment.mScriptManager->compileAll(); if (result.first) std::cout @@ -437,7 +436,7 @@ void OMW::Engine::activate() if (!script.empty()) { mEnvironment.mWorld->getLocalScripts().setIgnore (ptr); - mScriptManager->run (script, interpreterContext); + mEnvironment.mScriptManager->run (script, interpreterContext); } if (!interpreterContext.hasActivationBeenHandled()) diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 5c5cdc018f..690430784b 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -78,10 +78,9 @@ namespace OMW std::string mFocusName; MWWorld::Environment mEnvironment; - MWScript::ScriptManager *mScriptManager; Compiler::Extensions mExtensions; Compiler::Context *mScriptContext; - + Files::Collections mFileCollections; bool mFSStrict; diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 9c099f7dbc..5bcf465990 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -25,6 +25,8 @@ #include #include "../mwscript/extensions.hpp" +#include "../mwscript/scriptmanager.hpp" + #include #include #include @@ -409,7 +411,7 @@ namespace MWDialogue return true; } - DialogueManager::DialogueManager (MWWorld::Environment& environment) : + DialogueManager::DialogueManager (MWWorld::Environment& environment) : mEnvironment (environment),mCompilerContext (MWScript::CompilerContext::Type_Dialgoue, environment), mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream) { @@ -524,11 +526,21 @@ namespace MWDialogue { mErrorHandler.reset(); - std::istringstream input (cmd); + std::istringstream input (cmd + "\n"); Compiler::Scanner scanner (mErrorHandler, input, mCompilerContext.getExtensions()); - Compiler::ScriptParser parser(mErrorHandler,mCompilerContext,Compiler::Locals());//??????&mActor.getRefData().getLocals()); + Compiler::Locals locals; + + std::string actorScript = MWWorld::Class::get (mActor).getScript (mActor); + + if (!actorScript.empty()) + { + // grab local variables from actor's script, if available. + locals = mEnvironment.mScriptManager->getLocals (actorScript); + } + + Compiler::ScriptParser parser(mErrorHandler,mCompilerContext, locals); scanner.scan (parser); diff --git a/apps/openmw/mwscript/scriptmanager.cpp b/apps/openmw/mwscript/scriptmanager.cpp index 5fcfcc6050..e93f2deeca 100644 --- a/apps/openmw/mwscript/scriptmanager.cpp +++ b/apps/openmw/mwscript/scriptmanager.cpp @@ -63,7 +63,7 @@ namespace MWScript { std::vector code; mParser.getCode (code); - mScripts.insert (std::make_pair (name, code)); + mScripts.insert (std::make_pair (name, std::make_pair (code, mParser.getLocals()))); // TODO sanity check on generated locals @@ -77,8 +77,7 @@ namespace MWScript void ScriptManager::run (const std::string& name, Interpreter::Context& interpreterContext) { // compile script - std::map >::iterator iter = - mScripts.find (name); + ScriptCollection::iterator iter = mScripts.find (name); if (iter==mScripts.end()) { @@ -86,7 +85,7 @@ namespace MWScript { // failed -> ignore script from now on. std::vector empty; - mScripts.insert (std::make_pair (name, empty)); + mScripts.insert (std::make_pair (name, std::make_pair (empty, Compiler::Locals()))); return; } @@ -95,7 +94,7 @@ namespace MWScript } // execute script - if (!iter->second.empty()) + if (!iter->second.first.empty()) try { if (!mOpcodesInstalled) @@ -104,7 +103,7 @@ namespace MWScript mOpcodesInstalled = true; } - mInterpreter.run (&iter->second[0], iter->second.size(), interpreterContext); + mInterpreter.run (&iter->second.first[0], iter->second.first.size(), interpreterContext); } catch (const std::exception& e) { @@ -113,7 +112,7 @@ namespace MWScript if (mVerbose) std::cerr << "(" << e.what() << ")" << std::endl; - iter->second.clear(); // don't execute again. + iter->second.first.clear(); // don't execute again. } } @@ -132,4 +131,24 @@ namespace MWScript return std::make_pair (count, success); } + + Compiler::Locals& ScriptManager::getLocals (const std::string& name) + { + ScriptCollection::iterator iter = mScripts.find (name); + + if (iter==mScripts.end()) + { + if (!compile (name)) + { + // failed -> ignore script from now on. + std::vector empty; + mScripts.insert (std::make_pair (name, std::make_pair (empty, Compiler::Locals()))); + throw std::runtime_error ("failed to compile script " + name); + } + + iter = mScripts.find (name); + } + + return iter->second.second; + } } diff --git a/apps/openmw/mwscript/scriptmanager.hpp b/apps/openmw/mwscript/scriptmanager.hpp index 74511f456e..35cbc0d1e8 100644 --- a/apps/openmw/mwscript/scriptmanager.hpp +++ b/apps/openmw/mwscript/scriptmanager.hpp @@ -39,7 +39,11 @@ namespace MWScript Interpreter::Interpreter mInterpreter; bool mOpcodesInstalled; - std::map > mScripts; + typedef std::pair, Compiler::Locals> CompiledScript; + typedef std::map ScriptCollection; + + + ScriptCollection mScripts; public: @@ -56,6 +60,9 @@ namespace MWScript std::pair compileAll(); ///< Compile all scripts /// \return count, success + + Compiler::Locals& getLocals (const std::string& name); + ///< Return locals for script \a name. }; }; diff --git a/apps/openmw/mwworld/environment.hpp b/apps/openmw/mwworld/environment.hpp index a403ee1657..3a83f886fd 100644 --- a/apps/openmw/mwworld/environment.hpp +++ b/apps/openmw/mwworld/environment.hpp @@ -9,6 +9,7 @@ namespace MWSound namespace MWScript { class GlobalScripts; + class ScriptManager; } namespace MWGui @@ -41,7 +42,7 @@ namespace MWWorld { public: Environment() - : mWorld (0), mSoundManager (0), mGlobalScripts (0), mWindowManager (0), + : mWorld (0), mSoundManager (0), mGlobalScripts (0), mScriptManager (0), mWindowManager (0), mMechanicsManager (0), mDialogueManager (0), mJournal (0), mFrameDuration (0), mInputManager (0) {} @@ -49,6 +50,7 @@ namespace MWWorld World *mWorld; MWSound::SoundManager *mSoundManager; MWScript::GlobalScripts *mGlobalScripts; + MWScript::ScriptManager *mScriptManager; MWGui::WindowManager *mWindowManager; MWMechanics::MechanicsManager *mMechanicsManager; MWDialogue::DialogueManager *mDialogueManager; From 39415f0b4a90777dfdc04fc7c3c78b85ee7043b5 Mon Sep 17 00:00:00 2001 From: gugus Date: Wed, 7 Mar 2012 17:35:10 +0100 Subject: [PATCH 21/77] fix compilation bug with Visual C++ --- apps/openmw/mwworld/weather.cpp | 8 ++++++++ apps/openmw/mwworld/weather.hpp | 16 ++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 059b0ec1e2..90afc4e78b 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -21,6 +21,14 @@ const std::string WeatherGlobals::mThunderSoundID0 = "Thunder0"; const std::string WeatherGlobals::mThunderSoundID1 = "Thunder1"; const std::string WeatherGlobals::mThunderSoundID2 = "Thunder2"; const std::string WeatherGlobals::mThunderSoundID3 = "Thunder3"; +const float WeatherGlobals::mSunriseTime = 8; +const float WeatherGlobals::mSunsetTime = 18; +const float WeatherGlobals::mSunriseDuration = 2; +const float WeatherGlobals::mSunsetDuration = 2; +const float WeatherGlobals::mWeatherUpdateTime = 20.f; +const float WeatherGlobals::mThunderFrequency = .4; +const float WeatherGlobals::mThunderThreshold = 0.6; +const float WeatherGlobals::mThunderSoundDelay = 0.25; WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environment* env) : mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0), diff --git a/apps/openmw/mwworld/weather.hpp b/apps/openmw/mwworld/weather.hpp index 7a719252b0..9353f7cd1d 100644 --- a/apps/openmw/mwworld/weather.hpp +++ b/apps/openmw/mwworld/weather.hpp @@ -95,18 +95,18 @@ namespace MWWorld Script Color=255,20,20 */ - static const float mSunriseTime = 8; - static const float mSunsetTime = 18; - static const float mSunriseDuration = 2; - static const float mSunsetDuration = 2; + static const float mSunriseTime; + static const float mSunsetTime; + static const float mSunriseDuration; + static const float mSunsetDuration; - static const float mWeatherUpdateTime = 20.f; + static const float mWeatherUpdateTime; // morrowind sets these per-weather, but since they are only used by 'thunderstorm' // weather setting anyway, we can just as well set them globally - static const float mThunderFrequency = .4; - static const float mThunderThreshold = 0.6; - static const float mThunderSoundDelay = 0.25; + static const float mThunderFrequency; + static const float mThunderThreshold; + static const float mThunderSoundDelay; static const std::string mThunderSoundID0; static const std::string mThunderSoundID1; static const std::string mThunderSoundID2; From 6f7752633aad28291eeda7a8cbfa41c7ac731ca3 Mon Sep 17 00:00:00 2001 From: gugus Date: Wed, 7 Mar 2012 18:44:09 +0100 Subject: [PATCH 22/77] there was no extension in the compiler context. Corrected. But Choice doesn't work. --- apps/openmw/engine.cpp | 2 +- apps/openmw/mwdialogue/dialoguemanager.cpp | 11 +++++++++-- apps/openmw/mwdialogue/dialoguemanager.hpp | 4 +++- apps/openmw/mwgui/dialogue.cpp | 8 ++++---- apps/openmw/mwgui/dialogue.hpp | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index bff952ab8c..5322cb90d6 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -360,7 +360,7 @@ void OMW::Engine::go() // Create dialog system mEnvironment.mJournal = new MWDialogue::Journal (mEnvironment); - mEnvironment.mDialogueManager = new MWDialogue::DialogueManager (mEnvironment); + mEnvironment.mDialogueManager = new MWDialogue::DialogueManager (mEnvironment,mExtensions); // load cell ESM::Position pos; diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 5bcf465990..498485b975 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -411,10 +411,11 @@ namespace MWDialogue return true; } - DialogueManager::DialogueManager (MWWorld::Environment& environment) : + DialogueManager::DialogueManager (MWWorld::Environment& environment,const Compiler::Extensions& extensions) : mEnvironment (environment),mCompilerContext (MWScript::CompilerContext::Type_Dialgoue, environment), mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream) { + mCompilerContext.setExtensions (&extensions); } void DialogueManager::addTopic(std::string topic) @@ -522,6 +523,7 @@ namespace MWDialogue bool DialogueManager::compile (const std::string& cmd,std::vector& code) { + std::cout << cmd << std::endl; try { mErrorHandler.reset(); @@ -543,7 +545,6 @@ namespace MWDialogue Compiler::ScriptParser parser(mErrorHandler,mCompilerContext, locals); scanner.scan (parser); - if(mErrorHandler.isGood()) { parser.getCode(code); @@ -606,4 +607,10 @@ namespace MWDialogue win->addText(error); } + void DialogueManager::askQuestion(std::string question, int choice) + { + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + win->askQuestion(question,choice); + std::cout << "choice"; + } } diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index 600171d331..83d4832ba0 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -44,12 +44,14 @@ namespace MWDialogue public: - DialogueManager (MWWorld::Environment& environment); + DialogueManager (MWWorld::Environment& environment,const Compiler::Extensions& extensions); void startDialogue (const MWWorld::Ptr& actor); void addTopic(std::string topic); + void askQuestion(std::string question,int choice); + //calbacks for the GUI void keywordSelected(std::string keyword); void goodbyeSelected(); diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index f336d8a38d..01466a7dc8 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -204,13 +204,13 @@ void DialogueWindow::addText(std::string text) history->addDialogText("#B29154"+parseText(text)+"#B29154"); } -void DialogueWindow::askQuestion(std::string question,std::list answers) +void DialogueWindow::askQuestion(std::string question,int choice) { - history->addDialogText(parseText(question)); - for(std::list::iterator it = answers.begin();it!=answers.end();it++) + history->addDialogText("#572D21"+question+"#B29154"+" "); + /*for(std::list::iterator it = answers.begin();it!=answers.end();it++) { history->addDialogText("#572D21"+(*it)+"#B29154"+" "); - } + }*/ } void DialogueWindow::updateOptions() diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 232721f0aa..750a1c33ee 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -45,7 +45,7 @@ namespace MWGui void addKeyword(std::string keyWord,std::string topicText); void removeKeyword(std::string keyWord); void addText(std::string text); - void askQuestion(std::string question,std::list answers); + void askQuestion(std::string question,int choice); protected: void onSelectTopic(MyGUI::List* _sender, size_t _index); From 82c6b0f92a69c36f3d84a00d734973a8fcb609a2 Mon Sep 17 00:00:00 2001 From: gugus Date: Wed, 7 Mar 2012 18:52:27 +0100 Subject: [PATCH 23/77] choice function. Do not work. --- apps/openmw/mwscript/dialogueextensions.cpp | 36 +++++++++++++++++++-- apps/openmw/mwscript/docs/vmformat.txt | 3 +- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 26fb6d9bed..09adc0060f 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -89,17 +89,48 @@ namespace MWScript } }; + class OpChoice : public Interpreter::Opcode1 + { + public: + + virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) + { + std::cout << "CHOICECHOICEHOCQSCHQSHD"; + MWScript::InterpreterContext& context + = static_cast (runtime.getContext()); + MWDialogue::DialogueManager* dialogue = context.getEnvironment().mDialogueManager; + //int choice = 1; + while(arg0>0) + { + std::string question = runtime.getStringLiteral (runtime[0].mInteger); + runtime.pop(); + arg0 = arg0 -1; + Interpreter::Type_Integer choice = 1; + if(arg0>0) + { + choice = runtime[0].mInteger; + runtime.pop(); + arg0 = arg0 -1; + } + dialogue->askQuestion(question,choice); + } + } + }; + + const int opcodeJournal = 0x2000133; const int opcodeSetJournalIndex = 0x2000134; const int opcodeGetJournalIndex = 0x2000135; const int opcodeAddTopic = 0x200013a; + const int opcodeChoice = 0x2000a; void registerExtensions (Compiler::Extensions& extensions) { extensions.registerInstruction ("journal", "cl", opcodeJournal); extensions.registerInstruction ("setjournalindex", "cl", opcodeSetJournalIndex); extensions.registerFunction ("getjournalindex", 'l', "c", opcodeGetJournalIndex); - extensions.registerInstruction ("addtopic", "S" , opcodeAddTopic); + extensions.registerInstruction ("addtopic", "S" , opcodeAddTopic); + extensions.registerInstruction ("choice", "clcl", opcodeChoice); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -107,7 +138,8 @@ namespace MWScript interpreter.installSegment5 (opcodeJournal, new OpJournal); interpreter.installSegment5 (opcodeSetJournalIndex, new OpSetJournalIndex); interpreter.installSegment5 (opcodeGetJournalIndex, new OpGetJournalIndex); - interpreter.installSegment5 (opcodeAddTopic, new OpAddTopic); + interpreter.installSegment5 (opcodeAddTopic, new OpAddTopic); + interpreter.installSegment3 (opcodeChoice,new OpChoice); } } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 5fd3fe7735..eab5bf846f 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -23,7 +23,8 @@ op 0x20006: PlayAnim op 0x20007: PlayAnim, explicit reference op 0x20008: LoopAnim op 0x20009: LoopAnim, explicit reference -opcodes 0x2000a-0x3ffff unused +op 0x2000a: Choice +opcodes 0x2000b-0x3ffff unused Segment 4: (not implemented yet) From 07d8d654cd8b9192fc69946b5d0a26dcc4e9c516 Mon Sep 17 00:00:00 2001 From: gugus Date: Wed, 14 Mar 2012 18:47:29 +0100 Subject: [PATCH 24/77] one step toward function filters and end choices. --- apps/openmw/mwdialogue/dialoguemanager.cpp | 389 +++++++++++--------- apps/openmw/mwdialogue/dialoguemanager.hpp | 6 +- apps/openmw/mwgui/dialogue.cpp | 4 +- apps/openmw/mwscript/dialogueextensions.cpp | 5 +- 4 files changed, 229 insertions(+), 175 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 498485b975..49da44477a 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -56,12 +56,12 @@ namespace { switch (comp) { - case '0': return value1==value2; - case '1': return value1!=value2; - case '2': return value1>value2; - case '3': return value1>=value2; - case '4': return value1value2; + case '3': return value1>=value2; + case '4': return value1::const_iterator iter (info.selects.begin()); + iter != info.selects.end(); ++iter) + { + ESM::DialInfo::SelectStruct select = *iter; + char type = select.selectRule[1]; + if(type == '1') + { + char comp = select.selectRule[4]; + std::string name = select.selectRule.substr (5); + std::string function = select.selectRule.substr(1,2); + std::cout << function; + + int ifunction; + std::istringstream iss(function); + iss >> ifunction; + + switch(ifunction) + { + case 4://choice + if(!selectCompare(comp,mChoice,select.i)) return false; + break; + + default: + break; + + } + } + } + return true; + } bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo::SelectStruct& select) const @@ -152,168 +184,170 @@ namespace MWDialogue { char comp = select.selectRule[4]; std::string name = select.selectRule.substr (5); + std::string function = select.selectRule.substr(1,2); + std::cout << function; // TODO types 4, 5, 6, 7, 8, 9, A, B, C //new TOTO: 5,6,9 switch (type) { - case '1': // function + case '1': // function - return false; // TODO implement functions + return false; // TODO implement functions - case '2': // global + case '2': // global - if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || - select.type==ESM::VT_Long) - { - if (!checkGlobal (comp, toLower (name), select.i, *mEnvironment.mWorld)) - return false; - } - else if (select.type==ESM::VT_Float) - { - if (!checkGlobal (comp, toLower (name), select.f, *mEnvironment.mWorld)) - return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); + if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || + select.type==ESM::VT_Long) + { + if (!checkGlobal (comp, toLower (name), select.i, *mEnvironment.mWorld)) + return false; + } + else if (select.type==ESM::VT_Float) + { + if (!checkGlobal (comp, toLower (name), select.f, *mEnvironment.mWorld)) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); - return true; + return true; - case '3': // local + case '3': // local - if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || - select.type==ESM::VT_Long) - { - if (!checkLocal (comp, toLower (name), select.i, actor, - mEnvironment.mWorld->getStore())) - return false; - } - else if (select.type==ESM::VT_Float) - { - if (!checkLocal (comp, toLower (name), select.f, actor, - mEnvironment.mWorld->getStore())) - return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); + if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || + select.type==ESM::VT_Long) + { + if (!checkLocal (comp, toLower (name), select.i, actor, + mEnvironment.mWorld->getStore())) + return false; + } + else if (select.type==ESM::VT_Float) + { + if (!checkLocal (comp, toLower (name), select.f, actor, + mEnvironment.mWorld->getStore())) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); - return true; + return true; - case '4'://journal - if(select.type==ESM::VT_Int) + case '4'://journal + if(select.type==ESM::VT_Int) + { + //std::cout << "vtint: " << select.i << std::endl; + bool isInJournal; + if(mEnvironment.mJournal->begin()!=mEnvironment.mJournal->end()) { - //std::cout << "vtint: " << select.i << std::endl; - bool isInJournal; - if(mEnvironment.mJournal->begin()!=mEnvironment.mJournal->end()) + for(std::deque::const_iterator it = mEnvironment.mJournal->begin();it!=mEnvironment.mJournal->end();it++) { - for(std::deque::const_iterator it = mEnvironment.mJournal->begin();it!=mEnvironment.mJournal->end();it++) - { - if(it->mTopic == name) isInJournal = true; - } + if(it->mTopic == name) isInJournal = true; } - else - isInJournal = false; - if(!selectCompare(comp,int(isInJournal),select.i)) return false; } else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); + isInJournal = false; + if(!selectCompare(comp,int(isInJournal),select.i)) return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); - return true; + return true; - case '7':// not ID - if(select.type==ESM::VT_String ||select.type==ESM::VT_Int)//bug in morrowind here? it's not a short, it's a string - { - int isID = int(toLower(name)==toLower(MWWorld::Class::get (actor).getId (actor))); - if (selectCompare(comp,!isID,select.i)) return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); + case '7':// not ID + if(select.type==ESM::VT_String ||select.type==ESM::VT_Int)//bug in morrowind here? it's not a short, it's a string + { + int isID = int(toLower(name)==toLower(MWWorld::Class::get (actor).getId (actor))); + if (selectCompare(comp,!isID,select.i)) return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); - return true; + return true; - case '8':// not faction - if(select.type==ESM::VT_Int) - { - ESMS::LiveCellRef* npc = actor.get(); - int isFaction = int(toLower(npc->base->faction) == toLower(name)); - if(selectCompare(comp,!isFaction,select.i)) - return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); + case '8':// not faction + if(select.type==ESM::VT_Int) + { + ESMS::LiveCellRef* npc = actor.get(); + int isFaction = int(toLower(npc->base->faction) == toLower(name)); + if(selectCompare(comp,!isFaction,select.i)) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); - return true; + return true; - case '9':// not class - if(select.type==ESM::VT_Int) - { - ESMS::LiveCellRef* npc = actor.get(); - int isClass = int(toLower(npc->base->cls) == toLower(name)); - if(selectCompare(comp,!isClass,select.i)) - return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); + case '9':// not class + if(select.type==ESM::VT_Int) + { + ESMS::LiveCellRef* npc = actor.get(); + int isClass = int(toLower(npc->base->cls) == toLower(name)); + if(selectCompare(comp,!isClass,select.i)) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); - return true; + return true; - case 'A'://not Race - if(select.type==ESM::VT_Int) - { - ESMS::LiveCellRef* npc = actor.get(); - int isRace = int(toLower(npc->base->race) == toLower(name)); - //std::cout << "isRace"<(comp,!isRace,select.i)) - return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); + case 'A'://not Race + if(select.type==ESM::VT_Int) + { + ESMS::LiveCellRef* npc = actor.get(); + int isRace = int(toLower(npc->base->race) == toLower(name)); + //std::cout << "isRace"<(comp,!isRace,select.i)) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); - return true; + return true; - case 'B'://not Cell - if(select.type==ESM::VT_Int) - { - int isCell = int(toLower(actor.getCell()->cell->name) == toLower(name)); - if(selectCompare(comp,!isCell,select.i)) - return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); - return true; + case 'B'://not Cell + if(select.type==ESM::VT_Int) + { + int isCell = int(toLower(actor.getCell()->cell->name) == toLower(name)); + if(selectCompare(comp,!isCell,select.i)) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + return true; - case 'C'://not local - if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || - select.type==ESM::VT_Long) - { - if (checkLocal (comp, toLower (name), select.i, actor, - mEnvironment.mWorld->getStore())) - return false; - } - else if (select.type==ESM::VT_Float) - { - if (checkLocal (comp, toLower (name), select.f, actor, - mEnvironment.mWorld->getStore())) - return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); - return true; + case 'C'://not local + if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || + select.type==ESM::VT_Long) + { + if (checkLocal (comp, toLower (name), select.i, actor, + mEnvironment.mWorld->getStore())) + return false; + } + else if (select.type==ESM::VT_Float) + { + if (checkLocal (comp, toLower (name), select.f, actor, + mEnvironment.mWorld->getStore())) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + return true; - default: + default: - std::cout << "unchecked select: " << type << " " << comp << " " << name << std::endl; + std::cout << "unchecked select: " << type << " " << comp << " " << name << std::endl; } } @@ -401,12 +435,12 @@ namespace MWDialogue return false; /*std::cout - << "unchecked entries:" << std::endl - << " player faction: " << info.pcFaction << std::endl - << " disposition: " << info.data.disposition << std::endl - << " NPC rank: " << static_cast (info.data.rank) << std::endl - << " gender: " << static_cast (info.data.gender) << std::endl - << " PC rank: " << static_cast (info.data.PCrank) << std::endl;*/ + << "unchecked entries:" << std::endl + << " player faction: " << info.pcFaction << std::endl + << " disposition: " << info.data.disposition << std::endl + << " NPC rank: " << static_cast (info.data.rank) << std::endl + << " gender: " << static_cast (info.data.gender) << std::endl + << " PC rank: " << static_cast (info.data.PCrank) << std::endl;*/ return true; } @@ -415,6 +449,7 @@ namespace MWDialogue mEnvironment (environment),mCompilerContext (MWScript::CompilerContext::Type_Dialgoue, environment), mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream) { + mChoice = -1; mCompilerContext.setExtensions (&extensions); } @@ -425,24 +460,27 @@ namespace MWDialogue void DialogueManager::parseText(std::string text) { - std::map::iterator it; + std::map>::iterator it; for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) { MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); size_t pos = find_str_ci(text,it->first,0); if(pos !=std::string::npos) { - if(pos==0) + if(!it->second.empty()) { - //std::cout << "fouuuuuuuuuuund"; - knownTopics[it->first] = true; - win->addKeyword(it->first,it->second.response); - } - else if(text.substr(pos -1,1) == " ") - { - //std::cout << "fouuuuuuuuuuund"; - knownTopics[it->first] = true; - win->addKeyword(it->first,it->second.response); + if(pos==0) + { + //std::cout << "fouuuuuuuuuuund"; + knownTopics[it->first] = true; + win->addKeyword(it->first,it->second.front().response); + } + else if(text.substr(pos -1,1) == " ") + { + //std::cout << "fouuuuuuuuuuund"; + knownTopics[it->first] = true; + win->addKeyword(it->first,it->second.front().response); + } } } @@ -472,14 +510,14 @@ namespace MWDialogue { if (isMatching (actor, *iter)) { - actorKnownTopics[it->first] = *iter; + actorKnownTopics[it->first].push_back(*iter); if(knownTopics.find(toLower(it->first)) != knownTopics.end()) { MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); win->addKeyword(it->first,iter->response); //std::cout << it->first; //std::cout << "match found!!"; - break; + //break; } } } @@ -585,10 +623,21 @@ namespace MWDialogue void DialogueManager::keywordSelected(std::string keyword) { - std::string text = actorKnownTopics[keyword].response; - std::string script = actorKnownTopics[keyword].resultScript; - parseText(text); - executeScript(script); + if(!actorKnownTopics[keyword].empty()) + { + for(std::list::iterator it = actorKnownTopics[keyword].begin(); it != actorKnownTopics[keyword].end();it++) + { + ESM::DialInfo dial = *it; + if(functionFilter(mActor,dial)) + { + std::string text = actorKnownTopics[keyword].front().response; + std::string script = actorKnownTopics[keyword].front().resultScript; + parseText(text); + executeScript(script); + break; + } + } + } } void DialogueManager::goodbyeSelected() @@ -598,7 +647,7 @@ namespace MWDialogue void DialogueManager::questionAnswered(std::string answere) { - std::cout << "and the ansere is..."<< answere; + std::cout << "and the ansere is..."<< answere; } void DialogueManager::printError(std::string error) diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index 83d4832ba0..85e89573ff 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -26,10 +26,12 @@ namespace MWDialogue bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const; + bool functionFilter(const MWWorld::Ptr& actor, const ESM::DialInfo& info); + void parseText(std::string text); std::map knownTopics;// Those are the topics the player knows. - std::map actorKnownTopics; + std::map> actorKnownTopics; MWScript::CompilerContext mCompilerContext; std::ostream mErrorStream; @@ -42,6 +44,8 @@ namespace MWDialogue void printError(std::string error); + int mChoice; + public: DialogueManager (MWWorld::Environment& environment,const Compiler::Extensions& extensions); diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 01466a7dc8..25653d9fcd 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -84,8 +84,8 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) //std::cout << "Clicked on key: " << key << std::endl; if(color == "#686EBA") { - mEnvironment.mDialogueManager->keywordSelected(lower_string(key)); displayTopicText(lower_string(key)); + mEnvironment.mDialogueManager->keywordSelected(lower_string(key)); } if(color == "#572D21") { @@ -117,8 +117,8 @@ void DialogueWindow::onSelectTopic(MyGUI::List* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; std::string topic = _sender->getItem(_index); - mEnvironment.mDialogueManager->keywordSelected(lower_string(topic)); displayTopicText(topic); + mEnvironment.mDialogueManager->keywordSelected(lower_string(topic)); //const std::string* theTopic = topicsList->getItemDataAt(_index); //std::cout << "Selected: "<< theTopic << std::endl; diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 09adc0060f..331cb0a341 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -95,7 +95,8 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) { - std::cout << "CHOICECHOICEHOCQSCHQSHD"; + std::cout << "CHOICE" << arg0; + arg0 = 4; MWScript::InterpreterContext& context = static_cast (runtime.getContext()); MWDialogue::DialogueManager* dialogue = context.getEnvironment().mDialogueManager; @@ -130,7 +131,7 @@ namespace MWScript extensions.registerInstruction ("setjournalindex", "cl", opcodeSetJournalIndex); extensions.registerFunction ("getjournalindex", 'l', "c", opcodeGetJournalIndex); extensions.registerInstruction ("addtopic", "S" , opcodeAddTopic); - extensions.registerInstruction ("choice", "clcl", opcodeChoice); + extensions.registerInstruction ("choice", "/SlSl", opcodeChoice); } void installOpcodes (Interpreter::Interpreter& interpreter) From 56a84b6a1a1a416388084d3049572f51ce0dc344 Mon Sep 17 00:00:00 2001 From: gugus Date: Fri, 16 Mar 2012 17:30:59 +0100 Subject: [PATCH 25/77] choices works. The only thing remaining is the script arguments problems. Need a lot of clean up too. --- apps/openmw/mwdialogue/dialoguemanager.cpp | 120 +++++++++++++++++---- apps/openmw/mwdialogue/dialoguemanager.hpp | 6 +- apps/openmw/mwgui/dialogue.cpp | 11 +- apps/openmw/mwgui/dialogue.hpp | 3 +- 4 files changed, 115 insertions(+), 25 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 49da44477a..cba71f096c 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -142,8 +142,10 @@ namespace MWDialogue return toLower(str).find(toLower(substr),pos); } - bool DialogueManager::functionFilter(const MWWorld::Ptr& actor, const ESM::DialInfo& info) + bool DialogueManager::functionFilter(const MWWorld::Ptr& actor, const ESM::DialInfo& info,bool choice) { + bool isAChoice = false;//is there any choice in the filters? + bool isFunction = false; for (std::vector::const_iterator iter (info.selects.begin()); iter != info.selects.end(); ++iter) { @@ -151,19 +153,24 @@ namespace MWDialogue char type = select.selectRule[1]; if(type == '1') { + isFunction = true; char comp = select.selectRule[4]; std::string name = select.selectRule.substr (5); - std::string function = select.selectRule.substr(1,2); - std::cout << function; + std::string function = select.selectRule.substr(2,2); + std::cout << "f " <> ifunction; - switch(ifunction) { - case 4://choice - if(!selectCompare(comp,mChoice,select.i)) return false; + case 50://choice + std::cout << "choice"; + isAChoice = true; + if(choice) + { + if(!selectCompare(comp,mChoice,select.i)){std::cout << "pbhere"; return false;} + } break; default: @@ -172,6 +179,19 @@ namespace MWDialogue } } } + if(isAChoice) + { + std::cout << "CHOICEEE!"; + return true; + } + /*if(!choice && !isAChoice) + { + return false; + }*/ + if(isFunction) + { + return false; + } return true; } @@ -185,7 +205,7 @@ namespace MWDialogue char comp = select.selectRule[4]; std::string name = select.selectRule.substr (5); std::string function = select.selectRule.substr(1,2); - std::cout << function; + //std::cout << function; // TODO types 4, 5, 6, 7, 8, 9, A, B, C //new TOTO: 5,6,9 @@ -193,7 +213,7 @@ namespace MWDialogue { case '1': // function - return false; // TODO implement functions + return true; // TODO implement functions case '2': // global @@ -450,6 +470,7 @@ namespace MWDialogue mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream) { mChoice = -1; + mIsInChoice = false; mCompilerContext.setExtensions (&extensions); } @@ -508,8 +529,15 @@ namespace MWDialogue for (std::vector::const_iterator iter (it->second.mInfo.begin()); iter!=it->second.mInfo.end(); ++iter) { - if (isMatching (actor, *iter)) + if(it->first == "anneau") + { + std::cout << iter->response << std::endl; + } + //std::cout << "a"; + if (isMatching (actor, *iter) && functionFilter(mActor,*iter,false)) { + std::cout << "OK"; + //std::cout << it->first; actorKnownTopics[it->first].push_back(*iter); if(knownTopics.find(toLower(it->first)) != knownTopics.end()) { @@ -521,10 +549,12 @@ namespace MWDialogue } } } + //std::cout << "b"; } } //ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + //greeting bool greetingFound = false; for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { @@ -535,7 +565,7 @@ namespace MWDialogue for (std::vector::const_iterator iter (it->second.mInfo.begin()); iter!=it->second.mInfo.end(); ++iter) { - if (isMatching (actor, *iter)) + if (isMatching (actor, *iter) && functionFilter(mActor,*iter,false)) { if (!iter->sound.empty()) { @@ -552,6 +582,8 @@ namespace MWDialogue win->addText(iter->response); executeScript(iter->resultScript); greetingFound = true; + mLastTopic = it->first; + mLastDialogue = *iter; break; } } @@ -623,18 +655,30 @@ namespace MWDialogue void DialogueManager::keywordSelected(std::string keyword) { - if(!actorKnownTopics[keyword].empty()) + if(!mIsInChoice) { - for(std::list::iterator it = actorKnownTopics[keyword].begin(); it != actorKnownTopics[keyword].end();it++) + if(!actorKnownTopics[keyword].empty()) { - ESM::DialInfo dial = *it; - if(functionFilter(mActor,dial)) + for(std::list::iterator it = actorKnownTopics[keyword].begin(); it != actorKnownTopics[keyword].end();it++) { - std::string text = actorKnownTopics[keyword].front().response; - std::string script = actorKnownTopics[keyword].front().resultScript; - parseText(text); - executeScript(script); - break; + ESM::DialInfo dial = *it; + if(functionFilter(mActor,dial,true)) + { + std::string text = it->response; + std::string script = it->resultScript; + + parseText(text); + + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + win->addTitle(keyword); + win->addText(it->response); + + executeScript(script); + + mLastTopic = keyword; + mLastDialogue = dial; + break; + } } } } @@ -647,6 +691,40 @@ namespace MWDialogue void DialogueManager::questionAnswered(std::string answere) { + if(mChoiceMap.find(answere) != mChoiceMap.end()) + { + mChoice = mChoiceMap[answere]; + std::cout << "found1"; + std::list dials = actorKnownTopics[mLastTopic]; + + //bool passedLastDialogue = false; + std::cout << actorKnownTopics[mLastTopic].size() << mLastTopic; + std::list::iterator iter; + for(iter = actorKnownTopics[mLastTopic].begin(); iter->id != mLastDialogue.id;iter++) + { + } + //iter--; + for(std::list::iterator it = iter; it!=actorKnownTopics[mLastTopic].begin();) + { + it--; + std::cout << "parsing\n"; + if(functionFilter(mActor,*it,true)) + { + mChoiceMap.clear(); + mChoice = -1; + mIsInChoice = false; + std::cout << "2"; + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + std::string text = it->response; + parseText(text); + win->addText(text); + executeScript(it->resultScript); + mLastTopic = mLastTopic; + mLastDialogue = *it; + break; + } + } + } std::cout << "and the ansere is..."<< answere; } @@ -659,7 +737,9 @@ namespace MWDialogue void DialogueManager::askQuestion(std::string question, int choice) { MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); - win->askQuestion(question,choice); + win->askQuestion(question); + mChoiceMap[question] = choice; + mIsInChoice = true; std::cout << "choice"; } } diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index 85e89573ff..f32305b46e 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -26,7 +26,7 @@ namespace MWDialogue bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const; - bool functionFilter(const MWWorld::Ptr& actor, const ESM::DialInfo& info); + bool functionFilter(const MWWorld::Ptr& actor, const ESM::DialInfo& info,bool choice); void parseText(std::string text); @@ -45,6 +45,10 @@ namespace MWDialogue void printError(std::string error); int mChoice; + std::map mChoiceMap; + std::string mLastTopic; + ESM::DialInfo mLastDialogue; + bool mIsInChoice; public: diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 25653d9fcd..a68596a39d 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -84,7 +84,7 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) //std::cout << "Clicked on key: " << key << std::endl; if(color == "#686EBA") { - displayTopicText(lower_string(key)); + //displayTopicText(lower_string(key)); mEnvironment.mDialogueManager->keywordSelected(lower_string(key)); } if(color == "#572D21") @@ -117,7 +117,7 @@ void DialogueWindow::onSelectTopic(MyGUI::List* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; std::string topic = _sender->getItem(_index); - displayTopicText(topic); + //displayTopicText(topic); mEnvironment.mDialogueManager->keywordSelected(lower_string(topic)); //const std::string* theTopic = topicsList->getItemDataAt(_index); @@ -204,7 +204,12 @@ void DialogueWindow::addText(std::string text) history->addDialogText("#B29154"+parseText(text)+"#B29154"); } -void DialogueWindow::askQuestion(std::string question,int choice) +void DialogueWindow::addTitle(std::string text) +{ + history->addDialogHeading(text); +} + +void DialogueWindow::askQuestion(std::string question) { history->addDialogText("#572D21"+question+"#B29154"+" "); /*for(std::list::iterator it = answers.begin();it!=answers.end();it++) diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 750a1c33ee..a2d82b64b0 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -45,7 +45,8 @@ namespace MWGui void addKeyword(std::string keyWord,std::string topicText); void removeKeyword(std::string keyWord); void addText(std::string text); - void askQuestion(std::string question,int choice); + void addTitle(std::string text); + void askQuestion(std::string question); protected: void onSelectTopic(MyGUI::List* _sender, size_t _index); From 91801e5cab3098040f4d6ce616543d8b790d0131 Mon Sep 17 00:00:00 2001 From: gugus Date: Fri, 16 Mar 2012 17:39:14 +0100 Subject: [PATCH 26/77] stop spamming messages --- apps/openmw/mwdialogue/dialoguemanager.cpp | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index cba71f096c..525e072c65 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -157,7 +157,6 @@ namespace MWDialogue char comp = select.selectRule[4]; std::string name = select.selectRule.substr (5); std::string function = select.selectRule.substr(2,2); - std::cout << "f " <::const_iterator iter (it->second.mInfo.begin()); iter!=it->second.mInfo.end(); ++iter) { - if(it->first == "anneau") - { - std::cout << iter->response << std::endl; - } - //std::cout << "a"; if (isMatching (actor, *iter) && functionFilter(mActor,*iter,false)) { - std::cout << "OK"; - //std::cout << it->first; actorKnownTopics[it->first].push_back(*iter); if(knownTopics.find(toLower(it->first)) != knownTopics.end()) { MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); win->addKeyword(it->first,iter->response); - //std::cout << it->first; - //std::cout << "match found!!"; - //break; } } } - //std::cout << "b"; } } //ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; @@ -694,7 +680,6 @@ namespace MWDialogue if(mChoiceMap.find(answere) != mChoiceMap.end()) { mChoice = mChoiceMap[answere]; - std::cout << "found1"; std::list dials = actorKnownTopics[mLastTopic]; //bool passedLastDialogue = false; @@ -707,13 +692,11 @@ namespace MWDialogue for(std::list::iterator it = iter; it!=actorKnownTopics[mLastTopic].begin();) { it--; - std::cout << "parsing\n"; if(functionFilter(mActor,*it,true)) { mChoiceMap.clear(); mChoice = -1; mIsInChoice = false; - std::cout << "2"; MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); std::string text = it->response; parseText(text); @@ -725,7 +708,6 @@ namespace MWDialogue } } } - std::cout << "and the ansere is..."<< answere; } void DialogueManager::printError(std::string error) @@ -740,6 +722,5 @@ namespace MWDialogue win->askQuestion(question); mChoiceMap[question] = choice; mIsInChoice = true; - std::cout << "choice"; } } From 042d87f77f9e947c7aa5f150662a809440e37a79 Mon Sep 17 00:00:00 2001 From: gugus Date: Fri, 16 Mar 2012 17:53:34 +0100 Subject: [PATCH 27/77] a lot of clean up --- apps/openmw/mwdialogue/dialoguemanager.cpp | 24 ++---- apps/openmw/mwgui/dialogue.cpp | 83 +-------------------- apps/openmw/mwgui/dialogue.hpp | 3 +- apps/openmw/mwscript/dialogueextensions.cpp | 2 - 4 files changed, 10 insertions(+), 102 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 525e072c65..eb78e9e9de 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -181,10 +181,6 @@ namespace MWDialogue { return true; } - /*if(!choice && !isAChoice) - { - return false; - }*/ if(isFunction) { return false; @@ -202,7 +198,6 @@ namespace MWDialogue char comp = select.selectRule[4]; std::string name = select.selectRule.substr (5); std::string function = select.selectRule.substr(1,2); - //std::cout << function; // TODO types 4, 5, 6, 7, 8, 9, A, B, C //new TOTO: 5,6,9 @@ -373,7 +368,6 @@ namespace MWDialogue bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const { - //bool return true;//does the actor knows the topic? // actor id if (!info.actor.empty()) if (toLower (info.actor)!=MWWorld::Class::get (actor).getId (actor)) @@ -489,15 +483,13 @@ namespace MWDialogue { if(pos==0) { - //std::cout << "fouuuuuuuuuuund"; knownTopics[it->first] = true; - win->addKeyword(it->first,it->second.front().response); + win->addKeyword(it->first); } else if(text.substr(pos -1,1) == " ") { - //std::cout << "fouuuuuuuuuuund"; 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(); 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(); ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) @@ -529,16 +522,16 @@ namespace MWDialogue if (isMatching (actor, *iter) && functionFilter(mActor,*iter,false)) { actorKnownTopics[it->first].push_back(*iter); + //does the player know the topic? if(knownTopics.find(toLower(it->first)) != knownTopics.end()) { MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); - win->addKeyword(it->first,iter->response); + win->addKeyword(it->first); } } } } } - //ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; //greeting bool greetingFound = false; @@ -558,11 +551,6 @@ namespace MWDialogue // TODO play sound } - if (!iter->resultScript.empty()) - { - //std::cout << "script: " << iter->resultScript << std::endl; - // TODO execute script - } std::string text = iter->response; parseText(text); win->addText(iter->response); @@ -682,13 +670,11 @@ namespace MWDialogue mChoice = mChoiceMap[answere]; std::list dials = actorKnownTopics[mLastTopic]; - //bool passedLastDialogue = false; std::cout << actorKnownTopics[mLastTopic].size() << mLastTopic; std::list::iterator iter; for(iter = actorKnownTopics[mLastTopic].begin(); iter->id != mLastDialogue.id;iter++) { } - //iter--; for(std::list::iterator it = iter; it!=actorKnownTopics[mLastTopic].begin();) { it--; diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index a68596a39d..88b44c9c41 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -80,25 +80,14 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) if(color != "#B29154") { UString key = history->getColorTextAt(cursorPosition); + if(color == "#686EBA") mEnvironment.mDialogueManager->keywordSelected(lower_string(key)); - //std::cout << "Clicked on key: " << key << std::endl; - 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; - } + if(color == "#572D21") mEnvironment.mDialogueManager->questionAnswered(key); } } void DialogueWindow::open() { - //updateOptions(); topicsList->removeAllItems(); pTopicsText.clear(); history->eraseText(0,history->getTextLength()); @@ -108,7 +97,6 @@ void DialogueWindow::open() void DialogueWindow::onByeClicked(MyGUI::Widget* _sender) { - //eventBye(); mEnvironment.mDialogueManager->goodbyeSelected(); } @@ -117,12 +105,7 @@ void DialogueWindow::onSelectTopic(MyGUI::List* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; std::string topic = _sender->getItem(_index); - //displayTopicText(topic); mEnvironment.mDialogueManager->keywordSelected(lower_string(topic)); - - //const std::string* theTopic = topicsList->getItemDataAt(_index); - //std::cout << "Selected: "<< theTopic << std::endl; - //eventTopicSelected(key); } void DialogueWindow::startDialogue(std::string npcName) @@ -130,12 +113,12 @@ void DialogueWindow::startDialogue(std::string 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) { 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); pos+= color2.length(); } - //str.replace(pos, oldStr.length(), "#686EBA"+str.get); } } std::string DialogueWindow::parseText(std::string text) { - //topicsList->geti for(int i = 0;igetItemCount();i++) { std::string keyWord = topicsList->getItem(i); - //std::string newKeyWord = "#686EBA"+keyWord+"#B29154"; addColorInString(text,keyWord,"#686EBA","#B29154"); } 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) { history->addDialogText("#B29154"+parseText(text)+"#B29154"); @@ -212,60 +179,18 @@ void DialogueWindow::addTitle(std::string text) void DialogueWindow::askQuestion(std::string question) { history->addDialogText("#572D21"+question+"#B29154"+" "); - /*for(std::list::iterator it = answers.begin();it!=answers.end();it++) - { - history->addDialogText("#572D21"+(*it)+"#B29154"+" "); - }*/ } 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 topicsList->removeAllItems(); pTopicsText.clear(); history->eraseText(0,history->getTextLength()); - /*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 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++);*/ } diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index a2d82b64b0..4520d4586e 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -42,7 +42,7 @@ namespace MWGui void startDialogue(std::string npcName); void stopDialogue(); - void addKeyword(std::string keyWord,std::string topicText); + void addKeyword(std::string keyWord); void removeKeyword(std::string keyWord); void addText(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. */ std::string parseText(std::string text); - void displayTopicText(std::string topic); DialogeHistory* history; MyGUI::ListPtr topicsList; diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 331cb0a341..78a52a1850 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -95,12 +95,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) { - std::cout << "CHOICE" << arg0; arg0 = 4; MWScript::InterpreterContext& context = static_cast (runtime.getContext()); MWDialogue::DialogueManager* dialogue = context.getEnvironment().mDialogueManager; - //int choice = 1; while(arg0>0) { std::string question = runtime.getStringLiteral (runtime[0].mInteger); From 5b08baf5bfa311e9fb91e52309f83a9261fb6dca Mon Sep 17 00:00:00 2001 From: gugus Date: Fri, 16 Mar 2012 18:20:02 +0100 Subject: [PATCH 28/77] a little fix for CMake to be able not to build the launcher --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6dbd27a68c..8362bfca36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -448,7 +448,9 @@ if (WIN32) endforeach(d) set_target_properties(components PROPERTIES COMPILE_FLAGS ${WARNINGS}) - set_target_properties(omwlauncher PROPERTIES COMPILE_FLAGS ${WARNINGS}) + if (BUILD_LAUNCHER) + set_target_properties(omwlauncher PROPERTIES COMPILE_FLAGS ${WARNINGS}) + endif (BUILD_LAUNCHER) set_target_properties(openmw PROPERTIES COMPILE_FLAGS ${WARNINGS}) endif(MSVC) From a67cc8e73be69271c474543c86d8dd4fabd6a15f Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 16 Mar 2012 19:02:33 +0100 Subject: [PATCH 29/77] more fixes --- apps/openmw/mwrender/renderingmanager.cpp | 2 +- apps/openmw/mwrender/sky.cpp | 21 +++++++++++---------- apps/openmw/mwrender/sky.hpp | 5 ++--- apps/openmw/mwworld/world.cpp | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 95eb8dd333..4f84d90a95 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -51,7 +51,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const cameraPitchNode->attachObject(mRendering.getCamera()); //mSkyManager = 0; - mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera()); + mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera(), &environment); mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode); mSun = 0; diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index e09fa8a422..343afc13c9 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -10,11 +10,14 @@ #include +#include "../mwworld/environment.hpp" +#include "../mwworld/world.hpp" + using namespace MWRender; using namespace Ogre; // the speed at which the clouds are animated -#define CLOUD_SPEED 0.001 +#define CLOUD_SPEED 0.003 // this distance has to be set accordingly so that the // celestial bodies are behind the clouds, but in front of the atmosphere @@ -296,9 +299,10 @@ void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType) ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource())->unlock(); } -SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) : +SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera, MWWorld::Environment* env) : mGlareFade(0), mGlareEnabled(false) { + mEnvironment = env; mViewport = pCamera->getViewport(); mSceneMgr = pMwRoot->getCreator(); mRootNode = pCamera->getParentSceneNode()->createChildSceneNode(); @@ -312,7 +316,7 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) : Pass* pass = material->getTechnique(0)->getPass(0); pass->setSceneBlending(SBT_TRANSPARENT_ALPHA); mThunderTextureUnit = pass->createTextureUnitState(); - mThunderTextureUnit->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, ColourValue(1.f, 1.f, 1.f)); // always black colour + mThunderTextureUnit->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, ColourValue(1.f, 1.f, 1.f)); mThunderTextureUnit->setAlphaOperation(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, 0.5f); OverlayManager& ovm = OverlayManager::getSingleton(); mThunderOverlay = ovm.create( "ThunderOverlay" ); @@ -504,7 +508,7 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) : " uniform float4 emissive \n" ") \n" "{ \n" - " uv += float2(1,1) * time * speed * "<getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstantFromTime("time", 1); + mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstantFromTime("time", mEnvironment->mWorld->getTimeScaleFactor()/30.f); /// \todo improve this mMasser->setPhase( static_cast( (int) ((mDay % 32)/4.f)) ); @@ -594,8 +598,8 @@ void SkyManager::update(float duration) mMasser->setVisible(mMasserEnabled); mSecunda->setVisible(mSecundaEnabled); - // rotate the whole sky by 360 degrees every 4 days - mRootNode->roll(Degree(mHourDiff*360/96.f)); + // rotate the stars by 360 degrees every 4 days + mAtmosphereNight->roll(Degree(mEnvironment->mWorld->getTimeScaleFactor()*duration*360 / (3600*96.f))); } void SkyManager::enable() @@ -775,9 +779,6 @@ void SkyManager::setSecundaFade(const float fade) void SkyManager::setHour(double hour) { - mHourDiff = mHour - hour; - if (mHourDiff > 0) mHourDiff -= 24; - mHour = hour; } diff --git a/apps/openmw/mwrender/sky.hpp b/apps/openmw/mwrender/sky.hpp index 2c7b7379a5..bf52afd8dd 100644 --- a/apps/openmw/mwrender/sky.hpp +++ b/apps/openmw/mwrender/sky.hpp @@ -107,7 +107,7 @@ namespace MWRender class SkyManager { public: - SkyManager(Ogre::SceneNode* pMwRoot, Ogre::Camera* pCamera); + SkyManager(Ogre::SceneNode* pMwRoot, Ogre::Camera* pCamera, MWWorld::Environment* env); ~SkyManager(); void update(float duration); @@ -164,12 +164,11 @@ namespace MWRender Ogre::Vector3 getRealSunPos(); private: + MWWorld::Environment* mEnvironment; float mHour; int mDay; int mMonth; - float mHourDiff; - BillboardObject* mSun; BillboardObject* mSunGlare; Moon* mMasser; diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 1c47e3c710..a636ce2887 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -478,7 +478,7 @@ namespace MWWorld float World::getTimeScaleFactor() const { - return mGlobalVariables->getInt ("timescale"); + return mGlobalVariables->getFloat ("timescale"); } void World::changeToInteriorCell (const std::string& cellName, const ESM::Position& position) From 460b584934fb675d667d04aaa3184289385d3cad Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 16 Mar 2012 19:49:01 +0100 Subject: [PATCH 30/77] transition tweaks --- apps/openmw/mwworld/weather.cpp | 148 +++++++++++++++----------------- apps/openmw/mwworld/weather.hpp | 16 ++-- 2 files changed, 77 insertions(+), 87 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index eab1197c5e..09d30ee8bb 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -22,6 +22,14 @@ const std::string WeatherGlobals::mThunderSoundID1 = "Thunder1"; const std::string WeatherGlobals::mThunderSoundID2 = "Thunder2"; const std::string WeatherGlobals::mThunderSoundID3 = "Thunder3"; +const float WeatherGlobals::mWeatherUpdateTime = 20.f; + +// morrowind sets these per-weather, but since they are only used by 'thunderstorm' +// weather setting anyway, we can just as well set them globally +const float WeatherGlobals::mThunderFrequency = .4; +const float WeatherGlobals::mThunderThreshold = 0.6; +const float WeatherGlobals::mThunderSoundDelay = 0.25; + WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environment* env) : mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0), mThunderFlash(0), mThunderChance(0), mThunderChanceNeeded(50), mThunderSoundDelay(0) @@ -344,7 +352,7 @@ WeatherResult WeatherManager::getResult(const String& weather) { const Weather& current = mWeatherSettings[weather]; WeatherResult result; - + result.mCloudTexture = current.mCloudTexture; result.mCloudBlendFactor = 0; result.mCloudOpacity = current.mCloudsMaximumPercent; @@ -353,16 +361,13 @@ WeatherResult WeatherManager::getResult(const String& weather) result.mGlareView = current.mGlareView; result.mAmbientLoopSoundID = current.mAmbientLoopSoundID; result.mSunColor = current.mSunDiscSunsetColor; - - const float fade_duration = current.mTransitionDelta * 24.f; - - result.mNight = (mHour < 6.f+fade_duration || mHour > 20.f-fade_duration); - + + result.mNight = (mHour < 6 || mHour > 19); + result.mFogDepth = result.mNight ? current.mLandFogNightDepth : current.mLandFogDayDepth; - + // night - if (mHour <= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) - || mHour >= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration)) + if (mHour <= 5.5f || mHour >= 21) { result.mFogColor = current.mFogNightColor; result.mAmbientColor = current.mAmbientNightColor; @@ -370,82 +375,68 @@ WeatherResult WeatherManager::getResult(const String& weather) result.mSkyColor = current.mSkyNightColor; result.mNightFade = 1.f; } - + // sunrise - else if (mHour >= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) && mHour <= WeatherGlobals::mSunriseTime) + else if (mHour >= 5.5f && mHour <= 8) { - if (mHour <= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration+fade_duration)) + if (mHour <= 6) { // fade in - float advance = (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration+fade_duration)-mHour; - float factor = (advance / fade_duration); + float advance = 6-mHour; + float factor = advance / 0.5f; result.mFogColor = lerp(current.mFogSunriseColor, current.mFogNightColor); result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientNightColor); result.mSunColor = lerp(current.mSunSunriseColor, current.mSunNightColor); result.mSkyColor = lerp(current.mSkySunriseColor, current.mSkyNightColor); result.mNightFade = factor; } - else if (mHour >= (WeatherGlobals::mSunriseTime-fade_duration)) + else //if (mHour >= 6) { // fade out - float advance = mHour-(WeatherGlobals::mSunriseTime-fade_duration); - float factor = advance / fade_duration; + float advance = mHour-9; + float factor = advance / 3.f; result.mFogColor = lerp(current.mFogSunriseColor, current.mFogDayColor); result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientDayColor); result.mSunColor = lerp(current.mSunSunriseColor, current.mSunDayColor); result.mSkyColor = lerp(current.mSkySunriseColor, current.mSkyDayColor); } - else - { - result.mFogColor = current.mFogSunriseColor; - result.mAmbientColor = current.mAmbientSunriseColor; - result.mSunColor = current.mSunSunriseColor; - result.mSkyColor = current.mSkySunriseColor; - } } - + // day - else if (mHour >= (WeatherGlobals::mSunriseTime) && mHour <= (WeatherGlobals::mSunsetTime)) + else if (mHour >= 8 && mHour <= 17) { result.mFogColor = current.mFogDayColor; result.mAmbientColor = current.mAmbientDayColor; result.mSunColor = current.mSunDayColor; result.mSkyColor = current.mSkyDayColor; } - + // sunset - else if (mHour >= (WeatherGlobals::mSunsetTime) && mHour <= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration)) + else if (mHour >= 17 && mHour <= 21) { - if (mHour <= (WeatherGlobals::mSunsetTime+fade_duration)) + if (mHour <= 19) { // fade in - float advance = (WeatherGlobals::mSunsetTime+fade_duration)-mHour; - float factor = (advance / fade_duration); + float advance = 19-mHour; + float factor = (advance / 2); result.mFogColor = lerp(current.mFogSunsetColor, current.mFogDayColor); result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientDayColor); result.mSunColor = lerp(current.mSunSunsetColor, current.mSunDayColor); result.mSkyColor = lerp(current.mSkySunsetColor, current.mSkyDayColor); } - else if (mHour >= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration-fade_duration)) + else //if (mHour >= 19) { // fade out - float advance = mHour-(WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration-fade_duration); - float factor = advance / fade_duration; + float advance = mHour-19; + float factor = advance / 2.f; result.mFogColor = lerp(current.mFogSunsetColor, current.mFogNightColor); result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientNightColor); result.mSunColor = lerp(current.mSunSunsetColor, current.mSunNightColor); result.mSkyColor = lerp(current.mSkySunsetColor, current.mSkyNightColor); result.mNightFade = factor; } - else - { - result.mFogColor = current.mFogSunsetColor; - result.mAmbientColor = current.mAmbientSunsetColor; - result.mSunColor = current.mSunSunsetColor; - result.mSkyColor = current.mSkySunsetColor; - } } - + return result; } @@ -454,16 +445,16 @@ WeatherResult WeatherManager::transition(float factor) const WeatherResult& current = getResult(mCurrentWeather); const WeatherResult& other = getResult(mNextWeather); WeatherResult result; - + result.mCloudTexture = current.mCloudTexture; result.mNextCloudTexture = other.mCloudTexture; result.mCloudBlendFactor = factor; - + result.mCloudOpacity = lerp(current.mCloudOpacity, other.mCloudOpacity); result.mFogColor = lerp(current.mFogColor, other.mFogColor); result.mSunColor = lerp(current.mSunColor, other.mSunColor); result.mSkyColor = lerp(current.mSkyColor, other.mSkyColor); - + result.mAmbientColor = lerp(current.mAmbientColor, other.mAmbientColor); result.mSunDiscColor = lerp(current.mSunDiscColor, other.mSunDiscColor); result.mFogDepth = lerp(current.mFogDepth, other.mFogDepth); @@ -471,9 +462,9 @@ WeatherResult WeatherManager::transition(float factor) result.mCloudSpeed = lerp(current.mCloudSpeed, other.mCloudSpeed); result.mCloudOpacity = lerp(current.mCloudOpacity, other.mCloudOpacity); result.mGlareView = lerp(current.mGlareView, other.mGlareView); - + result.mNight = current.mNight; - + // sound change behaviour: // if 'other' has a new sound, switch to it after 1/2 of the transition length if (other.mAmbientLoopSoundID != "") @@ -481,7 +472,7 @@ WeatherResult WeatherManager::transition(float factor) // if 'current' has a sound and 'other' does not have a sound, turn off the sound immediately else if (current.mAmbientLoopSoundID != "") result.mAmbientLoopSoundID = ""; - + return result; } @@ -490,7 +481,7 @@ void WeatherManager::update(float duration) mWeatherUpdateTime -= duration; bool exterior = (mEnvironment->mWorld->isCellExterior() || mEnvironment->mWorld->isCellQuasiExterior()); - + if (exterior) { std::string regionstr = mEnvironment->mWorld->getPlayer().getPlayer().getCell()->cell->region; @@ -500,16 +491,16 @@ void WeatherManager::update(float duration) { mCurrentRegion = regionstr; mWeatherUpdateTime = WeatherGlobals::mWeatherUpdateTime*60.f; - + std::string weather; - + if (mRegionOverrides.find(regionstr) != mRegionOverrides.end()) weather = mRegionOverrides[regionstr]; else { // get weather probabilities for the current region const ESM::Region *region = mEnvironment->mWorld->getStore().regions.find (regionstr); - + float clear = region->data.clear/255.f; float cloudy = region->data.cloudy/255.f; float foggy = region->data.foggy/255.f; @@ -520,13 +511,13 @@ void WeatherManager::update(float duration) float blight = region->data.blight/255.f; float snow = region->data.a/255.f; float blizzard = region->data.b/255.f; - + // re-scale to 100 percent const float total = clear+cloudy+foggy+overcast+rain+thunder+ash+blight+snow+blizzard; - + srand(time(NULL)); float random = ((rand()%100)/100.f) * total; - + if (random >= snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear) weather = "blizzard"; else if (random >= blight+ash+thunder+rain+overcast+foggy+cloudy+clear) @@ -548,7 +539,7 @@ void WeatherManager::update(float duration) else weather = "clear"; } - + setWeather(weather, false); /* std::cout << "roll result: " << random << std::endl; @@ -560,9 +551,9 @@ void WeatherManager::update(float duration) std::cout << "New weather : " << weather << std::endl; */ } - + WeatherResult result; - + if (mNextWeather != "") { mRemainingTransitionTime -= duration; @@ -572,17 +563,16 @@ void WeatherManager::update(float duration) mNextWeather = ""; } } - + if (mNextWeather != "") result = transition(1-(mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60))); else result = getResult(mCurrentWeather); mRendering->configureFog(result.mFogDepth, result.mFogColor); - + // disable sun during night - if (mHour >= WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration - || mHour <= WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) + if (mHour >= 21 || mHour <= 5.5f) mRendering->getSkyManager()->sunDisable(); else { @@ -597,7 +587,7 @@ void WeatherManager::update(float duration) mRendering->getSkyManager()->sunEnable(); } - + // moon calculations float night; if (mHour >= 14) @@ -606,9 +596,9 @@ void WeatherManager::update(float duration) night = mHour+10; else night = 0; - + night /= 20.f; - + if (night != 0) { float moonHeight = 1-std::abs((night-0.5)*2); @@ -617,17 +607,17 @@ void WeatherManager::update(float duration) (1-moonHeight)*facing, (1-moonHeight)*facing, moonHeight); - + Vector3 secunda( (1-moonHeight)*facing*0.8, (1-moonHeight)*facing*1.25, moonHeight); - + mRendering->getSkyManager()->setMasserDirection(masser); mRendering->getSkyManager()->setSecundaDirection(secunda); mRendering->getSkyManager()->masserEnable(); mRendering->getSkyManager()->secundaEnable(); - + float hour_fade; if (mHour >= 7.f && mHour <= 14.f) hour_fade = 1-(mHour-7)/3.f; @@ -635,28 +625,28 @@ void WeatherManager::update(float duration) hour_fade = mHour-14; else hour_fade = 1; - + float secunda_angle_fade; float masser_angle_fade; float angle = moonHeight*90.f; - + if (angle >= 30 && angle <= 50) secunda_angle_fade = (angle-30)/20.f; else if (angle <30) secunda_angle_fade = 0.f; else secunda_angle_fade = 1.f; - + if (angle >= 40 && angle <= 50) masser_angle_fade = (angle-40)/10.f; else if (angle <40) masser_angle_fade = 0.f; else masser_angle_fade = 1.f; - + masser_angle_fade *= hour_fade; secunda_angle_fade *= hour_fade; - + mRendering->getSkyManager()->setMasserFade(masser_angle_fade); mRendering->getSkyManager()->setSecundaFade(secunda_angle_fade); } @@ -665,7 +655,7 @@ void WeatherManager::update(float duration) mRendering->getSkyManager()->masserDisable(); mRendering->getSkyManager()->secundaDisable(); } - + if (mCurrentWeather == "thunderstorm" && mNextWeather == "" && exterior) { if (mThunderFlash > 0) @@ -684,7 +674,7 @@ void WeatherManager::update(float duration) mEnvironment->mSoundManager->playSound(soundname, 1.0, 1.0); mThunderSoundDelay = 1000; } - + mThunderFlash -= duration; if (mThunderFlash > 0) mRendering->getSkyManager()->setThunder( mThunderFlash / WeatherGlobals::mThunderThreshold ); @@ -703,20 +693,20 @@ void WeatherManager::update(float duration) if (mThunderChance >= mThunderChanceNeeded) { mThunderFlash = WeatherGlobals::mThunderThreshold; - + mRendering->getSkyManager()->setThunder( mThunderFlash / WeatherGlobals::mThunderThreshold ); - + mThunderSoundDelay = WeatherGlobals::mThunderSoundDelay; } } } else mRendering->getSkyManager()->setThunder(0.f); - + mRendering->setAmbientColour(result.mAmbientColor); mRendering->sunEnable(); mRendering->setSunColour(result.mSunColor); - + mRendering->getSkyManager()->setWeather(result); } else diff --git a/apps/openmw/mwworld/weather.hpp b/apps/openmw/mwworld/weather.hpp index 1828a90c94..b9b40e6fad 100644 --- a/apps/openmw/mwworld/weather.hpp +++ b/apps/openmw/mwworld/weather.hpp @@ -95,18 +95,18 @@ namespace MWWorld Script Color=255,20,20 */ - static const float mSunriseTime = 8; - static const float mSunsetTime = 18; - static const float mSunriseDuration = 2; - static const float mSunsetDuration = 2; + static const float mSunriseTime; + static const float mSunsetTime; + static const float mSunriseDuration; + static const float mSunsetDuration; - static const float mWeatherUpdateTime = 20.f; + static const float mWeatherUpdateTime; // morrowind sets these per-weather, but since they are only used by 'thunderstorm' // weather setting anyway, we can just as well set them globally - static const float mThunderFrequency = .4; - static const float mThunderThreshold = 0.6; - static const float mThunderSoundDelay = 0.25; + static const float mThunderFrequency; + static const float mThunderThreshold; + static const float mThunderSoundDelay; static const std::string mThunderSoundID0; static const std::string mThunderSoundID1; static const std::string mThunderSoundID2; From d18b3271b126f92bb3e49ab8041110d1b845ae57 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 16 Mar 2012 20:32:41 +0100 Subject: [PATCH 31/77] transition tweak 2 --- apps/openmw/mwworld/weather.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 09d30ee8bb..5ec9fbbcb1 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -377,7 +377,7 @@ WeatherResult WeatherManager::getResult(const String& weather) } // sunrise - else if (mHour >= 5.5f && mHour <= 8) + else if (mHour >= 5.5f && mHour <= 9) { if (mHour <= 6) { @@ -393,7 +393,7 @@ WeatherResult WeatherManager::getResult(const String& weather) else //if (mHour >= 6) { // fade out - float advance = mHour-9; + float advance = mHour-6; float factor = advance / 3.f; result.mFogColor = lerp(current.mFogSunriseColor, current.mFogDayColor); result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientDayColor); @@ -403,7 +403,7 @@ WeatherResult WeatherManager::getResult(const String& weather) } // day - else if (mHour >= 8 && mHour <= 17) + else if (mHour >= 9 && mHour <= 17) { result.mFogColor = current.mFogDayColor; result.mAmbientColor = current.mAmbientDayColor; From 5ea2122f795c8bef64f2bd58bf05da1dac187e06 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 16 Mar 2012 20:39:58 +0100 Subject: [PATCH 32/77] sun gradually disappears --- apps/openmw/mwrender/sky.cpp | 1 + apps/openmw/mwworld/weather.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 343afc13c9..ce61f36b71 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -696,6 +696,7 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather) strength = 1.f; mSunGlare->setVisibility(weather.mGlareView * strength); + mSun->setVisibility(strength); mAtmosphereNight->setVisible(weather.mNight && mEnabled); } diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 5ec9fbbcb1..12a413ccf0 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -572,7 +572,7 @@ void WeatherManager::update(float duration) mRendering->configureFog(result.mFogDepth, result.mFogColor); // disable sun during night - if (mHour >= 21 || mHour <= 5.5f) + if (mHour >= 20 || mHour <= 6.f) mRendering->getSkyManager()->sunDisable(); else { From 3ae69f792ada3bbe9c44f2eaa12d1fb11ae1d6b8 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 17 Mar 2012 12:57:52 +0100 Subject: [PATCH 33/77] no light-"jumps" during night --- apps/openmw/mwworld/weather.cpp | 56 +++++++++++---------------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 12a413ccf0..a5c954ef81 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -465,14 +465,6 @@ WeatherResult WeatherManager::transition(float factor) result.mNight = current.mNight; - // sound change behaviour: - // if 'other' has a new sound, switch to it after 1/2 of the transition length - if (other.mAmbientLoopSoundID != "") - result.mAmbientLoopSoundID = factor>0.5 ? other.mAmbientLoopSoundID : current.mAmbientLoopSoundID; - // if 'current' has a sound and 'other' does not have a sound, turn off the sound immediately - else if (current.mAmbientLoopSoundID != "") - result.mAmbientLoopSoundID = ""; - return result; } @@ -541,15 +533,6 @@ void WeatherManager::update(float duration) } setWeather(weather, false); - /* - std::cout << "roll result: " << random << std::endl; - - std::cout << regionstr << " weather probabilities: " << clear << " " << cloudy << " " << foggy << " " - << overcast << " " << rain << " " << thunder << " " << ash << " " << blight << " " << snow << " " - << blizzard << std::endl; - - std::cout << "New weather : " << weather << std::endl; - */ } WeatherResult result; @@ -575,18 +558,26 @@ void WeatherManager::update(float duration) if (mHour >= 20 || mHour <= 6.f) mRendering->getSkyManager()->sunDisable(); else - { - // during day, calculate sun angle - float height = 1-std::abs(((mHour-13)/7.f)); - int facing = mHour > 13.f ? 1 : -1; - Vector3 final( - (1-height)*facing, - (1-height)*facing, - height); - mRendering->setSunDirection(final); - mRendering->getSkyManager()->sunEnable(); - } + + // sun angle + float height; + + // rise at 6, set at 20 + if (mHour >= 6 && mHour <= 20) + height = 1-std::abs(((mHour-13)/7.f)); + else if (mHour > 20) + height = (mHour-20.f)/4.f; + else //if (mHour > 0 && mHour < 6) + height = 1-(mHour/6.f); + + int facing = (mHour > 13.f) ? 1 : -1; + + Vector3 final( + (1-height)*facing, + (1-height)*facing, + height); + mRendering->setSunDirection(final); // moon calculations float night; @@ -755,15 +746,6 @@ void WeatherManager::update(float duration) void WeatherManager::setHour(const float hour) { - // accelerate a bit for testing - /* - mHour += 0.005; - - if (mHour >= 24.f) mHour = 0.f; - - std::cout << "hour " << mHour << std::endl; - */ - mHour = hour; } From 18404011722c5dbda1b401ab6c043c9e50b2bf6f Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 17 Mar 2012 13:14:31 +0100 Subject: [PATCH 34/77] weather transitions (e.g. from clear to cloudy) use timescale --- apps/openmw/mwworld/weather.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index a5c954ef81..ccbca52db6 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -328,6 +328,9 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environmen void WeatherManager::setWeather(const String& weather, bool instant) { + if (weather == mCurrentWeather && mNextWeather == "") + return; + if (instant || mFirstUpdate) { mNextWeather = ""; @@ -339,12 +342,12 @@ void WeatherManager::setWeather(const String& weather, bool instant) if (mNextWeather != "") { // transition more than 50% finished? - if (mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60) <= 0.5) + if (mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*3600) <= 0.5) mCurrentWeather = mNextWeather; } - + mNextWeather = weather; - mRemainingTransitionTime = mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60; + mRemainingTransitionTime = mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*3600; } } @@ -459,7 +462,8 @@ WeatherResult WeatherManager::transition(float factor) result.mSunDiscColor = lerp(current.mSunDiscColor, other.mSunDiscColor); result.mFogDepth = lerp(current.mFogDepth, other.mFogDepth); result.mWindSpeed = lerp(current.mWindSpeed, other.mWindSpeed); - result.mCloudSpeed = lerp(current.mCloudSpeed, other.mCloudSpeed); + //result.mCloudSpeed = lerp(current.mCloudSpeed, other.mCloudSpeed); + result.mCloudSpeed = current.mCloudSpeed; result.mCloudOpacity = lerp(current.mCloudOpacity, other.mCloudOpacity); result.mGlareView = lerp(current.mGlareView, other.mGlareView); @@ -470,7 +474,7 @@ WeatherResult WeatherManager::transition(float factor) void WeatherManager::update(float duration) { - mWeatherUpdateTime -= duration; + mWeatherUpdateTime -= duration * mEnvironment->mWorld->getTimeScaleFactor(); bool exterior = (mEnvironment->mWorld->isCellExterior() || mEnvironment->mWorld->isCellQuasiExterior()); @@ -482,7 +486,7 @@ void WeatherManager::update(float duration) if (mWeatherUpdateTime <= 0 || regionstr != mCurrentRegion) { mCurrentRegion = regionstr; - mWeatherUpdateTime = WeatherGlobals::mWeatherUpdateTime*60.f; + mWeatherUpdateTime = WeatherGlobals::mWeatherUpdateTime*3600; std::string weather; @@ -539,7 +543,7 @@ void WeatherManager::update(float duration) if (mNextWeather != "") { - mRemainingTransitionTime -= duration; + mRemainingTransitionTime -= duration * mEnvironment->mWorld->getTimeScaleFactor(); if (mRemainingTransitionTime < 0) { mCurrentWeather = mNextWeather; @@ -548,10 +552,10 @@ void WeatherManager::update(float duration) } if (mNextWeather != "") - result = transition(1-(mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60))); + result = transition(1-(mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*3600))); else result = getResult(mCurrentWeather); - + mRendering->configureFog(result.mFogDepth, result.mFogColor); // disable sun during night @@ -570,9 +574,9 @@ void WeatherManager::update(float duration) height = (mHour-20.f)/4.f; else //if (mHour > 0 && mHour < 6) height = 1-(mHour/6.f); - + int facing = (mHour > 13.f) ? 1 : -1; - + Vector3 final( (1-height)*facing, (1-height)*facing, From 9d4f79bcfcd7b4423b737e73729222c348f528be Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 17 Mar 2012 15:24:47 +0100 Subject: [PATCH 35/77] GCC compile fix --- apps/openmw/mwdialogue/dialoguemanager.cpp | 2 +- apps/openmw/mwdialogue/dialoguemanager.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index eb78e9e9de..c469f12a06 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -472,7 +472,7 @@ namespace MWDialogue void DialogueManager::parseText(std::string text) { - std::map>::iterator it; + std::map >::iterator it; for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) { MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index f32305b46e..2ea157562a 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -31,7 +31,7 @@ namespace MWDialogue void parseText(std::string text); std::map knownTopics;// Those are the topics the player knows. - std::map> actorKnownTopics; + std::map > actorKnownTopics; MWScript::CompilerContext mCompilerContext; std::ostream mErrorStream; From 21143f006bbaeef65261ef0e811afe7e8355e637 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 17 Mar 2012 15:47:22 +0100 Subject: [PATCH 36/77] fix several warnings --- apps/openmw/mwgui/dialogue.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 88b44c9c41..91ad18e7b2 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -104,7 +104,7 @@ void DialogueWindow::onSelectTopic(MyGUI::List* _sender, size_t _index) { if (_index == MyGUI::ITEM_NONE) return; - std::string topic = _sender->getItem(_index); + std::string topic = _sender->getItemNameAt(_index); mEnvironment.mDialogueManager->keywordSelected(lower_string(topic)); } @@ -126,8 +126,8 @@ void DialogueWindow::removeKeyword(std::string keyWord) { if(topicsList->findItemIndexWith(keyWord) != MyGUI::ITEM_NONE) { - std::cout << topicsList->findItem(keyWord); - topicsList->removeItemAt(topicsList->findItem(keyWord)); + std::cout << topicsList->findItemIndexWith(keyWord); + topicsList->removeItemAt(topicsList->findItemIndexWith(keyWord)); pTopicsText.erase(keyWord); } } @@ -158,9 +158,9 @@ void addColorInString(std::string& str, const std::string& keyword,std::string c std::string DialogueWindow::parseText(std::string text) { - for(int i = 0;igetItemCount();i++) + for(unsigned int i = 0;igetItemCount();i++) { - std::string keyWord = topicsList->getItem(i); + std::string keyWord = topicsList->getItemNameAt(i); addColorInString(text,keyWord,"#686EBA","#B29154"); } return text; From 846196d048cf0640996d7becc1c109d5f289afdb Mon Sep 17 00:00:00 2001 From: gugus Date: Sat, 17 Mar 2012 16:56:22 +0100 Subject: [PATCH 37/77] fixed a crash --- apps/openmw/mwgui/dialogue.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 88b44c9c41..9b63ad6d24 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -145,13 +145,20 @@ void addColorInString(std::string& str, const std::string& keyword,std::string c str.insert(pos,color2); pos+= color2.length(); } - else if(str.substr(pos -1,1) == " ") + else { - str.insert(pos,color1); - pos += color1.length(); - pos += keyword.length(); - str.insert(pos,color2); - pos+= color2.length(); + if(str.substr(pos -1,1) == " ") + { + str.insert(pos,color1); + pos += color1.length(); + pos += keyword.length(); + str.insert(pos,color2); + pos+= color2.length(); + } + else + { + pos += keyword.length(); + } } } } From 187b8e58d61f756f2ebe97aa590c7e7bf97c4115 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 17 Mar 2012 19:32:44 +0100 Subject: [PATCH 38/77] fixed handling of optional instruction/function arguments; removed choice workaround --- apps/openmw/mwscript/dialogueextensions.cpp | 5 ++--- components/compiler/exprparser.cpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 78a52a1850..0cca028e29 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -95,7 +95,6 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) { - arg0 = 4; MWScript::InterpreterContext& context = static_cast (runtime.getContext()); MWDialogue::DialogueManager* dialogue = context.getEnvironment().mDialogueManager; @@ -129,7 +128,7 @@ namespace MWScript extensions.registerInstruction ("setjournalindex", "cl", opcodeSetJournalIndex); extensions.registerFunction ("getjournalindex", 'l', "c", opcodeGetJournalIndex); extensions.registerInstruction ("addtopic", "S" , opcodeAddTopic); - extensions.registerInstruction ("choice", "/SlSl", opcodeChoice); + extensions.registerInstruction ("choice", "/SlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSl", opcodeChoice); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -137,7 +136,7 @@ namespace MWScript interpreter.installSegment5 (opcodeJournal, new OpJournal); interpreter.installSegment5 (opcodeSetJournalIndex, new OpSetJournalIndex); interpreter.installSegment5 (opcodeGetJournalIndex, new OpGetJournalIndex); - interpreter.installSegment5 (opcodeAddTopic, new OpAddTopic); + interpreter.installSegment5 (opcodeAddTopic, new OpAddTopic); interpreter.installSegment3 (opcodeChoice,new OpChoice); } } diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index 06c3207e2d..95480c0239 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -639,7 +639,7 @@ namespace Compiler std::vector& code, bool invert) { bool optional = false; - bool optionalCount = 0; + int optionalCount = 0; ExprParser parser (getErrorHandler(), getContext(), mLocals, mLiterals, true); StringParser stringParser (getErrorHandler(), getContext(), mLiterals); From 100c6a42a56135c9b58576e3db7569d80295702c Mon Sep 17 00:00:00 2001 From: gugus Date: Sun, 18 Mar 2012 11:32:05 +0100 Subject: [PATCH 39/77] better default values for filters --- apps/openmw/mwdialogue/dialoguemanager.cpp | 82 +++++++++++++++++++--- 1 file changed, 73 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index c469f12a06..fe9cbf4ba0 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -163,6 +163,26 @@ namespace MWDialogue iss >> ifunction; switch(ifunction) { + case 39://PC Expelled + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 43://PC Crime level + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 46://Same faction + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 48://Detected + if(!selectCompare(comp,1,select.i)) return false; + break; + + case 49://Alarmed + if(!selectCompare(comp,0,select.i)) return false; + break; + case 50://choice isAChoice = true; if(choice) @@ -171,20 +191,61 @@ namespace MWDialogue } break; + case 60://PC Vampire + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 61://Level + if(!selectCompare(comp,1,select.i)) return false; + break; + + case 62://Attacked + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 63://Talked to PC + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 64://PC Health + if(!selectCompare(comp,50,select.i)) return false; + break; + + case 65://Creature target + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 66://Friend hit + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 67://Fight + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 68://Hello???? + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 69://Alarm + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 70://Flee + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 71://Should Attack + if(!selectCompare(comp,0,select.i)) return false; + break; + default: break; } } } - if(isAChoice) - { - return true; - } - if(isFunction) - { - return false; - } + return true; } @@ -373,6 +434,9 @@ namespace MWDialogue if (toLower (info.actor)!=MWWorld::Class::get (actor).getId (actor)) return false; + //PC Faction + if(!info.pcFaction.empty()) return false; + //NPC race if (!info.race.empty()) { @@ -544,7 +608,7 @@ namespace MWDialogue for (std::vector::const_iterator iter (it->second.mInfo.begin()); iter!=it->second.mInfo.end(); ++iter) { - if (isMatching (actor, *iter) && functionFilter(mActor,*iter,false)) + if (isMatching (actor, *iter) && functionFilter(mActor,*iter,true)) { if (!iter->sound.empty()) { From d9677cb33e8e7c6dc13a43a82ae3b2fcc81a61c4 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 18 Mar 2012 14:27:49 +0100 Subject: [PATCH 40/77] fixed problem with parsing optional string arguments --- apps/openmw/mwdialogue/dialoguemanager.cpp | 6 +++--- components/compiler/scriptparser.cpp | 19 +++++++++---------- components/compiler/stringparser.cpp | 5 +++++ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index fe9cbf4ba0..d7b6bae6ab 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -650,7 +650,7 @@ namespace MWDialogue locals = mEnvironment.mScriptManager->getLocals (actorScript); } - Compiler::ScriptParser parser(mErrorHandler,mCompilerContext, locals); + Compiler::ScriptParser parser(mErrorHandler,mCompilerContext, locals, false); scanner.scan (parser); if(mErrorHandler.isGood()) @@ -712,7 +712,7 @@ namespace MWDialogue win->addText(it->response); executeScript(script); - + mLastTopic = keyword; mLastDialogue = dial; break; @@ -756,7 +756,7 @@ namespace MWDialogue mLastDialogue = *it; break; } - } + } } } diff --git a/components/compiler/scriptparser.cpp b/components/compiler/scriptparser.cpp index ce142847f5..ac0ee63f1c 100644 --- a/components/compiler/scriptparser.cpp +++ b/components/compiler/scriptparser.cpp @@ -24,7 +24,7 @@ namespace Compiler mLineParser.reset(); if (mLineParser.parseName (name, loc, scanner)) scanner.scan (mLineParser); - + return true; } @@ -34,22 +34,22 @@ namespace Compiler { mControlParser.reset(); if (mControlParser.parseKeyword (keyword, loc, scanner)) - scanner.scan (mControlParser); - + scanner.scan (mControlParser); + mControlParser.appendCode (mOutput.getCode()); - + return true; } - + if (keyword==Scanner::K_end && mEnd) { return false; } - + mLineParser.reset(); if (mLineParser.parseKeyword (keyword, loc, scanner)) scanner.scan (mLineParser); - + return true; } @@ -57,11 +57,11 @@ namespace Compiler { if (code==Scanner::S_newline) // empty line return true; - + mLineParser.reset(); if (mLineParser.parseSpecial (code, loc, scanner)) scanner.scan (mLineParser); - + return true; } @@ -77,4 +77,3 @@ namespace Compiler mOutput.clear(); } } - diff --git a/components/compiler/stringparser.cpp b/components/compiler/stringparser.cpp index 396a88c786..fe7bd30b9e 100644 --- a/components/compiler/stringparser.cpp +++ b/components/compiler/stringparser.cpp @@ -39,6 +39,11 @@ namespace Compiler mState = CommaState; return true; } + else if (code==Scanner::S_newline && mState==StartState) + { + scanner.putbackSpecial (code, loc); + return false; + } return Parser::parseSpecial (code, loc, scanner); } From 019a28093b9cbf9d9bb771b5e4fa38576d4b5fd0 Mon Sep 17 00:00:00 2001 From: gugus Date: Sun, 18 Mar 2012 15:26:18 +0100 Subject: [PATCH 41/77] better filters --- apps/openmw/mwdialogue/dialoguemanager.cpp | 41 ++++++++++++---------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index d7b6bae6ab..eb9e8bfb8f 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -164,79 +164,79 @@ namespace MWDialogue switch(ifunction) { case 39://PC Expelled - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.i)) return false; break; case 43://PC Crime level - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.i)) return false; break; case 46://Same faction - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.i)) return false; break; case 48://Detected - if(!selectCompare(comp,1,select.i)) return false; + if(!selectCompare(comp,1,select.i)) return false; break; case 49://Alarmed - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.i)) return false; break; case 50://choice isAChoice = true; if(choice) { - if(!selectCompare(comp,mChoice,select.i)) return false; + if(!selectCompare(comp,mChoice,select.i)) return false; } break; case 60://PC Vampire - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.i)) return false; break; case 61://Level - if(!selectCompare(comp,1,select.i)) return false; + if(!selectCompare(comp,1,select.i)) return false; break; case 62://Attacked - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.i)) return false; break; case 63://Talked to PC - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.i)) return false; break; case 64://PC Health - if(!selectCompare(comp,50,select.i)) return false; + if(!selectCompare(comp,50,select.i)) return false; break; case 65://Creature target - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.i)) return false; break; case 66://Friend hit - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.i)) return false; break; case 67://Fight - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.i)) return false; break; case 68://Hello???? - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.i)) return false; break; case 69://Alarm - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.i)) return false; break; case 70://Flee - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.i)) return false; break; case 71://Should Attack - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.i)) return false; break; default: @@ -331,6 +331,9 @@ namespace MWDialogue return true; + case '5'://item + if(!selectCompare(comp,0,select.i)) return false; + case '7':// not ID if(select.type==ESM::VT_String ||select.type==ESM::VT_Int)//bug in morrowind here? it's not a short, it's a string { @@ -563,6 +566,8 @@ namespace MWDialogue void DialogueManager::startDialogue (const MWWorld::Ptr& actor) { + mChoice = -1; + mIsInChoice = false; std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl; mActor = actor; From 8740354c80922efd1710a51dcf129e09b73ea42e Mon Sep 17 00:00:00 2001 From: gugus Date: Sun, 18 Mar 2012 17:03:54 +0100 Subject: [PATCH 42/77] inventory filter now use player inventory --- apps/openmw/mwdialogue/dialoguemanager.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index eb9e8bfb8f..4e80b8dc79 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -15,6 +15,7 @@ #include "../mwworld/world.hpp" #include "../mwworld/refdata.hpp" #include "../mwworld/player.hpp" +#include "../mwworld/containerstore.hpp" #include "../mwinput/inputmanager.hpp" #include "../mwgui/dialogue.hpp" @@ -332,7 +333,15 @@ namespace MWDialogue return true; case '5'://item - if(!selectCompare(comp,0,select.i)) return false; + MWWorld::Ptr player = mEnvironment.mWorld->getPlayer().getPlayer(); + MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player); + + Interpreter::Type_Integer sum = 0; + + for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter) + if (iter->getCellRef().refID==name) + sum += iter->getRefData().getCount(); + if(!selectCompare(comp,sum,select.i)) return false; case '7':// not ID if(select.type==ESM::VT_String ||select.type==ESM::VT_Int)//bug in morrowind here? it's not a short, it's a string From 76b24d9d1a54c8945491781deb485ac6444baab0 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 18 Mar 2012 17:30:05 +0100 Subject: [PATCH 43/77] fixed a compile error --- apps/openmw/mwdialogue/dialoguemanager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 4e80b8dc79..5395d3efb4 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -333,6 +333,7 @@ namespace MWDialogue return true; case '5'://item + { MWWorld::Ptr player = mEnvironment.mWorld->getPlayer().getPlayer(); MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player); @@ -343,6 +344,9 @@ namespace MWDialogue sum += iter->getRefData().getCount(); if(!selectCompare(comp,sum,select.i)) return false; + return true; + } + case '7':// not ID if(select.type==ESM::VT_String ||select.type==ESM::VT_Int)//bug in morrowind here? it's not a short, it's a string { From 34b33b78d2b1e2d2f29ebaa80ca2f417bbf03ee7 Mon Sep 17 00:00:00 2001 From: gugus Date: Sun, 18 Mar 2012 17:58:14 +0100 Subject: [PATCH 44/77] better filters --- apps/openmw/mwdialogue/dialoguemanager.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 4e80b8dc79..925191be30 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -168,6 +168,14 @@ namespace MWDialogue if(!selectCompare(comp,0,select.i)) return false; break; + case 40://PC Common Disease + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 41://PC Blight Disease + if(!selectCompare(comp,0,select.i)) return false; + break; + case 43://PC Crime level if(!selectCompare(comp,0,select.i)) return false; break; @@ -333,15 +341,17 @@ namespace MWDialogue return true; case '5'://item + { MWWorld::Ptr player = mEnvironment.mWorld->getPlayer().getPlayer(); MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player); - Interpreter::Type_Integer sum = 0; + int sum = 0; for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter) if (iter->getCellRef().refID==name) sum += iter->getRefData().getCount(); if(!selectCompare(comp,sum,select.i)) return false; + } case '7':// not ID if(select.type==ESM::VT_String ||select.type==ESM::VT_Int)//bug in morrowind here? it's not a short, it's a string From 4afe6dd2355fd43e2ba5889f7182269f7d036b13 Mon Sep 17 00:00:00 2001 From: gugus Date: Sun, 18 Mar 2012 18:04:51 +0100 Subject: [PATCH 45/77] death filter --- apps/openmw/mwdialogue/dialoguemanager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 6b71989fab..87c1aeff59 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -354,7 +354,10 @@ namespace MWDialogue } return true; - } + + + case '6'://dead + if(!selectCompare(comp,0,select.i)) return false; case '7':// not ID if(select.type==ESM::VT_String ||select.type==ESM::VT_Int)//bug in morrowind here? it's not a short, it's a string From 7f2ff6f5f12fb7a420b5fe820f5a1f06e21f1b72 Mon Sep 17 00:00:00 2001 From: gugus Date: Sun, 18 Mar 2012 18:05:28 +0100 Subject: [PATCH 46/77] removed the TODO --- apps/openmw/mwdialogue/dialoguemanager.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 87c1aeff59..19898ca725 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -269,8 +269,6 @@ namespace MWDialogue std::string name = select.selectRule.substr (5); std::string function = select.selectRule.substr(1,2); - // TODO types 4, 5, 6, 7, 8, 9, A, B, C - //new TOTO: 5,6,9 switch (type) { case '1': // function From 00d3bc9d23423a2a622f85211fbfdd3bf23a2a46 Mon Sep 17 00:00:00 2001 From: gugus Date: Sun, 18 Mar 2012 18:58:22 +0100 Subject: [PATCH 47/77] every filters are check during dialogue now. There is a problem with journal. --- apps/openmw/mwdialogue/dialoguemanager.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 19898ca725..ac168febbf 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -318,19 +318,7 @@ namespace MWDialogue case '4'://journal if(select.type==ESM::VT_Int) { - //std::cout << "vtint: " << select.i << std::endl; - bool isInJournal; - if(mEnvironment.mJournal->begin()!=mEnvironment.mJournal->end()) - { - for(std::deque::const_iterator it = mEnvironment.mJournal->begin();it!=mEnvironment.mJournal->end();it++) - { - - if(it->mTopic == name) isInJournal = true; - } - } - else - isInJournal = false; - if(!selectCompare(comp,int(isInJournal),select.i)) return false; + if(!selectCompare(comp,mEnvironment.mJournal->getJournalIndex(name),select.i)) return false; } else throw std::runtime_error ( @@ -728,7 +716,7 @@ namespace MWDialogue for(std::list::iterator it = actorKnownTopics[keyword].begin(); it != actorKnownTopics[keyword].end();it++) { ESM::DialInfo dial = *it; - if(functionFilter(mActor,dial,true)) + if(functionFilter(mActor,dial,true) && isMatching (mActor,dial)) { std::string text = it->response; std::string script = it->resultScript; @@ -770,7 +758,7 @@ namespace MWDialogue for(std::list::iterator it = iter; it!=actorKnownTopics[mLastTopic].begin();) { it--; - if(functionFilter(mActor,*it,true)) + if(functionFilter(mActor,*it,true) && isMatching (mActor,*it)) { mChoiceMap.clear(); mChoice = -1; From ce2cb709c51972e913cfe4a704c315a98b548dd8 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 18 Mar 2012 19:05:35 +0100 Subject: [PATCH 48/77] fixed getJournalIndex function --- apps/openmw/mwdialogue/journal.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journal.cpp index 42cce5cf55..ea4a5a01e2 100644 --- a/apps/openmw/mwdialogue/journal.cpp +++ b/apps/openmw/mwdialogue/journal.cpp @@ -60,7 +60,12 @@ namespace MWDialogue int Journal::getJournalIndex (const std::string& id) const { - return 0; + TQuestContainer::const_iterator iter = mQuests.find (id); + + if (iter==mQuests.end()) + return 0; + + return iter->second.getIndex(); } Journal::TEntryIter Journal::begin() const From c2329b7027b6180913cce9fe148a85e13daab075 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 18 Mar 2012 20:32:50 +0100 Subject: [PATCH 49/77] removed preprocessor constants --- apps/openmw/mwrender/sky.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index ce61f36b71..a747b9be04 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -16,13 +16,6 @@ using namespace MWRender; using namespace Ogre; -// the speed at which the clouds are animated -#define CLOUD_SPEED 0.003 - -// this distance has to be set accordingly so that the -// celestial bodies are behind the clouds, but in front of the atmosphere -#define CELESTIAL_BODY_DISTANCE 1000.f - BillboardObject::BillboardObject( const String& textureName, const float initialSize, const Vector3& position, @@ -53,7 +46,7 @@ void BillboardObject::setVisibility(const float visibility) void BillboardObject::setPosition(const Vector3& pPosition) { Vector3 normalised = pPosition.normalisedCopy(); - Vector3 finalPosition = normalised * CELESTIAL_BODY_DISTANCE; + Vector3 finalPosition = normalised * 1000.f; mBBSet->setCommonDirection( -normalised ); @@ -88,7 +81,7 @@ void BillboardObject::init(const String& textureName, { SceneManager* sceneMgr = rootNode->getCreator(); - Vector3 finalPosition = position.normalisedCopy() * CELESTIAL_BODY_DISTANCE; + Vector3 finalPosition = position.normalisedCopy() * 1000.f; static unsigned int bodyCount=0; @@ -508,7 +501,7 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera, MWWorld::Environmen " uniform float4 emissive \n" ") \n" "{ \n" - " uv += float2(1,0) * time * speed * "< Date: Sun, 18 Mar 2012 22:38:53 +0200 Subject: [PATCH 50/77] Fix for the --nosound crash --- apps/openmw/mwsound/soundmanager.cpp | 8 ++++++-- apps/openmw/mwsound/soundmanager.hpp | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index a5ba04e261..6a2ba2fe4f 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -67,6 +67,7 @@ namespace MWSound , updater(mgr) , cameraTracker(mgr) , mCurrentPlaylist(NULL) + , mUsingSound(useSound) { if(useSound) { @@ -105,8 +106,11 @@ namespace MWSound SoundManager::~SoundManager() { - Ogre::Root::getSingleton().removeFrameListener(&updater); - cameraTracker.unfollowCamera(); + if(mUsingSound) + { + Ogre::Root::getSingleton().removeFrameListener(&updater); + cameraTracker.unfollowCamera(); + } } // Convert a soundId to file name, and modify the volume diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index bd3b676797..dcf64b90ca 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -82,6 +82,8 @@ namespace MWSound IDMap mLoopedSounds; + bool mUsingSound; + std::string lookup(const std::string &soundId, float &volume, float &min, float &max); void add(const std::string &file, From ff5d4b24fcc9f988f8acdeaa7dd76c936bbd0634 Mon Sep 17 00:00:00 2001 From: gugus Date: Sun, 18 Mar 2012 21:47:43 +0100 Subject: [PATCH 51/77] journal filter works now --- apps/openmw/mwdialogue/dialoguemanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index ac168febbf..2a583f14b1 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -318,7 +318,7 @@ namespace MWDialogue case '4'://journal if(select.type==ESM::VT_Int) { - if(!selectCompare(comp,mEnvironment.mJournal->getJournalIndex(name),select.i)) return false; + if(!selectCompare(comp,mEnvironment.mJournal->getJournalIndex(toLower(name)),select.i)) return false; } else throw std::runtime_error ( From d10b18b0f305b1a6117c6b6e2f72b0c5b5e3c68d Mon Sep 17 00:00:00 2001 From: Michael Papageorgiou Date: Sun, 18 Mar 2012 22:50:52 +0200 Subject: [PATCH 52/77] Removed a couple of warnings with nosound --- apps/openmw/mwsound/soundmanager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 6a2ba2fe4f..226796603e 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -358,6 +358,9 @@ namespace MWSound void SoundManager::playPlaylist(std::string playlist) { + if (!mUsingSound) + return; + if (playlist == "") { if(!isMusicPlaying()) @@ -379,6 +382,9 @@ namespace MWSound void SoundManager::say (MWWorld::Ptr ptr, const std::string& filename) { + if (!mUsingSound) + return; + // The range values are not tested std::string filePath = Files::FileListLocator(mSoundFiles, filename, mFSStrict, true); if(!filePath.empty()) From cab869824a6b4a32e1c426dbbb633a226aaf4eda Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 18 Mar 2012 22:18:09 +0100 Subject: [PATCH 53/77] bumping version number --- CMakeLists.txt | 2 +- readme.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a12126c2a1..d2cb1e0e5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ include (OpenMWMacros) # Version set (OPENMW_VERSION_MAJOR 0) -set (OPENMW_VERSION_MINOR 12) +set (OPENMW_VERSION_MINOR 13) set (OPENMW_VERSION_RELEASE 0) set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") diff --git a/readme.txt b/readme.txt index 88c1700888..c61d835cbd 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ OpenMW: A reimplementation of The Elder Scrolls III: Morrowind OpenMW is an attempt at recreating the engine for the popular role-playing game Morrowind by Bethesda Softworks. You need to own and install the original game for OpenMW to work. -Version: 0.12.0 +Version: 0.13.0 License: GPL (see GPL3.txt for more information) Website: http://www.openmw.org From 16e61bb0285cbd6072b1afae9da473ec6ba49722 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 18 Mar 2012 22:20:45 +0100 Subject: [PATCH 54/77] updated developer list in readme file --- readme.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index c61d835cbd..2f63e81747 100644 --- a/readme.txt +++ b/readme.txt @@ -96,9 +96,12 @@ athile Cris “Mirceam” Mihalache gugus / gus Jacob “Yacoby” Essex +Jannik “scrawl” Heller Jason “jhooks” Hooks +Karl-Felix “k1ll” Glatzer Lukasz “lgro” Gromanowski Marc “Zini” Zinnschlag +Michael “werdanith” Papageorgiou Nikolay “corristo” Kasyanov Pieter “pvdk” van der Kloet Sebastian “swick” Wick @@ -110,7 +113,6 @@ Diggory Hardy Jan Borsodi Jan-Peter “peppe” Nilsson Josua Grawitter -Karl-Felix “k1ll” Glatzer Nicolay Korslund sergoz Star-Demon From c874fff4b16f69801c13ae877f2e89735d4f6a27 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 18 Mar 2012 22:25:43 +0100 Subject: [PATCH 55/77] added 0.13.0 changelog --- readme.txt | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/readme.txt b/readme.txt index 2f63e81747..149fd4f193 100644 --- a/readme.txt +++ b/readme.txt @@ -127,6 +127,36 @@ Thanks to Kevin Ryan for kindly providing us with the icon used for the Data Fil CHANGELOG +0.13.0 + +Bug #145: Fixed sound problems after cell change +Bug #179: Pressing space in console triggers activation +Bug #186: CMake doesn't use the debug versions of Ogre libraries on Linux +Bug #189: ASCII 16 character added to console on it's activation on Mac OS X +Bug #190: Case Folding fails with music files +Bug #196: Collision shapes out of place +Bug #202: ESMTool doesn't not work with localised ESM files anymore +Bug #203: Torch lights only visible on short distance +Bug #207: Ogre.log not written +Bug #209: Sounds do not play +Bug #210: Ogre crash at Dren plantation +Feature #9: NPC Dialogue Window +Feature #16/42: New sky/weather implementation +Feature #40: Fading +Feature #48: NPC Dialogue System +Feature #117: Equipping Items (backend only, no GUI yet, no rendering of equipped items yet) +Feature #161: Load REC_PGRD records +Feature #195: Wireframe-mode +Feature #198/199: Various sound effects +Feature #206: Allow picking data path from launcher if non is set +Task #108: Refactor window manager class +Task #172: Sound Manager Cleanup +Task #173: Create OpenEngine systems in the appropriate manager classes +Task #184: Adjust MSVC and gcc warning levels +Task #185: RefData rewrite +Task #201: Workaround for transparency issues +Task #208: silenced esm_reader.hpp warning + 0.12.0 Bug #154: FPS Drop From 1a832a65f664e2524c1a87b1f6fd793ee243e82b Mon Sep 17 00:00:00 2001 From: gugus Date: Mon, 19 Mar 2012 00:19:58 +0100 Subject: [PATCH 56/77] Changed a lot of things. Topics can now change durring dialogue without bug. Missing: ability to remove keyword --- apps/openmw/mwdialogue/dialoguemanager.cpp | 175 ++++++++++++--------- apps/openmw/mwdialogue/dialoguemanager.hpp | 5 +- 2 files changed, 108 insertions(+), 72 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 2a583f14b1..34cd51f259 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -550,25 +550,23 @@ namespace MWDialogue void DialogueManager::parseText(std::string text) { - std::map >::iterator it; + std::cout << "PARSE"; + std::list::iterator it; for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) { MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); - size_t pos = find_str_ci(text,it->first,0); + size_t pos = find_str_ci(text,*it,0); if(pos !=std::string::npos) { - if(!it->second.empty()) + if(pos==0) { - if(pos==0) - { - knownTopics[it->first] = true; - win->addKeyword(it->first); - } - else if(text.substr(pos -1,1) == " ") - { - knownTopics[it->first] = true; - win->addKeyword(it->first); - } + knownTopics[*it] = true; + win->addKeyword(*it); + } + else if(text.substr(pos -1,1) == " ") + { + knownTopics[*it] = true; + win->addKeyword(*it); } } @@ -583,38 +581,25 @@ namespace MWDialogue mActor = actor; + mDialogueMap.clear(); + actorKnownTopics.clear(); + ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + { + mDialogueMap[it->first] = it->second; + } + //initialise the GUI mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue); MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); 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(); - ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) - { - ESM::Dialogue ndialogue = it->second; - if(ndialogue.type == ESM::Dialogue::Topic) - { - for (std::vector::const_iterator iter (it->second.mInfo.begin()); - iter!=it->second.mInfo.end(); ++iter) - { - if (isMatching (actor, *iter) && functionFilter(mActor,*iter,false)) - { - actorKnownTopics[it->first].push_back(*iter); - //does the player know the topic? - if(knownTopics.find(toLower(it->first)) != knownTopics.end()) - { - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); - win->addKeyword(it->first); - } - } - } - } - } + updateTopics(); //greeting bool greetingFound = false; + //ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { ESM::Dialogue ndialogue = it->second; @@ -647,7 +632,6 @@ namespace MWDialogue bool DialogueManager::compile (const std::string& cmd,std::vector& code) { - std::cout << cmd << std::endl; try { mErrorHandler.reset(); @@ -707,35 +691,68 @@ namespace MWDialogue } } + void DialogueManager::updateTopics() + { + actorKnownTopics.clear(); + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + { + ESM::Dialogue ndialogue = it->second; + if(ndialogue.type == ESM::Dialogue::Topic) + { + for (std::vector::const_iterator iter (it->second.mInfo.begin()); + iter!=it->second.mInfo.end(); ++iter) + { + if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,false)) + { + actorKnownTopics.push_back(it->first); + //does the player know the topic? + if(knownTopics.find(toLower(it->first)) != knownTopics.end()) + { + win->addKeyword(it->first); + } + } + } + } + } + } + void DialogueManager::keywordSelected(std::string keyword) { if(!mIsInChoice) { - if(!actorKnownTopics[keyword].empty()) + if(mDialogueMap.find(keyword) != mDialogueMap.end()) { - for(std::list::iterator it = actorKnownTopics[keyword].begin(); it != actorKnownTopics[keyword].end();it++) + ESM::Dialogue ndialogue = mDialogueMap[keyword]; + std::vector::const_iterator iter; + if(ndialogue.type == ESM::Dialogue::Topic) { - ESM::DialInfo dial = *it; - if(functionFilter(mActor,dial,true) && isMatching (mActor,dial)) + for (iter = ndialogue.mInfo.begin(); + iter!=ndialogue.mInfo.end(); ++iter) { - std::string text = it->response; - std::string script = it->resultScript; + if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) + { + std::string text = iter->response; + std::string script = iter->resultScript; - parseText(text); + parseText(text); - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); - win->addTitle(keyword); - win->addText(it->response); + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + win->addTitle(keyword); + win->addText(iter->response); - executeScript(script); + executeScript(script); - mLastTopic = keyword; - mLastDialogue = dial; - break; + mLastTopic = keyword; + mLastDialogue = *iter; + break; + } } } } } + updateTopics(); } void DialogueManager::goodbyeSelected() @@ -748,31 +765,47 @@ namespace MWDialogue if(mChoiceMap.find(answere) != mChoiceMap.end()) { mChoice = mChoiceMap[answere]; - std::list dials = actorKnownTopics[mLastTopic]; - std::cout << actorKnownTopics[mLastTopic].size() << mLastTopic; - std::list::iterator iter; - for(iter = actorKnownTopics[mLastTopic].begin(); iter->id != mLastDialogue.id;iter++) - { - } - for(std::list::iterator it = iter; it!=actorKnownTopics[mLastTopic].begin();) + //ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + bool found = false; + //ESMS::RecListT::MapType::iterator it; + std::vector::const_iterator iter; + //for(it = dialogueList.begin(); it!=dialogueList.end();it++) + if(mDialogueMap.find(mLastTopic) != mDialogueMap.end()) { - it--; - if(functionFilter(mActor,*it,true) && isMatching (mActor,*it)) + ESM::Dialogue ndialogue = mDialogueMap[mLastTopic]; + if(ndialogue.type == ESM::Dialogue::Topic) { - mChoiceMap.clear(); - mChoice = -1; - mIsInChoice = false; - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); - std::string text = it->response; - parseText(text); - win->addText(text); - executeScript(it->resultScript); - mLastTopic = mLastTopic; - mLastDialogue = *it; - break; + for (iter = ndialogue.mInfo.begin(); + iter!=ndialogue.mInfo.end(); ++iter) + { + if(iter->id == mLastDialogue.id) found = true; + if(found) break; + } + } + if(found) + { + for (std::vector::const_iterator iter2 = iter; + iter2!=ndialogue.mInfo.begin(); --iter2) + { + if (isMatching (mActor, *iter2) && functionFilter(mActor,*iter2,true)) + { + mChoiceMap.clear(); + mChoice = -1; + mIsInChoice = false; + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + std::string text = iter2->response; + parseText(text); + win->addText(text); + executeScript(iter2->resultScript); + mLastTopic = mLastTopic; + mLastDialogue = *iter2; + break; + } + } } } + updateTopics(); } } diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index 2ea157562a..260d8e3394 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -30,8 +30,11 @@ namespace MWDialogue void parseText(std::string text); + void updateTopics(); + + std::map mDialogueMap; std::map knownTopics;// Those are the topics the player knows. - std::map > actorKnownTopics; + std::list actorKnownTopics; MWScript::CompilerContext mCompilerContext; std::ostream mErrorStream; From 1f76f375312f8c015f74e7de7603e841bbe161c7 Mon Sep 17 00:00:00 2001 From: k1ll Date: Mon, 19 Mar 2012 14:25:33 +0100 Subject: [PATCH 57/77] Adds search for plugins in OGRE dirs with version suffix and a workaround for a strange problem with set to FindOgre.cmake. --- cmake/FindOGRE.cmake | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cmake/FindOGRE.cmake b/cmake/FindOGRE.cmake index 78d0ef24e2..5e6453eea1 100644 --- a/cmake/FindOGRE.cmake +++ b/cmake/FindOGRE.cmake @@ -405,8 +405,16 @@ macro(ogre_find_plugin PLUGIN HEADER) set(OGRE_${PLUGIN}_LIBRARY_NAMES "${PLUGIN}${OGRE_LIB_SUFFIX}") get_debug_names(OGRE_${PLUGIN}_LIBRARY_NAMES) set(OGRE_${PLUGIN}_LIBRARY_FWK ${OGRE_LIBRARY_FWK}) + # Search for release plugins in OGRE dir with version suffix + find_library(OGRE_${PLUGIN}_LIBRARY_REL NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES} + HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE-${OGRE_VERSION} opt release release/opt relwithdebinfo relwithdebinfo/opt minsizerel minsizerel/opt) + # Search for release plugins in OGRE dir without version suffix find_library(OGRE_${PLUGIN}_LIBRARY_REL NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES} HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt release release/opt relwithdebinfo relwithdebinfo/opt minsizerel minsizerel/opt) + # Search for debug plugins in OGRE dir with version suffix + find_library(OGRE_${PLUGIN}_LIBRARY_DBG NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES_DBG} + HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE-${OGRE_VERSION} opt debug debug/opt) + # Search for debug plugins in OGRE dir without version suffix find_library(OGRE_${PLUGIN}_LIBRARY_DBG NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES_DBG} HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt debug debug/opt) make_library_set(OGRE_${PLUGIN}_LIBRARY) @@ -441,9 +449,13 @@ macro(ogre_find_plugin PLUGIN HEADER) PATH_SUFFIXES "" bin bin/debug debug) elseif (UNIX) get_filename_component(OGRE_PLUGIN_DIR_TMP ${OGRE_${PLUGIN}_LIBRARY_REL} PATH) - set(OGRE_PLUGIN_DIR_REL ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (release)") + # For some reason this fails + #set(OGRE_PLUGIN_DIR_REL ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (release)") + set(OGRE_PLUGIN_DIR_REL ${OGRE_PLUGIN_DIR_TMP}) get_filename_component(OGRE_PLUGIN_DIR_TMP ${OGRE_${PLUGIN}_LIBRARY_DBG} PATH) - set(OGRE_PLUGIN_DIR_DBG ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (debug)") + # Same here + #set(OGRE_PLUGIN_DIR_DBG ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (debug)") + set(OGRE_PLUGIN_DIR_DBG ${OGRE_PLUGIN_DIR_TMP}) endif () endif () From 5abaf1fee24d68830f3f57f1182f09acd07882d5 Mon Sep 17 00:00:00 2001 From: k1ll Date: Mon, 19 Mar 2012 15:04:55 +0100 Subject: [PATCH 58/77] Check if searching OGRE dir with version suffix failed. I'm not sure if this is the right way to do it though. --- cmake/FindOGRE.cmake | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cmake/FindOGRE.cmake b/cmake/FindOGRE.cmake index 5e6453eea1..fb4a090c6e 100644 --- a/cmake/FindOGRE.cmake +++ b/cmake/FindOGRE.cmake @@ -408,15 +408,19 @@ macro(ogre_find_plugin PLUGIN HEADER) # Search for release plugins in OGRE dir with version suffix find_library(OGRE_${PLUGIN}_LIBRARY_REL NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES} HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE-${OGRE_VERSION} opt release release/opt relwithdebinfo relwithdebinfo/opt minsizerel minsizerel/opt) - # Search for release plugins in OGRE dir without version suffix - find_library(OGRE_${PLUGIN}_LIBRARY_REL NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES} - HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt release release/opt relwithdebinfo relwithdebinfo/opt minsizerel minsizerel/opt) + if(NOT EXISTS "${OGRE_${PLUGIN}_LIBRARY_REL}") + # Search for release plugins in OGRE dir without version suffix + find_library(OGRE_${PLUGIN}_LIBRARY_REL NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES} + HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt release release/opt relwithdebinfo relwithdebinfo/opt minsizerel minsizerel/opt) + endif() # Search for debug plugins in OGRE dir with version suffix find_library(OGRE_${PLUGIN}_LIBRARY_DBG NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES_DBG} HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE-${OGRE_VERSION} opt debug debug/opt) - # Search for debug plugins in OGRE dir without version suffix - find_library(OGRE_${PLUGIN}_LIBRARY_DBG NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES_DBG} - HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt debug debug/opt) + if(NOT EXISTS "${OGRE_${PLUGIN}_LIBRARY_DBG}") + # Search for debug plugins in OGRE dir without version suffix + find_library(OGRE_${PLUGIN}_LIBRARY_DBG NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES_DBG} + HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt debug debug/opt) + endif() make_library_set(OGRE_${PLUGIN}_LIBRARY) if (OGRE_${PLUGIN}_LIBRARY OR OGRE_${PLUGIN}_INCLUDE_DIR) From ba4d44eb67bf9900aa7053118e4e478600fac96a Mon Sep 17 00:00:00 2001 From: gugus Date: Mon, 19 Mar 2012 18:01:41 +0100 Subject: [PATCH 59/77] fix for questions. --- apps/openmw/mwdialogue/dialoguemanager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 34cd51f259..81a89761af 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -550,7 +550,6 @@ namespace MWDialogue void DialogueManager::parseText(std::string text) { - std::cout << "PARSE"; std::list::iterator it; for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) { @@ -786,8 +785,9 @@ namespace MWDialogue if(found) { for (std::vector::const_iterator iter2 = iter; - iter2!=ndialogue.mInfo.begin(); --iter2) + iter2!=ndialogue.mInfo.begin();) { + --iter2; if (isMatching (mActor, *iter2) && functionFilter(mActor,*iter2,true)) { mChoiceMap.clear(); From 11569819dbda574e0452565a514fff5c85e5450c Mon Sep 17 00:00:00 2001 From: gugus Date: Mon, 19 Mar 2012 18:01:54 +0100 Subject: [PATCH 60/77] compilation fix --- apps/openmw/mwworld/weather.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 47f4361915..044d6e83a7 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -26,11 +26,7 @@ const float WeatherGlobals::mSunsetTime = 18; const float WeatherGlobals::mSunriseDuration = 2; const float WeatherGlobals::mSunsetDuration = 2; const float WeatherGlobals::mWeatherUpdateTime = 20.f; -const float WeatherGlobals::mThunderFrequency = .4; -const float WeatherGlobals::mThunderThreshold = 0.6; -const float WeatherGlobals::mThunderSoundDelay = 0.25; -const float WeatherGlobals::mWeatherUpdateTime = 20.f; // morrowind sets these per-weather, but since they are only used by 'thunderstorm' // weather setting anyway, we can just as well set them globally From 270739153585a1f377d4be79e7db0ea0a4706596 Mon Sep 17 00:00:00 2001 From: gugus Date: Mon, 19 Mar 2012 18:30:52 +0100 Subject: [PATCH 61/77] fix for questions --- apps/openmw/mwdialogue/dialoguemanager.cpp | 34 +++++++--------------- apps/openmw/mwgui/dialogue.cpp | 8 ++--- apps/openmw/mwgui/dialogue.hpp | 2 +- 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 81a89761af..7950a78881 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -560,16 +560,14 @@ namespace MWDialogue if(pos==0) { knownTopics[*it] = true; - win->addKeyword(*it); } else if(text.substr(pos -1,1) == " ") { knownTopics[*it] = true; - win->addKeyword(*it); } } - } + updateTopics(); } void DialogueManager::startDialogue (const MWWorld::Ptr& actor) @@ -692,6 +690,8 @@ namespace MWDialogue void DialogueManager::updateTopics() { + std::list keywordList; + actorKnownTopics.clear(); MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; @@ -709,12 +709,14 @@ namespace MWDialogue //does the player know the topic? if(knownTopics.find(toLower(it->first)) != knownTopics.end()) { - win->addKeyword(it->first); + keywordList.push_back(it->first); + break; } } } } } + win->setKeywords(keywordList); } void DialogueManager::keywordSelected(std::string keyword) @@ -765,41 +767,27 @@ namespace MWDialogue { mChoice = mChoiceMap[answere]; - //ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - bool found = false; - //ESMS::RecListT::MapType::iterator it; std::vector::const_iterator iter; - //for(it = dialogueList.begin(); it!=dialogueList.end();it++) if(mDialogueMap.find(mLastTopic) != mDialogueMap.end()) { ESM::Dialogue ndialogue = mDialogueMap[mLastTopic]; if(ndialogue.type == ESM::Dialogue::Topic) { - for (iter = ndialogue.mInfo.begin(); + for (std::vector::const_iterator iter = ndialogue.mInfo.begin(); iter!=ndialogue.mInfo.end(); ++iter) { - if(iter->id == mLastDialogue.id) found = true; - if(found) break; - } - } - if(found) - { - for (std::vector::const_iterator iter2 = iter; - iter2!=ndialogue.mInfo.begin();) - { - --iter2; - if (isMatching (mActor, *iter2) && functionFilter(mActor,*iter2,true)) + if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) { mChoiceMap.clear(); mChoice = -1; mIsInChoice = false; MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); - std::string text = iter2->response; + std::string text = iter->response; parseText(text); win->addText(text); - executeScript(iter2->resultScript); + executeScript(iter->resultScript); mLastTopic = mLastTopic; - mLastDialogue = *iter2; + mLastDialogue = *iter; break; } } diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 549022e704..5ab8604431 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -113,12 +113,12 @@ void DialogueWindow::startDialogue(std::string npcName) setText("NpcName", npcName); } -void DialogueWindow::addKeyword(std::string keyWord) +void DialogueWindow::setKeywords(std::list keyWords) { - if(topicsList->findItemIndexWith(keyWord) == MyGUI::ITEM_NONE) + topicsList->removeAllItems(); + for(std::list::iterator it = keyWords.begin(); it != keyWords.end(); it++) { - topicsList->addItem(keyWord); - pTopicsText[keyWord] = " "; + topicsList->addItem(*it); } } diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 4520d4586e..7dfd7bb7f4 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -42,7 +42,7 @@ namespace MWGui void startDialogue(std::string npcName); void stopDialogue(); - void addKeyword(std::string keyWord); + void setKeywords(std::list keyWord); void removeKeyword(std::string keyWord); void addText(std::string text); void addTitle(std::string text); From d4f3430fc66e8bc5db5c2035235a23ff43564485 Mon Sep 17 00:00:00 2001 From: gugus Date: Mon, 19 Mar 2012 19:17:20 +0100 Subject: [PATCH 62/77] fix: topics who should not be displayed are not displayed anymore. --- apps/openmw/mwdialogue/dialoguemanager.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 7950a78881..ef68226436 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -517,7 +517,6 @@ namespace MWDialogue return false; // TODO check DATAstruct - for (std::vector::const_iterator iter (info.selects.begin()); iter != info.selects.end(); ++iter) if (!isMatching (actor, *iter)) @@ -691,7 +690,8 @@ namespace MWDialogue void DialogueManager::updateTopics() { std::list keywordList; - + int choice = mChoice; + mChoice = -1; actorKnownTopics.clear(); MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; @@ -703,7 +703,7 @@ namespace MWDialogue for (std::vector::const_iterator iter (it->second.mInfo.begin()); iter!=it->second.mInfo.end(); ++iter) { - if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,false)) + if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) { actorKnownTopics.push_back(it->first); //does the player know the topic? @@ -717,6 +717,7 @@ namespace MWDialogue } } win->setKeywords(keywordList); + mChoice = choice; } void DialogueManager::keywordSelected(std::string keyword) @@ -726,10 +727,9 @@ namespace MWDialogue if(mDialogueMap.find(keyword) != mDialogueMap.end()) { ESM::Dialogue ndialogue = mDialogueMap[keyword]; - std::vector::const_iterator iter; if(ndialogue.type == ESM::Dialogue::Topic) { - for (iter = ndialogue.mInfo.begin(); + for (std::vector::const_iterator iter = ndialogue.mInfo.begin(); iter!=ndialogue.mInfo.end(); ++iter) { if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) @@ -753,6 +753,7 @@ namespace MWDialogue } } } + std::cout << std::endl << std::endl; updateTopics(); } From 82c4bfbf18c2ec95a3d5aed46c9245b7cb638f55 Mon Sep 17 00:00:00 2001 From: Michael Papageorgiou Date: Mon, 19 Mar 2012 20:18:08 +0200 Subject: [PATCH 63/77] Add a notification when the journal is updated --- apps/openmw/mwdialogue/journal.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journal.cpp index 42cce5cf55..c272de6050 100644 --- a/apps/openmw/mwdialogue/journal.cpp +++ b/apps/openmw/mwdialogue/journal.cpp @@ -3,6 +3,9 @@ #include "../mwworld/environment.hpp" +#include "../mwgui/window_manager.hpp" +#include "../mwgui/messagebox.hpp" + namespace MWDialogue { Quest& Journal::getQuest (const std::string& id) @@ -34,6 +37,10 @@ namespace MWDialogue Quest& quest = getQuest (id); quest.addEntry (entry, *mEnvironment.mWorld); // we are doing slicing on purpose here + + std::vector empty; + std::string notification = "Your Journal has been updated."; + mEnvironment.mWindowManager->messageBox (notification, empty); } void Journal::setJournalIndex (const std::string& id, int index) From f2a47d421b30b43be8eed9dd549c921494f6f904 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 19 Mar 2012 19:21:08 +0100 Subject: [PATCH 64/77] some cleanup --- apps/openmw/mwdialogue/dialoguemanager.cpp | 21 +++++---------------- apps/openmw/mwgui/dialogue.cpp | 7 ++----- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 7950a78881..dd57dfda07 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -168,11 +168,11 @@ namespace MWDialogue if(!selectCompare(comp,0,select.i)) return false; break; - case 40://PC Common Disease + case 40://PC Common Disease if(!selectCompare(comp,0,select.i)) return false; break; - case 41://PC Blight Disease + case 41://PC Blight Disease if(!selectCompare(comp,0,select.i)) return false; break; @@ -340,7 +340,7 @@ namespace MWDialogue } return true; - + case '6'://dead if(!selectCompare(comp,0,select.i)) return false; @@ -390,7 +390,6 @@ namespace MWDialogue { ESMS::LiveCellRef* npc = actor.get(); int isRace = int(toLower(npc->base->race) == toLower(name)); - //std::cout << "isRace"<(comp,!isRace,select.i)) return false; } @@ -523,14 +522,6 @@ namespace MWDialogue if (!isMatching (actor, *iter)) return false; - /*std::cout - << "unchecked entries:" << std::endl - << " player faction: " << info.pcFaction << std::endl - << " disposition: " << info.data.disposition << std::endl - << " NPC rank: " << static_cast (info.data.rank) << std::endl - << " gender: " << static_cast (info.data.gender) << std::endl - << " PC rank: " << static_cast (info.data.PCrank) << std::endl;*/ - return true; } @@ -553,7 +544,6 @@ namespace MWDialogue std::list::iterator it; for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) { - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); size_t pos = find_str_ci(text,*it,0); if(pos !=std::string::npos) { @@ -574,7 +564,6 @@ namespace MWDialogue { mChoice = -1; mIsInChoice = false; - std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl; mActor = actor; @@ -585,7 +574,7 @@ namespace MWDialogue { mDialogueMap[it->first] = it->second; } - + //initialise the GUI mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue); MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); @@ -743,7 +732,7 @@ namespace MWDialogue win->addTitle(keyword); win->addText(iter->response); - executeScript(script); + executeScript(script); mLastTopic = keyword; mLastDialogue = *iter; diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 5ab8604431..cef47d074e 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -51,7 +51,7 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager,MWWorld::Environm history->setOverflowToTheLeft(true); history->getClient()->eventMouseButtonClick = MyGUI::newDelegate(this, &DialogueWindow::onHistoryClicked); history->setMaxTextLength(1000000); - //Topics list + //Topics list getWidget(topicsList, "TopicsList"); topicsList->setScrollVisible(true); //topicsList->eventListSelectAccept = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); @@ -64,7 +64,6 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager,MWWorld::Environm getWidget(pDispositionBar, "Disposition"); getWidget(pDispositionText,"DispositionText"); - std::cout << "creation dialogue"; } void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) @@ -126,7 +125,6 @@ void DialogueWindow::removeKeyword(std::string keyWord) { if(topicsList->findItemIndexWith(keyWord) != MyGUI::ITEM_NONE) { - std::cout << topicsList->findItemIndexWith(keyWord); topicsList->removeItemAt(topicsList->findItemIndexWith(keyWord)); pTopicsText.erase(keyWord); } @@ -145,7 +143,7 @@ void addColorInString(std::string& str, const std::string& keyword,std::string c str.insert(pos,color2); pos+= color2.length(); } - else + else { if(str.substr(pos -1,1) == " ") { @@ -200,4 +198,3 @@ void DialogueWindow::updateOptions() pDispositionText->eraseText(0,pDispositionText->getTextLength()); pDispositionText->addText("#B29154"+std::string("40/100")+"#B29154"); } - From a9759c3f33c191e49a4b0775d5a4c8e0086f366f Mon Sep 17 00:00:00 2001 From: Roman Melnik Date: Mon, 19 Mar 2012 21:01:00 +0200 Subject: [PATCH 65/77] Fix bug #192: Remove the focus from the console when console is closed (set current keyFocusWidget to nullptr) --- apps/openmw/mwgui/console.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 3fd6e7892e..c16bbf0847 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -139,6 +139,9 @@ namespace MWGui void Console::disable() { setVisible(false); + // Remove keyboard focus from the console input whenever the + // console is turned off + MyGUI::InputManager::getInstance().setKeyFocusWidget(nullptr); } void Console::setFont(const std::string &fntName) From 88979577dbb9c811212182678b22fbd9f10c1194 Mon Sep 17 00:00:00 2001 From: Roman Melnik Date: Mon, 19 Mar 2012 21:45:53 +0200 Subject: [PATCH 66/77] Change 'nullptr' to 'NULL' (after fixing bug#192 in previous commit) --- apps/openmw/mwgui/console.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index c16bbf0847..0a5197c608 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -141,7 +141,7 @@ namespace MWGui setVisible(false); // Remove keyboard focus from the console input whenever the // console is turned off - MyGUI::InputManager::getInstance().setKeyFocusWidget(nullptr); + MyGUI::InputManager::getInstance().setKeyFocusWidget(NULL); } void Console::setFont(const std::string &fntName) From fc959172533fe9b1a5059bef0fbd43ea6ba3e28a Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski Date: Mon, 19 Mar 2012 20:54:30 +0100 Subject: [PATCH 67/77] Fix for not visible pthreads function with glibc 2.15 Linking error will appear: Linking CXX executable ../../openmw /usr/bin/ld: CMakeFiles/openmw.dir/__/__/components/bsa/bsa_archive.cpp.o: undefined reference to symbol 'pthread_mutexattr_settype@@GLIBC_2.2.5' /usr/bin/ld: note: 'pthread_mutexattr_settype@@GLIBC_2.2.5' is defined in DSO /lib/libpthread.so.0 so try adding it to the linker command line /lib/libpthread.so.0: could not read symbols: Invalid operation collect2: ld returned 1 exit status if we don't add explicitly pthreads library to linker flags after update glibc to version 2.15 on (Arch) Linux. Signed-off-by: Lukasz Gromanowski --- CMakeLists.txt | 5 +++++ apps/openmw/CMakeLists.txt | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08ce829f65..ab299b5491 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,6 +186,11 @@ endif (APPLE) # Dependencies +# Fix for not visible pthreads functions for linker with glibc 2.15 +if (UNIX AND NOT APPLE) +find_package (Threads) +endif() + find_package(OGRE REQUIRED) find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread) find_package(OIS REQUIRED) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 6d33298dfe..4edc08ba6a 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -81,7 +81,7 @@ add_definitions(${SOUND_DEFINE}) target_link_libraries(openmw ${OGRE_LIBRARIES} - ${OGRE_STATIC_PLUGINS} + ${OGRE_STATIC_PLUGINS} ${OIS_LIBRARIES} ${Boost_LIBRARIES} ${OPENAL_LIBRARY} @@ -92,6 +92,11 @@ target_link_libraries(openmw MyGUIOgrePlatform ) +# Fix for not visible pthreads functions for linker with glibc 2.15 +if (UNIX AND NOT APPLE) +target_link_libraries(openmw ${CMAKE_THREAD_LIBS_INIT}) +endif() + if(APPLE) find_library(CARBON_FRAMEWORK Carbon) target_link_libraries(openmw ${CARBON_FRAMEWORK}) From 04c6f23a2b44abead632e0cd9d9e13ae60d67862 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 19 Mar 2012 22:54:04 +0100 Subject: [PATCH 68/77] disabled solstheim weather (we can't travel there anyway) also, there was a bug that could cause this weather to show up on morrowind, which is fixed now --- apps/openmw/mwworld/weather.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 044d6e83a7..9a918c2fb3 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -271,7 +271,8 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environmen blight.mGlareView = 0; blight.mAmbientLoopSoundID = "blight"; mWeatherSettings["blight"] = blight; - + + /* Weather snow; snow.mCloudTexture = "tx_bm_sky_snow.dds"; snow.mCloudsMaximumPercent = 1.0; @@ -328,6 +329,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environmen blizzard.mGlareView = 0; blizzard.mAmbientLoopSoundID = "BM Blizzard"; mWeatherSettings["blizzard"] = blizzard; + */ } void WeatherManager::setWeather(const String& weather, bool instant) @@ -509,32 +511,32 @@ void WeatherManager::update(float duration) float thunder = region->data.thunder/255.f; float ash = region->data.ash/255.f; float blight = region->data.blight/255.f; - float snow = region->data.a/255.f; - float blizzard = region->data.b/255.f; + //float snow = region->data.a/255.f; + //float blizzard = region->data.b/255.f; // re-scale to 100 percent - const float total = clear+cloudy+foggy+overcast+rain+thunder+ash+blight+snow+blizzard; + const float total = clear+cloudy+foggy+overcast+rain+thunder+ash+blight;//+snow+blizzard; srand(time(NULL)); float random = ((rand()%100)/100.f) * total; - if (random >= snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear) - weather = "blizzard"; - else if (random >= blight+ash+thunder+rain+overcast+foggy+cloudy+clear) - weather = "snow"; - else if (random >= ash+thunder+rain+overcast+foggy+cloudy+clear) + //if (random > snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear) + // weather = "blizzard"; + //else if (random > blight+ash+thunder+rain+overcast+foggy+cloudy+clear) + // weather = "snow"; + /*else*/ if (random > ash+thunder+rain+overcast+foggy+cloudy+clear) weather = "blight"; - else if (random >= thunder+rain+overcast+foggy+cloudy+clear) + else if (random > thunder+rain+overcast+foggy+cloudy+clear) weather = "ashstorm"; - else if (random >= rain+overcast+foggy+cloudy+clear) + else if (random > rain+overcast+foggy+cloudy+clear) weather = "thunderstorm"; - else if (random >= overcast+foggy+cloudy+clear) + else if (random > overcast+foggy+cloudy+clear) weather = "rain"; - else if (random >= foggy+cloudy+clear) + else if (random > foggy+cloudy+clear) weather = "overcast"; - else if (random >= cloudy+clear) + else if (random > cloudy+clear) weather = "foggy"; - else if (random >= clear) + else if (random > clear) weather = "cloudy"; else weather = "clear"; From 0b517d15c14e19ce9cc4d9a14c9e1df41dc085c3 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Tue, 20 Mar 2012 02:49:59 +0100 Subject: [PATCH 69/77] Made missing data files dialog less scary and added exception handling for esmreader --- apps/launcher/datafilespage.cpp | 105 +++++++++++++++++--------------- 1 file changed, 56 insertions(+), 49 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 054cbf1414..c96fc2c7b6 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -222,7 +222,7 @@ void DataFilesPage::setupDataFiles() QMessageBox msgBox; msgBox.setWindowTitle("Error detecting Morrowind installation"); - msgBox.setIcon(QMessageBox::Critical); + msgBox.setIcon(QMessageBox::Warning); msgBox.setStandardButtons(QMessageBox::Cancel); msgBox.setText(tr("
Could not find the Data Files location

\ The directory containing the Data Files was not found.

\ @@ -279,72 +279,79 @@ void DataFilesPage::setupDataFiles() const Files::MultiDirCollection &esp = fileCollections.getCollection(".esp"); for (Files::MultiDirCollection::TIter iter(esp.begin()); iter!=esp.end(); ++iter) { - ESMReader fileReader; - QStringList availableMasters; // Will contain all found masters - fileReader.setEncoding(variables["encoding"].as()); - fileReader.open(iter->second.string()); + try { + ESMReader fileReader; + QStringList availableMasters; // Will contain all found masters + + fileReader.setEncoding(variables["encoding"].as()); + fileReader.open(iter->second.string()); - // First we fill the availableMasters and the mMastersWidget - ESMReader::MasterList mlist = fileReader.getMasters(); + // First we fill the availableMasters and the mMastersWidget + ESMReader::MasterList mlist = fileReader.getMasters(); - for (unsigned int i = 0; i < mlist.size(); ++i) { - const QString currentMaster = QString::fromStdString(mlist[i].name); - availableMasters.append(currentMaster); + for (unsigned int i = 0; i < mlist.size(); ++i) { + const QString currentMaster = QString::fromStdString(mlist[i].name); + availableMasters.append(currentMaster); - const QList itemList = mMastersWidget->findItems(currentMaster, Qt::MatchExactly); + const QList itemList = mMastersWidget->findItems(currentMaster, Qt::MatchExactly); - if (itemList.isEmpty()) { // Master is not yet in the widget - mMastersWidget->insertRow(i); + if (itemList.isEmpty()) { // Master is not yet in the widget + mMastersWidget->insertRow(i); - QTableWidgetItem *item = new QTableWidgetItem(currentMaster); - item->setForeground(Qt::red); - item->setFlags(item->flags() & ~(Qt::ItemIsSelectable)); + QTableWidgetItem *item = new QTableWidgetItem(currentMaster); + item->setForeground(Qt::red); + item->setFlags(item->flags() & ~(Qt::ItemIsSelectable)); - mMastersWidget->setItem(i, 0, item); + mMastersWidget->setItem(i, 0, item); + } } - } - availableMasters.sort(); // Sort the masters alphabetically + availableMasters.sort(); // Sort the masters alphabetically - // Now we put the current plugin in the mDataFilesModel under its masters - QStandardItem *parent = new QStandardItem(availableMasters.join(",")); + // Now we put the current plugin in the mDataFilesModel under its masters + QStandardItem *parent = new QStandardItem(availableMasters.join(",")); - QString fileName = QString::fromStdString(boost::filesystem::path (iter->second.filename()).string()); - QStandardItem *child = new QStandardItem(fileName); + QString fileName = QString::fromStdString(boost::filesystem::path (iter->second.filename()).string()); + QStandardItem *child = new QStandardItem(fileName); - // Tooltip information - QString author = QString::fromStdString(fileReader.getAuthor()); - float version = fileReader.getFVer(); - QString description = QString::fromStdString(fileReader.getDesc()); + // Tooltip information + QString author = QString::fromStdString(fileReader.getAuthor()); + float version = fileReader.getFVer(); + QString description = QString::fromStdString(fileReader.getDesc()); - // For the date created/modified - QFileInfo fi(QString::fromStdString(iter->second.string())); + // For the date created/modified + QFileInfo fi(QString::fromStdString(iter->second.string())); - QString toolTip= QString("Author: %1
\ - Version: %2

\ - Description:
\ - %3

\ - Created on: %4
\ - Last modified: %5") - .arg(author) - .arg(version) - .arg(description) - .arg(fi.created().toString(Qt::TextDate)) - .arg(fi.lastModified().toString(Qt::TextDate)); + QString toolTip= QString("Author: %1
\ + Version: %2

\ + Description:
\ + %3

\ + Created on: %4
\ + Last modified: %5") + .arg(author) + .arg(version) + .arg(description) + .arg(fi.created().toString(Qt::TextDate)) + .arg(fi.lastModified().toString(Qt::TextDate)); - child->setToolTip(toolTip); + child->setToolTip(toolTip); - const QList masterList = mDataFilesModel->findItems(availableMasters.join(",")); + const QList masterList = mDataFilesModel->findItems(availableMasters.join(",")); - if (masterList.isEmpty()) { // Masters node not yet in the mDataFilesModel - parent->appendRow(child); - mDataFilesModel->appendRow(parent); - } else { - // Masters node exists, append current plugin - foreach (QStandardItem *currentItem, masterList) { - currentItem->appendRow(child); + if (masterList.isEmpty()) { // Masters node not yet in the mDataFilesModel + parent->appendRow(child); + mDataFilesModel->appendRow(parent); + } else { + // Masters node exists, append current plugin + foreach (QStandardItem *currentItem, masterList) { + currentItem->appendRow(child); + } } + + } catch(std::runtime_error &e) { + // An error occurred while reading the .esp + continue; } } From 42584b013fa265f029ffd9686e1dd782f1d1f9f7 Mon Sep 17 00:00:00 2001 From: Brother Brick Date: Tue, 20 Mar 2012 09:43:48 +0100 Subject: [PATCH 70/77] Updated dependency to match our PPA --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08ce829f65..7cbc9b12f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -322,7 +322,7 @@ if(DPKG_PROGRAM) SET(CPACK_DEBIAN_PACKAGE_NAME "openmw") SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}") SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW esmtool;Esmtool omwlauncher;OMWLauncher") - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libogre-1.7.3 (>= 1.7.3), libbullet0 (>= 2.77), libboost-filesystem1.46.1 (>= 1.46.1), libboost-program-options1.46.1 (>= 1.46.1), libboost-system1.46.1 (>= 1.46.1), libboost-thread1.46.1 (>= 1.46.1), libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.3.0 (>= 1.3.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2), libqtgui4 (>= 4.7.0)") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libogre-1.7.4 (>= 1.7.4), libbullet0 (>= 2.77), libboost-filesystem1.46.1 (>= 1.46.1), libboost-program-options1.46.1 (>= 1.46.1), libboost-system1.46.1 (>= 1.46.1), libboost-thread1.46.1 (>= 1.46.1), libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.3.0 (>= 1.3.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2), libqtgui4 (>= 4.7.0)") SET(CPACK_DEBIAN_PACKAGE_SECTION "Games") From b6b972b73b6ee259293edcf76705d0443309cc88 Mon Sep 17 00:00:00 2001 From: Brother Brick Date: Tue, 20 Mar 2012 09:53:39 +0100 Subject: [PATCH 71/77] Removed libbullet and libogre dependencies and added nvidia-toolkit. We are releasing OpenMW based on static libraries, so the first two are no longer necessary --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cbc9b12f6..5fc9cd1662 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -322,7 +322,7 @@ if(DPKG_PROGRAM) SET(CPACK_DEBIAN_PACKAGE_NAME "openmw") SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}") SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW esmtool;Esmtool omwlauncher;OMWLauncher") - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libogre-1.7.4 (>= 1.7.4), libbullet0 (>= 2.77), libboost-filesystem1.46.1 (>= 1.46.1), libboost-program-options1.46.1 (>= 1.46.1), libboost-system1.46.1 (>= 1.46.1), libboost-thread1.46.1 (>= 1.46.1), libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.3.0 (>= 1.3.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2), libqtgui4 (>= 4.7.0)") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "nvidia-cg-toolkit (>= 2.1), libboost-filesystem1.46.1 (>= 1.46.1), libboost-program-options1.46.1 (>= 1.46.1), libboost-system1.46.1 (>= 1.46.1), libboost-thread1.46.1 (>= 1.46.1), libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.3.0 (>= 1.3.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2), libqtgui4 (>= 4.7.0)") SET(CPACK_DEBIAN_PACKAGE_SECTION "Games") From c3494326dbac6bf1f20a55f7354a53b22ae48737 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 20 Mar 2012 10:08:16 +0100 Subject: [PATCH 72/77] adjusted changelog --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index 149fd4f193..cb91faea2c 100644 --- a/readme.txt +++ b/readme.txt @@ -140,6 +140,7 @@ Bug #203: Torch lights only visible on short distance Bug #207: Ogre.log not written Bug #209: Sounds do not play Bug #210: Ogre crash at Dren plantation +Bug #214: Unsupported file format version Feature #9: NPC Dialogue Window Feature #16/42: New sky/weather implementation Feature #40: Fading From 6a0474a977989ab3d9e5a308005d5b14d482fde2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 20 Mar 2012 10:15:22 +0100 Subject: [PATCH 73/77] removed some cout spam --- apps/openmw/mwdialogue/dialoguemanager.cpp | 2 +- apps/openmw/mwgui/messagebox.cpp | 121 ++++++++++----------- 2 files changed, 58 insertions(+), 65 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 91785819f9..82a28ab502 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -742,7 +742,7 @@ namespace MWDialogue } } } - std::cout << std::endl << std::endl; + updateTopics(); } diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index f0745bbbec..cd32fc40f8 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -19,7 +19,7 @@ void MessageBoxManager::onFrame (float frameDuration) if(it->current >= it->max) { it->messageBox->mMarkedToDelete = true; - + if(*mMessageBoxes.begin() == it->messageBox) // if this box is the last one { // collect all with mMarkedToDelete and delete them. @@ -47,7 +47,7 @@ void MessageBoxManager::onFrame (float frameDuration) it++; } } - + if(mInterMessageBoxe != NULL && mInterMessageBoxe->mMarkedToDelete) { delete mInterMessageBoxe; mInterMessageBoxe = NULL; @@ -57,20 +57,18 @@ void MessageBoxManager::onFrame (float frameDuration) void MessageBoxManager::createMessageBox (const std::string& message) { - std::cout << "MessageBox: " << message << std::endl; - MessageBox *box = new MessageBox(*this, message); - + removeMessageBox(message.length()*mMessageBoxSpeed, box); - + mMessageBoxes.push_back(box); std::vector::iterator it; - + if(mMessageBoxes.size() > 3) { delete *mMessageBoxes.begin(); mMessageBoxes.erase(mMessageBoxes.begin()); } - + int height = 0; for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); ++it) { @@ -88,9 +86,9 @@ bool MessageBoxManager::createInteractiveMessageBox (const std::string& message, std::cout << "interactive MessageBox: " << message << " - "; std::copy (buttons.begin(), buttons.end(), std::ostream_iterator (std::cout, ", ")); std::cout << std::endl; - + mInterMessageBoxe = new InteractiveMessageBox(*this, message, buttons); - + return true; } @@ -105,7 +103,7 @@ void MessageBoxManager::removeMessageBox (float time, MessageBox *msgbox) timer.current = 0; timer.max = time; timer.messageBox = msgbox; - + mTimers.insert(mTimers.end(), timer); } @@ -152,25 +150,25 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin mBottomPadding = 20; mNextBoxPadding = 20; mMarkedToDelete = false; - + getWidget(mMessageWidget, "message"); - + mMessageWidget->setOverflowToTheLeft(true); mMessageWidget->addText(cMessage); - + MyGUI::IntSize size; size.width = mFixedWidth; size.height = 100; // dummy - + MyGUI::IntCoord coord; coord.left = 10; // dummy coord.top = 10; // dummy mMessageWidget->setSize(size); - + MyGUI::IntSize textSize = mMessageWidget->_getTextSize(); size.height = mHeight = textSize.height + 20; // this is the padding between the text and the box - + mMainWidget->setSize(size); size.width -= 15; // this is to center the text (see messagebox_layout.xml, Widget type="Edit" position="-2 -3 0 0") mMessageWidget->setSize(size); @@ -182,11 +180,11 @@ void MessageBox::update (int height) MyGUI::IntCoord coord; coord.left = (gameWindowSize.width - mFixedWidth)/2; coord.top = (gameWindowSize.height - mHeight - height - mBottomPadding); - + MyGUI::IntSize size; size.width = mFixedWidth; size.height = mHeight; - + mMainWidget->setCoord(coord); mMainWidget->setSize(size); mMainWidget->setVisible(true); @@ -211,26 +209,26 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan int buttonTopPadding = 5; // ^-- if vertical int buttonPadding = 5; // padding between button label and button itself int buttonMainPadding = 10; // padding between buttons and bottom of the main widget - + mMarkedToDelete = false; - - + + getWidget(mMessageWidget, "message"); getWidget(mButtonsWidget, "buttons"); - + mMessageWidget->setOverflowToTheLeft(true); mMessageWidget->addText(message); - + MyGUI::IntSize textSize = mMessageWidget->_getTextSize(); - + MyGUI::IntSize gameWindowSize = mMessageBoxManager.mWindowManager->getGui()->getViewSize(); - + int biggestButtonWidth = 0; int buttonWidth = 0; int buttonsWidth = 0; int buttonHeight = 0; MyGUI::IntCoord dummyCoord(0, 0, 0, 0); - + std::vector::const_iterator it; for(it = buttons.begin(); it != buttons.end(); ++it) { @@ -240,28 +238,28 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan dummyCoord, MyGUI::Align::Default); button->setCaption(*it); - - button->eventMouseButtonClick = MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed); - + + button->eventMouseButtonClick = MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed); + mButtons.push_back(button); - + buttonWidth = button->_getTextSize().width + 2*buttonPadding + buttonLeftPadding; buttonsWidth += buttonWidth; buttonHeight = button->_getTextSize().height + 2*buttonPadding + buttonTopPadding; - + if(buttonWidth > biggestButtonWidth) { biggestButtonWidth = buttonWidth; } } buttonsWidth += buttonLeftPadding; - + MyGUI::IntSize mainWidgetSize; if(buttonsWidth < fixedWidth) { // on one line std::cout << "on one line" << std::endl; - + if(textSize.width + 2*textPadding < buttonsWidth) { std::cout << "width = buttonsWidth" << std::endl; @@ -272,48 +270,48 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan mainWidgetSize.width = textSize.width + 3*textPadding; } mainWidgetSize.height = textSize.height + textButtonPadding + buttonHeight + buttonMainPadding; - + MyGUI::IntCoord absCoord; absCoord.left = (gameWindowSize.width - mainWidgetSize.width)/2; absCoord.top = (gameWindowSize.height - mainWidgetSize.height)/2; - + std::cout << "width " << mainWidgetSize.width << " height " << mainWidgetSize.height << std::endl; std::cout << "left " << absCoord.left << " top " << absCoord.top << std::endl; - + mMainWidget->setCoord(absCoord); mMainWidget->setSize(mainWidgetSize); - - + + MyGUI::IntCoord messageWidgetCoord; messageWidgetCoord.left = (mainWidgetSize.width - textSize.width)/2; messageWidgetCoord.top = textPadding; mMessageWidget->setCoord(messageWidgetCoord); - + mMessageWidget->setSize(textSize); - + MyGUI::IntCoord buttonCord; MyGUI::IntSize buttonSize(0, buttonHeight); int left = (mainWidgetSize.width - buttonsWidth)/2 + buttonPadding; - + std::vector::const_iterator button; for(button = mButtons.begin(); button != mButtons.end(); ++button) { buttonCord.left = left; buttonCord.top = textSize.height + textButtonPadding; - + buttonSize.width = (*button)->_getTextSize().width + 2*buttonPadding; buttonSize.height = (*button)->_getTextSize().height + 2*buttonPadding; - + (*button)->setCoord(buttonCord); (*button)->setSize(buttonSize); - + left += buttonSize.width + buttonLeftPadding; } } else { // among each other - + if(biggestButtonWidth > textSize.width) { mainWidgetSize.width = biggestButtonWidth + buttonTopPadding; } @@ -321,46 +319,46 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan mainWidgetSize.width = textSize.width + 3*textPadding; } mainWidgetSize.height = textSize.height + 2*textPadding + textButtonPadding + buttonHeight * buttons.size() + buttonMainPadding; - + std::cout << "biggestButtonWidth " << biggestButtonWidth << " textSize.width " << textSize.width << std::endl; std::cout << "width " << mainWidgetSize.width << " height " << mainWidgetSize.height << std::endl; mMainWidget->setSize(mainWidgetSize); - + MyGUI::IntCoord absCoord; absCoord.left = (gameWindowSize.width - mainWidgetSize.width)/2; absCoord.top = (gameWindowSize.height - mainWidgetSize.height)/2; - + mMainWidget->setCoord(absCoord); mMainWidget->setSize(mainWidgetSize); - - + + MyGUI::IntCoord messageWidgetCoord; messageWidgetCoord.left = (mainWidgetSize.width - textSize.width)/2; messageWidgetCoord.top = textPadding; mMessageWidget->setCoord(messageWidgetCoord); - + mMessageWidget->setSize(textSize); - + MyGUI::IntCoord buttonCord; MyGUI::IntSize buttonSize(0, buttonHeight); - + int top = textButtonPadding + buttonTopPadding + textSize.height; - + std::vector::const_iterator button; for(button = mButtons.begin(); button != mButtons.end(); ++button) { buttonSize.width = (*button)->_getTextSize().width + buttonPadding*2; buttonSize.height = (*button)->_getTextSize().height + buttonPadding*2; - + buttonCord.top = top; buttonCord.left = (mainWidgetSize.width - buttonSize.width)/2 - 5; // FIXME: -5 is not so nice :/ - + (*button)->setCoord(buttonCord); (*button)->setSize(buttonSize); - + top += buttonSize.height + 2*buttonTopPadding; } - + } } @@ -387,8 +385,3 @@ int InteractiveMessageBox::readPressedButton () mButtonPressed = -1; return pressed; } - - - - - From eed4441013a2201e377b08ff5580bcb9e60a13b2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 20 Mar 2012 10:22:01 +0100 Subject: [PATCH 74/77] adjusted changelog again --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index cb91faea2c..d58463ced9 100644 --- a/readme.txt +++ b/readme.txt @@ -134,6 +134,7 @@ Bug #179: Pressing space in console triggers activation Bug #186: CMake doesn't use the debug versions of Ogre libraries on Linux Bug #189: ASCII 16 character added to console on it's activation on Mac OS X Bug #190: Case Folding fails with music files +Bug #192: Keypresses write Text into Console no matter which gui element is active Bug #196: Collision shapes out of place Bug #202: ESMTool doesn't not work with localised ESM files anymore Bug #203: Torch lights only visible on short distance From 226d0b279e6b58217f69f07f09d781633a11ce96 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 20 Mar 2012 10:22:44 +0100 Subject: [PATCH 75/77] updated team list in readme.txt --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index d58463ced9..83624fefec 100644 --- a/readme.txt +++ b/readme.txt @@ -104,6 +104,7 @@ Marc “Zini” Zinnschlag Michael “werdanith” Papageorgiou Nikolay “corristo” Kasyanov Pieter “pvdk” van der Kloet +Roman "Kromgart" Melni Sebastian “swick” Wick Retired Developers: From 1023ddd5872ed594e5f601dc2544e89f272bc560 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 20 Mar 2012 10:30:21 +0100 Subject: [PATCH 76/77] silenced some warnings --- apps/openmw/mwdialogue/dialoguemanager.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 82a28ab502..50549f4a55 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -145,8 +145,6 @@ namespace MWDialogue bool DialogueManager::functionFilter(const MWWorld::Ptr& actor, const ESM::DialInfo& info,bool choice) { - bool isAChoice = false;//is there any choice in the filters? - bool isFunction = false; for (std::vector::const_iterator iter (info.selects.begin()); iter != info.selects.end(); ++iter) { @@ -154,7 +152,6 @@ namespace MWDialogue char type = select.selectRule[1]; if(type == '1') { - isFunction = true; char comp = select.selectRule[4]; std::string name = select.selectRule.substr (5); std::string function = select.selectRule.substr(2,2); @@ -193,7 +190,7 @@ namespace MWDialogue break; case 50://choice - isAChoice = true; + if(choice) { if(!selectCompare(comp,mChoice,select.i)) return false; From f1f6e214425cba905be0f880cae7503deef982ec Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 20 Mar 2012 10:33:43 +0100 Subject: [PATCH 77/77] fixed a copy & paste error --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 83624fefec..d53ec379c9 100644 --- a/readme.txt +++ b/readme.txt @@ -104,7 +104,7 @@ Marc “Zini” Zinnschlag Michael “werdanith” Papageorgiou Nikolay “corristo” Kasyanov Pieter “pvdk” van der Kloet -Roman "Kromgart" Melni +Roman "Kromgart" Melnik Sebastian “swick” Wick Retired Developers: