forked from teamnwah/openmw-tes3coop
Move item count text to ItemWidget
This commit is contained in:
parent
b145d183ae
commit
cbc242d857
7 changed files with 43 additions and 38 deletions
|
@ -203,12 +203,7 @@ namespace MWGui
|
||||||
ingredient->setUserString("ToolTipType", "ItemPtr");
|
ingredient->setUserString("ToolTipType", "ItemPtr");
|
||||||
ingredient->setUserData(item);
|
ingredient->setUserData(item);
|
||||||
|
|
||||||
MyGUI::TextBox* text = ingredient->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(0, 14, 32, 18), MyGUI::Align::Default, std::string("Label"));
|
ingredient->setCount(ingredient->getUserData<MWWorld::Ptr>()->getRefData().getCount());
|
||||||
text->setTextAlign(MyGUI::Align::Right);
|
|
||||||
text->setNeedMouseFocus(false);
|
|
||||||
text->setTextShadow(true);
|
|
||||||
text->setTextShadowColour(MyGUI::Colour(0,0,0));
|
|
||||||
text->setCaption(ItemView::getCountString(ingredient->getUserData<MWWorld::Ptr>()->getRefData().getCount()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mItemView->update();
|
mItemView->update();
|
||||||
|
|
|
@ -92,16 +92,7 @@ namespace MWGui
|
||||||
mDraggedWidget = baseWidget;
|
mDraggedWidget = baseWidget;
|
||||||
baseWidget->setItem(mItem.mBase);
|
baseWidget->setItem(mItem.mBase);
|
||||||
baseWidget->setNeedMouseFocus(false);
|
baseWidget->setNeedMouseFocus(false);
|
||||||
|
baseWidget->setCount(count);
|
||||||
// text widget that shows item count
|
|
||||||
// TODO: move to ItemWidget
|
|
||||||
MyGUI::TextBox* text = baseWidget->createWidget<MyGUI::TextBox>("SandBrightText",
|
|
||||||
MyGUI::IntCoord(0, 14, 32, 18), MyGUI::Align::Default, std::string("Label"));
|
|
||||||
text->setTextAlign(MyGUI::Align::Right);
|
|
||||||
text->setNeedMouseFocus(false);
|
|
||||||
text->setTextShadow(true);
|
|
||||||
text->setTextShadowColour(MyGUI::Colour(0,0,0));
|
|
||||||
text->setCaption(ItemView::getCountString(count));
|
|
||||||
|
|
||||||
sourceView->update();
|
sourceView->update();
|
||||||
|
|
||||||
|
|
|
@ -17,16 +17,6 @@
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string ItemView::getCountString(int count)
|
|
||||||
{
|
|
||||||
if (count == 1)
|
|
||||||
return "";
|
|
||||||
if (count > 9999)
|
|
||||||
return boost::lexical_cast<std::string>(int(count/1000.f)) + "k";
|
|
||||||
else
|
|
||||||
return boost::lexical_cast<std::string>(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemView::ItemView()
|
ItemView::ItemView()
|
||||||
: mModel(NULL)
|
: mModel(NULL)
|
||||||
, mScrollView(NULL)
|
, mScrollView(NULL)
|
||||||
|
@ -123,19 +113,10 @@ void ItemView::update()
|
||||||
if (item.mType == ItemStack::Type_Equipped)
|
if (item.mType == ItemStack::Type_Equipped)
|
||||||
state = ItemWidget::Equip;
|
state = ItemWidget::Equip;
|
||||||
itemWidget->setItem(item.mBase, state);
|
itemWidget->setItem(item.mBase, state);
|
||||||
|
itemWidget->setCount(item.mCount);
|
||||||
|
|
||||||
itemWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemView::onSelectedItem);
|
itemWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemView::onSelectedItem);
|
||||||
itemWidget->eventMouseWheel += MyGUI::newDelegate(this, &ItemView::onMouseWheel);
|
itemWidget->eventMouseWheel += MyGUI::newDelegate(this, &ItemView::onMouseWheel);
|
||||||
|
|
||||||
// text widget that shows item count
|
|
||||||
// TODO: move to ItemWidget
|
|
||||||
MyGUI::TextBox* text = itemWidget->createWidget<MyGUI::TextBox>("SandBrightText",
|
|
||||||
MyGUI::IntCoord(5, 19, 32, 18), MyGUI::Align::Default, std::string("Label"));
|
|
||||||
text->setTextAlign(MyGUI::Align::Right);
|
|
||||||
text->setNeedMouseFocus(false);
|
|
||||||
text->setTextShadow(true);
|
|
||||||
text->setTextShadowColour(MyGUI::Colour(0,0,0));
|
|
||||||
text->setCaption(getCountString(item.mCount));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
layoutWidgets();
|
layoutWidgets();
|
||||||
|
|
|
@ -30,8 +30,6 @@ namespace MWGui
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
static std::string getCountString(int count);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void initialiseOverride();
|
virtual void initialiseOverride();
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,34 @@
|
||||||
|
|
||||||
#include <MyGUI_FactoryManager.h>
|
#include <MyGUI_FactoryManager.h>
|
||||||
#include <MyGUI_ImageBox.h>
|
#include <MyGUI_ImageBox.h>
|
||||||
|
#include <MyGUI_TextBox.h>
|
||||||
|
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include <components/misc/resourcehelpers.hpp>
|
#include <components/misc/resourcehelpers.hpp>
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
std::string getCountString(int count)
|
||||||
|
{
|
||||||
|
if (count == 1)
|
||||||
|
return "";
|
||||||
|
if (count > 9999)
|
||||||
|
return boost::lexical_cast<std::string>(int(count/1000.f)) + "k";
|
||||||
|
else
|
||||||
|
return boost::lexical_cast<std::string>(count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
|
|
||||||
ItemWidget::ItemWidget()
|
ItemWidget::ItemWidget()
|
||||||
: mItem(NULL)
|
: mItem(NULL)
|
||||||
|
, mFrame(NULL)
|
||||||
|
, mText(NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,10 +47,20 @@ namespace MWGui
|
||||||
assignWidget(mFrame, "Frame");
|
assignWidget(mFrame, "Frame");
|
||||||
if (mFrame)
|
if (mFrame)
|
||||||
mFrame->setNeedMouseFocus(false);
|
mFrame->setNeedMouseFocus(false);
|
||||||
|
assignWidget(mText, "Text");
|
||||||
|
if (mText)
|
||||||
|
mText->setNeedMouseFocus(false);
|
||||||
|
|
||||||
Base::initialiseOverride();
|
Base::initialiseOverride();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ItemWidget::setCount(int count)
|
||||||
|
{
|
||||||
|
if (!mText)
|
||||||
|
return;
|
||||||
|
mText->setCaption(getCountString(count));
|
||||||
|
}
|
||||||
|
|
||||||
void ItemWidget::setIcon(const std::string &icon)
|
void ItemWidget::setIcon(const std::string &icon)
|
||||||
{
|
{
|
||||||
if (mItem)
|
if (mItem)
|
||||||
|
|
|
@ -29,6 +29,9 @@ namespace MWGui
|
||||||
Magic
|
Magic
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Set count to be displayed in a textbox over the item
|
||||||
|
void setCount(int count);
|
||||||
|
|
||||||
/// \a ptr may be empty
|
/// \a ptr may be empty
|
||||||
void setItem (const MWWorld::Ptr& ptr, ItemState state = None);
|
void setItem (const MWWorld::Ptr& ptr, ItemState state = None);
|
||||||
|
|
||||||
|
@ -42,6 +45,7 @@ namespace MWGui
|
||||||
|
|
||||||
MyGUI::ImageBox* mItem;
|
MyGUI::ImageBox* mItem;
|
||||||
MyGUI::ImageBox* mFrame;
|
MyGUI::ImageBox* mFrame;
|
||||||
|
MyGUI::TextBox* mText;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,6 +322,10 @@
|
||||||
<Resource type="ResourceLayout" name="MW_ItemIcon" version="3.2.0">
|
<Resource type="ResourceLayout" name="MW_ItemIcon" version="3.2.0">
|
||||||
<Widget type="Widget" skin="" position="0 0 42 42" name="Root">
|
<Widget type="Widget" skin="" position="0 0 42 42" name="Root">
|
||||||
<Widget type="ImageBox" skin="ImageBox" position="0 0 42 42" align="Stretch" name="Frame">
|
<Widget type="ImageBox" skin="ImageBox" position="0 0 42 42" align="Stretch" name="Frame">
|
||||||
|
<Widget type="TextBox" skin="SandBrightText" position="5 19 32 18" align="Right Bottom" name="Text">
|
||||||
|
<Property key="TextAlign" value="Right"/>
|
||||||
|
<Property key="TextShadow" value="true"/>
|
||||||
|
</Widget>
|
||||||
<Widget type="ImageBox" skin="ImageBox" position="5 5 32 32" align="Stretch" name="Item"/>
|
<Widget type="ImageBox" skin="ImageBox" position="5 5 32 32" align="Stretch" name="Item"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
@ -338,6 +342,10 @@
|
||||||
<Resource type="ResourceLayout" name="MW_ItemIconBox" version="3.2.0">
|
<Resource type="ResourceLayout" name="MW_ItemIconBox" version="3.2.0">
|
||||||
<Widget type="Widget" skin="" position="0 0 50 50" name="Root">
|
<Widget type="Widget" skin="" position="0 0 50 50" name="Root">
|
||||||
<Widget type="ImageBox" skin="ImageBox" position="4 4 42 42" align="Center" name="Frame">
|
<Widget type="ImageBox" skin="ImageBox" position="4 4 42 42" align="Center" name="Frame">
|
||||||
|
<Widget type="TextBox" skin="SandBrightText" position="5 19 32 18" align="Right Bottom" name="Text">
|
||||||
|
<Property key="TextAlign" value="Right"/>
|
||||||
|
<Property key="TextShadow" value="true"/>
|
||||||
|
</Widget>
|
||||||
<Widget type="ImageBox" skin="ImageBox" position="5 5 32 32" align="Center" name="Item"/>
|
<Widget type="ImageBox" skin="ImageBox" position="5 5 32 32" align="Center" name="Item"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue