Dynamically build the attribute selection dialog

revert-6246b479
Evil Eye 2 years ago
parent ea2cedb5ea
commit 75f0ad4e95

@ -749,24 +749,29 @@ namespace MWGui
center();
const auto& store = MWBase::Environment::get().getWorld()->getStore().get<ESM::Attribute>();
MyGUI::ScrollView* attributes;
getWidget(attributes, "Attributes");
MyGUI::IntCoord coord{ 0, 0, attributes->getWidth(), 18 };
for (const ESM::Attribute& attribute : store)
{
Widgets::MWAttributePtr widget;
char theIndex = '0' + attribute.mId;
getWidget(widget, std::string("Attribute").append(1, theIndex));
auto* widget
= attributes->createWidget<Widgets::MWAttribute>("MW_StatNameButtonC", coord, MyGUI::Align::Default);
coord.top += coord.height;
widget->setAttributeId(attribute.mId);
widget->eventClicked += MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked);
ToolTips::createAttributeToolTip(widget, widget->getAttributeId());
ToolTips::createAttributeToolTip(widget, attribute.mId);
}
attributes->setVisibleVScroll(false);
attributes->setCanvasSize(MyGUI::IntSize(attributes->getWidth(), std::max(attributes->getHeight(), coord.top)));
attributes->setVisibleVScroll(true);
attributes->setViewOffset(MyGUI::IntPoint());
MyGUI::Button* cancelButton;
getWidget(cancelButton, "CancelButton");
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked);
}
SelectAttributeDialog::~SelectAttributeDialog() {}
// widget controls
void SelectAttributeDialog::onAttributeClicked(Widgets::MWAttributePtr _sender)

@ -184,7 +184,7 @@ namespace MWGui
{
public:
SelectAttributeDialog();
~SelectAttributeDialog();
~SelectAttributeDialog() override = default;
bool exit() override;

@ -46,7 +46,7 @@ namespace MWGui
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
MyGUI::Widget* attributeView = getWidget("AttributeView");
MyGUI::IntCoord coord{ 0, 0, 204, 144 };
MyGUI::IntCoord coord{ 0, 0, 204, 18 };
const MyGUI::Align align = MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch;
for (const ESM::Attribute& attribute : store.get<ESM::Attribute>())
{
@ -56,7 +56,7 @@ namespace MWGui
box->setUserString("Caption_AttributeName", attribute.mName);
box->setUserString("Caption_AttributeDescription", attribute.mDescription);
box->setUserString("ImageTexture_AttributeImage", attribute.mIcon);
coord.top += 18;
coord.top += coord.height;
auto* name = box->createWidget<MyGUI::TextBox>("SandText", { 0, 0, 160, 18 }, align);
name->setNeedMouseFocus(false);
name->setCaption(attribute.mName);

@ -10,14 +10,9 @@
</Widget>
<!-- Attribute list -->
<Widget type="MWAttribute" skin="MW_StatNameButtonC" position="0 28 216 18" name="Attribute0" align="Left Top"/>
<Widget type="MWAttribute" skin="MW_StatNameButtonC" position="0 46 216 18" name="Attribute1" align="Left Top"/>
<Widget type="MWAttribute" skin="MW_StatNameButtonC" position="0 64 216 18" name="Attribute2" align="Left Top"/>
<Widget type="MWAttribute" skin="MW_StatNameButtonC" position="0 82 216 18" name="Attribute3" align="Left Top"/>
<Widget type="MWAttribute" skin="MW_StatNameButtonC" position="0 100 216 18" name="Attribute4" align="Left Top"/>
<Widget type="MWAttribute" skin="MW_StatNameButtonC" position="0 118 216 18" name="Attribute5" align="Left Top"/>
<Widget type="MWAttribute" skin="MW_StatNameButtonC" position="0 136 216 18" name="Attribute6" align="Left Top"/>
<Widget type="MWAttribute" skin="MW_StatNameButtonC" position="0 154 216 18" name="Attribute7" align="Left Top"/>
<Widget type="ScrollView" skin="MW_ScrollView" position="0 28 216 172" name="Attributes" align="Left Top">
<Property key="CanvasAlign" value="Left"/>
</Widget>
<!-- Dialog buttons -->
<Widget type="HBox" position="0 175 216 28">

Loading…
Cancel
Save