forked from teamnwah/openmw-tes3coop
fix a bug, some cleanup
This commit is contained in:
parent
342a244e31
commit
fb47681fbd
9 changed files with 30 additions and 40 deletions
|
@ -109,8 +109,9 @@ void ContainerBase::onSelectedItem(MyGUI::Widget* _sender)
|
|||
}
|
||||
else
|
||||
{
|
||||
std::string message = MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sTake")->str;
|
||||
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
||||
dialog->open(MWWorld::Class::get(object).getName(object), count);
|
||||
dialog->open(MWWorld::Class::get(object).getName(object), message, count);
|
||||
dialog->eventOkClicked.clear();
|
||||
dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerBase::startDragItem);
|
||||
}
|
||||
|
@ -135,6 +136,10 @@ void ContainerBase::onSelectedItem(MyGUI::Widget* _sender)
|
|||
}
|
||||
}
|
||||
|
||||
bool buying = isTradeWindow(); // buying or selling?
|
||||
std::string message = buying ? MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sQuanityMenuMessage02")->str
|
||||
: MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sQuanityMenuMessage01")->str;
|
||||
|
||||
if (std::find(mBoughtItems.begin(), mBoughtItems.end(), object) != mBoughtItems.end())
|
||||
{
|
||||
if (MyGUI::InputManager::getInstance().isShiftPressed() || count == 1)
|
||||
|
@ -148,7 +153,7 @@ void ContainerBase::onSelectedItem(MyGUI::Widget* _sender)
|
|||
else
|
||||
{
|
||||
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
||||
dialog->open(MWWorld::Class::get(object).getName(object), count);
|
||||
dialog->open(MWWorld::Class::get(object).getName(object), message, count);
|
||||
dialog->eventOkClicked.clear();
|
||||
dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerBase::sellAlreadyBoughtItem);
|
||||
}
|
||||
|
@ -166,7 +171,7 @@ void ContainerBase::onSelectedItem(MyGUI::Widget* _sender)
|
|||
else
|
||||
{
|
||||
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
||||
dialog->open(MWWorld::Class::get(object).getName(object), count);
|
||||
dialog->open(MWWorld::Class::get(object).getName(object), message, count);
|
||||
dialog->eventOkClicked.clear();
|
||||
dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerBase::sellItem);
|
||||
}
|
||||
|
@ -202,13 +207,15 @@ void ContainerBase::sellItem(MyGUI::Widget* _sender, int count)
|
|||
if (isInventory())
|
||||
{
|
||||
newPtr = MWBase::Environment::get().getWindowManager()->getTradeWindow()->addBarteredItem(*mSelectedItem->getUserData<MWWorld::Ptr>(), count);
|
||||
mSoldItems.push_back(newPtr);
|
||||
if (std::find(mSoldItems.begin(), mSoldItems.end(), newPtr) == mSoldItems.end())
|
||||
mSoldItems.push_back(newPtr);
|
||||
MWBase::Environment::get().getWindowManager()->getTradeWindow()->drawItems();
|
||||
}
|
||||
else
|
||||
{
|
||||
newPtr = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->addBarteredItem(*mSelectedItem->getUserData<MWWorld::Ptr>(), count);
|
||||
mSoldItems.push_back(newPtr);
|
||||
if (std::find(mSoldItems.begin(), mSoldItems.end(), newPtr) == mSoldItems.end())
|
||||
mSoldItems.push_back(newPtr);
|
||||
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->drawItems();
|
||||
}
|
||||
|
||||
|
@ -510,8 +517,6 @@ void ContainerBase::drawItems()
|
|||
MyGUI::IntSize size = MyGUI::IntSize(std::max(mItemView->getSize().width, x+42), mItemView->getSize().height);
|
||||
mItemView->setCanvasSize(size);
|
||||
mContainerWidget->setSize(size);
|
||||
|
||||
notifyContentChanged();
|
||||
}
|
||||
|
||||
std::string ContainerBase::getCountString(const int count)
|
||||
|
@ -524,16 +529,6 @@ std::string ContainerBase::getCountString(const int count)
|
|||
return boost::lexical_cast<std::string>(count);
|
||||
}
|
||||
|
||||
void ContainerBase::Update()
|
||||
{
|
||||
if(mDragAndDrop != NULL && mDragAndDrop->mIsOnDragAndDrop)
|
||||
{
|
||||
if(mDragAndDrop->mDraggedWidget)
|
||||
mDragAndDrop->mDraggedWidget->setPosition(MyGUI::InputManager::getInstance().getMousePosition());
|
||||
else mDragAndDrop->mIsOnDragAndDrop = false; //If this happens, there is a bug.
|
||||
}
|
||||
}
|
||||
|
||||
MWWorld::Ptr ContainerBase::readdBarteredItem(MWWorld::Ptr item, int count)
|
||||
{
|
||||
MWWorld::ContainerStore& containerStore = MWWorld::Class::get(mContainer).getContainerStore(mContainer);
|
||||
|
@ -558,7 +553,9 @@ MWWorld::Ptr ContainerBase::addBarteredItem(MWWorld::Ptr item, int count)
|
|||
MWWorld::ContainerStoreIterator it = containerStore.add(item);
|
||||
item.getRefData().setCount(origCount - count);
|
||||
|
||||
mBoughtItems.push_back(*it);
|
||||
if (std::find(mBoughtItems.begin(), mBoughtItems.end(), *it) == mBoughtItems.end())
|
||||
mBoughtItems.push_back(*it);
|
||||
|
||||
return *it;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,11 +73,8 @@ namespace MWGui
|
|||
|
||||
void openContainer(MWWorld::Ptr container);
|
||||
void setFilter(Filter filter); ///< set category filter
|
||||
virtual void Update();
|
||||
void drawItems();
|
||||
|
||||
virtual void notifyContentChanged() { }
|
||||
|
||||
protected:
|
||||
MyGUI::ScrollView* mItemView;
|
||||
MyGUI::Widget* mContainerWidget;
|
||||
|
|
|
@ -19,7 +19,6 @@ namespace MWGui
|
|||
|
||||
mOkButton->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sOk")->str);
|
||||
mCancelButton->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sCancel")->str);
|
||||
mLabelText->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sTake")->str);
|
||||
|
||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CountDialog::onCancelButtonClicked);
|
||||
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CountDialog::onOkButtonClicked);
|
||||
|
@ -27,10 +26,12 @@ namespace MWGui
|
|||
mSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &CountDialog::onSliderMoved);
|
||||
}
|
||||
|
||||
void CountDialog::open(const std::string& item, const int maxCount)
|
||||
void CountDialog::open(const std::string& item, const std::string& message, const int maxCount)
|
||||
{
|
||||
setVisible(true);
|
||||
|
||||
mLabelText->setCaption(message);
|
||||
|
||||
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
|
||||
mSlider->setScrollRange(maxCount);
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace MWGui
|
|||
{
|
||||
public:
|
||||
CountDialog(WindowManager& parWindowManager);
|
||||
void open(const std::string& item, const int maxCount);
|
||||
void open(const std::string& item, const std::string& message, const int maxCount);
|
||||
|
||||
typedef MyGUI::delegates::CMultiDelegate2<MyGUI::Widget*, int> EventHandle_WidgetInt;
|
||||
|
||||
|
|
|
@ -285,7 +285,6 @@ void HUD::onWorldClicked(MyGUI::Widget* _sender)
|
|||
|
||||
// remove object from the container it was coming from
|
||||
object.getRefData().setCount(origCount - mDragAndDrop->mDraggedCount);
|
||||
mDragAndDrop->mDraggedFrom->notifyContentChanged();
|
||||
|
||||
mDragAndDrop->mIsOnDragAndDrop = false;
|
||||
MyGUI::Gui::getInstance().destroyWidget(mDragAndDrop->mDraggedWidget);
|
||||
|
|
|
@ -228,15 +228,9 @@ namespace MWGui
|
|||
mEncumbranceText->setCaption( boost::lexical_cast<std::string>(int(encumbrance)) + "/" + boost::lexical_cast<std::string>(int(capacity)) );
|
||||
}
|
||||
|
||||
void InventoryWindow::notifyContentChanged()
|
||||
{
|
||||
}
|
||||
|
||||
void InventoryWindow::Update()
|
||||
void InventoryWindow::update()
|
||||
{
|
||||
updateEncumbranceBar();
|
||||
|
||||
ContainerBase::Update();
|
||||
}
|
||||
|
||||
int InventoryWindow::getPlayerGold()
|
||||
|
|
|
@ -16,8 +16,7 @@ namespace MWGui
|
|||
/// start trading, disables item drag&drop
|
||||
void startTrade();
|
||||
|
||||
virtual void Update();
|
||||
virtual void notifyContentChanged();
|
||||
void update();
|
||||
|
||||
int getPlayerGold();
|
||||
|
||||
|
|
|
@ -27,9 +27,6 @@ namespace MWGui
|
|||
|
||||
void startTrade(MWWorld::Ptr actor);
|
||||
|
||||
//virtual void Update();
|
||||
//virtual void notifyContentChanged();
|
||||
|
||||
bool npcAcceptsItem(MWWorld::Ptr item);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -97,7 +97,7 @@ WindowManager::WindowManager(
|
|||
MyGUI::Widget* dragAndDropWidget = gui->createWidgetT("Widget","",0,0,w,h,MyGUI::Align::Default,"DragAndDrop","DragAndDropWidget");
|
||||
dragAndDropWidget->setVisible(false);
|
||||
|
||||
DragAndDrop* mDragAndDrop = new DragAndDrop();
|
||||
mDragAndDrop = new DragAndDrop();
|
||||
mDragAndDrop->mIsOnDragAndDrop = false;
|
||||
mDragAndDrop->mDraggedWidget = 0;
|
||||
mDragAndDrop->mDragAndDropWidget = dragAndDropWidget;
|
||||
|
@ -468,9 +468,15 @@ void WindowManager::onDialogueWindowBye()
|
|||
void WindowManager::onFrame (float frameDuration)
|
||||
{
|
||||
mMessageBoxManager->onFrame(frameDuration);
|
||||
mInventoryWindow->Update();
|
||||
mContainerWindow->Update();
|
||||
mToolTips->onFrame(frameDuration);
|
||||
|
||||
if (mDragAndDrop->mIsOnDragAndDrop)
|
||||
{
|
||||
assert(mDragAndDrop->mDraggedWidget);
|
||||
mDragAndDrop->mDraggedWidget->setPosition(MyGUI::InputManager::getInstance().getMousePosition());
|
||||
}
|
||||
|
||||
mInventoryWindow->update();
|
||||
}
|
||||
|
||||
const ESMS::ESMStore& WindowManager::getStore() const
|
||||
|
|
Loading…
Reference in a new issue