mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 13:15:32 +00:00
trade window shows up and shows the vendor's inventory items.
This commit is contained in:
parent
1f85475536
commit
4213b4370f
5 changed files with 115 additions and 40 deletions
|
@ -88,31 +88,34 @@ ContainerBase::~ContainerBase()
|
|||
|
||||
void ContainerBase::onSelectedItem(MyGUI::Widget* _sender)
|
||||
{
|
||||
if(!mDragAndDrop->mIsOnDragAndDrop)
|
||||
if (mDragAndDrop)
|
||||
{
|
||||
mSelectedItem = _sender;
|
||||
|
||||
MWWorld::Ptr object = (*_sender->getUserData<MWWorld::Ptr>());
|
||||
int count = object.getRefData().getCount();
|
||||
|
||||
if (MyGUI::InputManager::getInstance().isShiftPressed() || count == 1)
|
||||
if(!mDragAndDrop->mIsOnDragAndDrop)
|
||||
{
|
||||
onSelectedItemImpl(_sender, count);
|
||||
}
|
||||
else if (MyGUI::InputManager::getInstance().isControlPressed())
|
||||
{
|
||||
onSelectedItemImpl(_sender, 1);
|
||||
mSelectedItem = _sender;
|
||||
|
||||
MWWorld::Ptr object = (*_sender->getUserData<MWWorld::Ptr>());
|
||||
int count = object.getRefData().getCount();
|
||||
|
||||
if (MyGUI::InputManager::getInstance().isShiftPressed() || count == 1)
|
||||
{
|
||||
onSelectedItemImpl(_sender, count);
|
||||
}
|
||||
else if (MyGUI::InputManager::getInstance().isControlPressed())
|
||||
{
|
||||
onSelectedItemImpl(_sender, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
||||
dialog->open(MWWorld::Class::get(object).getName(object), count);
|
||||
dialog->eventOkClicked.clear();
|
||||
dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerBase::onSelectedItemImpl);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
||||
dialog->open(MWWorld::Class::get(object).getName(object), count);
|
||||
dialog->eventOkClicked.clear();
|
||||
dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerBase::onSelectedItemImpl);
|
||||
}
|
||||
onContainerClicked(mContainerWidget);
|
||||
}
|
||||
else
|
||||
onContainerClicked(mContainerWidget);
|
||||
}
|
||||
|
||||
void ContainerBase::onSelectedItemImpl(MyGUI::Widget* _sender, int count)
|
||||
|
@ -143,6 +146,8 @@ void ContainerBase::onSelectedItemImpl(MyGUI::Widget* _sender, int count)
|
|||
|
||||
void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
if (mDragAndDrop == NULL) return;
|
||||
|
||||
if(mDragAndDrop->mIsOnDragAndDrop) //drop item here
|
||||
{
|
||||
MWWorld::Ptr object = *mDragAndDrop->mDraggedWidget->getUserData<MWWorld::Ptr>();
|
||||
|
@ -323,7 +328,7 @@ void ContainerBase::drawItems()
|
|||
const MWWorld::Ptr* iter = &((*it).first);
|
||||
|
||||
int displayCount = iter->getRefData().getCount();
|
||||
if (mDragAndDrop->mIsOnDragAndDrop && *iter == *mDragAndDrop->mDraggedWidget->getUserData<MWWorld::Ptr>())
|
||||
if (mDragAndDrop != NULL && mDragAndDrop->mIsOnDragAndDrop && *iter == *mDragAndDrop->mDraggedWidget->getUserData<MWWorld::Ptr>())
|
||||
{
|
||||
displayCount -= mDragAndDrop->mDraggedCount;
|
||||
}
|
||||
|
@ -402,7 +407,7 @@ std::string ContainerBase::getCountString(const int count)
|
|||
|
||||
void ContainerBase::Update()
|
||||
{
|
||||
if(mDragAndDrop->mIsOnDragAndDrop)
|
||||
if(mDragAndDrop != NULL && mDragAndDrop->mIsOnDragAndDrop)
|
||||
{
|
||||
if(mDragAndDrop->mDraggedWidget)
|
||||
mDragAndDrop->mDraggedWidget->setPosition(MyGUI::InputManager::getInstance().getMousePosition());
|
||||
|
@ -462,7 +467,7 @@ void ContainerWindow::open(MWWorld::Ptr container)
|
|||
|
||||
void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
if(!mDragAndDrop->mIsOnDragAndDrop)
|
||||
if(mDragAndDrop == NULL || !mDragAndDrop->mIsOnDragAndDrop)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->setGuiMode(GM_Game);
|
||||
setVisible(false);
|
||||
|
@ -471,7 +476,7 @@ void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
|
|||
|
||||
void ContainerWindow::onTakeAllButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
if(!mDragAndDrop->mIsOnDragAndDrop)
|
||||
if(mDragAndDrop == NULL || !mDragAndDrop->mIsOnDragAndDrop)
|
||||
{
|
||||
// transfer everything into the player's inventory
|
||||
MWWorld::ContainerStore& containerStore = MWWorld::Class::get(mContainer).getContainerStore(mContainer);
|
||||
|
|
|
@ -16,13 +16,6 @@
|
|||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwworld/manualref.hpp"
|
||||
|
||||
#include "../mwscript/scriptmanager.hpp"
|
||||
#include "../mwscript/compilercontext.hpp"
|
||||
#include "../mwscript/interpretercontext.hpp"
|
||||
#include "../mwscript/extensions.hpp"
|
||||
#include "../mwscript/globalscripts.hpp"
|
||||
|
||||
|
||||
#include "window_manager.hpp"
|
||||
#include "widgets.hpp"
|
||||
#include "bookwindow.hpp"
|
||||
|
|
|
@ -1,15 +1,87 @@
|
|||
#include "tradewindow.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwworld/world.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);
|
||||
|
||||
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);
|
||||
mFilterMagic->setCaption (MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sMagicTab")->str);
|
||||
mFilterMisc->setCaption (MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sMiscTab")->str);
|
||||
|
||||
// adjust size of buttons to fit text
|
||||
int curX = 0;
|
||||
mFilterAll->setSize( mFilterAll->getTextSize().width + 24, mFilterAll->getSize().height );
|
||||
curX += mFilterAll->getTextSize().width + 24 + 4;
|
||||
|
||||
mFilterWeapon->setPosition(curX, mFilterWeapon->getPosition().top);
|
||||
mFilterWeapon->setSize( mFilterWeapon->getTextSize().width + 24, mFilterWeapon->getSize().height );
|
||||
curX += mFilterWeapon->getTextSize().width + 24 + 4;
|
||||
|
||||
mFilterApparel->setPosition(curX, mFilterApparel->getPosition().top);
|
||||
mFilterApparel->setSize( mFilterApparel->getTextSize().width + 24, mFilterApparel->getSize().height );
|
||||
curX += mFilterApparel->getTextSize().width + 24 + 4;
|
||||
|
||||
mFilterMagic->setPosition(curX, mFilterMagic->getPosition().top);
|
||||
mFilterMagic->setSize( mFilterMagic->getTextSize().width + 24, mFilterMagic->getSize().height );
|
||||
curX += mFilterMagic->getTextSize().width + 24 + 4;
|
||||
|
||||
mFilterMisc->setPosition(curX, mFilterMisc->getPosition().top);
|
||||
mFilterMisc->setSize( mFilterMisc->getTextSize().width + 24, mFilterMisc->getSize().height );
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void TradeWindow::startTrade(MWWorld::Ptr actor)
|
||||
{
|
||||
ContainerBase::openContainer(actor);
|
||||
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
void TradeWindow::onFilterChanged(MyGUI::Widget* _sender)
|
||||
{
|
||||
if (_sender == mFilterAll)
|
||||
setFilter(ContainerBase::Filter_All);
|
||||
else if (_sender == mFilterWeapon)
|
||||
setFilter(ContainerBase::Filter_Weapon);
|
||||
else if (_sender == mFilterApparel)
|
||||
setFilter(ContainerBase::Filter_Apparel);
|
||||
else if (_sender == mFilterMagic)
|
||||
setFilter(ContainerBase::Filter_Magic);
|
||||
else if (_sender == mFilterMisc)
|
||||
setFilter(ContainerBase::Filter_Misc);
|
||||
|
||||
mFilterAll->setStateSelected(false);
|
||||
mFilterWeapon->setStateSelected(false);
|
||||
mFilterApparel->setStateSelected(false);
|
||||
mFilterMagic->setStateSelected(false);
|
||||
mFilterMisc->setStateSelected(false);
|
||||
|
||||
static_cast<MyGUI::Button*>(_sender)->setStateSelected(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ WindowManager::WindowManager(
|
|||
console = new Console(w,h, extensions);
|
||||
mJournal = new JournalWindow(*this);
|
||||
mMessageBoxManager = new MessageBoxManager(this);
|
||||
mTradeWindow = new TradeWindow(*this);
|
||||
mDialogueWindow = new DialogueWindow(*this);
|
||||
mContainerWindow = new ContainerWindow(*this,mDragAndDrop);
|
||||
mInventoryWindow = new InventoryWindow(*this,mDragAndDrop);
|
||||
|
@ -116,7 +117,6 @@ 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);
|
||||
|
|
|
@ -2,16 +2,10 @@
|
|||
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="Window" skin="MW_Window" layer="Windows" position="0 0 600 300" name="_Main">
|
||||
|
||||
<!-- Items in inventory -->
|
||||
<Widget type="Widget" skin="MW_Box" position="0 38 350 185" name="box" align="Left Top Stretch">
|
||||
<Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 342 181" align="Left Top Stretch" name="ItemView">
|
||||
<Widget type="Button" skin="" name="Items" position="0 0 342 181" name="Items" align="Left Top Stretch"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Property key="Visible" value="false"/>
|
||||
|
||||
<!-- Categories -->
|
||||
<Widget type="Widget" position="0 8 350 24" align="Left Top HStretch" name="Categories">
|
||||
<Widget type="Widget" position="8 8 584 24" align="Left Top HStretch" name="Categories">
|
||||
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="AllButton"/>
|
||||
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="WeaponButton"/>
|
||||
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="ApparelButton"/>
|
||||
|
@ -19,6 +13,17 @@
|
|||
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="MiscButton"/>
|
||||
</Widget>
|
||||
|
||||
<!-- Items -->
|
||||
<Widget type="Widget" skin="MW_Box" position="8 38 584 185" name="box" align="Left Top Stretch">
|
||||
<Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 576 181" align="Left Top Stretch" name="ItemView">
|
||||
<Widget type="Button" skin="" name="Items" position="0 0 576 181" name="Items" align="Left Top Stretch"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<Widget type="Widget" skin="" position="8 201 584 91" name="BottomPanel" align="Left Bottom HStretch">
|
||||
<Widget type="TextBox" skin="SandText" position="292 0 292 91" name="PlayerGold" align="Left Top HStretch"/>
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
|
||||
</MyGUI>
|
||||
|
|
Loading…
Reference in a new issue