Fix the bgcolor formspec element (#8716)

This commit is contained in:
DS 2019-09-15 18:14:31 +02:00 committed by rubenwardy
parent 1ea9bfc6f7
commit 1db3d252cf
2 changed files with 14 additions and 11 deletions

@ -2092,11 +2092,15 @@ Elements
* Show an inventory image of registered item/node * Show an inventory image of registered item/node
### `bgcolor[<color>;<fullscreen>]` ### `bgcolor[<color>]`
* Sets background color of formspec as `ColorString` * Sets background color of formspec as `ColorString`
* If `true`, the background color is drawn fullscreen (does not affect the size
of the formspec). ### `bgcolor[<color>;<fullscreen>]`
* If `color` is a valid `ColorString`, the fullscreen background color
is set to `color`.
* If `fullscreen` is a true value, the fullscreen background color is drawn.
### `background[<X>,<Y>;<W>,<H>;<texture name>]` ### `background[<X>,<Y>;<W>,<H>;<texture name>]`

@ -1881,17 +1881,17 @@ void GUIFormSpecMenu::parseBox(parserData* data, const std::string &element)
errorstream<< "Invalid Box element(" << parts.size() << "): '" << element << "'" << std::endl; errorstream<< "Invalid Box element(" << parts.size() << "): '" << element << "'" << std::endl;
} }
void GUIFormSpecMenu::parseBackgroundColor(parserData* data, const std::string &element) void GUIFormSpecMenu::parseBackgroundColor(parserData *data, const std::string &element)
{ {
std::vector<std::string> parts = split(element,';'); std::vector<std::string> parts = split(element,';');
if (((parts.size() == 1) || (parts.size() == 2)) || if (((parts.size() == 1) || (parts.size() == 2)) ||
((parts.size() > 2) && (m_formspec_version > FORMSPEC_API_VERSION))) { ((parts.size() > 2) && (m_formspec_version > FORMSPEC_API_VERSION))) {
parseColorString(parts[0], m_bgcolor, false); if (parts.size() == 1) {
parseColorString(parts[0], m_bgcolor, false);
if (parts.size() == 2) { } else if (parts.size() == 2) {
std::string fullscreen = parts[1]; parseColorString(parts[0], m_fullscreen_bgcolor, false);
m_bgfullscreen = is_yes(fullscreen); m_bgfullscreen = is_yes(parts[1]);
} }
return; return;
@ -2921,8 +2921,7 @@ void GUIFormSpecMenu::drawMenu()
if (m_bgfullscreen) if (m_bgfullscreen)
driver->draw2DRectangle(m_fullscreen_bgcolor, allbg, &allbg); driver->draw2DRectangle(m_fullscreen_bgcolor, allbg, &allbg);
else driver->draw2DRectangle(m_bgcolor, AbsoluteRect, &AbsoluteClippingRect);
driver->draw2DRectangle(m_bgcolor, AbsoluteRect, &AbsoluteClippingRect);
m_tooltip_element->setVisible(false); m_tooltip_element->setVisible(false);