Rework level up dialog to behave more like vanilla

deque
MiroslavR 11 years ago
parent 0f2305ae43
commit 3b67e9b329

@ -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);
}

@ -28,6 +28,9 @@ namespace MWGui
std::vector<int> mSpentAttributes;
unsigned int mCoinCount;
static const unsigned int sMaxCoins;
void onOkButtonClicked(MyGUI::Widget* sender);
void onAttributeClicked(MyGUI::Widget* sender);

@ -23,7 +23,7 @@
</Widget>
<Widget type="Widget" skin="" position="0 0 100 16" name="Coins">
<UserString key="HStretch" value="false"/>
<UserString key="HStretch" value="true"/>
<UserString key="VStretch" value="false"/>
</Widget>

Loading…
Cancel
Save