forked from Mirrorlandia_minetest/minetest
Formspec: make bgcolor element less confusing and allow setting fullscreen color (#8996)
This commit is contained in:
parent
d3255f92d7
commit
8f73ec6c6c
@ -2104,11 +2104,19 @@ Elements
|
||||
|
||||
* Show an inventory image of registered item/node
|
||||
|
||||
### `bgcolor[<color>;<fullscreen>]`
|
||||
### `bgcolor[<bgcolor>;<fullscreen>;<fbgcolor>]`
|
||||
|
||||
* Sets background color of formspec as `ColorString`
|
||||
* If `true`, a fullscreen background is drawn and the color is ignored
|
||||
(does not affect the size of the formspec)
|
||||
* Sets background color of formspec.
|
||||
* `bgcolor` and `fbgcolor` (optional) are `ColorString`s, they define the color
|
||||
of the non-fullscreen and the fullscreen background.
|
||||
* `fullscreen` (optional) can be one of the following:
|
||||
* `false`: Only the non-fullscreen background color is drawn. (default)
|
||||
* `true`: Only the fullscreen background color is drawn.
|
||||
* `both`: The non-fullscreen and the fullscreen background color are drawn.
|
||||
* `neither`: No background color is drawn.
|
||||
* Note: Leave a parameter empty to not modify the value.
|
||||
* Note: `fbgcolor`, leaving parameters empty and values for `fullscreen` that
|
||||
are not bools are only available since formspec version 3.
|
||||
|
||||
### `background[<X>,<Y>;<W>,<H>;<texture name>]`
|
||||
|
||||
|
@ -2178,21 +2178,36 @@ void GUIFormSpecMenu::parseBox(parserData* data, const std::string &element)
|
||||
void GUIFormSpecMenu::parseBackgroundColor(parserData* data, const std::string &element)
|
||||
{
|
||||
std::vector<std::string> parts = split(element,';');
|
||||
const u32 parameter_count = parts.size();
|
||||
|
||||
if (((parts.size() == 1) || (parts.size() == 2)) ||
|
||||
((parts.size() > 2) && (m_formspec_version > FORMSPEC_API_VERSION))) {
|
||||
parseColorString(parts[0], m_bgcolor, false);
|
||||
|
||||
if (parts.size() == 2) {
|
||||
std::string fullscreen = parts[1];
|
||||
m_bgfullscreen = is_yes(fullscreen);
|
||||
}
|
||||
|
||||
if ((parameter_count > 2 && m_formspec_version < 3) ||
|
||||
(parameter_count > 3 && m_formspec_version <= FORMSPEC_API_VERSION)) {
|
||||
errorstream << "Invalid bgcolor element(" << parameter_count << "): '"
|
||||
<< element << "'" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
errorstream << "Invalid bgcolor element(" << parts.size() << "): '" << element << "'"
|
||||
<< std::endl;
|
||||
// bgcolor
|
||||
if (parameter_count >= 1 && parts[0] != "")
|
||||
parseColorString(parts[0], m_bgcolor, false);
|
||||
|
||||
// fullscreen
|
||||
if (parameter_count >= 2) {
|
||||
if (parts[1] == "both") {
|
||||
m_bgnonfullscreen = true;
|
||||
m_bgfullscreen = true;
|
||||
} else if (parts[1] == "neither") {
|
||||
m_bgnonfullscreen = false;
|
||||
m_bgfullscreen = false;
|
||||
} else if (parts[1] != "" || m_formspec_version < 3) {
|
||||
m_bgfullscreen = is_yes(parts[1]);
|
||||
m_bgnonfullscreen = !m_bgfullscreen;
|
||||
}
|
||||
}
|
||||
|
||||
// fbgcolor
|
||||
if (parameter_count >= 3 && parts[2] != "")
|
||||
parseColorString(parts[2], m_fullscreen_bgcolor, false);
|
||||
}
|
||||
|
||||
void GUIFormSpecMenu::parseListColors(parserData* data, const std::string &element)
|
||||
@ -2735,6 +2750,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
||||
theme_by_name.clear();
|
||||
theme_by_type.clear();
|
||||
|
||||
m_bgnonfullscreen = true;
|
||||
m_bgfullscreen = false;
|
||||
|
||||
m_formspec_version = 1;
|
||||
@ -3312,7 +3328,7 @@ void GUIFormSpecMenu::drawMenu()
|
||||
|
||||
if (m_bgfullscreen)
|
||||
driver->draw2DRectangle(m_fullscreen_bgcolor, allbg, &allbg);
|
||||
else
|
||||
if (m_bgnonfullscreen)
|
||||
driver->draw2DRectangle(m_bgcolor, AbsoluteRect, &AbsoluteClippingRect);
|
||||
|
||||
/*
|
||||
|
@ -369,6 +369,7 @@ protected:
|
||||
bool m_lock = false;
|
||||
v2u32 m_lockscreensize;
|
||||
|
||||
bool m_bgnonfullscreen;
|
||||
bool m_bgfullscreen;
|
||||
bool m_slotborder;
|
||||
video::SColor m_bgcolor;
|
||||
|
@ -231,6 +231,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
background9[]: 9-slice scaling parameters
|
||||
FORMSPEC VERSION 3:
|
||||
Formspec elements are drawn in the order of definition
|
||||
bgcolor[]: use 3 parameters (bgcolor, formspec (now an enum), fbgcolor)
|
||||
*/
|
||||
#define FORMSPEC_API_VERSION 3
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user