Merge remote branch 'gus/DialogueSystem' into dialogue

pull/21/head
Marc Zinnschlag 12 years ago
commit d9945a976d

@ -9,6 +9,7 @@
#include <components/esm_store/store.hpp>
#include "../mwworld/class.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
@ -16,6 +17,10 @@
#include "../mwworld/player.hpp"
#include "../mwinput/inputmanager.hpp"
#include "../mwgui/dialogue.hpp"
#include "../mwgui/window_manager.hpp"
#include "journal.hpp"
#include <iostream>
@ -31,6 +36,7 @@ namespace
return lowerCase;
}
template<typename T1, typename T2>
bool selectCompare (char comp, T1 value1, T2 value2)
{
@ -115,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
{
@ -126,7 +140,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
@ -167,12 +181,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<MWDialogue::StampedJournalEntry>::const_iterator it = mEnvironment.mJournal->begin();it!=mEnvironment.mJournal->end();it++)
{
if(it->mTopic == name) isInJournal = true;
}
}
else
isInJournal = false;
if(!selectCompare<int,int>(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<int,int>(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<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
int isFaction = int(toLower(npc->base->faction) == toLower(name));
if(selectCompare<int,int>(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<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
int isClass = int(toLower(npc->base->cls) == toLower(name));
if(selectCompare<int,int>(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<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
int isRace = int(toLower(npc->base->race) == toLower(name));
//std::cout << "isRace"<<isRace; mEnvironment.mWorld
if(selectCompare<int,int>(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<int,int>(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;
@ -184,11 +308,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<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
@ -200,6 +326,7 @@ namespace MWDialogue
return false;
}
//NPC class
if (!info.clas.empty())
{
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
@ -211,6 +338,7 @@ namespace MWDialogue
return false;
}
//NPC faction
if (!info.npcFaction.empty())
{
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
@ -220,10 +348,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<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
if(npc->base->flags&npc->base->Female)
{
if(static_cast<int> (info.data.gender)==0) return false;
}
else
{
if(static_cast<int> (info.data.gender)==1) return false;
}
// check cell
if (!info.cell.empty())
if (mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell->name != info.cell)
@ -236,50 +386,126 @@ namespace MWDialogue
if (!isMatching (actor, *iter))
return false;
std::cout
/*std::cout
<< "unchecked entries:" << std::endl
<< " player faction: " << info.pcFaction << std::endl
<< " disposition: " << info.data.disposition << std::endl
<< " NPC rank: " << static_cast<int> (info.data.rank) << std::endl
<< " gender: " << static_cast<int> (info.data.gender) << std::endl
<< " PC rank: " << static_cast<int> (info.data.PCrank) << std::endl;
<< " PC rank: " << static_cast<int> (info.data.PCrank) << std::endl;*/
return true;
}
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;
const ESM::Dialogue *dialogue = mEnvironment.mWorld->getStore().dialogs.find ("hello");
//initialise the GUI
mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue);
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
win->startDialogue(MWWorld::Class::get (actor).getName (actor));
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter)
actorKnownTopics.clear();
ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
for(ESMS::RecListT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
{
if (isMatching (actor, *iter))
ESM::Dialogue ndialogue = it->second;
if(ndialogue.type == ESM::Dialogue::Type::Topic)
{
// start dialogue
std::cout << "found matching info record" << std::endl;
std::cout << "response: " << iter->response << std::endl;
if (!iter->sound.empty())
for (std::vector<ESM::DialInfo>::const_iterator iter (it->second.mInfo.begin());
iter!=it->second.mInfo.end(); ++iter)
{
// TODO play sound
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;
}
}
}
}
}
//ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
if (!iter->resultScript.empty())
bool greetingFound = false;
for(ESMS::RecListT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
{
ESM::Dialogue ndialogue = it->second;
if(ndialogue.type == ESM::Dialogue::Type::Greeting)
{
if (greetingFound) break;
for (std::vector<ESM::DialInfo>::const_iterator iter (it->second.mInfo.begin());
iter!=it->second.mInfo.end(); ++iter)
{
std::cout << "script: " << iter->resultScript << std::endl;
// TODO execute script
if (isMatching (actor, *iter))
{
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<std::string,std::string>::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;
}
}
}
}
}
mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue);
break;
void DialogueManager::keywordSelected(std::string keyword)
{
std::string text = actorKnownTopics[keyword];
std::map<std::string,std::string>::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);
}
}
}
void DialogueManager::goodbyeSelected()
{
mEnvironment.mInputManager->setGuiMode(MWGui::GM_Game);
}
void DialogueManager::questionAnswered(std::string answere)
{
std::cout << "and the ansere is..."<< answere;
}
}

@ -4,6 +4,7 @@
#include <components/esm/loadinfo.hpp>
#include "../mwworld/ptr.hpp"
#include <map>
namespace MWWorld
{
@ -20,12 +21,22 @@ namespace MWDialogue
bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const;
std::map<std::string,bool> knownTopics;// Those are the topics the player knows.
std::map<std::string,std::string> actorKnownTopics;
public:
DialogueManager (MWWorld::Environment& environment);
void startDialogue (const MWWorld::Ptr& actor);
void addTopic(std::string topic);
//calbacks for the GUI
void keywordSelected(std::string keyword);
void goodbyeSelected();
void questionAnswered(std::string answere);
};
}

