Levelup dialog is now dynamic; added level descriptions

actorid
scrawl 12 years ago
parent 41a958cd4e
commit 4c588cbab6

@ -23,6 +23,8 @@ namespace MWGui
getWidget(mOkButton, "OkButton");
getWidget(mClassImage, "ClassImage");
getWidget(mLevelText, "LevelText");
getWidget(mLevelDescription, "LevelDescription");
getWidget(mCoinBox, "Coins");
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &LevelupDialog::onOkButtonClicked);
@ -80,11 +82,13 @@ namespace MWGui
void LevelupDialog::resetCoins ()
{
int curX = mMainWidget->getWidth()/2 - (16 + 2) * 1.5;
int curX = 0;
for (int i=0; i<3; ++i)
{
MyGUI::ImageBox* image = mCoins[i];
image->setCoord(MyGUI::IntCoord(curX,250,16,16));
image->detachFromWidget();
image->attachToWidget(mCoinBox);
image->setCoord(MyGUI::IntCoord(curX,0,16,16));
curX += 24+2;
}
}
@ -95,6 +99,9 @@ namespace MWGui
for (unsigned int i=0; i<mSpentAttributes.size(); ++i)
{
MyGUI::ImageBox* image = mCoins[i];
image->detachFromWidget();
image->attachToWidget(mMainWidget);
int attribute = mSpentAttributes[i];
int xdiff = mAttributeMultipliers[attribute]->getCaption() == "" ? 0 : 30;
@ -113,8 +120,6 @@ namespace MWGui
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get(player).getCreatureStats (player);
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
center();
mSpentAttributes.clear();
resetCoins();
@ -128,16 +133,25 @@ namespace MWGui
mClassImage->setImageTexture ("textures\\levelup\\" + cls->mId + ".dds");
/// \todo replace this with INI-imported texts
int level = creatureStats.getLevel ()+1;
mLevelText->setCaptionWithReplacing("#{sLevelUpMenu1} " + boost::lexical_cast<std::string>(level));
std::string levelupdescription;
if(level>20)
levelupdescription=world->getFallback("Level_Up_Default");
else
levelupdescription=world->getFallback("Level_Up_Level"+boost::lexical_cast<std::string>(level));
mLevelDescription->setCaption (levelupdescription);
for (int i=0; i<8; ++i)
{
MyGUI::TextBox* text = mAttributeMultipliers[i];
int mult = pcStats.getLevelupAttributeMultiplier (i);
text->setCaption(mult <= 1 ? "" : "x" + boost::lexical_cast<std::string>(mult));
}
center();
}
void LevelupDialog::onOkButtonClicked (MyGUI::Widget* sender)

@ -17,6 +17,9 @@ namespace MWGui
MyGUI::Button* mOkButton;
MyGUI::ImageBox* mClassImage;
MyGUI::TextBox* mLevelText;
MyGUI::EditBox* mLevelDescription;
MyGUI::Widget* mCoinBox;
std::vector<MyGUI::Button*> mAttributes;
std::vector<MyGUI::TextBox*> mAttributeValues;

