mirror of
https://github.com/moparisthebest/minetest
synced 2024-11-12 04:15:01 -05:00
Fix background formspec elements from interfering with each other
Fixes #4397
This commit is contained in:
parent
fbe4a9267f
commit
78ff5c1936
@ -637,17 +637,17 @@ void GUIFormSpecMenu::parseBackground(parserData* data,std::string element)
|
|||||||
geom.X = stof(v_geom[0]) * (float)spacing.X;
|
geom.X = stof(v_geom[0]) * (float)spacing.X;
|
||||||
geom.Y = stof(v_geom[1]) * (float)spacing.Y;
|
geom.Y = stof(v_geom[1]) * (float)spacing.Y;
|
||||||
|
|
||||||
if (parts.size() == 4) {
|
if (!data->explicit_size)
|
||||||
m_clipbackground = is_yes(parts[3]);
|
|
||||||
if (m_clipbackground) {
|
|
||||||
pos.X = stoi(v_pos[0]); //acts as offset
|
|
||||||
pos.Y = stoi(v_pos[1]); //acts as offset
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!data->explicit_size)
|
|
||||||
warningstream<<"invalid use of background without a size[] element"<<std::endl;
|
warningstream<<"invalid use of background without a size[] element"<<std::endl;
|
||||||
m_backgrounds.push_back(ImageDrawSpec(name, pos, geom));
|
|
||||||
|
bool clip = false;
|
||||||
|
if (parts.size() == 4 && is_yes(parts[3])) {
|
||||||
|
pos.X = stoi(v_pos[0]); //acts as offset
|
||||||
|
pos.Y = stoi(v_pos[1]); //acts as offset
|
||||||
|
clip = true;
|
||||||
|
}
|
||||||
|
m_backgrounds.push_back(ImageDrawSpec(name, pos, geom, clip));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
errorstream<< "Invalid background element(" << parts.size() << "): '" << element << "'" << std::endl;
|
errorstream<< "Invalid background element(" << parts.size() << "): '" << element << "'" << std::endl;
|
||||||
@ -1892,7 +1892,6 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||||||
m_slotbordercolor = video::SColor(200,0,0,0);
|
m_slotbordercolor = video::SColor(200,0,0,0);
|
||||||
m_slotborder = false;
|
m_slotborder = false;
|
||||||
|
|
||||||
m_clipbackground = false;
|
|
||||||
// Add tooltip
|
// Add tooltip
|
||||||
{
|
{
|
||||||
assert(m_tooltip_element == NULL);
|
assert(m_tooltip_element == NULL);
|
||||||
@ -2344,7 +2343,7 @@ void GUIFormSpecMenu::drawMenu()
|
|||||||
// Image rectangle on screen
|
// Image rectangle on screen
|
||||||
core::rect<s32> rect = imgrect + spec.pos;
|
core::rect<s32> rect = imgrect + spec.pos;
|
||||||
|
|
||||||
if (m_clipbackground) {
|
if (spec.clip) {
|
||||||
core::dimension2d<s32> absrec_size = AbsoluteRect.getSize();
|
core::dimension2d<s32> absrec_size = AbsoluteRect.getSize();
|
||||||
rect = core::rect<s32>(AbsoluteRect.UpperLeftCorner.X - spec.pos.X,
|
rect = core::rect<s32>(AbsoluteRect.UpperLeftCorner.X - spec.pos.X,
|
||||||
AbsoluteRect.UpperLeftCorner.Y - spec.pos.Y,
|
AbsoluteRect.UpperLeftCorner.Y - spec.pos.Y,
|
||||||
@ -2358,8 +2357,7 @@ void GUIFormSpecMenu::drawMenu()
|
|||||||
core::rect<s32>(core::position2d<s32>(0,0),
|
core::rect<s32>(core::position2d<s32>(0,0),
|
||||||
core::dimension2di(texture->getOriginalSize())),
|
core::dimension2di(texture->getOriginalSize())),
|
||||||
NULL/*&AbsoluteClippingRect*/, colors, true);
|
NULL/*&AbsoluteClippingRect*/, colors, true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
errorstream << "GUIFormSpecMenu::drawMenu() Draw backgrounds unable to load texture:" << std::endl;
|
errorstream << "GUIFormSpecMenu::drawMenu() Draw backgrounds unable to load texture:" << std::endl;
|
||||||
errorstream << "\t" << spec.name << std::endl;
|
errorstream << "\t" << spec.name << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -143,9 +143,10 @@ class GUIFormSpecMenu : public GUIModalMenu
|
|||||||
struct ImageDrawSpec
|
struct ImageDrawSpec
|
||||||
{
|
{
|
||||||
ImageDrawSpec():
|
ImageDrawSpec():
|
||||||
parent_button(NULL)
|
parent_button(NULL),
|
||||||
{
|
clip(false)
|
||||||
}
|
{}
|
||||||
|
|
||||||
ImageDrawSpec(const std::string &a_name,
|
ImageDrawSpec(const std::string &a_name,
|
||||||
const std::string &a_item_name,
|
const std::string &a_item_name,
|
||||||
gui::IGUIButton *a_parent_button,
|
gui::IGUIButton *a_parent_button,
|
||||||
@ -155,9 +156,10 @@ class GUIFormSpecMenu : public GUIModalMenu
|
|||||||
parent_button(a_parent_button),
|
parent_button(a_parent_button),
|
||||||
pos(a_pos),
|
pos(a_pos),
|
||||||
geom(a_geom),
|
geom(a_geom),
|
||||||
scale(true)
|
scale(true),
|
||||||
{
|
clip(false)
|
||||||
}
|
{}
|
||||||
|
|
||||||
ImageDrawSpec(const std::string &a_name,
|
ImageDrawSpec(const std::string &a_name,
|
||||||
const std::string &a_item_name,
|
const std::string &a_item_name,
|
||||||
const v2s32 &a_pos, const v2s32 &a_geom):
|
const v2s32 &a_pos, const v2s32 &a_geom):
|
||||||
@ -166,32 +168,36 @@ class GUIFormSpecMenu : public GUIModalMenu
|
|||||||
parent_button(NULL),
|
parent_button(NULL),
|
||||||
pos(a_pos),
|
pos(a_pos),
|
||||||
geom(a_geom),
|
geom(a_geom),
|
||||||
scale(true)
|
scale(true),
|
||||||
{
|
clip(false)
|
||||||
}
|
{}
|
||||||
|
|
||||||
ImageDrawSpec(const std::string &a_name,
|
ImageDrawSpec(const std::string &a_name,
|
||||||
const v2s32 &a_pos, const v2s32 &a_geom):
|
const v2s32 &a_pos, const v2s32 &a_geom, bool clip=false):
|
||||||
name(a_name),
|
name(a_name),
|
||||||
parent_button(NULL),
|
parent_button(NULL),
|
||||||
pos(a_pos),
|
pos(a_pos),
|
||||||
geom(a_geom),
|
geom(a_geom),
|
||||||
scale(true)
|
scale(true),
|
||||||
{
|
clip(clip)
|
||||||
}
|
{}
|
||||||
|
|
||||||
ImageDrawSpec(const std::string &a_name,
|
ImageDrawSpec(const std::string &a_name,
|
||||||
const v2s32 &a_pos):
|
const v2s32 &a_pos):
|
||||||
name(a_name),
|
name(a_name),
|
||||||
parent_button(NULL),
|
parent_button(NULL),
|
||||||
pos(a_pos),
|
pos(a_pos),
|
||||||
scale(false)
|
scale(false),
|
||||||
{
|
clip(false)
|
||||||
}
|
{}
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string item_name;
|
std::string item_name;
|
||||||
gui::IGUIButton *parent_button;
|
gui::IGUIButton *parent_button;
|
||||||
v2s32 pos;
|
v2s32 pos;
|
||||||
v2s32 geom;
|
v2s32 geom;
|
||||||
bool scale;
|
bool scale;
|
||||||
|
bool clip;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FieldSpec
|
struct FieldSpec
|
||||||
@ -428,7 +434,6 @@ protected:
|
|||||||
|
|
||||||
bool m_bgfullscreen;
|
bool m_bgfullscreen;
|
||||||
bool m_slotborder;
|
bool m_slotborder;
|
||||||
bool m_clipbackground;
|
|
||||||
video::SColor m_bgcolor;
|
video::SColor m_bgcolor;
|
||||||
video::SColor m_slotbg_n;
|
video::SColor m_slotbg_n;
|
||||||
video::SColor m_slotbg_h;
|
video::SColor m_slotbg_h;
|
||||||
|
Loading…
Reference in New Issue
Block a user