diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 496cc4f7f..2c4de7be1 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -637,7 +637,7 @@ namespace MWDialogue //initialise the GUI MWBase::Environment::get().getInputManager()->setGuiMode(MWGui::GM_Dialogue); MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); - win->startDialogue(MWWorld::Class::get (actor).getName (actor)); + win->startDialogue(actor, 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 updateTopics(); diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 3f6ec0376..953657565 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -1,11 +1,4 @@ #include "dialogue.hpp" -#include "dialogue_history.hpp" -#include "window_manager.hpp" -#include "widgets.hpp" -#include "list.hpp" -#include "components/esm_store/store.hpp" -#include "../mwbase/environment.hpp" -#include "../mwdialogue/dialoguemanager.hpp" #include #include @@ -14,6 +7,17 @@ #include #include +#include + +#include "../mwbase/environment.hpp" +#include "../mwdialogue/dialoguemanager.hpp" + +#include "dialogue_history.hpp" +#include "window_manager.hpp" +#include "widgets.hpp" +#include "list.hpp" +#include "tradewindow.hpp" + using namespace MWGui; using namespace Widgets; @@ -59,9 +63,7 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager) //Topics list getWidget(topicsList, "TopicsList"); - //topicsList->eventListSelectAccept += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); topicsList->eventItemSelected += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); - //topicsList->eventListChangePosition += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); MyGUI::ButtonPtr byeButton; getWidget(byeButton, "ByeButton"); @@ -117,6 +119,9 @@ void DialogueWindow::open() history->eraseText(0,history->getTextLength()); updateOptions(); setVisible(true); + + // hide all sub-dialogues of the dialog window (trade window, persuasion, etc) + mWindowManager.getTradeWindow()->setVisible(false); } void DialogueWindow::onByeClicked(MyGUI::Widget* _sender) @@ -128,12 +133,20 @@ void DialogueWindow::onSelectTopic(std::string topic) { if (!mEnabled) return; - MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(topic)); + if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sBarter")->str) + { + /// \todo check if the player is allowed to trade with this actor (e.g. faction rank high enough)? + mWindowManager.getTradeWindow()->startTrade(mActor); + } + + else + MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(topic)); } -void DialogueWindow::startDialogue(std::string npcName) +void DialogueWindow::startDialogue(MWWorld::Ptr actor, std::string npcName) { mEnabled = true; + mActor = actor; topicsList->setEnabled(true); static_cast(mMainWidget)->setCaption(npcName); adjustWindowCaption(); diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 225ef37a4..7f69f972c 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -4,6 +4,8 @@ #include "window_base.hpp" #include +#include "../mwworld/ptr.hpp" + namespace MWGui { class WindowManager; @@ -38,7 +40,7 @@ namespace MWGui */ EventHandle_Void eventBye; - void startDialogue(std::string npcName); + void startDialogue(MWWorld::Ptr actor, std::string npcName); void stopDialogue(); void setKeywords(std::list keyWord); void removeKeyword(std::string keyWord); @@ -70,6 +72,8 @@ namespace MWGui bool mEnabled; + MWWorld::Ptr mActor; // actor being talked to + DialogueHistory* history; Widgets::MWList* topicsList; MyGUI::ProgressPtr pDispositionBar; diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 45a82eecb..cd38aa731 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -7,4 +7,9 @@ namespace MWGui ContainerBase(NULL) // no drag&drop { } + + void TradeWindow::startTrade(MWWorld::Ptr actor) + { + ContainerBase::openContainer(actor); + } } diff --git a/apps/openmw/mwgui/tradewindow.hpp b/apps/openmw/mwgui/tradewindow.hpp index f04f83c0d..5fc5b98b6 100644 --- a/apps/openmw/mwgui/tradewindow.hpp +++ b/apps/openmw/mwgui/tradewindow.hpp @@ -4,6 +4,8 @@ #include "container.hpp" #include "window_base.hpp" +#include "../mwworld/ptr.hpp" + namespace MyGUI { class Gui; @@ -23,6 +25,8 @@ namespace MWGui public: TradeWindow(WindowManager& parWindowManager); + void startTrade(MWWorld::Ptr actor); + //virtual void Update(); //virtual void notifyContentChanged(); diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 5c005835c..245b364c9 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -15,6 +15,7 @@ #include "hud.hpp" #include "mainmenu.hpp" #include "countdialog.hpp" +#include "tradewindow.hpp" #include "../mwmechanics/mechanicsmanager.hpp" #include "../mwinput/inputmanager.hpp" @@ -48,6 +49,7 @@ WindowManager::WindowManager( , mBookWindow(NULL) , mScrollWindow(NULL) , mCountDialog(NULL) + , mTradeWindow(NULL) , mCharGen(NULL) , playerClass() , playerName() @@ -114,6 +116,7 @@ WindowManager::WindowManager( mScrollWindow = new ScrollWindow(*this); mBookWindow = new BookWindow(*this); mCountDialog = new CountDialog(*this); + mTradeWindow = new TradeWindow(*this); // The HUD is always on hud->setVisible(true); @@ -153,6 +156,7 @@ WindowManager::~WindowManager() delete mDragAndDrop; delete mBookWindow; delete mScrollWindow; + delete mTradeWindow; cleanupGarbage(); } diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 8c9eec16d..52869ff55 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -136,6 +136,7 @@ namespace MWGui MWGui::BookWindow* getBookWindow() {return mBookWindow;} MWGui::ScrollWindow* getScrollWindow() {return mScrollWindow;} MWGui::CountDialog* getCountDialog() {return mCountDialog;} + MWGui::TradeWindow* getTradeWindow() {return mTradeWindow;} MyGUI::Gui* getGui() const { return gui; } diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index 2ee823d2a..cacfb7c5a 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -56,6 +56,7 @@ configure_file("${SDIR}/openmw_scroll_layout.xml" "${DDIR}/openmw_scroll_layout. configure_file("${SDIR}/openmw_scroll_skin.xml" "${DDIR}/openmw_scroll_skin.xml" COPYONLY) configure_file("${SDIR}/openmw_book_layout.xml" "${DDIR}/openmw_book_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_count_window_layout.xml" "${DDIR}/openmw_count_window_layout.xml" COPYONLY) +configure_file("${SDIR}/openmw_trade_window_layout.xml" "${DDIR}/openmw_trade_window_layout.xml" COPYONLY) configure_file("${SDIR}/atlas1.cfg" "${DDIR}/atlas1.cfg" COPYONLY) configure_file("${SDIR}/smallbars.png" "${DDIR}/smallbars.png" COPYONLY) configure_file("${SDIR}/transparent.png" "${DDIR}/transparent.png" COPYONLY)