|
|
|
@ -3,6 +3,8 @@
|
|
|
|
|
#include <MyGUI_LanguageManager.h>
|
|
|
|
|
#include <MyGUI_Window.h>
|
|
|
|
|
#include <MyGUI_ProgressBar.h>
|
|
|
|
|
#include <MyGUI_ScrollBar.h>
|
|
|
|
|
#include <MyGUI_Button.h>
|
|
|
|
|
|
|
|
|
|
#include <components/widgets/list.hpp>
|
|
|
|
|
#include <components/translation/translation.hpp>
|
|
|
|
@ -20,7 +22,6 @@
|
|
|
|
|
#include "../mwmechanics/creaturestats.hpp"
|
|
|
|
|
#include "../mwmechanics/actorutil.hpp"
|
|
|
|
|
|
|
|
|
|
#include "widgets.hpp"
|
|
|
|
|
#include "bookpage.hpp"
|
|
|
|
|
#include "textcolours.hpp"
|
|
|
|
|
|
|
|
|
@ -52,7 +53,7 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
void PersuasionDialog::onCancel(MyGUI::Widget *sender)
|
|
|
|
|
{
|
|
|
|
|
exit();
|
|
|
|
|
setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PersuasionDialog::onPersuade(MyGUI::Widget *sender)
|
|
|
|
@ -68,14 +69,15 @@ namespace MWGui
|
|
|
|
|
else /*if (sender == mBribe1000Button)*/
|
|
|
|
|
type = MWBase::MechanicsManager::PT_Bribe1000;
|
|
|
|
|
|
|
|
|
|
MWBase::Environment::get().getDialogueManager()->persuade(type);
|
|
|
|
|
MWBase::DialogueManager::Response response = MWBase::Environment::get().getDialogueManager()->persuade(type);
|
|
|
|
|
|
|
|
|
|
eventPersuadeMsg(response.first, response.second);
|
|
|
|
|
|
|
|
|
|
setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PersuasionDialog::open()
|
|
|
|
|
void PersuasionDialog::onOpen()
|
|
|
|
|
{
|
|
|
|
|
WindowModal::open();
|
|
|
|
|
center();
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
|
|
|
@ -86,11 +88,12 @@ namespace MWGui
|
|
|
|
|
mBribe1000Button->setEnabled (playerGold >= 1000);
|
|
|
|
|
|
|
|
|
|
mGoldLabel->setCaptionWithReplacing("#{sGold}: " + MyGUI::utility::toString(playerGold));
|
|
|
|
|
WindowModal::onOpen();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PersuasionDialog::exit()
|
|
|
|
|
MyGUI::Widget* PersuasionDialog::getDefaultKeyFocus()
|
|
|
|
|
{
|
|
|
|
|
setVisible(false);
|
|
|
|
|
return mAdmireButton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------------
|
|
|
|
@ -219,31 +222,27 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
void Choice::activated()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->playSound("Menu Click");
|
|
|
|
|
MWBase::Environment::get().getDialogueManager()->questionAnswered(mChoiceId);
|
|
|
|
|
eventChoiceActivated(mChoiceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Topic::activated()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->playSound("Menu Click");
|
|
|
|
|
MWBase::Environment::get().getDialogueManager()->keywordSelected(Misc::StringUtils::lowerCase(mTopicId));
|
|
|
|
|
eventTopicActivated(mTopicId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Goodbye::activated()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->playSound("Menu Click");
|
|
|
|
|
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
|
|
|
|
|
eventActivated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
DialogueWindow::DialogueWindow()
|
|
|
|
|
: WindowBase("openmw_dialogue_window.layout")
|
|
|
|
|
, mServices(0)
|
|
|
|
|
, mEnabled(false)
|
|
|
|
|
, mIsCompanion(false)
|
|
|
|
|
, mGoodbye(false)
|
|
|
|
|
, mPersuasionDialog()
|
|
|
|
|
{
|
|
|
|
@ -251,17 +250,17 @@ namespace MWGui
|
|
|
|
|
center();
|
|
|
|
|
|
|
|
|
|
mPersuasionDialog.setVisible(false);
|
|
|
|
|
mPersuasionDialog.eventPersuadeMsg += MyGUI::newDelegate(this, &DialogueWindow::onPersuadeResult);
|
|
|
|
|
|
|
|
|
|
//History view
|
|
|
|
|
getWidget(mHistory, "History");
|
|
|
|
|
|
|
|
|
|
//Topics list
|
|
|
|
|
getWidget(mTopicsList, "TopicsList");
|
|
|
|
|
mTopicsList->eventItemSelected += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic);
|
|
|
|
|
mTopicsList->eventItemSelected += MyGUI::newDelegate(this, &DialogueWindow::onSelectListItem);
|
|
|
|
|
|
|
|
|
|
MyGUI::Button* byeButton;
|
|
|
|
|
getWidget(byeButton, "ByeButton");
|
|
|
|
|
byeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onByeClicked);
|
|
|
|
|
getWidget(mGoodbyeButton, "ByeButton");
|
|
|
|
|
mGoodbyeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onByeClicked);
|
|
|
|
|
|
|
|
|
|
getWidget(mDispositionBar, "Disposition");
|
|
|
|
|
getWidget(mDispositionText,"DispositionText");
|
|
|
|
@ -276,18 +275,36 @@ namespace MWGui
|
|
|
|
|
mMainWidget->castType<MyGUI::Window>()->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::exit()
|
|
|
|
|
DialogueWindow::~DialogueWindow()
|
|
|
|
|
{
|
|
|
|
|
if ((!mEnabled || MWBase::Environment::get().getDialogueManager()->isInChoice())
|
|
|
|
|
&& !mGoodbye)
|
|
|
|
|
mPersuasionDialog.eventPersuadeMsg.clear();
|
|
|
|
|
|
|
|
|
|
deleteLater();
|
|
|
|
|
for (Link* link : mLinks)
|
|
|
|
|
delete link;
|
|
|
|
|
for (auto link : mTopicLinks)
|
|
|
|
|
delete link.second;
|
|
|
|
|
for (auto history : mHistoryContents)
|
|
|
|
|
delete history;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::onTradeComplete()
|
|
|
|
|
{
|
|
|
|
|
// in choice, not allowed to escape, but give access to main menu to allow loading other saves
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
|
|
|
|
|
addResponse("", MyGUI::LanguageManager::getInstance().replaceTags("#{sBarterDialog5}"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DialogueWindow::exit()
|
|
|
|
|
{
|
|
|
|
|
if ((MWBase::Environment::get().getDialogueManager()->isInChoice()))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
resetReference();
|
|
|
|
|
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
|
|
|
|
|
mTopicsList->scrollToTop();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -312,12 +329,13 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::onByeClicked(MyGUI::Widget* _sender)
|
|
|
|
|
{
|
|
|
|
|
exit();
|
|
|
|
|
if (exit())
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Dialogue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::onSelectTopic(const std::string& topic, int id)
|
|
|
|
|
void DialogueWindow::onSelectListItem(const std::string& topic, int id)
|
|
|
|
|
{
|
|
|
|
|
if (!mEnabled || MWBase::Environment::get().getDialogueManager()->isInChoice())
|
|
|
|
|
if (mGoodbye || MWBase::Environment::get().getDialogueManager()->isInChoice())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
int separatorPos = 0;
|
|
|
|
@ -328,63 +346,84 @@ namespace MWGui
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (id >= separatorPos)
|
|
|
|
|
MWBase::Environment::get().getDialogueManager()->keywordSelected(Misc::StringUtils::lowerCase(topic));
|
|
|
|
|
{
|
|
|
|
|
onTopicActivated(topic);
|
|
|
|
|
if (mGoodbyeButton->getEnabled())
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mGoodbyeButton);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const MWWorld::Store<ESM::GameSetting> &gmst =
|
|
|
|
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
|
|
|
|
|
|
|
|
|
MWBase::DialogueManager::Response response;
|
|
|
|
|
if (topic == gmst.find("sPersuasion")->getString())
|
|
|
|
|
mPersuasionDialog.setVisible(true);
|
|
|
|
|
else if (topic == gmst.find("sCompanionShare")->getString())
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->showCompanionWindow(mPtr);
|
|
|
|
|
else if (!MWBase::Environment::get().getDialogueManager()->checkServiceRefused())
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Companion, mPtr);
|
|
|
|
|
else if (!MWBase::Environment::get().getDialogueManager()->checkServiceRefused(response))
|
|
|
|
|
{
|
|
|
|
|
if (topic == gmst.find("sBarter")->getString())
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->startTrade(mPtr);
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Barter, mPtr);
|
|
|
|
|
else if (topic == gmst.find("sSpells")->getString())
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->startSpellBuying(mPtr);
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_SpellBuying, mPtr);
|
|
|
|
|
else if (topic == gmst.find("sTravel")->getString())
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->startTravel(mPtr);
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Travel, mPtr);
|
|
|
|
|
else if (topic == gmst.find("sSpellMakingMenuTitle")->getString())
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->startSpellMaking (mPtr);
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_SpellCreation, mPtr);
|
|
|
|
|
else if (topic == gmst.find("sEnchanting")->getString())
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->startEnchanting (mPtr);
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Enchanting, mPtr);
|
|
|
|
|
else if (topic == gmst.find("sServiceTrainingTitle")->getString())
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->startTraining (mPtr);
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Training, mPtr);
|
|
|
|
|
else if (topic == gmst.find("sRepair")->getString())
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->startRepair (mPtr);
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_MerchantRepair, mPtr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
addResponse(response.first, response.second);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::startDialogue(MWWorld::Ptr actor, std::string npcName, bool resetHistory)
|
|
|
|
|
void DialogueWindow::setPtr(const MWWorld::Ptr& actor)
|
|
|
|
|
{
|
|
|
|
|
MWBase::DialogueManager::Response response;
|
|
|
|
|
if (!MWBase::Environment::get().getDialogueManager()->startDialogue(actor, response))
|
|
|
|
|
{
|
|
|
|
|
// No greetings found. The dialogue window should not be shown.
|
|
|
|
|
// If this is a companion, we must show the companion window directly (used by BM_bear_be_unique).
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Dialogue);
|
|
|
|
|
if (isCompanion())
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Companion, mPtr);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mGoodbyeButton);
|
|
|
|
|
|
|
|
|
|
mGoodbye = false;
|
|
|
|
|
mEnabled = true;
|
|
|
|
|
bool sameActor = (mPtr == actor);
|
|
|
|
|
mPtr = actor;
|
|
|
|
|
mTopicsList->setEnabled(true);
|
|
|
|
|
setTitle(npcName);
|
|
|
|
|
|
|
|
|
|
clearChoices();
|
|
|
|
|
setTitle(mPtr.getClass().getName(mPtr));
|
|
|
|
|
|
|
|
|
|
mTopicsList->clear();
|
|
|
|
|
|
|
|
|
|
if (resetHistory || !sameActor)
|
|
|
|
|
if (!sameActor)
|
|
|
|
|
{
|
|
|
|
|
for (std::vector<DialogueText*>::iterator it = mHistoryContents.begin(); it != mHistoryContents.end(); ++it)
|
|
|
|
|
delete (*it);
|
|
|
|
|
mHistoryContents.clear();
|
|
|
|
|
|
|
|
|
|
mKeywords.clear();
|
|
|
|
|
updateTopicsPane();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (std::vector<Link*>::iterator it = mLinks.begin(); it != mLinks.end(); ++it)
|
|
|
|
|
delete (*it);
|
|
|
|
|
mDeleteLater.push_back(*it); // Links are not deleted right away to prevent issues with event handlers
|
|
|
|
|
mLinks.clear();
|
|
|
|
|
|
|
|
|
|
updateOptions();
|
|
|
|
|
|
|
|
|
|
updateDisposition();
|
|
|
|
|
restock();
|
|
|
|
|
|
|
|
|
|
addResponse(response.first, response.second, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::restock()
|
|
|
|
@ -401,16 +440,35 @@ namespace MWGui
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::deleteLater()
|
|
|
|
|
{
|
|
|
|
|
for (Link* link : mDeleteLater)
|
|
|
|
|
delete link;
|
|
|
|
|
mDeleteLater.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::setKeywords(std::list<std::string> keyWords)
|
|
|
|
|
{
|
|
|
|
|
if (mKeywords == keyWords && isCompanion() == mIsCompanion)
|
|
|
|
|
return;
|
|
|
|
|
mIsCompanion = isCompanion();
|
|
|
|
|
mKeywords = keyWords;
|
|
|
|
|
|
|
|
|
|
updateTopicsPane();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::updateTopicsPane()
|
|
|
|
|
{
|
|
|
|
|
mTopicsList->clear();
|
|
|
|
|
for (std::map<std::string, Link*>::iterator it = mTopicLinks.begin(); it != mTopicLinks.end(); ++it)
|
|
|
|
|
delete it->second;
|
|
|
|
|
mDeleteLater.push_back(it->second);
|
|
|
|
|
mTopicLinks.clear();
|
|
|
|
|
mKeywordSearch.clear();
|
|
|
|
|
|
|
|
|
|
bool isCompanion = !mPtr.getClass().getScript(mPtr).empty()
|
|
|
|
|
&& mPtr.getRefData().getLocals().getIntVar(mPtr.getClass().getScript(mPtr), "companion");
|
|
|
|
|
int services = mPtr.getClass().getServices(mPtr);
|
|
|
|
|
|
|
|
|
|
bool travel = (mPtr.getTypeName() == typeid(ESM::NPC).name() && !mPtr.get<ESM::NPC>()->mBase->getTransport().empty())
|
|
|
|
|
|| (mPtr.getTypeName() == typeid(ESM::Creature).name() && !mPtr.get<ESM::Creature>()->mBase->getTransport().empty());
|
|
|
|
|
|
|
|
|
|
const MWWorld::Store<ESM::GameSetting> &gmst =
|
|
|
|
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
|
|
|
@ -418,39 +476,40 @@ namespace MWGui
|
|
|
|
|
if (mPtr.getTypeName() == typeid(ESM::NPC).name())
|
|
|
|
|
mTopicsList->addItem(gmst.find("sPersuasion")->getString());
|
|
|
|
|
|
|
|
|
|
if (mServices & Service_Trade)
|
|
|
|
|
if (services & ESM::NPC::AllItems)
|
|
|
|
|
mTopicsList->addItem(gmst.find("sBarter")->getString());
|
|
|
|
|
|
|
|
|
|
if (mServices & Service_BuySpells)
|
|
|
|
|
if (services & ESM::NPC::Spells)
|
|
|
|
|
mTopicsList->addItem(gmst.find("sSpells")->getString());
|
|
|
|
|
|
|
|
|
|
if (mServices & Service_Travel)
|
|
|
|
|
if (travel)
|
|
|
|
|
mTopicsList->addItem(gmst.find("sTravel")->getString());
|
|
|
|
|
|
|
|
|
|
if (mServices & Service_CreateSpells)
|
|
|
|
|
if (services & ESM::NPC::Spellmaking)
|
|
|
|
|
mTopicsList->addItem(gmst.find("sSpellmakingMenuTitle")->getString());
|
|
|
|
|
|
|
|
|
|
if (mServices & Service_Enchant)
|
|
|
|
|
if (services & ESM::NPC::Enchanting)
|
|
|
|
|
mTopicsList->addItem(gmst.find("sEnchanting")->getString());
|
|
|
|
|
|
|
|
|
|
if (mServices & Service_Training)
|
|
|
|
|
if (services & ESM::NPC::Training)
|
|
|
|
|
mTopicsList->addItem(gmst.find("sServiceTrainingTitle")->getString());
|
|
|
|
|
|
|
|
|
|
if (mServices & Service_Repair)
|
|
|
|
|
if (services & ESM::NPC::Repair)
|
|
|
|
|
mTopicsList->addItem(gmst.find("sRepair")->getString());
|
|
|
|
|
|
|
|
|
|
if (isCompanion)
|
|
|
|
|
if (isCompanion())
|
|
|
|
|
mTopicsList->addItem(gmst.find("sCompanionShare")->getString());
|
|
|
|
|
|
|
|
|
|
if (mTopicsList->getItemCount() > 0)
|
|
|
|
|
mTopicsList->addSeparator();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(std::list<std::string>::iterator it = keyWords.begin(); it != keyWords.end(); ++it)
|
|
|
|
|
for(std::list<std::string>::iterator it = mKeywords.begin(); it != mKeywords.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
mTopicsList->addItem(*it);
|
|
|
|
|
|
|
|
|
|
Topic* t = new Topic(*it);
|
|
|
|
|
t->eventTopicActivated += MyGUI::newDelegate(this, &DialogueWindow::onTopicActivated);
|
|
|
|
|
mTopicLinks[Misc::StringUtils::lowerCase(*it)] = t;
|
|
|
|
|
|
|
|
|
|
mKeywordSearch.seed(Misc::StringUtils::lowerCase(*it), intptr_t(t));
|
|
|
|
@ -484,9 +543,11 @@ namespace MWGui
|
|
|
|
|
typesetter->sectionBreak(9);
|
|
|
|
|
// choices
|
|
|
|
|
const TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours();
|
|
|
|
|
for (std::vector<std::pair<std::string, int> >::iterator it = mChoices.begin(); it != mChoices.end(); ++it)
|
|
|
|
|
mChoices = MWBase::Environment::get().getDialogueManager()->getChoices();
|
|
|
|
|
for (std::vector<std::pair<std::string, int> >::const_iterator it = mChoices.begin(); it != mChoices.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
Choice* link = new Choice(it->second);
|
|
|
|
|
link->eventChoiceActivated += MyGUI::newDelegate(this, &DialogueWindow::onChoiceActivated);
|
|
|
|
|
mLinks.push_back(link);
|
|
|
|
|
|
|
|
|
|
typesetter->lineBreak();
|
|
|
|
@ -496,9 +557,11 @@ namespace MWGui
|
|
|
|
|
typesetter->write(questionStyle, to_utf8_span(it->first.c_str()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mGoodbye = MWBase::Environment::get().getDialogueManager()->isGoodbye();
|
|
|
|
|
if (mGoodbye)
|
|
|
|
|
{
|
|
|
|
|
Goodbye* link = new Goodbye();
|
|
|
|
|
link->eventActivated += MyGUI::newDelegate(this, &DialogueWindow::onGoodbyeActivated);
|
|
|
|
|
mLinks.push_back(link);
|
|
|
|
|
std::string goodbye = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGoodbye")->getString();
|
|
|
|
|
BookTypesetter::Style* questionStyle = typesetter->createHotStyle(body, textColours.answer, textColours.answerOver,
|
|
|
|
@ -528,10 +591,11 @@ namespace MWGui
|
|
|
|
|
onScrollbarMoved(mScrollBar, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MyGUI::Button* byeButton;
|
|
|
|
|
getWidget(byeButton, "ByeButton");
|
|
|
|
|
bool goodbyeEnabled = !MWBase::Environment::get().getDialogueManager()->isInChoice() || mGoodbye;
|
|
|
|
|
byeButton->setEnabled(goodbyeEnabled);
|
|
|
|
|
bool goodbyeWasEnabled = mGoodbyeButton->getEnabled();
|
|
|
|
|
mGoodbyeButton->setEnabled(goodbyeEnabled);
|
|
|
|
|
if (goodbyeEnabled && !goodbyeWasEnabled)
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mGoodbyeButton);
|
|
|
|
|
|
|
|
|
|
bool topicsEnabled = !MWBase::Environment::get().getDialogueManager()->isInChoice() && !mGoodbye;
|
|
|
|
|
mTopicsList->setEnabled(topicsEnabled);
|
|
|
|
@ -542,59 +606,47 @@ namespace MWGui
|
|
|
|
|
reinterpret_cast<Link*>(link)->activated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::onScrollbarMoved(MyGUI::ScrollBar *sender, size_t pos)
|
|
|
|
|
void DialogueWindow::onTopicActivated(const std::string &topicId)
|
|
|
|
|
{
|
|
|
|
|
mHistory->setPosition(0, static_cast<int>(pos) * -1);
|
|
|
|
|
MWBase::DialogueManager::Response response = MWBase::Environment::get().getDialogueManager()->keywordSelected(topicId);
|
|
|
|
|
addResponse(response.first, response.second);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::addResponse(const std::string &text, const std::string &title, bool needMargin)
|
|
|
|
|
{
|
|
|
|
|
// This is called from the dialogue manager, so text is
|
|
|
|
|
// case-smashed - thus we have to retrieve the correct case
|
|
|
|
|
// of the title through the topic list.
|
|
|
|
|
std::string realTitle = title;
|
|
|
|
|
if (realTitle != "")
|
|
|
|
|
{
|
|
|
|
|
for (size_t i=0; i<mTopicsList->getItemCount(); ++i)
|
|
|
|
|
void DialogueWindow::onChoiceActivated(int id)
|
|
|
|
|
{
|
|
|
|
|
std::string item = mTopicsList->getItemNameAt(i);
|
|
|
|
|
if (Misc::StringUtils::ciEqual(item, title))
|
|
|
|
|
{
|
|
|
|
|
realTitle = item;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MWBase::DialogueManager::Response response = MWBase::Environment::get().getDialogueManager()->questionAnswered(id);
|
|
|
|
|
addResponse(response.first, response.second);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mHistoryContents.push_back(new Response(text, realTitle, needMargin));
|
|
|
|
|
updateHistory();
|
|
|
|
|
void DialogueWindow::onGoodbyeActivated()
|
|
|
|
|
{
|
|
|
|
|
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Dialogue);
|
|
|
|
|
resetReference();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::addMessageBox(const std::string& text)
|
|
|
|
|
void DialogueWindow::onScrollbarMoved(MyGUI::ScrollBar *sender, size_t pos)
|
|
|
|
|
{
|
|
|
|
|
mHistoryContents.push_back(new Message(text));
|
|
|
|
|
updateHistory();
|
|
|
|
|
mHistory->setPosition(0, static_cast<int>(pos) * -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::addChoice(const std::string& choice, int id)
|
|
|
|
|
void DialogueWindow::addResponse(const std::string &title, const std::string &text, bool needMargin)
|
|
|
|
|
{
|
|
|
|
|
mChoices.push_back(std::make_pair(choice, id));
|
|
|
|
|
mHistoryContents.push_back(new Response(text, title, needMargin));
|
|
|
|
|
updateHistory();
|
|
|
|
|
updateTopics();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::clearChoices()
|
|
|
|
|
void DialogueWindow::addMessageBox(const std::string& text)
|
|
|
|
|
{
|
|
|
|
|
mChoices.clear();
|
|
|
|
|
mHistoryContents.push_back(new Message(text));
|
|
|
|
|
updateHistory();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::updateOptions()
|
|
|
|
|
void DialogueWindow::updateDisposition()
|
|
|
|
|
{
|
|
|
|
|
//Clear the list of topics
|
|
|
|
|
mTopicsList->clear();
|
|
|
|
|
|
|
|
|
|
bool dispositionVisible = false;
|
|
|
|
|
if (mPtr.getClass().isNpc())
|
|
|
|
|
if (!mPtr.isEmpty() && mPtr.getClass().isNpc())
|
|
|
|
|
{
|
|
|
|
|
dispositionVisible = true;
|
|
|
|
|
mDispositionBar->setProgressRange(100);
|
|
|
|
@ -620,26 +672,38 @@ namespace MWGui
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::goodbye()
|
|
|
|
|
void DialogueWindow::onReferenceUnavailable()
|
|
|
|
|
{
|
|
|
|
|
mGoodbye = true;
|
|
|
|
|
mEnabled = false;
|
|
|
|
|
updateHistory();
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Dialogue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::onReferenceUnavailable()
|
|
|
|
|
void DialogueWindow::onFrame(float dt)
|
|
|
|
|
{
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Dialogue);
|
|
|
|
|
checkReferenceAvailable();
|
|
|
|
|
if (mPtr.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
updateDisposition();
|
|
|
|
|
deleteLater();
|
|
|
|
|
|
|
|
|
|
if (mChoices != MWBase::Environment::get().getDialogueManager()->getChoices()
|
|
|
|
|
|| mGoodbye != MWBase::Environment::get().getDialogueManager()->isGoodbye())
|
|
|
|
|
updateHistory();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::onFrame()
|
|
|
|
|
void DialogueWindow::updateTopics()
|
|
|
|
|
{
|
|
|
|
|
if(mMainWidget->getVisible() && mPtr.getTypeName() == typeid(ESM::NPC).name())
|
|
|
|
|
setKeywords(MWBase::Environment::get().getDialogueManager()->getAvailableTopics());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DialogueWindow::isCompanion()
|
|
|
|
|
{
|
|
|
|
|
int disp = MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr);
|
|
|
|
|
mDispositionBar->setProgressRange(100);
|
|
|
|
|
mDispositionBar->setProgressPosition(disp);
|
|
|
|
|
mDispositionText->setCaption(MyGUI::utility::toString(disp)+std::string("/100"));
|
|
|
|
|
return !mPtr.getClass().getScript(mPtr).empty()
|
|
|
|
|
&& mPtr.getRefData().getLocals().getIntVar(mPtr.getClass().getScript(mPtr), "companion");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogueWindow::onPersuadeResult(const std::string &title, const std::string &text)
|
|
|
|
|
{
|
|
|
|
|
addResponse(title, text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|