summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorDS <vorunbekannt75@web.de>2019-12-08 18:59:30 +0100
committersfan5 <sfan5@live.de>2019-12-08 18:59:30 +0100
commit8f73ec6c6c18ea5676261064399a650911333da5 (patch)
treee225b3ffcb8984364d543d23dda349a3989d55f5 /src/gui
parentd3255f92d7ed5758de5db735eda7796ef7b5e017 (diff)
downloadminetest-8f73ec6c6c18ea5676261064399a650911333da5.tar.gz
minetest-8f73ec6c6c18ea5676261064399a650911333da5.tar.bz2
minetest-8f73ec6c6c18ea5676261064399a650911333da5.zip
Formspec: make bgcolor element less confusing and allow setting fullscreen color (#8996)
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/guiFormSpecMenu.cpp36
-rw-r--r--src/gui/guiFormSpecMenu.h1
2 files changed, 27 insertions, 10 deletions
diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp
index 26ca525c8..ed3445b5b 100644
--- a/src/gui/guiFormSpecMenu.cpp
+++ b/src/gui/guiFormSpecMenu.cpp
@@ -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))) {
+ 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;
+ }
+
+ // bgcolor
+ if (parameter_count >= 1 && parts[0] != "")
parseColorString(parts[0], m_bgcolor, false);
- if (parts.size() == 2) {
- std::string fullscreen = parts[1];
- m_bgfullscreen = is_yes(fullscreen);
+ // 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;
}
-
- return;
}
- errorstream << "Invalid bgcolor element(" << parts.size() << "): '" << element << "'"
- << std::endl;
+ // 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);
/*
diff --git a/src/gui/guiFormSpecMenu.h b/src/gui/guiFormSpecMenu.h
index 3a3a74c05..d6c762866 100644
--- a/src/gui/guiFormSpecMenu.h
+++ b/src/gui/guiFormSpecMenu.h
@@ -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;