Improved recharge widget

0.6.1
Andrei Kortunov 8 years ago
parent f63b1e81cd
commit 1164c3f16e

@ -33,6 +33,7 @@ namespace MWGui
Recharge::Recharge()
: WindowBase("openmw_recharge_dialog.layout")
, mItemSelectionDialog(NULL)
{
getWidget(mBox, "Box");
getWidget(mGemBox, "GemBox");
@ -45,6 +46,8 @@ Recharge::Recharge()
mBox->setDisplayMode(ItemChargeView::DisplayMode_EnchantmentCharge);
mGemIcon->eventMouseButtonClick += MyGUI::newDelegate(this, &Recharge::onSelectItem);
setVisible(false);
}
@ -87,6 +90,12 @@ void Recharge::updateView()
mGemBox->setVisible(toolBoxVisible);
mGemBox->setUserString("Hidden", toolBoxVisible ? "false" : "true");
if (!toolBoxVisible)
{
mGemIcon->setItem(MWWorld::Ptr());
mGemIcon->clearUserStrings();
}
mBox->update();
Gui::Box* box = dynamic_cast<Gui::Box*>(mMainWidget);
@ -102,6 +111,34 @@ void Recharge::onCancel(MyGUI::Widget *sender)
exit();
}
void Recharge::onSelectItem(MyGUI::Widget *sender)
{
delete mItemSelectionDialog;
mItemSelectionDialog = new ItemSelectionDialog("#{sSoulGemsWithSouls}");
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &Recharge::onItemSelected);
mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &Recharge::onItemCancel);
mItemSelectionDialog->setVisible(true);
mItemSelectionDialog->openContainer(MWMechanics::getPlayer());
mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyChargedSoulstones);
}
void Recharge::onItemSelected(MWWorld::Ptr item)
{
mItemSelectionDialog->setVisible(false);
mGemIcon->setItem(item);
mGemIcon->setUserString ("ToolTipType", "ItemPtr");
mGemIcon->setUserData(item);
MWBase::Environment::get().getSoundManager()->playSound(item.getClass().getDownSoundId(item), 1, 1);
updateView();
}
void Recharge::onItemCancel()
{
mItemSelectionDialog->setVisible(false);
}
void Recharge::onItemClicked(MyGUI::Widget *sender, const MWWorld::Ptr& item)
{
MWWorld::Ptr gem = *mGemIcon->getUserData<MWWorld::Ptr>();

@ -3,6 +3,8 @@
#include "windowbase.hpp"
#include "itemselection.hpp"
namespace MWWorld
{
class Ptr;
@ -11,6 +13,7 @@ namespace MWWorld
namespace MWGui
{
class ItemSelectionDialog;
class ItemWidget;
class ItemChargeView;
@ -32,12 +35,19 @@ protected:
ItemWidget* mGemIcon;
ItemSelectionDialog* mItemSelectionDialog;
MyGUI::TextBox* mChargeLabel;
MyGUI::Button* mCancelButton;
void updateView();
void onSelectItem(MyGUI::Widget* sender);
void onItemSelected(MWWorld::Ptr item);
void onItemCancel();
void onItemClicked (MyGUI::Widget* sender, const MWWorld::Ptr& item);
void onCancel (MyGUI::Widget* sender);
void onMouseWheel(MyGUI::Widget* _sender, int _rel);

@ -1,22 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="VBox" skin="MW_Dialog" layer="Windows" position="0 0 329 253" align="Center" name="_Main">
<Widget type="VBox" skin="MW_Dialog" layer="Windows" position="0 0 330 385" align="Center" name="_Main">
<Property key="Padding" value="12"/>
<Property key="Spacing" value="8"/>
<Widget type="HBox" name="GemBox">
<UserString key="HStretch" value="true"/>
<Widget type="ItemWidget" skin="MW_ItemIconSmall" position="0 0 32 32" name="GemIcon"/>
<Widget type="Widget">
<UserString key="HStretch" value="true"/>
</Widget>
<Widget type="AutoSizedTextBox" skin="SandText" name="ChargeLabel">
<Property key="Caption" value="#{sQuality}"/>
<Property key="TextAlign" value="Right"/>
</Widget>
<Widget type="AutoSizedTextBox" skin="SandText" name="Label">
<Property key="Caption" value="#{sRechargeEnchantment}"/>
</Widget>
<Widget type="ItemChargeView" skin="MW_ItemChargeView" align="Left Stretch" name="Box">
@ -26,14 +16,25 @@
<Widget type="HBox">
<UserString key="HStretch" value="true"/>
<Widget type="Widget">
<UserString key="HStretch" value="true"/>
</Widget>
<Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton">
<Property key="Caption" value="#{sCancel}"/>
</Widget>
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="0 0 44 44" name="GemIcon">
</Widget>
<Widget type="HBox" name="GemBox">
<Widget type="AutoSizedTextBox" skin="SandText" name="ChargeLabel">
<UserString key="HStretch" value="true"/>
<Property key="Caption" value="#{sCharges}"/>
<Property key="TextAlign" value="Left"/>
</Widget>
</Widget>
<Widget type="Widget">
<UserString key="HStretch" value="true"/>
</Widget>
<Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton">
<Property key="Caption" value="#{sCancel}"/>
</Widget>
</Widget>
</Widget>
</MyGUI>

Loading…
Cancel
Save