mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-19 19:53:53 +00:00
Improved repair widget
This commit is contained in:
parent
1164c3f16e
commit
10d4cb15ad
6 changed files with 85 additions and 27 deletions
|
@ -30,6 +30,7 @@ namespace MWGui
|
||||||
|
|
||||||
Repair::Repair()
|
Repair::Repair()
|
||||||
: WindowBase("openmw_repair.layout")
|
: WindowBase("openmw_repair.layout")
|
||||||
|
, mItemSelectionDialog(NULL)
|
||||||
{
|
{
|
||||||
getWidget(mRepairBox, "RepairBox");
|
getWidget(mRepairBox, "RepairBox");
|
||||||
getWidget(mToolBox, "ToolBox");
|
getWidget(mToolBox, "ToolBox");
|
||||||
|
@ -39,9 +40,11 @@ Repair::Repair()
|
||||||
getWidget(mCancelButton, "CancelButton");
|
getWidget(mCancelButton, "CancelButton");
|
||||||
|
|
||||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &Repair::onCancel);
|
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &Repair::onCancel);
|
||||||
mRepairBox->eventItemClicked += MyGUI::newDelegate(this, &Repair::onRepairItem);
|
|
||||||
|
|
||||||
|
mRepairBox->eventItemClicked += MyGUI::newDelegate(this, &Repair::onRepairItem);
|
||||||
mRepairBox->setDisplayMode(ItemChargeView::DisplayMode_Health);
|
mRepairBox->setDisplayMode(ItemChargeView::DisplayMode_Health);
|
||||||
|
|
||||||
|
mToolIcon->eventMouseButtonClick += MyGUI::newDelegate(this, &Repair::onSelectItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Repair::open()
|
void Repair::open()
|
||||||
|
@ -83,6 +86,8 @@ void Repair::updateRepairView()
|
||||||
|
|
||||||
float quality = ref->mBase->mData.mQuality;
|
float quality = ref->mBase->mData.mQuality;
|
||||||
|
|
||||||
|
mToolIcon->setUserData(mRepair.getTool());
|
||||||
|
|
||||||
std::stringstream qualityStr;
|
std::stringstream qualityStr;
|
||||||
qualityStr << std::setprecision(3) << quality;
|
qualityStr << std::setprecision(3) << quality;
|
||||||
|
|
||||||
|
@ -93,6 +98,12 @@ void Repair::updateRepairView()
|
||||||
mToolBox->setVisible(toolBoxVisible);
|
mToolBox->setVisible(toolBoxVisible);
|
||||||
mToolBox->setUserString("Hidden", toolBoxVisible ? "false" : "true");
|
mToolBox->setUserString("Hidden", toolBoxVisible ? "false" : "true");
|
||||||
|
|
||||||
|
if (!toolBoxVisible)
|
||||||
|
{
|
||||||
|
mToolIcon->setItem(MWWorld::Ptr());
|
||||||
|
mToolIcon->clearUserStrings();
|
||||||
|
}
|
||||||
|
|
||||||
mRepairBox->update();
|
mRepairBox->update();
|
||||||
|
|
||||||
Gui::Box* box = dynamic_cast<Gui::Box*>(mMainWidget);
|
Gui::Box* box = dynamic_cast<Gui::Box*>(mMainWidget);
|
||||||
|
@ -103,6 +114,36 @@ void Repair::updateRepairView()
|
||||||
center();
|
center();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Repair::onSelectItem(MyGUI::Widget *sender)
|
||||||
|
{
|
||||||
|
delete mItemSelectionDialog;
|
||||||
|
mItemSelectionDialog = new ItemSelectionDialog("#{sRepair}");
|
||||||
|
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &Repair::onItemSelected);
|
||||||
|
mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &Repair::onItemCancel);
|
||||||
|
mItemSelectionDialog->setVisible(true);
|
||||||
|
mItemSelectionDialog->openContainer(MWMechanics::getPlayer());
|
||||||
|
mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyRepairTools);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Repair::onItemSelected(MWWorld::Ptr item)
|
||||||
|
{
|
||||||
|
mItemSelectionDialog->setVisible(false);
|
||||||
|
|
||||||
|
mToolIcon->setItem(item);
|
||||||
|
mToolIcon->setUserString ("ToolTipType", "ItemPtr");
|
||||||
|
mToolIcon->setUserData(item);
|
||||||
|
|
||||||
|
mRepair.setTool(item);
|
||||||
|
|
||||||
|
MWBase::Environment::get().getSoundManager()->playSound(item.getClass().getDownSoundId(item), 1, 1);
|
||||||
|
updateRepairView();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Repair::onItemCancel()
|
||||||
|
{
|
||||||
|
mItemSelectionDialog->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
void Repair::onCancel(MyGUI::Widget* /*sender*/)
|
void Repair::onCancel(MyGUI::Widget* /*sender*/)
|
||||||
{
|
{
|
||||||
exit();
|
exit();
|
||||||
|
|
|
@ -3,11 +3,14 @@
|
||||||
|
|
||||||
#include "windowbase.hpp"
|
#include "windowbase.hpp"
|
||||||
|
|
||||||
|
#include "itemselection.hpp"
|
||||||
|
|
||||||
#include "../mwmechanics/repair.hpp"
|
#include "../mwmechanics/repair.hpp"
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class ItemSelectionDialog;
|
||||||
class ItemWidget;
|
class ItemWidget;
|
||||||
class ItemChargeView;
|
class ItemChargeView;
|
||||||
|
|
||||||
|
@ -29,6 +32,8 @@ protected:
|
||||||
|
|
||||||
ItemWidget* mToolIcon;
|
ItemWidget* mToolIcon;
|
||||||
|
|
||||||
|
ItemSelectionDialog* mItemSelectionDialog;
|
||||||
|
|
||||||
MyGUI::TextBox* mUsesLabel;
|
MyGUI::TextBox* mUsesLabel;
|
||||||
MyGUI::TextBox* mQualityLabel;
|
MyGUI::TextBox* mQualityLabel;
|
||||||
|
|
||||||
|
@ -38,6 +43,11 @@ protected:
|
||||||
|
|
||||||
void updateRepairView();
|
void updateRepairView();
|
||||||
|
|
||||||
|
void onSelectItem(MyGUI::Widget* sender);
|
||||||
|
|
||||||
|
void onItemSelected(MWWorld::Ptr item);
|
||||||
|
void onItemCancel();
|
||||||
|
|
||||||
void onRepairItem(MyGUI::Widget* sender, const MWWorld::Ptr& ptr);
|
void onRepairItem(MyGUI::Widget* sender, const MWWorld::Ptr& ptr);
|
||||||
void onCancel(MyGUI::Widget* sender);
|
void onCancel(MyGUI::Widget* sender);
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,8 @@ namespace MWGui
|
||||||
if ((mFilter & Filter_OnlyChargedSoulstones) && (base.getTypeName() != typeid(ESM::Miscellaneous).name()
|
if ((mFilter & Filter_OnlyChargedSoulstones) && (base.getTypeName() != typeid(ESM::Miscellaneous).name()
|
||||||
|| base.getCellRef().getSoul() == ""))
|
|| base.getCellRef().getSoul() == ""))
|
||||||
return false;
|
return false;
|
||||||
|
if ((mFilter & Filter_OnlyRepairTools) && (base.getTypeName() != typeid(ESM::Repair).name()))
|
||||||
|
return false;
|
||||||
if ((mFilter & Filter_OnlyEnchantable) && (item.mFlags & ItemStack::Flag_Enchanted
|
if ((mFilter & Filter_OnlyEnchantable) && (item.mFlags & ItemStack::Flag_Enchanted
|
||||||
|| (base.getTypeName() != typeid(ESM::Armor).name()
|
|| (base.getTypeName() != typeid(ESM::Armor).name()
|
||||||
&& base.getTypeName() != typeid(ESM::Clothing).name()
|
&& base.getTypeName() != typeid(ESM::Clothing).name()
|
||||||
|
|
|
@ -41,6 +41,7 @@ namespace MWGui
|
||||||
static const int Filter_OnlyUsableItems = (1<<4); // Only items with a Use action
|
static const int Filter_OnlyUsableItems = (1<<4); // Only items with a Use action
|
||||||
static const int Filter_OnlyRepairable = (1<<5);
|
static const int Filter_OnlyRepairable = (1<<5);
|
||||||
static const int Filter_OnlyRechargable = (1<<6);
|
static const int Filter_OnlyRechargable = (1<<6);
|
||||||
|
static const int Filter_OnlyRepairTools = (1<<7);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<MyGUI type="Layout">
|
<MyGUI type="Layout">
|
||||||
<Widget type="Window" skin="MW_Dialog" position="0 0 380 285" layer="Windows" align="Center" name="_Main">
|
<Widget type="Window" skin="MW_DialogNoTransp" position="0 0 380 285" layer="Windows" align="Center" name="_Main">
|
||||||
|
|
||||||
<Widget type="TextBox" skin="SandText" position="8 8 300 18" name="Label"/>
|
<Widget type="TextBox" skin="SandText" position="8 8 300 18" name="Label"/>
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<MyGUI type="Layout">
|
<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="Padding" value="12"/>
|
||||||
<Property key="Spacing" value="8"/>
|
<Property key="Spacing" value="8"/>
|
||||||
|
|
||||||
<Widget type="HBox" name="ToolBox">
|
<Widget type="AutoSizedTextBox" skin="SandText" name="Label">
|
||||||
<UserString key="HStretch" value="true"/>
|
<Property key="Caption" value="#{sRepairServiceTitle}"/>
|
||||||
|
|
||||||
<Widget type="ItemWidget" skin="MW_ItemIconSmall" position="0 0 32 32" name="ToolIcon"/>
|
|
||||||
|
|
||||||
<Widget type="AutoSizedTextBox" skin="SandText" name="UsesLabel">
|
|
||||||
<Property key="Caption" value="#{sUses}"/>
|
|
||||||
</Widget>
|
|
||||||
<Widget type="Widget">
|
|
||||||
<UserString key="HStretch" value="true"/>
|
|
||||||
</Widget>
|
|
||||||
<Widget type="AutoSizedTextBox" skin="SandText" name="QualityLabel">
|
|
||||||
<Property key="Caption" value="#{sQuality}"/>
|
|
||||||
<Property key="TextAlign" value="Right"/>
|
|
||||||
</Widget>
|
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
<Widget type="ItemChargeView" skin="MW_ItemChargeView" align="Left Stretch" name="RepairBox">
|
<Widget type="ItemChargeView" skin="MW_ItemChargeView" align="Left Stretch" name="RepairBox">
|
||||||
|
@ -29,14 +16,31 @@
|
||||||
|
|
||||||
<Widget type="HBox">
|
<Widget type="HBox">
|
||||||
<UserString key="HStretch" value="true"/>
|
<UserString key="HStretch" value="true"/>
|
||||||
|
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="0 0 44 44" name="ToolIcon">
|
||||||
|
</Widget>
|
||||||
|
|
||||||
|
<Widget type="HBox" name="ToolBox">
|
||||||
|
<Widget type="VBox">
|
||||||
|
<Widget type="AutoSizedTextBox" skin="SandText" name="UsesLabel">
|
||||||
|
<UserString key="HStretch" value="true"/>
|
||||||
|
<Property key="Caption" value="#{sUses}"/>
|
||||||
|
<Property key="TextAlign" value="Left"/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="AutoSizedTextBox" skin="SandText" name="QualityLabel">
|
||||||
|
<UserString key="HStretch" value="true"/>
|
||||||
|
<Property key="Caption" value="#{sQuality}"/>
|
||||||
|
<Property key="TextAlign" value="Left"/>
|
||||||
|
</Widget>
|
||||||
|
</Widget>
|
||||||
|
</Widget>
|
||||||
|
|
||||||
<Widget type="Widget">
|
<Widget type="Widget">
|
||||||
<UserString key="HStretch" value="true"/>
|
<UserString key="HStretch" value="true"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
<Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton">
|
<Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton">
|
||||||
<Property key="Caption" value="#{sCancel}"/>
|
<Property key="Caption" value="#{sCancel}"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
</MyGUI>
|
</MyGUI>
|
||||||
|
|
Loading…
Reference in a new issue