@ -586,6 +586,30 @@ void AutoSizedTextBox::setPropertyOverride(const std::string& _key, const std::s
}
}
MyGUI::IntSize AutoSizedEditBox::getRequestedSize()
{
return MyGUI::IntSize(getSize().width, getTextSize().height);
}
void AutoSizedEditBox::setCaption(const MyGUI::UString& _value)
{
EditBox::setCaption(_value);
notifySizeChange (this);
}
void AutoSizedEditBox::setPropertyOverride(const std::string& _key, const std::string& _value)
{
if (_key == "ExpandDirection")
{
mExpandDirection = MyGUI::Align::parse (_value);
}
else
{
EditBox::setPropertyOverride (_key, _value);
}
}
MyGUI::IntSize AutoSizedButton::getRequestedSize()
{
@ -660,6 +684,8 @@ void HBox::align ()
{
sizes.push_back (std::make_pair(w->getSize(), hstretch));
total_width += w->getSize().width;
if (!(w->getUserString("VStretch") == "true"))
total_height = std::max(total_height, w->getSize().height);
}
if (i != count-1)
@ -783,6 +809,9 @@ void VBox::align ()
{
sizes.push_back (std::make_pair(w->getSize(), vstretch));
total_height += w->getSize().height;
if (!(w->getUserString("HStretch") == "true"))
total_width = std::max(total_width, w->getSize().width);
}
if (i != count-1)

@ -7,6 +7,7 @@
#include <MyGUI_Widget.h>
#include <MyGUI_TextBox.h>
#include <MyGUI_Button.h>
#include <MyGUI_EditBox.h>
namespace MyGUI
{
@ -340,6 +341,18 @@ namespace MWGui
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
};
class AutoSizedEditBox : public AutoSizedWidget, public MyGUI::EditBox
{
MYGUI_RTTI_DERIVED( AutoSizedEditBox )
public:
virtual MyGUI::IntSize getRequestedSize();
virtual void setCaption(const MyGUI::UString& _value);
protected:
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
};
class AutoSizedButton : public AutoSizedWidget, public MyGUI::Button
{
MYGUI_RTTI_DERIVED( AutoSizedButton )

@ -129,6 +129,7 @@ WindowManager::WindowManager(
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::HBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::VBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::AutoSizedTextBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::AutoSizedEditBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::AutoSizedButton>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::ImageButton>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::ExposedWindow>("Widget");

@ -1,17 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 440 438" name="_Main">
<Widget type="VBox" skin="MW_Dialog" layer="Windows" position="0 0 0 0" name="_Main">
<Property key="Padding" value="12"/>
<Property key="Spacing" value="8"/>
<Property key="AutoResize" value="true"/>
<Widget type="Widget" skin="MW_Box" position="28 14 391 198">
<UserString key="HStretch" value="false"/>
<UserString key="VStretch" value="false"/>
<Widget type="ImageBox" skin="ImageBox" name="ClassImage" position="4 4 383 190">
</Widget>
</Widget>
<Widget type="TextBox" skin="SandText" position="28 218 391 24" name="LevelText">
<Widget type="AutoSizedTextBox" skin="SandText" position="28 218 391 24" name="LevelText">
</Widget>
<Widget type="Widget" skin="" position="36 280 400 400">
<Widget type="AutoSizedEditBox" skin="SandText" position="36 280 330 24" name="LevelDescription">
<Property key="MultiLine" value="true"/>
<Property key="WordWrap" value="true"/>
<Property key="Static" value="true"/>
</Widget>
<Widget type="Widget" skin="" position="0 0 100 16" name="Coins">
<UserString key="HStretch" value="false"/>
<UserString key="VStretch" value="false"/>
</Widget>
<Widget type="Widget" skin="" position="0 280 350 100">
<UserString key="HStretch" value="false"/>
<UserString key="VStretch" value="false"/>
<Widget type="TextBox" skin="SandText" position="0 0 100 24" name="AttribMultiplier1"/>
<Widget type="TextBox" skin="SandText" position="0 24 100 24" name="AttribMultiplier2"/>
<Widget type="TextBox" skin="SandText" position="0 48 100 24" name="AttribMultiplier3"/>
@ -127,12 +146,17 @@
</Widget>
</Widget>
<Widget type="AutoSizedButton" skin="MW_Button" position="422 398 0 24" name="OkButton">
<Property key="ExpandDirection" value="Left"/>
<Property key="Caption" value="#{sOk}"/>
<Widget type="HBox" skin="" position="0 0 330 24">
<UserString key="HStretch" value="true"/>
<Widget type="Widget">
<UserString key="HStretch" value="true"/>
</Widget>
<Widget type="AutoSizedButton" skin="MW_Button" position="0 0 0 24" name="OkButton">
<Property key="Caption" value="#{sOk}"/>
</Widget>
</Widget>
</Widget>
</MyGUI>

Loading…
Cancel
Save