@ -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 <assert.h>
#include <iostream>
@ -14,32 +16,55 @@
using namespace MWGui;
using namespace Widgets;
DialogueWindow::DialogueWindow(WindowManager& parWindowManager)
: WindowBase("openmw_dialogue_window_layout.xml", parWindowManager)
/**
*Copied from the internet.
*/
std::string lower_string(const std::string& str)
{
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)
{
return lower_string(str).find(lower_string(substr),pos);
}
DialogueWindow::DialogueWindow(WindowManager& parWindowManager,MWWorld::Environment& environment)
: WindowBase("openmw_dialogue_window_layout.xml", parWindowManager),
mEnvironment(environment)
{
// 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);
history->setMaxTextLength(1000000);
//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();
getWidget(pDispositionBar, "Disposition");
getWidget(pDispositionText,"DispositionText");
std::cout << "creation dialogue";
}
void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender)
@ -51,50 +76,160 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender)
const IntPoint& lastPressed = InputManager::getInstance().getLastLeftPressed();
size_t cursorPosition = t->getCursorPosition(lastPressed);
if(history->getColorAtPos(cursorPosition) != "#FFFFFF")
MyGUI::UString color = history->getColorAtPos(cursorPosition);
if(color != "#B29154")
{
UString key = history->getColorTextAt(cursorPosition);
std::cout << "Clicked on key: " << key << std::endl;
//eventTopicSelected(key);
//std::cout << "Clicked on key: " << key << std::endl;
if(color == "#686EBA")
{
mEnvironment.mDialogueManager->keywordSelected(lower_string(key));
displayTopicText(lower_string(key));
}
if(color == "#572D21")
{
//TODO: send back the answere to the question!
mEnvironment.mDialogueManager->questionAnswered(key);
//std::cout << "and the ansere is..."<< key;
}
}
}
void DialogueWindow::open()
{
//updateOptions();
topicsList->removeAllItems();
pTopicsText.clear();
history->eraseText(0,history->getTextLength());
updateOptions();
setVisible(true);
}
void DialogueWindow::onByeClicked(MyGUI::Widget* _sender)
{
eventBye();
//eventBye();
mEnvironment.mDialogueManager->goodbyeSelected();
}
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<std::string>(_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);
}
}
void addColorInString(std::string& str, const std::string& keyword,std::string color1, std::string color2)
{
size_t pos = 0;
while((pos = find_str_ci(str,keyword, pos)) != std::string::npos)
{
//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();
}
}
std::string DialogueWindow::parseText(std::string text)
{
//topicsList->geti
for(int i = 0;i<topicsList->getItemCount();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(parseText(text));
}
void DialogueWindow::askQuestion(std::string question,std::list<std::string> answers)
{
history->addDialogText(parseText(question));
for(std::list<std::string>::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...");
/*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");*/
pDispositionBar->setProgressRange(100);
pDispositionBar->setProgressPosition(40);
pDispositionText->eraseText(0,pDispositionText->getTextLength());
pDispositionText->addText("#B29154"+std::string("40/100")+"#B29154");
/*std::list<std::string> test;
test.push_back("option 1");
test.push_back("option 2");
askQuestion("is gus cooking?",test);*/
/*topicsList->addItem("Ald'ruhn", i++);
topicsList->addItem("Balmora", i++);
topicsList->addItem("Sadrith Mora", i++);
topicsList->addItem("Vivec", i++);
@ -115,6 +250,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++);*/
}

@ -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();
@ -35,6 +40,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(std::string question,std::list<std::string> answers);
protected:
void onSelectTopic(MyGUI::List* _sender, size_t _index);
void onByeClicked(MyGUI::Widget* _sender);
@ -42,9 +54,19 @@ 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;
MyGUI::ProgressPtr pDispositionBar;
MyGUI::EditPtr pDispositionText;
std::map<std::string,std::string> pTopicsText;// this map links keyword and "real" text.
MWWorld::Environment& mEnvironment;
};
}
#endif

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

@ -51,6 +51,7 @@ WindowManager::WindowManager(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);
@ -149,6 +150,7 @@ void WindowManager::updateVisible()
stats->setVisible(false);
console->disable();
mJournal->setVisible(false);
dialogueWindow->setVisible(false);
// Mouse is visible whenever we're not in game mode
gui->setVisiblePointer(isGuiMode());
@ -195,11 +197,6 @@ void WindowManager::updateVisible()
if (mode == GM_Dialogue)
{
if (!dialogueWindow)
{
dialogueWindow = new DialogueWindow(*this);
dialogueWindow->eventBye = MyGUI::newDelegate(this, &WindowManager::onDialogueWindowBye);
}
dialogueWindow->open();
return;
}
@ -349,6 +346,7 @@ void WindowManager::updateSkillArea()
void WindowManager::removeDialog(OEngine::GUI::Layout*dialog)
{
std::cout << "dialogue a la poubelle";
assert(dialog);
if (!dialog)
return;
@ -387,7 +385,8 @@ void WindowManager::onDialogueWindowBye()
if (dialogueWindow)
{
//FIXME set some state and stuff?
removeDialog(dialogueWindow);
//removeDialog(dialogueWindow);
dialogueWindow->setVisible(false);
}
setGuiMode(GM_Game);
}

@ -124,6 +124,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)

@ -52,10 +52,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;
}
@ -202,12 +204,15 @@ void RenderingManager::configureAmbient(ESMS::CellStore<MWWorld::RefData> &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.

@ -118,6 +118,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

@ -8,6 +8,7 @@
#include <components/interpreter/opcodes.hpp>
#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<MWScript::InterpreterContext&> (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);
}
}

@ -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

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

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

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

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