From 6ae642aa069efabd7eb3d643e9906eb5ffa4d8ec Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 17 May 2012 21:15:48 +0200 Subject: [PATCH] complete trade window layout --- apps/openmw/mwgui/container.cpp | 2 - apps/openmw/mwgui/dialogue.cpp | 2 + apps/openmw/mwgui/tradewindow.cpp | 77 +++++++++++++++++++--- apps/openmw/mwgui/tradewindow.hpp | 15 +++++ apps/openmw/mwgui/window_manager.cpp | 6 ++ apps/openmw/mwgui/window_manager.hpp | 3 +- files/mygui/openmw_trade_window_layout.xml | 36 ++++++++-- 7 files changed, 122 insertions(+), 19 deletions(-) diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index eb02c5826..078a5e370 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -470,7 +470,6 @@ void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender) if(mDragAndDrop == NULL || !mDragAndDrop->mIsOnDragAndDrop) { MWBase::Environment::get().getWindowManager()->setGuiMode(GM_Game); - setVisible(false); } } @@ -502,6 +501,5 @@ void ContainerWindow::onTakeAllButtonClicked(MyGUI::Widget* _sender) containerStore.clear(); MWBase::Environment::get().getWindowManager()->setGuiMode(GM_Game); - setVisible(false); } } diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 953657565..e8db4b6d1 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -17,6 +17,7 @@ #include "widgets.hpp" #include "list.hpp" #include "tradewindow.hpp" +#include "inventorywindow.hpp" using namespace MWGui; using namespace Widgets; @@ -137,6 +138,7 @@ void DialogueWindow::onSelectTopic(std::string topic) { /// \todo check if the player is allowed to trade with this actor (e.g. faction rank high enough)? mWindowManager.getTradeWindow()->startTrade(mActor); + mWindowManager.setGuiMode(GM_Barter); } else diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 09557b196..31e0722aa 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -3,24 +3,49 @@ #include "../mwbase/environment.hpp" #include "../mwworld/world.hpp" +#include "window_manager.hpp" + namespace MWGui { TradeWindow::TradeWindow(WindowManager& parWindowManager) : WindowBase("openmw_trade_window_layout.xml", parWindowManager), ContainerBase(NULL) // no drag&drop { - getWidget(mFilterAll, "AllButton"); - getWidget(mFilterWeapon, "WeaponButton"); - getWidget(mFilterApparel, "ApparelButton"); - getWidget(mFilterMagic, "MagicButton"); - getWidget(mFilterMisc, "MiscButton"); - MyGUI::ScrollView* itemView; MyGUI::Widget* containerWidget; getWidget(containerWidget, "Items"); getWidget(itemView, "ItemView"); setWidgets(containerWidget, itemView); + getWidget(mFilterAll, "AllButton"); + getWidget(mFilterWeapon, "WeaponButton"); + getWidget(mFilterApparel, "ApparelButton"); + getWidget(mFilterMagic, "MagicButton"); + getWidget(mFilterMisc, "MiscButton"); + + getWidget(mMaxSaleButton, "MaxSaleButton"); + getWidget(mCancelButton, "CancelButton"); + getWidget(mOfferButton, "OfferButton"); + getWidget(mPlayerGold, "PlayerGold"); + getWidget(mMerchantGold, "MerchantGold"); + getWidget(mIncreaseButton, "IncreaseButton"); + getWidget(mDecreaseButton, "DecreaseButton"); + getWidget(mTotalBalance, "TotalBalance"); + getWidget(mTotalBalanceLabel, "TotalBalanceLabel"); + getWidget(mBottomPane, "BottomPane"); + + // this GMST doesn't seem to get retrieved - even though i can clearly see it in the CS !??!? + mMaxSaleButton->setCaption(mWindowManager.getGameSettingString("sMaxSale", "Max. Sale")); + + mCancelButton->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sCancel")->str); + mOfferButton->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sOffer")->str); +/* + mTotalBalanceLabel->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sTotalCost")->str); + mTotalBalanceLabel->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sTotalSold")->str); + mPlayerGold->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sYourGold")->str); + mMerchantGold->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sSellerGold")->str); + +*/ mFilterAll->setCaption (MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sAllTab")->str); mFilterWeapon->setCaption (MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sWeaponTab")->str); mFilterApparel->setCaption (MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sApparelTab")->str); @@ -47,20 +72,42 @@ namespace MWGui mFilterMisc->setPosition(curX, mFilterMisc->getPosition().top); mFilterMisc->setSize( mFilterMisc->getTextSize().width + 24, mFilterMisc->getSize().height ); + mFilterAll->setStateSelected(true); + mFilterAll->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onFilterChanged); mFilterWeapon->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onFilterChanged); mFilterApparel->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onFilterChanged); mFilterMagic->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onFilterChanged); mFilterMisc->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onFilterChanged); - mFilterAll->setStateSelected(true); + mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onCancelButtonClicked); + mOfferButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onOfferButtonClicked); + + mMaxSaleButton->setSize(MyGUI::IntSize(mMaxSaleButton->getTextSize().width + 24, mMaxSaleButton->getHeight())); + + int cancelButtonWidth = mCancelButton->getTextSize().width + 24; + mCancelButton->setCoord(mBottomPane->getWidth()-cancelButtonWidth, + mCancelButton->getTop(), + cancelButtonWidth, + mCancelButton->getHeight()); + + int offerButtonWidth = mOfferButton->getTextSize().width + 24; + mOfferButton->setCoord(mBottomPane->getWidth()-cancelButtonWidth-offerButtonWidth-8, + mOfferButton->getTop(), + offerButtonWidth, + mOfferButton->getHeight()); + + setCoord(400, 0, 400, 300); + + static_cast(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &TradeWindow::onWindowResize); } void TradeWindow::startTrade(MWWorld::Ptr actor) { ContainerBase::openContainer(actor); - setVisible(true); + setTitle(MWWorld::Class::get(actor).getName(actor)); + adjustWindowCaption(); } void TradeWindow::onFilterChanged(MyGUI::Widget* _sender) @@ -84,4 +131,18 @@ namespace MWGui static_cast(_sender)->setStateSelected(true); } + + void TradeWindow::onWindowResize(MyGUI::Window* _sender) + { + drawItems(); + } + + void TradeWindow::onOfferButtonClicked(MyGUI::Widget* _sender) + { + } + + void TradeWindow::onCancelButtonClicked(MyGUI::Widget* _sender) + { + mWindowManager.setGuiMode(GM_Game); + } } diff --git a/apps/openmw/mwgui/tradewindow.hpp b/apps/openmw/mwgui/tradewindow.hpp index 5fc5b98b6..1f937d06e 100644 --- a/apps/openmw/mwgui/tradewindow.hpp +++ b/apps/openmw/mwgui/tradewindow.hpp @@ -37,8 +37,23 @@ namespace MWGui MyGUI::Button* mFilterMagic; MyGUI::Button* mFilterMisc; + MyGUI::Button* mIncreaseButton; + MyGUI::Button* mDecreaseButton; + MyGUI::TextBox* mTotalBalanceLabel; + MyGUI::TextBox* mTotalBalance; + + MyGUI::Widget* mBottomPane; + + MyGUI::Button* mMaxSaleButton; + MyGUI::Button* mCancelButton; + MyGUI::Button* mOfferButton; + MyGUI::TextBox* mPlayerGold; + MyGUI::TextBox* mMerchantGold; + void onWindowResize(MyGUI::Window* _sender); void onFilterChanged(MyGUI::Widget* _sender); + void onOfferButtonClicked(MyGUI::Widget* _sender); + void onCancelButtonClicked(MyGUI::Widget* _sender); }; } diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 1593c6b19..e970de2e6 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -215,6 +215,7 @@ void WindowManager::updateVisible() mInventoryWindow->setVisible(false); mScrollWindow->setVisible(false); mBookWindow->setVisible(false); + mTradeWindow->setVisible(false); // Mouse is visible whenever we're not in game mode MyGUI::PointerManager::getInstance().setVisible(isGuiMode()); @@ -273,6 +274,11 @@ void WindowManager::updateVisible() case GM_Dialogue: mDialogueWindow->open(); break; + case GM_Barter: + mInventoryWindow->setVisible(true); + mInventoryWindow->openInventory(); + mTradeWindow->setVisible(true); + break; case GM_InterMessageBox: if(!mMessageBoxManager->isInteractiveMessageBox()) { setGuiMode(GM_Game); diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 52869ff55..82c494191 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -130,9 +130,8 @@ namespace MWGui } MWGui::DialogueWindow* getDialogueWindow() {return mDialogueWindow;} - MWGui::ContainerWindow* getContainerWindow() {return mContainerWindow;} - + MWGui::InventoryWindow* getInventoryWindow() {return mInventoryWindow;} MWGui::BookWindow* getBookWindow() {return mBookWindow;} MWGui::ScrollWindow* getScrollWindow() {return mScrollWindow;} MWGui::CountDialog* getCountDialog() {return mCountDialog;} diff --git a/files/mygui/openmw_trade_window_layout.xml b/files/mygui/openmw_trade_window_layout.xml index 15d313c4d..076924322 100644 --- a/files/mygui/openmw_trade_window_layout.xml +++ b/files/mygui/openmw_trade_window_layout.xml @@ -1,11 +1,11 @@ - + - + @@ -14,14 +14,36 @@ - - - + + + + - - + + + + + + + + + + + + + + + + + + + + + + +