From 1b3e4e173624bb2523d4386aeef6987709d9b022 Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Tue, 29 Aug 2017 19:25:16 +0200 Subject: Formspec: Add options to set background color and opacity (fullscreen mode + default mode) (#5493) * Formspec: Add options to set background color and opacity (fullscreen mode) * Enhance previous comment: Set formspec background when regenerate UI. * This permit to do the calcul only at regen and override it with bgcolor tag * Add a setting for default background color into formspec, separated from fullscreen * Add a little performance gain on formspecs using a const ref instead of copying formspec string --- src/game.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 17ab68e7c..8a2ca00a2 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -185,6 +185,7 @@ struct LocalFormspecHandler : public TextDest /* Form update callback */ +static const std::string empty_string = ""; class NodeMetadataFormSource: public IFormSource { public: @@ -193,12 +194,12 @@ public: m_p(p) { } - std::string getForm() + const std::string &getForm() const { NodeMetadata *meta = m_map->getNodeMetadata(m_p); if (!meta) - return ""; + return empty_string; return meta->getString("formspec"); } @@ -224,7 +225,8 @@ public: m_client(client) { } - std::string getForm() + + const std::string &getForm() const { LocalPlayer *player = m_client->getEnv().getLocalPlayer(); return player->inventory_formspec; -- cgit v1.2.3