mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 01:49:41 +00:00
more spell buying window cleanup
This commit is contained in:
parent
0696a3b10e
commit
996e6280d8
4 changed files with 18 additions and 53 deletions
|
@ -34,13 +34,7 @@ namespace MWGui
|
|||
getWidget(mPlayerGold, "PlayerGold");
|
||||
getWidget(mSelect, "Select");
|
||||
getWidget(mSpells, "Spells");
|
||||
getWidget(mSpellsBoxWidget, "SpellsBox");
|
||||
getWidget(mSpellsClientWidget, "SpellsClient");
|
||||
getWidget(mSpellsScrollerWidget, "SpellsScroller");
|
||||
|
||||
mSpellsClientWidget->eventMouseWheel += MyGUI::newDelegate(this, &SpellBuyingWindow::onMouseWheel);
|
||||
|
||||
mSpellsScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &SpellBuyingWindow::onScrollChangePosition);
|
||||
getWidget(mSpellsView, "SpellsView");
|
||||
|
||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellBuyingWindow::onCancelButtonClicked);
|
||||
|
||||
|
@ -58,7 +52,7 @@ namespace MWGui
|
|||
{
|
||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId);
|
||||
int price = spell->data.cost*MWBase::Environment::get().getWorld()->getStore().gameSettings.search("fSpellValueMult")->f;
|
||||
MyGUI::Button* toAdd = mSpellsClientWidget->createWidget<MyGUI::Button>((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SpellText", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default);
|
||||
MyGUI::Button* toAdd = mSpellsView->createWidget<MyGUI::Button>((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SpellText", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default);
|
||||
mCurrentY += sLineHeight;
|
||||
/// \todo price adjustment depending on merchantile skill
|
||||
toAdd->setUserData(price);
|
||||
|
@ -73,11 +67,10 @@ namespace MWGui
|
|||
|
||||
void SpellBuyingWindow::clearSpells()
|
||||
{
|
||||
mSpellsScrollerWidget->setScrollPosition(0);
|
||||
onScrollChangePosition(mSpellsScrollerWidget, mSpellsScrollerWidget->getScrollPosition());
|
||||
mSpellsView->setViewOffset(MyGUI::IntPoint(0,0));
|
||||
mCurrentY = 0;
|
||||
while (mSpellsClientWidget->getChildCount())
|
||||
MyGUI::Gui::getInstance().destroyWidget(mSpellsClientWidget->getChildAt(0));
|
||||
while (mSpellsView->getChildCount())
|
||||
MyGUI::Gui::getInstance().destroyWidget(mSpellsView->getChildAt(0));
|
||||
mSpellsWidgetMap.clear();
|
||||
}
|
||||
|
||||
|
@ -106,7 +99,8 @@ namespace MWGui
|
|||
}
|
||||
|
||||
updateLabels();
|
||||
updateScroller();
|
||||
|
||||
mSpellsView->setCanvasSize (MyGUI::IntSize(mSpellsView->getWidth(), std::max(mSpellsView->getHeight(), mCurrentY)));
|
||||
}
|
||||
|
||||
void SpellBuyingWindow::onSpellButtonClick(MyGUI::Widget* _sender)
|
||||
|
@ -120,10 +114,9 @@ namespace MWGui
|
|||
MWMechanics::Spells& spells = stats.getSpells();
|
||||
spells.add (mSpellsWidgetMap.find(_sender)->second);
|
||||
mWindowManager.getTradeWindow()->addOrRemoveGold(-price);
|
||||
mSpellsScrollerWidget->setScrollPosition(0);
|
||||
onScrollChangePosition(mSpellsScrollerWidget, mSpellsScrollerWidget->getScrollPosition());
|
||||
updateScroller();
|
||||
startSpellBuying(mActor);
|
||||
|
||||
MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,39 +142,12 @@ namespace MWGui
|
|||
mWindowManager.removeGuiMode(GM_Dialogue);
|
||||
}
|
||||
|
||||
void SpellBuyingWindow::updateScroller()
|
||||
{
|
||||
mSpellsScrollerWidget->setScrollRange(std::max(mCurrentY - mSpellsClientWidget->getHeight(), 0));
|
||||
mSpellsScrollerWidget->setScrollPage(std::max(mSpellsClientWidget->getHeight() - sLineHeight, 0));
|
||||
if (mCurrentY != 0)
|
||||
mSpellsScrollerWidget->setTrackSize( (mSpellsBoxWidget->getHeight() / float(mCurrentY)) * mSpellsScrollerWidget->getLineSize() );
|
||||
}
|
||||
|
||||
void SpellBuyingWindow::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos)
|
||||
{
|
||||
int diff = mLastPos - pos;
|
||||
// Adjust position of all widget according to difference
|
||||
if (diff == 0)
|
||||
return;
|
||||
mLastPos = pos;
|
||||
|
||||
for (unsigned int i=0;i<mSpellsClientWidget->getChildCount();i++)
|
||||
{
|
||||
MyGUI::Widget* toMove = mSpellsClientWidget->getChildAt(i);
|
||||
toMove->setCoord(toMove->getCoord() + MyGUI::IntPoint(0, diff));
|
||||
}
|
||||
}
|
||||
|
||||
void SpellBuyingWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel)
|
||||
{
|
||||
if (mSpellsScrollerWidget->getScrollPosition() - _rel*0.3 < 0)
|
||||
mSpellsScrollerWidget->setScrollPosition(0);
|
||||
else if (mSpellsScrollerWidget->getScrollPosition() - _rel*0.3 > mSpellsScrollerWidget->getScrollRange()-1)
|
||||
mSpellsScrollerWidget->setScrollPosition(mSpellsScrollerWidget->getScrollRange()-1);
|
||||
if (mSpellsView->getViewOffset().top + _rel*0.3 > 0)
|
||||
mSpellsView->setViewOffset(MyGUI::IntPoint(0, 0));
|
||||
else
|
||||
mSpellsScrollerWidget->setScrollPosition(mSpellsScrollerWidget->getScrollPosition() - _rel*0.3);
|
||||
|
||||
onScrollChangePosition(mSpellsScrollerWidget, mSpellsScrollerWidget->getScrollPosition());
|
||||
mSpellsView->setViewOffset(MyGUI::IntPoint(0, mSpellsView->getViewOffset().top + _rel*0.3));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@ namespace MWGui
|
|||
MyGUI::TextBox* mSpells;
|
||||
MyGUI::TextBox* mSelect;
|
||||
|
||||
MyGUI::WidgetPtr mSpellsBoxWidget, mSpellsClientWidget;
|
||||
MyGUI::ScrollBar* mSpellsScrollerWidget;
|
||||
MyGUI::ScrollView* mSpellsView;
|
||||
|
||||
MWWorld::Ptr mActor;
|
||||
|
||||
|
@ -42,8 +41,6 @@ namespace MWGui
|
|||
|
||||
void onCancelButtonClicked(MyGUI::Widget* _sender);
|
||||
void onSpellButtonClick(MyGUI::Widget* _sender);
|
||||
void updateScroller();
|
||||
void onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos);
|
||||
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
|
||||
void addSpell(const std::string& spellID);
|
||||
void clearSpells();
|
||||
|
|
|
@ -678,6 +678,7 @@ void WindowManager::processChangedSettings(const Settings::CategorySettingVector
|
|||
mScrollWindow->center();
|
||||
mBookWindow->center();
|
||||
mQuickKeysMenu->center();
|
||||
mSpellBuyingWindow->center();
|
||||
mDragAndDrop->mDragAndDropWidget->setSize(MyGUI::IntSize(x, y));
|
||||
mInputBlocker->setSize(MyGUI::IntSize(x,y));
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
</Widget>
|
||||
|
||||
|
||||
<Widget type="Widget" skin="MW_Box" position="6 31 430 225" align="ALIGN_LEFT ALIGN_STRETCH" name="SpellsBox">
|
||||
<Widget type="Widget" skin="" position="4 4 404 217" align="ALIGN_LEFT ALIGN_TOP ALIGN_STRETCH" name="SpellsClient" />
|
||||
<Widget type="ScrollBar" skin="MW_VScroll" position="412 4 14 217" align="ALIGN_RIGHT ALIGN_VSTRETCH" name="SpellsScroller" />
|
||||
<Widget type="Widget" skin="MW_Box" position="6 31 430 225" align="ALIGN_LEFT ALIGN_STRETCH">
|
||||
<Widget type="ScrollView" skin="MW_ScrollView" position="4 4 422 217" align="ALIGN_LEFT ALIGN_TOP ALIGN_STRETCH" name="SpellsView">
|
||||
<Property key="CanvasAlign" value="Left"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue