|
|
|
@ -16,9 +16,10 @@
|
|
|
|
|
|
|
|
|
|
namespace MWGui
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
const unsigned int LevelupDialog::sMaxCoins = 3;
|
|
|
|
|
LevelupDialog::LevelupDialog()
|
|
|
|
|
: WindowBase("openmw_levelup_dialog.layout")
|
|
|
|
|
: WindowBase("openmw_levelup_dialog.layout"),
|
|
|
|
|
mCoinCount(sMaxCoins)
|
|
|
|
|
{
|
|
|
|
|
getWidget(mOkButton, "OkButton");
|
|
|
|
|
getWidget(mClassImage, "ClassImage");
|
|
|
|
@ -46,12 +47,10 @@ namespace MWGui
|
|
|
|
|
mAttributeMultipliers.push_back(t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int curX = mMainWidget->getWidth()/2 - (16 + 2) * 1.5;
|
|
|
|
|
for (int i=0; i<3; ++i)
|
|
|
|
|
for (unsigned int i = 0; i < mCoinCount; ++i)
|
|
|
|
|
{
|
|
|
|
|
MyGUI::ImageBox* image = mMainWidget->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(curX,250,16,16), MyGUI::Align::Default);
|
|
|
|
|
MyGUI::ImageBox* image = mCoinBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0,0,16,16), MyGUI::Align::Default);
|
|
|
|
|
image->setImageTexture ("icons\\tx_goldicon.dds");
|
|
|
|
|
curX += 24+2;
|
|
|
|
|
mCoins.push_back(image);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -82,14 +81,15 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
void LevelupDialog::resetCoins()
|
|
|
|
|
{
|
|
|
|
|
int curX = 0;
|
|
|
|
|
for (int i=0; i<3; ++i)
|
|
|
|
|
const int coinSpacing = 10;
|
|
|
|
|
int curX = mCoinBox->getWidth()/2 - (coinSpacing*(mCoinCount - 1) + 16*mCoinCount)/2;
|
|
|
|
|
for (unsigned int i=0; i<mCoinCount; ++i)
|
|
|
|
|
{
|
|
|
|
|
MyGUI::ImageBox* image = mCoins[i];
|
|
|
|
|
image->detachFromWidget();
|
|
|
|
|
image->attachToWidget(mCoinBox);
|
|
|
|
|
image->setCoord(MyGUI::IntCoord(curX,0,16,16));
|
|
|
|
|
curX += 24+2;
|
|
|
|
|
curX += 16+coinSpacing;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -121,11 +121,6 @@ namespace MWGui
|
|
|
|
|
MWMechanics::CreatureStats& creatureStats = player.getClass().getCreatureStats(player);
|
|
|
|
|
MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats(player);
|
|
|
|
|
|
|
|
|
|
mSpentAttributes.clear();
|
|
|
|
|
resetCoins();
|
|
|
|
|
|
|
|
|
|
setAttributeValues();
|
|
|
|
|
|
|
|
|
|
const ESM::NPC *playerData = player.get<ESM::NPC>()->mBase;
|
|
|
|
|
|
|
|
|
|
// set class image
|
|
|
|
@ -160,12 +155,40 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
mLevelDescription->setCaption (levelupdescription);
|
|
|
|
|
|
|
|
|
|
unsigned int availableAttributes = 0;
|
|
|
|
|
for (int i = 0; i < 8; ++i)
|
|
|
|
|
{
|
|
|
|
|
MyGUI::TextBox* text = mAttributeMultipliers[i];
|
|
|
|
|
if (pcStats.getAttribute(i).getBase() < 100)
|
|
|
|
|
{
|
|
|
|
|
mAttributes[i]->setEnabled(true);
|
|
|
|
|
availableAttributes++;
|
|
|
|
|
|
|
|
|
|
int mult = pcStats.getLevelupAttributeMultiplier (i);
|
|
|
|
|
text->setCaption(mult <= 1 ? "" : "x" + boost::lexical_cast<std::string>(mult));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mAttributes[i]->setEnabled(false);
|
|
|
|
|
|
|
|
|
|
text->setCaption("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mCoinCount = std::min(sMaxCoins, availableAttributes);
|
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < sMaxCoins; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i < mCoinCount)
|
|
|
|
|
mCoins[i]->attachToWidget(mCoinBox);
|
|
|
|
|
else
|
|
|
|
|
mCoins[i]->detachFromWidget();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mSpentAttributes.clear();
|
|
|
|
|
resetCoins();
|
|
|
|
|
|
|
|
|
|
setAttributeValues();
|
|
|
|
|
|
|
|
|
|
center();
|
|
|
|
|
}
|
|
|
|
@ -175,12 +198,12 @@ namespace MWGui
|
|
|
|
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
|
|
|
|
MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats (player);
|
|
|
|
|
|
|
|
|
|
if (mSpentAttributes.size() < 3)
|
|
|
|
|
if (mSpentAttributes.size() < mCoinCount)
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage36}");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// increase attributes
|
|
|
|
|
for (int i=0; i<3; ++i)
|
|
|
|
|
for (unsigned int i = 0; i < mCoinCount; ++i)
|
|
|
|
|
{
|
|
|
|
|
MWMechanics::AttributeValue attribute = pcStats.getAttribute(mSpentAttributes[i]);
|
|
|
|
|
attribute.setBase(attribute.getBase() + pcStats.getLevelupAttributeMultiplier(mSpentAttributes[i]));
|
|
|
|
@ -206,8 +229,8 @@ namespace MWGui
|
|
|
|
|
mSpentAttributes.erase(found);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (mSpentAttributes.size() == 3)
|
|
|
|
|
mSpentAttributes[2] = attribute;
|
|
|
|
|
if (mSpentAttributes.size() == mCoinCount)
|
|
|
|
|
mSpentAttributes[mCoinCount - 1] = attribute;
|
|
|
|
|
else
|
|
|
|
|
mSpentAttributes.push_back(attribute);
|
|
|
|
|
}
|
|
|
|
|