Add list[] bgimg
This commit is contained in:
parent
9e77da9f8c
commit
1558a2df54
@ -2911,6 +2911,9 @@ Some types may inherit styles from parent types.
|
|||||||
* noclip - boolean, set to true to allow the element to exceed formspec bounds.
|
* noclip - boolean, set to true to allow the element to exceed formspec bounds.
|
||||||
* size - 2d vector, sets the size of inventory slots in coordinates.
|
* size - 2d vector, sets the size of inventory slots in coordinates.
|
||||||
* spacing - 2d vector, sets the space between inventory slots in coordinates.
|
* spacing - 2d vector, sets the space between inventory slots in coordinates.
|
||||||
|
* bgimg - slot background image. Defaults to none.
|
||||||
|
* bgimg_hovered - hovered slot background image.
|
||||||
|
* bgimg_middle - Makes the bgimg textures render in 9-sliced mode and defines the middle rect.
|
||||||
* image_button (additional properties)
|
* image_button (additional properties)
|
||||||
* fgimg - standard image. Defaults to none.
|
* fgimg - standard image. Defaults to none.
|
||||||
* fgimg_hovered - image when hovered. Defaults to fgimg when not provided.
|
* fgimg_hovered - image when hovered. Defaults to fgimg when not provided.
|
||||||
|
@ -538,10 +538,14 @@ void GUIFormSpecMenu::parseList(parserData *data, const std::string &element)
|
|||||||
pos.X + (geom.X - 1) * slot_spacing.X + slot_size.X,
|
pos.X + (geom.X - 1) * slot_spacing.X + slot_size.X,
|
||||||
pos.Y + (geom.Y - 1) * slot_spacing.Y + slot_size.Y);
|
pos.Y + (geom.Y - 1) * slot_spacing.Y + slot_size.Y);
|
||||||
|
|
||||||
|
video::ITexture *bgimg = style.getTexture(StyleSpec::BGIMG, m_tsrc, nullptr);
|
||||||
|
video::ITexture *bgimg_hovered = style.getTexture(StyleSpec::BGIMG_HOVERED, m_tsrc, nullptr);
|
||||||
|
core::rect<s32> bgimg_middle = style.getRect(StyleSpec::BGIMG_MIDDLE, core::rect<s32>());
|
||||||
|
|
||||||
GUIInventoryList *e = new GUIInventoryList(Environment, data->current_parent,
|
GUIInventoryList *e = new GUIInventoryList(Environment, data->current_parent,
|
||||||
spec.fid, rect, m_invmgr, loc, listname, geom, start_i,
|
spec.fid, rect, m_invmgr, loc, listname, geom, start_i,
|
||||||
v2s32(slot_size.X, slot_size.Y), slot_spacing, this,
|
v2s32(slot_size.X, slot_size.Y), slot_spacing, bgimg, bgimg_hovered,
|
||||||
data->inventorylist_options, m_font);
|
bgimg_middle, this, data->inventorylist_options, m_font);
|
||||||
|
|
||||||
e->setNotClipped(style.getBool(StyleSpec::NOCLIP, false));
|
e->setNotClipped(style.getBool(StyleSpec::NOCLIP, false));
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
#include "guiInventoryList.h"
|
#include "guiInventoryList.h"
|
||||||
#include "guiFormSpecMenu.h"
|
#include "guiFormSpecMenu.h"
|
||||||
|
#include "client/guiscalingfilter.h"
|
||||||
#include "client/hud.h"
|
#include "client/hud.h"
|
||||||
#include "client/client.h"
|
#include "client/client.h"
|
||||||
|
|
||||||
@ -33,6 +34,9 @@ GUIInventoryList::GUIInventoryList(gui::IGUIEnvironment *env,
|
|||||||
const s32 start_item_i,
|
const s32 start_item_i,
|
||||||
const v2s32 &slot_size,
|
const v2s32 &slot_size,
|
||||||
const v2f32 &slot_spacing,
|
const v2f32 &slot_spacing,
|
||||||
|
video::ITexture* slotbg_n_texture,
|
||||||
|
video::ITexture* slotbg_h_texture,
|
||||||
|
const core::rect<s32> &slotbg_middle,
|
||||||
GUIFormSpecMenu *fs_menu,
|
GUIFormSpecMenu *fs_menu,
|
||||||
const Options &options,
|
const Options &options,
|
||||||
gui::IGUIFont *font) :
|
gui::IGUIFont *font) :
|
||||||
@ -44,6 +48,9 @@ GUIInventoryList::GUIInventoryList(gui::IGUIEnvironment *env,
|
|||||||
m_start_item_i(start_item_i),
|
m_start_item_i(start_item_i),
|
||||||
m_slot_size(slot_size),
|
m_slot_size(slot_size),
|
||||||
m_slot_spacing(slot_spacing),
|
m_slot_spacing(slot_spacing),
|
||||||
|
m_slotbg_n_texture(slotbg_n_texture),
|
||||||
|
m_slotbg_h_texture(slotbg_h_texture),
|
||||||
|
m_slotbg_middle(slotbg_middle),
|
||||||
m_fs_menu(fs_menu),
|
m_fs_menu(fs_menu),
|
||||||
m_options(options),
|
m_options(options),
|
||||||
m_font(font),
|
m_font(font),
|
||||||
@ -109,6 +116,23 @@ void GUIInventoryList::draw()
|
|||||||
(hovering ? IT_ROT_HOVERED : IT_ROT_NONE);
|
(hovering ? IT_ROT_HOVERED : IT_ROT_NONE);
|
||||||
|
|
||||||
// layer 0
|
// layer 0
|
||||||
|
if (m_slotbg_n_texture) {
|
||||||
|
video::ITexture *texture = m_slotbg_n_texture;
|
||||||
|
if (hovering && m_slotbg_h_texture)
|
||||||
|
texture = m_slotbg_h_texture;
|
||||||
|
|
||||||
|
core::rect<s32> srcrect(core::position2d<s32>(0, 0),
|
||||||
|
core::dimension2di(texture->getOriginalSize()));
|
||||||
|
if (m_slotbg_middle.getArea() == 0) {
|
||||||
|
const video::SColor color(255, 255, 255, 255);
|
||||||
|
const video::SColor colors[] = {color, color, color, color};
|
||||||
|
draw2DImageFilterScaled(driver, texture, rect, srcrect,
|
||||||
|
&AbsoluteClippingRect, colors, true);
|
||||||
|
} else {
|
||||||
|
draw2DImage9Slice(driver, texture, rect, srcrect, m_slotbg_middle,
|
||||||
|
&AbsoluteClippingRect);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (hovering) {
|
if (hovering) {
|
||||||
driver->draw2DRectangle(m_options.slotbg_h, rect, &AbsoluteClippingRect);
|
driver->draw2DRectangle(m_options.slotbg_h, rect, &AbsoluteClippingRect);
|
||||||
} else {
|
} else {
|
||||||
@ -138,6 +162,7 @@ void GUIInventoryList::draw()
|
|||||||
core::rect<s32>(v2s32(x2, y1),
|
core::rect<s32>(v2s32(x2, y1),
|
||||||
v2s32(x2 + border, y2)), clipping_rect_ptr);
|
v2s32(x2 + border, y2)), clipping_rect_ptr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// layer 1
|
// layer 1
|
||||||
if (selected)
|
if (selected)
|
||||||
|
@ -69,6 +69,9 @@ public:
|
|||||||
const s32 start_item_i,
|
const s32 start_item_i,
|
||||||
const v2s32 &slot_size,
|
const v2s32 &slot_size,
|
||||||
const v2f32 &slot_spacing,
|
const v2f32 &slot_spacing,
|
||||||
|
video::ITexture* slotbg_n_texture,
|
||||||
|
video::ITexture* slotbg_h_texture,
|
||||||
|
const core::rect<s32> &slotbg_middle,
|
||||||
GUIFormSpecMenu *fs_menu,
|
GUIFormSpecMenu *fs_menu,
|
||||||
const Options &options,
|
const Options &options,
|
||||||
gui::IGUIFont *font);
|
gui::IGUIFont *font);
|
||||||
@ -117,6 +120,11 @@ private:
|
|||||||
// specifies how large the space between slots is (space between is spacing-size)
|
// specifies how large the space between slots is (space between is spacing-size)
|
||||||
const v2f32 m_slot_spacing;
|
const v2f32 m_slot_spacing;
|
||||||
|
|
||||||
|
// Slot textures
|
||||||
|
video::ITexture* m_slotbg_n_texture;
|
||||||
|
video::ITexture* m_slotbg_h_texture;
|
||||||
|
core::rect<s32> m_slotbg_middle;
|
||||||
|
|
||||||
// the GUIFormSpecMenu can have an item selected and co.
|
// the GUIFormSpecMenu can have an item selected and co.
|
||||||
GUIFormSpecMenu *m_fs_menu;
|
GUIFormSpecMenu *m_fs_menu;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user