mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 12:49:40 +00:00
added a scrollbar to the item container, dynamic positioning of items, fixed the item count display bug
This commit is contained in:
parent
a31a9e51d3
commit
1abf70692c
7 changed files with 35 additions and 14 deletions
|
@ -125,7 +125,8 @@ void ContainerBase::drawItems()
|
|||
|
||||
int x = 4;
|
||||
int y = 4;
|
||||
int count = 0;
|
||||
int maxHeight = mItemView->getSize().height - 48;
|
||||
|
||||
int index = 0;
|
||||
|
||||
for (MWWorld::ContainerStoreIterator iter (containerStore.begin()); iter!=containerStore.end(); ++iter)
|
||||
|
@ -133,21 +134,21 @@ void ContainerBase::drawItems()
|
|||
index++;
|
||||
if(iter->getRefData().getCount() > 0)
|
||||
{
|
||||
count++;
|
||||
std::string path = std::string("icons\\");
|
||||
path+=MWWorld::Class::get(*iter).getInventoryIcon(*iter);
|
||||
ItemWidget* image = mContainerWidget->createWidget<ItemWidget>("ImageBox", MyGUI::IntCoord(x, y, 32, 32), MyGUI::Align::Default);
|
||||
MyGUI::TextBox* text = image->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(x, y, 18, 18), MyGUI::Align::Default, std::string("Label"));
|
||||
MyGUI::TextBox* text = image->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(14, 14, 18, 18), MyGUI::Align::Default, std::string("Label"));
|
||||
text->setTextAlign(MyGUI::Align::Right);
|
||||
text->setNeedMouseFocus(false);
|
||||
image->eventMouseButtonClick += MyGUI::newDelegate(this,&ContainerBase::onSelectedItem);
|
||||
image->setUserString("ToolTipType", "ItemPtr");
|
||||
image->setUserData(*iter);
|
||||
image->mPos = index;
|
||||
x += 36;
|
||||
if(count % 20 == 0)
|
||||
{
|
||||
y += 36;
|
||||
x = 4;
|
||||
count = 0;
|
||||
if (y > maxHeight)
|
||||
{
|
||||
x += 36;
|
||||
y = 4;
|
||||
}
|
||||
|
||||
if(iter->getRefData().getCount() > 1)
|
||||
|
@ -158,7 +159,11 @@ void ContainerBase::drawItems()
|
|||
path.append(".dds");
|
||||
image->setImageTexture(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MyGUI::IntSize size = MyGUI::IntSize(std::max(mItemView->getSize().width, x), 2048);
|
||||
mItemView->setCanvasSize(size);
|
||||
mContainerWidget->setSize(size);
|
||||
}
|
||||
|
||||
void ContainerBase::Update()
|
||||
|
@ -204,6 +209,7 @@ ContainerWindow::~ContainerWindow()
|
|||
|
||||
void ContainerWindow::onWindowResize(MyGUI::Window* window)
|
||||
{
|
||||
drawItems();
|
||||
}
|
||||
|
||||
void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace MWGui
|
|||
InventoryWindow::InventoryWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop)
|
||||
: ContainerBase(parWindowManager,dragAndDrop,"openmw_inventory_window_layout.xml")
|
||||
{
|
||||
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize);
|
||||
}
|
||||
|
||||
void InventoryWindow::openInventory()
|
||||
|
@ -31,4 +32,9 @@ namespace MWGui
|
|||
open(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
||||
}
|
||||
|
||||
void InventoryWindow::onWindowResize(MyGUI::Window* _sender)
|
||||
{
|
||||
drawItems();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@ namespace MWGui
|
|||
InventoryWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop);
|
||||
|
||||
void openInventory();
|
||||
|
||||
protected:
|
||||
void onWindowResize(MyGUI::Window* _sender);
|
||||
};
|
||||
}
|
||||
#endif // Inventory_H
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
<Widget type="Window" skin="MW_Window" layer="Windows" position="900 500 600 300" name="_Main">
|
||||
|
||||
<!-- Items -->
|
||||
<Widget type="Widget" skin="MW_Box" position="5 10 570 220" name="box" align="Left Top Stretch">
|
||||
<Widget type="ScrollView" skin="MW_ScrollView" position="4 4 566 216" name="ItemView" align="Left Top Stretch">
|
||||
<Widget type="Widget" skin="MW_Box" position="5 5 575 225" name="box" align="Left Top Stretch">
|
||||
<Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 571 221" name="ItemView" align="Left Top Stretch">
|
||||
<Property key="CanvasSize" value="1024 1024"/>
|
||||
<Widget type="Button" skin="" name="Items" position="0 0 566 216" name="Items" align="Left Top Stretch"/>
|
||||
<Widget type="Button" skin="" name="Items" position="0 0 571 221" name="Items" align="Left Top Stretch"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
<!-- Items in inventory -->
|
||||
<Widget type="Widget" skin="MW_Box" position="228 32 300 215" name="box" align="Left Top Stretch">
|
||||
<Widget type="ScrollView" skin="MW_ScrollView" position="4 4 296 211" align="Left Top Stretch" name="ItemView">
|
||||
<Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 296 211" align="Left Top Stretch" name="ItemView">
|
||||
<Property key="CanvasSize" value="1024 1024"/>
|
||||
<Widget type="Button" skin="" name="Items" position="0 0 296 211" name="Items" align="Left Top Stretch"/>
|
||||
</Widget>
|
||||
|
|
|
@ -131,6 +131,7 @@
|
|||
<Skin name = "MW_HScroll" size = "90 14">
|
||||
<Property key="TrackRangeMargins" value = "14 14" />
|
||||
<Property key="MinTrackSize" value = "14" />
|
||||
<Property key="VerticalAlignment" value="false"/>
|
||||
|
||||
<!-- Background widget trick that must go first to be placed behind Track and FirstPart/SecondPart widgets, provides the bar texture -->
|
||||
<Child type="Button" skin="MW_HScrollBackground" offset = "14 0 62 14" align = "ALIGN_STRETCH" name = "Background"/>
|
||||
|
@ -143,7 +144,7 @@
|
|||
<Child type="Button" skin="MW_ScrollEmptyPart" offset = "52 0 24 14" align = "ALIGN_TOP ALIGN_HSTRETCH" name = "SecondPart"/>
|
||||
|
||||
<!-- Tracker must be last to be on top and receive mouse events -->
|
||||
<Child type="Button" skin="MW_ScrollTrack" offset = "38 0 14 14" align = "ALIGN_TOP ALIGN_VSTRETCH" name = "Track"/>
|
||||
<Child type="Button" skin="MW_ScrollTrack" offset = "38 0 14 14" align = "ALIGN_LEFT ALIGN_VSTRETCH" name = "Track"/>
|
||||
</Skin>
|
||||
|
||||
<!-- Morrowind has a 1 pixel gap between the top arrow and the inner bar, this skin does not replicate that -->
|
||||
|
|
|
@ -7,4 +7,9 @@
|
|||
<Child type="ScrollBar" skin="MW_VScroll" offset="498 3 14 509" align="ALIGN_RIGHT ALIGN_VSTRETCH" name="VScroll"/>
|
||||
</Skin>
|
||||
|
||||
<Skin name="MW_ScrollViewH" size="516 516" texture="mwgui.png">
|
||||
<Child type="Widget" skin="" offset="0 0 516 516" align="Stretch" name="Client"/>
|
||||
<Child type="ScrollBar" skin="MW_HScroll" offset="3 498 509 14" align="ALIGN_LEFT ALIGN_BOTTOM ALIGN_HSTRETCH" name="HScroll"/>
|
||||
</Skin>
|
||||
|
||||
</MyGUI>
|
||||
|
|
Loading…
Reference in a new issue